魏熙美 пре 6 година
родитељ
комит
fdad85fcfd

+ 20
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/feign/IHKServer.java Прегледај датотеку

@@ -196,4 +196,24 @@ public interface IHKServer {
196 196
      */
197 197
     @PostMapping(value = "/temporaryRegister", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
198 198
     String temporaryRegister(@RequestBody String jsonString);
199
+
200
+
201
+    /**
202
+     * 远程开门
203
+     * {
204
+     *             "type:"厂家",
205
+     *             "sync": {
206
+     *                     "longNums": "门口机编号",
207
+     *                     "openapi_ip_port_http": 服务器地址",
208
+     *                      "secret": 服务器secret",
209
+     *                      "appkey": 服务器appkey",
210
+     *                    "opUserUuid": 服务器操作人员UUID"
211
+     *             }
212
+     *  }
213
+     *
214
+     * @param jsonString
215
+     * @return
216
+     */
217
+    @PostMapping(value = "/syncControl", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
218
+    String syncControl(@RequestBody String jsonString);
199 219
 }

+ 34
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/feign/entity/SyncControl.java Прегледај датотеку

@@ -0,0 +1,34 @@
1
+package com.community.huiju.feign.entity;
2
+
3
+import lombok.Data;
4
+
5
+@Data
6
+public class SyncControl {
7
+
8
+
9
+    /**
10
+     * type : 厂家
11
+     * sync : {"longNums":"门口机编号","openapi_ip_port_http":"服务器地址","secret":"服务器secret","appkey":"服务器appkey","opUserUuid":"服务器操作人员UUID"}
12
+     */
13
+
14
+    private String type;
15
+    private SyncBean sync;
16
+
17
+    @Data
18
+    public static class SyncBean {
19
+        /**
20
+         * longNums : 门口机编号
21
+         * openapi_ip_port_http : 服务器地址
22
+         * secret : 服务器secret
23
+         * appkey : 服务器appkey
24
+         * opUserUuid : 服务器操作人员UUID
25
+         */
26
+
27
+        private String longNums;
28
+        private String openapi_ip_port_http;
29
+        private String secret;
30
+        private String appkey;
31
+        private String opUserUuid;
32
+
33
+    }
34
+}

+ 5
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/feign/impl/HKServerFallbackImpl.java Прегледај датотеку

@@ -35,6 +35,11 @@ public class HKServerFallbackImpl implements IHKServer {
35 35
         return back();
36 36
     }
37 37
 
38
+    @Override
39
+    public String syncControl(String jsonString) {
40
+        return back();
41
+    }
42
+
38 43
     private String back() {
39 44
         log.error("hardware-server 远端服务请求失败!");
40 45
         ResponseBean responseBean = new ResponseBean();

+ 9
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/IEquipmentService.java Прегледај датотеку

@@ -67,4 +67,13 @@ public interface IEquipmentService {
67 67
      * @return
68 68
      */
69 69
     String temporaryRegister(String visitorName, String phoneNo,Integer personNum,Long startTime,Long endTime,Integer personId, TpEquipmentTree tpEquipmentTree);
70
+
71
+    /**
72
+     * 异步反控开门
73
+     *
74
+     * @param longNums 设备UUID
75
+     * @return
76
+     */
77
+    String syncControl(String longNums, String factory, TpEquipmentTree tpEquipmentTree);
78
+
70 79
 }

+ 19
- 4
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/EquipmentServiceImpl.java Прегледај датотеку

@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
4 4
 import com.community.commom.mode.ResponseBean;
5 5
 import com.community.huiju.exception.WisdomException;
6 6
 import com.community.huiju.feign.IHKServer;
7
-import com.community.huiju.feign.entity.AddFace;
8
-import com.community.huiju.feign.entity.PushPerson;
9
-import com.community.huiju.feign.entity.TemporaryRegister;
10
-import com.community.huiju.feign.entity.UpdateFace;
7
+import com.community.huiju.feign.entity.*;
11 8
 import com.community.huiju.model.*;
12 9
 import com.community.huiju.service.IEquipmentService;
13 10
 import com.sun.org.apache.regexp.internal.RE;
@@ -231,4 +228,22 @@ public class EquipmentServiceImpl implements IEquipmentService {
231 228
         ResponseBean responseBean = getResponseBean(result);
232 229
         return JSONObject.toJSONString(responseBean.getData());
233 230
     }
231
+
232
+    @Override
233
+    public String syncControl(String longNums, String factory,TpEquipmentTree tpEquipmentTree) {
234
+        SyncControl syncControl = new SyncControl();
235
+        SyncControl.SyncBean syncBean = new SyncControl.SyncBean();
236
+        syncBean.setLongNums(longNums);
237
+        syncBean.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
238
+        syncBean.setSecret(tpEquipmentTree.getSecret());
239
+        syncBean.setAppkey(tpEquipmentTree.getAppkey());
240
+        syncBean.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
241
+
242
+        syncControl.setSync(syncBean);
243
+        syncControl.setType(factory);
244
+
245
+        String result = ihkServer.syncControl(JSONObject.toJSONString(syncControl));
246
+        ResponseBean responseBean = getResponseBean(result);
247
+        return JSONObject.toJSONString(responseBean.getData());
248
+    }
234 249
 }

+ 4
- 9
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/HKServiceImpl.java Прегледај датотеку

@@ -10,6 +10,7 @@ import com.community.commom.hk.HKOpenApi;
10 10
 import com.community.huiju.dao.*;
11 11
 import com.community.huiju.exception.WisdomException;
12 12
 import com.community.huiju.feign.entity.PushPerson;
13
+import com.community.huiju.feign.entity.SyncControl;
13 14
 import com.community.huiju.model.*;
14 15
 import com.community.huiju.service.IEquipmentService;
15 16
 import com.community.huiju.service.IHKService;
@@ -487,16 +488,10 @@ public class HKServiceImpl implements IHKService {
487 488
          // uuid_id 是可是对讲设备
488 489
          TpConfiguration tpConfiguration = tpConfigurationMapper.selectByPrimaryKey(tpEquipment.getUuidId());
489 490
 
490
-        // 查询设备编号
491
+        // 远程开门
491 492
 
492
-        Map<String,Object> parMap = com.beust.jcommander.internal.Maps.newHashMap();
493
-        parMap.put("longNums", tpConfiguration.getConfigurationValue());
494
-        parMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
495
-        parMap.put("secret", tpEquipmentTree.getSecret());
496
-        parMap.put("appkey", tpEquipmentTree.getAppkey());
497
-        parMap.put("opUserUuid", tpEquipmentTree.getOpUserUuid());
498
-        String data = HKOpenApi.syncControl(parMap);
499
-        JSONObject jsonObject = JSONObject.parseObject(data);
493
+        String result = iEquipmentService.syncControl(tpConfiguration.getConfigurationValue(), tpEquipmentTree.getFactory(), tpEquipmentTree);
494
+        JSONObject jsonObject = JSONObject.parseObject(result);
500 495
         int errorCode = jsonObject.getInteger("errorCode");
501 496
         if (errorCode == 0) {
502 497
 

+ 30
- 0
CODE/smart-community/hardware-server/src/main/java/com/community/huiju/controller/HardwareController.java Прегледај датотеку

@@ -272,4 +272,34 @@ public class HardwareController {
272 272
 
273 273
 		return responseBean;
274 274
 	}
275
+
276
+	@ApiImplicitParams({
277
+			@ApiImplicitParam(dataTypeClass = String.class, paramType = "body", name = "jsonString", value =
278
+					"{\n" +
279
+							"\t\"type\":\"厂家\",\n" +
280
+							"\t\"sync\": {\n" +
281
+							"         \"longNums\": \"门口机编号\",\n" +
282
+							"          \"openapi_ip_port_http\": 服务器地址\n" +
283
+							"           \"secret\": 服务器secret\n" +
284
+							"           \"appkey\": 服务器appkey\n" +
285
+							"          \"opUserUuid\": 服务器操作人员UUID\n" +
286
+							"      }\n" +
287
+							"}"
288
+			)
289
+	})
290
+	@ApiOperation(value = "远程开门", notes = "远程开门")
291
+	@PostMapping(value = "/syncControl")
292
+	public ResponseBean syncControl(@RequestBody String jsonString) {
293
+		ResponseBean responseBean = new ResponseBean();
294
+
295
+		JSONObject jsonObject = JSONObject.parseObject(jsonString);
296
+		String type = jsonObject.getString("type");
297
+		if ("hk".equals(type)) {
298
+			responseBean = hkHardwareService.syncControl(jsonObject.getString("sync"));
299
+		} else {
300
+			responseBean.addError("未找到服务商: " + type);
301
+		}
302
+
303
+		return responseBean;
304
+	}
275 305
 }

+ 1
- 1
CODE/smart-community/hardware-server/src/main/java/com/community/huiju/exception/ExceptionHandleAdice.java Прегледај датотеку

@@ -26,7 +26,7 @@ public class ExceptionHandleAdice {
26 26
     public ResponseBean handleException(Exception e){
27 27
         log.error(e.getMessage(),e);
28 28
         ResponseBean response = new ResponseBean();
29
-        response.addError(Constant.REQUEST_ERROR,"设备还未联网,系统维护中");
29
+        response.addError("1","设备还未联网,系统维护中","",null);
30 30
         return response;
31 31
     }
32 32