dingxin 6 anos atrás
pai
commit
f09294b8b7

+ 40
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/feign/IHKServer.java Ver arquivo

@@ -175,5 +175,45 @@ public interface IHKServer {
175 175
     @PostMapping(value = "/updateFace", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
176 176
     String updateFace(@RequestPart MultipartFile faceImg, @RequestParam("jsonString") String jsonString);
177 177
 
178
+    /**
179
+     * 访客邀请
180
+     *
181
+     *{
182
+     * 	"type":"厂家",
183
+     * 	"temporaryRegister": {
184
+     *          "visitorName": "访客人姓名",
185
+     *           "visitorName": 访客姓名
186
+     *            "phoneNo": 联系电话
187
+     *            "personNum": 来访人数
188
+     *           "startTime": 来访时间
189
+     *           "endTime": 离开时间
190
+     *            "personId": 被访人ID
191
+     *       }
192
+     * }
193
+     *
194
+     * @param jsonString
195
+     * @return
196
+     */
197
+    @PostMapping(value = "/temporaryRegister", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
198
+    String temporaryRegister(@RequestBody String jsonString);
178 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);
179 219
 }

+ 34
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/feign/entity/SyncControl.java Ver arquivo

@@ -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
+}

+ 38
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/feign/entity/TemporaryRegister.java Ver arquivo

@@ -0,0 +1,38 @@
1
+package com.community.huiju.feign.entity;
2
+
3
+import lombok.Data;
4
+
5
+@Data
6
+public class TemporaryRegister {
7
+
8
+
9
+    /**
10
+     * type : 厂家
11
+     * temporaryRegister : {"visitorName":"访客姓名","phoneNo":"联系电话","personNum":"来访人数","startTime":"来访时间","endTime":"离开时间","personId":"被访人ID"}
12
+     */
13
+
14
+    private String type;
15
+    private TemporaryRegisterBean temporaryRegister;
16
+
17
+    @Data
18
+    public static class TemporaryRegisterBean {
19
+        /**
20
+         * visitorName : 访客姓名
21
+         * phoneNo : 联系电话
22
+         * personNum : 来访人数
23
+         * startTime : 来访时间
24
+         * endTime : 离开时间
25
+         * personId : 被访人ID
26
+         */
27
+
28
+        private String visitorName;
29
+        private String phoneNo;
30
+        private Integer personNum;
31
+        private Long startTime;
32
+        private Long endTime;
33
+        private Integer personId;
34
+        private String secret;
35
+        private String appkey;
36
+        private String openapi_ip_port_http;
37
+    }
38
+}

+ 10
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/feign/impl/HKServerFallbackImpl.java Ver arquivo

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

+ 22
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/IEquipmentService.java Ver arquivo

@@ -54,4 +54,26 @@ public interface IEquipmentService {
54 54
     String updateFace(MultipartFile faceImg, TpUnitHkSetting unitHkSetting, TpEquipmentTree tpEquipmentTree,
55 55
                       TaUserHk taUserHk, TaUserVerify userVerify, TaUser user, List<String> visualList,
56 56
                       String deviceUuids);
57
+
58
+    /**
59
+     * 访客邀请
60
+     * @param visitorName 姓名
61
+     * @param phoneNo 手机号
62
+     * @param personNum  人员数量
63
+     * @param startTime 访问开始时间
64
+     * @param endTime 访问结束时间
65
+     * @param personId 人员海康ID
66
+     * @param tpEquipmentTree
67
+     * @return
68
+     */
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
+
57 79
 }

+ 45
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/EquipmentServiceImpl.java Ver arquivo

@@ -4,11 +4,10 @@ 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.UpdateFace;
7
+import com.community.huiju.feign.entity.*;
10 8
 import com.community.huiju.model.*;
11 9
 import com.community.huiju.service.IEquipmentService;
10
+import com.sun.org.apache.regexp.internal.RE;
12 11
 import lombok.extern.slf4j.Slf4j;
13 12
 import org.apache.commons.collections.CollectionUtils;
14 13
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
18 17
 import java.util.Arrays;
19 18
 import java.util.HashMap;
