|
@@ -1,9 +1,11 @@
|
1
|
1
|
package com.community.huiju.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.alibaba.fastjson.JSONObject;
|
|
4
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
5
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
5
|
6
|
import com.community.commom.ailiyun.AESDecode;
|
6
|
7
|
import com.community.commom.constant.Constant;
|
|
8
|
+import com.community.commom.hk.HKConstant;
|
7
|
9
|
import com.community.commom.hk.HKOpenApi;
|
8
|
10
|
import com.community.commom.session.UserElement;
|
9
|
11
|
import com.community.huiju.common.base.ResponseBean;
|
|
@@ -144,7 +146,7 @@ public class FaceServicelimpl extends ServiceImpl<TaFaceMapper, TaFace> impleme
|
144
|
146
|
face.setFaceImg(faceImg);
|
145
|
147
|
face.setUpdateUser(userId);
|
146
|
148
|
face.setUpdateDate(new Date());
|
147
|
|
- ResponseBean resps = checKout(faceImg, face, false, uploadFile, userId, userVerify.getCommunityId(), userVerify.getRoomNoId(), userVerify.getUnitId(), tpEquipmentTree.getAppkey(), tpEquipmentTree.getSecret(), tpEquipmentTree.getHttpServer());
|
|
149
|
+ ResponseBean resps = checKout(faceImg, face, false, uploadFile, userId, userVerify.getCommunityId(), userVerify.getRoomNoId(), userVerify.getUnitId(), tpEquipmentTree.getAppkey(), tpEquipmentTree.getSecret(), tpEquipmentTree.getHttpServer(), tpEquipmentTree.getOpUserUuid());
|
148
|
150
|
if (resps.getCode().equals("0")) {
|
149
|
151
|
resps.addSuccess(face);
|
150
|
152
|
} else {
|
|
@@ -168,7 +170,7 @@ public class FaceServicelimpl extends ServiceImpl<TaFaceMapper, TaFace> impleme
|
168
|
170
|
* @param openapi_ip_port_http 海康服务器地址
|
169
|
171
|
* @return
|
170
|
172
|
*/
|
171
|
|
- public ResponseBean checKout(String faceImg, TaFace taFace, boolean isA, MultipartFile uploadFile, Integer userId, Integer communityId, Integer roomNoId, Integer unitId, String appkey, String secret, String openapi_ip_port_http) {
|
|
173
|
+ public ResponseBean checKout(String faceImg, TaFace taFace, boolean isA, MultipartFile uploadFile, Integer userId, Integer communityId, Integer roomNoId, Integer unitId, String appkey, String secret, String openapi_ip_port_http,String opUserUuid) {
|
172
|
174
|
ResponseBean responseBean = new ResponseBean();
|
173
|
175
|
TaUser user = taUserMapper.selectById(userId);
|
174
|
176
|
if (user.getHkUserId() == null) {
|
|
@@ -184,7 +186,7 @@ public class FaceServicelimpl extends ServiceImpl<TaFaceMapper, TaFace> impleme
|
184
|
186
|
Integer faceNum = (Integer) jsonObject.get("face_num");
|
185
|
187
|
|
186
|
188
|
/*推送海康*/
|
187
|
|
- String data = HKOpenApi.HKpersonGroupId(uploadFile, user.getHkUserId(), user.getHkPersonNo(), user.getUserName(), user.getHkCardNo(), appkey, secret, openapi_ip_port_http);
|
|
189
|
+ String data = HKOpenApi.HKpersonGroupId(uploadFile, user.getHkUserId(), user.getHkPersonNo(), user.getUserName(), user.getHkCardNo(), appkey, secret, openapi_ip_port_http, opUserUuid);
|
188
|
190
|
/*boolean isA为true进行添加,为false进行修改*/
|
189
|
191
|
if (0 == type && 1 == faceNum) {
|
190
|
192
|
if (null == data) {
|
|
@@ -328,7 +330,7 @@ public class FaceServicelimpl extends ServiceImpl<TaFaceMapper, TaFace> impleme
|
328
|
330
|
if (null == face) {
|
329
|
331
|
boolean isA = true;
|
330
|
332
|
if (Constant.EFFECTIVE_STATUS.equals(taUser.getStatus())) {
|
331
|
|
- ResponseBean responseBean = checKout(faceImg, taFace, isA, uploadFile, userid, userVerify.getCommunityId(), userVerify.getRoomNoId(), userVerify.getUnitId(),tpEquipmentTree.getAppkey(), tpEquipmentTree.getSecret(), tpEquipmentTree.getHttpServer());
|
|
333
|
+ ResponseBean responseBean = checKout(faceImg, taFace, isA, uploadFile, userid, userVerify.getCommunityId(), userVerify.getRoomNoId(), userVerify.getUnitId(),tpEquipmentTree.getAppkey(), tpEquipmentTree.getSecret(), tpEquipmentTree.getHttpServer(), tpEquipmentTree.getOpUserUuid());
|
332
|
334
|
if (responseBean.getCode().equals("0")) {
|
333
|
335
|
responseBean.addSuccess("人脸录入成功");
|
334
|
336
|
} else {
|
|
@@ -351,69 +353,112 @@ public class FaceServicelimpl extends ServiceImpl<TaFaceMapper, TaFace> impleme
|
351
|
353
|
}
|
352
|
354
|
TaUser taUser = taUserMapper.selectById(taUserVerify.getUserId());
|
353
|
355
|
|
|
356
|
+ // 校验是否存在人脸
|
|
357
|
+ QueryWrapper<TaFace> faceQueryWrapper = new QueryWrapper<>();
|
|
358
|
+ faceQueryWrapper.eq("ta_user_verify_id", taUserVerify.getUserVerifyId());
|
|
359
|
+ TaFace taFace = taFaceMapper.selectOne(faceQueryWrapper);
|
|
360
|
+ if (null == taFace) {
|
|
361
|
+ responseBean.addError(ResponseErrorsMessages.NOT_USER_FACE.getCode(), ResponseErrorsMessages.NOT_USER_FACE.getMsg());
|
|
362
|
+ return responseBean;
|
|
363
|
+ }
|
|
364
|
+
|
|
365
|
+
|
354
|
366
|
// 设备树
|
355
|
367
|
TpEquipmentTree tpEquipmentTree = tpEquipmentTreeMapper.selectByCommunityId(taUserVerify.getCommunityId());
|
356
|
368
|
// 所有设备
|
357
|
369
|
List<TpEquipment> tpEquipments = tpEquipmentMapper.selectByCommunityIdAndUnitId(taUserVerify.getCommunityId(), taUserVerify.getUnitId(), 4);
|
358
|
|
- if (CollectionUtils.isEmpty(tpEquipments)) {
|
359
|
|
- responseBean.addError(ResponseErrorsMessages.NOT_EQUIPMENT.getCode(), ResponseErrorsMessages.NOT_EQUIPMENT.getMsg());
|
360
|
|
- return responseBean;
|
361
|
|
- }
|
362
|
|
- List<Map<String, Object>> equipmentUUID = getEquipmentUUID(tpEquipments);
|
363
|
|
- StringBuilder doorUuids = new StringBuilder();
|
364
|
|
- StringBuilder deviceUuids = new StringBuilder();
|
365
|
|
- equipmentUUID.forEach(e-> {
|
366
|
|
- doorUuids.append(e.get("doorUuid"));
|
367
|
|
- doorUuids.append(",");
|
368
|
|
- deviceUuids.append(e.get("deviceUuid"));
|
369
|
|
- deviceUuids.append(",");
|
370
|
|
- });
|
371
|
|
-
|
372
|
|
-
|
373
|
|
- // TODO 删除人脸,是否删除海康
|
374
|
|
- // 修改人脸(图片为null时。海康删除人脸)
|
|
370
|
+
|
|
371
|
+ // 门禁删除人脸
|
|
372
|
+ if (CollectionUtils.isNotEmpty(tpEquipments)) {
|
|
373
|
+ // responseBean.addError(ResponseErrorsMessages.NOT_EQUIPMENT.getCode(), ResponseErrorsMessages.NOT_EQUIPMENT.getMsg());
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+ List<Map<String, Object>> equipmentUUID = getEquipmentUUID(tpEquipments);
|
|
377
|
+ StringBuilder doorUuids = new StringBuilder();
|
|
378
|
+ StringBuilder deviceUuids = new StringBuilder();
|
|
379
|
+ equipmentUUID.forEach(e-> {
|
|
380
|
+ doorUuids.append(e.get("doorUuid"));
|
|
381
|
+ doorUuids.append(",");
|
|
382
|
+ deviceUuids.append(e.get("deviceUuid"));
|
|
383
|
+ deviceUuids.append(",");
|
|
384
|
+ });
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+ // TODO 删除人脸,是否删除海康
|
|
388
|
+ // 修改人脸(图片为null时。海康删除人脸)
|
375
|
389
|
// HKOpenApi.HKpersonGroupId(null, taUser.getHkUserId(), taUser.getHkPersonNo(), taUser.getUserName(), taUser.getHkCardNo(), tpEquipmentTree.getAppkey(), tpEquipmentTree.getSecret());
|
376
|
|
- // 删除 权限
|
377
|
|
- Map<String,Object> selectUserFaceMap = Maps.newHashMap();
|
378
|
|
- selectUserFaceMap.put("personIds", taUser.getHkUserId()+"");
|
379
|
|
- selectUserFaceMap.put("opUserUuid", tpEquipmentTree.getOpUserUuid());
|
380
|
|
- selectUserFaceMap.put("appkey", tpEquipmentTree.getAppkey());
|
381
|
|
- selectUserFaceMap.put("secret", tpEquipmentTree.getSecret());
|
382
|
|
- selectUserFaceMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
|
383
|
|
- // 查询人脸信息
|
384
|
|
- HKOpenApi.selectUserFace(selectUserFaceMap);
|
385
|
|
-
|
386
|
|
- Map<String,Object> deleteUserMap = Maps.newHashMap();
|
387
|
|
- deleteUserMap.put("personIds", taUser.getHkUserId()+"");
|
388
|
|
- deleteUserMap.put("opUserUuid", tpEquipmentTree.getOpUserUuid());
|
389
|
|
- deleteUserMap.put("doorUuids", doorUuids.substring(0, doorUuids.lastIndexOf(",")));
|
390
|
|
- deleteUserMap.put("appkey", tpEquipmentTree.getAppkey());
|
391
|
|
- deleteUserMap.put("secret", tpEquipmentTree.getSecret());
|
392
|
|
- deleteUserMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
|
393
|
|
- // 删除当前人脸设备信息
|
394
|
|
- String data= HKOpenApi.deleteUser(deleteUserMap);
|
395
|
|
- JSONObject object= JSONObject.parseObject(data);
|
396
|
|
-
|
397
|
|
- if (object.get("errorCode").equals(1)){
|
398
|
|
- String errorMessage= object.getString("errorMessage");
|
399
|
|
- log.info("删除人脸信息异常:{}", data);
|
400
|
|
- responseBean.addError(ResponseErrorsMessages.DELETE_FACE.getCode(), ResponseErrorsMessages.DELETE_FACE.getMsg());
|
401
|
|
- return responseBean;
|
|
390
|
+ // 删除 权限
|
|
391
|
+ Map<String,Object> selectUserFaceMap = Maps.newHashMap();
|
|
392
|
+ selectUserFaceMap.put("personIds", taUser.getHkUserId()+"");
|
|
393
|
+ selectUserFaceMap.put("opUserUuid", tpEquipmentTree.getOpUserUuid());
|
|
394
|
+ selectUserFaceMap.put("appkey", tpEquipmentTree.getAppkey());
|
|
395
|
+ selectUserFaceMap.put("secret", tpEquipmentTree.getSecret());
|
|
396
|
+ selectUserFaceMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
|
|
397
|
+ // 查询人脸信息
|
|
398
|
+ HKOpenApi.selectUserFace(selectUserFaceMap);
|
|
399
|
+
|
|
400
|
+ Map<String,Object> deleteUserMap = Maps.newHashMap();
|
|
401
|
+ deleteUserMap.put("personIds", taUser.getHkUserId()+"");
|
|
402
|
+ deleteUserMap.put("opUserUuid", tpEquipmentTree.getOpUserUuid());
|
|
403
|
+ deleteUserMap.put("doorUuids", doorUuids.substring(0, doorUuids.lastIndexOf(",")));
|
|
404
|
+ deleteUserMap.put("appkey", tpEquipmentTree.getAppkey());
|
|
405
|
+ deleteUserMap.put("secret", tpEquipmentTree.getSecret());
|
|
406
|
+ deleteUserMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
|
|
407
|
+ // 删除当前人脸设备信息
|
|
408
|
+ String data= HKOpenApi.deleteUser(deleteUserMap);
|
|
409
|
+ JSONObject object= JSONObject.parseObject(data);
|
|
410
|
+
|
|
411
|
+ if (object.get("errorCode").equals(1)){
|
|
412
|
+ String errorMessage= object.getString("errorMessage");
|
|
413
|
+ log.info("删除人脸信息异常:{}", data);
|
|
414
|
+ responseBean.addError(ResponseErrorsMessages.DELETE_FACE.getCode(), ResponseErrorsMessages.DELETE_FACE.getMsg());
|
|
415
|
+ return responseBean;
|
|
416
|
+ }
|
|
417
|
+ // 异动同步到设备
|
|
418
|
+ Map<String,Object> appointJurisdictionMap = Maps.newHashMap();
|
|
419
|
+ appointJurisdictionMap.put("appkey", tpEquipmentTree.getAppkey());
|
|
420
|
+ appointJurisdictionMap.put("secret", tpEquipmentTree.getSecret());
|
|
421
|
+ appointJurisdictionMap.put("opUserUuid", tpEquipmentTree.getOpUserUuid());
|
|
422
|
+ appointJurisdictionMap.put("personIds", taUser.getHkUserId()+"" );
|
|
423
|
+ appointJurisdictionMap.put("doorUuids", doorUuids.substring(0, doorUuids.lastIndexOf(",")));
|
|
424
|
+ appointJurisdictionMap.put("operateType",3);
|
|
425
|
+ appointJurisdictionMap.put("includeFinger",0);
|
|
426
|
+ appointJurisdictionMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
|
|
427
|
+
|
|
428
|
+ HKOpenApi.appointJurisdiction(appointJurisdictionMap);
|
|
429
|
+
|
|
430
|
+ }
|
|
431
|
+
|
|
432
|
+ // 门口机删除人脸
|
|
433
|
+ // 单元门口机
|
|
434
|
+ List<TpEquipment> visualEquipments = tpEquipmentMapper.selectByCommunityIdAndUnitId(taUserVerify.getCommunityId(), taUserVerify.getUnitId(), 3);
|
|
435
|
+ if (CollectionUtils.isNotEmpty(visualEquipments)) {
|
|
436
|
+ List<String> visualList = visualEquipments.stream()
|
|
437
|
+ .map(e -> tpConfigurationMapper.selectById(e.getUuidId()).getConfigurationValue())
|
|
438
|
+ .collect(Collectors.toList());
|
|
439
|
+
|
|
440
|
+ List<Integer> userIdList = new ArrayList<>();
|
|
441
|
+ userIdList.add(taUser.getHkUserId());
|
|
442
|
+
|
|
443
|
+ Map<String, Object> delOutDoorAuthMap = Maps.newHashMap();
|
|
444
|
+ delOutDoorAuthMap.put("appkey", tpEquipmentTree.getAppkey());
|
|
445
|
+ delOutDoorAuthMap.put("secret", tpEquipmentTree.getSecret());
|
|
446
|
+ delOutDoorAuthMap.put("opUserUuid", tpEquipmentTree.getOpUserUuid());
|
|
447
|
+ delOutDoorAuthMap.put("personIds", userIdList);
|
|
448
|
+ delOutDoorAuthMap.put("longNums", visualList);
|
|
449
|
+ delOutDoorAuthMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
|
|
450
|
+
|
|
451
|
+ //可视对讲时 指定人员权限删除
|
|
452
|
+ HKOpenApi.delOutDoorAuth(delOutDoorAuthMap);
|
|
453
|
+
|
|
454
|
+ // 可是对讲时, 删除人脸权限
|
|
455
|
+ HKOpenApi.visualIntercom(tpEquipmentTree.getOpUserUuid(), 2, userIdList, visualList, tpEquipmentTree.getAppkey(), tpEquipmentTree.getSecret(), tpEquipmentTree.getHttpServer());
|
|
456
|
+
|
402
|
457
|
}
|
403
|
458
|
|
|
459
|
+
|
|
460
|
+
|
404
|
461
|
taFaceMapper.deleteFace(userVerifyId);
|
405
|
|
- // 异动同步到设备
|
406
|
|
- Map<String,Object> appointJurisdictionMap = Maps.newHashMap();
|
407
|
|
- appointJurisdictionMap.put("appkey", tpEquipmentTree.getAppkey());
|
408
|
|
- appointJurisdictionMap.put("secret", tpEquipmentTree.getSecret());
|
409
|
|
- appointJurisdictionMap.put("opUserUuid", tpEquipmentTree.getOpUserUuid());
|
410
|
|
- appointJurisdictionMap.put("personIds", taUser.getHkUserId()+"" );
|
411
|
|
- appointJurisdictionMap.put("doorUuids", doorUuids.substring(0, doorUuids.lastIndexOf(",")));
|
412
|
|
- appointJurisdictionMap.put("operateType",3);
|
413
|
|
- appointJurisdictionMap.put("includeFinger",0);
|
414
|
|
- appointJurisdictionMap.put("openapi_ip_port_http", tpEquipmentTree.getHttpServer());
|
415
|
|
-
|
416
|
|
- HKOpenApi.appointJurisdiction(appointJurisdictionMap);
|
417
|
462
|
// HKOpenApi.selectUserSynchronization();
|
418
|
463
|
// ihkService.downloadAuthorityByDeviceUuids();
|
419
|
464
|
return responseBean;
|