ソースを参照

项目审核进度处理

tags/24080901
WendyYang 7ヶ月前
コミット
05128442e9
28個のファイルの変更813行の追加1285行の削除
  1. +0
    -21
      hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/CommonConst.java
  2. +12
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseInstService.java
  3. +28
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AbstractProcessBusinessHandle.java
  4. +0
    -121
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AnnualPlanHandle.java
  5. +38
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ApprovalAmountHandle.java
  6. +0
    -78
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ArchivedHandle.java
  7. +0
    -125
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ConstructionPlanReviewHandle.java
  8. +0
    -117
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/DeptUnitedReviewHandle.java
  9. +80
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/FinalInspectionHandle.java
  10. +58
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/FirstInspectedHandle.java
  11. +59
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/PilotRunningHandle.java
  12. +0
    -132
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/PreliminaryPreviewHandle.java
  13. +0
    -84
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProcessExecuteChainHandle.java
  14. +47
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProcessProgressContext.java
  15. +81
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectAdaptionHandle.java
  16. +41
    -27
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectApprovalHandle.java
  17. +8
    -18
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectDeclareHandle.java
  18. +0
    -116
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectFinalInspectionHandle.java
  19. +0
    -99
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectPreliminaryInspectionHandle.java
  20. +72
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectPurchaseHandle.java
  21. +43
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectReviewHandle.java
  22. +81
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectSelfTestHandle.java
  23. +82
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectTestValidHandle.java
  24. +0
    -109
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProvinceUnitedReviewHandle.java
  25. +0
    -97
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/TenderPurchaseHandle.java
  26. +0
    -136
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/UnitInnerAuditHandle.java
  27. +81
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/XcfhxReviewHandle.java
  28. +2
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java

+ 0
- 21
hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/CommonConst.java ファイルの表示

@@ -11,27 +11,6 @@ public interface CommonConst {

Integer EXPORT_PAGE_NUMBER = 1;
Integer EXPORT_PAGE_SIZE = 100000;
String CALL_STATUS = "status";
String CALL_STATUS_OK_VALUE = "ok";

Integer COMMENT_MAX_SIZE = 163;
Integer SUB_COMMENT_SIZE_MIN = 0;
Integer SUB_COMMENT_SIZE_MAX = 160;

String PROJECT_DECLARE = "项目申报";
String UNIT_INNER_AUDIT = "单位内部审核";
String PRELIMINARY_PREVIEW = "项目预审";

String DEPT_UNITED_REVIEW = "部门联审";
String PROVINCE_UNITED_REVIEW = "省级部门联审";
String ANNUAL_PLAN = "年度计划";
String CONSTRUCTION_PLAN_REVIEW = "建设方案评审";
String PROJECT_APPROVAL = "立项批复";
String TENDER_PURCHASE = "招标采购";
String PROJECT_PRELIMINARY_INSPECTION = "项目初验";
String PROJECT_FINAL_INSPECTION = "项目终验";

String ARCHIVED = "归档";

String FILE_NAME = "name";
String BASIS_FILE_NAME = "fileName";


+ 12
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseInstService.java ファイルの表示

@@ -3,10 +3,14 @@ package com.hz.pm.api.projectdeclared.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hz.pm.api.common.util.BizUtils;
import com.hz.pm.api.projectdeclared.model.entity.PurchaseInst;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;

import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

/**
* <p>
@@ -31,4 +35,12 @@ public interface IPurchaseInstService extends IService<PurchaseInst> {
return list(query);
}

default Map<Long, PurchaseInst> list(Collection<Long> purchaseIds, Integer instType) {
List<PurchaseInst> instances = list(Wrappers.lambdaQuery(PurchaseInst.class)
.in(PurchaseInst::getBidId, purchaseIds)
.eq(PurchaseInst::getInstType, instType));
return BizUtils.groupFirstMap(instances, PurchaseInst::getBidId,
Comparator.comparing(PurchaseInst::getCreateOn).reversed());
}

}

+ 28
- 3
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AbstractProcessBusinessHandle.java ファイルの表示

@@ -2,6 +2,9 @@ package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectlib.model.entity.Project;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.core.Ordered;

import java.util.List;

@@ -12,7 +15,7 @@ import java.util.List;
* @since 2023/02/24 14:22
*/

public abstract class AbstractProcessBusinessHandle {
public abstract class AbstractProcessBusinessHandle implements Ordered {
/**
* 构造,子类必须实现
*/
@@ -28,7 +31,29 @@ public abstract class AbstractProcessBusinessHandle {
*/
abstract void businessHandle(Project project, List<ProcessDetailVO> processSchedule);

abstract Integer getOrder();
abstract ProcessNode getProcessNode();

@Getter
@AllArgsConstructor
enum ProcessNode {

PROJECT_DECLARED("项目申报", 1),
PROJECT_REVIEW("项目评审", 2),
APPROVAL_AMOUNT("资金下达", 3),
PROJECT_APPROVAL("项目立项", 4),
PROJECT_PURCHASE("招标采购", 5),
PROJECT_ADAPTION("适配改造", 6),
SYSTEM_SELF_TEST("系统自测", 7),
SYSTEM_TEST_VALID("测试验证", 8),
FIRST_INSPECTED("项目初验", 9),
PILOT_RUNNING("上线试运行", 10),
XCFHX_REVIEW("信创测评", 11),
FINAL_INSPECTED("项目终验", 12);


private final String name;
private final Integer order;

}

abstract void setOrder(Integer order);
}

+ 0
- 121
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AnnualPlanHandle.java ファイルの表示

@@ -1,121 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.ningdatech.basic.util.CollUtils;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import static com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum.*;

/**
* 年度计划处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(6)
@Component
public class AnnualPlanHandle extends AbstractProcessBusinessHandle {
private final IProjectStatusChangeService projectStatusChangeService;
private final IProjectService projectService;

private Integer order = 6;

/**
* 项目状态为:年度计划中之前的状态
*/
private static final List<ProjectStatusEnum> ANNUAL_PLAN_LIST_STATUS = Arrays.asList(
NOT_APPROVED,
UNDER_INTERNAL_AUDIT,
UNDER_INTERNAL_AUDIT_NOT_PASS,
PENDING_PREQUALIFICATION,
JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS,
JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS,
THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED,
PRE_APPLYING,
PREQUALIFICATION_FAILED,
DEPARTMENT_JOINT_REVIEW,
DEPARTMENT_JOINT_REVIEW_FAILED
);

public AnnualPlanHandle(IProjectStatusChangeService projectStatusChangeService, IProjectService projectService) {
this.projectStatusChangeService = projectStatusChangeService;
this.projectService = projectService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();
// 根据项目状态判断年度计划是否开始
Integer status = project.getStatus();
List<Integer> fieldList = CollUtils.fieldList(ANNUAL_PLAN_LIST_STATUS, ProjectStatusEnum::getCode);

//查出历史版本的 所有项目ID
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(project.getProjectCode());

// 项目状态为年度计划中之前的状态
if (fieldList.contains(status)) {
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.ANNUAL_PLAN);
processSchedule.add(processDetailVO);
return;
}

// 项目状态为年度计划中
LambdaQueryWrapper<ProjectStatusChange> pscQuery = Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectId, allVersionProjectIds)
.last(BizConst.LIMIT_1);
if (ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode().equals(status)) {
// 根据部门联审通过的时间获取
pscQuery.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS);
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(pscQuery);
if (Objects.nonNull(projectStatusChange)) {
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);
}
} else if (ProjectStatusEnum.BE_SUSPENDED.getCode().equals(status)) {
// 根据年度计划暂缓的时间获取
pscQuery.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.ANNUAL_PLAN_SUSPEND);
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(pscQuery);
if (Objects.nonNull(projectStatusChange)) {
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.REJECTED);
}
} else {
// 根据开启方案申报的时间获取
pscQuery.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE);
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(pscQuery);
if (Objects.nonNull(projectStatusChange)) {
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
}
}
processDetailVO.setProcessName(CommonConst.ANNUAL_PLAN);
processSchedule.add(processDetailVO);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 38
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ApprovalAmountHandle.java ファイルの表示

