Browse Source

增加测试验证、系统自测、适配改造状态机

tags/24080901
WendyYang 7 months ago
parent
commit
b008f66df6
21 changed files with 1306 additions and 8 deletions
  1. +58
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/AdaptAction.java
  2. +58
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/SelfTestAction.java
  3. +56
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TestValidAction.java
  4. +40
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/AdaptStateMachineBuilder.java
  5. +40
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/SelfTestStateMachineBuilder.java
  6. +38
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/TestValidStateMachineBuilder.java
  7. +114
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java
  8. +114
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java
  9. +114
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java
  10. +66
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java
  11. +66
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java
  12. +78
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java
  13. +107
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java
  14. +107
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java
  15. +107
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java
  16. +6
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java
  17. +0
    -7
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java
  18. +8
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/entity/Purchase.java
  19. +43
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/AdaptStatusEnum.java
  20. +43
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/SelfTestStatusEnum.java
  21. +43
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/TestValidStatusEnum.java

+ 58
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/AdaptAction.java View File

@@ -0,0 +1,58 @@
package com.hz.pm.api.common.statemachine.action;

import cn.hutool.core.lang.Assert;
import com.hz.pm.api.common.statemachine.builder.impl.TestValidStateMachineBuilderImpl;
import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent;
import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent;
import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.AdaptStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* <p>
* 测试验证状态机action集合类
* </p>
*
* @author WendyYang
* @since 17:08 2024/2/24
*/
@Slf4j
@WithStateMachine(id = TestValidStateMachineBuilderImpl.MACHINE_ID)
public class AdaptAction {

private Purchase getPurchaseInfo(Message<AdaptStateChangeEvent> message) {
Purchase purchase = (Purchase) message.getHeaders().get(TenderStateMachineUtil.PURCHASE);
Assert.notNull(purchase, "未获取到需要状态变更的标段信息");
return purchase;
}

@OnTransition(source = "WITHOUT_ADAPT_INFO", target = "ADAPT_INFO_AUDIT")
public void SUBMIT_ADAPT_INFO(Message<AdaptStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setAdaptStatus(AdaptStatusEnum.ADAPT_INFO_AUDIT.getCode());
}

@OnTransition(source = "ADAPT_INFO_AUDIT", target = "ADAPT_INFO_PASSED")
public void ADAPT_INFO_PASSED(Message<AdaptStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setAdaptStatus(AdaptStatusEnum.ADAPT_INFO_PASSED.getCode());
}

@OnTransition(source = "ADAPT_INFO_AUDIT", target = "ADAPT_INFO_FAILED")
public void ADAPT_INFO_FAILED(Message<AdaptStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setAdaptStatus(AdaptStatusEnum.ADAPT_INFO_FAILED.getCode());
}

@OnTransition(source = "ADAPT_INFO_FAILED", target = "ADAPT_INFO_AUDIT")
public void RESUBMIT_ADAPT_INFO(Message<AdaptStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setAdaptStatus(AdaptStatusEnum.ADAPT_INFO_AUDIT.getCode());
}

}

+ 58
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/SelfTestAction.java View File

@@ -0,0 +1,58 @@
package com.hz.pm.api.common.statemachine.action;

import cn.hutool.core.lang.Assert;
import com.hz.pm.api.common.statemachine.builder.impl.TestValidStateMachineBuilderImpl;
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.TenderStateMachineUtil;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.SelfTestStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* <p>
* 系统自测状态机action集合类
* </p>
*
* @author WendyYang
* @since 17:08 2024/2/24
*/
@Slf4j
@WithStateMachine(id = TestValidStateMachineBuilderImpl.MACHINE_ID)
public class SelfTestAction {

private Purchase getPurchaseInfo(Message<SelfTestStateChangeEvent> message) {
Purchase purchase = (Purchase) message.getHeaders().get(TenderStateMachineUtil.PURCHASE);
Assert.notNull(purchase, "未获取到需要状态变更的标段信息");
return purchase;
}

@OnTransition(source = "WITHOUT_SELF_TEST_INFO", target = "TEST_VALID_INFO_AUDIT")
public void SUBMIT_SELF_TEST_INFO(Message<SelfTestStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setSelfTestStatus(SelfTestStatusEnum.SELF_TEST_INFO_AUDIT.getCode());
}

@OnTransition(source = "SELF_TEST_INFO_AUDIT", target = "SELF_TEST_INFO_PASSED")
public void SELF_TEST_INFO_PASSED(Message<SelfTestStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setSelfTestStatus(SelfTestStatusEnum.SELF_TEST_INFO_PASSED.getCode());
}

@OnTransition(source = "SELF_TEST_INFO_AUDIT", target = "SELF_TEST_INFO_FAILED")
public void SELF_TEST_INFO_FAILED(Message<SelfTestStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setSelfTestStatus(SelfTestStatusEnum.SELF_TEST_INFO_FAILED.getCode());
}

@OnTransition(source = "SELF_TEST_INFO_FAILED", target = "TEST_VALID_INFO_AUDIT")
public void RESUBMIT_SELF_TEST_INFO(Message<SelfTestStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setSelfTestStatus(SelfTestStatusEnum.SELF_TEST_INFO_AUDIT.getCode());
}

}

