diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/GovSystemReplaceInfoDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/GovSystemReplaceInfoDTO.java index a3cb23b..f7a12a1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/GovSystemReplaceInfoDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/GovSystemReplaceInfoDTO.java @@ -21,6 +21,12 @@ public class GovSystemReplaceInfoDTO implements Serializable { private static final long serialVersionUID = -1054216204216816787L; + @ApiModelProperty("项目名称") + private String projectName; + + @ApiModelProperty("申报单位") + private String buildOrgName; + @ApiModelProperty("替代前系统名称") private List sourceSystemNames; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java index 2160a1c..bf1abeb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java @@ -2,6 +2,7 @@ package com.hz.pm.api.user.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -94,11 +95,24 @@ public class MhUnitManage { List nodes = allUnits.stream() .filter(w -> MhUnitTypeEnum.SASAC.equals(w.getType()) || ((MhUnitTypeEnum.REGION.equals(w.getType()) || MhUnitTypeEnum.NODE.equals(w.getType())) - && (w.getName().endsWith("信创办") || "市级部门".equals(w.getName()) || "杭州市".equals(w.getName())))) - .map(w -> BeanUtil.copyProperties(w, MhUnitTreeDTO.class)) - .collect(Collectors.toList()); + && (w.getName().endsWith("信创办") + || "市级部门".equals(w.getName()) + || "杭州市".equals(w.getName()) + || "区县部门".equals(w.getName())))) + .map(w -> { + MhUnitTreeDTO unit = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); + if ("区县部门".equals(w.getName())) { + UnitDTO parent = mhUnitCache.getById(unit.getParentId()); + if (parent != null) { + String parentName = StrUtil.blankToDefault(parent.getShortName(), parent.getName()); + String unitName = StrUtil.blankToDefault(unit.getShortName(), unit.getName()); + unit.setShortName(parentName + unitName); + } + } + return unit; + }).collect(Collectors.toList()); Function function = w -> w.getType().getStrip().getCode(); - nodes.sort(Comparator.comparing(MhUnitTreeDTO::getName) + nodes.sort(Comparator.comparing(MhUnitTreeDTO::getShortName) .thenComparing(function, Comparator.reverseOrder())); return nodes; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/controller/WorkbenchController.java b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/controller/WorkbenchController.java index c29662c..29cae02 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/controller/WorkbenchController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/controller/WorkbenchController.java @@ -1,6 +1,7 @@ package com.hz.pm.api.workbench.controller; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; +import com.hz.pm.api.projectlib.model.vo.SystemReplaceInfoVO; import com.hz.pm.api.workbench.manage.WorkbenchManage; import com.hz.pm.api.workbench.model.WorkbenchProjectLibReq; import com.hz.pm.api.workbench.model.WorkbenchReq; @@ -70,4 +71,10 @@ public class WorkbenchController { return workbenchManage.pageProjectLib(req); } + @GetMapping("/systemReplaceInfos") + @ApiOperation("获取项目替代情况") + public SystemReplaceInfoVO systemReplaceInfos(WorkbenchProjectLibReq req ) { + return workbenchManage.listSystemReplaceInfos(req); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java index 85d23b2..2b5afb1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java @@ -23,12 +23,15 @@ import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; import com.hz.pm.api.projectlib.helper.ProjectManageUtil; import com.hz.pm.api.projectlib.manage.ProjectLibManage; +import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO; 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.GovSystemReplaceTypeEnum; -import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; import com.hz.pm.api.projectlib.model.req.ProjectListReq; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; +import com.hz.pm.api.projectlib.model.vo.SystemReplaceInfoVO; +import com.hz.pm.api.projectlib.model.vo.UnitProjectGovSystemReplaceVO; +import com.hz.pm.api.projectlib.model.vo.UnitProjectGovSystemReplaceVO.ProjectGovSystemReplaceVO; import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; @@ -68,6 +71,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiFunction; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -188,7 +192,7 @@ public class WorkbenchManage { initWorkbenchDefaultParam(req); LambdaQueryWrapper projectQuery = Wrappers.lambdaQuery(Project.class) .select(Project::getReviewAmount, Project::getApprovalAmount, Project::getId, - Project::getApprovalGovOwnFinanceAmount,Project::getApprovalGovSuperiorFinanceAmount) + Project::getApprovalGovOwnFinanceAmount, Project::getApprovalGovSuperiorFinanceAmount) .eq(Project::getProjectYear, req.getProjectYear()) .eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) .eq(Project::getNewest, Boolean.TRUE); @@ -520,23 +524,7 @@ public class WorkbenchManage { } public PageVo pageProjectLib(WorkbenchProjectLibReq req) { - Assert.notNull(req.getProcessNode(), "节点不能为空"); - Long unitId = Optional.ofNullable(req.getUnitId()).orElseGet(LoginUserUtil::getMhUnitId); - List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(unitId); - LambdaQueryWrapper query = Wrappers.lambdaQuery(Project.class) - .eq(req.getProjectYear() != null, Project::getProjectYear, req.getProjectYear()) - .like(StrUtil.isNotBlank(req.getBuildOrg()), Project::getBuildOrgName, req.getBuildOrg()) - .like(StrUtil.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()) - .in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)) - // 评审金额 - .ge(req.getReviewAmountMin() != null, Project::getReviewAmount, req.getReviewAmountMin()) - .le(req.getReviewAmountMax() != null, Project::getReviewAmount, req.getReviewAmountMax()) - // 下达金额 - .ge(req.getApproveAmountMin() != null, Project::getApprovalAmount, req.getApproveAmountMin()) - .le(req.getApproveAmountMax() != null, Project::getApprovalAmount, req.getApproveAmountMax()) - .eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) - .eq(Project::getNewest, Boolean.TRUE) - .orderByDesc(Project::getUpdateOn); + LambdaQueryWrapper query = workbenchProjectLibQuery(req); ProjectManageUtil.projectBaseQuery(query); projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.PROJECT_APPLICATION_SUBMIT); switch (req.getProcessNode()) { @@ -590,4 +578,123 @@ public class WorkbenchManage { return PageVo.of(records, page.getTotal()); } + public SystemReplaceInfoVO listSystemReplaceInfos(WorkbenchProjectLibReq req) { + LambdaQueryWrapper query = workbenchProjectLibQuery(req) + .select(Project::getProjectCode, Project::getProjectName, + Project::getBuildOrgCode, Project::getBuildOrgName); + projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.PROJECT_APPLICATION_SUBMIT); + switch (req.getProcessNode()) { + case PROJECT_DECLARED: + break; + case PROJECT_REVIEW: + projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.PROJECT_REVIEW_PASS); + break; + case APPROVAL_AMOUNT: + query.isNotNull(Project::getApprovalAmount).gt(Project::getApprovalAmount, BigDecimal.ZERO); + break; + case PROJECT_APPROVAL: + projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.DECLARED_RECORD_SUBMIT); + break; + case PROJECT_PURCHASE: + projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD); + break; + case FIRST_INSPECTED: + projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES); + break; + case PROJECT_ADAPTION: + projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM); + break; + case FINAL_INSPECTED: + projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.FINAL_ACCEPTANCE_PASS); + break; + default: + return null; + } + List projects = projectService.list(query); + return buildSystemReplaceInfos(projects); + } + + private LambdaQueryWrapper workbenchProjectLibQuery(WorkbenchProjectLibReq req) { + Assert.notNull(req.getProcessNode(), "节点不能为空"); + Long unitId = Optional.ofNullable(req.getUnitId()).orElseGet(LoginUserUtil::getMhUnitId); + List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(unitId); + return Wrappers.lambdaQuery(Project.class) + .eq(req.getProjectYear() != null, Project::getProjectYear, req.getProjectYear()) + .like(StrUtil.isNotBlank(req.getBuildOrg()), Project::getBuildOrgName, req.getBuildOrg()) + .like(StrUtil.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()) + .in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)) + .ge(req.getReviewAmountMin() != null, Project::getReviewAmount, req.getReviewAmountMin()) + .le(req.getReviewAmountMax() != null, Project::getReviewAmount, req.getReviewAmountMax()) + .ge(req.getApproveAmountMin() != null, Project::getApprovalAmount, req.getApproveAmountMin()) + .le(req.getApproveAmountMax() != null, Project::getApprovalAmount, req.getApproveAmountMax()) + .eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) + .eq(Project::getNewest, Boolean.TRUE) + .orderByDesc(Project::getUpdateOn); + } + + private SystemReplaceInfoVO buildSystemReplaceInfos(List projects) { + if (projects.isEmpty()) { + return null; + } + List projectCodes = CollUtils.fieldList(projects, Project::getProjectCode); + Wrapper query = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class) + .in(ProjectGovSystemReplaceInfos::getProjectCode, projectCodes); + List systemReplaceInfos = systemReplaceInfosService.list(query); + if (systemReplaceInfos.isEmpty()) { + return null; + } + SystemReplaceInfoVO retDetail = new SystemReplaceInfoVO(); + Map> projectSystemMap = CollUtils.group(systemReplaceInfos, + ProjectGovSystemReplaceInfos::getProjectCode); + Map> unitProjectMap = CollUtils.group(projects, Project::getBuildOrgCode); + List retList = new ArrayList<>(); + AtomicInteger sourceCount = new AtomicInteger(0); + AtomicInteger targetCount = new AtomicInteger(0); + for (Map.Entry> entry : unitProjectMap.entrySet()) { + List tmpProjects = entry.getValue(); + List currOrgReplaceInfos = new ArrayList<>(); + for (Project proj : tmpProjects) { + List replaceInfos = projectSystemMap.get(proj.getProjectCode()); + if (replaceInfos != null) { + ProjectGovSystemReplaceVO projectSystem = new ProjectGovSystemReplaceVO(); + projectSystem.setProjectName(proj.getProjectName()); + currOrgReplaceInfos.add(projectSystem); + Map> replaceInfoGroup = CollUtils.group(replaceInfos, + ProjectGovSystemReplaceInfos::getBatchNo); + List replaceInfoList = replaceInfoGroup.entrySet().stream() + .sorted(Comparator.comparingInt(Map.Entry::getKey)) + .map(w -> { + List currBatchValues = w.getValue(); + ProjectGovSystemReplaceInfos firstReplaceInfo = currBatchValues.get(0); + GovSystemReplaceInfoDTO replaceInfo = new GovSystemReplaceInfoDTO(); + replaceInfo.setReplaceType(firstReplaceInfo.getReplaceType()); + replaceInfo.setTargetSystemName(firstReplaceInfo.getTargetSystem()); + List sourceSystemNames = CollUtils.fieldList(currBatchValues, val -> { + String sourceSystem = val.getSourceSystem(); + if (isValidSystem.test(sourceSystem)) { + sourceCount.incrementAndGet(); + } + return sourceSystem; + }); + replaceInfo.setSourceSystemNames(sourceSystemNames); + if (isValidSystem.test(replaceInfo.getTargetSystemName())) { + targetCount.incrementAndGet(); + } + return replaceInfo; + }).collect(Collectors.toList()); + projectSystem.setReplaceSystems(replaceInfoList); + } + } + if (!currOrgReplaceInfos.isEmpty()) { + UnitProjectGovSystemReplaceVO item = new UnitProjectGovSystemReplaceVO(); + item.setUnitName(tmpProjects.get(0).getBuildOrgName()); + item.setProjectSystemReplaces(currOrgReplaceInfos); + retList.add(item); + } + } + retDetail.setBeforeReplace(sourceCount.get()); + retDetail.setAfterReplace(targetCount.get()); + retDetail.setReplaceDetail(retList); + return retDetail; + } }