法规任务确认-定时任务发送消息。
This commit is contained in:
+239
-1
@@ -4,23 +4,28 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.jero.common.constant.enums.MessageType2Enum;
|
import com.jero.common.constant.enums.MessageType2Enum;
|
||||||
import com.jero.common.constant.enums.MessageTypeEnum;
|
import com.jero.common.constant.enums.MessageTypeEnum;
|
||||||
import com.jero.common.constant.enums.MsgColorEnum;
|
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.entity.BussDocumentLibraryEO;
|
||||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
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.service.IFeishuService;
|
||||||
import com.jero.modules.feishu.vo.FeishuMsg2Vo;
|
import com.jero.modules.feishu.vo.FeishuMsg2Vo;
|
||||||
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
|
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
|
||||||
import com.jero.modules.project.entity.ProjectLibraryBase;
|
import com.jero.modules.project.entity.ProjectLibraryBase;
|
||||||
import com.jero.modules.project.entity.ProjectNameInfoEO;
|
import com.jero.modules.project.entity.ProjectNameInfoEO;
|
||||||
import com.jero.modules.project.entity.ProjectYearNameInfoEO;
|
import com.jero.modules.project.entity.ProjectYearNameInfoEO;
|
||||||
|
import com.jero.modules.project.enums.ComplianceFlowStatusEnum;
|
||||||
import com.jero.modules.project.enums.InventoryAffirmStatusEnum;
|
import com.jero.modules.project.enums.InventoryAffirmStatusEnum;
|
||||||
import com.jero.modules.project.enums.JumpLinkEnum;
|
import com.jero.modules.project.enums.JumpLinkEnum;
|
||||||
import com.jero.modules.project.mapper.ProjectLawsInventoryEOMapper;
|
import com.jero.modules.project.mapper.ProjectLawsInventoryEOMapper;
|
||||||
import com.jero.modules.project.mapper.ProjectLibraryBaseMapper;
|
import com.jero.modules.project.mapper.ProjectLibraryBaseMapper;
|
||||||
import com.jero.modules.project.mapper.ProjectNameInfoEOMapper;
|
import com.jero.modules.project.mapper.ProjectNameInfoEOMapper;
|
||||||
import com.jero.modules.project.mapper.ProjectYearNameInfoEOMapper;
|
import com.jero.modules.project.mapper.ProjectYearNameInfoEOMapper;
|
||||||
|
import com.jero.modules.project.service.IProjectLawsInventoryEOService;
|
||||||
import com.jero.modules.system.entity.SysUser;
|
import com.jero.modules.system.entity.SysUser;
|
||||||
import com.jero.modules.system.service.ISysUserService;
|
import com.jero.modules.system.service.ISysUserService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
@@ -60,6 +65,11 @@ public class TaskAffirmJob implements Job {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IBussDocumentLibraryEOService bussDocumentLibraryEOService;
|
private IBussDocumentLibraryEOService bussDocumentLibraryEOService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IProjectLawsInventoryEOService projectLawsInventoryEOService;
|
||||||
|
|
||||||
|
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务确认流程定时
|
* 任务确认流程定时
|
||||||
@@ -71,6 +81,183 @@ public class TaskAffirmJob implements Job {
|
|||||||
log.info("任务确认流程,定时任务开启 =====================================================");
|
log.info("任务确认流程,定时任务开启 =====================================================");
|
||||||
|
|
||||||
QueryWrapper<ProjectLawsInventoryEO> queryWrapperInventory = new QueryWrapper<>();
|
QueryWrapper<ProjectLawsInventoryEO> queryWrapperInventory = new QueryWrapper<>();
|
||||||
|
// 获取出 任务待确认 的数据(这个状态的数据任务在责任人上)
|
||||||
|
queryWrapperInventory.and(queryWrapper -> {
|
||||||
|
queryWrapper.lambda().eq(ProjectLawsInventoryEO::getDesignFlowStatus, ComplianceFlowStatusEnum.TASK_TO_BE_CONFIRMED.getValue());
|
||||||
|
});
|
||||||
|
List<ProjectLawsInventoryEO> projectLawsInventoryEOList = projectLawsInventoryEOMapper.selectList(queryWrapperInventory);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 验证符合性
|
||||||
|
Map<String, List<ProjectLawsInventoryEO>> lawsInventoryByVerifyDutyIdGroupMap = lawsInventoryListByProjectLibraryId.stream().collect(Collectors.groupingBy(ProjectLawsInventoryEO::getVerifyDutyId));
|
||||||
|
|
||||||
|
for (Map.Entry<String, List<ProjectLawsInventoryEO>> lawsInventoryByVerifyDutyIdGroup : lawsInventoryByVerifyDutyIdGroupMap.entrySet()) {
|
||||||
|
String verifyDutyId = lawsInventoryByVerifyDutyIdGroup.getKey();
|
||||||
|
List<ProjectLawsInventoryEO> verifyDutyDataList = lawsInventoryByVerifyDutyIdGroup.getValue();
|
||||||
|
if(StringUtils.isEmpty(verifyDutyId) || CollectionUtils.isEmpty(verifyDutyDataList)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> userIdList = Arrays.asList(verifyDutyId.split(","));
|
||||||
|
|
||||||
|
Map<String, Object> sendMsgDataListMap = this.disposeSendMsgDataList(verifyDutyDataList);
|
||||||
|
|
||||||
|
// 三条后结束的
|
||||||
|
List<ProjectLawsInventoryEO> threeDaysList = (List<ProjectLawsInventoryEO>) sendMsgDataListMap.get("threeDaysList");
|
||||||
|
if(CollectionUtils.isNotEmpty(threeDaysList)){
|
||||||
|
Date verifyDueDate = threeDaysList.get(0).getVerifyDueDate();
|
||||||
|
String endTime = "";
|
||||||
|
if(verifyDueDate != null){
|
||||||
|
endTime = DateUtils.formatDate(verifyDueDate);
|
||||||
|
}
|
||||||
|
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","Validation Compliance Process");
|
||||||
|
this.projectLawsInventoryEOService.sendMessageByTemplateId(TemplateInfoEnum2.REGULATION_TASK_CONFIRMATION4.getValue(),params);
|
||||||
|
}
|
||||||
|
// 当天结束的
|
||||||
|
List<ProjectLawsInventoryEO> currentDaysList = (List<ProjectLawsInventoryEO>) sendMsgDataListMap.get("currentDaysList");
|
||||||
|
if(CollectionUtils.isNotEmpty(currentDaysList)){
|
||||||
|
Date verifyDueDate = currentDaysList.get(0).getVerifyDueDate();
|
||||||
|
String endTime = "";
|
||||||
|
if(verifyDueDate != null){
|
||||||
|
endTime = DateUtils.formatDate(verifyDueDate);
|
||||||
|
}
|
||||||
|
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","Validation Compliance Process");
|
||||||
|
this.projectLawsInventoryEOService.sendMessageByTemplateId(TemplateInfoEnum2.REGULATION_TASK_CONFIRMATION4.getValue(),params);
|
||||||
|
}
|
||||||
|
// 逾期的
|
||||||
|
List<ProjectLawsInventoryEO> overdueList = (List<ProjectLawsInventoryEO>) sendMsgDataListMap.get("overdueList");
|
||||||
|
if(CollectionUtils.isNotEmpty(overdueList)){
|
||||||
|
Date verifyDueDate = overdueList.get(0).getVerifyDueDate();
|
||||||
|
String endTime = "";
|
||||||
|
if(verifyDueDate != null){
|
||||||
|
endTime = DateUtils.formatDate(verifyDueDate);
|
||||||
|
}
|
||||||
|
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","Validation Compliance Process");
|
||||||
|
this.projectLawsInventoryEOService.sendMessageByTemplateId(TemplateInfoEnum2.REGULATION_TASK_CONFIRMATION5.getValue(),params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*QueryWrapper<ProjectLawsInventoryEO> queryWrapperInventory = new QueryWrapper<>();
|
||||||
queryWrapperInventory.lambda().eq(ProjectLawsInventoryEO::getTaskAffirmStatus, InventoryAffirmStatusEnum.LIST_TO_CONFIRM.getValue());
|
queryWrapperInventory.lambda().eq(ProjectLawsInventoryEO::getTaskAffirmStatus, InventoryAffirmStatusEnum.LIST_TO_CONFIRM.getValue());
|
||||||
List<ProjectLawsInventoryEO> projectLawsInventoryEOList = projectLawsInventoryEOMapper.selectList(queryWrapperInventory);
|
List<ProjectLawsInventoryEO> projectLawsInventoryEOList = projectLawsInventoryEOMapper.selectList(queryWrapperInventory);
|
||||||
if (ObjectUtils.isNotEmpty(projectLawsInventoryEOList)) {
|
if (ObjectUtils.isNotEmpty(projectLawsInventoryEOList)) {
|
||||||
@@ -290,8 +477,59 @@ public class TaskAffirmJob implements Job {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
log.info("任务确认流程,定时任务结束 =====================================================");
|
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 calendar=new GregorianCalendar();
|
||||||
|
calendar.setTime(new Date());
|
||||||
|
calendar.add(Calendar.DATE,3);
|
||||||
|
Date threeDays = calendar.getTime();
|
||||||
|
String threeDaysStr = sdf.format(threeDays);
|
||||||
|
|
||||||
|
// 当天结束的
|
||||||
|
List<ProjectLawsInventoryEO> currentDaysList = projectLawsInventoryEOList.stream().filter(data -> {
|
||||||
|
boolean flag = false;
|
||||||
|
//结束日期是当前日期
|
||||||
|
if(data.getInventoryAffirmDueDate() != null){
|
||||||
|
if (StringUtils.equals(currentDateStr, sdf.format(data.getInventoryAffirmDueDate()))) {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 三天后结束的
|
||||||
|
List<ProjectLawsInventoryEO> threeDaysList = projectLawsInventoryEOList.stream().filter(data -> {
|
||||||
|
boolean flag = false;
|
||||||
|
if(data.getInventoryAffirmDueDate() != null){
|
||||||
|
if (StringUtils.equals(threeDaysStr, sdf.format(data.getInventoryAffirmDueDate()))) {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 逾期的
|
||||||
|
List<ProjectLawsInventoryEO> overdueList = projectLawsInventoryEOList.stream().filter(data -> {
|
||||||
|
// 只要早于当前日期都算逾期 不算当天。
|
||||||
|
boolean flag = false;
|
||||||
|
if(data.getInventoryAffirmDueDate() != null){
|
||||||
|
flag = (data.getInventoryAffirmDueDate().before(currentDate) && !StringUtils.equals(currentDateStr, sdf.format(data.getInventoryAffirmDueDate())));
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
result.put("currentDaysList",currentDaysList);
|
||||||
|
result.put("threeDaysList",threeDaysList);
|
||||||
|
result.put("overdueList",overdueList);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user