修改监测点类别

This commit is contained in:
huangzj
2023-08-04 11:42:57 +08:00
parent 065dfe7d9c
commit 7ffa3f8c10
7 changed files with 132 additions and 34 deletions

View File

@@ -0,0 +1,22 @@
package com.njcn.prepare.harmonic.api.newalgorithm;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.newalgorithm.fallback.RStatHarmonicFeignClientFallbackFactory;
import com.njcn.prepare.harmonic.api.newalgorithm.fallback.RStatHarmonicOrgFeignClientFallbackFactory;
import com.njcn.prepare.harmonic.pojo.param.OrgParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(
value = ServerInfo.PREPARE_BOOT,//对应模块名
path = "/rstatharmonicorg",//对应controller请求类
fallbackFactory = RStatHarmonicOrgFeignClientFallbackFactory.class//服务降级处理类
)
public interface RStatHarmonicOrgFeignClient {
@PostMapping("/Handler")
HttpResult<String> handler(@RequestBody OrgParam orgParam);
}

View File

@@ -0,0 +1,34 @@
package com.njcn.prepare.harmonic.api.newalgorithm.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.prepare.harmonic.api.newalgorithm.RStatHarmonicFeignClient;
import com.njcn.prepare.harmonic.api.newalgorithm.RStatHarmonicOrgFeignClient;
import com.njcn.prepare.harmonic.pojo.param.OrgParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RStatHarmonicOrgFeignClientFallbackFactory implements FallbackFactory<RStatHarmonicOrgFeignClient> {
@Override
public RStatHarmonicOrgFeignClient 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 RStatHarmonicOrgFeignClient() {
@Override
public HttpResult<String> handler(OrgParam orgParam) {
log.error("{}异常,降级处理,异常为:{}", "单位监测点稳态指标统计: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}