|
@@ -20,6 +20,7 @@ import com.community.huiju.dao.*;
|
20
|
20
|
import com.community.huiju.enums.UserVerifyEnum;
|
21
|
21
|
import com.community.huiju.exception.WisdomException;
|
22
|
22
|
import com.community.huiju.model.*;
|
|
23
|
+import com.community.huiju.service.IHKService;
|
23
|
24
|
import com.community.huiju.service.ITaUserService;
|
24
|
25
|
import com.community.huiju.service.ImageServiceI;
|
25
|
26
|
import com.community.huiju.vo.TaUserVO;
|
|
@@ -71,9 +72,6 @@ public class TaUserServiceImpl implements ITaUserService {
|
71
|
72
|
@Autowired
|
72
|
73
|
private TaUserMapper taUserMapper;
|
73
|
74
|
|
74
|
|
- @Autowired
|
75
|
|
- private TpBuildingOwnerInfoMapper tpBuildingOwnerInfoMapper;
|
76
|
|
-
|
77
|
75
|
@Autowired
|
78
|
76
|
private TaSysRoleMapper taSysRoleMapper;
|
79
|
77
|
|
|
@@ -105,6 +103,45 @@ public class TaUserServiceImpl implements ITaUserService {
|
105
|
103
|
@Autowired
|
106
|
104
|
private LoginCodePerproties loginCodePerproties;
|
107
|
105
|
|
|
106
|
+ @Autowired
|
|
107
|
+ private IHKService ihkService;
|
|
108
|
+
|
|
109
|
+ /**
|
|
110
|
+ * 期
|
|
111
|
+ */
|
|
112
|
+ @Autowired
|
|
113
|
+ private TpPhaseMapper tpPhaseMapper;
|
|
114
|
+
|
|
115
|
+ /**
|
|
116
|
+ * 单元
|
|
117
|
+ */
|
|
118
|
+ @Autowired
|
|
119
|
+ private TpUnitMapper tpUnitMapper;
|
|
120
|
+
|
|
121
|
+ /**
|
|
122
|
+ * 楼层
|
|
123
|
+ */
|
|
124
|
+ @Autowired
|
|
125
|
+ private TpLevelMapper tpLevelMapper;
|
|
126
|
+
|
|
127
|
+ /**
|
|
128
|
+ * 栋
|
|
129
|
+ */
|
|
130
|
+ @Autowired
|
|
131
|
+ private TpBuildingMapper tpBuildingMapper;
|
|
132
|
+
|
|
133
|
+ /**
|
|
134
|
+ * 楼栋资料库
|
|
135
|
+ */
|
|
136
|
+ @Autowired
|
|
137
|
+ private TpBuildingOwnerInfoMapper tpBuildingOwnerInfoMapper;
|
|
138
|
+
|
|
139
|
+ /**
|
|
140
|
+ * 户号
|
|
141
|
+ */
|
|
142
|
+ @Autowired
|
|
143
|
+ private TpRoomNoMapper tpRoomNoMapper;
|
|
144
|
+
|
108
|
145
|
@Override
|
109
|
146
|
@Transactional(rollbackFor = Exception.class)
|
110
|
147
|
public ResponseBean login(String loginName, String code, HttpSession session) {
|
|
@@ -192,6 +229,10 @@ public class TaUserServiceImpl implements ITaUserService {
|
192
|
229
|
|
193
|
230
|
// 校验房产
|
194
|
231
|
List<TaUserVerify> taUserVerifies = taUserVerifyMapper.selectByUserId(currentUser.getId());
|
|
232
|
+ taUserVerifies.forEach(e->{
|
|
233
|
+ e.setVerifyUrl(loginCodePerproties.getLoginCode().get("-1") + e.getId());
|
|
234
|
+ });
|
|
235
|
+ taUserVO.setUserVerifyList(taUserVerifies);
|
195
|
236
|
// 无关联房产
|
196
|
237
|
if (null == taUserVerifies || taUserVerifies.size() == 0) {
|
197
|
238
|
String token = null;
|
|
@@ -213,10 +254,6 @@ public class TaUserServiceImpl implements ITaUserService {
|
213
|
254
|
|
214
|
255
|
return checkHouse(response, taUserVO, userVerify);
|
215
|
256
|
} else if (taUserVerifies.size() >= 2) {
|
216
|
|
- taUserVerifies.forEach(e->{
|
217
|
|
- e.setVerifyUrl(loginCodePerproties.getLoginCode().get("-1") + e.getId());
|
218
|
|
- });
|
219
|
|
- taUserVO.setUserVerifyList(taUserVerifies);
|
220
|
257
|
response.addSuccess(UserVerifyEnum.A_MULTIPLE_REAL_ESTATE.getMsg(), taUserVO, loginCodePerproties.getLoginCode().get(UserVerifyEnum.A_MULTIPLE_REAL_ESTATE.getCode()));
|
221
|
258
|
return response;
|
222
|
259
|
}
|
|
@@ -247,35 +284,6 @@ public class TaUserServiceImpl implements ITaUserService {
|
247
|
284
|
userVO.setCommunityName(toCommunities.getCommunityName());
|
248
|
285
|
}
|
249
|
286
|
|
250
|
|
- /**
|
251
|
|
- * 可视对讲下发
|
252
|
|
- *
|
253
|
|
- * @param user
|
254
|
|
- */
|
255
|
|
- private void visualIntercom(TaUser user) {
|
256
|
|
- // TODO 目前下发的 authName权限组是我们自定义的, 后面肯定是按照小区的 期楼栋号来设置的
|
257
|
|
- // TODO longNums设备编号, 可视对讲的机器编号, 应该根据 期楼栋号 下面的机器编号来设置的
|
258
|
|
-
|
259
|
|
- //--------- 可视对讲 ----------
|
260
|
|
-
|
261
|
|
- // 可视对讲 根据人员 ID 集添加权限并下发
|
262
|
|
- Map<String, Object> addOutDoorAuthMap = new HashMap<>();
|
263
|
|
- addOutDoorAuthMap.put("authName", "荟居");
|
264
|
|
- addOutDoorAuthMap.put("personIds", Arrays.asList(user.getHkUserId()));
|
265
|
|
- addOutDoorAuthMap.put("longNums", Arrays.asList("10010100000"));
|
266
|
|
- // 可视对讲 根据人员 ID 集添加权限并下发
|
267
|
|
- HKOpenApi.addOutDoorAuth(addOutDoorAuthMap);
|
268
|
|
-
|
269
|
|
- // 可视对讲 指定人员指纹权限下载
|
270
|
|
-// Map<String, Object> downloadFingerMap = new HashMap<>();
|
271
|
|
-// // opType 操作类型 Integer 是 1 为下发权限;2 为删除权限
|
272
|
|
-// downloadFingerMap.put("opType", 1);
|
273
|
|
-// downloadFingerMap.put("personIds", Arrays.asList(user.getHkUserId()));
|
274
|
|
-// downloadFingerMap.put("longNums", Arrays.asList("10010100000"));
|
275
|
|
-// // 可视对讲 指定人员指纹权限下载
|
276
|
|
-// HKOpenApi.downloadFinger(downloadFingerMap);
|
277
|
|
-
|
278
|
|
- }
|
279
|
287
|
|
280
|
288
|
@Transactional(rollbackFor = Exception.class)
|
281
|
289
|
@Override
|
|
@@ -475,7 +483,9 @@ public class TaUserServiceImpl implements ITaUserService {
|
475
|
483
|
// 返回值 code 为 1,表示已经注册
|
476
|
484
|
if ("1".equals(response.getCode())) {
|
477
|
485
|
// 用户数据查询出来
|
478
|
|
- user = taUserMapper.selectByPrimaryKey(user.getId());
|
|
486
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
487
|
+ map.put("loginName", user.getLoginName());
|
|
488
|
+ user = taUserMapper.selectByLoginName(map);
|
479
|
489
|
} else {
|
480
|
490
|
user = (TaUser) response.getData();
|
481
|
491
|
}
|
|
@@ -505,31 +515,86 @@ public class TaUserServiceImpl implements ITaUserService {
|
505
|
515
|
|
506
|
516
|
taUserVerifyMapper.insertSelective(userVerify);
|
507
|
517
|
|
508
|
|
- // 设置 海康id
|
509
|
|
- user.setHkPersonNo(idGen.nextId());
|
510
|
|
-
|
|
518
|
+ // 插入楼栋资料库
|
|
519
|
+ TpBuildingOwnerInfo buildingInfo = getBuildingInfo(userElement, user.getLoginName());
|
|
520
|
+ if (null == buildingInfo) {
|
|
521
|
+ insertTpBuildingOwnerInfo(userElement, user, null);
|
|
522
|
+ }
|
511
|
523
|
|
512
|
524
|
// 推送海康
|
513
|
|
- /**
|
514
|
|
- * 1.获取部门(比如 住户)
|
515
|
|
- * 2.根据部门编号推送 海康
|
516
|
|
- */
|
517
|
|
- addUserAndOpenCard(response, user);
|
|
525
|
+ response = ihkService.pushPerson(user.getId()+"");
|
|
526
|
+ if ("1".equals(response.getCode())) {
|
|
527
|
+ throw new WisdomException("推送HK失败!");
|
|
528
|
+ }
|
518
|
529
|
|
519
|
|
- // 给用户添加 海康门禁权限
|
520
|
|
- HKOpenApi.addAuthoritiesByPersonIds(String.valueOf(user.getHkUserId()));
|
|
530
|
+ response.addSuccess(user);
|
|
531
|
+ return response;
|
|
532
|
+ }
|
521
|
533
|
|
522
|
|
- // 下发门禁权限
|
523
|
|
- HKOpenApi.downloadAuthorityByDeviceUuids();
|
|
534
|
+ /**
|
|
535
|
+ * 查询 楼栋信息
|
|
536
|
+ * 根据小区Id, 栋,单元,楼层,房号, 手机号
|
|
537
|
+ * @param userElement
|
|
538
|
+ * @param phone
|
|
539
|
+ * @return
|
|
540
|
+ */
|
|
541
|
+ private TpBuildingOwnerInfo getBuildingInfo(UserElement userElement, String phone) {
|
524
|
542
|
|
525
|
|
- //--------- 可视对讲 ----------
|
526
|
|
- visualIntercom(user);
|
|
543
|
+ TpBuildingOwnerInfo selectBuild = tpBuildingOwnerInfoMapper.selectCommunityAndAddressAndPhone(userElement.getCommunityId(),
|
|
544
|
+ userElement.getPhaseId(), userElement.getBuildingId(), userElement.getUnitId(), userElement.getLevelId(),
|
|
545
|
+ userElement.getRoomNoId(), phone);
|
527
|
546
|
|
528
|
|
- if ("0".equals(response.getCode())) {
|
529
|
|
- response.addSuccess(user);
|
530
|
|
- }
|
|
547
|
+ return selectBuild;
|
|
548
|
+ }
|
531
|
549
|
|
532
|
|
- return response;
|
|
550
|
+ /**
|
|
551
|
+ * 插入 楼栋资料库
|
|
552
|
+ *
|
|
553
|
+ * @param userElement
|
|
554
|
+ * @param user
|
|
555
|
+ * @param userId 创建人
|
|
556
|
+ */
|
|
557
|
+ private TpBuildingOwnerInfo insertTpBuildingOwnerInfo (UserElement userElement, TaUser user, Integer userId) {
|
|
558
|
+ TpBuildingOwnerInfo tpBuildingOwnerInfo = new TpBuildingOwnerInfo();
|
|
559
|
+ // 查询 期/楼栋/单元/层/户号
|
|
560
|
+ TpPhase phase = tpPhaseMapper.selectByPrimaryKey(userElement.getPhaseId());
|
|
561
|
+ TpBuilding building = tpBuildingMapper.selectByPrimaryKey(userElement.getBuildingId());
|
|
562
|
+ TpUnit unit = tpUnitMapper.selectByPrimaryKey(userElement.getUnitId());
|
|
563
|
+ TpLevel level = tpLevelMapper.selectByPrimaryKey(userElement.getLevelId());
|
|
564
|
+ TpRoomNo roomNo = tpRoomNoMapper.selectByPrimaryKey(userElement.getRoomNoId());
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+ // 主键是自增的, 所以设置为 null
|
|
568
|
+ tpBuildingOwnerInfo.setId(null);
|
|
569
|
+ tpBuildingOwnerInfo.setPhaseId(phase.getId());
|
|
570
|
+ tpBuildingOwnerInfo.setPhaseName(phase.getName());
|
|
571
|
+ tpBuildingOwnerInfo.setBuildingId(building.getId());
|
|
572
|
+ tpBuildingOwnerInfo.setBuildingName(building.getName());
|
|
573
|
+ tpBuildingOwnerInfo.setUnitId(unit.getId());
|
|
574
|
+ tpBuildingOwnerInfo.setUnitName(unit.getName());
|
|
575
|
+ tpBuildingOwnerInfo.setLevelId(level.getId());
|
|
576
|
+ tpBuildingOwnerInfo.setLevelName(level.getName());
|
|
577
|
+ tpBuildingOwnerInfo.setRoomNoId(roomNo.getId());
|
|
578
|
+ tpBuildingOwnerInfo.setRoomNoName(roomNo.getName());
|
|
579
|
+ tpBuildingOwnerInfo.setOwnerName(user.getUserName());
|
|
580
|
+ tpBuildingOwnerInfo.setOwnerTel(user.getLoginName());
|
|
581
|
+ tpBuildingOwnerInfo.setGender(user.getGender());
|
|
582
|
+ // tpBuildingOwnerInfo.setUpdateUser(userId);
|
|
583
|
+ tpBuildingOwnerInfo.setUpdateDate(new Date());
|
|
584
|
+ tpBuildingOwnerInfo.setCreateDate(new Date());
|
|
585
|
+ // tpBuildingOwnerInfo.setCreateUser(userId);
|
|
586
|
+ tpBuildingOwnerInfo.setVerifyStatus("1");
|
|
587
|
+ tpBuildingOwnerInfo.setPairStatus("1");
|
|
588
|
+
|
|
589
|
+ // 添加的时候, 默认是当前操作的小区
|
|
590
|
+ tpBuildingOwnerInfo.setCommunityId(userElement.getCommunityId());
|
|
591
|
+
|
|
592
|
+ int row = tpBuildingOwnerInfoMapper.insertSelective(tpBuildingOwnerInfo);
|
|
593
|
+ if (row <= 0) {
|
|
594
|
+ log.error("添加操作! 楼栋业主信息表 失败!");
|
|
595
|
+ throw new WisdomException("操作失败!");
|
|
596
|
+ }
|
|
597
|
+ return tpBuildingOwnerInfo;
|
533
|
598
|
}
|
534
|
599
|
|
535
|
600
|
@Override
|
|
@@ -595,60 +660,7 @@ public class TaUserServiceImpl implements ITaUserService {
|
595
|
660
|
return response;
|
596
|
661
|
}
|
597
|
662
|
|
598
|
|
- /**
|
599
|
|
- * 公共方法
|
600
|
|
- * 添加人员, 开卡
|
601
|
|
- *
|
602
|
|
- * @param response
|
603
|
|
- * @param user
|
604
|
|
- */
|
605
|
|
- private void addUserAndOpenCard(ResponseBean response, TaUser user) {
|
606
|
|
- Map<String, Object> parDept = Maps.newHashMap();
|
607
|
|
- parDept.put("pageNo", 1);
|
608
|
|
- parDept.put("pageSize", 100);
|
609
|
|
- parDept.put("deptName", Constant.DEPT_RESIDENTS);
|
610
|
|
- // 部门UUID
|
611
|
|
- String deptUuid = getDeptUUID(parDept);
|
612
|
663
|
|
613
|
|
- // 添加人员
|
614
|
|
- Map<String, Object> parUser = Maps.newHashMap();
|
615
|
|
- parUser.put("personNo", user.getHkPersonNo());
|
616
|
|
- parUser.put("personName", user.getUserName());
|
617
|
|
- parUser.put("phoneNo", user.getLoginName());
|
618
|
|
- parUser.put("deptUuid", deptUuid);
|
619
|
|
- Map<String, Object> resultMap = JSONObject.parseObject(HKOpenApi.addUser(parUser), HashMap.class);
|
620
|
|
- int errorCode = (int) resultMap.get("errorCode");
|
621
|
|
- if (errorCode == 0) {
|
622
|
|
- Map<String, Object> resultDataMap = (Map<String, Object>) resultMap.get("data");
|
623
|
|
- // 开卡 卡号
|
624
|
|
- long cardNo = System.currentTimeMillis();
|
625
|
|
- // 海康人员ID
|
626
|
|
- Integer personId = (Integer) resultDataMap.get("personId");
|
627
|
|
- TaUser tempUser = taUserMapper.selectByPrimaryKey(user.getId());
|
628
|
|
- tempUser.setHkUserId(personId);
|
629
|
|
- tempUser.setHkCardNo(cardNo + "");
|
630
|
|
-
|
631
|
|
- user.setHkUserId(personId);
|
632
|
|
- // 存储海康人员ID
|
633
|
|
- int row = taUserMapper.updateByPrimaryKeySelective(tempUser);
|
634
|
|
- if (row > 0) {
|
635
|
|
- response.addSuccess("操作成功!");
|
636
|
|
- } else {
|
637
|
|
- response.addError("操作失败");
|
638
|
|
- throw new RuntimeException("数据库添加 家属/租客 人员失败!");
|
639
|
|
- }
|
640
|
|
-
|
641
|
|
- // 开卡
|
642
|
|
- List<String> cardAndPersonList = Lists.newArrayList();
|
643
|
|
- cardAndPersonList.add(cardNo + "," + personId);
|
644
|
|
- response = openCard(cardAndPersonList, null);
|
645
|
|
- } else {
|
646
|
|
- String errorMessage = String.valueOf(resultMap.get("errorMessage"));
|
647
|
|
- response.addError(errorMessage);
|
648
|
|
- log.error("海康添加人员失败! {}", errorMessage);
|
649
|
|
- throw new RuntimeException(errorMessage);
|
650
|
|
- }
|
651
|
|
- }
|
652
|
664
|
|
653
|
665
|
/**
|
654
|
666
|
* 公共方法
|
|
@@ -701,53 +713,7 @@ public class TaUserServiceImpl implements ITaUserService {
|
701
|
713
|
return deptUuid;
|
702
|
714
|
}
|
703
|
715
|
|
704
|
|
- /**
|
705
|
|
- * 批量开卡
|
706
|
|
- *
|
707
|
|
- * @param cardIdAndHKUserID list.add("卡号,人员ID")
|
708
|
|
- * @param expirationTime 有效期为多少? 单位为 年
|
709
|
|
- * @return
|
710
|
|
- */
|
711
|
|
- private ResponseBean openCard(List<String> cardIdAndHKUserID, Integer expirationTime) {
|
712
|
|
- ResponseBean response = new ResponseBean();
|
713
|
|
-
|
714
|
|
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
715
|
|
- LocalDate today = LocalDate.now();
|
716
|
|
- int year = today.getYear();
|
717
|
|
- // 加上20, 表示加上20年,默认
|
718
|
|
- if (null == expirationTime || expirationTime <= 0) {
|
719
|
|
- year += 20;
|
720
|
|
- } else {
|
721
|
|
- year += expirationTime;
|
722
|
|
- }
|
723
|
|
- int month = today.getMonthValue();
|
724
|
|
- int day = today.getDayOfMonth();
|
725
|
716
|
|
726
|
|
- Long time = null;
|
727
|
|
- try {
|
728
|
|
- time = formatter.parse(year + "-" + month + "-" + day).getTime();
|
729
|
|
- } catch (ParseException e) {
|
730
|
|
- e.printStackTrace();
|
731
|
|
- }
|
732
|
|
-
|
733
|
|
- // 开卡
|
734
|
|
- Map<String, Object> parOpenCard = Maps.newHashMap();
|
735
|
|
- parOpenCard.put("cardAndPerson", cardIdAndHKUserID);
|
736
|
|
- parOpenCard.put("startTime", System.currentTimeMillis());
|
737
|
|
- parOpenCard.put("endTime", time);
|
738
|
|
- JSONObject openCardJSON = JSONObject.parseObject(HKOpenApi.openCard(parOpenCard));
|
739
|
|
- int code = (int) openCardJSON.get("errorCode");
|
740
|
|
- if (code == 0) {
|
741
|
|
- response.addSuccess("操作成功!");
|
742
|
|
- } else {
|
743
|
|
- String errorMessage = String.valueOf(openCardJSON.get("errorMessage"));
|
744
|
|
- response.addError(errorMessage);
|
745
|
|
- log.error("开卡失败! {}", errorMessage);
|
746
|
|
- throw new RuntimeException(errorMessage);
|
747
|
|
- }
|
748
|
|
-
|
749
|
|
- return response;
|
750
|
|
- }
|
751
|
717
|
|
752
|
718
|
/**
|
753
|
719
|
* 公共方法,添加或者修改 角色.
|