New file |
| | |
| | | package com.ruoyi.order.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 充电订单服务降级处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class ChargingOrderAccountingStrategyFallbackFactory implements FallbackFactory<ChargingOrderAccountingStrategyClient> |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(ChargingOrderAccountingStrategyFallbackFactory.class); |
| | | |
| | | @Override |
| | | public ChargingOrderAccountingStrategyClient create(Throwable throwable) { |
| | | log.error("充电订单调用失败:{}", throwable.getMessage()); |
| | | return new ChargingOrderAccountingStrategyClient() { |
| | | |
| | | |
| | | @Override |
| | | public R<List<List<Map<String, Object>>>> getTotalElectricQuantity(Integer days) { |
| | | return R.fail("获取给定天数每天的充电量统计数据失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Double>> getDailyChargingDegree(Integer days) { |
| | | return R.fail("获取给定天数每天的充电度数失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |