diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java index 1be82ae..61bdc1d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/AdaptStateMachineBuilderImpl.java @@ -104,8 +104,7 @@ public class AdaptStateMachineBuilderImpl implements BaseStateMachineBuilder read(Purchase contextObj) { - TenderAdaptStatus status = TenderAdaptStatus.get(contextObj.getAdaptStatus()) - .orElseThrow(() -> BizException.wrap("系统自测状态无效")); + TenderAdaptStatus status = TenderAdaptStatus.getNoNull(contextObj.getAdaptStatus()); return new DefaultStateMachineContext<>(status, null, null, null, null, MACHINE_ID); } }); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java index 23f13a4..f5025e1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/SelfTestStateMachineBuilderImpl.java @@ -104,8 +104,7 @@ public class SelfTestStateMachineBuilderImpl implements BaseStateMachineBuilder< @Override public StateMachineContext read(Purchase contextObj) { - TenderSelfTestStatus status = TenderSelfTestStatus.get(contextObj.getSelfTestStatus()) - .orElseThrow(() -> BizException.wrap("系统自测状态无效")); + TenderSelfTestStatus status = TenderSelfTestStatus.getNoNull(contextObj.getSelfTestStatus()); return new DefaultStateMachineContext<>(status, null, null, null, null, MACHINE_ID); } }); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java index e1fbbb2..93b9df0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TenderStateMachineBuilderImpl.java @@ -131,7 +131,7 @@ public class TenderStateMachineBuilderImpl implements BaseStateMachineBuilder read(Purchase contextObj) { - return new DefaultStateMachineContext<>(TenderStatus.getByStatus(contextObj.getStatus()), + return new DefaultStateMachineContext<>(TenderStatus.getNoNull(contextObj.getStatus()), null, null, null, null, MACHINE_ID); } }); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java index 1c5362b..d43d7c1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/TestValidStateMachineBuilderImpl.java @@ -104,8 +104,7 @@ public class TestValidStateMachineBuilderImpl implements BaseStateMachineBuilder @Override public StateMachineContext read(Purchase contextObj) { - TenderTestValidStatus testValidStatus = TenderTestValidStatus.get(contextObj.getTestValidStatus()) - .orElseThrow(() -> BizException.wrap("测试验证状态无效")); + TenderTestValidStatus testValidStatus = TenderTestValidStatus.getNoNull(contextObj.getTestValidStatus()); return new DefaultStateMachineContext<>(testValidStatus, null, null, null, null, MACHINE_ID); } }); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/XcfhxStateMachineBuilderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/XcfhxStateMachineBuilderImpl.java index cb56e55..5cbf8cc 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/XcfhxStateMachineBuilderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/impl/XcfhxStateMachineBuilderImpl.java @@ -107,8 +107,7 @@ public class XcfhxStateMachineBuilderImpl implements BaseStateMachineBuilder read(Purchase contextObj) { - TenderXcfhxApplyStatus status = TenderXcfhxApplyStatus.get(contextObj.getXcfhxApplyStatus()) - .orElseThrow(() -> BizException.wrap("信创符合性申请状态无效")); + TenderXcfhxApplyStatus status = TenderXcfhxApplyStatus.getNoNull(contextObj.getXcfhxApplyStatus()); return new DefaultStateMachineContext<>(status, null, null, null, null, MACHINE_ID); } }); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStatus.java index ab2f4f6..9ad9481 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStatus.java @@ -5,10 +5,8 @@ import com.hz.pm.api.gov.enumeration.GovProjectStatusEnum; import com.ningdatech.basic.exception.BizException; import lombok.AllArgsConstructor; import lombok.Getter; -import org.apache.commons.lang3.StringUtils; import java.util.Arrays; -import java.util.Objects; import java.util.Optional; /** @@ -79,7 +77,7 @@ public enum ProjectStatus implements IStatus { return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); } - public static Optional get(Integer code) { + private static Optional get(Integer code) { return Arrays.stream(values()).filter(w -> w.getCode().equals(code)).findFirst(); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderAdaptStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderAdaptStatus.java index b0de6d8..1b9e3fc 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderAdaptStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderAdaptStatus.java @@ -1,6 +1,7 @@ package com.hz.pm.api.projectlib.model.enumeration.status; import cn.hutool.core.util.StrUtil; +import com.ningdatech.basic.exception.BizException; import lombok.AllArgsConstructor; import lombok.Getter; @@ -27,10 +28,14 @@ public enum TenderAdaptStatus implements IStatus { private final Integer code; private final String desc; - public static Optional get(Integer code) { + private static Optional get(Integer code) { return Arrays.stream(values()).filter(w -> w.eq(code)).findFirst(); } + public static TenderAdaptStatus getNoNull(Integer code) { + return get(code).orElseThrow(() -> BizException.wrap("无效的适配改造状态:%s", code)); + } + public static String getDesc(Integer code) { return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderSelfTestStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderSelfTestStatus.java index 4eb1bc8..71e385b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderSelfTestStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderSelfTestStatus.java @@ -1,6 +1,7 @@ package com.hz.pm.api.projectlib.model.enumeration.status; import cn.hutool.core.util.StrUtil; +import com.ningdatech.basic.exception.BizException; import lombok.AllArgsConstructor; import lombok.Getter; @@ -27,12 +28,16 @@ public enum TenderSelfTestStatus implements IStatus { private final Integer code; private final String desc; - public static Optional get(Integer code) { + private static Optional get(Integer code) { return Arrays.stream(values()) .filter(w -> w.eq(code)) .findFirst(); } + public static TenderSelfTestStatus getNoNull(Integer code) { + return get(code).orElseThrow(() -> BizException.wrap("无效的系统自测状态:%s", code)); + } + public static String getDesc(Integer code) { return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderStatus.java index 0bd5dd3..a50d457 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderStatus.java @@ -1,6 +1,7 @@ package com.hz.pm.api.projectlib.model.enumeration.status; import cn.hutool.core.util.StrUtil; +import com.ningdatech.basic.exception.BizException; import lombok.AllArgsConstructor; import lombok.Getter; @@ -33,17 +34,18 @@ public enum TenderStatus implements IStatus { private final String desc; - public static TenderStatus getByStatus(Integer tenderStatus) { + private static Optional get(Integer tenderStatus) { return Arrays.stream(values()) .filter(w -> w.eq(tenderStatus)) - .findFirst() - .orElse(null); + .findFirst(); + } + + public static TenderStatus getNoNull(Integer tenderStatus) { + return get(tenderStatus).orElseThrow(() -> BizException.wrap("无效的标段状态:%s", tenderStatus)); } public static String getDescByStatus(Integer tenderStatus) { - return Optional.ofNullable(getByStatus(tenderStatus)) - .flatMap(w -> Optional.of(w.getDesc())) - .orElse(StrUtil.EMPTY); + return get(tenderStatus).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderTestValidStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderTestValidStatus.java index 14502ec..914a65e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderTestValidStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderTestValidStatus.java @@ -1,6 +1,7 @@ package com.hz.pm.api.projectlib.model.enumeration.status; import cn.hutool.core.util.StrUtil; +import com.ningdatech.basic.exception.BizException; import lombok.AllArgsConstructor; import lombok.Getter; @@ -27,10 +28,14 @@ public enum TenderTestValidStatus implements IStatus { private final Integer code; private final String desc; - public static Optional get(Integer code) { + private static Optional get(Integer code) { return Arrays.stream(values()).filter(w -> w.eq(code)).findFirst(); } + public static TenderTestValidStatus getNoNull(Integer code) { + return get(code).orElseThrow(() -> BizException.wrap("无效的测试验证状态:%s", code)); + } + public static String getDesc(Integer code) { return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderXcfhxApplyStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderXcfhxApplyStatus.java index 34da932..7bf3c33 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderXcfhxApplyStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/TenderXcfhxApplyStatus.java @@ -1,6 +1,7 @@ package com.hz.pm.api.projectlib.model.enumeration.status; import cn.hutool.core.util.StrUtil; +import com.ningdatech.basic.exception.BizException; import lombok.AllArgsConstructor; import lombok.Getter; @@ -27,10 +28,14 @@ public enum TenderXcfhxApplyStatus implements IStatus { private final Integer code; private final String desc; - public static Optional get(Integer code) { + private static Optional get(Integer code) { return Arrays.stream(values()).filter(w -> w.eq(code)).findFirst(); } + public static TenderXcfhxApplyStatus getNoNull(Integer code) { + return get(code).orElseThrow(() -> BizException.wrap("无效的信创符合性审查状态:%s",code)); + } + public static String getDesc(Integer code) { return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); }