流程相关-发送飞书消息。

This commit is contained in:
wangzhijiang
2023-03-22 22:19:58 +08:00
parent 5385a892f8
commit e92b3a30b9
4 changed files with 236 additions and 18 deletions
@@ -18,7 +18,7 @@ public enum TemplateInfoEnum2 {
CERTIFICATION_MESSAGE10("认证工程师发起流程,责任人收到消息","ctp_AAuePL6rUK1L"),
CERTIFICATION_MESSAGE11("责任人拒绝,认证工程师收到消息","ctp_AAu2ZrSEiB1V"),
CERTIFICATION_MESSAGE12("责任人接受,认证工程师收到消息","ctp_AAuePL6r3B0I"),
CERTIFICATION_MESSAGE13("studio修改认证工程师,被修改人收到消息",""),
CERTIFICATION_MESSAGE13("studio修改认证工程师,被修改人收到消息","ctp_AAuLRr2QhG9J"),
CERTIFICATION_MESSAGE14("studio修改符合性截止时间,认证工程师收到消息","ctp_AAuePL6r3XqN"),
CERTIFICATION_MESSAGE15("认证工程师修改责任人,被修改人收到消息","ctp_AAu2ZrSE1z3f"),
CERTIFICATION_MESSAGE16("认证工程师催办,责任人收到消息","ctp_AAuPfn0M0H6i"),
@@ -52,6 +52,21 @@ public enum TemplateInfoEnum2 {
REGULATION_TASK_CONFIRMATION5("法规任务确认-公用消息-红色-有流程类型","ctp_AAuPWTSU2Fg2"),
REGULATION_TASK_CONFIRMATION6("法规任务确认-公用消息-黄色-有流程类型","ctp_AAuLRr2Qzkbo"),
/**
* 设计符合性流程
*/
DESIGN_COMPLIANCE_CONFIRMATION1("设计符合性流程-公用消息-绿色","ctp_AAuPIdaoms57"),
DESIGN_COMPLIANCE_CONFIRMATION2("设计符合性流程-公用消息-红色","ctp_AAuLRr2QX8xb"),
DESIGN_COMPLIANCE_CONFIRMATION3("设计符合性流程-公用消息-黄色","ctp_AAuLdvF0lUtu"),
/**
* 验证符合性流程
*/
VALIDATION_COMPLIANCE_CONFIRMATION1("验证符合性流程-公用消息-绿色","ctp_AAuLdvF0lS41"),
VALIDATION_COMPLIANCE_CONFIRMATION2("验证符合性流程-公用消息-红色","ctp_AAu2lBI6MV0i"),
VALIDATION_COMPLIANCE_CONFIRMATION3("验证符合性流程-公用消息-黄色","ctp_AAupcD3RBbUV"),
;
String name;
@@ -254,13 +254,13 @@ public class CertificationInventoryJob implements Job {
Calendar sevenCalendar=new GregorianCalendar();
sevenCalendar.setTime(new Date());
sevenCalendar.add(Calendar.DATE,7);
Date sevenDays = sevenCalendar.getTime(); //fourteen
Date sevenDays = sevenCalendar.getTime();
//获取后十四天后的时间
Calendar fourteenCalendar=new GregorianCalendar();
fourteenCalendar.setTime(new Date());
fourteenCalendar.add(Calendar.DATE,14);
Date fourteenDays = fourteenCalendar.getTime(); //fourteen
Date fourteenDays = fourteenCalendar.getTime();
String threeDaysStr = sdf.format(threeDays);
String sevenDaysStr = sdf.format(sevenDays);
@@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.constant.enums.MessageType2Enum;
import com.jero.common.constant.enums.MessageTypeEnum;
import com.jero.common.constant.enums.MsgColorEnum;
import com.jero.common.util.DateUtils;
import com.jero.modules.document.entity.BussDocumentLibraryEO;
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
import com.jero.modules.feishu.enums.TemplateInfoEnum2;
import com.jero.modules.feishu.service.IFeishuService;
import com.jero.modules.feishu.vo.FeishuMsg2Vo;
import com.jero.modules.feishu.vo.FeishuMsgVo;
import com.jero.modules.project.entity.*;
import com.jero.modules.project.enums.ComplianceFlowStatusEnum;
import com.jero.modules.project.enums.DesignComplianceStatusEnum;
import com.jero.modules.project.enums.JumpLinkEnum;
import com.jero.modules.project.enums.SendMsgFlagEnum;
@@ -68,12 +71,112 @@ public class designComplianceJob implements Job {
private ISysUserService sysUserService;
@Autowired
private IFeishuService feishuService;
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
log.info("设计符合性确认流程,定时任务开启 =====================================================");
// 查询出 任务待确认、结果待提交的数据
List<String> designFlowStatusList = new ArrayList<>();
designFlowStatusList.add(ComplianceFlowStatusEnum.TASK_TO_BE_CONFIRMED.getValue());
designFlowStatusList.add(ComplianceFlowStatusEnum.RESULTS_TO_BE_SUBMITTED.getValue());
QueryWrapper<ProjectLawsInventoryEO> lawsInventoryEOQueryWrap = new QueryWrapper<>();
lawsInventoryEOQueryWrap.lambda().in(ProjectLawsInventoryEO::getDesignFlowStatus,designFlowStatusList);
List<ProjectLawsInventoryEO> projectLawsInventoryEOList = this.projectLawsInventoryEOService.list(lawsInventoryEOQueryWrap);
if(CollectionUtils.isNotEmpty(projectLawsInventoryEOList)){
// 根据项目进行分组
Map<String, List<ProjectLawsInventoryEO>> lawsInventoryByProjectLibraryIdGroupMap = projectLawsInventoryEOList.stream().collect(Collectors.groupingBy(ProjectLawsInventoryEO::getProjectLibraryId));
for (Map.Entry<String, List<ProjectLawsInventoryEO>> lawsInventoryByProjectLibraryIdGroup : lawsInventoryByProjectLibraryIdGroupMap.entrySet()) {
String projectLibraryId = lawsInventoryByProjectLibraryIdGroup.getKey();
List<ProjectLawsInventoryEO> lawsInventoryListByProjectLibraryId = lawsInventoryByProjectLibraryIdGroup.getValue();
if(StringUtils.isEmpty(projectLibraryId) || CollectionUtils.isEmpty(lawsInventoryListByProjectLibraryId)){
continue;
}
// 设计符合性
Map<String, List<ProjectLawsInventoryEO>> lawsInventoryByDesignDutyIdGroupMap = lawsInventoryListByProjectLibraryId.stream().collect(Collectors.groupingBy(ProjectLawsInventoryEO::getDesignDutyId));
for (Map.Entry<String, List<ProjectLawsInventoryEO>> lawsInventoryByDesignDutyIdGroup : lawsInventoryByDesignDutyIdGroupMap.entrySet()) {
String designDutyId = lawsInventoryByDesignDutyIdGroup.getKey();
List<ProjectLawsInventoryEO> designDutyDataList = lawsInventoryByDesignDutyIdGroup.getValue();
if(StringUtils.isEmpty(designDutyId) || CollectionUtils.isEmpty(designDutyDataList)){
continue;
}
List<String> userIdList = Arrays.asList(designDutyId.split(","));
Map<String, Object> sendMsgDataListMap = this.disposeSendMsgDataList(designDutyDataList);
// 三条后结束的
List<ProjectLawsInventoryEO> threeDaysList = (List<ProjectLawsInventoryEO>) sendMsgDataListMap.get("threeDaysList");
if(CollectionUtils.isNotEmpty(threeDaysList)){
Date designDueDate = threeDaysList.get(0).getDesignDueDate();
String endTime = "";
if(designDueDate != null){
endTime = DateUtils.formatDate(designDueDate);
}
String serialNumbers = threeDaysList.stream().map(ProjectLawsInventoryEO::getSerialNumber).distinct().collect(Collectors.joining(","));
// 给法规工程师发消息
Map<String,Object> params = new HashMap<>();
params.put("contentCn","您好,以下待办任务距离截止日期仅剩3天,请及时查看处理。");
params.put("contentEn","Hello! This task will expire in 3 days. Please check and address it in a timely manner. Thank you!");
params.put("projectLibraryId",projectLibraryId);
params.put("endTime",endTime);
params.put("userIdList",userIdList);
params.put("serialNumbers",serialNumbers);
params.put("flowTypeCn","设计符合性流程");
params.put("flowTypeEn","Design Compliance Process");
this.projectLawsInventoryEOService.sendMessageByTemplateId(TemplateInfoEnum2.REGULATION_TASK_CONFIRMATION4.getValue(),params);
}
// 当天结束的
List<ProjectLawsInventoryEO> currentDaysList = (List<ProjectLawsInventoryEO>) sendMsgDataListMap.get("currentDaysList");
if(CollectionUtils.isNotEmpty(currentDaysList)){
Date designDueDate = currentDaysList.get(0).getDesignDueDate();
String endTime = "";
if(designDueDate != null){
endTime = DateUtils.formatDate(designDueDate);
}
String serialNumbers = currentDaysList.stream().map(ProjectLawsInventoryEO::getSerialNumber).distinct().collect(Collectors.joining(","));
// 给法规工程师发消息
Map<String,Object> params = new HashMap<>();
params.put("contentCn","您好,以下待办任务已到截止日期,请尽快查看处理。");
params.put("contentEn","Hello! This task will expire today. Please check and address it ASAP. Thank you!");
params.put("projectLibraryId",projectLibraryId);
params.put("endTime",endTime);
params.put("userIdList",userIdList);
params.put("serialNumbers",serialNumbers);
params.put("flowTypeCn","设计符合性流程");
params.put("flowTypeEn","Design Compliance Process");
this.projectLawsInventoryEOService.sendMessageByTemplateId(TemplateInfoEnum2.REGULATION_TASK_CONFIRMATION4.getValue(),params);
}
// 逾期的
List<ProjectLawsInventoryEO> overdueList = (List<ProjectLawsInventoryEO>) sendMsgDataListMap.get("overdueList");
if(CollectionUtils.isNotEmpty(overdueList)){
Date designDueDate = overdueList.get(0).getDesignDueDate();
String endTime = "";
if(designDueDate != null){
endTime = DateUtils.formatDate(designDueDate);
}
String serialNumbers = overdueList.stream().map(ProjectLawsInventoryEO::getSerialNumber).distinct().collect(Collectors.joining(","));
// 给法规工程师发消息
Map<String,Object> params = new HashMap<>();
params.put("contentCn","您好,以下待办任务已逾期,请尽快处理。");
params.put("contentEn","Hello! This task is overdue. Please address it ASAP. Thank you!");
params.put("projectLibraryId",projectLibraryId);
params.put("endTime",endTime);
params.put("userIdList",userIdList);
params.put("serialNumbers",serialNumbers);
params.put("flowTypeCn","设计符合性流程");
params.put("flowTypeEn","Design Compliance Process");
this.projectLawsInventoryEOService.sendMessageByTemplateId(TemplateInfoEnum2.REGULATION_TASK_CONFIRMATION5.getValue(),params);
}
}
}
}
//查询出已经启动了设计符合性流程的数据。 并且流程没有结束。
QueryWrapper<ProjectTaskInventoryEO> queryProjectTaskInventoryWrapper = new QueryWrapper<>();
/*QueryWrapper<ProjectTaskInventoryEO> queryProjectTaskInventoryWrapper = new QueryWrapper<>();
queryProjectTaskInventoryWrapper.isNotNull("design_p_id");
List<String> status = new ArrayList<>();
status.add(DesignComplianceStatusEnum.TO_SUBMIT.getValue());
@@ -378,7 +481,76 @@ public class designComplianceJob implements Job {
}
}
}
}
}*/
log.info("设计符合性确认流程,定时任务结束 =====================================================");
}
private Map<String, Object> disposeSendMsgDataList(List<ProjectLawsInventoryEO> projectLawsInventoryEOList) {
Map<String,Object> result = new HashMap<>();
Date currentDate = new Date();
String currentDateStr = sdf.format(currentDate);
//获取十四天后的时间
Calendar fourteenCalendar=new GregorianCalendar();
fourteenCalendar.setTime(new Date());
fourteenCalendar.add(Calendar.DATE,14);
Date fourteenDays = fourteenCalendar.getTime();
String fourteenDaysStr = sdf.format(fourteenDays);
//获取七天后的时间
Calendar sevenCalendar=new GregorianCalendar();
sevenCalendar.setTime(new Date());
sevenCalendar.add(Calendar.DATE,7);
Date sevenDays = sevenCalendar.getTime();
String sevenDaysStr = sdf.format(sevenDays);
// 十四天后结束的
List<ProjectLawsInventoryEO> fourteenDaysList = projectLawsInventoryEOList.stream().filter(data -> {
boolean flag = false;
if(data.getDesignDueDate() != null){
if (StringUtils.equals(fourteenDaysStr, sdf.format(data.getDesignDueDate()))) {
flag = true;
}
}
return flag;
}).collect(Collectors.toList());
// 七天后结束的
List<ProjectLawsInventoryEO> threeDaysList = projectLawsInventoryEOList.stream().filter(data -> {
boolean flag = false;
if(data.getDesignDueDate() != null){
if (StringUtils.equals(sevenDaysStr, sdf.format(data.getDesignDueDate()))) {
flag = true;
}
}
return flag;
}).collect(Collectors.toList());
// 当天结束的
List<ProjectLawsInventoryEO> currentDaysList = projectLawsInventoryEOList.stream().filter(data -> {
boolean flag = false;
//结束日期是当前日期
if(data.getDesignDueDate() != null){
if (StringUtils.equals(currentDateStr, sdf.format(data.getDesignDueDate()))) {
flag = true;
}
}
return flag;
}).collect(Collectors.toList());
// 逾期的
List<ProjectLawsInventoryEO> overdueList = projectLawsInventoryEOList.stream().filter(data -> {
// 只要早于当前日期都算逾期 不算当天。
boolean flag = false;
if(data.getDesignDueDate() != null){
flag = (data.getDesignDueDate().before(currentDate) && !StringUtils.equals(currentDateStr, sdf.format(data.getDesignDueDate())));
}
return flag;
}).collect(Collectors.toList());
result.put("currentDaysList",currentDaysList);
result.put("threeDaysList",threeDaysList);
result.put("overdueList",overdueList);
return result;
}
}
@@ -12,15 +12,8 @@ import com.jero.common.system.vo.LoginUser;
import com.jero.modules.cert.collect.service.IParamsManifestEOService;
import com.jero.modules.dummy.enums.OrderEnum;
import com.jero.modules.enums.DictCodeEnum;
import com.jero.modules.project.entity.ConditionAssessmentEO;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
import com.jero.modules.project.entity.ProjectLawsInventoryLogEO;
import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.entity.ProjectLibraryRoleRelEO;
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
import com.jero.modules.project.entity.ProjectTaskInventoryEO;
import com.jero.modules.project.entity.ProjectTaskPlanning;
import com.jero.modules.project.entity.ProjectUserPermission;
import com.jero.modules.feishu.enums.TemplateInfoEnum2;
import com.jero.modules.project.entity.*;
import com.jero.modules.project.enums.*;
import com.jero.modules.project.mapper.ProjectLawsInventoryEOMapper;
import com.jero.modules.project.mapper.ProjectLibraryBaseMapper;
@@ -28,10 +21,7 @@ import com.jero.modules.project.mapper.ProjectNameInfoEOMapper;
import com.jero.modules.project.mapper.ProjectRelatedPersonnelMapper;
import com.jero.modules.project.mapper.ProjectTaskInventoryEOMapper;
import com.jero.modules.project.mapper.ProjectUserPermissionMapper;
import com.jero.modules.project.service.IConditionAssessmentEOService;
import com.jero.modules.project.service.IProjectLibraryBaseService;
import com.jero.modules.project.service.IProjectLibraryRoleRelEOService;
import com.jero.modules.project.service.IProjectUserPermissionService;
import com.jero.modules.project.service.*;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.enums.DicCodeEnum;
@@ -154,6 +144,9 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
@Autowired
private ITopProjectEOService iTopProjectEOService;
@Autowired
private IProjectCertificationInventoryEOService projectCertificationInventoryEOService;
/**
* 保存
*
@@ -379,6 +372,44 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
ProjectLibraryBase original = baseMapper.selectById(projectLibraryBase.getId());
// 如果studio编辑了认证工程师,需要给旧的认证工程师发送认证清单任务消息
if(StringUtils.isNotEmpty(projectLibraryBase.getCertificationEngineer()) && StringUtils.isNotEmpty(original.getCertificationEngineer())){
List<String> originalCertificationEngineerIdList = Arrays.asList(original.getCertificationEngineer().split(","));
List<String> newCertificationEngineerIdList = Arrays.asList(projectLibraryBase.getCertificationEngineer().split(","));
originalCertificationEngineerIdList = originalCertificationEngineerIdList.stream().filter(originalCertificationEngineerId -> {
boolean flag = true;
for (String newCertificationEngineerId : newCertificationEngineerIdList) {
// 如果新传进来的 认证工程师id跟现有的认证工程师id一致,不用发消息
if(StringUtils.equals(newCertificationEngineerId,originalCertificationEngineerId)){
flag = false;
break;
}
}
return flag;
}).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(originalCertificationEngineerIdList)){
// 判断当前项目下是否还有需要认证工程师操作的数据 只有清单待校核、结果待审查 这两个状态的数据由认证工程师操作。
List<String> flowStatusList = new ArrayList<>();
flowStatusList.add(CertificationInventoryFlowStatusEnum.LIST_TO_BE_CHECKED.getValue());
flowStatusList.add(CertificationInventoryFlowStatusEnum.RESULTS_TO_BE_REVIEWED.getValue());
QueryWrapper<ProjectCertificationInventoryEO> certificationInventoryEOQueryWrapper = new QueryWrapper<>();
certificationInventoryEOQueryWrapper.lambda().eq(ProjectCertificationInventoryEO::getProjectLibraryId,projectLibraryBase.getId());
certificationInventoryEOQueryWrapper.lambda().in(ProjectCertificationInventoryEO::getFlowStatus,flowStatusList);
List<ProjectCertificationInventoryEO> projectCertificationInventoryEOList = this.projectCertificationInventoryEOService.list(certificationInventoryEOQueryWrapper);
if(CollectionUtils.isNotEmpty(projectCertificationInventoryEOList)){
List<SysUser> userInfoList = this.sysUserService.querySysUserListByIdList(originalCertificationEngineerIdList);
this.projectCertificationInventoryEOService.sendMessageByTemplateId(
projectCertificationInventoryEOList,
TemplateInfoEnum2.CERTIFICATION_MESSAGE13.getValue(),
originalCertificationEngineerIdList,
userInfoList
);
}
}
}
checkExitData(projectLibraryBase);
saveOrUpdate(projectLibraryBase);