同步符合性流程截止时间定时器开发。
This commit is contained in:
+106
@@ -0,0 +1,106 @@
|
||||
package com.jero.modules.todoCenter.job;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
|
||||
import com.jero.modules.project.service.IProjectLawsInventoryEOService;
|
||||
import com.jero.modules.todoCenter.entity.ProcessInfoEO;
|
||||
import com.jero.modules.todoCenter.service.IProcessInfoEOService;
|
||||
import com.jero.modules.wkflow.enums.FlowTypeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 同步符合性流程截止时间定时器
|
||||
* @Author: wzj
|
||||
* @Date: 2022/11/24 13:48
|
||||
**/
|
||||
@Slf4j
|
||||
public class SyncComplianceProcessEndTimeJob implements Job {
|
||||
@Autowired
|
||||
private IProjectLawsInventoryEOService projectLawsInventoryEOService;
|
||||
@Autowired
|
||||
private IProcessInfoEOService processInfoEOService;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
log.info("同步符合性流程截止时间,定时任务开启 =====================================================");
|
||||
QueryWrapper<ProcessInfoEO> processInfoQueryWrap = new QueryWrapper<>();
|
||||
List<String> flowTypeList = new ArrayList<>();
|
||||
flowTypeList.add(FlowTypeEnum.SJFHXSHLC.getValue());
|
||||
flowTypeList.add(FlowTypeEnum.PREHOMOQRLC.getValue());
|
||||
flowTypeList.add(FlowTypeEnum.YZFHXSCLC.getValue());
|
||||
processInfoQueryWrap.lambda().in(ProcessInfoEO::getFlowType,flowTypeList);
|
||||
List<ProcessInfoEO> processInfoEOList = this.processInfoEOService.list(processInfoQueryWrap);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(processInfoEOList)) {
|
||||
List<String> lawsInventoryIdList = processInfoEOList.stream().map(ProcessInfoEO::getProjectLawsInventoryId).distinct().collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(lawsInventoryIdList)) {
|
||||
QueryWrapper<ProjectLawsInventoryEO> lawsInventoryQueryWrap = new QueryWrapper<>();
|
||||
lawsInventoryQueryWrap.lambda().in(ProjectLawsInventoryEO::getId,lawsInventoryIdList);
|
||||
List<ProjectLawsInventoryEO> lawsInventoryEOList = this.projectLawsInventoryEOService.list(lawsInventoryQueryWrap);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(lawsInventoryEOList)) {
|
||||
processInfoEOList.forEach(processInfo -> {
|
||||
this.setProcessInfoEndTime(lawsInventoryEOList, processInfo);
|
||||
});
|
||||
this.processInfoEOService.updateBatchById(processInfoEOList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
log.info("同步符合性流程截止时间,定时任务结束 =====================================================");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置流程信息的截止时间。
|
||||
* @param lawsInventoryEOList
|
||||
* @param processInfoEO
|
||||
*/
|
||||
private void setProcessInfoEndTime(List<ProjectLawsInventoryEO> lawsInventoryEOList, ProcessInfoEO processInfoEO) {
|
||||
for (ProjectLawsInventoryEO projectLawsInventoryEO : lawsInventoryEOList) {
|
||||
if(StringUtils.equals(processInfoEO.getProjectLawsInventoryId(),projectLawsInventoryEO.getId())){
|
||||
String flowType = processInfoEO.getFlowType();
|
||||
|
||||
// 停止循环标识
|
||||
boolean stopCycle = false;
|
||||
FlowTypeEnum flowTypeEnumByValue = FlowTypeEnum.getFlowTypeEnumByValue(flowType);
|
||||
switch (flowTypeEnumByValue){
|
||||
case SJFHXSHLC:
|
||||
if(projectLawsInventoryEO.getDesignDueDate() != null){
|
||||
processInfoEO.setEndTime(projectLawsInventoryEO.getDesignDueDate());
|
||||
stopCycle = true;
|
||||
}
|
||||
break;
|
||||
case PREHOMOQRLC:
|
||||
if(projectLawsInventoryEO.getPrehomoDueDate() != null){
|
||||
processInfoEO.setEndTime(projectLawsInventoryEO.getPrehomoDueDate());
|
||||
stopCycle = true;
|
||||
}
|
||||
break;
|
||||
case YZFHXSCLC:
|
||||
if(projectLawsInventoryEO.getVerifyDueDate() != null){
|
||||
processInfoEO.setEndTime(projectLawsInventoryEO.getVerifyDueDate());
|
||||
stopCycle = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// 匹配到一个之后,将本次循环终止。
|
||||
if (stopCycle) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -74,4 +74,19 @@ public enum FlowTypeEnum {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据value获取枚举对象。
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static FlowTypeEnum getFlowTypeEnumByValue(String value) {
|
||||
FlowTypeEnum[] flowTypeEnumArr = FlowTypeEnum.values();
|
||||
for (FlowTypeEnum flowTypeEnum : flowTypeEnumArr) {
|
||||
if(StringUtils.equals(value,flowTypeEnum.getValue())){
|
||||
return flowTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user