|
@@ -1,5 +1,6 @@ |
|
|
package com.hz.pm.api.workbench.manage; |
|
|
package com.hz.pm.api.workbench.manage; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
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.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.hz.pm.api.common.helper.UserInfoHelper; |
|
|
import com.hz.pm.api.common.helper.UserInfoHelper; |
|
|
import com.hz.pm.api.common.model.constant.BizConst; |
|
|
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.statemachine.event.*; |
|
|
import com.hz.pm.api.common.util.DecimalUtil; |
|
|
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.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.service.IPurchaseService; |
|
|
import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; |
|
|
import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil; |
|
|
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; |
|
|
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.Project; |
|
|
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; |
|
|
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.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.req.ProjectListReq; |
|
|
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; |
|
|
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; |
|
|
import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; |
|
|
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.WorkbenchReq; |
|
|
import com.hz.pm.api.workbench.model.vo.ProjectProcessStageStatisticsVO; |
|
|
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.ProjectTotalViewVO; |
|
|
|
|
|
import com.hz.pm.api.workbench.model.vo.SystemReplaceStatVO; |
|
|
import com.hz.pm.api.workbench.model.vo.WorkbenchVO; |
|
|
import com.hz.pm.api.workbench.model.vo.WorkbenchVO; |
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
import com.ningdatech.basic.util.CollUtils; |
|
@@ -60,6 +64,7 @@ import java.time.LocalDate; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.temporal.ChronoUnit; |
|
|
import java.time.temporal.ChronoUnit; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.function.Predicate; |
|
|
import java.util.function.ToLongBiFunction; |
|
|
import java.util.function.ToLongBiFunction; |
|
|
import java.util.function.ToLongFunction; |
|
|
import java.util.function.ToLongFunction; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
@@ -86,6 +91,7 @@ public class WorkbenchManage { |
|
|
private final IProjectService projectService; |
|
|
private final IProjectService projectService; |
|
|
private final IProjectStatusChangeService projectStatusChangeService; |
|
|
private final IProjectStatusChangeService projectStatusChangeService; |
|
|
private final IPurchaseService purchaseService; |
|
|
private final IPurchaseService purchaseService; |
|
|
|
|
|
private final IContractService contractService; |
|
|
private final MhUnitCache mhUnitCache; |
|
|
private final MhUnitCache mhUnitCache; |
|
|
private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; |
|
|
private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; |
|
|
private final IPurchaseStatusChangeService purchaseStatusChangeService; |
|
|
private final IPurchaseStatusChangeService purchaseStatusChangeService; |
|
@@ -174,42 +180,61 @@ public class WorkbenchManage { |
|
|
public ProjectTotalViewVO projectTotalView(WorkbenchReq req) { |
|
|
public ProjectTotalViewVO projectTotalView(WorkbenchReq req) { |
|
|
ProjectTotalViewVO retDetail = new ProjectTotalViewVO(); |
|
|
ProjectTotalViewVO retDetail = new ProjectTotalViewVO(); |
|
|
initWorkbenchDefaultParam(req); |
|
|
initWorkbenchDefaultParam(req); |
|
|
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class) |
|
|
|
|
|
|
|
|
LambdaQueryWrapper<Project> projectQuery = Wrappers.lambdaQuery(Project.class) |
|
|
|
|
|
.ne(Project::getStatus, ProjectStatus.STOPPED_PASSED.getCode()) |
|
|
.select(Project::getReviewAmount, Project::getApprovalGovOwnFinanceAmount, Project::getId) |
|
|
.select(Project::getReviewAmount, Project::getApprovalGovOwnFinanceAmount, Project::getId) |
|
|
.eq(Project::getProjectYear, req.getProjectYear()) |
|
|
.eq(Project::getProjectYear, req.getProjectYear()) |
|
|
.eq(Project::getNewest, Boolean.TRUE); |
|
|
.eq(Project::getNewest, Boolean.TRUE); |
|
|
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(req.getUnitId()); |
|
|
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(req.getUnitId()); |
|
|
query.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)); |
|
|
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
|
|
|
|
|
projectQuery.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)); |
|
|
|
|
|
List<Project> projects = projectService.list(projectQuery); |
|
|
if (projects.isEmpty()) { |
|
|
if (projects.isEmpty()) { |
|
|
return retDetail; |
|
|
return retDetail; |
|
|
} |
|
|
} |
|
|
BigDecimal approvalAmount = DecimalUtil.sum(projects, Project::getApprovalGovOwnFinanceAmount); |
|
|
BigDecimal approvalAmount = DecimalUtil.sum(projects, Project::getApprovalGovOwnFinanceAmount); |
|
|
BigDecimal reviewAmount = DecimalUtil.sum(projects, Project::getReviewAmount); |
|
|
BigDecimal reviewAmount = DecimalUtil.sum(projects, Project::getReviewAmount); |
|
|
retDetail.setTotalExecuteAmount(BigDecimal.ZERO); |
|
|
|
|
|
retDetail.setTotalApprovalAmount(approvalAmount); |
|
|
retDetail.setTotalApprovalAmount(approvalAmount); |
|
|
retDetail.setTotalReviewAmount(reviewAmount); |
|
|
retDetail.setTotalReviewAmount(reviewAmount); |
|
|
|
|
|
List<Long> projectIds = CollUtils.fieldList(projects, Project::getId); |
|
|
|
|
|
// 合同金额 |
|
|
|
|
|
List<Contract> contracts = contractService.list(Wrappers.lambdaQuery(Contract.class) |
|
|
|
|
|
.select(Contract::getTotalAmount, Contract::getId) |
|
|
|
|
|
.in(Contract::getProjectId, projectIds)); |
|
|
|
|
|
retDetail.setTotalContractAmount(DecimalUtil.sum(contracts, Contract::getTotalAmount)); |
|
|
|
|
|
// 系统替代情况统计 |
|
|
Wrapper<ProjectGovSystemReplaceInfos> pgsriQuery = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class) |
|
|
Wrapper<ProjectGovSystemReplaceInfos> pgsriQuery = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class) |
|
|
.in(ProjectGovSystemReplaceInfos::getProjectId, |
|
|
|
|
|
CollUtils.fieldList(projects, Project::getId)); |
|
|
|
|
|
|
|
|
.in(ProjectGovSystemReplaceInfos::getProjectId, projectIds); |
|
|
List<ProjectGovSystemReplaceInfos> systemReplaceInfos = systemReplaceInfosService.list(pgsriQuery); |
|
|
List<ProjectGovSystemReplaceInfos> systemReplaceInfos = systemReplaceInfosService.list(pgsriQuery); |
|
|
Map<String, Long> 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<KeyValDTO<String, Integer>> systemTypes = typeCountMap.entrySet().stream() |
|
|
|
|
|
.map(w -> KeyValDTO.of(w.getKey(), w.getValue().intValue())) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
retDetail.setSystemTypes(systemTypes); |
|
|
|
|
|
|
|
|
Map<String, List<ProjectGovSystemReplaceInfos>> replaceInfosMap = new HashMap<>(); |
|
|
|
|
|
for (ProjectGovSystemReplaceInfos systemReplaceInfo : systemReplaceInfos) { |
|
|
|
|
|
List<String> 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<String> isValidSystem = x -> StrUtil.isNotBlank(x) && !"/".equals(x); |
|
|
|
|
|
replaceInfosMap.remove("其他"); |
|
|
|
|
|
List<SystemReplaceStatVO> systemReplaceStat = replaceInfosMap.entrySet().stream().map(w -> { |
|
|
|
|
|
String replaceType = w.getKey(); |
|
|
|
|
|
List<ProjectGovSystemReplaceInfos> 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; |
|
|
return retDetail; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -286,7 +311,7 @@ public class WorkbenchManage { |
|
|
projectCount = projectPurchaseCountMap.size(); |
|
|
projectCount = projectPurchaseCountMap.size(); |
|
|
if (bidCount > 0) { |
|
|
if (bidCount > 0) { |
|
|
Wrapper<PurchaseStatusChange> pQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) |
|
|
Wrapper<PurchaseStatusChange> pQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) |
|
|
.select(PurchaseStatusChange::getEvent,PurchaseStatusChange::getProjectId) |
|
|
|
|
|
|
|
|
.select(PurchaseStatusChange::getEvent, PurchaseStatusChange::getProjectId) |
|
|
.in(PurchaseStatusChange::getProjectId, allVersionProjectIds) |
|
|
.in(PurchaseStatusChange::getProjectId, allVersionProjectIds) |
|
|
.in(PurchaseStatusChange::getEvent, AdaptStateChangeEvent.ADAPT_INFO_PASSED, |
|
|
.in(PurchaseStatusChange::getEvent, AdaptStateChangeEvent.ADAPT_INFO_PASSED, |
|
|
SelfTestStateChangeEvent.SELF_TEST_PASSED, |
|
|
SelfTestStateChangeEvent.SELF_TEST_PASSED, |
|
|