+ 56
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/action/TestValidAction.java View File

@@ -0,0 +1,56 @@
package com.hz.pm.api.common.statemachine.action;

import cn.hutool.core.lang.Assert;
import com.hz.pm.api.common.statemachine.builder.impl.TestValidStateMachineBuilderImpl;
import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent;
import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;

/**
* <p>
* 测试验证状态机action集合类
* </p>
*
* @author WendyYang
* @since 17:08 2024/2/24
*/
@Slf4j
@WithStateMachine(id = TestValidStateMachineBuilderImpl.MACHINE_ID)
public class TestValidAction {

private Purchase getPurchaseInfo(Message<TestValidStateChangeEvent> message) {
Purchase purchase = (Purchase) message.getHeaders().get(TenderStateMachineUtil.PURCHASE);
Assert.notNull(purchase, "未获取到需要状态变更的标段信息");
return purchase;
}

@OnTransition(source = "WITHOUT_TEST_VALID_INFO", target = "TEST_VALID_INFO_AUDIT")
public void SUBMIT_TEST_VALID_INFO(Message<TestValidStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setTestValidStatus(TestValidStatusEnum.TEST_VALID_INFO_AUDIT.getCode());
}

@OnTransition(source = "TEST_VALID_INFO_AUDIT", target = "TEST_VALID_INFO_PASSED")
public void TEST_VALID_INFO_PASSED(Message<TestValidStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setTestValidStatus(TestValidStatusEnum.TEST_VALID_INFO_PASSED.getCode());
}

@OnTransition(source = "TEST_VALID_INFO_AUDIT", target = "TEST_VALID_INFO_FAILED")
public void TEST_VALID_INFO_FAILED(Message<TestValidStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setTestValidStatus(TestValidStatusEnum.TEST_VALID_INFO_FAILED.getCode());
}

@OnTransition(source = "TEST_VALID_INFO_FAILED", target = "TEST_VALID_INFO_AUDIT")
public void RESUBMIT_TEST_VALID_INFO(Message<TestValidStateChangeEvent> message) {
Purchase purchase = getPurchaseInfo(message);
purchase.setTestValidStatus(TestValidStatusEnum.TEST_VALID_INFO_AUDIT.getCode());
}

}

+ 40
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/AdaptStateMachineBuilder.java View File

@@ -0,0 +1,40 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent;
import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.AdaptStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineException;
import org.springframework.statemachine.persist.StateMachinePersister;

/**
* 项目申报状态机
*
* @author CMM
* @since 2023/02/07 15:56
*/
public interface AdaptStateMachineBuilder {


StateMachine<AdaptStatusEnum, AdaptStateChangeEvent> build() throws StateMachineException;

/**
* 构建状态机
*
* @param beanFactory \
*/
StateMachine<AdaptStatusEnum, AdaptStateChangeEvent> build(BeanFactory beanFactory) throws StateMachineException;

/**
* 持久化配置
*
* @author CMM
* @since 2023/02/07 16:22
*/
StateMachinePersister<AdaptStatusEnum, AdaptStateChangeEvent, Purchase> stateMachinePersister();


}

+ 40
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/SelfTestStateMachineBuilder.java View File

@@ -0,0 +1,40 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent;
import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.SelfTestStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineException;
import org.springframework.statemachine.persist.StateMachinePersister;

/**
* 项目申报状态机
*
* @author CMM
* @since 2023/02/07 15:56
*/
public interface SelfTestStateMachineBuilder {


StateMachine<SelfTestStatusEnum, SelfTestStateChangeEvent> build() throws StateMachineException;

/**
* 构建状态机
*
* @param beanFactory \
*/
StateMachine<SelfTestStatusEnum, SelfTestStateChangeEvent> build(BeanFactory beanFactory) throws StateMachineException;

/**
* 持久化配置
*
* @author CMM
* @since 2023/02/07 16:22
*/
StateMachinePersister<SelfTestStatusEnum, SelfTestStateChangeEvent, Purchase> stateMachinePersister();


}

+ 38
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/TestValidStateMachineBuilder.java View File

@@ -0,0 +1,38 @@
package com.hz.pm.api.common.statemachine.builder;

import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineException;
import org.springframework.statemachine.persist.StateMachinePersister;

/**
* 项目申报状态机
*
* @author CMM
* @since 2023/02/07 15:56
*/
public interface TestValidStateMachineBuilder {


StateMachine<TestValidStatusEnum, TestValidStateChangeEvent> build() throws StateMachineException;

/**
* 构建状态机
*
* @param beanFactory \
*/
StateMachine<TestValidStatusEnum, TestValidStateChangeEvent> build(BeanFactory beanFactory) throws StateMachineException;

/**
* 持久化配置
*
* @author CMM
* @since 2023/02/07 16:22
*/
StateMachinePersister<TestValidStatusEnum, TestValidStateChangeEvent, Purchase> stateMachinePersister();


}