20 19
 import java.util.List;
20
+import java.util.Map;
21 21
 
22 22
 @Slf4j
23 23
 @Service
@@ -204,4 +204,46 @@ public class EquipmentServiceImpl implements IEquipmentService {
204 204
         ResponseBean responseBean = getResponseBean(result);
205 205
         return JSONObject.toJSONString(responseBean.getData());
206 206
     }
207
+
208
+    @Override
209
+    public String temporaryRegister(String visitorName, String phoneNo, Integer personNum, Long startTime, Long endTime, Integer personId, TpEquipmentTree tpEquipmentTree) {
210
+
211
+        TemporaryRegister temporaryRegister = new TemporaryRegister();
212
+        temporaryRegister.setType(tpEquipmentTree.getFactory());
213
+        TemporaryRegister.TemporaryRegisterBean temporaryRegisterBean = new TemporaryRegister.TemporaryRegisterBean();
214
+        temporaryRegisterBean.setVisitorName(visitorName);
215
+        temporaryRegisterBean.setPhoneNo(phoneNo);
216
+        temporaryRegisterBean.setPersonNum(personNum);
217
+        temporaryRegisterBean.setStartTime(startTime);
218
+        temporaryRegisterBean.setEndTime(endTime);
219
+        temporaryRegisterBean.setPersonId(personId);
220
+        temporaryRegisterBean.setAppkey(tpEquipmentTree.getAppkey());
221
+        temporaryRegisterBean.setSecret(tpEquipmentTree.getSecret());
222
+        temporaryRegisterBean.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
223
+
224
+        temporaryRegister.setTemporaryRegister(temporaryRegisterBean);
225
+
226
+
227
+        String result = ihkServer.temporaryRegister(JSONObject.toJSONString(temporaryRegister));
228
+        ResponseBean responseBean = getResponseBean(result);
229
+        return JSONObject.toJSONString(responseBean.getData());
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
+    }
207 249
 }

+ 4
- 9
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/HKServiceImpl.java Ver arquivo

@@ -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
 

+ 5
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaVistorServiceImpl.java Ver arquivo

@@ -7,6 +7,7 @@ import com.community.commom.session.UserElement;
7 7
 import com.community.commom.hk.HKOpenApi;
8 8
 import com.community.huiju.dao.*;
9 9
 import com.community.huiju.model.*;
10
+import com.community.huiju.service.IEquipmentService;
10 11
 import com.community.huiju.service.IHKService;
11 12
 import com.community.huiju.service.TaVistorServiceI;
12 13
 import com.google.common.collect.Maps;
@@ -57,6 +58,8 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
57 58
     @Autowired
58 59
     private IHKService ihkService;
59 60
 
61
+    @Autowired
62
+    private IEquipmentService iEquipmentService;
60 63
 
61 64
     @Override
62 65
     @Transactional(rollbackFor = Exception.class)
