Pu Zhibing
2025-01-23 792cbb986fb8c32f6bbc1638c4ae264372e7a28f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 com.ruoyi.order.api.model.TChargingOrderAccountingStrategy;
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;
import java.util.Set;
 
/**
 * 充电订单服务降级处理
 * 
 * @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, Set<Integer> siteIds) {
                return R.fail("获取给定天数每天的充电量统计数据失败:" + throwable.getMessage());
            }
 
            @Override
            public R<List<Double>> getDailyChargingDegree(Integer days, Set<Integer> siteIds) {
                return R.fail("获取给定天数每天的充电度数失败:" + throwable.getMessage());
            }
    
            @Override
            public R<List<TChargingOrderAccountingStrategy>> getChargingOrderAccountingStrategyByOrderId(Long chargingOrderId) {
                return R.fail("根据订单id查询充电明细失败:" + throwable.getMessage());
            }
        };
    }
}