diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 59d6569..0a6c724 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -1164,16 +1164,7 @@ public class PurchaseManage { } tenderStateMachineUtil.pass(purchase); purchaseService.updateById(purchase); - LambdaQueryWrapper purchaseQuery = Wrappers.lambdaQuery(Purchase.class) - .select(Purchase::getStatus, Purchase::getBidType) - .eq(Purchase::getProjectId, purchase.getProjectId()); - List purchases = purchaseService.list(purchaseQuery); - boolean changeProjectStatus = CollUtil.allMatch(purchases, w -> { - if (!BidTypeEnum.BUILD_APP.eq(w.getBidType())) { - return true; - } - return TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.eq(w.getStatus()); - }); + boolean changeProjectStatus = allPurchaseOrgConfirmed(purchase.getProjectId()); Project project = projectService.getNewestNoNull(purchase.getProjectId()); if (changeProjectStatus) { projectStateMachineUtil.pass(project); @@ -1183,4 +1174,20 @@ public class PurchaseManage { SpringUtil.publishEvent(MhTodoSendEvent.of(MHTodoTypeEnum.WITHOUT_FIRST_ACCEPT_RECORD, project, purchase)); } + private boolean allPurchaseOrgConfirmed(Long projectId) { + Wrapper purchaseQuery = Wrappers.lambdaQuery(Purchase.class) + .select(Purchase::getId) + .eq(Purchase::getProjectId, projectId) + .eq(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()); + List purchases = purchaseService.list(purchaseQuery); + Set bidIds = CollUtils.fieldSet(purchases, Purchase::getId); + Wrapper statusChangeQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) + .select(PurchaseStatusChange::getBidId) + .eq(PurchaseStatusChange::getEvent, TenderStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM) + .in(PurchaseStatusChange::getBidId, bidIds); + List changes = purchaseStatusChangeService.list(statusChangeQuery); + int orgConfirmedCount = CollUtils.fieldSet(changes, PurchaseStatusChange::getBidId).size(); + return orgConfirmedCount == bidIds.size(); + } + }