@@ -0,0 +1,38 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectlib.model.entity.Project;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.stereotype.Component;

import java.util.List;

/**
* <p>
* ApprovalAmountHandle
* </p>
*
* @author WendyYang
* @since 21:02 2024/4/8
*/
@Component
public class ApprovalAmountHandle extends AbstractProcessBusinessHandle {

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO detail = new ProcessDetailVO();
processSchedule.add(detail);
detail.setProcessName(getProcessNode().getName());
detail.setStepStatus(project.getApprovalAmount() != null ? StepStatusEnum.COMPLETED : StepStatusEnum.NOT_START);
}

@Override
ProcessNode getProcessNode() {
return ProcessNode.APPROVAL_AMOUNT;
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}
}

+ 0
- 78
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ArchivedHandle.java ファイルの表示

@@ -1,78 +0,0 @@
package com.hz.pm.api.projectlib.handle;


import java.util.List;
import java.util.Objects;

import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;

/**
* 归档处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(12)
@Component
public class ArchivedHandle extends AbstractProcessBusinessHandle {
private final IProjectService projectService;
private final IProjectStatusChangeService projectStatusChangeService;

private Integer order = 12;

public ArchivedHandle( IProjectService projectService, IProjectStatusChangeService projectStatusChangeService){
this.projectService = projectService;
this.projectStatusChangeService = projectStatusChangeService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();
Integer status = project.getStage();
//查出历史版本的 所有项目ID
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(project.getProjectCode());
// 根据项目阶段判断是否已归档
// 项目阶段不为已归档
if (!ProjectStatusEnum.ARCHIVED.getCode().equals(status)){
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.ARCHIVED);
processSchedule.add(processDetailVO);
return;
}
// 项目阶段为已归档
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
// 根据项目终验获取归档时间
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectId, allVersionProjectIds)
.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.FINAL_ACCEPTANCE_PASS.name())
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1));
if(Objects.nonNull(projectStatusChange)){
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setProcessName(CommonConst.ARCHIVED);
}
processSchedule.add(processDetailVO);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 0
- 125
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ConstructionPlanReviewHandle.java ファイルの表示

@@ -1,125 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.service.IProjectInstService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.projectlib.utils.ProjectVersionUtil;
import com.hz.pm.api.todocenter.constant.TodoCenterConst;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.ningdatech.basic.util.NdDateUtils;
import com.wflow.workflow.bean.process.ProgressNode;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.ProcessStatusEnum;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
* 建设方案评审处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(7)
@Component
public class ConstructionPlanReviewHandle extends AbstractProcessBusinessHandle {

private final IProjectInstService projectInstService;
private final ProcessInstanceService processInstanceService;
private final BuildUserUtils buildUserUtils;
private final ProjectVersionUtil projectVersionUtil;
private final IProjectService projectService;

private Integer order = 7;

public ConstructionPlanReviewHandle(IProjectInstService projectInstService, ProcessInstanceService processInstanceService, BuildUserUtils buildUserUtils, ProjectVersionUtil projectVersionUtil, IProjectService projectService) {
this.projectInstService = projectInstService;
this.processInstanceService = processInstanceService;
this.buildUserUtils = buildUserUtils;
this.projectVersionUtil = projectVersionUtil;
this.projectService = projectService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();
//查出历史版本的 所有项目ID
Long projectId = project.getId();
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(project.getProjectCode());
// 根据项目ID查询出建设方案评审流程的流程状态
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, allVersionProjectIds)
.eq(ProjectInst::getInstType, InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode())
.ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE)
.orderByDesc(ProjectInst::getCreateOn)
.last(BizConst.LIMIT_1));
ProcessProgressVo instanceDetail = null;
// 未找到当前版本项目的建设方案审核流程且当前项目版本号大于1(是被驳回重新申报的项目)
if (Objects.isNull(projectInst)) {
if (project.getVersion() > CommonConst.VERSION_ONE) {
// 获取上个版本的信息
instanceDetail = projectVersionUtil.getPreVerProcessInfo(projectId, InstTypeEnum.CONSTRUCTION_PLAN_REVIEW);
}
} else {
String instCode = projectInst.getInstCode();
instanceDetail = processInstanceService.getProgressInstanceDetail(null, instCode);
}
if (Objects.isNull(instanceDetail)) {
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.CONSTRUCTION_PLAN_REVIEW);
processSchedule.add(processDetailVO);
return;
}
String status = instanceDetail.getStatus();
if (ProcessStatusEnum.UNDER_REVIEW.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);
} else if (ProcessStatusEnum.BE_REJECTED.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.REJECTED);
} else if (ProcessStatusEnum.APPROVED.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
}

// 装配节点审核人员信息
List<ProgressNode> progressInfo = instanceDetail.getProgressInfo();
if (CollUtil.isNotEmpty(progressInfo)) {
buildUserUtils.buildUserByProcessInfo(progressInfo);
// 根据流程处理详情获取流程完成时间
if (StepStatusEnum.contains(processDetailVO.getStepStatus(),
Lists.newArrayList(StepStatusEnum.REJECTED,
StepStatusEnum.COMPLETED))) {
ProgressNode progressNode = progressInfo.get(progressInfo.size() - 1);
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime());
processDetailVO.setFinishTime(finishTime);
}
} else {
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime());
processDetailVO.setFinishTime(finishTime);
}
processDetailVO.setProcessProgressVo(instanceDetail);
processDetailVO.setProcessName(CommonConst.CONSTRUCTION_PLAN_REVIEW);
processSchedule.add(processDetailVO);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 0
- 117
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/DeptUnitedReviewHandle.java ファイルの表示

@@ -1,117 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.service.IProjectInstService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.todocenter.constant.TodoCenterConst;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.ningdatech.basic.util.NdDateUtils;
import com.wflow.workflow.bean.process.ProgressNode;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.ProcessStatusEnum;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
* 部门联审审核处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(5)
@Component
public class DeptUnitedReviewHandle extends AbstractProcessBusinessHandle {

private final IProjectInstService projectInstService;

private final IProjectService projectService;
private final ProcessInstanceService processInstanceService;
private final BuildUserUtils buildUserUtils;

private Integer order = 5;

public DeptUnitedReviewHandle(IProjectInstService projectInstService,
IProjectService projectService,
ProcessInstanceService processInstanceService,
BuildUserUtils buildUserUtils) {
this.projectInstService = projectInstService;
this.projectService = projectService;
this.processInstanceService = processInstanceService;
this.buildUserUtils = buildUserUtils;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO retProcessDetail = new ProcessDetailVO();
Long projectId = project.getId();
//查出历史版本的 所有项目ID
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(projectId);

// 根据项目ID查询出部门联审流程的流程状态
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, allVersionProjectIds)
.eq(ProjectInst::getInstType, InstTypeEnum.DEPT_UNITED_REVIEW.getCode())
.ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE)
.orderByDesc(ProjectInst::getCreateOn)
.last(BizConst.LIMIT_1));
if (Objects.isNull(projectInst)) {
retProcessDetail.setStepStatus(StepStatusEnum.NOT_START);
retProcessDetail.setProcessName(CommonConst.DEPT_UNITED_REVIEW);
processSchedule.add(retProcessDetail);
return;
}
String instCode = projectInst.getInstCode();
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, instCode);
String status = instanceDetail.getStatus();
if (ProcessStatusEnum.UNDER_REVIEW.getDesc().equals(status)) {
retProcessDetail.setStepStatus(StepStatusEnum.ON_GOING);
} else if (ProcessStatusEnum.BE_REJECTED.getDesc().equals(status)) {
retProcessDetail.setStepStatus(StepStatusEnum.REJECTED);
} else if (ProcessStatusEnum.APPROVED.getDesc().equals(status)) {
retProcessDetail.setStepStatus(StepStatusEnum.COMPLETED);
}
// 装配节点审核人员信息
List<ProgressNode> progressInfo = instanceDetail.getProgressInfo();
if (CollUtil.isNotEmpty(progressInfo)) {
buildUserUtils.buildUserByProcessInfo(progressInfo);
// 根据流程处理详情获取流程完成时间
if (StepStatusEnum.contains(retProcessDetail.getStepStatus(),
Lists.newArrayList(StepStatusEnum.REJECTED,
StepStatusEnum.COMPLETED))) {
ProgressNode progressNode = progressInfo.get(progressInfo.size() - 1);
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime());
retProcessDetail.setFinishTime(finishTime);
}
} else {
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime());
retProcessDetail.setFinishTime(finishTime);
}
retProcessDetail.setProcessProgressVo(instanceDetail);
retProcessDetail.setProcessName(CommonConst.DEPT_UNITED_REVIEW);
processSchedule.add(retProcessDetail);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 80
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/FinalInspectionHandle.java ファイルの表示

@@ -0,0 +1,80 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectdeclared.model.entity.PurchaseInst;
import com.hz.pm.api.projectdeclared.service.IPurchaseInstService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.TenderStatusEnum;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessInfoVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;


/**
* 项目终验处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Component
@RequiredArgsConstructor
public class FinalInspectionHandle extends AbstractProcessBusinessHandle {

private final IPurchaseInstService purchaseInstService;
private final IPurchaseService purchaseService;
private final ProcessInstanceService processInstanceService;
private final BuildUserUtils buildUserUtils;

@Override
ProcessNode getProcessNode() {
return ProcessNode.FINAL_INSPECTED;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
List<Purchase> purchases = purchaseService.listByProjectId(project.getId());
Map<Long, Purchase> purchaseMap = purchases.stream()
.filter(w -> TenderStatusEnum.FINALLY_INSPECTED_FAILED.eq(w.getStatus())
|| TenderStatusEnum.FINALLY_INSPECTED_PASSED.eq(w.getStatus()))
.collect(Collectors.toMap(Purchase::getId, Function.identity()));
if (purchaseMap.isEmpty()) {
return;
}
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
detail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setProcessInfoList(new ArrayList<>());
processSchedule.add(detail);
Map<Long, PurchaseInst> instMap = purchaseInstService.list(purchaseMap.keySet(), InstTypeEnum.PROJECT_FINAL_INSPECTION.getCode());
for (Map.Entry<Long, PurchaseInst> entry : instMap.entrySet()) {
if (detail.getFinishTime() == null || detail.getFinishTime().isBefore(entry.getValue().getCreateOn())) {
detail.setFinishTime(entry.getValue().getCreateOn());
}
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, entry.getValue().getInstCode());
buildUserUtils.buildUserByProcessInfo(instanceDetail.getProgressInfo());
ProcessInfoVO tenderProgress = new ProcessInfoVO();
tenderProgress.setProcessName(purchaseMap.get(entry.getKey()).getBidName());
tenderProgress.setProcessProgressVo(instanceDetail);
detail.getProcessInfoList().add(tenderProgress);
}
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}

}

+ 58
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/FirstInspectedHandle.java ファイルの表示

@@ -0,0 +1,58 @@
package com.hz.pm.api.projectlib.handle;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
* 初验处理
*
* @author CMM
* @since 2023/02/27 10:09
*/
@Component
@RequiredArgsConstructor
public class FirstInspectedHandle extends AbstractProcessBusinessHandle {

private final IProjectStatusChangeService projectStatusChangeService;

@Override
ProcessNode getProcessNode() {
return ProcessNode.FIRST_INSPECTED;
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
processSchedule.add(detail);
Wrapper<ProjectStatusChange> query = Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectCode, project.getProjectCode())
.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES)
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1);
ProjectStatusChange change = projectStatusChangeService.getOne(query);
if (change != null) {
detail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setFinishTime(change.getCreateOn());
} else {
detail.setStepStatus(StepStatusEnum.NOT_START);
}
}

}

