wangmengmeng
2024-12-24 24432a361d5c6bd6f3d8c008693e9f1155d62517
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
package com.dji.sample.debug.service.impl;
 
import com.dji.sample.debug.model.param.*;
import com.dji.sample.debug.service.DebugService;
import com.dji.sdk.cloudapi.debug.*;
import com.dji.sdk.cloudapi.debug.api.AbstractDebugService;
import com.dji.sdk.common.HttpResultResponse;
import com.dji.sdk.common.SDKManager;
import com.dji.sdk.mqtt.services.ServicesReplyData;
import com.dji.sdk.mqtt.services.TopicServicesResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
/**
 * @author wmm
 * @version 0.1
 * @date 2024/5/8
 */
@Service
@Slf4j
public class DebugServiceImpl implements DebugService {
 
 
    @Autowired
    private AbstractDebugService abstractDebugService;
 
    @Autowired
    private ObjectMapper mapper;
 
    @Override
    public HttpResultResponse coverOpen(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.coverOpen(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The cover failed to open. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse coverClose(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.coverClose(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The cover failed to close. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse debugModeOpen(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.debugModeOpen(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The debug mode failed to open. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse debugModeClose(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.debugModeClose(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The debug mode failed to close. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse supplementLightOpen(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.supplementLightOpen(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The supplementLight failed to open. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse supplementLightClose(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.supplementLightClose(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The supplementLight failed to close. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse chargeOpen(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.chargeOpen(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The charge failed to open. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse chargeClose(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.chargeClose(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The charge failed to close. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse droneOpen(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.droneOpen(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The drone failed to open. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse droneClose(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.droneClose(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The drone failed to close. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse deviceFormat(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.deviceFormat(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The device failed to format. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse droneFormat(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.droneFormat(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The drone failed to format. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse deviceReboot(String sn) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.deviceReboot(SDKManager.getDeviceSDK(sn));
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The device failed to reboot. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse batteryMaintenanceSwitch(String sn, BatteryMaintenanceSwitchParam param) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.batteryMaintenanceSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, BatteryMaintenanceSwitchRequest.class));
 
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The battery maintenance failed to switch. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse airConditionerModeSwitch(String sn, AirConditionerModeSwitchParam param) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.airConditionerModeSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, AirConditionerModeSwitchRequest.class));
 
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The air conditioner mode failed to switch. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse alarmStateSwitch(String sn, AlarmStateSwitchParam param) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.alarmStateSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, AlarmStateSwitchRequest.class));
 
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The alarm state failed to switch. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse batteryStoreModeSwitch(String sn, BatteryStoreModeSwitchParam param) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.batteryStoreModeSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, BatteryStoreModeSwitchRequest.class));
 
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The battery store mode failed to switch. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse sdrWorkmodeSwitch(String sn, SdrWorkmodeSwitchParam param) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.sdrWorkmodeSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, SdrWorkmodeSwitchRequest.class));
 
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The sdr workmode failed to switch. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse esimActivate(String sn, EsimActivateParam param) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.esimActivate(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, EsimActivateRequest.class));
 
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The esim failed to activate. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse simSlotSwitch(String sn, SimSlotSwitchParam param) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.simSlotSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, SimSlotSwitchRequest.class));
 
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The sim slot failed to switch. " + reply.getResult());
    }
 
    @Override
    public HttpResultResponse esimOperatorSwitch(String sn, EsimOperatorSwitchParam param) {
 
        TopicServicesResponse<ServicesReplyData<RemoteDebugResponse>> response = abstractDebugService.esimOperatorSwitch(SDKManager.getDeviceSDK(sn),mapper.convertValue(param, EsimOperatorSwitchRequest.class));
 
        ServicesReplyData reply = response.getData();
        return reply.getResult().isSuccess() ?
                HttpResultResponse.success()
                : HttpResultResponse.error("The esim operator failed to switch. " + reply.getResult());
    }
}