Browse Source

modify:

1. 工作台各阶段项目数标段数统计修改;
tags/24080901
WendyYang 4 months ago
parent
commit
9970bd4dcf
2 changed files with 66 additions and 28 deletions
  1. +60
    -27
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java
  2. +6
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/ProjectProcessStageStatisticsVO.java

+ 60
- 27
hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java View File

@@ -221,8 +221,26 @@ public class WorkbenchManage {
initWorkbenchDefaultParam(req);
List<ProjectProcessStageStatisticsVO> retData = new ArrayList<>();
List<Long> allVersionProjectIds = new ArrayList<>();
Map<String, Long> purchaseEventMap = new HashMap<>();
ToLongFunction<AbstractStateChangeEvent> countPurchase = event -> purchaseEventMap.getOrDefault(event.name(), 0L);
Map<String, Map<Long, Long>> purchaseEventMap = new HashMap<>();
Map<Long, Long> projectPurchaseCountMap = new HashMap<>();
ToLongFunction<AbstractStateChangeEvent> countPurchase = event -> {
Map<Long, Long> projBizMap = purchaseEventMap.getOrDefault(event.name(), Collections.emptyMap());
return projBizMap.values().stream().mapToLong(l -> l).sum();
};
ToLongFunction<AbstractStateChangeEvent> countProject = event -> {
Map<Long, Long> projBizMap = purchaseEventMap.getOrDefault(event.name(), Collections.emptyMap());
if (event.name().equals(ProcessNode.PROJECT_ADAPTION.name())
|| event.name().equals(ProcessNode.SYSTEM_SELF_TEST.name())
|| event.name().equals(ProcessNode.SYSTEM_TEST_VALID.name())
|| event.name().equals(ProcessNode.XCFHX_REVIEW.name())) {
return projBizMap.size();
} else {
return projectPurchaseCountMap.entrySet().stream().filter(w -> {
Long finishedBizCount = projBizMap.get(w.getKey());
return finishedBizCount != null && finishedBizCount.equals(w.getValue());
}).count();
}
};
// 查询完成立项备案的项目
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(req.getUnitId());
Wrapper<Project> query = Wrappers.lambdaQuery(Project.class)
@@ -235,33 +253,36 @@ public class WorkbenchManage {
.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf));
List<Project> projects = projectService.list(query);
for (ProcessNode node : ProcessNode.ALL) {
long count;
if (projects.isEmpty()) {
count = 0;
} else {
long projectCount = 0;
long bidCount = 0;
if (!projects.isEmpty()) {
switch (node) {
case PROJECT_DECLARED:
count = projects.size();
projectCount = projects.size();
for (Project project : projects) {
allVersionProjectIds.addAll(ProjectIdCodeCacheUtil.get(project.getProjectCode()));
}
break;
case PROJECT_REVIEW:
count = getProjectCount(allVersionProjectIds, ProjectStateChangeEvent.PROJECT_REVIEW_PASS);
projectCount = getProjectCount(allVersionProjectIds, ProjectStateChangeEvent.PROJECT_REVIEW_PASS);
break;
case APPROVAL_AMOUNT:
count = projects.stream()
projectCount = projects.stream()
.filter(w -> w.getApprovalAmount() != null)
.filter(w -> w.getApprovalAmount().compareTo(BigDecimal.ZERO) > 0)
.count();
break;
case PROJECT_APPROVAL:
count = getProjectCount(allVersionProjectIds, ProjectStateChangeEvent.DECLARED_RECORD_PASS);
projectCount = getProjectCount(allVersionProjectIds, ProjectStateChangeEvent.DECLARED_RECORD_PASS);
break;
case PROJECT_PURCHASE:
count = purchaseService.count(Wrappers.lambdaQuery(Purchase.class)
List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class)
.select(Purchase::getId, Purchase::getProjectId)
.in(Purchase::getProjectId, allVersionProjectIds));
if (count > 0) {
bidCount = purchases.size();
projectPurchaseCountMap.putAll(CollUtils.groupCount(purchases, Purchase::getProjectId));
projectCount = projectPurchaseCountMap.size();
if (bidCount > 0) {
Wrapper<PurchaseStatusChange> pQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class)
.select(PurchaseStatusChange::getEvent)
.in(PurchaseStatusChange::getProjectId, allVersionProjectIds)
@@ -272,39 +293,49 @@ public class WorkbenchManage {
XcfhxStateChangeEvent.XCFHX_APPLY_PASSED,
TenderStateChangeEvent.FINALLY_INSPECTED_PASSED);
List<PurchaseStatusChange> changes = purchaseStatusChangeService.list(pQuery);
changes.forEach(change -> purchaseEventMap.merge(change.getEvent(), 1L, Long::sum));
Map<String, Map<Long, Long>> purchaseEventMapTmp = changes.stream()
.collect(Collectors.groupingBy(PurchaseStatusChange::getEvent,
Collectors.collectingAndThen(Collectors.toList(),
w -> CollUtils.groupCount(w, PurchaseStatusChange::getProjectId))));
purchaseEventMap.putAll(purchaseEventMapTmp);
}
break;
case PROJECT_ADAPTION:
count = countPurchase.applyAsLong(AdaptStateChangeEvent.ADAPT_INFO_PASSED);
bidCount = countPurchase.applyAsLong(AdaptStateChangeEvent.ADAPT_INFO_PASSED);
projectCount = countProject.applyAsLong(AdaptStateChangeEvent.ADAPT_INFO_PASSED);
break;
case SYSTEM_SELF_TEST:
count = countPurchase.applyAsLong(SelfTestStateChangeEvent.SELF_TEST_PASSED);
bidCount = countPurchase.applyAsLong(SelfTestStateChangeEvent.SELF_TEST_PASSED);
projectCount = countProject.applyAsLong(SelfTestStateChangeEvent.SELF_TEST_PASSED);
break;
case SYSTEM_TEST_VALID:
count = countPurchase.applyAsLong(TestValidStateChangeEvent.TEST_VALID_INFO_PASSED);
bidCount = countPurchase.applyAsLong(TestValidStateChangeEvent.TEST_VALID_INFO_PASSED);
projectCount = countProject.applyAsLong(TestValidStateChangeEvent.TEST_VALID_INFO_PASSED);
break;
case FIRST_INSPECTED:
case PILOT_RUNNING:
// 初验试运行数量同步
count = countPurchase.applyAsLong(TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES);
bidCount = countPurchase.applyAsLong(TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES);
projectCount = countProject.applyAsLong(TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES);
break;
case XCFHX_REVIEW:
count = countPurchase.applyAsLong(XcfhxStateChangeEvent.XCFHX_APPLY_PASSED);
bidCount = countPurchase.applyAsLong(XcfhxStateChangeEvent.XCFHX_APPLY_PASSED);
projectCount = countProject.applyAsLong(XcfhxStateChangeEvent.XCFHX_APPLY_PASSED);
break;
case FINAL_INSPECTED:
count = countPurchase.applyAsLong(TenderStateChangeEvent.FINALLY_INSPECTED_PASSED);
bidCount = countPurchase.applyAsLong(TenderStateChangeEvent.FINALLY_INSPECTED_PASSED);
projectCount = countProject.applyAsLong(TenderStateChangeEvent.FINALLY_INSPECTED_PASSED);
break;
default:
count = 0;
break;
}
retData.add(ProjectProcessStageStatisticsVO.builder()
.stage(node)
.stageName(node.getName())
.projectCount((int) projectCount)
.bidCount((int) bidCount)
.build());
}
retData.add(ProjectProcessStageStatisticsVO.builder()
.stage(node)
.stageName(node.getName())
.count((int) count)
.build());
}
return retData;
}
@@ -401,13 +432,15 @@ public class WorkbenchManage {
return PageVo.of(records, page.getTotal());
}