+ 114
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java View File

@@ -0,0 +1,114 @@
package com.hz.pm.api.common.statemachine.builder.impl;

import com.hz.pm.api.common.statemachine.builder.AdaptStateMachineBuilder;
import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.AdaptStatusEnum;
import com.ningdatech.basic.exception.BizException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachineException;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* <p>
* 标段状态机
* </p>
*
* @author WendyYang
* @since 16:38 2024/2/24
*/
@Slf4j
@Component
@EnableStateMachine(name = AdaptStateMachineBuilderImpl.MACHINE_ID)
@RequiredArgsConstructor
public class AdaptStateMachineBuilderImpl implements AdaptStateMachineBuilder {

public static final String MACHINE_ID = "adaptStateMachine";

private final BeanFactory beanFactory;

@Override
public StateMachine<AdaptStatusEnum, AdaptStateChangeEvent> build() throws StateMachineException {
StateMachine<AdaptStatusEnum, AdaptStateChangeEvent> stateMachine = build(beanFactory);
log.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}

@Override
public StateMachine<AdaptStatusEnum, AdaptStateChangeEvent> build(BeanFactory beanFactory) throws StateMachineException {
try {
return buildStateMachine(beanFactory);
} catch (Exception e) {
throw new StateMachineException("状态机构件失败", e);
}
}

private StateMachine<AdaptStatusEnum, AdaptStateChangeEvent> buildStateMachine(BeanFactory factory) throws Exception {
StateMachineBuilder.Builder<AdaptStatusEnum, AdaptStateChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINE_ID)
.beanFactory(factory);

builder.configureStates()
.withStates()
.initial(AdaptStatusEnum.WITHOUT_ADAPT_INFO)
.states(EnumSet.allOf(AdaptStatusEnum.class));

builder.configureTransitions()
.withExternal()
.source(AdaptStatusEnum.WITHOUT_ADAPT_INFO)
.target(AdaptStatusEnum.ADAPT_INFO_AUDIT)
.event(AdaptStateChangeEvent.SUBMIT_ADAPT_INFO)
.and()
.withExternal()
.source(AdaptStatusEnum.ADAPT_INFO_AUDIT)
.target(AdaptStatusEnum.ADAPT_INFO_PASSED)
.event(AdaptStateChangeEvent.ADAPT_INFO_PASSED)
.and()
.withExternal()
.source(AdaptStatusEnum.ADAPT_INFO_AUDIT)
.target(AdaptStatusEnum.ADAPT_INFO_FAILED)
.event(AdaptStateChangeEvent.ADAPT_INFO_FAILED)
.and()
.withExternal()
.source(AdaptStatusEnum.ADAPT_INFO_FAILED)
.target(AdaptStatusEnum.ADAPT_INFO_AUDIT)
.event(AdaptStateChangeEvent.RESUBMIT_ADAPT_INFO)
.and();
return builder.build();
}

@Override
@Bean(name = "adaptStatePersister")
public StateMachinePersister<AdaptStatusEnum, AdaptStateChangeEvent, Purchase> stateMachinePersister() {
return new DefaultStateMachinePersister<>(new StateMachinePersist<AdaptStatusEnum, AdaptStateChangeEvent, Purchase>() {
@Override
public void write(StateMachineContext<AdaptStatusEnum, AdaptStateChangeEvent> context, Purchase contextObj) {
log.info("当前项目为:{}", contextObj);
}

@Override
public StateMachineContext<AdaptStatusEnum, AdaptStateChangeEvent> read(Purchase contextObj) {
AdaptStatusEnum status = AdaptStatusEnum.get(contextObj.getAdaptStatus())
.orElseThrow(() -> BizException.wrap("系统自测状态无效"));
return new DefaultStateMachineContext<>(status, null, null, null, null, MACHINE_ID);
}
});
}

}

+ 114
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java View File

@@ -0,0 +1,114 @@
package com.hz.pm.api.common.statemachine.builder.impl;

