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 9047f73..99bdaba 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 @@ -1,5 +1,6 @@ package com.hz.pm.api.workbench.manage; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; @@ -9,10 +10,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.model.entity.KeyValDTO; import com.hz.pm.api.common.statemachine.event.*; import com.hz.pm.api.common.util.DecimalUtil; +import com.hz.pm.api.projectdeclared.model.entity.Contract; import com.hz.pm.api.projectdeclared.model.entity.Purchase; +import com.hz.pm.api.projectdeclared.service.IContractService; import com.hz.pm.api.projectdeclared.service.IPurchaseService; import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; @@ -22,6 +24,7 @@ import com.hz.pm.api.projectlib.manage.ProjectLibManage; 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.service.IProjectGovSystemReplaceInfosService; @@ -44,6 +47,7 @@ import com.hz.pm.api.workbench.model.WorkbenchProjectLibReq; import com.hz.pm.api.workbench.model.WorkbenchReq; import com.hz.pm.api.workbench.model.vo.ProjectProcessStageStatisticsVO; import com.hz.pm.api.workbench.model.vo.ProjectTotalViewVO; +import com.hz.pm.api.workbench.model.vo.SystemReplaceStatVO; import com.hz.pm.api.workbench.model.vo.WorkbenchVO; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; @@ -60,6 +64,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.function.Predicate; import java.util.function.ToLongBiFunction; import java.util.function.ToLongFunction; import java.util.stream.Collectors; @@ -86,6 +91,7 @@ public class WorkbenchManage { private final IProjectService projectService; private final IProjectStatusChangeService projectStatusChangeService; private final IPurchaseService purchaseService; + private final IContractService contractService; private final MhUnitCache mhUnitCache; private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; private final IPurchaseStatusChangeService purchaseStatusChangeService; @@ -174,42 +180,61 @@ public class WorkbenchManage { public ProjectTotalViewVO projectTotalView(WorkbenchReq req) { ProjectTotalViewVO retDetail = new ProjectTotalViewVO(); initWorkbenchDefaultParam(req); - LambdaQueryWrapper query = Wrappers.lambdaQuery(Project.class) + LambdaQueryWrapper projectQuery = Wrappers.lambdaQuery(Project.class) + .ne(Project::getStatus, ProjectStatus.STOPPED_PASSED.getCode()) .select(Project::getReviewAmount, Project::getApprovalGovOwnFinanceAmount, Project::getId) .eq(Project::getProjectYear, req.getProjectYear()) .eq(Project::getNewest, Boolean.TRUE); List viewUnitIds = mhUnitCache.getViewChildIdsRecursion(req.getUnitId()); - query.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)); - List projects = projectService.list(query); + projectQuery.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)); + List projects = projectService.list(projectQuery); if (projects.isEmpty()) { return retDetail; } BigDecimal approvalAmount = DecimalUtil.sum(projects, Project::getApprovalGovOwnFinanceAmount); BigDecimal reviewAmount = DecimalUtil.sum(projects, Project::getReviewAmount); - retDetail.setTotalExecuteAmount(BigDecimal.ZERO); retDetail.setTotalApprovalAmount(approvalAmount); retDetail.setTotalReviewAmount(reviewAmount); + List projectIds = CollUtils.fieldList(projects, Project::getId); + // 合同金额 + List contracts = contractService.list(Wrappers.lambdaQuery(Contract.class) + .select(Contract::getTotalAmount, Contract::getId) + .in(Contract::getProjectId, projectIds)); + retDetail.setTotalContractAmount(DecimalUtil.sum(contracts, Contract::getTotalAmount)); + // 系统替代情况统计 Wrapper pgsriQuery = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class) - .in(ProjectGovSystemReplaceInfos::getProjectId, - CollUtils.fieldList(projects, Project::getId)); + .in(ProjectGovSystemReplaceInfos::getProjectId, projectIds); List systemReplaceInfos = systemReplaceInfosService.list(pgsriQuery); - Map typeCountMap = systemReplaceInfos.stream() - .map(w -> StrUtil.split(w.getReplaceType(), ",")) - .flatMap(Collection::stream) - .collect(Collectors.groupingBy(w -> { - if (!NumberUtil.isNumber(w)) { - return "其他"; - } else { - return GovSystemReplaceTypeEnum.get(Integer.parseInt(w)) - .flatMap(t -> Optional.of(t.getVal())) - .orElse("其他"); - } - }, Collectors.counting())); - typeCountMap.remove("其他"); - List> systemTypes = typeCountMap.entrySet().stream() - .map(w -> KeyValDTO.of(w.getKey(), w.getValue().intValue())) - .collect(Collectors.toList()); - retDetail.setSystemTypes(systemTypes); + Map> replaceInfosMap = new HashMap<>(); + for (ProjectGovSystemReplaceInfos systemReplaceInfo : systemReplaceInfos) { + List replaceTypes = StrUtil.split(systemReplaceInfo.getReplaceType(), ","); + for (String replaceType : replaceTypes) { + if (!NumberUtil.isNumber(replaceType)) { + replaceType = "其他"; + } else { + replaceType = GovSystemReplaceTypeEnum.get(Integer.parseInt(replaceType)) + .flatMap(t -> Optional.of(t.getVal())) + .orElse("其他"); + } + replaceInfosMap.computeIfAbsent(replaceType, k -> new ArrayList<>()).add(systemReplaceInfo); + } + } + Predicate isValidSystem = x -> StrUtil.isNotBlank(x) && !"/".equals(x); + replaceInfosMap.remove("其他"); + List systemReplaceStat = replaceInfosMap.entrySet().stream().map(w -> { + String replaceType = w.getKey(); + List replaceInfosList = w.getValue(); + int sourceCount = CollUtil.count(replaceInfosList, x -> isValidSystem.test(x.getSourceSystem())); + int targetCount = CollUtil.count(replaceInfosList, x -> isValidSystem.test(x.getTargetSystem())); + return SystemReplaceStatVO.builder() + .sourceCount(sourceCount) + .targetCount(targetCount) + .replaceType(replaceType) + .build(); + }).collect(Collectors.toList()); + retDetail.setTotalTargetSystemCount(CollUtil.count(systemReplaceInfos, x -> isValidSystem.test(x.getTargetSystem()))); + retDetail.setTotalSourceSystemCount(CollUtil.count(systemReplaceInfos, x -> isValidSystem.test(x.getSourceSystem()))); + retDetail.setSystemReplaceInfos(systemReplaceStat); return retDetail; } @@ -286,7 +311,7 @@ public class WorkbenchManage { projectCount = projectPurchaseCountMap.size(); if (bidCount > 0) { Wrapper pQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) - .select(PurchaseStatusChange::getEvent,PurchaseStatusChange::getProjectId) + .select(PurchaseStatusChange::getEvent, PurchaseStatusChange::getProjectId) .in(PurchaseStatusChange::getProjectId, allVersionProjectIds) .in(PurchaseStatusChange::getEvent, AdaptStateChangeEvent.ADAPT_INFO_PASSED, SelfTestStateChangeEvent.SELF_TEST_PASSED, diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/ProjectTotalViewVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/ProjectTotalViewVO.java index eff8cd3..dbd7314 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/ProjectTotalViewVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/ProjectTotalViewVO.java @@ -1,6 +1,5 @@ package com.hz.pm.api.workbench.model.vo; -import com.hz.pm.api.common.model.entity.KeyValDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -19,7 +18,13 @@ import java.util.List; public class ProjectTotalViewVO { @ApiModelProperty("系统类型(替代类型)") - private List> systemTypes; + private List systemReplaceInfos; + + @ApiModelProperty("替代前系统总数") + private Integer totalSourceSystemCount; + + @ApiModelProperty("替代后系统总数") + private Integer totalTargetSystemCount; @ApiModelProperty("评审金额") private BigDecimal totalReviewAmount; @@ -27,7 +32,7 @@ public class ProjectTotalViewVO { @ApiModelProperty("下达金额") private BigDecimal totalApprovalAmount; - @ApiModelProperty("执行金额") - private BigDecimal totalExecuteAmount; + @ApiModelProperty("合同金额") + private BigDecimal totalContractAmount; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/SystemReplaceStatVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/SystemReplaceStatVO.java new file mode 100644 index 0000000..259e945 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/SystemReplaceStatVO.java @@ -0,0 +1,28 @@ +package com.hz.pm.api.workbench.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +/** + *

+ * SystemReplaceStatVO + *

+ * + * @author WendyYang + * @since 10:00 2024/8/14 + */ +@Data +@Builder +public class SystemReplaceStatVO { + + @ApiModelProperty("替代类型") + private String replaceType; + + @ApiModelProperty("替代前数量") + private Integer sourceCount; + + @ApiModelProperty("替代后数量") + private Integer targetCount; + +}