组态功能开发
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.csdevice.api.fallback.CsEdDataFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.dto.CsDictDTO;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/dict", fallbackFactory = CsEdDataFeignClientFallbackFactory.class,contextId = "edData")
|
||||
public interface CsDictFeignClient {
|
||||
|
||||
@PostMapping("/getOwnAndFatherData")
|
||||
HttpResult<CsDictDTO> getOwnAndFatherData(@RequestParam("name")String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsLedgerFeignClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csLedger", fallbackFactory = CsLedgerFeignClientFallbackFactory.class,contextId = "csLedger")
|
||||
public interface CsLedgerFeignClient {
|
||||
|
||||
@PostMapping("/findDevByLineId")
|
||||
HttpResult<String> findDevByLineId(@RequestParam("lineId") String lineId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.api.fallback.DataArrayFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csDataArray", fallbackFactory = DataArrayFeignClientFallbackFactory.class,contextId = "csDataArray")
|
||||
|
||||
public interface DataArrayFeignClient {
|
||||
|
||||
@PostMapping("/getArrayBySet")
|
||||
HttpResult<List<CsDataArray>> getArrayBySet(@RequestBody List<CsDataSet> setList);
|
||||
|
||||
@PostMapping("/getDataArray")
|
||||
HttpResult<List<LineTargetVO>> getDataArray(@RequestBody List<String> dataSetList);
|
||||
|
||||
@PostMapping("/getDataArrayById")
|
||||
HttpResult<List<CsDataArray>> getDataArrayById(@RequestParam("pid") String pid, @RequestParam("name") String name);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.DataSetFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csDataSet", fallbackFactory = DataSetFeignClientFallbackFactory.class,contextId = "csDataSet")
|
||||
|
||||
public interface DataSetFeignClient {
|
||||
|
||||
@PostMapping("/getSetByModelId")
|
||||
HttpResult<List<CsDataSet>> getSetByModelId(@RequestParam("modelId") String modelId);
|
||||
|
||||
@PostMapping("/getDataSet")
|
||||
HttpResult<List<LineTargetVO>> getDataSet(@RequestParam("modelId") String modelId);
|
||||
|
||||
}
|
||||
@@ -28,4 +28,8 @@ public interface DevModelFeignClient {
|
||||
|
||||
@PostMapping("/findModel")
|
||||
HttpResult<CsDevModelPO> findModel(@RequestParam("devType") String devType, @RequestParam("version") String version, @RequestParam("time") String time);
|
||||
|
||||
@PostMapping("/getModelById")
|
||||
HttpResult<CsDevModelPO> getModelById(@RequestParam("id") String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.DevModelRelationFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelRelationPO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/devmodelRelation", fallbackFactory = DevModelRelationFeignClientFallbackFactory.class,contextId = "devmodelRelation")
|
||||
public interface DevModelRelationFeignClient {
|
||||
|
||||
@PostMapping("/getModelByDevId")
|
||||
HttpResult<CsDevModelRelationPO> getModelByDevId(@RequestParam("devId") String devId);
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.csdevice.api.CsDictFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsDictDTO;
|
||||
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.csdevice.api.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -14,20 +14,21 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsDictFeignClientFallbackFactory implements FallbackFactory<CsDictFeignClient> {
|
||||
public class CsLedgerFeignClientFallbackFactory implements FallbackFactory<CsLedgerFeignClient> {
|
||||
@Override
|
||||
public CsDictFeignClient create(Throwable cause) {
|
||||
public CsLedgerFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsDictFeignClient() {
|
||||
return new CsLedgerFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<CsDictDTO> getOwnAndFatherData(String name) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取指标自身和父级信息",cause.toString());
|
||||
public HttpResult<String> findDevByLineId(String lineId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据监测点获取装置失败",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
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.csdevice.api.DataArrayFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/10 20:09
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataArrayFeignClientFallbackFactory implements FallbackFactory<DataArrayFeignClient> {
|
||||
@Override
|
||||
public DataArrayFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DataArrayFeignClient() {
|
||||
@Override
|
||||
public HttpResult<List<CsDataArray>> getArrayBySet(List<CsDataSet> setList) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据数据集获取详细数据失败",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<LineTargetVO>> getDataArray(List<String> dataSetList) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取详细数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsDataArray>> getDataArrayById(String pid, String name) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据数据集id和名称获取详细数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
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.csdevice.api.DataSetFeignClient;
|
||||
import com.njcn.csdevice.api.DevModelFeignClient;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelQueryListParm;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsDevModelPageVO;
|
||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/10 20:09
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataSetFeignClientFallbackFactory implements FallbackFactory<DataSetFeignClient> {
|
||||
@Override
|
||||
public DataSetFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DataSetFeignClient() {
|
||||
@Override
|
||||
public HttpResult<List<CsDataSet>> getSetByModelId(String modelId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据模板id获取数据集",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<LineTargetVO>> getDataSet(String modelId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取数据集",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.njcn.csdevice.pojo.vo.CsDevModelPageVO;
|
||||
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.csdevice.utils.CsDeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -28,7 +29,7 @@ public class DevModelFeignClientFallbackFactory implements FallbackFactory<DevMo
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
// exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DevModelFeignClient() {
|
||||
@@ -50,6 +51,12 @@ public class DevModelFeignClientFallbackFactory implements FallbackFactory<DevMo
|
||||
log.error("{}异常,降级处理,异常为:{}","根据条件查询模板",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<CsDevModelPO> getModelById(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据id查询模板失败",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
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.csdevice.api.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.api.DevModelRelationFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelRelationPO;
|
||||
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DevModelRelationFeignClientFallbackFactory implements FallbackFactory<DevModelRelationFeignClient> {
|
||||
@Override
|
||||
public DevModelRelationFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new DevModelRelationFeignClient() {
|
||||
@Override
|
||||
public HttpResult<CsDevModelRelationPO> getModelByDevId(String devId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据装置获取模板",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public enum AlgorithmResponseEnum {
|
||||
/**
|
||||
* A00500 ~ A01550 用于终端模块的枚举
|
||||
*/
|
||||
CS_DEVICE_COMMON_ERROR("A00500","治理终端模块异常"),
|
||||
PROJECT_COMMON_ERROR("A00500","同一用户下项目名不能相同"),
|
||||
DICT_DATA_ERROR("A00501","暂无此字典表类型"),
|
||||
NDID_ERROR("A00502","存在相同的ndid"),
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.csdevice.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/6/1 16:57
|
||||
*/
|
||||
@Data
|
||||
public class DataArrayDTO implements Serializable {
|
||||
|
||||
private String dataSetId;
|
||||
|
||||
private String dataSetName;
|
||||
|
||||
private String dataArrayName;
|
||||
|
||||
private String dataArrayShowName;
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -15,8 +17,7 @@ import lombok.Setter;
|
||||
* @author xuyang
|
||||
* @since 2023-05-31
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
@TableName("cs_data_array")
|
||||
public class CsDataArray extends BaseEntity {
|
||||
|
||||
|
||||
@@ -26,9 +26,11 @@ public class CsDevModelRelationPO extends BaseEntity {
|
||||
@TableId(value = "id",type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value="装置id")
|
||||
@TableField(value = "dev_id")
|
||||
private String devId;
|
||||
|
||||
@ApiModelProperty(value="装置模板id")
|
||||
@TableField(value = "model_id")
|
||||
private String modelId;
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/6/1 10:13
|
||||
*/
|
||||
@Data
|
||||
public class LineTargetVO {
|
||||
|
||||
@ApiModelProperty("指标id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("父id")
|
||||
private String pid;
|
||||
|
||||
@ApiModelProperty("指标名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("显示名称")
|
||||
private String anotherName;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("子集")
|
||||
private List<LineTargetVO> children = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.csdevice.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.csdevice.enums.AlgorithmResponseEnum;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年05月26日 17:17
|
||||
*/
|
||||
public class CsDeviceEnumUtil {
|
||||
|
||||
/**
|
||||
* 获取UserResponseEnum实例
|
||||
*/
|
||||
public static AlgorithmResponseEnum getResponseEnumByMessage(@NotNull Object value) {
|
||||
AlgorithmResponseEnum algorithmResponseEnum;
|
||||
try {
|
||||
String message = value.toString();
|
||||
if(message.indexOf(StrUtil.C_COMMA)>0){
|
||||
value = message.substring(message.indexOf(StrUtil.C_COMMA)+1);
|
||||
}
|
||||
algorithmResponseEnum = EnumUtils.valueOf(AlgorithmResponseEnum.class, value, AlgorithmResponseEnum.class.getMethod(BusinessException.GET_MESSAGE_METHOD));
|
||||
return Objects.isNull(algorithmResponseEnum) ? AlgorithmResponseEnum.CS_DEVICE_COMMON_ERROR : algorithmResponseEnum;
|
||||
} 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.CS_DEVICE_RESPONSE_ENUM) {
|
||||
return getResponseEnumByMessage(result.getMessage());
|
||||
}
|
||||
return commonResponseEnum;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user