import com.hz.pm.api.common.statemachine.builder.SelfTestStateMachineBuilder;
import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.SelfTestStatusEnum;
import com.ningdatech.basic.exception.BizException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachineException;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* <p>
* 标段状态机
* </p>
*
* @author WendyYang
* @since 16:38 2024/2/24
*/
@Slf4j
@Component
@EnableStateMachine(name = SelfTestStateMachineBuilderImpl.MACHINE_ID)
@RequiredArgsConstructor
public class SelfTestStateMachineBuilderImpl implements SelfTestStateMachineBuilder {

public static final String MACHINE_ID = "selfTestStateMachine";

private final BeanFactory beanFactory;

@Override
public StateMachine<SelfTestStatusEnum, SelfTestStateChangeEvent> build() throws StateMachineException {
StateMachine<SelfTestStatusEnum, SelfTestStateChangeEvent> stateMachine = build(beanFactory);
log.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}

@Override
public StateMachine<SelfTestStatusEnum, SelfTestStateChangeEvent> build(BeanFactory beanFactory) throws StateMachineException {
try {
return buildStateMachine(beanFactory);
} catch (Exception e) {
throw new StateMachineException("状态机构件失败", e);
}
}

private StateMachine<SelfTestStatusEnum, SelfTestStateChangeEvent> buildStateMachine(BeanFactory factory) throws Exception {
StateMachineBuilder.Builder<SelfTestStatusEnum, SelfTestStateChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINE_ID)
.beanFactory(factory);

builder.configureStates()
.withStates()
.initial(SelfTestStatusEnum.WITHOUT_SELF_TEST_INFO)
.states(EnumSet.allOf(SelfTestStatusEnum.class));

builder.configureTransitions()
.withExternal()
.source(SelfTestStatusEnum.WITHOUT_SELF_TEST_INFO)
.target(SelfTestStatusEnum.SELF_TEST_INFO_AUDIT)
.event(SelfTestStateChangeEvent.SUBMIT_SELF_TEST_INFO)
.and()
.withExternal()
.source(SelfTestStatusEnum.SELF_TEST_INFO_AUDIT)
.target(SelfTestStatusEnum.SELF_TEST_INFO_PASSED)
.event(SelfTestStateChangeEvent.SELF_TEST_PASSED)
.and()
.withExternal()
.source(SelfTestStatusEnum.SELF_TEST_INFO_AUDIT)
.target(SelfTestStatusEnum.SELF_TEST_INFO_FAILED)
.event(SelfTestStateChangeEvent.SELF_TEST_FAILED)
.and()
.withExternal()
.source(SelfTestStatusEnum.SELF_TEST_INFO_FAILED)
.target(SelfTestStatusEnum.SELF_TEST_INFO_AUDIT)
.event(SelfTestStateChangeEvent.RESUBMIT_SELF_TEST)
.and();
return builder.build();
}

@Override
@Bean(name = "selfTestStatePersister")
public StateMachinePersister<SelfTestStatusEnum, SelfTestStateChangeEvent, Purchase> stateMachinePersister() {
return new DefaultStateMachinePersister<>(new StateMachinePersist<SelfTestStatusEnum, SelfTestStateChangeEvent, Purchase>() {
@Override
public void write(StateMachineContext<SelfTestStatusEnum, SelfTestStateChangeEvent> context, Purchase contextObj) {
log.info("当前项目为:{}", contextObj);
}

@Override
public StateMachineContext<SelfTestStatusEnum, SelfTestStateChangeEvent> read(Purchase contextObj) {
SelfTestStatusEnum status = SelfTestStatusEnum.get(contextObj.getSelfTestStatus())
.orElseThrow(() -> BizException.wrap("系统自测状态无效"));
return new DefaultStateMachineContext<>(status, null, null, null, null, MACHINE_ID);
}
});
}

}

+ 114
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java View File

@@ -0,0 +1,114 @@
package com.hz.pm.api.common.statemachine.builder.impl;

import com.hz.pm.api.common.statemachine.builder.TestValidStateMachineBuilder;
import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import com.ningdatech.basic.exception.BizException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineContext;
import org.springframework.statemachine.StateMachineException;
import org.springframework.statemachine.StateMachinePersist;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.statemachine.support.DefaultStateMachineContext;
import org.springframework.stereotype.Component;

import java.util.EnumSet;

