From eca146bca1babed6234763144ffae2eaa7e80c13 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 3 Apr 2024 16:51:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E6=96=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectdeclared/manage/OperationManage.java | 26 ++--- .../api/projectdeclared/manage/PurchaseManage.java | 105 +++++++++++++-------- 2 files changed, 81 insertions(+), 50 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java index c5d4ef1..5cc9268 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java @@ -84,21 +84,21 @@ public class OperationManage { if (!TenderStatusEnum.TO_BE_SUBMIT_OPERATION_PLAN.eq(purchase.getStatus())) { throw BizException.wrap("该标段不支持填写实施计划"); } - Operation pre = operationService.getByBidId(req.getBidId()); + Operation operation = operationService.getByBidId(req.getBidId()); + if (operation == null) { + operation = new Operation(); + } Project project = projectService.getNewProject(req.getProjectId()); LocalDateTime now = LocalDateTime.now(); - Operation curr = BeanUtil.copyProperties(req, Operation.class); - if (Objects.nonNull(pre)) { - curr.setId(pre.getId()); - } else { - curr.setCreateOn(now); - curr.setCreateBy(user.getUsername()); + BeanUtil.copyProperties(req, operation); + if (operation.getId() == null) { + operation.setCreateOn(now); + operation.setCreateBy(user.getUsername()); } - curr.setProjectCode(project.getProjectCode()); - curr.setUpdateOn(now); - curr.setUpdateBy(user.getUsername()); - operationService.saveOrUpdate(curr); - + operation.setProjectCode(project.getProjectCode()); + operation.setUpdateOn(now); + operation.setUpdateBy(user.getUsername()); + operationService.saveOrUpdate(operation); long operationCount = operationService.countByBidIds(purchaseMap.keySet()); if (operationCount == purchaseMap.size()) { // 修改项目状态 @@ -108,6 +108,6 @@ public class OperationManage { // 修改标段状态 tenderStateMachineUtil.pass(purchase); purchaseService.updateById(purchase); - return curr.getProjectCode(); + return operation.getProjectCode(); } } 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 0855d0b..866d6a7 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 @@ -1,6 +1,5 @@ package com.hz.pm.api.projectdeclared.manage; -import cn.dev33.satoken.fun.SaParamRetFunction; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; @@ -17,7 +16,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.UserInfoHelper; -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.AdaptStateChangeEvent; +import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent; +import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent; import com.hz.pm.api.common.statemachine.util.*; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.EnvironmentUtil; @@ -452,14 +454,13 @@ public class PurchaseManage { .isNotNull(function) .orderByDesc(Purchase::getCreateOn); boolean display = !Boolean.FALSE.equals(req.getDisplay()); + String existsSql = String.format("select 1 from nd_project_operation no" + + " where no.bid_id = nd_purchase.id and no.%s is not null", actualTimeColumn); if (display) { query.and(q1 -> q1.eq(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()) - .or(q2 -> q2.exists(String.format("select 1 from nd_project_operation no" + - " where no.bid_id = nd_purchase.id and no.%s is not null", actualTimeColumn)))); + .or(q2 -> q2.exists(existsSql))); } else { - query.ne(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()) - .exists(String.format("select 1 from nd_project_operation no" + - " where no.bid_id = nd_purchase.id and no.%s is null", actualTimeColumn)); + query.ne(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()).notExists(existsSql); } UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); if (!buildPurchaseQueryPermission(query, user)) { @@ -482,22 +483,20 @@ public class PurchaseManage { event = SelfTestStateChangeEvent.SUBMIT_SELF_TEST_INFO; } Wrapper pscQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) - .in(PurchaseStatusChange::getEvent, event.name(), TenderStateChangeEvent.SUBMIT_OPERATION_PLAN) + .in(PurchaseStatusChange::getEvent, event.name()) .in(PurchaseStatusChange::getBidId, bidIds) .orderByAsc(PurchaseStatusChange::getCreateOn); List changes = purchaseStatusChangeService.list(pscQuery); - Map> mapByBidId = CollUtils.group(changes, PurchaseStatusChange::getBidId); + Map mapByBidId = BizUtils.groupFirstMap(changes, + PurchaseStatusChange::getBidId, Comparator.comparing(PurchaseStatusChange::getCreateOn)); records.forEach(w -> { - List tmpChanges = mapByBidId.get(w.getId()); - if (tmpChanges == null) { - return; - } - Map changeMap = CollUtils.listToMap(tmpChanges, - PurchaseStatusChange::getEvent, PurchaseStatusChange::getCreateOn); if (BidTypeEnum.BUILD_APP.getCode().equals(w.getBidType())) { - createOnMap.put(w.getId(), changeMap.get(TenderStateChangeEvent.SUBMIT_OPERATION_PLAN.name())); + createOnMap.put(w.getId(), w.getCreateOn()); } else { - createOnMap.put(w.getId(), changeMap.get(event.name())); + PurchaseStatusChange change = mapByBidId.get(w.getId()); + if (change != null) { + createOnMap.put(w.getId(), change.getCreateOn()); + } } }); } @@ -517,10 +516,12 @@ public class PurchaseManage { String projectCode = ProjectIdCodeCacheUtil.get(w.getProjectId()); item.setProjectCode(projectCode); Contract contract = contractMap.get(w.getId()); - item.setContractAmount(contract.getTotalAmount()); + if (contract != null) { + item.setContractAmount(contract.getTotalAmount()); + } item.setStatus(function.apply(w)); if (display) { - item.setCreateOn(createOnMap.getOrDefault(w.getId(), w.getCreateOn())); + item.setCreateOn(createOnMap.get(w.getId())); } return item; }).collect(Collectors.toList()); @@ -554,6 +555,7 @@ public class PurchaseManage { if (Objects.isNull(model)) { throw new BusinessException("找不到测试验证流程配置"); } + LocalDateTime now = LocalDateTime.now(); for (Purchase purchase : purchases) { Long projectId = purchase.getProjectId(); Project project = projectService.getNewProject(projectId); @@ -564,14 +566,23 @@ public class PurchaseManage { // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 Map orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project); String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap); - Wrapper update = Wrappers.lambdaUpdate(Operation.class) - .set(Operation::getActualTestValidTime, req.getActualTime()) - .set(Operation::getTestValidFiles, req.getFiles()) - .set(Operation::getTestValidRemark, req.getRemark()) - .eq(Operation::getBidId, purchase.getId()); testValidStateMachineUtil.pass(purchase); purchaseService.updateById(purchase); - operationService.update(update); + Operation operation = operationService.getByBidId(purchase.getId()); + if (operation == null) { + operation = new Operation(); + operation.setActualTestValidTime(req.getActualTime()); + operation.setTestValidFiles(req.getFiles()); + operation.setTestValidRemark(req.getRemark()); + operation.setBidId(purchase.getId()); + operation.setCreateBy(user.getUsername()); + operation.setCreateOn(now); + operation.setProjectId(projectId); + operation.setProjectCode(project.getProjectCode()); + } + operation.setUpdateBy(user.getUsername()); + operation.setUpdateOn(now); + operationService.saveOrUpdate(operation); saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); } } @@ -610,6 +621,7 @@ public class PurchaseManage { if (Objects.isNull(model)) { throw new BusinessException("找不到系统自测流程配置"); } + LocalDateTime now = LocalDateTime.now(); for (Purchase purchase : purchases) { Long projectId = purchase.getProjectId(); Project project = projectService.getNewProject(projectId); @@ -620,14 +632,23 @@ public class PurchaseManage { // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 Map orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project); String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap); - Wrapper update = Wrappers.lambdaUpdate(Operation.class) - .set(Operation::getActualSelfTestTime, req.getActualTime()) - .set(Operation::getSelfTestFiles, req.getFiles()) - .set(Operation::getSelfTestRemark, req.getRemark()) - .eq(Operation::getBidId, purchase.getId()); selfTestStateMachineUtil.pass(purchase); purchaseService.updateById(purchase); - operationService.update(update); + Operation operation = operationService.getByBidId(purchase.getId()); + if (operation == null) { + operation = new Operation(); + operation.setActualSelfTestTime(req.getActualTime()); + operation.setSelfTestFiles(req.getFiles()); + operation.setSelfTestRemark(req.getRemark()); + operation.setBidId(purchase.getId()); + operation.setCreateBy(user.getUsername()); + operation.setCreateOn(now); + operation.setProjectId(projectId); + operation.setProjectCode(project.getProjectCode()); + } + operation.setUpdateBy(user.getUsername()); + operation.setUpdateOn(now); + operationService.saveOrUpdate(operation); saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); } } @@ -647,6 +668,7 @@ public class PurchaseManage { if (Objects.isNull(model)) { throw new BusinessException("找不到适配改造流程配置"); } + LocalDateTime now = LocalDateTime.now(); for (Purchase purchase : purchases) { Long projectId = purchase.getProjectId(); Project project = projectService.getNewProject(projectId); @@ -657,14 +679,23 @@ public class PurchaseManage { // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 Map orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project); String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap); - Wrapper update = Wrappers.lambdaUpdate(Operation.class) - .set(Operation::getActualAdaptionTime, req.getActualTime()) - .set(Operation::getAdaptionFiles, req.getFiles()) - .set(Operation::getAdaptionRemark, req.getRemark()) - .eq(Operation::getBidId, purchase.getId()); adaptStateMachineUtil.pass(purchase); purchaseService.updateById(purchase); - operationService.update(update); + Operation operation = operationService.getByBidId(purchase.getId()); + if (operation == null) { + operation = new Operation(); + operation.setActualAdaptionTime(req.getActualTime()); + operation.setAdaptionFiles(req.getFiles()); + operation.setAdaptionRemark(req.getRemark()); + operation.setBidId(purchase.getId()); + operation.setCreateBy(user.getUsername()); + operation.setCreateOn(now); + operation.setProjectId(projectId); + operation.setProjectCode(project.getProjectCode()); + } + operation.setUpdateBy(user.getUsername()); + operation.setUpdateOn(now); + operationService.saveOrUpdate(operation); saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); } }