Bläddra i källkod

修改状态机

tags/24080901
WendyYang 9 månader sedan
förälder
incheckning
1104b94d19
9 ändrade filer med 120 tillägg och 92 borttagningar
  1. +4
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java
  2. +4
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java
  3. +4
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java
  4. +4
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java
  5. +4
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java
  6. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java
  7. +79
    -64
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java
  8. +2
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidInfoReq.java
  9. +16
    -4
      hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java

+ 4
- 4
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java Visa fil

@@ -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;


+ 4
- 4
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java Visa fil

@@ -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;


+ 4
- 4
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java Visa fil

@@ -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;


+ 4
- 4
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java Visa fil

@@ -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<TenderAdaptStatusEnum, AdaptStateChangeEvent, Purchase> stateMachinePersister = adaptStateMachineBuilder.stateMachinePersister();
stateMachinePersister.restore(stateMachine, purchase);
stateMachine.sendEvent(message);
log.info("调用状态机后的标段状态为:{}", purchase.getStatus());
log.info("调用状态机后的标段状态为:{}", purchase.getAdaptStatus());
}




+ 4
- 4
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java Visa fil

@@ -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<TenderSelfTestStatusEnum, SelfTestStateChangeEvent, Purchase> stateMachinePersister = selfTestStateMachineBuilder.stateMachinePersister();
stateMachinePersister.restore(stateMachine, purchase);
stateMachine.sendEvent(message);
log.info("调用状态机后的标段状态为:{}", purchase.getStatus());
log.info("调用状态机后的标段状态为:{}", purchase.getSelfTestStatus());
}




+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java Visa fil

@@ -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);


+ 79
- 64
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java Visa fil

@@ -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<Purchase> 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<String, OrgInfoDTO> orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project);
String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap);
Wrapper<Operation> 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<String, OrgInfoDTO> orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project);
String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap);
Wrapper<Operation> 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<Purchase> 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<String, OrgInfoDTO> orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project);
String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap);
Wrapper<Operation> 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<String, OrgInfoDTO> orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project);
String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap);
Wrapper<Operation> 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<Purchase> 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<String, OrgInfoDTO> orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project);
String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap);
Wrapper<Operation> 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<String, OrgInfoDTO> orgMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), project);
String instanceId = processInstanceService.startProcessLs(model, instParam, orgMap);
Wrapper<Operation> 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);
}
}

}

+ 2
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/req/TestValidInfoReq.java Visa fil

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/**
* <p>
@@ -17,7 +18,7 @@ import java.time.LocalDateTime;
public class TestValidInfoReq {

@ApiModelProperty("标段ID")
private Long bidId;
private List<Long> bidIds;

@ApiModelProperty("备注")
private String remark;


+ 16
- 4
hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java Visa fil

@@ -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<MhUnitTreeDTO> units = mhUnitManage.getMhUnitDashboardOption();
Set<Long> unitIds = CollUtils.fieldSet(units, MhUnitTreeDTO::getId);
initProcessManage.initProcessForUnits(unitIds);
}

@Test
public void test() {


Laddar…
Avbryt
Spara