2
liusuyi
2026-05-12 9b5c9db9189493fbc6db48f55a7b7311b2a3253c
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
package com.ard.work.api.factory;
 
import com.ard.common.core.domain.R;
import com.ard.common.core.web.domain.AjaxResult;
import com.ard.work.api.RemoteCameraService;
import com.ard.work.api.domian.ArdCamera;
import com.ard.work.api.domian.CameraCmd;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
 
import java.util.List;
import java.util.TreeMap;
 
/**
 * 相机服务降级处理
 * 
 * @author ard
 */
@Component
public class RemoteCameraFallbackFactory implements FallbackFactory<RemoteCameraService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteCameraFallbackFactory.class);
 
    @Override
    public RemoteCameraService create(Throwable throwable)
    {
        log.error("相机服务调用失败:{}", throwable.getMessage());
        return new RemoteCameraService()
        {
            @Override
            public R<List<ArdCamera>> getAllCamera(String source) {
                return R.fail("获取全部相机失败:" + throwable.getMessage());
            }
            @Override
            public R<List<ArdCamera>> getAllCameraRpc(ArdCamera ardCamera,String source) {
                return R.fail("获取全部相机失败:" + throwable.getMessage());
            }
            @Override
            public R<ArdCamera> getCameraInfoRpc(String id,String source) {
                return R.fail("获取相机详情失败:" + throwable.getMessage());
            }
            @Override
            public R<TreeMap<Double, ArdCamera>> getNearbyCamerasRpc(CameraCmd cmd, String source) {
                return R.fail("获取附近的相机:" + throwable.getMessage());
            }
            @Override
            public R<AjaxResult> setPTZLockRpc( CameraCmd cmd, String source) {
                return R.fail("设置锁定相机:" + throwable.getMessage());
            }
            @Override
            public R<ArdCamera> getCameraByRadar(String radarId, String source) {
                return R.fail("获取雷达所在塔上的大光电:" + throwable.getMessage());
            }
 
            @Override
            public R<ArdCamera> getCameraByName(String name, String source) {
                return R.fail("通过名称获取相机:" + throwable.getMessage());
            }
 
            @Override
            public R<Boolean> updateCamera(ArdCamera camera, String source) {
                return R.fail("更新相机:" + throwable.getMessage());
            }
 
            @Override
            public R<?> updateCameraLocationAndYaw(String cameraId, Double longitude, Double latitude, Double altitude, Float baseYaw, String source) {
                return R.fail("更新坐标和基座偏航角失败:" + throwable.getMessage());
            }
        };
    }
}