算法模块删除不必要的代码,有备份,如果存疑就联系我
This commit is contained in:
@@ -3,6 +3,7 @@ package com.njcn.prepare.harmonic.api.newalgorithm;
|
|||||||
|
|
||||||
import com.njcn.common.pojo.constant.ServerInfo;
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.prepare.harmonic.api.newalgorithm.fallback.PmsStatisticsSpecialMonitorFeignClientFallbackFactory;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -11,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
@org.springframework.cloud.openfeign.FeignClient(
|
@org.springframework.cloud.openfeign.FeignClient(
|
||||||
value = ServerInfo.PREPARE_BOOT,//对应模块名
|
value = ServerInfo.PREPARE_BOOT,//对应模块名
|
||||||
path = "/pmsStatisticsSpecialMonitor",//对应controller请求类
|
path = "/pmsStatisticsSpecialMonitor",//对应controller请求类
|
||||||
fallbackFactory = RStatAbnormalFeignClientFallbackFactory.class//服务降级处理类
|
fallbackFactory = PmsStatisticsSpecialMonitorFeignClientFallbackFactory.class//服务降级处理类
|
||||||
)
|
)
|
||||||
public interface PmsStatisticsSpecialMonitorFeignClient {
|
public interface PmsStatisticsSpecialMonitorFeignClient {
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class rMpInfluenceFallbackFactory implements FallbackFactory<RMpInfluenceFeignClient> {
|
public class RMpInfluenceFallbackFactory implements FallbackFactory<RMpInfluenceFeignClient> {
|
||||||
@Override
|
@Override
|
||||||
public RMpInfluenceFeignClient create(Throwable throwable) {
|
public RMpInfluenceFeignClient create(Throwable throwable) {
|
||||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
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.prepare.harmonic.api.newalgorithm.RMpInfluenceFeignClient;
|
|
||||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
|
||||||
import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
|
|
||||||
import feign.hystrix.FallbackFactory;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class RMpInfluenceFallbackFactory implements FallbackFactory<RMpInfluenceFeignClient> {
|
|
||||||
@Override
|
|
||||||
public RMpInfluenceFeignClient create(Throwable throwable) {
|
|
||||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
|
||||||
if (throwable.getCause() instanceof BusinessException) {
|
|
||||||
BusinessException businessException = (BusinessException)throwable.getCause();
|
|
||||||
exceptionEnum = PrepareEnumUtil.getExceptionEnum(businessException.getResult());
|
|
||||||
}
|
|
||||||
|
|
||||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
|
||||||
return new RMpInfluenceFeignClient() {
|
|
||||||
@Override
|
|
||||||
public HttpResult<Boolean> rMpInfluenceMHandler(LineParam jobParam) {
|
|
||||||
log.error("{}异常,降级处理,异常为:{}", "影响特性: ", throwable.toString());
|
|
||||||
throw new BusinessException(finalExceptionEnum);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user