feat: 试用结束的企标自动发起复审流程
This commit is contained in:
+2
-2
@@ -102,7 +102,7 @@ public class ESRecheckPlanJob implements Job {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 构建发起流程数据
|
// 构建发起流程数据
|
||||||
ESRecheckDataVO esRecheckDataVO = this.getEsRecheckDataVO(es, standardizationUser, standardEngineer, recheckPlan.getId());
|
ESRecheckDataVO esRecheckDataVO = getEsRecheckDataVO(es, standardizationUser, standardEngineer, recheckPlan.getId());
|
||||||
// 发起流程
|
// 发起流程
|
||||||
recheckService.autoStartProcess(esRecheckDataVO);
|
recheckService.autoStartProcess(esRecheckDataVO);
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ public class ESRecheckPlanJob implements Job {
|
|||||||
log.info("企标复审计划定时任务执行完成");
|
log.info("企标复审计划定时任务执行完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ESRecheckDataVO getEsRecheckDataVO(LawsEnterpriseStandard es, String standardizationUser, String standardEngineer, String recheckPlanId) {
|
public static ESRecheckDataVO getEsRecheckDataVO(LawsEnterpriseStandard es, String standardizationUser, String standardEngineer, String recheckPlanId) {
|
||||||
ESRecheckDataVO esRecheckDataVO = new ESRecheckDataVO();
|
ESRecheckDataVO esRecheckDataVO = new ESRecheckDataVO();
|
||||||
ProcessEsRecheck recheck = BeanCopyUtils.copyBean(es, ProcessEsRecheck.class);
|
ProcessEsRecheck recheck = BeanCopyUtils.copyBean(es, ProcessEsRecheck.class);
|
||||||
recheck.setId(null);
|
recheck.setId(null);
|
||||||
|
|||||||
+110
@@ -0,0 +1,110 @@
|
|||||||
|
package com.jero.modules.laws.enterprise.job;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||||
|
import com.jero.modules.activiti.process.esRecheck.entity.ProcessEsRecheck;
|
||||||
|
import com.jero.modules.activiti.process.esRecheck.entity.vo.ESRecheckDataVO;
|
||||||
|
import com.jero.modules.activiti.process.esRecheck.service.ProcessEsRecheckService;
|
||||||
|
import com.jero.modules.laws.common.constant.FieldCommon;
|
||||||
|
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardRecheckPlan;
|
||||||
|
import com.jero.modules.laws.enterprise.service.EnterpriseStandardRecheckPlanService;
|
||||||
|
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
|
||||||
|
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
|
||||||
|
import com.jero.modules.laws.system.service.ILawsContactManageService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Mzaxd
|
||||||
|
* @Date: 2023/12/25 13:54
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class ESTrialEndRecheckJob implements Job {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ILawsEnterpriseStandardService esService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProcessEsRecheckService recheckService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseStandardRecheckPlanService esRecheckPlanService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ILawsContactManageService contactManageService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
|
// 找到所有在试用期且没有发过复审流程的企标
|
||||||
|
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
|
||||||
|
esWrapper.eq(LawsEnterpriseStandard::getDelFlag, YesOrNoEnum.NO.getValue());
|
||||||
|
esWrapper.eq(LawsEnterpriseStandard::getTryFlag, YesOrNoEnum.YES.getValue());
|
||||||
|
List<LawsEnterpriseStandard> trialStandards = esService.list(esWrapper);
|
||||||
|
List<LawsEnterpriseStandard> expireStandards = new ArrayList<>();
|
||||||
|
// 找到所有超出试用期的企标
|
||||||
|
Date currentDate = new Date();
|
||||||
|
for (LawsEnterpriseStandard es : trialStandards) {
|
||||||
|
Date releaseDate = es.getReleaseDate();
|
||||||
|
int trialPeriodMonths = Integer.parseInt(String.valueOf(es.getTrialPeriod())); // 将试用周期转换为天数
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(releaseDate);
|
||||||
|
calendar.add(Calendar.MONTH, trialPeriodMonths); // 将试用周期加到发布日期上
|
||||||
|
Date trialEndDate = calendar.getTime(); // 获取试用期结束日期
|
||||||
|
// 超出试用期的企标
|
||||||
|
if (currentDate.compareTo(trialEndDate) > 0) {
|
||||||
|
expireStandards.add(es);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<ProcessEsRecheck> recheckWrapper = new LambdaQueryWrapper<>();
|
||||||
|
recheckWrapper.in(ProcessEsRecheck::getStandardNumber,
|
||||||
|
expireStandards.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()));
|
||||||
|
List<ProcessEsRecheck> recheckList = recheckService.list(recheckWrapper);
|
||||||
|
if (recheckList != null && !recheckList.isEmpty()) {
|
||||||
|
// 找到已经发过复审流程的企标
|
||||||
|
List<String> recheckStandardNumbers = recheckList.stream().map(ProcessEsRecheck::getStandardNumber).collect(Collectors.toList());
|
||||||
|
// 将已经发过复审流程的企标从超出试用期的企标中移除
|
||||||
|
expireStandards = expireStandards.stream().filter(es -> !recheckStandardNumbers.contains(es.getStandardNumber())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
// 发起复审流程
|
||||||
|
for (LawsEnterpriseStandard es : expireStandards) {
|
||||||
|
// 企标已经达到35个月,需要重新复审
|
||||||
|
EnterpriseStandardRecheckPlan recheckPlan = new EnterpriseStandardRecheckPlan();
|
||||||
|
recheckPlan.setStandardId(es.getId());
|
||||||
|
recheckPlan.setStandardNo(es.getStandardNumber());
|
||||||
|
// 加一天
|
||||||
|
Date recheckDate = new Date();
|
||||||
|
recheckPlan.setRecheckDate(recheckDate);
|
||||||
|
esRecheckPlanService.save(recheckPlan);
|
||||||
|
// 自动发起流程
|
||||||
|
// 找到各自企标的联络人,如果找不到联络人则发给标准化工程师
|
||||||
|
String deptId = es.getMainDraftingUnit();
|
||||||
|
String standardNo = es.getStandardNumber();
|
||||||
|
if (StrUtil.isBlank(deptId)) {
|
||||||
|
log.error("企标复审流程发起失败,企标编号为{}的企标部门ID为空,无法找到其联络人", standardNo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String standardizationUser = contactManageService.findContactUserByDept(deptId);
|
||||||
|
String standardEngineer = null;
|
||||||
|
if (StrUtil.isBlank(standardizationUser)) {
|
||||||
|
standardEngineer = contactManageService.findStandardEngineerByDept(deptId);
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(standardizationUser) && StrUtil.isBlank(standardEngineer)) {
|
||||||
|
log.error("企标复审流程发起失败,无法找到企标编号为{}的联络人和标准化工程师", standardNo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 构建发起流程数据
|
||||||
|
ESRecheckDataVO esRecheckDataVO = ESRecheckPlanJob.getEsRecheckDataVO(es, standardizationUser, standardEngineer, recheckPlan.getId());
|
||||||
|
// 发起流程
|
||||||
|
recheckService.autoStartProcess(esRecheckDataVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user