新增预警/告警技术监督数据
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.njcn.prepare.harmonic.api.line;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.prepare.harmonic.api.line.fallback.CoustomReportFeignClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(
|
||||
value = ServerInfo.PREPARE_BOOT,//对应模块名
|
||||
path = "/thsSupervise",//对应controller请求类
|
||||
fallbackFactory = CoustomReportFeignClientFallbackFactory.class//服务降级处理类
|
||||
)
|
||||
public interface ThsSuperviseClient {
|
||||
/**
|
||||
* 预警/告警事务的生成
|
||||
*
|
||||
* @param initType 生成方式 0 自动;1 手动
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/initSupervise")
|
||||
HttpResult<Boolean> initSupervise(@RequestParam("initType") Integer initType);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.prepare.harmonic.api.line.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.pq.utils.DeviceEnumUtil;
|
||||
import com.njcn.prepare.harmonic.api.line.ThsSuperviseClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ThsSuperviseClientFallbackFactory implements FallbackFactory<ThsSuperviseClient> {
|
||||
@Override
|
||||
public ThsSuperviseClient 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 ThsSuperviseClient() {
|
||||
@Override
|
||||
public HttpResult<Boolean> initSupervise(@RequestParam("initType") Integer initType) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "预警/告警事务的生成: ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user