Browse Source

modify:

1. 处理总览跳转项目列表;
tags/24101601
WendyYang 2 months ago
parent
commit
23541bd27e
2 changed files with 61 additions and 25 deletions
  1. +15
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/UserTaskCreateOrFinishListener.java
  2. +46
    -23
      hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java

+ 15
- 2
hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/UserTaskCreateOrFinishListener.java View File

@@ -74,12 +74,25 @@ public class UserTaskCreateOrFinishListener {


@EventListener(classes = NodeCreateEvent.class) @EventListener(classes = NodeCreateEvent.class)
public void onEvent(NodeCreateEvent event) { public void onEvent(NodeCreateEvent event) {
SCHEDULER.schedule(() -> handleEvent(event), instantDelay10s());
SCHEDULER.schedule(() -> {
try {
handleEvent(event);
} catch (Exception e) {
log.error("任务节点创建监听异常:{}", event, e);
}
}, instantDelay10s());
} }


@EventListener(classes = NodeCompleteEvent.class) @EventListener(classes = NodeCompleteEvent.class)
public void onEvent(NodeCompleteEvent event) { public void onEvent(NodeCompleteEvent event) {
SCHEDULER.schedule(() -> handleEvent(event), instantDelay10s());
SCHEDULER.schedule(() -> {
try {
handleEvent(event);

} catch (Exception e) {
log.error("任务节点完成监听异常:{}", event, e);
}
}, instantDelay10s());
} }


public void handleEvent(NodeCreateEvent event) { public void handleEvent(NodeCreateEvent event) {


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

@@ -15,7 +15,10 @@ import com.google.common.collect.Sets;
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.constant.ExistsSqlConst; import com.hz.pm.api.common.model.constant.ExistsSqlConst;
import com.hz.pm.api.common.statemachine.event.*;
import com.hz.pm.api.common.statemachine.event.AbstractStateChangeEvent;
import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent;
import com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent;
import com.hz.pm.api.common.statemachine.event.XcfhxStateChangeEvent;
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.Contract;
import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.model.entity.Purchase;
@@ -86,6 +89,10 @@ import java.util.function.BiFunction;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;


import static com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent.ADAPT_INFO_PASSED;
import static com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent.SELF_TEST_PASSED;
import static com.hz.pm.api.common.statemachine.event.TenderStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM;
import static com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent.TEST_VALID_INFO_PASSED;
import static com.hz.pm.api.projectlib.helper.ProjectManageUtil.projectQueryByProjectStatusChange; import static com.hz.pm.api.projectlib.helper.ProjectManageUtil.projectQueryByProjectStatusChange;
import static com.hz.pm.api.workbench.model.vo.ProjectProcessStatVO.TenderAdaptFinishStatVO; import static com.hz.pm.api.workbench.model.vo.ProjectProcessStatVO.TenderAdaptFinishStatVO;


@@ -443,13 +450,13 @@ public class WorkbenchManage {
.select(PurchaseStatusChange::getEvent, PurchaseStatusChange::getProjectId) .select(PurchaseStatusChange::getEvent, PurchaseStatusChange::getProjectId)
.in(PurchaseStatusChange::getProjectId, projectIds) .in(PurchaseStatusChange::getProjectId, projectIds)
.in(PurchaseStatusChange::getEvent, .in(PurchaseStatusChange::getEvent,
AdaptStateChangeEvent.ADAPT_INFO_PASSED,
SelfTestStateChangeEvent.SELF_TEST_PASSED,
TestValidStateChangeEvent.TEST_VALID_INFO_PASSED,
ADAPT_INFO_PASSED,
SELF_TEST_PASSED,
TEST_VALID_INFO_PASSED,
TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES, TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES,
XcfhxStateChangeEvent.XCFHX_APPLY_PASSED, XcfhxStateChangeEvent.XCFHX_APPLY_PASSED,
TenderStateChangeEvent.FINALLY_INSPECTED_PASSED, TenderStateChangeEvent.FINALLY_INSPECTED_PASSED,
TenderStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM,
SUBMIT_PURCHASE_ORG_CONFIRM,
TenderStateChangeEvent.SUBMIT_PURCHASE_CONSTRUCTION_INFO); TenderStateChangeEvent.SUBMIT_PURCHASE_CONSTRUCTION_INFO);
List<PurchaseStatusChange> purchaseChanges = purchaseStatusChangeService.list(pQuery); List<PurchaseStatusChange> purchaseChanges = purchaseStatusChangeService.list(pQuery);
Map<String, Map<Long, Long>> purchaseEventMapTmp = purchaseChanges.stream() Map<String, Map<Long, Long>> purchaseEventMapTmp = purchaseChanges.stream()
@@ -461,7 +468,7 @@ public class WorkbenchManage {
} }
break; break;
case PROJECT_ADAPTION: { case PROJECT_ADAPTION: {
List<Long> projectIds = computeProjectIds.apply(TenderStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM, node);
List<Long> projectIds = computeProjectIds.apply(SUBMIT_PURCHASE_ORG_CONFIRM, node);
currStat.setProjectCount(projectIds.size()); currStat.setProjectCount(projectIds.size());
Pair<Integer, Integer> replaceSystemCount = countReplaceSystemByProjectIds(projectIds); Pair<Integer, Integer> replaceSystemCount = countReplaceSystemByProjectIds(projectIds);
currStat.setSourceCount(replaceSystemCount.getKey()); currStat.setSourceCount(replaceSystemCount.getKey());
@@ -475,7 +482,7 @@ public class WorkbenchManage {
.map(Map.Entry::getKey) .map(Map.Entry::getKey)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!tmpProjectIds.isEmpty()) { if (!tmpProjectIds.isEmpty()) {
currStat.setAdaptFinishStat(tenderAdaptStatistics(tmpProjectIds));
currStat.setAdaptFinishStat(tenderAdaptStatistics(tmpProjectIds, projectPurchaseCountMap));
} }
} }
long finishPurchaseByWithoutApp = CollUtil.count(projectPurchaseCountMap.entrySet(), w -> { long finishPurchaseByWithoutApp = CollUtil.count(projectPurchaseCountMap.entrySet(), w -> {
@@ -521,26 +528,42 @@ public class WorkbenchManage {
return retData; return retData;
} }


private TenderAdaptFinishStatVO tenderAdaptStatistics(List<Long> projectIds) {
private TenderAdaptFinishStatVO tenderAdaptStatistics(List<Long> projectIds, Map<Long, List<Purchase>> projectPurchaseCountMap) {
Wrapper<PurchaseStatusChange> purchaseQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) Wrapper<PurchaseStatusChange> purchaseQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class)
.select(PurchaseStatusChange::getEvent, PurchaseStatusChange::getBidId)
.select(PurchaseStatusChange::getEvent, PurchaseStatusChange::getBidId, PurchaseStatusChange::getProjectId)
.in(PurchaseStatusChange::getProjectId, projectIds) .in(PurchaseStatusChange::getProjectId, projectIds)
.in(PurchaseStatusChange::getEvent, AdaptStateChangeEvent.SUBMIT_ADAPT_INFO,
SelfTestStateChangeEvent.SUBMIT_SELF_TEST_INFO,
TestValidStateChangeEvent.SUBMIT_TEST_VALID_INFO,
TenderStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM);
.in(PurchaseStatusChange::getEvent, ADAPT_INFO_PASSED,
SELF_TEST_PASSED,
TEST_VALID_INFO_PASSED,
SUBMIT_PURCHASE_ORG_CONFIRM);
List<PurchaseStatusChange> statusChanges = purchaseStatusChangeService.list(purchaseQuery); List<PurchaseStatusChange> statusChanges = purchaseStatusChangeService.list(purchaseQuery);
Map<String, Integer> eventMap = statusChanges.stream()
.collect(Collectors.groupingBy(PurchaseStatusChange::getEvent,
Collectors.collectingAndThen(Collectors.mapping(PurchaseStatusChange::getBidId, Collectors.toSet()), Set::size)));
Map<Long, List<PurchaseStatusChange>> projectPurchaseStatusChangeMap = CollUtils.group(statusChanges, PurchaseStatusChange::getProjectId);
TenderAdaptFinishStatVO stat = new TenderAdaptFinishStatVO(); TenderAdaptFinishStatVO stat = new TenderAdaptFinishStatVO();
stat.setFinishTestValidCount(eventMap.getOrDefault(TestValidStateChangeEvent.SUBMIT_TEST_VALID_INFO.name(), 0));
stat.setFinishAdaptionInfo(eventMap.getOrDefault(AdaptStateChangeEvent.SUBMIT_ADAPT_INFO.name(), 0));
stat.setFinishOrgConfirmCount(eventMap.getOrDefault(TenderStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM.name(), 0));
stat.setFinishSelfTestCount(eventMap.getOrDefault(SelfTestStateChangeEvent.SUBMIT_SELF_TEST_INFO.name(), 0));
stat.setFinishTestValidCount(countAdaptBranchStatus(TEST_VALID_INFO_PASSED, projectIds, projectPurchaseCountMap, projectPurchaseStatusChangeMap));
stat.setFinishAdaptionInfo(countAdaptBranchStatus(ADAPT_INFO_PASSED, projectIds, projectPurchaseCountMap, projectPurchaseStatusChangeMap));
stat.setFinishOrgConfirmCount(countAdaptBranchStatus(SUBMIT_PURCHASE_ORG_CONFIRM, projectIds, projectPurchaseCountMap, projectPurchaseStatusChangeMap));
stat.setFinishSelfTestCount(countAdaptBranchStatus(SELF_TEST_PASSED, projectIds, projectPurchaseCountMap, projectPurchaseStatusChangeMap));
return stat; return stat;
} }


private static <T extends AbstractStateChangeEvent> int countAdaptBranchStatus(T event,
List<Long> projectIds,
Map<Long, List<Purchase>> projectPurchaseCountMap,
Map<Long, List<PurchaseStatusChange>> projectPurchaseChangeMap) {
return (int) projectIds.stream().filter(w -> {
int bidCount = CollUtil.count(projectPurchaseCountMap.getOrDefault(w, Collections.emptyList()),
w1 -> BidTypeEnum.BUILD_APP.eq(w1.getBidType()));
List<PurchaseStatusChange> purchaseStatusChanges = projectPurchaseChangeMap.getOrDefault(w, Collections.emptyList());
int finishedBidCount = purchaseStatusChanges.stream()
.filter(w1 -> w1.getProjectId().equals(w) && event.eq(w1.getEvent()))
.map(PurchaseStatusChange::getBidId)
.collect(Collectors.toSet()).size();
return finishedBidCount != 0 && finishedBidCount == bidCount;
}).count();
}

private static int stoppedProjectCount(Map<String, List<ProjectStatusChange>> projectStatusChangeMap, List<String> projectCodes) { private static int stoppedProjectCount(Map<String, List<ProjectStatusChange>> projectStatusChangeMap, List<String> projectCodes) {
return CollUtil.count(projectStatusChangeMap.entrySet(), return CollUtil.count(projectStatusChangeMap.entrySet(),
w -> projectCodes.contains(w.getKey()) w -> projectCodes.contains(w.getKey())
@@ -597,17 +620,17 @@ public class WorkbenchManage {
case TEST_VALID: case TEST_VALID:
query.apply("(select count(1) from nd_purchase np where np.project_id = nd_project.id and bid_type = {0}) " + query.apply("(select count(1) from nd_purchase np where np.project_id = nd_project.id and bid_type = {0}) " +
"= (select count(distinct bid_id) from nd_purchase_status_change npsc where npsc.project_code = nd_project.project_code " + "= (select count(distinct bid_id) from nd_purchase_status_change npsc where npsc.project_code = nd_project.project_code " +
"and event = {1})", BidTypeEnum.BUILD_APP.getCode(), TestValidStateChangeEvent.TEST_VALID_INFO_PASSED);
"and event = {1})", BidTypeEnum.BUILD_APP.getCode(), TEST_VALID_INFO_PASSED);
break; break;
case SELF_TEST: case SELF_TEST:
query.apply("(select count(1) from nd_purchase np where np.project_id = nd_project.id and bid_type = {0}) " + query.apply("(select count(1) from nd_purchase np where np.project_id = nd_project.id and bid_type = {0}) " +
"= (select count(distinct bid_id) from nd_purchase_status_change npsc where npsc.project_code = nd_project.project_code " + "= (select count(distinct bid_id) from nd_purchase_status_change npsc where npsc.project_code = nd_project.project_code " +
"and event = {1})", BidTypeEnum.BUILD_APP.getCode(), SelfTestStateChangeEvent.SELF_TEST_PASSED);
"and event = {1})", BidTypeEnum.BUILD_APP.getCode(), SELF_TEST_PASSED);
break; break;
case SUBMIT_START_FILE: case SUBMIT_START_FILE:
query.apply("(select count(1) from nd_purchase np where np.project_id = nd_project.id and bid_type = {0}) " + query.apply("(select count(1) from nd_purchase np where np.project_id = nd_project.id and bid_type = {0}) " +
"= (select count(distinct bid_id) from nd_purchase_status_change npsc where npsc.project_code = nd_project.project_code " + "= (select count(distinct bid_id) from nd_purchase_status_change npsc where npsc.project_code = nd_project.project_code " +
"and event = {1})", BidTypeEnum.BUILD_APP.getCode(), AdaptStateChangeEvent.ADAPT_INFO_PASSED);
"and event = {1})", BidTypeEnum.BUILD_APP.getCode(), ADAPT_INFO_PASSED);
break; break;
default: default:
return PageVo.empty(); return PageVo.empty();


Loading…
Cancel
Save