private static void projectQueryByProjectStatusChange(LambdaQueryWrapper<Project> query, AbstractStateChangeEvent event) {
private static void projectQueryByProjectStatusChange
(LambdaQueryWrapper<Project> query, AbstractStateChangeEvent event) {
query.exists("select 1 from nd_project_status_change npsc" +
" where nd_project.project_code = npsc.project_code" +
" and npsc.event = {0}", event);
}

private static void projectQueryByPurchaseStatusChange(LambdaQueryWrapper<Project> query, AbstractStateChangeEvent event) {
private static void projectQueryByPurchaseStatusChange
(LambdaQueryWrapper<Project> query, AbstractStateChangeEvent event) {
query.exists("select 1 from nd_purchase_status_change npsc" +
" where nd_project.project_code = npsc.project_code" +
" and npsc.event ={0}", event.name());


+ 6
- 1
hz-pm-api/src/main/java/com/hz/pm/api/workbench/model/vo/ProjectProcessStageStatisticsVO.java View File

@@ -1,6 +1,7 @@
package com.hz.pm.api.workbench.model.vo;

import com.hz.pm.api.projectlib.handle.AbstractProcessHandle.ProcessNode;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

@@ -20,6 +21,10 @@ public class ProjectProcessStageStatisticsVO {

private String stageName;

private Integer count;
@ApiModelProperty("标段数量")
private Integer bidCount;

@ApiModelProperty("项目数量")
private Integer projectCount;

}

Loading…
Cancel
Save