+ 59
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/PilotRunningHandle.java ファイルの表示

@@ -0,0 +1,59 @@
package com.hz.pm.api.projectlib.handle;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
* <p>
* PilotRunningHandle
* </p>
*
* @author WendyYang
* @since 10:34 2024/4/9
*/
@Component
@RequiredArgsConstructor
public class PilotRunningHandle extends AbstractProcessBusinessHandle {

private final IProjectStatusChangeService projectStatusChangeService;

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
processSchedule.add(detail);
Wrapper<ProjectStatusChange> query = Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectCode, project.getProjectCode())
.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES)
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1);
ProjectStatusChange change = projectStatusChangeService.getOne(query);
if (change != null) {
detail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setFinishTime(change.getCreateOn());
} else {
detail.setStepStatus(StepStatusEnum.NOT_START);
}
}

@Override
ProcessNode getProcessNode() {
return ProcessNode.PILOT_RUNNING;
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}
}

+ 0
- 132
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/PreliminaryPreviewHandle.java ファイルの表示

@@ -1,132 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.NdDateUtils;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.service.IProjectInstService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.projectlib.utils.ProjectVersionUtil;
import com.hz.pm.api.todocenter.constant.TodoCenterConst;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.wflow.workflow.bean.process.ProgressNode;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.ProcessStatusEnum;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
* 项目预审处理
*
* @author CMM
* @since 2023/02/27 10:09
*/
@Order(4)
@Component
public class PreliminaryPreviewHandle extends AbstractProcessBusinessHandle {

private final IProjectInstService projectInstService;
private final ProcessInstanceService processInstanceService;
private final BuildUserUtils buildUserUtils;
private final ProjectVersionUtil projectVersionUtil;
private final IProjectService projectService;

private Integer order = 4;

public PreliminaryPreviewHandle(IProjectInstService projectInstService,
ProcessInstanceService processInstanceService,
BuildUserUtils buildUserUtils,
ProjectVersionUtil projectVersionUtil,
IProjectService projectService) {
this.projectInstService = projectInstService;
this.processInstanceService = processInstanceService;
this.buildUserUtils = buildUserUtils;
this.projectVersionUtil = projectVersionUtil;
this.projectService = projectService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();
if (Objects.isNull(project)){
throw new BizException("当前项目不存在!");
}
Long projectId = project.getId();
//查出历史版本的 所有项目ID
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(projectId);
// 根据项目ID查询项目预审流程的流程状态
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, allVersionProjectIds)
.eq(ProjectInst::getInstType, InstTypeEnum.PRELIMINARY_PREVIEW.getCode())
.ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE)
.orderByDesc(ProjectInst::getCreateOn)
.last("limit 1"));
ProcessProgressVo instanceDetail = null;
// 未找到当前版本项目的预审审核流程且当前项目版本号大于1(是被驳回重新申报的项目或者建设方案申报的项目)
if (Objects.isNull(projectInst)) {
if (project.getVersion() > CommonConst.VERSION_ONE){
// 获取上个版本的信息
instanceDetail = projectVersionUtil.getPreVerProcessInfo(projectId,InstTypeEnum.PRELIMINARY_PREVIEW);
}
}else {
String instCode = projectInst.getInstCode();
instanceDetail = processInstanceService.getProgressInstanceDetail(null, instCode);
}
if (Objects.isNull(instanceDetail)){
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.PRELIMINARY_PREVIEW);
processSchedule.add(processDetailVO);
return;
}
String status = instanceDetail.getStatus();
if (ProcessStatusEnum.UNDER_REVIEW.getDesc().equals(status)){
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);
} else if (ProcessStatusEnum.BE_REJECTED.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.REJECTED);
} else if (ProcessStatusEnum.APPROVED.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
}

