@@ -1,20 +1,14 @@ | |||
package com.ningdatech.pmapi.projectlib.handle; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.stream.Collectors; | |||
import java.util.*; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.manage.AnnualPlanLibManage; | |||
import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.AnnualPlanListItemVO; | |||
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import org.springframework.core.annotation.Order; | |||
@@ -24,6 +18,8 @@ import com.ningdatech.pmapi.common.constant.CommonConstant; | |||
import com.ningdatech.pmapi.projectlib.enumeration.StepStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProcessDetailVO; | |||
import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; | |||
/** | |||
* 年度计划处理 | |||
* | |||
@@ -33,41 +29,46 @@ import com.ningdatech.pmapi.projectlib.model.vo.ProcessDetailVO; | |||
@Order(5) | |||
@Component | |||
public class AnnualPlanHandle extends AbstractProcessBusinessHandle { | |||
private final AnnualPlanLibManage annualPlanLibManage; | |||
private final INdProjectStatusChangeService projectStatusChangeService; | |||
private final IProjectService projectService; | |||
/** | |||
* 项目状态为:年度计划中之前的状态 | |||
*/ | |||
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, | |||
THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED, | |||
PRE_APPLYING, | |||
PREQUALIFICATION_FAILED, | |||
DEPARTMENT_JOINT_REVIEW, | |||
DEPARTMENT_JOINT_REVIEW_FAILED | |||
); | |||
public AnnualPlanHandle(AnnualPlanLibManage annualPlanLibManage, INdProjectStatusChangeService projectStatusChangeService){ | |||
this.annualPlanLibManage = annualPlanLibManage; | |||
public AnnualPlanHandle(INdProjectStatusChangeService projectStatusChangeService, IProjectService projectService){ | |||
this.projectStatusChangeService = projectStatusChangeService; | |||
this.projectService = projectService; | |||
} | |||
@Override | |||
void businessHandle(Long projectId, List<ProcessDetailVO> processSchedule) { | |||
ProcessDetailVO processDetailVO = new ProcessDetailVO(); | |||
// 根据年度计划库列表是否包含该项目以及是否开启方案申报判断年度计划是否开始 | |||
ProjectListReq req = new ProjectListReq(); | |||
PageVo<AnnualPlanListItemVO> planLibList = annualPlanLibManage.annulPlanLibList(req); | |||
Collection<AnnualPlanListItemVO> records = planLibList.getRecords(); | |||
Map<Long, AnnualPlanListItemVO> itemVOMap = records.stream() | |||
.collect(Collectors.toMap(AnnualPlanListItemVO::getProjectId, v -> v)); | |||
AnnualPlanListItemVO itemVO = itemVOMap.get(projectId); | |||
// 年度计划库中不包含当前项目 | |||
if (Objects.isNull(itemVO)){ | |||
processDetailVO.setStepStatus(StepStatusEnum.NOT_START); | |||
processDetailVO.setProcessName(CommonConstant.ANNUAL_PLAN); | |||
processSchedule.add(processDetailVO); | |||
return; | |||
} | |||
Boolean isStartDeclaredProject = itemVO.getIsStartDeclaredProject(); | |||
// 年度计划库中包含当前项目但未开启方案申报 | |||
if (Boolean.FALSE.equals(isStartDeclaredProject)) { | |||
// 根据项目状态判断年度计划是否开始 | |||
Project project = projectService.getById(projectId); | |||
Integer status = project.getStatus(); | |||
List<Integer> fieldList = CollUtils.fieldList(ANNUAL_PLAN_LIST_STATUS, ProjectStatusEnum::getCode); | |||
// 项目状态为年度计划中之前的状态 | |||
if (fieldList.contains(status)){ | |||
processDetailVO.setStepStatus(StepStatusEnum.NOT_START); | |||
processDetailVO.setProcessName(CommonConstant.ANNUAL_PLAN); | |||
processSchedule.add(processDetailVO); | |||
return; | |||
} | |||
// 年度计划库包含当前项目且开启了方案申报 | |||
Integer status = itemVO.getStatus(); | |||
// 项目状态为年度计划中 | |||
if (ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode().equals(status)){ | |||
// 根据部门联审通过的时间获取 | |||
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class) | |||
@@ -42,17 +42,23 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle { | |||
private final IProjectService projectService; | |||
/** | |||
* 项目状态为:待立项批复及之后的状态 | |||
* 项目状态为:待立项批复之前的状态 | |||
*/ | |||
private static final List<ProjectStatusEnum> ANNUAL_PLAN_LIST_STATUS = Arrays.asList( | |||
TO_BE_APPROVED, | |||
PROJECT_APPROVED, | |||
TO_BE_PURCHASED, | |||
UNDER_CONSTRUCTION, | |||
TO_BE_FINALLY_INSPECTED, | |||
FINAL_ACCEPTANCE_IS_UNDER_REVIEW, | |||
FINAL_ACCEPTANCE_REVIEW_FAILED, | |||
ARCHIVED | |||
private static final List<ProjectStatusEnum> PROJECT_APPROVAL_LIST_STATUS = Arrays.asList( | |||
NOT_APPROVED, | |||
UNDER_INTERNAL_AUDIT, | |||
UNDER_INTERNAL_AUDIT_NOT_PASS, | |||
PENDING_PREQUALIFICATION, | |||
JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS, | |||
THE_JOINT_REVIEW_OF_PROVINCIAL_DEPARTMENTS_FAILED, | |||
PRE_APPLYING, | |||
PREQUALIFICATION_FAILED, | |||
DEPARTMENT_JOINT_REVIEW, | |||
DEPARTMENT_JOINT_REVIEW_FAILED, | |||
IN_THE_ANNUAL_PLAN, | |||
BE_SUSPENDED, | |||
SCHEME_UNDER_REVIEW, | |||
SCHEME_REVIEW_FAILED | |||
); | |||
public ProjectApprovalHandle(AnnualPlanLibManage annualPlanLibManage, INdProjectStatusChangeService projectStatusChangeService, IProjectService projectService){ | |||
@@ -64,32 +70,20 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle { | |||
@Override | |||
void businessHandle(Long projectId, List<ProcessDetailVO> processSchedule) { | |||
ProcessDetailVO processDetailVO = new ProcessDetailVO(); | |||
// 根据年度计划库列表是否包含该项目以及建设方案评审流程是否通过来判断立项批复是否开始 | |||
ProjectListReq req = new ProjectListReq(); | |||
PageVo<AnnualPlanListItemVO> planLibList = annualPlanLibManage.annulPlanLibList(req); | |||
Collection<AnnualPlanListItemVO> records = planLibList.getRecords(); | |||
Map<Long, AnnualPlanListItemVO> itemVOMap = records.stream() | |||
.collect(Collectors.toMap(AnnualPlanListItemVO::getProjectId, v -> v)); | |||
AnnualPlanListItemVO itemVO = itemVOMap.get(projectId); | |||
// 年度计划库中不包含当前项目 | |||
if (Objects.isNull(itemVO)){ | |||
Project project = projectService.getById(projectId); | |||
Integer status = project.getStatus(); | |||
List<Integer> fieldList = CollUtils.fieldList(PROJECT_APPROVAL_LIST_STATUS, ProjectStatusEnum::getCode); | |||
// 项目状态为待立项批复之前的状态 | |||
if (fieldList.contains(status)){ | |||
processDetailVO.setStepStatus(StepStatusEnum.NOT_START); | |||
processDetailVO.setProcessName(CommonConstant.PROJECT_APPROVAL); | |||
processSchedule.add(processDetailVO); | |||
return; | |||
} | |||
Integer projectStatus = itemVO.getStatus(); | |||
List<Integer> fieldList = CollUtils.fieldList(ANNUAL_PLAN_LIST_STATUS, ProjectStatusEnum::getCode); | |||
// 年度计划库中包含当前项目,但当前项目状态在待立项批复之前 | |||
if (!fieldList.contains(projectStatus)) { | |||
processDetailVO.setStepStatus(StepStatusEnum.NOT_START); | |||
processDetailVO.setProcessName(CommonConstant.ANNUAL_PLAN); | |||
processSchedule.add(processDetailVO); | |||
return; | |||
} | |||
// 年度计划库包含当前项目且当前项目状态为待立项批复 | |||
Integer status = itemVO.getStatus(); | |||
// 当前项目状态为待立项批复 | |||
if (ProjectStatusEnum.TO_BE_APPROVED.getCode().equals(status)){ | |||
// 根据建设方案评审通过的时间获取 | |||
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class) | |||
@@ -100,9 +94,8 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle { | |||
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING); | |||
} else { | |||
// 年度计划库包含当前项目且当前项目状态为待立项批复之后的状态 | |||
// 当前项目状态为待立项批复之后的状态 | |||
// 根据立项批复的时间获取 | |||
Project project = projectService.getById(projectId); | |||
LocalDate approvalDate = project.getApprovalDate(); | |||
LocalDateTime approvalDateTime = approvalDate.atStartOfDay(); | |||
processDetailVO.setFinishTime(approvalDateTime); | |||
@@ -37,7 +37,7 @@ public class ProjectPreliminaryInspectionHandle extends AbstractProcessBusinessH | |||
/** | |||
* 项目状态为:建设中及之后的状态 | |||
*/ | |||
private static final List<ProjectStatusEnum> ANNUAL_PLAN_LIST_STATUS = Arrays.asList( | |||
private static final List<ProjectStatusEnum> PROJECT_PRELIMINARY_INSPECTION_LIST_STATUS = Arrays.asList( | |||
UNDER_CONSTRUCTION, | |||
TO_BE_FINALLY_INSPECTED, | |||
FINAL_ACCEPTANCE_IS_UNDER_REVIEW, | |||
@@ -54,7 +54,7 @@ public class ProjectPreliminaryInspectionHandle extends AbstractProcessBusinessH | |||
void businessHandle(Long projectId, List<ProcessDetailVO> processSchedule) { | |||
ProcessDetailVO processDetailVO = new ProcessDetailVO(); | |||
// 根据项目状态是否在建设中及之后的状态判断项目初验是否开始 | |||
List<Integer> fieldList = CollUtils.fieldList(ANNUAL_PLAN_LIST_STATUS, ProjectStatusEnum::getCode); | |||
List<Integer> fieldList = CollUtils.fieldList(PROJECT_PRELIMINARY_INSPECTION_LIST_STATUS, ProjectStatusEnum::getCode); | |||
Project project = projectService.getById(projectId); | |||
Integer status = project.getStatus(); | |||
// 项目状态不在建设中及之后的状态 | |||
@@ -41,7 +41,7 @@ public class TenderPurchaseHandle extends AbstractProcessBusinessHandle { | |||
/** | |||
* 项目状态为:建设中及之后的状态 | |||
*/ | |||
private static final List<ProjectStatusEnum> ANNUAL_PLAN_LIST_STATUS = Arrays.asList( | |||
private static final List<ProjectStatusEnum> TENDER_PURCHASE_LIST_STATUS = Arrays.asList( | |||
UNDER_CONSTRUCTION, | |||
TO_BE_FINALLY_INSPECTED, | |||
FINAL_ACCEPTANCE_IS_UNDER_REVIEW, | |||
@@ -67,7 +67,7 @@ public class TenderPurchaseHandle extends AbstractProcessBusinessHandle { | |||
processSchedule.add(processDetailVO); | |||
return; | |||
} | |||
List<Integer> fieldList = CollUtils.fieldList(ANNUAL_PLAN_LIST_STATUS, ProjectStatusEnum::getCode); | |||
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); | |||