/**
* <p>
* 标段状态机
* </p>
*
* @author WendyYang
* @since 16:38 2024/2/24
*/
@Slf4j
@Component
@EnableStateMachine(name = TestValidStateMachineBuilderImpl.MACHINE_ID)
@RequiredArgsConstructor
public class TestValidStateMachineBuilderImpl implements TestValidStateMachineBuilder {

public static final String MACHINE_ID = "testValidStateMachine";

private final BeanFactory beanFactory;

@Override
public StateMachine<TestValidStatusEnum, TestValidStateChangeEvent> build() throws StateMachineException {
StateMachine<TestValidStatusEnum, TestValidStateChangeEvent> stateMachine = build(beanFactory);
log.info("状态机ID:" + stateMachine.getId());
stateMachine.start();
return stateMachine;
}

@Override
public StateMachine<TestValidStatusEnum, TestValidStateChangeEvent> build(BeanFactory beanFactory) throws StateMachineException {
try {
return buildStateMachine(beanFactory);
} catch (Exception e) {
throw new StateMachineException("状态机构件失败", e);
}
}

private StateMachine<TestValidStatusEnum, TestValidStateChangeEvent> buildStateMachine(BeanFactory factory) throws Exception {
StateMachineBuilder.Builder<TestValidStatusEnum, TestValidStateChangeEvent> builder = StateMachineBuilder.builder();
builder.configureConfiguration()
.withConfiguration()
.machineId(MACHINE_ID)
.beanFactory(factory);

builder.configureStates()
.withStates()
.initial(TestValidStatusEnum.WITHOUT_TEST_VALID_INFO)
.states(EnumSet.allOf(TestValidStatusEnum.class));

builder.configureTransitions()
.withExternal()
.source(TestValidStatusEnum.WITHOUT_TEST_VALID_INFO)
.target(TestValidStatusEnum.TEST_VALID_INFO_AUDIT)
.event(TestValidStateChangeEvent.SUBMIT_TEST_VALID_INFO)
.and()
.withExternal()
.source(TestValidStatusEnum.TEST_VALID_INFO_AUDIT)
.target(TestValidStatusEnum.TEST_VALID_INFO_PASSED)
.event(TestValidStateChangeEvent.TEST_VALID_INFO_PASSED)
.and()
.withExternal()
.source(TestValidStatusEnum.TEST_VALID_INFO_AUDIT)
.target(TestValidStatusEnum.TEST_VALID_INFO_FAILED)
.event(TestValidStateChangeEvent.TEST_VALID_INFO_FAILED)
.and()
.withExternal()
.source(TestValidStatusEnum.TEST_VALID_INFO_FAILED)
.target(TestValidStatusEnum.TEST_VALID_INFO_AUDIT)
.event(TestValidStateChangeEvent.RESUBMIT_TEST_VALID_INFO)
.and();
return builder.build();
}

@Override
@Bean(name = "testValidStatePersister")
public StateMachinePersister<TestValidStatusEnum, TestValidStateChangeEvent, Purchase> stateMachinePersister() {
return new DefaultStateMachinePersister<>(new StateMachinePersist<TestValidStatusEnum, TestValidStateChangeEvent, Purchase>() {
@Override
public void write(StateMachineContext<TestValidStatusEnum, TestValidStateChangeEvent> context, Purchase contextObj) {
log.info("当前项目为:{}", contextObj);
}

@Override
public StateMachineContext<TestValidStatusEnum, TestValidStateChangeEvent> read(Purchase contextObj) {
TestValidStatusEnum testValidStatus = TestValidStatusEnum.get(contextObj.getTestValidStatus())
.orElseThrow(() -> BizException.wrap("测试验证状态无效"));
return new DefaultStateMachineContext<>(testValidStatus, null, null, null, null, MACHINE_ID);
}
});
}

}

+ 66
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/AdaptStateChangeEvent.java View File

@@ -0,0 +1,66 @@
package com.hz.pm.api.common.statemachine.event;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
* <p>
* TenderStatusChangeEvent
* </p>
*
* @author WendyYang
* @since 00:14 2024/2/24
*/
@Getter
@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);


private final Integer passStatusCode;
private final Integer rejectStatusCode;
private final Integer withdrawStatusCode;

public static AdaptStateChangeEvent getPassValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (AdaptStateChangeEvent t : AdaptStateChangeEvent.values()) {
if (code.equals(t.getPassStatusCode())) {
return t;
}
}
return null;
}

public static AdaptStateChangeEvent getRejectValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (AdaptStateChangeEvent t : AdaptStateChangeEvent.values()) {
if (code.equals(t.getRejectStatusCode())) {
return t;
}
}
return null;
}

public static AdaptStateChangeEvent getWithdrawValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (AdaptStateChangeEvent t : AdaptStateChangeEvent.values()) {
if (code.equals(t.getWithdrawStatusCode())) {
return t;
}
}
return null;
}

}

+ 66
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/SelfTestStateChangeEvent.java View File

@@ -0,0 +1,66 @@
package com.hz.pm.api.common.statemachine.event;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
* <p>
* SelfTestStateChangeEvent
* </p>
*
* @author WendyYang
* @since 00:14 2024/2/24
*/
@Getter
@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);


private final Integer passStatusCode;
private final Integer rejectStatusCode;
private final Integer withdrawStatusCode;

public static SelfTestStateChangeEvent getPassValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (SelfTestStateChangeEvent t : SelfTestStateChangeEvent.values()) {
if (code.equals(t.getPassStatusCode())) {
return t;
}
}
return null;
}

public static SelfTestStateChangeEvent getRejectValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (SelfTestStateChangeEvent t : SelfTestStateChangeEvent.values()) {
if (code.equals(t.getRejectStatusCode())) {
return t;
}
}
return null;
}

public static SelfTestStateChangeEvent getWithdrawValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (SelfTestStateChangeEvent t : SelfTestStateChangeEvent.values()) {
if (code.equals(t.getWithdrawStatusCode())) {
return t;
}
}
return null;
}

}

+ 78
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/event/TestValidStateChangeEvent.java View File