// 装配节点审核人员信息
List<ProgressNode> progressInfo = instanceDetail.getProgressInfo();
if (CollUtil.isNotEmpty(progressInfo)) {
buildUserUtils.buildUserByProcessInfo(progressInfo);
// 根据流程处理详情获取流程完成时间
if (StepStatusEnum.contains(processDetailVO.getStepStatus(),
Lists.newArrayList(StepStatusEnum.REJECTED,
StepStatusEnum.COMPLETED))) {
ProgressNode progressNode = progressInfo.get(progressInfo.size() - 1);
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime());
processDetailVO.setFinishTime(finishTime);
}
}else {
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime());
processDetailVO.setFinishTime(finishTime);
}
processDetailVO.setProcessProgressVo(instanceDetail);
processDetailVO.setProcessName(CommonConst.PRELIMINARY_PREVIEW);
processSchedule.add(processDetailVO);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 0
- 84
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProcessExecuteChainHandle.java ファイルの表示

@@ -1,84 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import com.google.common.collect.Lists;
import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.sys.manage.ProcessModelManage;
import com.wflow.bean.entity.WflowModels;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

/**
* 流程执行链
*
* @author CMM
* @since 2023/02/26 21:36
*/
@Component
@RequiredArgsConstructor
public class ProcessExecuteChainHandle {

private final ProcessModelManage processModelManage;

/**
* 具体处理者的集合
*/
private final List<AbstractProcessBusinessHandle> processBusinessHandles;

/**
* 遍历处理链,通过前缀判断能否处理逻辑,如果不能继续遍历
*
* @param projectId \
* @return void
* @author CMM
* @since 2023/02/26
*/
public List<ProcessDetailVO> handle(Project project, List<ProcessDetailVO> processSchedule) {
List<AbstractProcessBusinessHandle> handles = Lists.newArrayList();
for (AbstractProcessBusinessHandle processBusinessHandle : processBusinessHandles) {
if (processBusinessHandle instanceof AnnualPlanHandle) {
processBusinessHandle.setOrder(6);
} else if (processBusinessHandle instanceof ConstructionPlanReviewHandle) {
processBusinessHandle.setOrder(7);
}

//建设方案
if (processBusinessHandle instanceof ConstructionPlanReviewHandle) {
ProjectProcessStageEnum processType = ProjectProcessStageEnum.CONSTRUCTION_PROJECT_APPROVAL_PROCESS;
WflowModels wflowModels = processModelManage.getWflowModels(processType, project.getId());
if (Objects.nonNull(wflowModels) && (Boolean.FALSE.equals(wflowModels.getIsStop()))) {
handles.add(processBusinessHandle);
}
} else if (processBusinessHandle instanceof ProvinceUnitedReviewHandle) {
// TODO 省级联审
} else {
handles.add(processBusinessHandle);
}
}

if (!handles.isEmpty()) {
handles.sort(Comparator.comparing(AbstractProcessBusinessHandle::getOrder));
for (AbstractProcessBusinessHandle processBusinessHandle : handles) {
processBusinessHandle.businessHandle(project, processSchedule);
}
for (int i = processSchedule.size() - 1; i >= 1; i--) {
ProcessDetailVO curr = processSchedule.get(i);
if (curr.getStepStatus() == null ||
curr.getStepStatus().equals(StepStatusEnum.NOT_START)) {
continue;
}
ProcessDetailVO pre = processSchedule.get(i - 1);
pre.setStepStatus(StepStatusEnum.COMPLETED);
}
return processSchedule;
}
return Collections.emptyList();
}
}

+ 47
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProcessProgressContext.java ファイルの表示

@@ -0,0 +1,47 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectlib.model.entity.Project;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
* 流程执行链
*
* @author CMM
* @since 2023/02/26 21:36
*/
@Component
@RequiredArgsConstructor
public class ProcessProgressContext {

/**
* 具体处理者的集合
*/
private final List<AbstractProcessBusinessHandle> processBusinessHandles;

public List<ProcessDetailVO> handle(Project project, List<ProcessDetailVO> processSchedule) {
if (!processBusinessHandles.isEmpty()) {
processBusinessHandles.sort(Comparator.comparing(AbstractProcessBusinessHandle::getOrder));
for (AbstractProcessBusinessHandle processBusinessHandle : processBusinessHandles) {
processBusinessHandle.businessHandle(project, processSchedule);
}
for (int i = processSchedule.size() - 1; i >= 1; i--) {
ProcessDetailVO curr = processSchedule.get(i);
if (curr.getStepStatus() == null ||
curr.getStepStatus().equals(StepStatusEnum.NOT_START)) {
continue;
}
ProcessDetailVO pre = processSchedule.get(i - 1);
pre.setStepStatus(StepStatusEnum.COMPLETED);
}
return processSchedule;
}
return Collections.emptyList();
}
}

+ 81
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectAdaptionHandle.java ファイルの表示

@@ -0,0 +1,81 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectdeclared.model.entity.PurchaseInst;
import com.hz.pm.api.projectdeclared.service.IPurchaseInstService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.TenderAdaptStatusEnum;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessInfoVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* <p>
* AdaptionHandle
* </p>
*
* @author WendyYang
* @since 09:29 2024/4/9
*/
@Component
@RequiredArgsConstructor
public class ProjectAdaptionHandle extends AbstractProcessBusinessHandle {

private final IPurchaseService purchaseService;
private final IPurchaseInstService purchaseInstService;
private final BuildUserUtils buildUserUtils;
private final ProcessInstanceService processInstanceService;

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
List<Purchase> purchases = purchaseService.listByProjectId(project.getId());
Map<Long, Purchase> purchaseMap = purchases.stream()
.filter(w -> TenderAdaptStatusEnum.ADAPT_INFO_PASSED.eq(w.getAdaptStatus())
|| TenderAdaptStatusEnum.ADAPT_INFO_FAILED.eq(w.getAdaptStatus()))
.collect(Collectors.toMap(Purchase::getId, Function.identity()));
if (purchaseMap.isEmpty()) {
return;
}
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
detail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setProcessInfoList(new ArrayList<>());
processSchedule.add(detail);
Map<Long, PurchaseInst> instMap = purchaseInstService.list(purchaseMap.keySet(), InstTypeEnum.ADAPTION.getCode());
for (Map.Entry<Long, PurchaseInst> entry : instMap.entrySet()) {
if (detail.getFinishTime() == null || detail.getFinishTime().isBefore(entry.getValue().getCreateOn())) {
detail.setFinishTime(entry.getValue().getCreateOn());
}
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, entry.getValue().getInstCode());
buildUserUtils.buildUserByProcessInfo(instanceDetail.getProgressInfo());
ProcessInfoVO tenderProgress = new ProcessInfoVO();
tenderProgress.setProcessName(purchaseMap.get(entry.getKey()).getBidName());
tenderProgress.setProcessProgressVo(instanceDetail);
detail.getProcessInfoList().add(tenderProgress);
}
}

@Override
ProcessNode getProcessNode() {
return ProcessNode.PROJECT_ADAPTION;
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}

}

