From 65cf966defeb2b6d96d2a0736b9b25265f093a0d Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Thu, 15 Jun 2023 19:43:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=BB=B6=E6=9C=9F=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E6=B5=81=E7=A8=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectdeclared/manage/DelayedApplyManage.java | 2 +- .../pmapi/projectlib/manage/ProjectLibManage.java | 7 ++++++ .../pmapi/todocenter/handle/WithDrawHandle.java | 15 +++++++++++++ .../pmapi/todocenter/manage/HandlerManage.java | 25 ++++++++++++++++------ 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DelayedApplyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DelayedApplyManage.java index a7d66cd..bfef5a1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DelayedApplyManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DelayedApplyManage.java @@ -230,7 +230,7 @@ public class DelayedApplyManage { .throwMessage("提交失败 该项目不是 已立项|待终验"); VUtils.isTrue(Objects.isNull(project.getPlanAcceptanceTime()) - || project.getPlanAcceptanceTime().compareTo(LocalDateTime.now()) <= 0) + || project.getPlanAcceptanceTime().compareTo(LocalDateTime.now()) > 0) .throwMessage("当前项目还未过期验收"); String regionCode = user.getRegionCode(); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 48f2df7..14c7385 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -616,6 +616,13 @@ public class ProjectLibManage { public void saveProjectByApplyDelay(DelayedApplyDTO dto, Project project, String instanceId) { + // 更新项目流程实例ID + project.setInstCode(instanceId); + project.setCreateOn(LocalDateTime.now()); + project.setUpdateOn(LocalDateTime.now()); + projectService.updateById(project); + + // 保存延期申请信息 ProjectDelayApply projectDelayApply = new ProjectDelayApply(); projectDelayApply.setDelayTime(dto.getDelayedMonth()); projectDelayApply.setDelayApplyFile(dto.getSupportingMaterials()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java index 5dca80d..c8b4abb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java @@ -1,8 +1,12 @@ package com.ningdatech.pmapi.todocenter.handle; import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.basic.exception.BizException; import com.ningdatech.pmapi.common.helper.UserInfoHelper; +import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; +import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; +import com.ningdatech.pmapi.projectlib.service.IProjectInstService; import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; @@ -44,6 +48,7 @@ public class WithDrawHandle { private final HistoryService historyService; private final RepositoryService repositoryService; + private final IProjectInstService projectInstService; /** * 判断 当前流程 可否被当前登录人 所撤回 @@ -306,6 +311,16 @@ public class WithDrawHandle { */ public boolean canRootWithDraw(HistoricProcessInstance instance,String employeeCode) { String startUserId = instance.getStartUserId(); + // 如果是申请延期或者申请借阅审批流程,流程发起人不能撤回,直接返回false + String instanceId = instance.getId(); + ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) + .eq(ProjectInst::getInstCode, instanceId)); + Integer instType = projectInst.getInstType(); + + if (InstTypeEnum.APPLY_DELAY.getCode().equals(instType) || + InstTypeEnum.APPLY_BORROW.getCode().equals(instType)){ + return Boolean.FALSE; + } //如果流程发起人 不是 当前登录人 直接返回false if(StringUtils.isBlank(employeeCode) || StringUtils.isBlank(startUserId) || !employeeCode.equals(startUserId)){ diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java index a8da302..49cbc28 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/HandlerManage.java @@ -3,6 +3,7 @@ package com.ningdatech.pmapi.todocenter.manage; import static com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant.*; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -145,7 +146,7 @@ public class HandlerManage { updateProjectDelayApplyInfo(declaredProject,instanceId); break; case APPLY_BORROW: - // 申请借阅审批逻辑 + //TODO 申请借阅审批逻辑 break; default: throw new BizException("传入实例类型错误: " + instTypeEnum); @@ -217,11 +218,13 @@ public class HandlerManage { LocalDateTime approvalDate = declaredProject.getApprovalDate(); String buildCycle = declaredProject.getBuildCycle(); // 重新计算建设周期、验收时间 - String constructCycle = buildCycle + delayApply.getDelayTime(); + String constructCycle = String.valueOf(Integer.parseInt(buildCycle) + delayApply.getDelayTime()); declaredProject.setBuildCycle(constructCycle); - Long delayedMonth = Long.valueOf(delayApply.getDelayTime()); - String acceptTime = NdDateUtils.format(approvalDate.plusMonths(delayedMonth), DatePattern.NORM_DATETIME_MINUTE_PATTERN); - declaredProject.setBuildCycle(acceptTime); + Long constructMonth = Long.valueOf(constructCycle); + declaredProject.setBuildCycle(String.valueOf(constructMonth)); + String acceptTime = NdDateUtils.format(approvalDate.plusMonths(constructMonth), DatePattern.NORM_DATETIME_MINUTE_PATTERN); + LocalDateTime time = LocalDateTime.parse(acceptTime, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MINUTE_PATTERN)); + declaredProject.setPlanAcceptanceTime(time); declaredProject.setInstCode(instanceId); declaredProject.setApplyDelayFile(delayApply.getDelayApplyFile()); declaredProject.setApplyDelayReason(delayApply.getDelayApplyReason()); @@ -236,8 +239,16 @@ public class HandlerManage { */ public void afterRejectTodo(Project declaredProject, HistoricProcessInstance instance) { Long userId = LoginUserUtil.getUserId(); - // 更新项目状态和流程状态 - updateRejectProjectStatus(userId, declaredProject); + // 获取当前流程实例类型 + String instanceId = declaredProject.getInstCode(); + ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) + .eq(ProjectInst::getInstCode, instanceId)); + Integer instType = projectInst.getInstType(); + // 审批流程不是申请延期和申请借阅,需调用状态机 + if (!InstTypeEnum.APPLY_DELAY.getCode().equals(instType) && !InstTypeEnum.APPLY_BORROW.getCode().equals(instType)) { + // 更新项目状态和流程状态 + updateRejectProjectStatus(userId, declaredProject); + } //发送消息 noticeManage.sendNotice(instance.getStartUserId(),userId,declaredProject,instance.getProcessDefinitionName(), REJECT_MSG_TEMPLATE,MsgTypeEnum.PROJECT_REVIEW_REJECT);