@@ -0,0 +1,78 @@
package com.hz.pm.api.common.statemachine.event;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
* <p>
* TenderStatusChangeEvent
* </p>
*
* @author WendyYang
* @since 00:14 2024/2/24
*/
@Getter
@AllArgsConstructor
public enum TestValidStateChangeEvent {

/**
* 填写测试验证信息
*/
SUBMIT_TEST_VALID_INFO(100, null, null),
/**
* 测试验证信息审核通过
*/
TEST_VALID_INFO_PASSED(101, null, null),
/**
* 测试验证信息审核不通过
*/
TEST_VALID_INFO_FAILED(null, 101, null),
/**
* 重新填写测试验证信息
*/
RESUBMIT_TEST_VALID_INFO(102, null, null);


private final Integer passStatusCode;
private final Integer rejectStatusCode;
private final Integer withdrawStatusCode;

public static TestValidStateChangeEvent getPassValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (TestValidStateChangeEvent t : TestValidStateChangeEvent.values()) {
if (code.equals(t.getPassStatusCode())) {
return t;
}
}
return null;
}

public static TestValidStateChangeEvent getRejectValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (TestValidStateChangeEvent t : TestValidStateChangeEvent.values()) {
if (code.equals(t.getRejectStatusCode())) {
return t;
}
}
return null;
}

public static TestValidStateChangeEvent getWithdrawValueByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (TestValidStateChangeEvent t : TestValidStateChangeEvent.values()) {
if (code.equals(t.getWithdrawStatusCode())) {
return t;
}
}
return null;
}

}

+ 107
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/AdaptStateMachineUtil.java View File

@@ -0,0 +1,107 @@
package com.hz.pm.api.common.statemachine.util;

import com.hz.pm.api.common.statemachine.builder.AdaptStateMachineBuilder;
import com.hz.pm.api.common.statemachine.event.AdaptStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.AdaptStatusEnum;
import com.ningdatech.basic.exception.BizException;
import com.wflow.exception.BusinessException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
* <p>
* 标段状态机工具类
* </p>
*
* @author WendyYang
* @since 17:06 2024/2/24
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class AdaptStateMachineUtil {

public static final String PURCHASE = "purchaseInfo";

//==================================================================================================================

private final AdaptStateMachineBuilder adaptStateMachineBuilder;

//通过审核
public void pass(Purchase purchase) {
try {
execute(purchase, getPassEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 通过失败 :{}", e.getMessage());
throw new BusinessException("状态机 通过失败: " + e);
}
}

//拒绝
public void reject(Purchase purchase) {
try {
execute(purchase, getRejectEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 拒绝失败 :{}", e.getMessage());
throw new BusinessException("状态机 拒绝失败: " + e);
}
}

//撤回
public void withDraw(Purchase purchase) {
try {
execute(purchase, getWithdrawEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 撤回失败 :{}", e.getMessage());
throw new BusinessException("状态机 撤回失败: " + e);
}
}

public void execute(Purchase purchase, AdaptStateChangeEvent event) throws Exception {
log.info("调用状态机前的标段状态为:{}", purchase.getStatus());
// 获取TO状态机
StateMachine<AdaptStatusEnum, AdaptStateChangeEvent> stateMachine = adaptStateMachineBuilder.build();
Message<AdaptStateChangeEvent> message = MessageBuilder.withPayload(event)
.setHeader(PURCHASE, purchase)
.build();
//初始化状态机
StateMachinePersister<AdaptStatusEnum, AdaptStateChangeEvent, Purchase> stateMachinePersister = adaptStateMachineBuilder.stateMachinePersister();
stateMachinePersister.restore(stateMachine, purchase);
stateMachine.sendEvent(message);
log.info("调用状态机后的标段状态为:{}", purchase.getStatus());
}


public AdaptStateChangeEvent getPassEvent(Integer status) {
AdaptStateChangeEvent event = AdaptStateChangeEvent.getPassValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的通过操作!");
}
return event;
}

public AdaptStateChangeEvent getRejectEvent(Integer status) {
AdaptStateChangeEvent event = AdaptStateChangeEvent.getRejectValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的驳回操作!");
}
return event;
}

public AdaptStateChangeEvent getWithdrawEvent(Integer status) {
AdaptStateChangeEvent event = AdaptStateChangeEvent.getWithdrawValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的撤回操作!");
}
return event;
}

}

+ 107
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/SelfTestStateMachineUtil.java View File

@@ -0,0 +1,107 @@
package com.hz.pm.api.common.statemachine.util;