+ 41
- 27
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectApprovalHandle.java ファイルの表示

@@ -1,15 +1,22 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.common.model.constant.CommonConst;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.hz.pm.api.projectlib.service.IProjectInstService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.core.annotation.Order;
import com.wflow.workflow.service.ProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Arrays;
@@ -22,27 +29,27 @@ import java.util.Objects;
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(8)
@Component
@RequiredArgsConstructor
public class ProjectApprovalHandle extends AbstractProcessBusinessHandle {

private final IProjectStatusChangeService projectStatusChangeService;
private final IProjectService projectService;
private final IProjectInstService projectInstService;
private final ProcessInstanceService processInstanceService;
private final BuildUserUtils buildUserUtils;

private Integer order = 8;

public ProjectApprovalHandle(IProjectStatusChangeService projectStatusChangeService,
IProjectService projectService) {
this.projectStatusChangeService = projectStatusChangeService;
this.projectService = projectService;
@Override
ProcessNode getProcessNode() {
return ProcessNode.PROJECT_APPROVAL;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetail = new ProcessDetailVO();
processDetail.setProcessName(CommonConst.PROJECT_APPROVAL);
processSchedule.add(processDetail);
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
processSchedule.add(detail);
//查出历史版本的 所有项目ID
List<Long> allProjectIds = projectService.allVersionProjectIds(project.getProjectCode());
Integer status = project.getStatus();
if (Objects.isNull(status)) {
return;
@@ -50,9 +57,10 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle {
// 项目状态为待立项批复之前的状态
if (status < ProjectStatusEnum.TO_BE_APPROVED.getCode()
&& status < ProjectStatusEnum.DECLARED_APPROVED_TO_BE_RECORD.getCode()) {
processDetail.setStepStatus(StepStatusEnum.NOT_START);
detail.setStepStatus(StepStatusEnum.NOT_START);
return;
}
List<Long> projectIds = projectService.allVersionProjectIds(project.getProjectCode());
// 当前项目状态为待立项批复
if (ProjectStatusEnum.TO_BE_APPROVED.eq(status)
|| ProjectStatusEnum.DECLARED_APPROVED_TO_BE_RECORD.eq(status)
@@ -61,31 +69,37 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle {
final List<ProjectStateChangeEvent> events = Arrays.asList(ProjectStateChangeEvent.PLAN_REVIEW_PASS,
ProjectStateChangeEvent.DECLARED_RECORD_SUBMIT,
ProjectStateChangeEvent.DECLARED_RECORD_RESUBMIT);
ProjectStatusChange projectStatusChange = projectStatusChangeService.getLastOne(allProjectIds, events);
ProjectStatusChange projectStatusChange = projectStatusChangeService.getLastOne(projectIds, events);
if (projectStatusChange != null) {
processDetail.setFinishTime(projectStatusChange.getCreateOn());
detail.setFinishTime(projectStatusChange.getCreateOn());
}
processDetail.setStepStatus(StepStatusEnum.ON_GOING);
detail.setStepStatus(StepStatusEnum.ON_GOING);
} else {
// 取 状态机 改变状态时间
final List<ProjectStateChangeEvent> events = Arrays.asList(ProjectStateChangeEvent.PLAN_REVIEW_PASS,
ProjectStateChangeEvent.DECLARED_RECORD_FAILED,
ProjectStateChangeEvent.DECLARED_RECORD_PASS);
ProjectStatusChange projectStatusChange = projectStatusChangeService.getLastOne(allProjectIds, events);
ProjectStatusChange projectStatusChange = projectStatusChangeService.getLastOne(projectIds, events);
if (Objects.nonNull(projectStatusChange)) {
processDetail.setFinishTime(projectStatusChange.getCreateOn());
processDetail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setFinishTime(projectStatusChange.getCreateOn());
detail.setStepStatus(StepStatusEnum.COMPLETED);
ProjectInst inst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, projectIds)
.eq(ProjectInst::getInstType, InstTypeEnum.DECLARED_RECORD.getCode())
.orderByDesc(ProjectInst::getCreateOn)
.last(BizConst.LIMIT_1));
if (inst != null) {
ProcessProgressVo instDetail = processInstanceService.getProgressInstanceDetail(null, inst.getInstCode());
detail.setProcessProgressVo(instDetail);
buildUserUtils.buildUserByProcessInfo(instDetail.getProgressInfo());
}
}
}
}

@Override
Integer getOrder() {
return order;
public int getOrder() {
return getProcessNode().getOrder();
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 8
- 18
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectDeclareHandle.java ファイルの表示

@@ -1,11 +1,9 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.core.annotation.Order;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
@@ -17,19 +15,15 @@ import java.util.List;
* @author CMM
* @since 2023/02/24 14:35
*/

@Order(1)
@Component
@RequiredArgsConstructor
public class ProjectDeclareHandle extends AbstractProcessBusinessHandle {

private final IProjectService projectService;

public ProjectDeclareHandle(IProjectService projectService){
this.projectService = projectService;
@Override
ProcessNode getProcessNode() {
return ProcessNode.PROJECT_DECLARED;
}

private Integer order = 1;

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
// 因为此时在项目库中的项目,都是已经申报过的项目,所以直接设置环节状态为已完成
@@ -38,17 +32,13 @@ public class ProjectDeclareHandle extends AbstractProcessBusinessHandle {
// 项目库中查出申报完成时间
LocalDateTime createOn = project.getCreateOn();
processDetailVO.setFinishTime(createOn);
processDetailVO.setProcessName(CommonConst.PROJECT_DECLARE);
processDetailVO.setProcessName(getProcessNode().getName());
processSchedule.add(processDetailVO);
}

@Override
Integer getOrder() {
return order;
public int getOrder() {
return getProcessNode().getOrder();
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 0
- 116
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectFinalInspectionHandle.java ファイルの表示

@@ -1,116 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists;
import com.ningdatech.basic.util.NdDateUtils;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.service.IProjectInstService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.todocenter.constant.TodoCenterConst;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.wflow.workflow.bean.process.ProgressNode;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.ProcessStatusEnum;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.CommonConst;


/**
* 项目终验处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(11)
@Component
public class ProjectFinalInspectionHandle extends AbstractProcessBusinessHandle {
private final IProjectInstService projectInstService;
private final ProcessInstanceService processInstanceService;
private final BuildUserUtils buildUserUtils;

private final IProjectService projectService;

private Integer order = 11;
public ProjectFinalInspectionHandle(IProjectInstService projectInstService, ProcessInstanceService processInstanceService,
BuildUserUtils buildUserUtils,IProjectService projectService){
this.projectInstService = projectInstService;
this.processInstanceService = processInstanceService;
this.buildUserUtils = buildUserUtils;
this.projectService = projectService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();
//查出历史版本的 所有项目ID
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(project.getProjectCode());
// 根据项目ID查询出项目终验流程的流程状态
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, allVersionProjectIds)
.eq(ProjectInst::getInstType, InstTypeEnum.PROJECT_FINAL_INSPECTION.getCode())
.ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE)
.orderByDesc(ProjectInst::getCreateOn)
.last(BizConst.LIMIT_1));

if (Objects.isNull(projectInst)){
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.PROJECT_FINAL_INSPECTION);
processSchedule.add(processDetailVO);
return;
}

String instCode = projectInst.getInstCode();
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, instCode);
String status = instanceDetail.getStatus();
// 项目状态不在待终验之后的状态
if (ProcessStatusEnum.UNDER_REVIEW.getDesc().equals(status)){
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);
} else if (ProcessStatusEnum.BE_REJECTED.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.REJECTED);
} else if (ProcessStatusEnum.APPROVED.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
}

// 装配节点审核人员信息
List<ProgressNode> progressInfo = instanceDetail.getProgressInfo();
if (CollUtil.isNotEmpty(progressInfo)) {
buildUserUtils.buildUserByProcessInfo(progressInfo);
// 根据流程处理详情获取流程完成时间
if (StepStatusEnum.contains(processDetailVO.getStepStatus(),
Lists.newArrayList(StepStatusEnum.REJECTED,
StepStatusEnum.COMPLETED))) {
ProgressNode progressNode = progressInfo.get(progressInfo.size() - 1);
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime());
processDetailVO.setFinishTime(finishTime);
}
}else {
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime());
processDetailVO.setFinishTime(finishTime);
}
processDetailVO.setProcessProgressVo(instanceDetail);
processDetailVO.setProcessName(CommonConst.PROJECT_FINAL_INSPECTION);
processSchedule.add(processDetailVO);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 0
- 99
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectPreliminaryInspectionHandle.java ファイルの表示

@@ -1,99 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import static com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum.*;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import com.hz.pm.api.common.model.constant.BizConst;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.util.CollUtils;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.hz.pm.api.projectlib.service.IProjectService;

/**
* 项目初验处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(10)
@Component
public class ProjectPreliminaryInspectionHandle extends AbstractProcessBusinessHandle {
private final IProjectStatusChangeService projectStatusChangeService;
private final IProjectService projectService;

private Integer order = 10;

/**
* 项目状态为:建设中及之后的状态
*/
private static final List<ProjectStatusEnum> PROJECT_PRELIMINARY_INSPECTION_LIST_STATUS = Arrays.asList(
UNDER_CONSTRUCTION,
TO_BE_FINALLY_INSPECTED,
FINAL_ACCEPTANCE_IS_UNDER_REVIEW,
FINAL_ACCEPTANCE_REVIEW_FAILED,
ARCHIVED,
ACCEPTED
);

public ProjectPreliminaryInspectionHandle(IProjectStatusChangeService projectStatusChangeService, IProjectService projectService){
this.projectStatusChangeService = projectStatusChangeService;
this.projectService = projectService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();
// 根据项目状态是否在建设中及之后的状态判断项目初验是否开始
List<Integer> fieldList = CollUtils.fieldList(PROJECT_PRELIMINARY_INSPECTION_LIST_STATUS, ProjectStatusEnum::getCode);
//查出历史版本的 所有项目ID
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(project.getProjectCode());
Integer status = project.getStatus();
// 项目状态不在建设中及之后的状态
if (!fieldList.contains(status)){
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.PROJECT_PRELIMINARY_INSPECTION);
processSchedule.add(processDetailVO);
return;
}
// 项目状态为建设中或之后的状态
if (ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(project.getStatus())){
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);
}else {
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
// 根据初验备案的时间获取
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectId, allVersionProjectIds)
.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD.name())
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1));
if(Objects.nonNull(projectStatusChange)){
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
}
}
processDetailVO.setProcessName(CommonConst.PROJECT_PRELIMINARY_INSPECTION);
processSchedule.add(processDetailVO);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 72
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectPurchaseHandle.java ファイルの表示

@@ -0,0 +1,72 @@
package com.hz.pm.api.projectlib.handle;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

import static com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum.ON_PURCHASING;
import static com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum.TO_BE_PURCHASED;

/**
* 招标采购处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Component
@RequiredArgsConstructor
public class ProjectPurchaseHandle extends AbstractProcessBusinessHandle {

private final IProjectStatusChangeService projectStatusChangeService;
private final IProjectService projectService;

@Override
public int getOrder() {
return getProcessNode().getOrder();
}

@Override
ProcessNode getProcessNode() {
return ProcessNode.PROJECT_PURCHASE;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
processSchedule.add(detail);
// 根据项目是否通过立项批复(立项批复时间)来判断招标采购是否开始
// 进行了立项批复且项目状态是待采购
if (TO_BE_PURCHASED.eq(project.getStatus())) {
detail.setStepStatus(StepStatusEnum.NOT_START);
} else if (ON_PURCHASING.eq(project.getStatus())) {
detail.setStepStatus(StepStatusEnum.ON_GOING);
} else {
List<Long> projectIds = projectService.allVersionProjectIds(project.getProjectCode());
// 根据采购备案的时间获取
ProjectStatusChange change = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectId, projectIds)
.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.SUBMIT_OPERATION_PLAN)
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1));
if (change == null) {
detail.setStepStatus(StepStatusEnum.NOT_START);
} else {
detail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setFinishTime(change.getCreateOn());
}
}
detail.setProcessName(getProcessNode().getName());
}

}

+ 43
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectReviewHandle.java ファイルの表示

@@ -0,0 +1,43 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectlib.model.entity.Project;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

/**
* 项目申报处理
*
* @author CMM
* @since 2023/02/24 14:35
*/

@Component
public class ProjectReviewHandle extends AbstractProcessBusinessHandle {

@Override
ProcessNode getProcessNode() {
return ProcessNode.PROJECT_REVIEW;
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
// 因为此时在项目库中的项目,都是已经申报过的项目,所以直接设置环节状态为已完成
ProcessDetailVO processDetailVO = new ProcessDetailVO();
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
// 项目库中查出申报完成时间
LocalDateTime createOn = project.getCreateOn();
processDetailVO.setFinishTime(createOn);
processDetailVO.setProcessName(getProcessNode().getName());
processSchedule.add(processDetailVO);
}

}

+ 81
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectSelfTestHandle.java ファイルの表示

@@ -0,0 +1,81 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectdeclared.model.entity.PurchaseInst;
import com.hz.pm.api.projectdeclared.service.IPurchaseInstService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.TenderSelfTestStatusEnum;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessInfoVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* <p>
* SelfTestHandle
* </p>
*
* @author WendyYang
* @since 09:29 2024/4/9
*/
@Component
@RequiredArgsConstructor
public class ProjectSelfTestHandle extends AbstractProcessBusinessHandle {

private final IPurchaseService purchaseService;
private final IPurchaseInstService purchaseInstService;
private final BuildUserUtils buildUserUtils;
private final ProcessInstanceService processInstanceService;

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
List<Purchase> purchases = purchaseService.listByProjectId(project.getId());
Map<Long, Purchase> purchaseMap = purchases.stream()
.filter(w -> TenderSelfTestStatusEnum.SELF_TEST_INFO_PASSED.eq(w.getSelfTestStatus())
|| TenderSelfTestStatusEnum.SELF_TEST_INFO_FAILED.eq(w.getSelfTestStatus()))
.collect(Collectors.toMap(Purchase::getId, Function.identity()));
if (purchaseMap.isEmpty()) {
return;
}
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
detail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setProcessInfoList(new ArrayList<>());
processSchedule.add(detail);
Map<Long, PurchaseInst> instMap = purchaseInstService.list(purchaseMap.keySet(), InstTypeEnum.SELF_TEST.getCode());
for (Map.Entry<Long, PurchaseInst> entry : instMap.entrySet()) {
if (detail.getFinishTime() == null || detail.getFinishTime().isBefore(entry.getValue().getCreateOn())) {
detail.setFinishTime(entry.getValue().getCreateOn());
}
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, entry.getValue().getInstCode());
buildUserUtils.buildUserByProcessInfo(instanceDetail.getProgressInfo());
ProcessInfoVO tenderProgress = new ProcessInfoVO();
tenderProgress.setProcessName(purchaseMap.get(entry.getKey()).getBidName());
tenderProgress.setProcessProgressVo(instanceDetail);
detail.getProcessInfoList().add(tenderProgress);
}
}

@Override
ProcessNode getProcessNode() {
return ProcessNode.SYSTEM_SELF_TEST;
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}

}

+ 82
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectTestValidHandle.java ファイルの表示

@@ -0,0 +1,82 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectdeclared.model.entity.PurchaseInst;
import com.hz.pm.api.projectdeclared.service.IPurchaseInstService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.TenderSelfTestStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.TenderTestValidStatusEnum;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessInfoVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* <p>
* SelfTestHandle
* </p>
*
* @author WendyYang
* @since 09:29 2024/4/9
*/
@Component
@RequiredArgsConstructor
public class ProjectTestValidHandle extends AbstractProcessBusinessHandle {

private final IPurchaseService purchaseService;
private final IPurchaseInstService purchaseInstService;
private final BuildUserUtils buildUserUtils;
private final ProcessInstanceService processInstanceService;

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
List<Purchase> purchases = purchaseService.listByProjectId(project.getId());
Map<Long, Purchase> purchaseMap = purchases.stream()
.filter(w -> TenderTestValidStatusEnum.TEST_VALID_INFO_PASSED.eq(w.getTestValidStatus())
|| TenderTestValidStatusEnum.TEST_VALID_INFO_FAILED.eq(w.getTestValidStatus()))
.collect(Collectors.toMap(Purchase::getId, Function.identity()));
if (purchaseMap.isEmpty()) {
return;
}
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
detail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setProcessInfoList(new ArrayList<>());
processSchedule.add(detail);
Map<Long, PurchaseInst> instMap = purchaseInstService.list(purchaseMap.keySet(), InstTypeEnum.TEST_VALID.getCode());
for (Map.Entry<Long, PurchaseInst> entry : instMap.entrySet()) {
if (detail.getFinishTime() == null || detail.getFinishTime().isBefore(entry.getValue().getCreateOn())) {
detail.setFinishTime(entry.getValue().getCreateOn());
}
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, entry.getValue().getInstCode());
buildUserUtils.buildUserByProcessInfo(instanceDetail.getProgressInfo());
ProcessInfoVO tenderProgress = new ProcessInfoVO();
tenderProgress.setProcessName(purchaseMap.get(entry.getKey()).getBidName());
tenderProgress.setProcessProgressVo(instanceDetail);
detail.getProcessInfoList().add(tenderProgress);
}
}

@Override
ProcessNode getProcessNode() {
return ProcessNode.SYSTEM_TEST_VALID;
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}

}

