From eee96044c3c29c2dec7fd05ea9421cc26aa8f299 Mon Sep 17 00:00:00 2001 From: yjz <3131811435@qq.com> Date: Tue, 26 Dec 2023 16:30:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BC=81=E6=A0=87=E7=A8=BD=E6=9F=A5?= =?UTF-8?q?=E6=95=B4=E6=94=B9):=2079475?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/EsInspectFlowServiceImpl.java | 6 +- .../common/EsInspectRectifyCommon.java | 9 ++ .../EsInspectRectifyFlowController.java | 6 +- .../entity/ProcessEsInspectRectify.java | 4 + .../esinspectrectify/job/DelayApplyJob.java | 117 ++++++++++++++++++ .../service/IEsInspectRectifyFlowService.java | 4 +- .../impl/EsInspectRectifyFlowServiceImpl.java | 80 +++++++++--- 7 files changed, 204 insertions(+), 22 deletions(-) create mode 100644 laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/job/DelayApplyJob.java diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspect/service/impl/EsInspectFlowServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspect/service/impl/EsInspectFlowServiceImpl.java index 238b5194..5395b685 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspect/service/impl/EsInspectFlowServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspect/service/impl/EsInspectFlowServiceImpl.java @@ -73,7 +73,7 @@ public class EsInspectFlowServiceImpl implements IEsInspectFlowService { private final EnterpriseStandardInspectRectifyPlanService enterpriseStandardInspectRectifyPlanService; private final EnterpriseStandardInspectReportService enterpriseStandardInspectReportService; private final IEsInspectRectifyFlowService esInspectReportFlowService; - private final IProcessEsInspectRectifyService processEsInspectReportService; + private final IProcessEsInspectRectifyService processEsInspectRectifyService; public EsInspectFlowServiceImpl(ProcessAllService processAllService, ProcessApprovalRecordService processApprovalRecordService, ProcessDraftService processDraftService, @@ -97,7 +97,7 @@ public class EsInspectFlowServiceImpl implements IEsInspectFlowService { this.enterpriseStandardInspectRectifyPlanService = enterpriseStandardInspectRectifyPlanService; this.enterpriseStandardInspectReportService = enterpriseStandardInspectReportService; this.esInspectReportFlowService = esInspectReportFlowService; - this.processEsInspectReportService = processEsInspectReportService; + this.processEsInspectRectifyService = processEsInspectReportService; } ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); @@ -403,7 +403,7 @@ public class EsInspectFlowServiceImpl implements IEsInspectFlowService { processEsInspectRectify.setProjectId(processAll.getProjectId()); processEsInspectRectify.setInspectRectifyPlanId(enterpriseStandardInspectRectifyPlan.getId()); esInspectReportFlowVO.setProcessEsInspectRectify(processEsInspectRectify); - processEsInspectReportService.save(processEsInspectRectify); + processEsInspectRectifyService.save(processEsInspectRectify); // 处理人员信息 Map map = new HashMap<>(); diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/common/EsInspectRectifyCommon.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/common/EsInspectRectifyCommon.java index 99418450..db182cc0 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/common/EsInspectRectifyCommon.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/common/EsInspectRectifyCommon.java @@ -51,4 +51,13 @@ public class EsInspectRectifyCommon { * 整改状态 1:整改中 2:审核中 3:整改已完成 4:无需整改 */ public static final String INSPECT_RECTIFY_STATUS_4 = "4"; + + /** + * 操作类型 1:提交整改结果 2:申请延期 + */ + public static final String OPERATION_TYPE_1 = "1"; + /** + * 操作类型 1:提交整改结果 2:申请延期 + */ + public static final String OPERATION_TYPE_2 = "2"; } diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/controller/EsInspectRectifyFlowController.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/controller/EsInspectRectifyFlowController.java index 2ef52008..5d6f4b52 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/controller/EsInspectRectifyFlowController.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/controller/EsInspectRectifyFlowController.java @@ -14,6 +14,8 @@ import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.formula.functions.T; import org.springframework.web.bind.annotation.*; +import java.text.ParseException; + /** * @ClassName: 企标稽查整改 * @Description: @@ -68,7 +70,7 @@ public class EsInspectRectifyFlowController { @AutoLog(value = "企标稽查整改-流程审批") @ApiOperation(value="企标稽查整改-流程审批", notes="企标稽查整改-流程审批") @PostMapping(value = "/flowApproval") - public Result flowApproval(@RequestBody EsInspectRectifyFlowVO esInspectReportFlowVO) { + public Result flowApproval(@RequestBody EsInspectRectifyFlowVO esInspectReportFlowVO) throws ParseException { esInspectReportFlowService.flowApproval(esInspectReportFlowVO); return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); } @@ -81,7 +83,7 @@ public class EsInspectRectifyFlowController { @AutoLog(value = "企标稽查整改-驳回") @ApiOperation(value="企标稽查整改-驳回", notes="企标稽查整改-驳回") @PostMapping(value = "/flowReject") - public Result flowReject(@RequestBody EsInspectRectifyFlowVO esInspectReportFlowVO) { + public Result flowReject(@RequestBody EsInspectRectifyFlowVO esInspectReportFlowVO) throws ParseException { log.info(""); esInspectReportFlowService.flowApproval(esInspectReportFlowVO); return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/entity/ProcessEsInspectRectify.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/entity/ProcessEsInspectRectify.java index 72c089a5..069b4dba 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/entity/ProcessEsInspectRectify.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/entity/ProcessEsInspectRectify.java @@ -58,4 +58,8 @@ public class ProcessEsInspectRectify extends BaseEntity { @Excel(name = "延期说明", width = 15) @ApiModelProperty(value = "延期说明") private String delayDetail; + /**是否生成过新的流程(1:是 0:否)*/ + @Excel(name = "是否生成过新的流程(1:是 0:否)", width = 15) + @ApiModelProperty(value = "是否生成过新的流程(1:是 0:否)") + private String isDelayCreate; } diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/job/DelayApplyJob.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/job/DelayApplyJob.java new file mode 100644 index 00000000..238687f5 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/job/DelayApplyJob.java @@ -0,0 +1,117 @@ +package com.jero.modules.activiti.process.esinspectrectify.job; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.jero.common.constant.enums.YesOrNoEnum; +import com.jero.common.exception.JeroBootException; +import com.jero.common.util.SnowflakeUtils; +import com.jero.modules.activiti.entity.ProcessAll; +import com.jero.modules.activiti.entity.ProcessApprovalRecord; +import com.jero.modules.activiti.process.esinspectrectify.entity.ProcessEsInspectRectify; +import com.jero.modules.activiti.process.esinspectrectify.service.IEsInspectRectifyFlowService; +import com.jero.modules.activiti.process.esinspectrectify.service.IProcessEsInspectRectifyService; +import com.jero.modules.activiti.process.esinspectrectify.vo.EsInspectRectifyFlowVO; +import com.jero.modules.activiti.service.ProcessAllService; +import com.jero.modules.laws.enterprise.entity.EnterpriseStandardInspectRectifyPlan; +import com.jero.modules.laws.enterprise.service.EnterpriseStandardInspectRectifyPlanService; +import lombok.extern.slf4j.Slf4j; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @ClassName: DelayApplyJob + * @Description: 企标稽查整改-申请延期生成稽查整改定时任务 + * @Author: yjz + * @Date: 2023-12-26 09:59 + * @Version: 1.0 + **/ +@Slf4j +@Transactional(rollbackFor = RuntimeException.class) +public class DelayApplyJob implements Job { + @Resource + private IEsInspectRectifyFlowService esInspectRectifyFlowService; + @Resource + private IProcessEsInspectRectifyService processEsInspectRectifyService; + @Resource + private ProcessAllService processAllService; + @Resource + private EnterpriseStandardInspectRectifyPlanService enterpriseStandardInspectRectifyPlanService; + + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JeroBootException { + log.info("企标稽查整改-申请延期生成稽查整改定时任务开始"); + long num = 0L; + // 需要生成的企标稽查整改 + Date date = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date parse; + try { + parse = dateFormat.parse(dateFormat.format(date)); + } catch (ParseException e) { + throw new JeroBootException(e); + } + List list = processEsInspectRectifyService.list( + new LambdaQueryWrapper() + .eq(ProcessEsInspectRectify::getIsDelayCreate, YesOrNoEnum.NO.getValue()) + .eq(ProcessEsInspectRectify::getApplyDelayDate, parse)); + + List idList = new ArrayList<>(); + // 生成新整改流程 + for (ProcessEsInspectRectify processEsInspectRectify : list) { + idList.add(processEsInspectRectify.getId()); + EsInspectRectifyFlowVO esInspectReportFlowVO = new EsInspectRectifyFlowVO(); + // 处理流程信息 + ProcessAll oldProcessAll = processAllService.getOne( + new LambdaQueryWrapper() + .eq(ProcessAll::getProjectId, processEsInspectRectify.getProjectId())); + ProcessAll processAll = new ProcessAll(); + processAll.setProjectId(String.valueOf(SnowflakeUtils.snowflake())); + processAll.setPrcName(oldProcessAll.getPrcName()); + esInspectReportFlowVO.setProcessAll(processAll); + + // 整改计划 + EnterpriseStandardInspectRectifyPlan enterpriseStandardInspectRectifyPlan = enterpriseStandardInspectRectifyPlanService.getById(processEsInspectRectify.getInspectRectifyPlanId()); + + // 处理流程审批信息 + ProcessApprovalRecord processApprovalRecord = new ProcessApprovalRecord(); + processApprovalRecord.setProjectId(processAll.getProjectId()); + processApprovalRecord.setUserId(enterpriseStandardInspectRectifyPlan.getResponseUser()); + esInspectReportFlowVO.setProcessApprovalRecord(processApprovalRecord); + + // 处理业务表数据 + ProcessEsInspectRectify newProcessEsInspectRectify = new ProcessEsInspectRectify(); + newProcessEsInspectRectify.setId(String.valueOf(SnowflakeUtils.snowflake())); + newProcessEsInspectRectify.setProjectId(processAll.getProjectId()); + newProcessEsInspectRectify.setIsDelayCreate(YesOrNoEnum.NO.getValue()); + newProcessEsInspectRectify.setInspectRectifyPlanId(processEsInspectRectify.getInspectRectifyPlanId()); + esInspectReportFlowVO.setProcessEsInspectRectify(newProcessEsInspectRectify); + processEsInspectRectifyService.save(newProcessEsInspectRectify); + + // 处理人员信息 + Map map = new HashMap<>(); + map.put("responsible", enterpriseStandardInspectRectifyPlan.getResponseUser()); + map.put("leader", "请选择"); + map.put("responsibleApproval", "请选择"); + esInspectReportFlowVO.setMap(map); + esInspectRectifyFlowService.createReportFlow(esInspectReportFlowVO); + num += 1; + } + + if (!idList.isEmpty()){ + // 修改状态 + processEsInspectRectifyService.update( + new LambdaUpdateWrapper() + .in(ProcessEsInspectRectify::getId, idList) + .set(ProcessEsInspectRectify::getIsDelayCreate, YesOrNoEnum.YES.getValue())); + } + log.info("企标稽查整改-申请延期生成稽查整改定时任务结束"); + log.info("企标稽查整改-申请延期生成稽查整改{}条", num); + } +} diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/service/IEsInspectRectifyFlowService.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/service/IEsInspectRectifyFlowService.java index 65be1538..cd96b7b0 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/service/IEsInspectRectifyFlowService.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/service/IEsInspectRectifyFlowService.java @@ -2,6 +2,8 @@ package com.jero.modules.activiti.process.esinspectrectify.service; import com.jero.modules.activiti.process.esinspectrectify.vo.EsInspectRectifyFlowVO; +import java.text.ParseException; + /** * @ClassName: IEsInspectReportFlowService * @Description: @@ -34,7 +36,7 @@ public interface IEsInspectRectifyFlowService { * 企标稽查流程-流程审批 * @param esInspectReportFlowVO */ - void flowApproval(EsInspectRectifyFlowVO esInspectReportFlowVO); + void flowApproval(EsInspectRectifyFlowVO esInspectReportFlowVO) throws ParseException; /** * 企标稽查流程-流程转办 diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/service/impl/EsInspectRectifyFlowServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/service/impl/EsInspectRectifyFlowServiceImpl.java index c46ec3da..aeaba15c 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/service/impl/EsInspectRectifyFlowServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/esinspectrectify/service/impl/EsInspectRectifyFlowServiceImpl.java @@ -3,6 +3,7 @@ package com.jero.modules.activiti.process.esinspectrectify.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.jero.common.constant.enums.YesOrNoEnum; import com.jero.common.exception.JeroBootException; import com.jero.common.system.vo.LoginUser; import com.jero.common.util.SnowflakeUtils; @@ -37,10 +38,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.stream.Collectors; /** @@ -57,7 +57,7 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer private final ProcessApprovalRecordService processApprovalRecordService; private final ProcessDraftService processDraftService; private final ProcessNodeLinkService processNodeLinkService; - private final IProcessEsInspectRectifyService processEsInspectReportService; + private final IProcessEsInspectRectifyService processEsInspectRectifyService; private final EnterpriseStandardInspectRectifyPlanService enterpriseStandardInspectRectifyPlanService; public EsInspectRectifyFlowServiceImpl(ProcessAllService processAllService, @@ -70,7 +70,7 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer this.processApprovalRecordService = processApprovalRecordService; this.processDraftService = processDraftService; this.processNodeLinkService = processNodeLinkService; - this.processEsInspectReportService = processEsInspectReportService; + this.processEsInspectRectifyService = processEsInspectReportService; this.enterpriseStandardInspectRectifyPlanService = enterpriseStandardInspectRectifyPlanService; } @@ -162,7 +162,7 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer // 保存业务表信息 ProcessEsInspectRectify processEsInspectReport = esInspectReportFlowVO.getProcessEsInspectRectify(); - processEsInspectReportService.updateById(processEsInspectReport); + processEsInspectRectifyService.updateById(processEsInspectReport); } @Override @@ -216,7 +216,7 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer } @Override - public void flowApproval(EsInspectRectifyFlowVO esInspectReportFlowVO) { + public void flowApproval(EsInspectRectifyFlowVO esInspectReportFlowVO) throws ParseException { LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // 流程信息 ProcessAll processAll = esInspectReportFlowVO.getProcessAll(); @@ -238,7 +238,7 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer // 保存业务表信息 ProcessEsInspectRectify processEsInspectReport = esInspectReportFlowVO.getProcessEsInspectRectify(); - processEsInspectReportService.updateById(processEsInspectReport); + processEsInspectRectifyService.updateById(processEsInspectReport); // 更新流程审批信息 processApprovalRecordService.update( @@ -258,13 +258,61 @@ public class EsInspectRectifyFlowServiceImpl implements IEsInspectRectifyFlowSer taskService.complete(task.getId(), map); // 判断是否是最后一个节点 if (isLastNode(processAll.getProcessInstanceId())){ - ProcessEsInspectRectifyVO processEsInspectReportVO = processEsInspectReportService.queryByProjectId(processAll.getProjectId()); - // 更新整改状态 - enterpriseStandardInspectRectifyPlanService.update( - new LambdaUpdateWrapper() - .eq(EnterpriseStandardInspectRectifyPlan::getId, processEsInspectReportVO.getInspectRectifyPlanId()) - .set(EnterpriseStandardInspectRectifyPlan::getRectifyStatus, EsInspectRectifyCommon.INSPECT_RECTIFY_STATUS_3) - .set(EnterpriseStandardInspectRectifyPlan::getActualCompleteDate, new Date())); + ProcessEsInspectRectifyVO processEsInspectReportVO = processEsInspectRectifyService.queryByProjectId(processAll.getProjectId()); + Date date = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date parse = dateFormat.parse(dateFormat.format(date)); + // 是否申请延期 + if (EsInspectRectifyCommon.OPERATION_TYPE_2.equals(processEsInspectReportVO.getOperationType()) + && (processEsInspectReportVO.getApplyDelayDate().before(parse) + || processEsInspectReportVO.getApplyDelayDate().equals(parse))){ + // 生成新整改流程 + EsInspectRectifyFlowVO newEsInspectReportFlowVO = new EsInspectRectifyFlowVO(); + // 处理流程信息 + ProcessAll newProcessAll = new ProcessAll(); + newProcessAll.setProjectId(String.valueOf(SnowflakeUtils.snowflake())); + newProcessAll.setPrcName(processAll.getPrcName()); + newEsInspectReportFlowVO.setProcessAll(newProcessAll); + + // 整改计划 + EnterpriseStandardInspectRectifyPlan enterpriseStandardInspectRectifyPlan = enterpriseStandardInspectRectifyPlanService.getById(processEsInspectReportVO.getInspectRectifyPlanId()); + + // 处理流程审批信息 + ProcessApprovalRecord newProcessApprovalRecord = new ProcessApprovalRecord(); + newProcessApprovalRecord.setId(String.valueOf(SnowflakeUtils.snowflake())); + newProcessApprovalRecord.setProjectId(newProcessAll.getProjectId()); + newProcessApprovalRecord.setUserId(enterpriseStandardInspectRectifyPlan.getResponseUser()); + newEsInspectReportFlowVO.setProcessApprovalRecord(newProcessApprovalRecord); + + // 处理业务表数据 + ProcessEsInspectRectify processEsInspectRectify = new ProcessEsInspectRectify(); + processEsInspectRectify.setId(String.valueOf(SnowflakeUtils.snowflake())); + processEsInspectRectify.setProjectId(newProcessAll.getProjectId()); + processEsInspectRectify.setIsDelayCreate(YesOrNoEnum.NO.getValue()); + processEsInspectRectify.setInspectRectifyPlanId(processEsInspectReportVO.getInspectRectifyPlanId()); + newEsInspectReportFlowVO.setProcessEsInspectRectify(processEsInspectRectify); + processEsInspectRectifyService.save(processEsInspectRectify); + + // 处理人员信息 + Map newMap = new HashMap<>(); + newMap.put("responsible", enterpriseStandardInspectRectifyPlan.getResponseUser()); + newMap.put("leader", "请选择"); + newMap.put("responsibleApproval", "请选择"); + newEsInspectReportFlowVO.setMap(newMap); + createReportFlow(newEsInspectReportFlowVO); + + // 修改状态 + processEsInspectRectifyService.update( + new LambdaUpdateWrapper() + .in(ProcessEsInspectRectify::getId, processEsInspectReportVO.getId()) + .set(ProcessEsInspectRectify::getIsDelayCreate, YesOrNoEnum.YES.getValue())); + }else { + // 更新整改状态 + enterpriseStandardInspectRectifyPlanService.update(new LambdaUpdateWrapper() + .eq(EnterpriseStandardInspectRectifyPlan::getId, processEsInspectReportVO.getInspectRectifyPlanId()) + .set(EnterpriseStandardInspectRectifyPlan::getRectifyStatus, EsInspectRectifyCommon.INSPECT_RECTIFY_STATUS_3) + .set(EnterpriseStandardInspectRectifyPlan::getActualCompleteDate, parse)); + } } } }