预处理模块:工单问题生成,主网有效监测时长计算,
过程监督模块:工单模块功能,其他模块的审核
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.njcn.process.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.EnumUtils;
|
||||
import com.njcn.process.enums.ProcessResponseEnum;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月20日 10:03
|
||||
*/
|
||||
public class ProcessEnumUtil {
|
||||
|
||||
/**
|
||||
* 获取HarmonicResponseEnum实例
|
||||
*/
|
||||
public static ProcessResponseEnum getHarmonicEnumResponseEnumByMessage(@NotNull Object value) {
|
||||
ProcessResponseEnum harmonicResponseEnum;
|
||||
try {
|
||||
String message = value.toString();
|
||||
if(message.indexOf(StrUtil.C_COMMA)>0){
|
||||
value = message.substring(message.indexOf(StrUtil.C_COMMA)+1);
|
||||
}
|
||||
harmonicResponseEnum = EnumUtils.valueOf(ProcessResponseEnum.class, value, ProcessResponseEnum.class.getMethod(BusinessException.GET_MESSAGE_METHOD));
|
||||
return Objects.isNull(harmonicResponseEnum) ? ProcessResponseEnum.PROCESS_COMMON_ERROR : harmonicResponseEnum;
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new BusinessException(CommonResponseEnum.INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
public static Enum<?> getExceptionEnum(HttpResult<Object> result){
|
||||
//如果返回错误,且为内部错误,则直接抛出异常
|
||||
CommonResponseEnum commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
|
||||
if (commonResponseEnum == CommonResponseEnum.DEVICE_RESPONSE_ENUM) {
|
||||
return getHarmonicEnumResponseEnumByMessage(result.getMessage());
|
||||
}
|
||||
return commonResponseEnum;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user