liusuyi
2026-06-01 a2e7e8ff9cfaa69b001d483710bddbda50d55c91
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
package com.ard.work.api.factory;
 
import com.ard.common.core.domain.R;
import com.ard.work.api.RemoteSDKService;
import com.ard.work.api.domian.CameraCmd;
import com.ard.work.api.domian.PtzDto;
import com.ard.work.api.domian.VideoCompressionCfg;
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.RequestBody;
 
/**
 * SDK服务降级处理
 *
 * @author ard
 */
@Component
public class RemoteSDKFallbackFactory implements FallbackFactory<RemoteSDKService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteSDKFallbackFactory.class);
 
    @Override
    public RemoteSDKService create(Throwable throwable) {
        log.error("SDK服务调用失败:{}", throwable.getMessage());
        return new RemoteSDKService() {
            @Override
            public R<VideoCompressionCfg> getVideoCompressionCfg(CameraCmd cameraCmd) {
                return R.fail("获取视频压缩参数失败:" + throwable.getMessage());
            }
 
            @Override
            public R<Boolean> guideTargetPosition(CameraCmd cameraCmd) {
                return R.fail("引导目标位置失败:" + throwable.getMessage());
            }
 
            @Override
            public R<String> picCutCateRpc(CameraCmd cameraCmd, String bucketName, String objectName, String source) {
                return R.fail("抓图失败:" + throwable.getMessage());
            }
 
            @Override
            public R<Boolean> recordStartRpc(@RequestBody CameraCmd cameraCmd, String source) {
                return R.fail("开始录像失败:" + throwable.getMessage());
            }
 
            @Override
            public R<String> recordStopRpc(@RequestBody CameraCmd cameraCmd, String source) {
                return R.fail("停止录像失败:" + throwable.getMessage());
            }
 
            @Override
            public R<?> picCutCate(CameraCmd cameraCmd) {
                return R.fail("抓图失败:" + throwable.getMessage());
            }
 
            @Override
            public R<?> recordStart(CameraCmd cameraCmd) {
                return R.fail("开始录像失败:" + throwable.getMessage());
            }
 
            @Override
            public R<?> recordStop(CameraCmd cameraCmd) {
                return R.fail("停止录像失败:" + throwable.getMessage());
            }
 
            @Override
            public R<Boolean> setPTZRpc(CameraCmd cmd, String source) {
                return R.fail("设置PTZ失败:" + throwable.getMessage());
            }
 
            @Override
            public R<PtzDto> getPTZRpc(CameraCmd cmd, String source) {
                return R.fail("获取PTZ失败:" + throwable.getMessage());
            }
        };
    }
}