技术监督管理调整
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.njcn.process.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.process.api.fallback.SupvStatisticReportMFallbackFactory;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 过程监督月报统计
|
||||
* @author cdf
|
||||
* @date 2023/4/13
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.PROCESS,path = "/supv/report",fallbackFactory = SupvStatisticReportMFallbackFactory.class)
|
||||
public interface SupvStatisticReportMFeignClient {
|
||||
|
||||
@PostMapping("/statisticReport")
|
||||
HttpResult<Boolean> statisticReport(@RequestParam("timeId") String timeId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.process.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.process.api.SupvStatisticReportMFeignClient;
|
||||
import com.njcn.process.utils.ProcessEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/4/13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SupvStatisticReportMFallbackFactory implements FallbackFactory<SupvStatisticReportMFeignClient> {
|
||||
|
||||
@Override
|
||||
public SupvStatisticReportMFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = ProcessEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SupvStatisticReportMFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> statisticReport(String timeId) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "技术监督月报统计", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user