Pu Zhibing
2025-03-19 cf32754f130955a617836cae7685c1a24979060c
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.ruoyi.chargingPile.api.factory;
 
import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode;
import com.ruoyi.chargingPile.api.vo.SiteNameVO;
import com.ruoyi.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * 充电桩服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class ChargingGunFallbackFactory implements FallbackFactory<ChargingGunClient>
{
    private static final Logger log = LoggerFactory.getLogger(ChargingGunFallbackFactory.class);
 
    @Override
    public ChargingGunClient create(Throwable throwable) {
        log.error("充电枪调用失败:{}", throwable.getMessage());
        return new ChargingGunClient() {
 
            @Override
            public R<List<TChargingGun>> getAllGun() {
                return R.fail("获取数据失败:" + throwable.getMessage());
            }
 
            @Override
            public R<List<TChargingPile>> getAllPile() {
                return R.fail("获取所有桩失败:" + throwable.getMessage());
            }
 
            @Override
            public R<String> getAllName(Integer id) {
                return R.fail("根据id获取充电枪完整名称失败:" + throwable.getMessage());
            }
    
            @Override
            public R<TChargingGun> getChargingGunById(Integer id) {
                return R.fail("根据id获取充电枪失败:" + throwable.getMessage());
            }
 
            @Override
            public R<SiteNameVO> getAllInfoById(Integer id) {
                return R.fail("通过枪id获取站点、桩、枪的名称失败:" + throwable.getMessage());
            }
 
            @Override
            public R<TChargingGun> getChargingGunByCode(GetChargingGunByCode code) {
                return R.fail("根据枪编号获取充电枪失败:" + throwable.getMessage());
            }
 
            @Override
            public R<String> updateChargingGunById(TChargingGun chargingGun) {
                return R.fail("编辑充电枪失败:" + throwable.getMessage());
            }
    
            @Override
            public R<List<TChargingGun>> getChargingGunByChargingPileId(Integer chargingPileId) {
                return R.fail("根据充电桩id获取枪失败:" + throwable.getMessage());
            }
    
            @Override
            public R<List<TChargingGun>> getChargingGunByChargingPileIds(List<Integer> chargingPileIds) {
                return R.fail("根据充电桩ids获取枪失败:" + throwable.getMessage());
            }
    
            @Override
            public R pushChargingGunStatus(Integer id, Integer status) {
                return R.fail("接口状态变化后推送给第三方失败:" + throwable.getMessage());
            }
 
            @Override
            public R<TChargingGun> getChargingGunByFullNumber(String fullNumber) {
                return R.fail("根据枪唯一码查询信息失败:" + throwable.getMessage());
            }
        };
    }
}