diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AbstractProcessBusinessHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AbstractProcessBusinessHandle.java index 7dbc3f0..7973155 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AbstractProcessBusinessHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AbstractProcessBusinessHandle.java @@ -27,4 +27,7 @@ public abstract class AbstractProcessBusinessHandle { */ abstract void businessHandle(Long projectId, List processSchedule); + abstract Integer getOrder(); + + abstract void setOrder(Integer order); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AnnualPlanHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AnnualPlanHandle.java index 2d61390..66b081d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AnnualPlanHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AnnualPlanHandle.java @@ -34,6 +34,8 @@ public class AnnualPlanHandle extends AbstractProcessBusinessHandle { private final INdProjectStatusChangeService projectStatusChangeService; private final IProjectService projectService; + private Integer order = 5; + /** * 项目状态为:年度计划中之前的状态 */ @@ -110,4 +112,14 @@ public class AnnualPlanHandle extends AbstractProcessBusinessHandle { processDetailVO.setProcessName(CommonConst.ANNUAL_PLAN); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ArchivedHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ArchivedHandle.java index 7040013..62ed5c2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ArchivedHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ArchivedHandle.java @@ -30,6 +30,8 @@ public class ArchivedHandle extends AbstractProcessBusinessHandle { private final IProjectService projectService; private final INdProjectStatusChangeService projectStatusChangeService; + private Integer order = 11; + public ArchivedHandle( IProjectService projectService, INdProjectStatusChangeService projectStatusChangeService){ this.projectService = projectService; this.projectStatusChangeService = projectStatusChangeService; @@ -63,4 +65,14 @@ public class ArchivedHandle extends AbstractProcessBusinessHandle { } processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ConstructionPlanReviewHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ConstructionPlanReviewHandle.java index 851bff0..5d7aded 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ConstructionPlanReviewHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ConstructionPlanReviewHandle.java @@ -43,6 +43,8 @@ public class ConstructionPlanReviewHandle extends AbstractProcessBusinessHandle private final ProjectVersionUtil projectVersionUtil; private final IProjectService projectService; + private Integer order = 6; + public ConstructionPlanReviewHandle(IProjectInstService projectInstService, ProcessInstanceService processInstanceService, BuildUserUtils buildUserUtils, ProjectVersionUtil projectVersionUtil, IProjectService projectService){ this.projectInstService = projectInstService; this.processInstanceService = processInstanceService; @@ -109,4 +111,14 @@ public class ConstructionPlanReviewHandle extends AbstractProcessBusinessHandle processDetailVO.setProcessName(CommonConst.CONSTRUCTION_PLAN_REVIEW); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/DeptUnitedReviewHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/DeptUnitedReviewHandle.java index 2d580e4..7072aae 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/DeptUnitedReviewHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/DeptUnitedReviewHandle.java @@ -43,6 +43,8 @@ public class DeptUnitedReviewHandle extends AbstractProcessBusinessHandle { private final BuildUserUtils buildUserUtils; private final ProjectVersionUtil projectVersionUtil; + private Integer order = 4; + public DeptUnitedReviewHandle(IProjectInstService projectInstService,IProjectService projectService , ProcessInstanceService processInstanceService, BuildUserUtils buildUserUtils, ProjectVersionUtil projectVersionUtil){ @@ -102,4 +104,14 @@ public class DeptUnitedReviewHandle extends AbstractProcessBusinessHandle { processDetailVO.setProcessName(CommonConst.DEPT_UNITED_REVIEW); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/PreliminaryPreviewHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/PreliminaryPreviewHandle.java index 95a8fd6..a529178 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/PreliminaryPreviewHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/PreliminaryPreviewHandle.java @@ -42,6 +42,8 @@ public class PreliminaryPreviewHandle extends AbstractProcessBusinessHandle { private final ProjectVersionUtil projectVersionUtil; private final IProjectService projectService; + private Integer order = 3; + public PreliminaryPreviewHandle(IProjectInstService projectInstService, ProcessInstanceService processInstanceService, BuildUserUtils buildUserUtils, ProjectVersionUtil projectVersionUtil, IProjectService projectService) { this.projectInstService = projectInstService; this.processInstanceService = processInstanceService; @@ -109,4 +111,14 @@ public class PreliminaryPreviewHandle extends AbstractProcessBusinessHandle { processDetailVO.setProcessName(CommonConst.PRELIMINARY_PREVIEW); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProcessExecuteChainHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProcessExecuteChainHandle.java index db6e9c0..1253eac 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProcessExecuteChainHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProcessExecuteChainHandle.java @@ -1,10 +1,22 @@ package com.ningdatech.pmapi.projectlib.handle; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; +import com.ningdatech.pmapi.common.statemachine.contants.RegionContant; +import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.service.IProjectService; +import com.wflow.bean.entity.WflowModels; import com.wflow.workflow.bean.vo.ProcessDetailVO; +import com.wflow.workflow.service.ProcessModelService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import java.util.Collections; +import java.util.Comparator; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; /** * 流程执行链 @@ -15,10 +27,16 @@ import java.util.List; @Component public class ProcessExecuteChainHandle { + @Autowired + private IProjectService projectService; + + @Autowired + private ProcessModelService processModelService; + /** * 具体处理者的集合 */ - private final List processBusinessHandles; + private List processBusinessHandles; public ProcessExecuteChainHandle(List processBusinessHandles) { this.processBusinessHandles = processBusinessHandles; @@ -32,8 +50,43 @@ public class ProcessExecuteChainHandle { * @since 2023/02/26 */ public List handle(Long projectId, List processSchedule){ - if (processBusinessHandles.size() > 0) { - for (AbstractProcessBusinessHandle processBusinessHandle : processBusinessHandles) { + Project project = projectService.getById(projectId); + + List handles = Lists.newArrayList(); + for (AbstractProcessBusinessHandle processBusinessHandle : processBusinessHandles) { + if(Objects.nonNull(project) && RegionContant.LS_LQ_CODE.equals(project.getAreaCode())) { + if(processBusinessHandle instanceof AnnualPlanHandle){ + processBusinessHandle.setOrder(5); + }else if(processBusinessHandle instanceof ConstructionPlanReviewHandle){ + processBusinessHandle.setOrder(6); + } + }else{ + if(processBusinessHandle instanceof AnnualPlanHandle){ + processBusinessHandle.setOrder(6); + }else if(processBusinessHandle instanceof ConstructionPlanReviewHandle){ + processBusinessHandle.setOrder(5); + } + } + if(processBusinessHandle instanceof ConstructionPlanReviewHandle){ + WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) + .eq(WflowModels::getRegionCode, project.getAreaCode()) + .eq(WflowModels::getProcessType, ProjectProcessStageEnum.CONSTRUCTION_PROJECT_APPROVAL_PROCESS.getCode()) + .last(BizConst.LIMIT_1)); + if(Objects.nonNull(model)){ + if(!model.getIsStop()){ + handles.add(processBusinessHandle); + } + } + continue; + } + handles.add(processBusinessHandle); + } + + handles = handles.stream() + .sorted(Comparator.comparing(AbstractProcessBusinessHandle::getOrder)) + .collect(Collectors.toList()); + if (handles.size() > 0) { + for (AbstractProcessBusinessHandle processBusinessHandle : handles) { processBusinessHandle.businessHandle(projectId, processSchedule); } return processSchedule; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java index 88814c9..aea63a8 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java @@ -32,6 +32,8 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle { private final IProjectService projectService; private final AnnualPlanLibManage annualPlanLibManage; + private Integer order = 7; + /** * 项目状态为:待立项批复之前的状态 */ @@ -101,4 +103,14 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle { processDetailVO.setProcessName(CommonConst.PROJECT_APPROVAL); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectDeclareHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectDeclareHandle.java index 48c79a9..55d9e61 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectDeclareHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectDeclareHandle.java @@ -28,6 +28,8 @@ public class ProjectDeclareHandle extends AbstractProcessBusinessHandle { this.projectService = projectService; } + private Integer order = 1; + @Override void businessHandle(Long projectId, List processSchedule) { // 因为此时在项目库中的项目,都是已经申报过的项目,所以直接设置环节状态为已完成 @@ -40,4 +42,14 @@ public class ProjectDeclareHandle extends AbstractProcessBusinessHandle { processDetailVO.setProcessName(CommonConst.PROJECT_DECLARE); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectFinalInspectionHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectFinalInspectionHandle.java index 0d4265e..93160ce 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectFinalInspectionHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectFinalInspectionHandle.java @@ -36,6 +36,7 @@ public class ProjectFinalInspectionHandle extends AbstractProcessBusinessHandle private final ProcessInstanceService processInstanceService; private final BuildUserUtils buildUserUtils; + private Integer order = 10; public ProjectFinalInspectionHandle(IProjectInstService projectInstService, ProcessInstanceService processInstanceService, BuildUserUtils buildUserUtils){ this.projectInstService = projectInstService; this.processInstanceService = processInstanceService; @@ -92,4 +93,14 @@ public class ProjectFinalInspectionHandle extends AbstractProcessBusinessHandle processDetailVO.setProcessName(CommonConst.PROJECT_FINAL_INSPECTION); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectPreliminaryInspectionHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectPreliminaryInspectionHandle.java index 38b768a..8a95a4f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectPreliminaryInspectionHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectPreliminaryInspectionHandle.java @@ -32,6 +32,8 @@ public class ProjectPreliminaryInspectionHandle extends AbstractProcessBusinessH private final INdProjectStatusChangeService projectStatusChangeService; private final IProjectService projectService; + private Integer order = 9; + /** * 项目状态为:建设中及之后的状态 */ @@ -77,4 +79,14 @@ public class ProjectPreliminaryInspectionHandle extends AbstractProcessBusinessH processDetailVO.setProcessName(CommonConst.PROJECT_PRELIMINARY_INSPECTION); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/TenderPurchaseHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/TenderPurchaseHandle.java index 388c90a..2c7988c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/TenderPurchaseHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/TenderPurchaseHandle.java @@ -3,7 +3,9 @@ package com.ningdatech.pmapi.projectlib.handle; import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; import java.util.*; +import java.util.stream.Collectors; +import com.ningdatech.pmapi.common.constant.BizConst; import com.wflow.workflow.bean.vo.ProcessDetailVO; import com.wflow.workflow.enums.StepStatusEnum; import org.springframework.core.annotation.Order; @@ -31,6 +33,8 @@ public class TenderPurchaseHandle extends AbstractProcessBusinessHandle { private final INdProjectStatusChangeService projectStatusChangeService; private final IProjectService projectService; + private Integer order = 8; + /** * 项目状态为:建设中及之后的状态 */ @@ -51,7 +55,10 @@ public class TenderPurchaseHandle extends AbstractProcessBusinessHandle { void businessHandle(Long projectId, List processSchedule) { ProcessDetailVO processDetailVO = new ProcessDetailVO(); // 根据项目是否通过立项批复(立项批复时间)来判断招标采购是否开始 - Project project = projectService.getById(projectId); + Project project = projectService.getNewProject(projectId); + List projectIds = projectService.list(Wrappers.lambdaQuery(Project.class) + .in(Project::getProjectCode, project.getProjectCode())).stream() + .map(Project::getId).collect(Collectors.toList()); Integer status = project.getStatus(); // 未进行立项批复 if (Objects.isNull(project.getApprovalDate())){ @@ -68,12 +75,22 @@ public class TenderPurchaseHandle extends AbstractProcessBusinessHandle { processDetailVO.setStepStatus(StepStatusEnum.COMPLETED); // 根据采购备案的时间获取 ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class) - .eq(ProjectStatusChange::getProjectId, projectId) + .in(ProjectStatusChange::getProjectId, projectIds) .eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD.name()) - .last("limit 1")); + .last(BizConst.LIMIT_1)); processDetailVO.setFinishTime(projectStatusChange.getCreateOn()); } processDetailVO.setProcessName(CommonConst.TENDER_PURCHASE); processSchedule.add(processDetailVO); } + + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/UnitInnerAuditHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/UnitInnerAuditHandle.java index 8b00ace..83920a5 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/UnitInnerAuditHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/UnitInnerAuditHandle.java @@ -47,6 +47,8 @@ public class UnitInnerAuditHandle extends AbstractProcessBusinessHandle { private final ProjectVersionUtil projectVersionUtil; private final IProjectService projectService; + private Integer order = 2; + public UnitInnerAuditHandle(IProjectInstService projectInstService, ProcessInstanceService processInstanceService, BuildUserUtils buildUserUtils, ProjectVersionUtil projectVersionUtil, IProjectService projectService){ this.projectInstService = projectInstService; this.processInstanceService = processInstanceService; @@ -112,6 +114,16 @@ public class UnitInnerAuditHandle extends AbstractProcessBusinessHandle { processSchedule.add(processDetailVO); } + @Override + Integer getOrder() { + return order; + } + + @Override + void setOrder(Integer order) { + this.order = order; + } + private void buildUser(List progressInfo, Map userMap) { for (ProgressNode progressNode : progressInfo) { progressNode.setUser(userMap.get(progressNode.getUserId()));