+ 0
- 109
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProvinceUnitedReviewHandle.java ファイルの表示

@@ -1,109 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;

/**
* 省级联审审核处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(3)
@Component
public class ProvinceUnitedReviewHandle extends AbstractProcessBusinessHandle {
private final IProjectService projectService;
private final IProjectStatusChangeService projectStatusChangeService;

private Integer order = 3;

public ProvinceUnitedReviewHandle(IProjectService projectService,
IProjectStatusChangeService projectStatusChangeService) {
this.projectService = projectService;
this.projectStatusChangeService = projectStatusChangeService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();

//查询项目
Long projectId = project.getId();
List<Long> allVersionProjectId = projectService.allVersionProjectIds(projectId);

// 根据项目ID查询出部门联审流程的流程状态
if (Objects.isNull(project)) {
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.PROVINCE_UNITED_REVIEW);
processSchedule.add(processDetailVO);
return;
}

Integer status = project.getStatus();
if (ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);
ProjectStatusChange startChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectId, allVersionProjectId)
.eq(ProjectStatusChange::getBeforeStatus, ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode())
.eq(ProjectStatusChange::getAfterStatus, ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode()).orderByDesc(ProjectStatusChange::getCreateOn)
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1));
if (Objects.nonNull(startChange)) {
processDetailVO.setFinishTime(startChange.getCreateOn());
}
} else if (status.compareTo(ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode()) > 0) {
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
ProjectStatusChange passChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectId, allVersionProjectId)
.eq(ProjectStatusChange::getBeforeStatus, ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode())
.eq(ProjectStatusChange::getAfterStatus, ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode())
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1));
if (Objects.nonNull(passChange)) {
processDetailVO.setFinishTime(passChange.getCreateOn());
}
} else if (status.compareTo(ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode()) > 0) {
processDetailVO.setStepStatus(StepStatusEnum.REJECTED);
ProjectStatusChange rejectChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectId, allVersionProjectId)
.eq(ProjectStatusChange::getBeforeStatus, ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode())
.eq(ProjectStatusChange::getAfterStatus, ProjectStatusEnum.THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED.getCode())
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1));
if (Objects.nonNull(rejectChange)) {
processDetailVO.setFinishTime(rejectChange.getCreateOn());
}
} else {
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.PROVINCE_UNITED_REVIEW);
processSchedule.add(processDetailVO);
return;
}
processDetailVO.setContent(project.getSjlsResult());
processDetailVO.setProcessName(CommonConst.PROVINCE_UNITED_REVIEW);
processSchedule.add(processDetailVO);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}
}

+ 0
- 97
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/TenderPurchaseHandle.java ファイルの表示

@@ -1,97 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange;
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.ningdatech.basic.util.CollUtils;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.enums.StepStatusEnum;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import static com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum.*;

/**
* 招标采购处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(9)
@Component
public class TenderPurchaseHandle extends AbstractProcessBusinessHandle {
private final IProjectStatusChangeService projectStatusChangeService;
private final IProjectService projectService;

private Integer order = 9;

/**
* 项目状态为:建设中及之后的状态
*/
private static final List<ProjectStatusEnum> TENDER_PURCHASE_LIST_STATUS = Arrays.asList(
UNDER_CONSTRUCTION,
TO_BE_FINALLY_INSPECTED,
FINAL_ACCEPTANCE_IS_UNDER_REVIEW,
FINAL_ACCEPTANCE_REVIEW_FAILED,
ARCHIVED,
ACCEPTED
);

