|
|
@@ -259,10 +259,10 @@ public class WorkbenchManage { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<String> getProjectCodes(List<Long> projectIds, ProjectStateChangeEvent event) { |
|
|
|
public List<String> getProjectCodes(List<String> projectCodes, ProjectStateChangeEvent event) { |
|
|
|
Wrapper<ProjectStatusChange> query = Wrappers.lambdaQuery(ProjectStatusChange.class) |
|
|
|
.select(ProjectStatusChange::getProjectCode) |
|
|
|
.in(ProjectStatusChange::getProjectId, projectIds) |
|
|
|
.in(ProjectStatusChange::getProjectCode, projectCodes) |
|
|
|
.eq(ProjectStatusChange::getEvent, event); |
|
|
|
return CollUtils.fieldList(projectStatusChangeService.list(query), ProjectStatusChange::getProjectCode); |
|
|
|
} |
|
|
@@ -271,6 +271,7 @@ public class WorkbenchManage { |
|
|
|
initWorkbenchDefaultParam(req); |
|
|
|
List<ProjectProcessStatVO> retData = new ArrayList<>(); |
|
|
|
List<Long> allProjectIds = new ArrayList<>(); |
|
|
|
List<String> allProjectCodes = new ArrayList<>(); |
|
|
|
Map<String, Map<Long, Long>> purchaseEventMap = new HashMap<>(); |
|
|
|
Map<Long, Long> projectPurchaseCountMap = new HashMap<>(); |
|
|
|
BiFunction<AbstractStateChangeEvent, WorkbenchProcessNode, List<Long>> computeProjectIds = (event, node) -> { |
|
|
@@ -289,33 +290,48 @@ public class WorkbenchManage { |
|
|
|
Wrapper<Project> query = Wrappers.lambdaQuery(Project.class) |
|
|
|
.select(Project::getId, Project::getApprovalAmount, Project::getProjectCode) |
|
|
|
.eq(Project::getProjectYear, req.getProjectYear()) |
|
|
|
.eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.exists(ExistsSqlConst.PROJECT_EXISTS_STATUS_CHANGE + " and npsc.event = {0}", |
|
|
|
ProjectStateChangeEvent.PROJECT_APPLICATION_SUBMIT) |
|
|
|
.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)); |
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
Map<String, List<ProjectStatusChange>> projectStatusChangeMap = new HashMap<>(); |
|
|
|
for (WorkbenchProcessNode node : WorkbenchProcessNode.ALL) { |
|
|
|
int projectCount; |
|
|
|
int targetCount; |
|
|
|
int sourceCount; |
|
|
|
if (!projects.isEmpty()) { |
|
|
|
ProjectProcessStatVO currStat = ProjectProcessStatVO.builder() |
|
|
|
.stageName(node.name()) |
|
|
|
.stage(node) |
|
|
|
.build(); |
|
|
|
switch (node) { |
|
|
|
case PROJECT_DECLARED: { |
|
|
|
projectCount = projects.size(); |
|
|
|
currStat.setProjectCount(projects.size()); |
|
|
|
for (Project project : projects) { |
|
|
|
allProjectCodes.add(project.getProjectCode()); |
|
|
|
allProjectIds.addAll(ProjectIdCodeCacheUtil.get(project.getProjectCode())); |
|
|
|
} |
|
|
|
Wrapper<ProjectStatusChange> pscQuery = Wrappers.lambdaQuery(ProjectStatusChange.class) |
|
|
|
.in(ProjectStatusChange::getProjectCode, allProjectCodes); |
|
|
|
List<ProjectStatusChange> projectStatusChanges = projectStatusChangeService.list(pscQuery); |
|
|
|
projectStatusChangeMap.putAll(CollUtils.group(projectStatusChanges, ProjectStatusChange::getProjectCode)); |
|
|
|
currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, allProjectCodes)); |
|
|
|
Pair<Integer, Integer> replaceSystemCount = countReplaceSystemByProjectIds(allProjectIds); |
|
|
|
sourceCount = replaceSystemCount.getKey(); |
|
|
|
targetCount = replaceSystemCount.getValue(); |
|
|
|
currStat.setSourceCount(replaceSystemCount.getKey()); |
|
|
|
currStat.setTargetCount(replaceSystemCount.getValue()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case PROJECT_REVIEW: { |
|
|
|
List<String> projectCodes = getProjectCodes(allProjectIds, ProjectStateChangeEvent.PROJECT_REVIEW_PASS); |
|
|
|
projectCount = projectCodes.size(); |
|
|
|
List<String> projectCodes = getProjectCodes(allProjectCodes, ProjectStateChangeEvent.PROJECT_REVIEW_PASS); |
|
|
|
currStat.setProjectCount(projectCodes.size()); |
|
|
|
Pair<Integer, Integer> systemReplaceCount = countReplaceSystemByProjectCodes(projectCodes); |
|
|
|
sourceCount = systemReplaceCount.getKey(); |
|
|
|
targetCount = systemReplaceCount.getValue(); |
|
|
|
currStat.setSourceCount(systemReplaceCount.getKey()); |
|
|
|
currStat.setTargetCount(systemReplaceCount.getValue()); |
|
|
|
currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, projectCodes)); |
|
|
|
int reviewFailed = lastMatchProjectCount(projectStatusChangeMap, ProjectStateChangeEvent.PROJECT_REVIEW_FAILED); |
|
|
|
int reviewing = lastMatchProjectCount(projectStatusChangeMap, ProjectStateChangeEvent.PROJECT_REVIEW_SUBMIT, |
|
|
|
ProjectStateChangeEvent.PROJECT_REVIEW_RESUBMIT); |
|
|
|
currStat.setReviewingCount(reviewing); |
|
|
|
currStat.setReviewFailedCount(reviewFailed); |
|
|
|
} |
|
|
|
break; |
|
|
|
case APPROVAL_AMOUNT: { |
|
|
@@ -324,29 +340,34 @@ public class WorkbenchManage { |
|
|
|
&& NumberUtil.isGreater(w.getApprovalAmount(), BigDecimal.ZERO)) |
|
|
|
.map(Project::getProjectCode) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
projectCount = projectCodes.size(); |
|
|
|
currStat.setProjectCount(projectCodes.size()); |
|
|
|
Pair<Integer, Integer> systemReplaceCount = countReplaceSystemByProjectCodes(projectCodes); |
|
|
|
sourceCount = systemReplaceCount.getKey(); |
|
|
|
targetCount = systemReplaceCount.getValue(); |
|
|
|
currStat.setSourceCount(systemReplaceCount.getKey()); |
|
|
|
currStat.setTargetCount(systemReplaceCount.getValue()); |
|
|
|
currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, projectCodes)); |
|
|
|
} |
|
|
|
break; |
|
|
|
case PROJECT_APPROVAL: { |
|
|
|
List<String> projectCodes = getProjectCodes(allProjectIds, ProjectStateChangeEvent.DECLARED_RECORD_SUBMIT); |
|
|
|
projectCount = projectCodes.size(); |
|
|
|
List<String> projectCodes = getProjectCodes(allProjectCodes, ProjectStateChangeEvent.DECLARED_RECORD_SUBMIT); |
|
|
|
currStat.setProjectCount(projectCodes.size()); |
|
|
|
Pair<Integer, Integer> systemReplaceCount = countReplaceSystemByProjectCodes(projectCodes); |
|
|
|
sourceCount = systemReplaceCount.getKey(); |
|
|
|
targetCount = systemReplaceCount.getValue(); |
|
|
|
currStat.setSourceCount(systemReplaceCount.getKey()); |
|
|
|
currStat.setTargetCount(systemReplaceCount.getValue()); |
|
|
|
currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, projectCodes)); |
|
|
|
} |
|
|
|
break; |
|
|
|
case PROJECT_PURCHASE: { |
|
|
|
List<Purchase> purchases = purchaseService.list(Wrappers.lambdaQuery(Purchase.class) |
|
|
|
Wrapper<Purchase> purchaseQuery = Wrappers.lambdaQuery(Purchase.class) |
|
|
|
.select(Purchase::getId, Purchase::getProjectId) |
|
|
|
.in(Purchase::getProjectId, allProjectIds)); |
|
|
|
.in(Purchase::getProjectId, allProjectIds); |
|
|
|
List<Purchase> purchases = purchaseService.list(purchaseQuery); |
|
|
|
projectPurchaseCountMap.putAll(CollUtils.groupCount(purchases, Purchase::getProjectId)); |
|
|
|
projectCount = projectPurchaseCountMap.size(); |
|
|
|
currStat.setProjectCount(projectPurchaseCountMap.size()); |
|
|
|
Pair<Integer, Integer> systemReplaceCount = countReplaceSystemByProjectIds(projectPurchaseCountMap.keySet()); |
|
|
|
sourceCount = systemReplaceCount.getKey(); |
|
|
|
targetCount = systemReplaceCount.getValue(); |
|
|
|
currStat.setSourceCount(systemReplaceCount.getKey()); |
|
|
|
currStat.setTargetCount(systemReplaceCount.getValue()); |
|
|
|
List<String> projectCodes = CollUtils.convert(projectPurchaseCountMap.keySet(), ProjectIdCodeCacheUtil::get); |
|
|
|
currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, projectCodes)); |
|
|
|
if (!purchases.isEmpty()) { |
|
|
|
Wrapper<PurchaseStatusChange> pQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) |
|
|
|
.select(PurchaseStatusChange::getEvent, PurchaseStatusChange::getProjectId) |
|
|
@@ -370,43 +391,58 @@ public class WorkbenchManage { |
|
|
|
case PROJECT_ADAPTION: { |
|
|
|
List<Long> projectIds = computeProjectIds.apply(AdaptStateChangeEvent.ADAPT_INFO_PASSED, node); |
|
|
|
Pair<Integer, Integer> replaceSystemCount = countReplaceSystemByProjectIds(projectIds); |
|
|
|
targetCount = replaceSystemCount.getKey(); |
|
|
|
sourceCount = replaceSystemCount.getValue(); |
|
|
|
projectCount = projectIds.size(); |
|
|
|
currStat.setProjectCount(projectIds.size()); |
|
|
|
currStat.setSourceCount(replaceSystemCount.getKey()); |
|
|
|
currStat.setTargetCount(replaceSystemCount.getValue()); |
|
|
|
List<String> projectCodes = CollUtils.convert(projectIds, ProjectIdCodeCacheUtil::get); |
|
|
|
currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, projectCodes)); |
|
|
|
} |
|
|
|
break; |
|
|
|
case FIRST_INSPECTED: { |
|
|
|
List<Long> projectIds = computeProjectIds.apply(TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES, node); |
|
|
|
Pair<Integer, Integer> replaceSystemCount = countReplaceSystemByProjectIds(projectIds); |
|
|
|
targetCount = replaceSystemCount.getKey(); |
|
|
|
sourceCount = replaceSystemCount.getValue(); |
|
|
|
projectCount = projectIds.size(); |
|
|
|
currStat.setProjectCount(projectIds.size()); |
|
|
|
currStat.setSourceCount(replaceSystemCount.getKey()); |
|
|
|
currStat.setTargetCount(replaceSystemCount.getValue()); |
|
|
|
List<String> projectCodes = CollUtils.convert(projectIds, ProjectIdCodeCacheUtil::get); |
|
|
|
currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, projectCodes)); |
|
|
|
} |
|
|
|
break; |
|
|
|
case FINAL_INSPECTED: { |
|
|
|
List<Long> projectIds = computeProjectIds.apply(TenderStateChangeEvent.FINALLY_INSPECTED_PASSED, node); |
|
|
|
Pair<Integer, Integer> replaceSystemCount = countReplaceSystemByProjectIds(projectIds); |
|
|
|
projectCount = projectIds.size(); |
|
|
|
targetCount = replaceSystemCount.getKey(); |
|
|
|
sourceCount = replaceSystemCount.getValue(); |
|
|
|
currStat.setProjectCount(projectIds.size()); |
|
|
|
currStat.setSourceCount(replaceSystemCount.getKey()); |
|
|
|
currStat.setTargetCount(replaceSystemCount.getValue()); |
|
|
|
List<String> projectCodes = CollUtils.convert(projectIds, ProjectIdCodeCacheUtil::get); |
|
|
|
currStat.setStoppedCount(stoppedProjectCount(projectStatusChangeMap, projectCodes)); |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
projectCount = targetCount = sourceCount = 0; |
|
|
|
break; |
|
|
|
} |
|
|
|
retData.add(ProjectProcessStatVO.builder() |
|
|
|
.stage(node) |
|
|
|
.stageName(node.getName()) |
|
|
|
.projectCount(projectCount) |
|
|
|
.targetCount(targetCount) |
|
|
|
.sourceCount(sourceCount) |
|
|
|
.build()); |
|
|
|
retData.add(currStat); |
|
|
|
} |
|
|
|
} |
|
|
|
return retData; |
|
|
|
} |
|
|
|
|
|
|
|
private static int stoppedProjectCount(Map<String, List<ProjectStatusChange>> projectStatusChangeMap, List<String> projectCodes) { |
|
|
|
return CollUtil.count(projectStatusChangeMap.entrySet(), |
|
|
|
w -> projectCodes.contains(w.getKey()) |
|
|
|
&& CollUtil.anyMatch(w.getValue(), x -> ProjectStateChangeEvent.STOPPED_APPLY_PASS.eq(x.getEvent()))); |
|
|
|
} |
|
|
|
|
|
|
|
private static int lastMatchProjectCount(Map<String, List<ProjectStatusChange>> projectStatusChangeMap, |
|
|
|
ProjectStateChangeEvent... events) { |
|
|
|
List<ProjectStateChangeEvent> changeEvents = Arrays.asList(events); |
|
|
|
return CollUtil.count(projectStatusChangeMap.entrySet(), |
|
|
|
w -> { |
|
|
|
w.getValue().sort(Comparator.comparing(ProjectStatusChange::getId).reversed()); |
|
|
|
return changeEvents.stream().anyMatch(x -> x.eq(w.getValue().get(0).getEvent())); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public PageVo<ProjectLibListItemVO> pageProjectLib(WorkbenchProjectLibReq req) { |
|
|
|
Assert.notNull(req.getProcessNode(), "节点不能为空"); |
|
|
|
Long unitId; |
|
|
|