From 1104b94d19e9ab3eda7d8cbfbeca1a9a2d064cf2 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Mon, 1 Apr 2024 13:50:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statemachine/event/AdaptStateChangeEvent.java | 8 +- .../event/SelfTestStateChangeEvent.java | 8 +- .../event/TestValidStateChangeEvent.java | 8 +- .../statemachine/util/AdaptStateMachineUtil.java | 8 +- .../util/SelfTestStateMachineUtil.java | 8 +- .../util/TestValidStateMachineUtil.java | 6 +- .../api/projectdeclared/manage/PurchaseManage.java | 143 ++++++++++++--------- .../model/req/TestValidInfoReq.java | 3 +- .../com/hz/pm/api/todocenter/FlowableTest.java | 20 ++- 9 files changed, 120 insertions(+), 92 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java index 45fc80d..2141057 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java @@ -17,10 +17,10 @@ import java.util.Objects; @AllArgsConstructor public enum AdaptStateChangeEvent { - SUBMIT_ADAPT_INFO(100, null, null), - ADAPT_INFO_PASSED(101, null, null), - ADAPT_INFO_FAILED(null, 101, null), - RESUBMIT_ADAPT_INFO(102, null, null); + SUBMIT_ADAPT_INFO(2100, null, null), + ADAPT_INFO_PASSED(2101, null, null), + ADAPT_INFO_FAILED(null, 2101, null), + RESUBMIT_ADAPT_INFO(2102, null, null); private final Integer passStatusCode; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java index fdd36c9..293c43c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java @@ -17,10 +17,10 @@ import java.util.Objects; @AllArgsConstructor public enum SelfTestStateChangeEvent { - SUBMIT_SELF_TEST_INFO(100, null, null), - SELF_TEST_PASSED(101, null, null), - SELF_TEST_FAILED(null, 101, null), - RESUBMIT_SELF_TEST(102, null, null); + SUBMIT_SELF_TEST_INFO(1100, null, null), + SELF_TEST_PASSED(1101, null, null), + SELF_TEST_FAILED(null, 1101, null), + RESUBMIT_SELF_TEST(1102, null, null); private final Integer passStatusCode; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java index aca2fcb..31e0b66 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java @@ -20,19 +20,19 @@ public enum TestValidStateChangeEvent { /** * 填写测试验证信息 */ - SUBMIT_TEST_VALID_INFO(100, null, null), + SUBMIT_TEST_VALID_INFO(3100, null, null), /** * 测试验证信息审核通过 */ - TEST_VALID_INFO_PASSED(101, null, null), + TEST_VALID_INFO_PASSED(3101, null, null), /** * 测试验证信息审核不通过 */ - TEST_VALID_INFO_FAILED(null, 101, null), + TEST_VALID_INFO_FAILED(null, 3101, null), /** * 重新填写测试验证信息 */ - RESUBMIT_TEST_VALID_INFO(102, null, null); + RESUBMIT_TEST_VALID_INFO(3102, null, null); private final Integer passStatusCode; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java index 18ca509..c1e0ede 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java @@ -38,7 +38,7 @@ public class AdaptStateMachineUtil { //通过审核 public void pass(Purchase purchase) { try { - execute(purchase, getPassEvent(purchase.getStatus())); + execute(purchase, getPassEvent(purchase.getAdaptStatus())); } catch (Exception e) { log.info("状态机 通过失败 :{}", e.getMessage()); throw new BusinessException("状态机 通过失败: " + e); @@ -48,7 +48,7 @@ public class AdaptStateMachineUtil { //拒绝 public void reject(Purchase purchase) { try { - execute(purchase, getRejectEvent(purchase.getStatus())); + execute(purchase, getRejectEvent(purchase.getAdaptStatus())); } catch (Exception e) { log.info("状态机 拒绝失败 :{}", e.getMessage()); throw new BusinessException("状态机 拒绝失败: " + e); @@ -58,7 +58,7 @@ public class AdaptStateMachineUtil { //撤回 public void withDraw(Purchase purchase) { try { - execute(purchase, getWithdrawEvent(purchase.getStatus())); + execute(purchase, getWithdrawEvent(purchase.getAdaptStatus())); } catch (Exception e) { log.info("状态机 撤回失败 :{}", e.getMessage()); throw new BusinessException("状态机 撤回失败: " + e); @@ -76,7 +76,7 @@ public class AdaptStateMachineUtil { StateMachinePersister stateMachinePersister = adaptStateMachineBuilder.stateMachinePersister(); stateMachinePersister.restore(stateMachine, purchase); stateMachine.sendEvent(message); - log.info("调用状态机后的标段状态为:{}", purchase.getStatus()); + log.info("调用状态机后的标段状态为:{}", purchase.getAdaptStatus()); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java index 35eeb6f..c994da0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java @@ -38,7 +38,7 @@ public class SelfTestStateMachineUtil { //通过审核 public void pass(Purchase purchase) { try { - execute(purchase, getPassEvent(purchase.getStatus())); + execute(purchase, getPassEvent(purchase.getSelfTestStatus())); } catch (Exception e) { log.info("状态机 通过失败 :{}", e.getMessage()); throw new BusinessException("状态机 通过失败: " + e); @@ -48,7 +48,7 @@ public class SelfTestStateMachineUtil { //拒绝 public void reject(Purchase purchase) { try { - execute(purchase, getRejectEvent(purchase.getStatus())); + execute(purchase, getRejectEvent(purchase.getSelfTestStatus())); } catch (Exception e) { log.info("状态机 拒绝失败 :{}", e.getMessage()); throw new BusinessException("状态机 拒绝失败: " + e); @@ -58,7 +58,7 @@ public class SelfTestStateMachineUtil { //撤回 public void withDraw(Purchase purchase) { try { - execute(purchase, getWithdrawEvent(purchase.getStatus())); + execute(purchase, getWithdrawEvent(purchase.getSelfTestStatus())); } catch (Exception e) { log.info("状态机 撤回失败 :{}", e.getMessage()); throw new BusinessException("状态机 撤回失败: " + e); @@ -76,7 +76,7 @@ public class SelfTestStateMachineUtil { StateMachinePersister stateMachinePersister = selfTestStateMachineBuilder.stateMachinePersister(); stateMachinePersister.restore(stateMachine, purchase); stateMachine.sendEvent(message); - log.info("调用状态机后的标段状态为:{}", purchase.getStatus()); + log.info("调用状态机后的标段状态为:{}", purchase.getSelfTestStatus()); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java index 356d3fa..2953ae1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java @@ -38,7 +38,7 @@ public class TestValidStateMachineUtil { //通过审核 public void pass(Purchase purchase) { try { - execute(purchase, getPassEvent(purchase.getStatus())); + execute(purchase, getPassEvent(purchase.getTestValidStatus())); } catch (Exception e) { log.info("状态机 通过失败 :{}", e.getMessage()); throw new BusinessException("状态机 通过失败: " + e); @@ -48,7 +48,7 @@ public class TestValidStateMachineUtil { //拒绝 public void reject(Purchase purchase) { try { - execute(purchase, getRejectEvent(purchase.getStatus())); + execute(purchase, getRejectEvent(purchase.getTestValidStatus())); } catch (Exception e) { log.info("状态机 拒绝失败 :{}", e.getMessage()); throw new BusinessException("状态机 拒绝失败: " + e); @@ -58,7 +58,7 @@ public class TestValidStateMachineUtil { //撤回 public void withDraw(Purchase purchase) { try { - execute(purchase, getWithdrawEvent(purchase.getStatus())); + execute(purchase, getWithdrawEvent(purchase.getTestValidStatus())); } catch (Exception e) { log.info("状态机 撤回失败 :{}", e.getMessage()); throw new BusinessException("状态机 撤回失败: " + e); 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 245c4ca..73ad9ea 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 @@ -485,34 +485,39 @@ public class PurchaseManage { @Transactional(rollbackFor = Exception.class) public synchronized void submitTestValidInfo(TestValidInfoReq req) { - Purchase purchase = purchaseService.getById(req.getBidId()); - if (TenderTestValidStatusEnum.WITHOUT_TEST_VALID_INFO.eq(purchase.getTestValidStatus()) - && TenderTestValidStatusEnum.TEST_VALID_INFO_FAILED.eq(purchase.getTestValidStatus())) { - throw BizException.wrap("该状态下不支持提交测试验证信息"); - } + List purchases = purchaseService.listByIds(req.getBidIds()); + purchases.forEach(purchase -> { + if (TenderTestValidStatusEnum.WITHOUT_TEST_VALID_INFO.eq(purchase.getTestValidStatus()) + && TenderTestValidStatusEnum.TEST_VALID_INFO_FAILED.eq(purchase.getTestValidStatus())) { + throw BizException.wrap("该状态下不支持提交测试验证信息"); + } + }); UserInfoDetails user = LoginUserUtil.loginUserDetail(); ProjectProcessStageEnum instType = ProjectProcessStageEnum.TEST_VALID; WflowModels model = processModelManage.getWflowModels(instType, user.getMhUnitId()); if (Objects.isNull(model)) { throw new BusinessException("找不到测试验证流程配置"); } - Project project = projectService.getNewProject(purchase.getProjectId()); - ProcessStartParamsVo instParam = new ProcessStartParamsVo(); - instParam.setUser(declaredProjectManage.buildUser(user)); - instParam.setProcessUsers(Collections.emptyMap()); - instParam.setFormData(Collections.emptyMap()); - // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 - 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, req.getBidId()); - testValidStateMachineUtil.pass(purchase); - purchaseService.updateById(purchase); - operationService.update(update); - saveProjectPurchaseInstCode(req.getBidId(), instanceId, project.getId(), instType); + for (Purchase purchase : purchases) { + Long projectId = purchase.getProjectId(); + Project project = projectService.getNewProject(projectId); + ProcessStartParamsVo instParam = new ProcessStartParamsVo(); + instParam.setUser(declaredProjectManage.buildUser(user)); + instParam.setProcessUsers(Collections.emptyMap()); + instParam.setFormData(Collections.emptyMap()); + // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 + 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); + testValidStateMachineUtil.pass(purchase); + purchaseService.updateById(purchase); + operationService.update(update); + saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); + } } private void saveProjectPurchaseInstCode(Long bidId, @@ -536,10 +541,12 @@ public class PurchaseManage { @Transactional(rollbackFor = Exception.class) public synchronized void submitSelfTestInfo(TestValidInfoReq req) { - Purchase purchase = purchaseService.getById(req.getBidId()); - if (TenderSelfTestStatusEnum.WITHOUT_SELF_TEST_INFO.eq(purchase.getSelfTestStatus()) - && TenderSelfTestStatusEnum.SELF_TEST_INFO_FAILED.eq(purchase.getSelfTestStatus())) { - throw BizException.wrap("该状态下不支持提交系统自测信息"); + List purchases = purchaseService.listByIds(req.getBidIds()); + for (Purchase purchase : purchases) { + if (TenderSelfTestStatusEnum.WITHOUT_SELF_TEST_INFO.eq(purchase.getSelfTestStatus()) + && TenderSelfTestStatusEnum.SELF_TEST_INFO_FAILED.eq(purchase.getSelfTestStatus())) { + throw BizException.wrap("该状态下不支持提交系统自测信息"); + } } UserInfoDetails user = LoginUserUtil.loginUserDetail(); ProjectProcessStageEnum instType = ProjectProcessStageEnum.SELF_TEST; @@ -547,31 +554,36 @@ public class PurchaseManage { if (Objects.isNull(model)) { throw new BusinessException("找不到系统自测流程配置"); } - Project project = projectService.getNewProject(purchase.getProjectId()); - ProcessStartParamsVo instParam = new ProcessStartParamsVo(); - instParam.setUser(declaredProjectManage.buildUser(user)); - instParam.setProcessUsers(Collections.emptyMap()); - instParam.setFormData(Collections.emptyMap()); - // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 - Map orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project); - String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap); - Wrapper update = Wrappers.lambdaUpdate(Operation.class) - .set(Operation::getSelfTestTime, req.getActualTime()) - .set(Operation::getSelfTestFiles, req.getFiles()) - .set(Operation::getSelfTestRemark, req.getRemark()) - .eq(Operation::getBidId, req.getBidId()); - testValidStateMachineUtil.pass(purchase); - purchaseService.updateById(purchase); - operationService.update(update); - saveProjectPurchaseInstCode(req.getBidId(), instanceId, project.getId(), instType); + for (Purchase purchase : purchases) { + Long projectId = purchase.getProjectId(); + Project project = projectService.getNewProject(projectId); + ProcessStartParamsVo instParam = new ProcessStartParamsVo(); + instParam.setUser(declaredProjectManage.buildUser(user)); + instParam.setProcessUsers(Collections.emptyMap()); + instParam.setFormData(Collections.emptyMap()); + // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 + Map orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project); + String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap); + Wrapper update = Wrappers.lambdaUpdate(Operation.class) + .set(Operation::getSelfTestTime, req.getActualTime()) + .set(Operation::getSelfTestFiles, req.getFiles()) + .set(Operation::getSelfTestRemark, req.getRemark()) + .eq(Operation::getBidId, purchase.getId()); + testValidStateMachineUtil.pass(purchase); + purchaseService.updateById(purchase); + operationService.update(update); + saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); + } } @Transactional(rollbackFor = Exception.class) public synchronized void submitAdaptionInfo(TestValidInfoReq req) { - Purchase purchase = purchaseService.getById(req.getBidId()); - if (TenderAdaptStatusEnum.WITHOUT_ADAPT_INFO.eq(purchase.getAdaptStatus()) - && TenderAdaptStatusEnum.ADAPT_INFO_FAILED.eq(purchase.getAdaptStatus())) { - throw BizException.wrap("该状态下不支持提交适配改造信息"); + List purchases = purchaseService.listByIds(req.getBidIds()); + for (Purchase purchase : purchases) { + if (TenderAdaptStatusEnum.WITHOUT_ADAPT_INFO.eq(purchase.getAdaptStatus()) + && TenderAdaptStatusEnum.ADAPT_INFO_FAILED.eq(purchase.getAdaptStatus())) { + throw BizException.wrap("该状态下不支持提交适配改造信息"); + } } UserInfoDetails user = LoginUserUtil.loginUserDetail(); ProjectProcessStageEnum instType = ProjectProcessStageEnum.ADAPTION; @@ -579,23 +591,26 @@ public class PurchaseManage { if (Objects.isNull(model)) { throw new BusinessException("找不到适配改造流程配置"); } - Project project = projectService.getNewProject(purchase.getProjectId()); - ProcessStartParamsVo instParam = new ProcessStartParamsVo(); - instParam.setUser(declaredProjectManage.buildUser(user)); - instParam.setProcessUsers(Collections.emptyMap()); - instParam.setFormData(Collections.emptyMap()); - // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 - Map orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project); - String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap); - Wrapper update = Wrappers.lambdaUpdate(Operation.class) - .set(Operation::getAdaptationTime, req.getActualTime()) - .set(Operation::getAdaptionFiles, req.getFiles()) - .set(Operation::getAdaptionRemark, req.getRemark()) - .eq(Operation::getBidId, req.getBidId()); - testValidStateMachineUtil.pass(purchase); - purchaseService.updateById(purchase); - operationService.update(update); - saveProjectPurchaseInstCode(req.getBidId(), instanceId, project.getId(), instType); + for (Purchase purchase : purchases) { + Long projectId = purchase.getProjectId(); + Project project = projectService.getNewProject(projectId); + ProcessStartParamsVo instParam = new ProcessStartParamsVo(); + instParam.setUser(declaredProjectManage.buildUser(user)); + instParam.setProcessUsers(Collections.emptyMap()); + instParam.setFormData(Collections.emptyMap()); + // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 + Map orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project); + String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap); + Wrapper update = Wrappers.lambdaUpdate(Operation.class) + .set(Operation::getAdaptationTime, req.getActualTime()) + .set(Operation::getAdaptionFiles, req.getFiles()) + .set(Operation::getAdaptionRemark, req.getRemark()) + .eq(Operation::getBidId, purchase.getId()); + testValidStateMachineUtil.pass(purchase); + purchaseService.updateById(purchase); + operationService.update(update); + saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); + } } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidInfoReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidInfoReq.java index 86b5dd3..d023328 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidInfoReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidInfoReq.java @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; +import java.util.List; /** *

@@ -17,7 +18,7 @@ import java.time.LocalDateTime; public class TestValidInfoReq { @ApiModelProperty("标段ID") - private Long bidId; + private List bidIds; @ApiModelProperty("备注") private String remark; diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java b/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java index 89b1f5c..b2e5089 100644 --- a/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java +++ b/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java @@ -4,7 +4,11 @@ import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.AppTests; import com.hz.pm.api.common.helper.WflowHelper; +import com.hz.pm.api.sys.manage.InitProcessManage; +import com.hz.pm.api.user.manage.MhUnitManage; +import com.hz.pm.api.user.model.dto.MhUnitTreeDTO; import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.util.CollUtils; import com.wflow.bean.entity.WflowCcTasks; import com.wflow.mapper.WflowCcTasksMapper; import com.wflow.utils.CodeUtil; @@ -29,10 +33,7 @@ import org.junit.Test; import org.mockito.internal.util.collections.Sets; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -312,6 +313,17 @@ public class FlowableTest extends AppTests { @Autowired private WflowHelper wflowHelper; + @Autowired + private InitProcessManage initProcessManage; + @Autowired + private MhUnitManage mhUnitManage; + + @Test + public void test1(){ + List units = mhUnitManage.getMhUnitDashboardOption(); + Set unitIds = CollUtils.fieldSet(units, MhUnitTreeDTO::getId); + initProcessManage.initProcessForUnits(unitIds); + } @Test public void test() {