public TenderPurchaseHandle(IProjectStatusChangeService projectStatusChangeService, IProjectService projectService) {
this.projectStatusChangeService = projectStatusChangeService;
this.projectService = projectService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();
// 根据项目是否通过立项批复(立项批复时间)来判断招标采购是否开始
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(project.getProjectCode());
Integer status = project.getStatus();
// 未进行立项批复
if (Objects.isNull(project.getApprovalDate())) {
processDetailVO.setStepStatus(StepStatusEnum.NOT_START);
processDetailVO.setProcessName(CommonConst.TENDER_PURCHASE);
processSchedule.add(processDetailVO);
return;
}
List<Integer> fieldList = CollUtils.fieldList(TENDER_PURCHASE_LIST_STATUS, ProjectStatusEnum::getCode);
// 进行了立项批复且项目状态是待采购
if (ProjectStatusEnum.TO_BE_PURCHASED.getCode().equals(project.getStatus())) {
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);
} else if (fieldList.contains(status)) {
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
// 根据采购备案的时间获取
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.in(ProjectStatusChange::getProjectId, allVersionProjectIds)
.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.SUBMIT_PURCHASE_NOTICE.name())
.orderByDesc(ProjectStatusChange::getCreateOn)
.last(BizConst.LIMIT_1));
if (projectStatusChange != null) {
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;
}
}

+ 0
- 136
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/UnitInnerAuditHandle.java ファイルの表示

@@ -1,136 +0,0 @@
package com.hz.pm.api.projectlib.handle;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.entity.ProjectInst;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.service.IProjectInstService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.projectlib.utils.ProjectVersionUtil;
import com.hz.pm.api.todocenter.constant.TodoCenterConst;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.ningdatech.basic.util.NdDateUtils;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import com.wflow.workflow.bean.process.ProgressNode;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.ProcessStatusEnum;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* 单位内部审核处理
*
* @author CMM
* @since 2023/02/24 14:35
*/
@Order(2)
@Component
public class UnitInnerAuditHandle extends AbstractProcessBusinessHandle {

private final IProjectInstService projectInstService;

private final ProcessInstanceService processInstanceService;
private final BuildUserUtils buildUserUtils;
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;
this.buildUserUtils = buildUserUtils;
this.projectVersionUtil = projectVersionUtil;
this.projectService = projectService;
}

