//package com.njcn.prepare.harmonic.api.event.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.event.SpThroughFeignClient;
//import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
//import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
//import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
//import feign.hystrix.FallbackFactory;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//import java.util.List;
//
///**
// * 高低电压穿越熔断降级
// * @author guofeihu
// * @date 2024-08-22
// */
//@Slf4j
//@Component
//public class SpThroughFeignClientFallbackFactory implements FallbackFactory<SpThroughFeignClient> {
//
//    @Override
//    public SpThroughFeignClient 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 SpThroughFeignClient() {
//            @Override
//            public HttpResult<Boolean> record() {
//                log.error("{}异常，降级处理，异常为：{}", "高低电压穿越记录:", throwable.toString());
//                throw new BusinessException(finalExceptionEnum);
//            }
//
//            @Override
//            public HttpResult<SpThroughVO> getDataByEventIds(SpThroughParam spThroughParam) {
//                log.error("{}异常，降级处理，异常为：{}", "根据事件ID集合及能源站类型获取高低电压穿越次数:", throwable.toString());
//                throw new BusinessException(finalExceptionEnum);
//            }
//
//            @Override
//            public HttpResult<List<String>> formatEventIds(SpThroughParam spThroughParam) {
//                log.error("{}异常，降级处理，异常为：{}", "根据原有的事件集合进行过滤：", throwable.toString());
//                throw new BusinessException(finalExceptionEnum);
//            }
//        };
//    }
//}