@@ -156,9 +159,9 @@ public class TaVistorServiceImpl implements TaVistorServiceI {
156 159
 
157 160
         TaUserHk taUserHk = taUserHkMapper.selectByUserVerifyIdAndCommunityId(userElement.getUserVerifyId(), communityId);
158 161
 
159
-        String result = HKOpenApi.temporaryRegister(visitor.getVisitorName(),visitor.getVisitorTel(),
162
+        String result = iEquipmentService.temporaryRegister(visitor.getVisitorName(),visitor.getVisitorTel(),
160 163
                 Integer.valueOf(visitor.getVisitorNum()),visitor.getVisitorStartTime().getTime(),
161
-                visitor.getVisitorEndTime().getTime(),taUserHk.getHkUserId(), tpEquipmentTree.getOpUserUuid(), tpEquipmentTree.getAppkey(), tpEquipmentTree.getSecret(), tpEquipmentTree.getHttpServer());
164
+                visitor.getVisitorEndTime().getTime(),taUserHk.getHkUserId(), tpEquipmentTree);
162 165
 
163 166
         JSONObject resultJSON = JSONObject.parseObject(result);
164 167
         int errorCode = resultJSON.getInteger("errorCode");

+ 61
- 0
CODE/smart-community/hardware-server/src/main/java/com/community/huiju/controller/HardwareController.java Ver arquivo

@@ -241,4 +241,65 @@ public class HardwareController {
241 241
         return responseBean;
242 242
     }
243 243
 
244
+    @ApiImplicitParams({
245
+			@ApiImplicitParam(dataTypeClass = String.class, paramType = "body", name = "jsonString", value =
246
+					"{\n" +
247
+							"\t\"type\":\"厂家\",\n" +
248
+							"\t\"temporaryRegister\": {\n" +
249
+							"         \"visitorName\": \"访客人姓名\",\n" +
250
+							"          \"visitorName\": 访客姓名\n" +
251
+							"           \"phoneNo\": 联系电话\n" +
252
+							"           \"personNum\": 来访人数\n" +
253
+							"          \"startTime\": 来访时间\n" +
254
+							"          \"endTime\": 离开时间\n" +
255
+							"           \"personId\": 被访人ID\n" +
256
+							"      }\n" +
257
+							"}"
258
+			)
259
+	})
260
+    @ApiOperation(value = "访客邀请", notes = "访客邀请")
261
+	@PostMapping(value = "/temporaryRegister")
262
+    public ResponseBean temporaryRegister(@RequestBody String jsonString) {
263
+		ResponseBean responseBean = new ResponseBean();
264
+
265
+		JSONObject jsonObject = JSONObject.parseObject(jsonString);
266
+		String type = jsonObject.getString("type");
267
+		if ("hk".equals(type)) {
268
+			responseBean = hkHardwareService.temporaryRegister(jsonObject.getString("temporaryRegister"));
269
+		} else {
270
+			responseBean.addError("未找到服务商: " + type);
271
+		}
272
+
273
+		return responseBean;
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
+	}
244 305
 }

+ 1
- 1
CODE/smart-community/hardware-server/src/main/java/com/community/huiju/exception/ExceptionHandleAdice.java Ver arquivo

@@ -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
 

+ 17
- 0
CODE/smart-community/hardware-server/src/main/java/com/community/huiju/service/HkHardwareServiceI.java Ver arquivo

@@ -280,4 +280,21 @@ public interface HkHardwareServiceI {
280 280
     ResponseBean deletePerson(String jsonString);
281 281
 
282 282
 
283
+    /**
284
+     *
285
+     * {
286
+     *     "visitorName": "访客人姓名",
287
+     *     "visitorName": 访客姓名
288
+     *      "phoneNo": 联系电话
289
+     *      "personNum": 来访人数
290
+     *      "startTime": 来访时间
291
+     *      "endTime": 离开时间
292
+     *      "personId": 被访人ID
293
+     * }
294
+     *
295
+     * 访客邀请
296
+     * @param jsonString
297
+     * @return
298
+     */
299
+    ResponseBean temporaryRegister(String jsonString);
283 300
 }

+ 16
- 0
CODE/smart-community/hardware-server/src/main/java/com/community/huiju/service/impl/HkHardwareServiceImpl.java Ver arquivo

@@ -294,4 +294,20 @@ public class HkHardwareServiceImpl implements HkHardwareServiceI {
294 294
         return result;
295 295
     }
296 296
 
297
+    @Override
298
+    public ResponseBean temporaryRegister(String jsonString) {
299
+        ResponseBean responseBean = new ResponseBean();
300
+
301
+        JSONObject jsonObject = JSONObject.parseObject(jsonString);
302
+
303
+        String result = HKOpenApi.temporaryRegister(jsonObject.getString("visitorName"),jsonObject.getString("phoneNo"),
304
+                jsonObject.getInteger("personNum"),jsonObject.getLong("startTime"),
305
+                jsonObject.getLong("endTime"),jsonObject.getInteger("personId"), jsonObject.getString("opUserUuid"),
306
+                jsonObject.getString("appkey"), jsonObject.getString("secret"), jsonObject.getString("openapi_ip_port_http"));
307
+
308
+        checkResult(result);
309
+
310
+        responseBean.addSuccess(JSONObject.parseObject(result).getInnerMap());
311
+        return responseBean;
312
+    }
297 313
 }