1.灿能云代码调整

This commit is contained in:
wr
2024-01-04 16:12:31 +08:00
parent 6a32c44fb6
commit 16e4520ce1
10 changed files with 165 additions and 9 deletions

View File

@@ -59,8 +59,14 @@ public interface EventDetailFeignClient {
HttpResult<List<RmpEventDetailPO>> getEventDetailByIdsList(@RequestBody List<String> ids);
/**
* 根据监测点id集合获取暂降列表
* 根据监测点id集合,统计时间范围内暂态超标次数
*/
@PostMapping("/getEventDetailByLineCount")
HttpResult<Integer> getEventDetailByLineCount(@RequestBody EventCountParam param);
/**
* 根据监测点id集合,统计时间范围内特征增幅小于0.9的暂态信息
*/
@PostMapping("/getAppEventDetailLtAmplitude")
HttpResult<List<RmpEventDetailPO>> getAppEventDetailLtAmplitude(@RequestBody EventCountParam param);
}

View File

@@ -0,0 +1,30 @@
package com.njcn.event.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.event.api.fallback.ReportFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author wr
* @description
* @date 2024/1/3 10:02
*/
@FeignClient(value = ServerInfo.EVENT, path = "/report", fallbackFactory = ReportFeignClientFallbackFactory.class)
public interface ReportFeignClient {
/**
* 灿能云获取暂态报告
* @param businessParam
* @return
*/
@PostMapping("/appEventExport")
HttpResult<String> appEventExport(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam);
}

View File

@@ -66,7 +66,13 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory<Ev
@Override
public HttpResult<Integer> getEventDetailByLineCount(EventCountParam param) {
log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合获取暂降列表", throwable.toString());
log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合,统计时间范围内暂态超标次数", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<RmpEventDetailPO>> getAppEventDetailLtAmplitude(EventCountParam param) {
log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合,统计时间范围内特征增幅小于0.9的暂态信息", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}

View File

@@ -0,0 +1,40 @@
package com.njcn.event.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.pq.pojo.param.DeviceInfoParam;
import com.njcn.event.api.ReportFeignClient;
import com.njcn.event.utils.EventlEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author wr
* @description
* @date 2024/1/3 10:02
*/
@Slf4j
@Component
public class ReportFeignClientFallbackFactory implements FallbackFactory<ReportFeignClient> {
@Override
public ReportFeignClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = EventlEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new ReportFeignClient() {
@Override
public HttpResult<String> appEventExport(DeviceInfoParam.BusinessParam businessParam) {
log.error("{}异常,降级处理,异常为:{}", "暂态报告导出", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}