diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/stage/ProjectDeclareHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/stage/ProjectDeclareHandle.java index b9467a3..1bef11f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/stage/ProjectDeclareHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/stage/ProjectDeclareHandle.java @@ -62,22 +62,26 @@ public class ProjectDeclareHandle extends AbstractProcessHandle { w -> InstTypeEnum.getNoNull(w.getInstType()), Comparator.comparing(ProjectInst::getCreateOn).reversed()); ctx.setProjectInstMap(instMap); - ProjectInst inst = instMap.get(InstTypeEnum.COMPLIANCE_REVIEW); - if (inst == null) { - detail.setStepStatus(StepStatusEnum.NOT_START); - } else { - Optional event = eventMap.values().stream() - .filter(w -> PROJECT_APPLICATION_SUBMIT.eq(w.getEvent()) - || COMPLIANCE_REVIEW_FAILED.eq(w.getEvent()) - || COMPLIANCE_REVIEW_RESUBMIT.eq(w.getEvent()) - || COMPLIANCE_REVIEW_PASS.eq(w.getEvent()) - ).max(Comparator.comparing(ProjectStatusChange::getCreateOn)); - if (event.isPresent()) { + Optional event = eventMap.values().stream() + .filter(w -> PROJECT_APPLICATION_SUBMIT.eq(w.getEvent()) + || COMPLIANCE_REVIEW_FAILED.eq(w.getEvent()) + || COMPLIANCE_REVIEW_RESUBMIT.eq(w.getEvent()) + || COMPLIANCE_REVIEW_PASS.eq(w.getEvent()) + ).max(Comparator.comparing(ProjectStatusChange::getCreateOn)); + if (event.isPresent()) { + ProjectStatusChange change = event.get(); + ProjectInst inst = instMap.get(InstTypeEnum.COMPLIANCE_REVIEW); + if (COMPLIANCE_REVIEW_PASS.eq(change.getEvent()) && inst == null) { + detail.setStepStatus(StepStatusEnum.COMPLETED); + detail.setFinishTime(change.getCreateOn()); + } else if (inst != null) { ProcessProgressVo progress = processInstanceService.getProgressInstanceDetail(null, inst.getInstCode()); - buildStepStatus(detail, progress, event.get()); + buildStepStatus(detail, progress, change); } else { detail.setStepStatus(StepStatusEnum.NOT_START); } + } else { + detail.setStepStatus(StepStatusEnum.NOT_START); } } ctx.setPreStepStatus(detail.getStepStatus()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/stage/ProjectReviewHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/stage/ProjectReviewHandle.java index 4d247cb..06cbb72 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/stage/ProjectReviewHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/stage/ProjectReviewHandle.java @@ -55,22 +55,26 @@ public class ProjectReviewHandle extends AbstractProcessHandle { if (!eventMap.containsKey(PROJECT_REVIEW_SUBMIT)) { detail.setStepStatus(StepStatusEnum.NOT_START); } else { - ProjectInst inst = ctx.getProjectInstMap().get(InstTypeEnum.PROJECT_REVIEW); - if (inst == null) { - detail.setStepStatus(StepStatusEnum.NOT_START); - } else { - Optional event = eventMap.values().stream() - .filter(w -> PROJECT_REVIEW_PASS.eq(w.getEvent()) - || PROJECT_REVIEW_RESUBMIT.eq(w.getEvent()) - || PROJECT_REVIEW_FAILED.eq(w.getEvent()) - || PROJECT_REVIEW_SUBMIT.eq(w.getEvent()) - ).max(Comparator.comparing(ProjectStatusChange::getCreateOn)); - if (event.isPresent()) { + Optional event = eventMap.values().stream() + .filter(w -> PROJECT_REVIEW_PASS.eq(w.getEvent()) + || PROJECT_REVIEW_RESUBMIT.eq(w.getEvent()) + || PROJECT_REVIEW_FAILED.eq(w.getEvent()) + || PROJECT_REVIEW_SUBMIT.eq(w.getEvent()) + ).max(Comparator.comparing(ProjectStatusChange::getCreateOn)); + if (event.isPresent()) { + ProjectStatusChange change = event.get(); + ProjectInst inst = ctx.getProjectInstMap().get(InstTypeEnum.PROJECT_REVIEW); + if (PROJECT_REVIEW_PASS.eq(change.getEvent()) && inst == null) { + detail.setStepStatus(StepStatusEnum.COMPLETED); + detail.setFinishTime(change.getCreateOn()); + } else if (inst != null) { ProcessProgressVo progress = processInstanceService.getProgressInstanceDetail(null, inst.getInstCode()); - buildStepStatus(detail, progress, event.get()); + buildStepStatus(detail, progress, change); } else { detail.setStepStatus(StepStatusEnum.NOT_START); } + } else { + detail.setStepStatus(StepStatusEnum.NOT_START); } } ctx.setPreStepStatus(detail.getStepStatus()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java index c5f50bb..b7f00d9 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectManageUtil.java @@ -69,6 +69,7 @@ public class ProjectManageUtil { .in(CollUtil.isNotEmpty(req.getInstCodes()), Project::getInstCode, req.getInstCodes()) //已添加评价计划的项目code .notIn(CollUtil.isNotEmpty(req.getProjectCodes()), Project::getProjectCode, req.getProjectCodes()) + .eq(req.getIsStartDeclaredProject() != null, Project::getAnnualPlanOpened, req.getIsStartDeclaredProject()) .orderByDesc(Project::getUpdateOn); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java index c2a5efc..929ac55 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java @@ -1,9 +1,7 @@ package com.hz.pm.api.projectlib.manage; import cn.hutool.core.bean.BeanUtil; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.helper.UserInfoHelper; @@ -18,7 +16,6 @@ import com.hz.pm.api.datascope.utils.DataScopeUtil; import com.hz.pm.api.projectlib.helper.ProjectManageUtil; import com.hz.pm.api.projectlib.model.dto.ProjectDTO; import com.hz.pm.api.projectlib.model.entity.Project; -import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; import com.hz.pm.api.projectlib.model.req.ProjectApprovedReq; import com.hz.pm.api.projectlib.model.req.ProjectIdReq; @@ -27,7 +24,6 @@ import com.hz.pm.api.projectlib.model.req.StartProjectDeclareReq; import com.hz.pm.api.projectlib.model.vo.AnnualPlanListItemVO; import com.hz.pm.api.projectlib.service.IProjectApplicationService; import com.hz.pm.api.projectlib.service.IProjectService; -import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.user.helper.MhUnitCache; import com.hz.pm.api.user.security.model.UserFullInfoDTO; @@ -67,7 +63,6 @@ public class AnnualPlanLibManage { private final IProjectApplicationService applicationService; private final ProjectStateMachineUtil stateMachine; private final UserInfoHelper userInfoHelper; - private final IProjectStatusChangeService projectStatusChangeService; public PageVo annulPlanLibList(ProjectListReq req) { LambdaQueryWrapper query = ProjectManageUtil.initQuery(); @@ -86,13 +81,6 @@ public class AnnualPlanLibManage { if (total == 0) { return PageVo.empty(); } - List projCodes = CollUtils.fieldList(page.getRecords(), Project::getProjectCode); - Wrapper pscQuery = Wrappers.lambdaQuery(ProjectStatusChange.class) - .select(ProjectStatusChange::getProjectCode) - .eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.ANNUAL_PLAN_PASS) - .in(ProjectStatusChange::getProjectCode, projCodes); - List changes = projectStatusChangeService.list(pscQuery); - List annualPlanProjCodes = CollUtils.fieldList(changes, ProjectStatusChange::getProjectCode); List records = CollUtils.convert(page.getRecords(), w -> { AnnualPlanListItemVO item = new AnnualPlanListItemVO(); item.setProjectId(w.getId()); @@ -106,7 +94,7 @@ public class AnnualPlanLibManage { item.setBuildOrg(w.getBuildOrgName()); item.setCreateOn(w.getCreateOn()); item.setApprovalAmount(w.getApprovalAmount()); - item.setIsStartDeclaredProject(annualPlanProjCodes.contains(w.getProjectCode())); + item.setIsStartDeclaredProject(w.getAnnualPlanOpened()); return item; }); return PageVo.of(records, total); @@ -120,7 +108,10 @@ public class AnnualPlanLibManage { throw BizException.wrap("开启方案申报失败"); } }); - projects.forEach(stateMachine::pass); + projects.forEach(w -> { + stateMachine.pass(w); + w.setAnnualPlanOpened(Boolean.TRUE); + }); projectService.updateBatchById(projects); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java index ffec330..cfd28b5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java @@ -146,22 +146,22 @@ public class ProjectDTO { @ApiModelProperty("项目简介") private String projectIntroduction; - @ApiModelProperty("资金情况-下达情况-申报金额(总计)(万元)") + @ApiModelProperty("资金情况-申报-申报金额(总计)(万元)") private BigDecimal declareAmount; - @ApiModelProperty("资金情况-下达情况-自有金额(万元)") + @ApiModelProperty("资金情况-申报-自有金额(万元)") private BigDecimal declareHaveAmount; - @ApiModelProperty("资金情况-下达情况-政府投资-本级财政资金(万元)") + @ApiModelProperty("资金情况-申报-政府投资-本级财政资金(万元)") private BigDecimal declareGovOwnFinanceAmount; - @ApiModelProperty("资金情况-下达情况-政府投资-上级补助资金(万元)") + @ApiModelProperty("资金情况-申报-政府投资-上级补助资金(万元)") private BigDecimal declareGovSuperiorFinanceAmount; - @ApiModelProperty("银行贷款(万元)") + @ApiModelProperty("申报-银行贷款(万元)") private BigDecimal declareBankLendingAmount; - @ApiModelProperty("其它资金(万元)") + @ApiModelProperty("申报-其它资金(万元)") private BigDecimal declareOtherAmount; @ApiModelProperty("申报资金-分配情况-软件开发(万元)") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java index da81c5b..e12422d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java @@ -580,4 +580,7 @@ public class Project implements Serializable { @ApiModelProperty("置顶") private Integer topped; + @ApiModelProperty("是否已开启年度计划") + private Boolean annualPlanOpened; + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java index e2e7de6..4b3838a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java @@ -114,4 +114,7 @@ public class ProjectListReq extends PagePo { @ApiModelProperty("评审金额最大值") private BigDecimal reviewAmountMax; + + private Boolean isStartDeclaredProject; + } diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/MhApiClientTest.java b/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/MhApiClientTest.java index ac565fd..ec84e78 100644 --- a/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/MhApiClientTest.java +++ b/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/MhApiClientTest.java @@ -1,25 +1,29 @@ package com.hz.pm.api.todocenter; -import cn.hutool.core.io.FileUtil; -import cn.hutool.http.HttpUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.AppTests; +import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.external.MhApiClient; import com.hz.pm.api.external.MhFileClient; import com.hz.pm.api.external.model.dto.MhZwddWorkNoticeDTO; import com.hz.pm.api.external.todo.MHTodoClient; import com.hz.pm.api.external.todo.dto.MhTodoExtraParamDTO; import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; +import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; +import com.hz.pm.api.projectlib.model.entity.MhProject; +import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; +import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; +import com.hz.pm.api.projectlib.service.IMhProjectService; +import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; import com.hz.pm.api.user.security.model.UserFullInfoDTO; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.file.entity.File; -import com.ningdatech.file.entity.vo.result.FileResultVO; import com.ningdatech.file.service.FileService; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Arrays; +import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** *

@@ -68,4 +72,63 @@ public class MhApiClientTest extends AppTests { mhApiClient.sendZwddWorkNotice(notice); } + @Autowired + private IProjectService projectService; + @Autowired + private IProjectStatusChangeService projectStatusChangeService; + @Autowired + private IMhProjectService mhProjectService; + + + @Test + public void test1() { + List projects = mhProjectService.list(); + for (MhProject project : projects) { + if (project.getProjectCode() == null) { + continue; + } + projectStatusChangeService.remove(Wrappers.lambdaQuery(ProjectStatusChange.class) + .in(ProjectStatusChange::getEvent, + ProjectStateChangeEvent.PROJECT_APPLICATION_SUBMIT, + ProjectStateChangeEvent.COMPLIANCE_REVIEW_PASS, + ProjectStateChangeEvent.PROJECT_REVIEW_SUBMIT, + ProjectStateChangeEvent.PROJECT_REVIEW_PASS) + .eq(ProjectStatusChange::getProjectCode, project.getProjectCode())); + List changes = new ArrayList<>(); + changes.add(new ProjectStatusChange() {{ + setAfterStatus(ProjectStatus.ON_COMPLIANCE_REVIEW.getCode()); + setBeforeStatus(ProjectStatus.TO_BE_DECLARED.getCode()); + setEvent(ProjectStateChangeEvent.PROJECT_APPLICATION_SUBMIT.name()); + setCreateOn(LocalDateTime.now()); + setProjectCode(project.getProjectCode()); + setProjectId(ProjectIdCodeCacheUtil.newest(project.getProjectCode())); + }}); + changes.add(new ProjectStatusChange() {{ + setAfterStatus(ProjectStatus.WITHOUT_PROJECT_REVIEW.getCode()); + setBeforeStatus(ProjectStatus.ON_COMPLIANCE_REVIEW.getCode()); + setEvent(ProjectStateChangeEvent.COMPLIANCE_REVIEW_PASS.name()); + setCreateOn(LocalDateTime.now().plusMinutes(1)); + setProjectCode(project.getProjectCode()); + setProjectId(ProjectIdCodeCacheUtil.newest(project.getProjectCode())); + }}); + changes.add(new ProjectStatusChange() {{ + setAfterStatus(ProjectStatus.ON_PROJECT_REVIEW.getCode()); + setBeforeStatus(ProjectStatus.WITHOUT_PROJECT_REVIEW.getCode()); + setEvent(ProjectStateChangeEvent.PROJECT_REVIEW_SUBMIT.name()); + setCreateOn(LocalDateTime.now().plusMinutes(2)); + setProjectCode(project.getProjectCode()); + setProjectId(ProjectIdCodeCacheUtil.newest(project.getProjectCode())); + }}); + changes.add(new ProjectStatusChange() {{ + setAfterStatus(ProjectStatus.ON_ANNUAL_PLAN.getCode()); + setBeforeStatus(ProjectStatus.ON_PROJECT_REVIEW.getCode()); + setEvent(ProjectStateChangeEvent.PROJECT_REVIEW_PASS.name()); + setCreateOn(LocalDateTime.now().plusMinutes(3)); + setProjectCode(project.getProjectCode()); + setProjectId(ProjectIdCodeCacheUtil.newest(project.getProjectCode())); + }}); + projectStatusChangeService.saveBatch(changes); + } + } + }