import com.hz.pm.api.common.statemachine.builder.SelfTestStateMachineBuilder;
import com.hz.pm.api.common.statemachine.event.SelfTestStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.SelfTestStatusEnum;
import com.ningdatech.basic.exception.BizException;
import com.wflow.exception.BusinessException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
* <p>
* 标段状态机工具类
* </p>
*
* @author WendyYang
* @since 17:06 2024/2/24
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class SelfTestStateMachineUtil {

public static final String PURCHASE = "purchaseInfo";

//==================================================================================================================

private final SelfTestStateMachineBuilder selfTestStateMachineBuilder;

//通过审核
public void pass(Purchase purchase) {
try {
execute(purchase, getPassEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 通过失败 :{}", e.getMessage());
throw new BusinessException("状态机 通过失败: " + e);
}
}

//拒绝
public void reject(Purchase purchase) {
try {
execute(purchase, getRejectEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 拒绝失败 :{}", e.getMessage());
throw new BusinessException("状态机 拒绝失败: " + e);
}
}

//撤回
public void withDraw(Purchase purchase) {
try {
execute(purchase, getWithdrawEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 撤回失败 :{}", e.getMessage());
throw new BusinessException("状态机 撤回失败: " + e);
}
}

public void execute(Purchase purchase, SelfTestStateChangeEvent event) throws Exception {
log.info("调用状态机前的标段状态为:{}", purchase.getStatus());
// 获取TO状态机
StateMachine<SelfTestStatusEnum, SelfTestStateChangeEvent> stateMachine = selfTestStateMachineBuilder.build();
Message<SelfTestStateChangeEvent> message = MessageBuilder.withPayload(event)
.setHeader(PURCHASE, purchase)
.build();
//初始化状态机
StateMachinePersister<SelfTestStatusEnum, SelfTestStateChangeEvent, Purchase> stateMachinePersister = selfTestStateMachineBuilder.stateMachinePersister();
stateMachinePersister.restore(stateMachine, purchase);
stateMachine.sendEvent(message);
log.info("调用状态机后的标段状态为:{}", purchase.getStatus());
}


public SelfTestStateChangeEvent getPassEvent(Integer status) {
SelfTestStateChangeEvent event = SelfTestStateChangeEvent.getPassValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的通过操作!");
}
return event;
}

public SelfTestStateChangeEvent getRejectEvent(Integer status) {
SelfTestStateChangeEvent event = SelfTestStateChangeEvent.getRejectValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的驳回操作!");
}
return event;
}

public SelfTestStateChangeEvent getWithdrawEvent(Integer status) {
SelfTestStateChangeEvent event = SelfTestStateChangeEvent.getWithdrawValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的撤回操作!");
}
return event;
}

}

+ 107
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/util/TestValidStateMachineUtil.java View File

@@ -0,0 +1,107 @@
package com.hz.pm.api.common.statemachine.util;

import com.hz.pm.api.common.statemachine.builder.TestValidStateMachineBuilder;
import com.hz.pm.api.common.statemachine.event.TestValidStateChangeEvent;
import com.hz.pm.api.projectdeclared.model.entity.Purchase;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import com.ningdatech.basic.exception.BizException;
import com.wflow.exception.BusinessException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.persist.StateMachinePersister;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
* <p>
* 标段状态机工具类
* </p>
*
* @author WendyYang
* @since 17:06 2024/2/24
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class TestValidStateMachineUtil {

public static final String PURCHASE = "purchaseInfo";

//==================================================================================================================

private final TestValidStateMachineBuilder testValidStateMachineBuilder;

//通过审核
public void pass(Purchase purchase) {
try {
execute(purchase, getPassEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 通过失败 :{}", e.getMessage());
throw new BusinessException("状态机 通过失败: " + e);
}
}

//拒绝
public void reject(Purchase purchase) {
try {
execute(purchase, getRejectEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 拒绝失败 :{}", e.getMessage());
throw new BusinessException("状态机 拒绝失败: " + e);
}
}

//撤回
public void withDraw(Purchase purchase) {
try {
execute(purchase, getWithdrawEvent(purchase.getStatus()));
} catch (Exception e) {
log.info("状态机 撤回失败 :{}", e.getMessage());
throw new BusinessException("状态机 撤回失败: " + e);
}
}

public void execute(Purchase purchase, TestValidStateChangeEvent event) throws Exception {
log.info("调用状态机前的标段状态为:{}", purchase.getStatus());
// 获取TO状态机
StateMachine<TestValidStatusEnum, TestValidStateChangeEvent> stateMachine = testValidStateMachineBuilder.build();
Message<TestValidStateChangeEvent> message = MessageBuilder.withPayload(event)
.setHeader(PURCHASE, purchase)
.build();
//初始化状态机
StateMachinePersister<TestValidStatusEnum, TestValidStateChangeEvent, Purchase> stateMachinePersister = testValidStateMachineBuilder.stateMachinePersister();
stateMachinePersister.restore(stateMachine, purchase);
stateMachine.sendEvent(message);
log.info("调用状态机后的标段状态为:{}", purchase.getStatus());
}


public TestValidStateChangeEvent getPassEvent(Integer status) {
TestValidStateChangeEvent event = TestValidStateChangeEvent.getPassValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的通过操作!");
}
return event;
}

public TestValidStateChangeEvent getRejectEvent(Integer status) {
TestValidStateChangeEvent event = TestValidStateChangeEvent.getRejectValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的驳回操作!");
}
return event;
}

public TestValidStateChangeEvent getWithdrawEvent(Integer status) {
TestValidStateChangeEvent event = TestValidStateChangeEvent.getWithdrawValueByCode(status);
if (Objects.isNull(event)) {
throw new BizException("该状态下没有对应的撤回操作!");
}
return event;
}

}

+ 6
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java View File

