@@ -104,8 +104,7 @@ public class AdaptStateMachineBuilderImpl implements BaseStateMachineBuilder<Pur | |||||
@Override | @Override | ||||
public StateMachineContext<TenderAdaptStatus, AdaptStateChangeEvent> read(Purchase contextObj) { | public StateMachineContext<TenderAdaptStatus, AdaptStateChangeEvent> 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); | return new DefaultStateMachineContext<>(status, null, null, null, null, MACHINE_ID); | ||||
} | } | ||||
}); | }); | ||||
@@ -104,8 +104,7 @@ public class SelfTestStateMachineBuilderImpl implements BaseStateMachineBuilder< | |||||
@Override | @Override | ||||
public StateMachineContext<TenderSelfTestStatus, SelfTestStateChangeEvent> read(Purchase contextObj) { | public StateMachineContext<TenderSelfTestStatus, SelfTestStateChangeEvent> 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); | return new DefaultStateMachineContext<>(status, null, null, null, null, MACHINE_ID); | ||||
} | } | ||||
}); | }); | ||||
@@ -131,7 +131,7 @@ public class TenderStateMachineBuilderImpl implements BaseStateMachineBuilder<Pu | |||||
@Override | @Override | ||||
public StateMachineContext<TenderStatus, TenderStateChangeEvent> read(Purchase contextObj) { | public StateMachineContext<TenderStatus, TenderStateChangeEvent> read(Purchase contextObj) { | ||||
return new DefaultStateMachineContext<>(TenderStatus.getByStatus(contextObj.getStatus()), | |||||
return new DefaultStateMachineContext<>(TenderStatus.getNoNull(contextObj.getStatus()), | |||||
null, null, null, null, MACHINE_ID); | null, null, null, null, MACHINE_ID); | ||||
} | } | ||||
}); | }); | ||||
@@ -104,8 +104,7 @@ public class TestValidStateMachineBuilderImpl implements BaseStateMachineBuilder | |||||
@Override | @Override | ||||
public StateMachineContext<TenderTestValidStatus, TestValidStateChangeEvent> read(Purchase contextObj) { | public StateMachineContext<TenderTestValidStatus, TestValidStateChangeEvent> 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); | return new DefaultStateMachineContext<>(testValidStatus, null, null, null, null, MACHINE_ID); | ||||
} | } | ||||
}); | }); | ||||
@@ -107,8 +107,7 @@ public class XcfhxStateMachineBuilderImpl implements BaseStateMachineBuilder<Pur | |||||
@Override | @Override | ||||
public StateMachineContext<TenderXcfhxApplyStatus, XcfhxStateChangeEvent> read(Purchase contextObj) { | public StateMachineContext<TenderXcfhxApplyStatus, XcfhxStateChangeEvent> 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); | return new DefaultStateMachineContext<>(status, null, null, null, null, MACHINE_ID); | ||||
} | } | ||||
}); | }); | ||||
@@ -5,10 +5,8 @@ import com.hz.pm.api.gov.enumeration.GovProjectStatusEnum; | |||||
import com.ningdatech.basic.exception.BizException; | import com.ningdatech.basic.exception.BizException; | ||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.Arrays; | import java.util.Arrays; | ||||
import java.util.Objects; | |||||
import java.util.Optional; | import java.util.Optional; | ||||
/** | /** | ||||
@@ -79,7 +77,7 @@ public enum ProjectStatus implements IStatus<Integer, String> { | |||||
return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | ||||
} | } | ||||
public static Optional<ProjectStatus> get(Integer code) { | |||||
private static Optional<ProjectStatus> get(Integer code) { | |||||
return Arrays.stream(values()).filter(w -> w.getCode().equals(code)).findFirst(); | return Arrays.stream(values()).filter(w -> w.getCode().equals(code)).findFirst(); | ||||
} | } | ||||
@@ -1,6 +1,7 @@ | |||||
package com.hz.pm.api.projectlib.model.enumeration.status; | package com.hz.pm.api.projectlib.model.enumeration.status; | ||||
import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||
import com.ningdatech.basic.exception.BizException; | |||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
@@ -27,10 +28,14 @@ public enum TenderAdaptStatus implements IStatus<Integer, String> { | |||||
private final Integer code; | private final Integer code; | ||||
private final String desc; | private final String desc; | ||||
public static Optional<TenderAdaptStatus> get(Integer code) { | |||||
private static Optional<TenderAdaptStatus> get(Integer code) { | |||||
return Arrays.stream(values()).filter(w -> w.eq(code)).findFirst(); | 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) { | public static String getDesc(Integer code) { | ||||
return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | ||||
} | } | ||||
@@ -1,6 +1,7 @@ | |||||
package com.hz.pm.api.projectlib.model.enumeration.status; | package com.hz.pm.api.projectlib.model.enumeration.status; | ||||
import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||
import com.ningdatech.basic.exception.BizException; | |||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
@@ -27,12 +28,16 @@ public enum TenderSelfTestStatus implements IStatus<Integer, String> { | |||||
private final Integer code; | private final Integer code; | ||||
private final String desc; | private final String desc; | ||||
public static Optional<TenderSelfTestStatus> get(Integer code) { | |||||
private static Optional<TenderSelfTestStatus> get(Integer code) { | |||||
return Arrays.stream(values()) | return Arrays.stream(values()) | ||||
.filter(w -> w.eq(code)) | .filter(w -> w.eq(code)) | ||||
.findFirst(); | .findFirst(); | ||||
} | } | ||||
public static TenderSelfTestStatus getNoNull(Integer code) { | |||||
return get(code).orElseThrow(() -> BizException.wrap("无效的系统自测状态:%s", code)); | |||||
} | |||||
public static String getDesc(Integer code) { | public static String getDesc(Integer code) { | ||||
return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | ||||
} | } | ||||
@@ -1,6 +1,7 @@ | |||||
package com.hz.pm.api.projectlib.model.enumeration.status; | package com.hz.pm.api.projectlib.model.enumeration.status; | ||||
import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||
import com.ningdatech.basic.exception.BizException; | |||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
@@ -33,17 +34,18 @@ public enum TenderStatus implements IStatus<Integer, String> { | |||||
private final String desc; | private final String desc; | ||||
public static TenderStatus getByStatus(Integer tenderStatus) { | |||||
private static Optional<TenderStatus> get(Integer tenderStatus) { | |||||
return Arrays.stream(values()) | return Arrays.stream(values()) | ||||
.filter(w -> w.eq(tenderStatus)) | .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) { | 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); | |||||
} | } | ||||
} | } |
@@ -1,6 +1,7 @@ | |||||
package com.hz.pm.api.projectlib.model.enumeration.status; | package com.hz.pm.api.projectlib.model.enumeration.status; | ||||
import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||
import com.ningdatech.basic.exception.BizException; | |||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
@@ -27,10 +28,14 @@ public enum TenderTestValidStatus implements IStatus<Integer, String> { | |||||
private final Integer code; | private final Integer code; | ||||
private final String desc; | private final String desc; | ||||
public static Optional<TenderTestValidStatus> get(Integer code) { | |||||
private static Optional<TenderTestValidStatus> get(Integer code) { | |||||
return Arrays.stream(values()).filter(w -> w.eq(code)).findFirst(); | 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) { | public static String getDesc(Integer code) { | ||||
return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | ||||
} | } | ||||
@@ -1,6 +1,7 @@ | |||||
package com.hz.pm.api.projectlib.model.enumeration.status; | package com.hz.pm.api.projectlib.model.enumeration.status; | ||||
import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||
import com.ningdatech.basic.exception.BizException; | |||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
@@ -27,10 +28,14 @@ public enum TenderXcfhxApplyStatus implements IStatus<Integer, String> { | |||||
private final Integer code; | private final Integer code; | ||||
private final String desc; | private final String desc; | ||||
public static Optional<TenderXcfhxApplyStatus> get(Integer code) { | |||||
private static Optional<TenderXcfhxApplyStatus> get(Integer code) { | |||||
return Arrays.stream(values()).filter(w -> w.eq(code)).findFirst(); | 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) { | public static String getDesc(Integer code) { | ||||
return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); | ||||
} | } | ||||