feat: 企标复审复审日期更新逻辑

This commit is contained in:
2024-01-15 16:01:55 +08:00
parent 0c2d60fe5e
commit e333f900aa
3 changed files with 51 additions and 20 deletions
@@ -74,10 +74,14 @@ public class ProcessESRecheckEndListener implements ExecutionListener {
// 继续有效 // 继续有效
plan.setRecheckResult(RECHECK_CONTINUE_VALID); plan.setRecheckResult(RECHECK_CONTINUE_VALID);
Date recheckDate = plan.getRecheckDate(); Date recheckDate = plan.getRecheckDate();
// 发布日期加6 // 复审日期再加3
Date nextRecheckDate = new Date(recheckDate.getTime() + (3 * 365 - 1) * 24 * 60 * 60 * 1000L); Date nextRecheckDate = new Date(recheckDate.getTime() + (3 * 365 - 1) * 24 * 60 * 60 * 1000L);
plan.setRecheckDate(nextRecheckDate); plan.setRecheckDate(nextRecheckDate);
esRecheckPlanService.updateById(plan); esRecheckPlanService.updateById(plan);
LambdaUpdateWrapper<LawsEnterpriseStandard> esWrapper = new LambdaUpdateWrapper<>();
esWrapper.eq(LawsEnterpriseStandard::getStandardNumber, standNo);
esWrapper.set(LawsEnterpriseStandard::getStandardState, StandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue());
esService.update(esWrapper);
} }
if (RECHECK_INIT_CHANGE.equals(recheckAdvice)) { if (RECHECK_INIT_CHANGE.equals(recheckAdvice)) {
// 修订 自动发起企标立项/变更流程(修订模式) // 修订 自动发起企标立项/变更流程(修订模式)
@@ -75,4 +75,8 @@ public class EnterpriseStandardRecheckPlan implements Serializable {
/**复审结果*/ /**复审结果*/
@ApiModelProperty(value = "复审结果") @ApiModelProperty(value = "复审结果")
private String recheckResult; private String recheckResult;
/**是否在流程中 0不在 1在*/
@ApiModelProperty(value = "是否在流程中 0不在 1在")
private String inProcessFlag;
} }
@@ -57,8 +57,6 @@ public class ESRecheckPlanJob implements Job {
for (LawsEnterpriseStandard es : allEs) { for (LawsEnterpriseStandard es : allEs) {
// 根据企标发布日期判断是否当前已经达到35个月 // 根据企标发布日期判断是否当前已经达到35个月
// 请确保es.getReleaseDate()返回的是Date类型的实例
if (es.getReleaseDate() == null) { if (es.getReleaseDate() == null) {
log.info("无法找到企标编号为{}的发布日期,无法进行复审计划定时任务", es.getStandardNumber()); log.info("无法找到企标编号为{}的发布日期,无法进行复审计划定时任务", es.getStandardNumber());
continue; continue;
@@ -85,32 +83,57 @@ public class ESRecheckPlanJob implements Job {
recheckPlan.setRecheckDate(recheckDate); recheckPlan.setRecheckDate(recheckDate);
esRecheckPlanService.save(recheckPlan); esRecheckPlanService.save(recheckPlan);
// 自动发起流程 // 自动发起流程
// 找到各自企标的联络人,如果找不到联络人则发给标准化工程师 autoStartProcess(es, recheckPlan);
String deptId = es.getMainDraftingUnit(); } else {
String standardNo = es.getStandardNumber(); // 如果已经有复审计划,则需要判断是否到达复审日期前一个月,如果到达则需要发起流程,已经发起过流程的不能重复发送
if (StrUtil.isBlank(deptId)) { EnterpriseStandardRecheckPlan recheckPlan = recheckPlans.get(0);
log.error("企标复审流程发起失败,企标编号为{}的企标部门ID为空,无法找到其联络人", standardNo); Date recheckDate = recheckPlan.getRecheckDate();
LocalDate recheckLocalDate = recheckDate.toInstant().atZone(ZoneId.of("Asia/Shanghai")).toLocalDate();
LocalDate minusMonths = recheckLocalDate.minusMonths(1);
if (recheckPlan.getInProcessFlag().equals(YesOrNoEnum.YES.getValue())) {
// 已经发起过流程,不需要重复发起
continue; continue;
} }
String standardizationUser = contactManageService.findContactUserByDept(deptId); if (minusMonths.isBefore(recheckLocalDate)) {
String standardEngineer = null; autoStartProcess(es, recheckPlan);
if (StrUtil.isBlank(standardizationUser)) {
standardEngineer = contactManageService.findStandardEngineerByDept(deptId);
} }
if (StrUtil.isBlank(standardizationUser) && StrUtil.isBlank(standardEngineer)) {
log.error("企标复审流程发起失败,无法找到企标编号为{}的联络人和标准化工程师", standardNo);
continue;
}
// 构建发起流程数据
ESRecheckDataVO esRecheckDataVO = getEsRecheckDataVO(es, standardizationUser, standardEngineer, recheckPlan);
// 发起流程
recheckService.autoStartProcess(esRecheckDataVO);
} }
} }
} }
log.info("企标复审计划定时任务执行完成"); log.info("企标复审计划定时任务执行完成");
} }
/**
* 自动发起流程
* @param es 企标
* @param recheckPlan 复审计划
*/
private void autoStartProcess(LawsEnterpriseStandard es, EnterpriseStandardRecheckPlan recheckPlan) {
// 找到各自企标的联络人,如果找不到联络人则发给标准化工程师
String deptId = es.getMainDraftingUnit();
String standardNo = es.getStandardNumber();
if (StrUtil.isBlank(deptId)) {
log.error("企标复审流程发起失败,企标编号为{}的企标部门ID为空,无法找到其联络人", standardNo);
return;
}
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);
return;
}
// 构建发起流程数据
ESRecheckDataVO esRecheckDataVO = getEsRecheckDataVO(es, standardizationUser, standardEngineer, recheckPlan);
// 发起流程
recheckService.autoStartProcess(esRecheckDataVO);
// 更新标识
recheckPlan.setInProcessFlag(YesOrNoEnum.YES.getValue());
esRecheckPlanService.updateById(recheckPlan);
}
public static ESRecheckDataVO getEsRecheckDataVO(LawsEnterpriseStandard es, String standardizationUser public static ESRecheckDataVO getEsRecheckDataVO(LawsEnterpriseStandard es, String standardizationUser
, String standardEngineer, EnterpriseStandardRecheckPlan recheckPlan) { , String standardEngineer, EnterpriseStandardRecheckPlan recheckPlan) {
ESRecheckDataVO esRecheckDataVO = new ESRecheckDataVO(); ESRecheckDataVO esRecheckDataVO = new ESRecheckDataVO();