新能源场站高低电压穿越业务新增根据ID查询基本信息方法
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.njcn.device.pq.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.api.fallback.NewStationClientFallbackFactory;
|
||||
import com.njcn.device.pq.pojo.po.NewStation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 新能源场站高低电压穿越Feign客户端
|
||||
* @author guofeihu
|
||||
* @date 2024-08-14
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE, path = "/newStation", fallbackFactory = NewStationClientFallbackFactory.class, contextId = "newStation")
|
||||
public interface NewStationClient {
|
||||
|
||||
/**
|
||||
* 根据ID获取新能源场站高低电压穿越表信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/selectById")
|
||||
HttpResult<NewStation> selectById(@RequestParam(name = "id") String id);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.device.pq.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.device.biz.utils.DeviceEnumUtil;
|
||||
import com.njcn.device.pq.api.NewStationClient;
|
||||
import com.njcn.device.pq.pojo.po.NewStation;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 新能源场站高低电压穿越管理熔断降级
|
||||
* @author guofeihu
|
||||
* @date 2024-08-14
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NewStationClientFallbackFactory implements FallbackFactory<NewStationClient> {
|
||||
@Override
|
||||
public NewStationClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new NewStationClient() {
|
||||
@Override
|
||||
public HttpResult<NewStation> selectById(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取终获取告警策略列表", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,4 +121,7 @@ public class LineDetailDataVO {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty(name = "新能源场站信息ID")
|
||||
private String newStationId;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user