@@ -3,7 +3,6 @@ package com.hz.pm.api.projectdeclared.manage;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.statemachine.util.StateMachineUtil;
import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil;
import com.hz.pm.api.projectdeclared.model.dto.OperationReq;
@@ -13,7 +12,10 @@ import com.hz.pm.api.projectdeclared.model.vo.OperationVO;
import com.hz.pm.api.projectdeclared.service.IOperationService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.AdaptStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.SelfTestStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.TenderStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.TestValidStatusEnum;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.user.security.model.UserInfoDetails;
import com.hz.pm.api.user.util.LoginUserUtil;
@@ -94,6 +96,9 @@ public class OperationManage {
}
// 修改标段状态
tenderStateMachineUtil.pass(purchase);
purchase.setSelfTestStatus(SelfTestStatusEnum.WITHOUT_SELF_TEST_INFO.getCode());
purchase.setTestValidStatus(TestValidStatusEnum.WITHOUT_TEST_VALID_INFO.getCode());
purchase.setAdaptStatus(AdaptStatusEnum.WITHOUT_ADAPT_INFO.getCode());
purchaseService.updateById(purchase);
return curr.getProjectCode();
}


+ 0
- 7
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java View File

@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;
@@ -53,18 +52,12 @@ import com.ningdatech.file.service.FileService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;


+ 8
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/entity/Purchase.java View File

@@ -146,5 +146,13 @@ public class Purchase {
@ApiModelProperty("信创报告")
private String xcfhxReportFiles;

@ApiModelProperty("适配改造状态")
private Integer adaptStatus;

@ApiModelProperty("系统自测状态")
private Integer selfTestStatus;

@ApiModelProperty("测试验证状态")
private Integer testValidStatus;

}

+ 43
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/AdaptStatusEnum.java View File

@@ -0,0 +1,43 @@
package com.hz.pm.api.projectlib.model.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
* <p>
* SelfTestStatusEnum
* </p>
*
* @author WendyYang
* @since 10:16 2024/3/27
*/
@Getter
@AllArgsConstructor
public enum AdaptStatusEnum {

WITHOUT_ADAPT_INFO(100, "待填写适配改造信息"),
ADAPT_INFO_AUDIT(101, "适配改造信息审核中"),
ADAPT_INFO_FAILED(102, "适配改造信息审核失败"),
ADAPT_INFO_PASSED(103, "适配改造信息审核通过");

private final Integer code;
private final String val;

public boolean eq(Integer code) {
return this.code.equals(code);
}

public static Optional<AdaptStatusEnum> get(Integer code) {
return Arrays.stream(values())
.filter(w -> w.getCode().equals(code))
.findFirst();
}

public static String getVal(Integer code) {
return get(code).flatMap(w -> Optional.of(w.getVal())).orElse("");
}

}

+ 43
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/SelfTestStatusEnum.java View File

@@ -0,0 +1,43 @@
package com.hz.pm.api.projectlib.model.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
* <p>
* SelfTestStatusEnum
* </p>
*
* @author WendyYang
* @since 10:16 2024/3/27
*/
@Getter
@AllArgsConstructor
public enum SelfTestStatusEnum {

WITHOUT_SELF_TEST_INFO(100, "待填写系统自测信息"),
SELF_TEST_INFO_AUDIT(101, "系统自测信息审核中"),
SELF_TEST_INFO_FAILED(102, "系统自测信息审核失败"),
SELF_TEST_INFO_PASSED(103, "系统自测信息审核通过");

private final Integer code;
private final String val;

public boolean eq(Integer code) {
return this.code.equals(code);
}

public static Optional<SelfTestStatusEnum> get(Integer code) {
return Arrays.stream(values())
.filter(w -> w.getCode().equals(code))
.findFirst();
}

public static String getVal(Integer code) {
return get(code).flatMap(w -> Optional.of(w.getVal())).orElse("");
}

}

+ 43
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/TestValidStatusEnum.java View File

@@ -0,0 +1,43 @@
package com.hz.pm.api.projectlib.model.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
* <p>
* SelfTestStatusEnum
* </p>
*
* @author WendyYang
* @since 10:16 2024/3/27
*/
@Getter
@AllArgsConstructor
public enum TestValidStatusEnum {

WITHOUT_TEST_VALID_INFO(100, "待填写测试验证信息"),
TEST_VALID_INFO_AUDIT(101, "测试验证信息审核中"),
TEST_VALID_INFO_FAILED(102, "测试验证信息审核失败"),
TEST_VALID_INFO_PASSED(103, "测试验证信息审核通过");

private final Integer code;
private final String val;

public boolean eq(Integer code) {
return this.code.equals(code);
}

public static Optional<TestValidStatusEnum> get(Integer code) {
return Arrays.stream(values())
.filter(w -> w.getCode().equals(code))
.findFirst();
}

public static String getVal(Integer code) {
return get(code).flatMap(w -> Optional.of(w.getVal())).orElse("");
}

}

Loading…
Cancel
Save