From bcf919b625698e63ea851d55a590112e9bdc9317 Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Thu, 15 Jun 2023 16:47:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=BB=B6=E6=9C=9F?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/GeneratorCodeKingbaseConfig.java | 3 +- .../controller/DelayedApplyController.java | 3 +- .../projectdeclared/manage/DelayedApplyManage.java | 6 +- .../pmapi/projectlib/enumeration/InstTypeEnum.java | 12 ++ .../pmapi/projectlib/manage/ProjectLibManage.java | 33 +++--- .../mapper/NdProjectDelayApplyMapper.java | 16 +++ .../mapper/NdProjectDelayApplyMapper.xml | 5 + .../projectlib/model/entity/ProjectDelayApply.java | 57 ++++++++++ .../service/INdProjectDelayApplyService.java | 16 +++ .../impl/NdProjectDelayApplyServiceImpl.java | 20 ++++ .../pmapi/todocenter/manage/HandlerManage.java | 122 +++++++++++++++------ 11 files changed, 233 insertions(+), 60 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectDelayApplyMapper.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectDelayApplyMapper.xml create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectDelayApply.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/INdProjectDelayApplyService.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/impl/NdProjectDelayApplyServiceImpl.java diff --git a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java index e06dd9d..36675c5 100644 --- a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java +++ b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java @@ -56,7 +56,8 @@ public class GeneratorCodeKingbaseConfig { } public static void main(String[] args) { - generate("Liuxinxin", "expert", PATH_LXX, "expert_gov_business_strip"); + //generate("Liuxinxin", "expert", PATH_LXX, "expert_gov_business_strip"); + generate("CMM", "test", PATH_CMM, "nd_project_delay_apply"); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/DelayedApplyController.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/DelayedApplyController.java index c6028b2..dfb7944 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/DelayedApplyController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/DelayedApplyController.java @@ -49,7 +49,6 @@ public class DelayedApplyController { @PostMapping("/apply") public String delayedApply(@Validated @RequestBody DelayedApplyDTO dto) { String instanceId = delayedApplyManage.startDelayedApplyProcess(dto); - return "启动流程实例 【" + instanceId + "】 成功"; - //return delayedApplyManage.delayedApply(dto); + return "启动延期申请流程实例 【" + instanceId + "】 成功"; } } 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 8fa4c62..a7d66cd 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 @@ -36,6 +36,7 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; +import com.ningdatech.pmapi.projectlib.service.INdProjectDelayApplyService; import com.ningdatech.pmapi.projectlib.service.IProjectInstService; import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; @@ -253,12 +254,11 @@ public class DelayedApplyManage { // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode, project); String instanceId = processInstanceService.newStartProcess(model.getProcessDefId(), model.getFormId(), params, orgModelMap); - log.info("终验方案项目申报成功 【{}】", instanceId); + log.info("延期申请申报成功 【{}】", instanceId); - // 保存项目相关 + // 保存项目延期实例相关 projectLibManage.saveProjectByApplyDelay(dto, project, instanceId); - //发送给第一个审批人消息 noticeManage.sendFirtUser(project,model.getFormName(),instanceId, WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/InstTypeEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/InstTypeEnum.java index 78b7f82..92511c4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/InstTypeEnum.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/InstTypeEnum.java @@ -44,4 +44,16 @@ public enum InstTypeEnum { } return StringUtils.EMPTY; } + + public static InstTypeEnum getByCode(Integer code) { + if (Objects.isNull(code)) { + return null; + } + for (InstTypeEnum t : InstTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t; + } + } + return null; + } } 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 8f39f65..48f2df7 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 @@ -34,16 +34,14 @@ import com.ningdatech.pmapi.projectlib.handle.ProcessExecuteChainHandle; import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; import com.ningdatech.pmapi.projectlib.model.dto.ProjectApplicationDTO; import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; -import com.ningdatech.pmapi.projectlib.model.entity.Project; -import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; -import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; -import com.ningdatech.pmapi.projectlib.model.entity.ProjectRenewalFundDeclaration; +import com.ningdatech.pmapi.projectlib.model.entity.*; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import com.ningdatech.pmapi.projectlib.model.vo.AnnualAmountVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import com.ningdatech.pmapi.projectlib.service.*; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; +import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.wflow.exception.BusinessException; import com.wflow.workflow.bean.vo.ProcessDetailVO; import lombok.RequiredArgsConstructor; @@ -79,8 +77,8 @@ public class ProjectLibManage { private final IProjectApplicationService projectApplicationService; private final GenerateProjectCodeUtil generateProjectCodeUtil; private final IProjectInstService projectInstService; - private final StateMachineUtils stateMachineUtils; + private final INdProjectDelayApplyService projectDelayApplyService; public PageVo projectLibList(ProjectListReq req) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); @@ -617,19 +615,18 @@ public class ProjectLibManage { } public void saveProjectByApplyDelay(DelayedApplyDTO dto, Project project, String instanceId) { - // 获取项目的立项批复时间和建设周期 - LocalDateTime approvalDate = project.getApprovalDate(); - String buildCycle = project.getBuildCycle(); - // 重新计算建设周期、验收时间 - String constructCycle = buildCycle + dto.getDelayedMonth(); - project.setBuildCycle(constructCycle); - Long delayedMonth = Long.valueOf(dto.getDelayedMonth()); - String acceptTime = NdDateUtils.format(approvalDate.plusMonths(delayedMonth), DatePattern.NORM_DATETIME_MINUTE_PATTERN); - project.setBuildCycle(acceptTime); - project.setInstCode(instanceId); - project.setApplyDelayFile(dto.getSupportingMaterials()); - project.setApplyDelayReason(dto.getDelayedReason()); - projectService.updateById(project); + + ProjectDelayApply projectDelayApply = new ProjectDelayApply(); + projectDelayApply.setDelayTime(dto.getDelayedMonth()); + projectDelayApply.setDelayApplyFile(dto.getSupportingMaterials()); + projectDelayApply.setDelayApplyReason(dto.getDelayedReason()); + projectDelayApply.setProjectId(project.getId()); + projectDelayApply.setInstanceId(instanceId); + projectDelayApply.setCreateBy(LoginUserUtil.getUserId()); + projectDelayApply.setCreateOn(LocalDateTime.now()); + projectDelayApply.setUpdateBy(LoginUserUtil.getUserId()); + projectDelayApply.setUpdateOn(LocalDateTime.now()); + projectDelayApplyService.save(projectDelayApply); //保存项目和实例的关系 ProjectInst projectInst = new ProjectInst(); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectDelayApplyMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectDelayApplyMapper.java new file mode 100644 index 0000000..4a205fb --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectDelayApplyMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.projectlib.mapper; + +import com.ningdatech.pmapi.projectlib.model.entity.ProjectDelayApply; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 项目延期申请记录表 Mapper 接口 + *

+ * + * @author CMM + * @since 2023-06-15 + */ +public interface NdProjectDelayApplyMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectDelayApplyMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectDelayApplyMapper.xml new file mode 100644 index 0000000..0413769 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectDelayApplyMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectDelayApply.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectDelayApply.java new file mode 100644 index 0000000..7d9360c --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectDelayApply.java @@ -0,0 +1,57 @@ +package com.ningdatech.pmapi.projectlib.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * 项目延期申请记录表 + *

+ * + * @author CMM + * @since 2023-06-15 + */ +@Data +@TableName("nd_project_delay_apply") +@ApiModel(value = "NdProjectDelayApply对象", description = "项目延期申请记录表") +public class ProjectDelayApply implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + @TableId(type = IdType.AUTO) + private Long id; + + @ApiModelProperty("项目ID") + private Long projectId; + + @ApiModelProperty("延期时间(几个月)") + private Integer delayTime; + + @ApiModelProperty("延期申请佐证材料") + private String delayApplyFile; + + @ApiModelProperty("延期申请理由") + private String delayApplyReason; + + @ApiModelProperty("创建人") + private Long createBy; + + @ApiModelProperty("创建时间") + private LocalDateTime createOn; + + @ApiModelProperty("更新人") + private Long updateBy; + + @ApiModelProperty("更新时间") + private LocalDateTime updateOn; + + @ApiModelProperty("延期申请实例ID") + private String instanceId; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/INdProjectDelayApplyService.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/INdProjectDelayApplyService.java new file mode 100644 index 0000000..613edde --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/INdProjectDelayApplyService.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.projectlib.service; + +import com.ningdatech.pmapi.projectlib.model.entity.ProjectDelayApply; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 项目延期申请记录表 服务类 + *

+ * + * @author CMM + * @since 2023-06-15 + */ +public interface INdProjectDelayApplyService extends IService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/impl/NdProjectDelayApplyServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/impl/NdProjectDelayApplyServiceImpl.java new file mode 100644 index 0000000..845c6c4 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/impl/NdProjectDelayApplyServiceImpl.java @@ -0,0 +1,20 @@ +package com.ningdatech.pmapi.projectlib.service.impl; + +import com.ningdatech.pmapi.projectlib.model.entity.ProjectDelayApply; +import com.ningdatech.pmapi.projectlib.mapper.NdProjectDelayApplyMapper; +import com.ningdatech.pmapi.projectlib.service.INdProjectDelayApplyService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 项目延期申请记录表 服务实现类 + *

+ * + * @author CMM + * @since 2023-06-15 + */ +@Service +public class NdProjectDelayApplyServiceImpl extends ServiceImpl implements INdProjectDelayApplyService { + +} 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 a1abd6a..a8da302 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 @@ -6,13 +6,17 @@ import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; +import cn.hutool.core.date.DatePattern; import com.google.common.collect.Lists; +import com.ningdatech.basic.util.NdDateUtils; import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.common.constant.ProjectDeclareConst; import com.ningdatech.pmapi.projectdeclared.converter.ApplicationConverter; +import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; +import com.ningdatech.pmapi.projectlib.model.entity.ProjectDelayApply; +import com.ningdatech.pmapi.projectlib.service.INdProjectDelayApplyService; import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; import org.apache.commons.lang3.StringUtils; -import org.checkerframework.checker.nullness.qual.Nullable; import org.flowable.engine.HistoryService; import org.flowable.engine.RuntimeService; import org.flowable.engine.TaskService; @@ -77,10 +81,9 @@ public class HandlerManage { private final IProjectInstService projectInstService; private final NoticeManage noticeManage; private final DeclaredProjectManage declaredProjectManage; - private final FileService fileService; - private final IJoinReviewProvincialBureauService joinReviewProvincialBureauService; + private final INdProjectDelayApplyService projectDelayApplyService; /** * 审核通过后 所处理的逻辑 @@ -93,6 +96,16 @@ public class HandlerManage { HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(instance.getId()) .singleResult(); + // 获取当前流程实例类型 + String instanceId = newInstance.getId(); + ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) + .eq(ProjectInst::getInstCode, instanceId)); + Integer instType = projectInst.getInstType(); + InstTypeEnum instTypeEnum = InstTypeEnum.getByCode(instType); + if (Objects.isNull(instTypeEnum)){ + throw new BizException("当前审批流类型不存在,流程类型code:" + instType); + } + // 获取流程通过后当前流程详情 ProcessProgressVo newInstanceDetail = processInstanceService.getProgressInstanceDetail(null, instance.getId()); // 获取流程通过后当前审核人信息,向其发送工作通知 @@ -124,41 +137,58 @@ public class HandlerManage { // 若当前登录用户是最后一个审批人,需更新流程状态为审核完成,项目状态到下个状态 // 并向流程发起人发送浙政钉工作通知:【项目名称】已通过【流程名称】,请及时开始下一步操作。 if (HisProInsEndActId.END.equals(newInstance.getEndActivityId())) { - switch (Objects.requireNonNull(ProjectStatusEnum.getValue(declaredProject.getStatus()))) { - // 当前项目状态是预审中 - case PRE_APPLYING: - //先修改项目状态 - updatePassProjectStatus(userId, declaredProject); - //然后入库暂存库 - projectStagingService.addByProject(declaredProject,"暂存入库 待提交部门联审"); - break; - // 当前项目状态是单位内部审核中 - case UNDER_INTERNAL_AUDIT: + // 如果是申请延期和申请借阅审批流程,不走状态机 + if (InstTypeEnum.APPLY_DELAY.getCode().equals(instType) || InstTypeEnum.APPLY_BORROW.getCode().equals(instType)){ + switch (instTypeEnum) { + case APPLY_DELAY: + // 保存延期申请记录,更新项目建设周期和计划验收时间 + updateProjectDelayApplyInfo(declaredProject,instanceId); + break; + case APPLY_BORROW: + // 申请借阅审批逻辑 + break; + default: + throw new BizException("传入实例类型错误: " + instTypeEnum); + } + }else { + switch (Objects.requireNonNull(ProjectStatusEnum.getValue(declaredProject.getStatus()))) { + // 当前项目状态是预审中 + case PRE_APPLYING: + //先修改项目状态 + updatePassProjectStatus(userId, declaredProject); + //然后入库暂存库 + projectStagingService.addByProject(declaredProject, "暂存入库 待提交部门联审"); + break; + // 当前项目状态是单位内部审核中 + case UNDER_INTERNAL_AUDIT: // 当前项目状态是部门联审中 - case DEPARTMENT_JOINT_REVIEW: - //如果是 区县 并且 500万及以上要推送省局重大项目 - if(!StateMachineUtils.isCityProject(declaredProject) && - StateMachineUtils.judgeDeclareAmount(declaredProject, - ProjectDeclareConst.Number.DECLARE_COUNTY_AMOUNT_JUDGEMENT) ){ - try{ - List applications = projectApplicationService - .list(Wrappers.lambdaQuery(ProjectApplication.class) - .eq(ProjectApplication::getProjectId,declaredProject.getId())); - joinReviewProvincialBureauService.pushImportProject( - ApplicationConverter.convertProject(declaredProject,applications,fileService)); - }catch (Exception e){ - log.info("区县推送省级联审失败[{}],{}", declaredProject.getProjectName() ,e.getMessage()); - log.error("区县推送省级联审失败:" + e); + case DEPARTMENT_JOINT_REVIEW: + //如果是 区县 并且 500万及以上要推送省局重大项目 + if (!StateMachineUtils.isCityProject(declaredProject) && + StateMachineUtils.judgeDeclareAmount(declaredProject, + ProjectDeclareConst.Number.DECLARE_COUNTY_AMOUNT_JUDGEMENT)) { + try { + List applications = projectApplicationService + .list(Wrappers.lambdaQuery(ProjectApplication.class) + .eq(ProjectApplication::getProjectId, declaredProject.getId())); + joinReviewProvincialBureauService.pushImportProject( + ApplicationConverter.convertProject(declaredProject, applications, fileService)); + updatePassProjectStatus(userId, declaredProject); + break; + } catch (Exception e) { + log.info("区县推送省级联审失败[{}],{}", declaredProject.getProjectName(), e.getMessage()); + log.error("区县推送省级联审失败:" + e); + } } - } - // 当前项目状态是方案评审中 - case SCHEME_UNDER_REVIEW: - // 当前项目状态是终验审核中 - case FINAL_ACCEPTANCE_IS_UNDER_REVIEW: - updatePassProjectStatus(userId, declaredProject); - break; - default: - throw new IllegalStateException("Unexpected value: " + declaredProject.getStatus()); + // 当前项目状态是方案评审中 + case SCHEME_UNDER_REVIEW: + // 当前项目状态是终验审核中 + case FINAL_ACCEPTANCE_IS_UNDER_REVIEW: + updatePassProjectStatus(userId, declaredProject); + break; + default: + throw new BizException("传入项目状态错误: " + declaredProject.getStatus()); + } } //发送消息 noticeManage.sendNotice(instance.getStartUserId(),userId,declaredProject,instance.getProcessDefinitionName(), @@ -178,6 +208,26 @@ public class HandlerManage { } } + private void updateProjectDelayApplyInfo(Project declaredProject, String instanceId) { + // 获取延期申请填写的相关信息 + ProjectDelayApply delayApply = projectDelayApplyService.getOne(Wrappers.lambdaQuery(ProjectDelayApply.class) + .eq(ProjectDelayApply::getProjectId, declaredProject.getId()) + .eq(ProjectDelayApply::getInstanceId, instanceId)); + // 获取项目的立项批复时间和建设周期 + LocalDateTime approvalDate = declaredProject.getApprovalDate(); + String buildCycle = declaredProject.getBuildCycle(); + // 重新计算建设周期、验收时间 + String constructCycle = 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); + declaredProject.setInstCode(instanceId); + declaredProject.setApplyDelayFile(delayApply.getDelayApplyFile()); + declaredProject.setApplyDelayReason(delayApply.getDelayApplyReason()); + projectService.updateById(declaredProject); + } + /** * 驳回后 所处理的逻辑 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 2/2] =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=BB=B6=E6=9C=9F?= =?UTF-8?q?=E5=AE=A1=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);