@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
ProcessDetailVO processDetailVO = new ProcessDetailVO();
processDetailVO.setProcessName(CommonConst.UNIT_INNER_AUDIT);
Long projectId = project.getId();
List<Long> allVersionProjectIds = projectService.allVersionProjectIds(project.getProjectCode());
// 根据项目ID查询出单位内部审核流程的流程状态
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, allVersionProjectIds)
.eq(ProjectInst::getInstType, InstTypeEnum.UNIT_INNER_AUDIT.getCode())
.ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE)
.orderByDesc(ProjectInst::getCreateOn)
.last(BizConst.LIMIT_1));
ProcessProgressVo instanceDetail = null;

// 未找到当前版本项目的单位内部审核流程且当前项目版本号大于1(是被驳回重新申报的项目)
// 注意:已经在项目库中的项目,一定是单位内部审核已经开始的项目
if (Objects.isNull(projectInst)) {
if (project.getVersion() > CommonConst.VERSION_ONE) {
// 获取上个版本的信息
instanceDetail = projectVersionUtil.getPreVerProcessInfo(projectId, InstTypeEnum.UNIT_INNER_AUDIT);
}
} else {
String instCode = projectInst.getInstCode();
instanceDetail = processInstanceService.getProgressInstanceDetail(null, instCode);
}
processSchedule.add(processDetailVO);
if (Objects.isNull(instanceDetail)) {
return;
}
String status = instanceDetail.getStatus();
if (ProcessStatusEnum.UNDER_REVIEW.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);
} else if (ProcessStatusEnum.BE_REJECTED.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.REJECTED);
} else if (ProcessStatusEnum.APPROVED.getDesc().equals(status)) {
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
}

// 装配节点审核人员信息
List<ProgressNode> progressInfo = instanceDetail.getProgressInfo();
if (CollUtil.isNotEmpty(progressInfo)) {
buildUserUtils.buildUserByProcessInfo(progressInfo);
// 根据流程处理详情获取流程完成时间
if (StepStatusEnum.contains(processDetailVO.getStepStatus(),
Lists.newArrayList(StepStatusEnum.REJECTED,
StepStatusEnum.COMPLETED))) {
// 如果是驳回,获取流程信息时可能
ProgressNode progressNode = progressInfo.get(progressInfo.size() - 1);
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime());
processDetailVO.setFinishTime(finishTime);
}
} else {
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime());
processDetailVO.setFinishTime(finishTime);
}
processDetailVO.setProcessProgressVo(instanceDetail);
}

@Override
Integer getOrder() {
return order;
}

@Override
void setOrder(Integer order) {
this.order = order;
}

private void buildUser(List<ProgressNode> progressInfo, Map<String, ProcessInstanceUserDto> userMap) {
for (ProgressNode progressNode : progressInfo) {
progressNode.setUser(userMap.get(progressNode.getUserId()));
if (CollUtil.isNotEmpty(progressNode.getChildren())) {
buildUser(progressNode.getChildren(), userMap);
}
}
}
}

+ 81
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/XcfhxReviewHandle.java ファイルの表示

@@ -0,0 +1,81 @@
package com.hz.pm.api.projectlib.handle;

import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectdeclared.model.entity.PurchaseInst;
import com.hz.pm.api.projectdeclared.service.IPurchaseInstService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum;
import com.hz.pm.api.projectlib.model.enumeration.TenderXcfhxApplyStatusEnum;
import com.hz.pm.api.todocenter.utils.BuildUserUtils;
import com.wflow.workflow.bean.vo.ProcessDetailVO;
import com.wflow.workflow.bean.vo.ProcessInfoVO;
import com.wflow.workflow.bean.vo.ProcessProgressVo;
import com.wflow.workflow.enums.StepStatusEnum;
import com.wflow.workflow.service.ProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* <p>
* XcfhxReviewHandle
* </p>
*
* @author WendyYang
* @since 10:43 2024/4/9
*/
@Component
@RequiredArgsConstructor
public class XcfhxReviewHandle extends AbstractProcessBusinessHandle {

private final IPurchaseService purchaseService;
private final IPurchaseInstService purchaseInstService;
private final BuildUserUtils buildUserUtils;
private final ProcessInstanceService processInstanceService;


@Override
void businessHandle(Project project, List<ProcessDetailVO> processSchedule) {
List<Purchase> purchases = purchaseService.listByProjectId(project.getId());
Map<Long, Purchase> purchaseMap = purchases.stream()
.filter(w -> TenderXcfhxApplyStatusEnum.XCFHX_APPLY_PASSED.eq(w.getXcfhxApplyStatus())
|| TenderXcfhxApplyStatusEnum.XCFHX_APPLY_FAILED.eq(w.getXcfhxApplyStatus()))
.collect(Collectors.toMap(Purchase::getId, Function.identity()));
if (purchaseMap.isEmpty()) {
return;
}
ProcessDetailVO detail = new ProcessDetailVO();
detail.setProcessName(getProcessNode().getName());
detail.setStepStatus(StepStatusEnum.COMPLETED);
detail.setProcessInfoList(new ArrayList<>());
processSchedule.add(detail);
Map<Long, PurchaseInst> instMap = purchaseInstService.list(purchaseMap.keySet(), InstTypeEnum.XCFHX_APPLY.getCode());
for (Map.Entry<Long, PurchaseInst> entry : instMap.entrySet()) {
if (detail.getFinishTime() == null || detail.getFinishTime().isBefore(entry.getValue().getCreateOn())) {
detail.setFinishTime(entry.getValue().getCreateOn());
}
ProcessProgressVo instanceDetail = processInstanceService.getProgressInstanceDetail(null, entry.getValue().getInstCode());
buildUserUtils.buildUserByProcessInfo(instanceDetail.getProgressInfo());
ProcessInfoVO tenderProgress = new ProcessInfoVO();
tenderProgress.setProcessName(purchaseMap.get(entry.getKey()).getBidName());
tenderProgress.setProcessProgressVo(instanceDetail);
detail.getProcessInfoList().add(tenderProgress);
}
}

@Override
ProcessNode getProcessNode() {
return ProcessNode.XCFHX_REVIEW;
}

@Override
public int getOrder() {
return getProcessNode().getOrder();
}
}

+ 2
- 2
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java ファイルの表示

@@ -53,7 +53,7 @@ import com.hz.pm.api.projectdeclared.service.IPreInsAcceptancePersonService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectdeclared.utils.ProjectCodeGenUtil;
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos;
import com.hz.pm.api.projectlib.handle.ProcessExecuteChainHandle;
import com.hz.pm.api.projectlib.handle.ProcessProgressContext;
import com.hz.pm.api.projectlib.helper.ProjectHelper;
import com.hz.pm.api.projectlib.model.constant.ProjectConstant;
import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO;
@@ -122,7 +122,7 @@ public class ProjectLibManage {
private final IProjectService projectService;
private final IProjectApplicationService applicationService;
private final IProjectRenewalFundDeclarationService renewalFundDeclarationService;
private final ProcessExecuteChainHandle processExecuteHandle;
private final ProcessProgressContext processExecuteHandle;
private final FileService fileService;
private final IProjectApplicationService projectApplicationService;
private final ProjectCodeGenUtil projectCodeGenUtil;


読み込み中…
キャンセル
保存