|
@@ -53,6 +53,7 @@ import java.util.stream.Collectors;
|
53
|
53
|
*/
|
54
|
54
|
@Service("iBuildingOwnerInfoService")
|
55
|
55
|
@Slf4j
|
|
56
|
+@Transactional
|
56
|
57
|
public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInfoMapper, TpBuildingOwnerInfo> implements IBuildingOwnerInfoService {
|
57
|
58
|
|
58
|
59
|
@Autowired
|
|
@@ -79,6 +80,9 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
79
|
80
|
@Autowired
|
80
|
81
|
private TpBuildingMapper tpBuildingMapper;
|
81
|
82
|
|
|
83
|
+ @Autowired
|
|
84
|
+ private TaUserVerifyMapper taUserVerifyMapper;
|
|
85
|
+
|
82
|
86
|
public static final Logger logger = LoggerFactory.getLogger(BuildingOwnerInfoServiceImpl.class);
|
83
|
87
|
|
84
|
88
|
@Override
|
|
@@ -97,20 +101,21 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
97
|
101
|
Map<String, Object> map = Maps.newHashMap();
|
98
|
102
|
// 小区Id
|
99
|
103
|
map.put("community_id", userElement.getCommunityId());
|
|
104
|
+ map.put("owner_status", "1");
|
100
|
105
|
// 期
|
101
|
|
- map.put("phase", tpBuildingOwnerInfo.getPhaseName());
|
|
106
|
+ //map.put("phase", tpBuildingOwnerInfo.getPhaseName());
|
102
|
107
|
// 栋
|
103
|
|
- map.put("building", tpBuildingOwnerInfo.getBuildingName());
|
|
108
|
+ //map.put("building", tpBuildingOwnerInfo.getBuildingName());
|
104
|
109
|
// 单元
|
105
|
|
- map.put("unit", tpBuildingOwnerInfo.getUnitName());
|
|
110
|
+ //map.put("unit", tpBuildingOwnerInfo.getUnitName());
|
106
|
111
|
// 楼层
|
107
|
|
- map.put("level", tpBuildingOwnerInfo.getLevelName());
|
|
112
|
+ //map.put("level", tpBuildingOwnerInfo.getLevelName());
|
108
|
113
|
// 房号
|
109
|
|
- map.put("room_no", tpBuildingOwnerInfo.getName());
|
|
114
|
+ //map.put("room_no", tpBuildingOwnerInfo.getName());
|
110
|
115
|
|
111
|
116
|
QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
|
112
|
117
|
queryWrapper.allEq(map,false);
|
113
|
|
- queryWrapper.like(tpBuildingOwnerInfo.getOwnerName() != null,"owner_name", tpBuildingOwnerInfo.getOwnerName());
|
|
118
|
+ //queryWrapper.like(tpBuildingOwnerInfo.getOwnerName() != null,"owner_name", tpBuildingOwnerInfo.getOwnerName());
|
114
|
119
|
queryWrapper.orderByDesc("create_date");
|
115
|
120
|
|
116
|
121
|
// 分页查询
|
|
@@ -385,39 +390,19 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
385
|
390
|
|
386
|
391
|
// 小区
|
387
|
392
|
map.put("community_id", communityId);
|
|
393
|
+ map.put("owner_status", "1");
|
388
|
394
|
// 期
|
389
|
|
- map.put("phase", tpBuildingOwnerInfo.getPhaseName());
|
|
395
|
+ //map.put("phase", tpBuildingOwnerInfo.getPhaseName());
|
390
|
396
|
// 栋
|
391
|
|
- map.put("building", tpBuildingOwnerInfo.getBuildingName());
|
|
397
|
+ //map.put("building", tpBuildingOwnerInfo.getBuildingName());
|
392
|
398
|
// 单元
|
393
|
|
- map.put("unit", tpBuildingOwnerInfo.getUnitName());
|
|
399
|
+ //map.put("unit", tpBuildingOwnerInfo.getUnitName());
|
394
|
400
|
// 楼层
|
395
|
|
- map.put("level", tpBuildingOwnerInfo.getLevelName());
|
|
401
|
+ //map.put("level", tpBuildingOwnerInfo.getLevelName());
|
396
|
402
|
|
397
|
403
|
QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
|
398
|
404
|
queryWrapper.allEq(map, false);
|
399
|
405
|
|
400
|
|
- /**
|
401
|
|
- * 通过分组来去重
|
402
|
|
- *
|
403
|
|
- * 1. phase 为空表示为 phase 字段进行分组
|
404
|
|
- * 2. building 为空表示为 building 字段进行分组
|
405
|
|
- * 3. unit 为空表示为 unit 字段进行分组
|
406
|
|
- * 4. level 为空表示为 level 字段进行分组
|
407
|
|
- * 5. room_no 为空表示为 room_no 字段进行分组
|
408
|
|
- */
|
409
|
|
- if (null == tpBuildingOwnerInfo.getPhaseName() || "".equals(tpBuildingOwnerInfo.getPhaseName())) {
|
410
|
|
- queryWrapper.groupBy("phase");
|
411
|
|
- } else if (null == tpBuildingOwnerInfo.getBuildingName() || "".equals(tpBuildingOwnerInfo.getBuildingName())) {
|
412
|
|
- queryWrapper.groupBy("building");
|
413
|
|
- } else if (null == tpBuildingOwnerInfo.getUnitName() || "".equals(tpBuildingOwnerInfo.getUnitName())) {
|
414
|
|
- queryWrapper.groupBy("unit");
|
415
|
|
- } else if (null == tpBuildingOwnerInfo.getLevelName() || "".equals(tpBuildingOwnerInfo.getLevelName())) {
|
416
|
|
- queryWrapper.groupBy("level");
|
417
|
|
- } else if (null == tpBuildingOwnerInfo.getName() || "".equals(tpBuildingOwnerInfo.getName())) {
|
418
|
|
- queryWrapper.groupBy("room_no");
|
419
|
|
- }
|
420
|
|
-
|
421
|
406
|
/**
|
422
|
407
|
* 1.如果 楼栋值不存在表示根据小区Id查询时查询楼栋!
|
423
|
408
|
* 2.如果 楼栋存在表示查询单元
|
|
@@ -454,41 +439,92 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
454
|
439
|
//获取要上传的数据
|
455
|
440
|
Map<String,Object> map = (Map<String, Object>) responseBean.getData();
|
456
|
441
|
List<TpBuildingOwnerInfo> list = (List<TpBuildingOwnerInfo>) map.get("list");
|
457
|
|
- list.stream().forEach(BuildingOwnerInfo -> {
|
458
|
|
- BuildingOwnerInfo.setCommunityId(userElement.getCommunityId());
|
459
|
|
- BuildingOwnerInfo.setVerifyStatus(Constant.UN_VERIFY_STATUS);
|
460
|
|
- BuildingOwnerInfo.setCreateUser(userElement.getId());
|
461
|
|
- BuildingOwnerInfo.setCreateDate(LocalDateTime.now());
|
462
|
|
- BuildingOwnerInfo.setUpdateUser(userElement.getId());
|
463
|
|
- BuildingOwnerInfo.setUpdateDate(LocalDateTime.now());
|
464
|
|
- });
|
465
|
|
- //批量插入
|
466
|
|
- tpBuildingOwnerInfoMapper.batchInsert(list);
|
467
|
|
- //判断是否认证过
|
468
|
|
- List<TpBuildingOwnerInfo> updateList = new ArrayList<TpBuildingOwnerInfo>();
|
469
|
|
- List<TaUser> updataTaUserList = new ArrayList<TaUser>();
|
470
|
|
- list.stream().forEach(BuildingOwnerInfo -> {
|
471
|
|
- TaUser taUser = taUserMapper.selectByTel(BuildingOwnerInfo.getOwnerTel(),BuildingOwnerInfo.getCommunityId());
|
472
|
|
- if (null != taUser){
|
473
|
|
- BuildingOwnerInfo.setVerifyStatus(Constant.VERIFY_STATUS);
|
474
|
|
- updateList.add(BuildingOwnerInfo);
|
475
|
|
- taUser.setVerifyStatus(Constant.VERIFY_STATUS);
|
476
|
|
- taUser.setBuildingOwnerInfoId(BuildingOwnerInfo.getId());
|
477
|
|
- updataTaUserList.add(taUser);
|
478
|
|
- }
|
479
|
|
- });
|
|
442
|
+
|
480
|
443
|
//批量更新
|
481
|
|
- if (updateList.size() > 0){
|
482
|
|
- tpBuildingOwnerInfoMapper.batchUpdate(updateList);
|
483
|
|
- }
|
484
|
|
- if (updataTaUserList.size() > 0){
|
485
|
|
- taUserMapper.batchUpdate(updataTaUserList);
|
486
|
|
- taUserMapper.batchUpdateRole(updataTaUserList);
|
|
444
|
+ tpBuildingOwnerInfoMapper.batchUpdate(list);
|
|
445
|
+
|
|
446
|
+ //构造数据
|
|
447
|
+ for (TpBuildingOwnerInfo tpBuildingOwnerInfo : list){
|
|
448
|
+ //根据手机号查询这个手机号是否注册
|
|
449
|
+ TaUser taUser = taUserMapper.selectByTel(tpBuildingOwnerInfo.getOwnerTel());
|
|
450
|
+ if (null == taUser){
|
|
451
|
+ //插入新用户并审核通过
|
|
452
|
+ addNewUser(tpBuildingOwnerInfo,userElement);
|
|
453
|
+ }else {
|
|
454
|
+ //已经有用户的情况下看是否审核通过,是否要添加新的房产
|
|
455
|
+ checkUserVerify(taUser,tpBuildingOwnerInfo,userElement);
|
|
456
|
+ }
|
487
|
457
|
}
|
488
|
458
|
responseBean.addSuccess("success");
|
489
|
459
|
return responseBean;
|
490
|
460
|
}
|
491
|
|
-
|
|
461
|
+
|
|
462
|
+ private void checkUserVerify(TaUser taUser, TpBuildingOwnerInfo tpBuildingOwnerInfo, UserElement userElement) {
|
|
463
|
+ //有用户的情况下查看是否有申请的房产
|
|
464
|
+ QueryWrapper<TaUserVerify> queryWrapper = new QueryWrapper<>();
|
|
465
|
+ queryWrapper.eq("community_id",userElement.getCommunityId());
|
|
466
|
+ queryWrapper.eq("user_id",taUser.getId());
|
|
467
|
+ List<TaUserVerify> verifyList = taUserVerifyMapper.selectList(queryWrapper);
|
|
468
|
+ if (verifyList.size() > 0){
|
|
469
|
+ verifyList.stream().forEach(e -> {
|
|
470
|
+ if (e.getRoomNoId().equals(tpBuildingOwnerInfo.getId()) && e.getVerifyStatus().equals("0")){
|
|
471
|
+ e.setVerifyStatus("1");
|
|
472
|
+ e.setVerifyName(userElement.getUserName());
|
|
473
|
+ taUserVerifyMapper.updateById(e);
|
|
474
|
+ }
|
|
475
|
+ });
|
|
476
|
+ return;
|
|
477
|
+ }
|
|
478
|
+ //插入一条房产数据
|
|
479
|
+ saveVerifyData(taUser.getId(),tpBuildingOwnerInfo,userElement);
|
|
480
|
+ }
|
|
481
|
+
|
|
482
|
+ /**
|
|
483
|
+ * 插入新用户并审核通过
|
|
484
|
+ * @param tpBuildingOwnerInfo
|
|
485
|
+ * @param userElement
|
|
486
|
+ */
|
|
487
|
+ private void addNewUser(TpBuildingOwnerInfo tpBuildingOwnerInfo, UserElement userElement) {
|
|
488
|
+ //插入用户
|
|
489
|
+ TaUser taUser = new TaUser();
|
|
490
|
+ taUser.setUserName(tpBuildingOwnerInfo.getOwnerName());
|
|
491
|
+ taUser.setLoginName(tpBuildingOwnerInfo.getOwnerTel());
|
|
492
|
+ taUser.setStatus("1");
|
|
493
|
+ taUser.setCreateDate(LocalDateTime.now());
|
|
494
|
+ taUser.setFaceStatus("0");
|
|
495
|
+ taUserMapper.insert(taUser);
|
|
496
|
+ //审核通过
|
|
497
|
+ saveVerifyData(taUser.getId(),tpBuildingOwnerInfo,userElement);
|
|
498
|
+
|
|
499
|
+ }
|
|
500
|
+
|
|
501
|
+ private void saveVerifyData(Integer userId, TpBuildingOwnerInfo tpBuildingOwnerInfo, UserElement userElement) {
|
|
502
|
+ TaUserVerify taUserVerify = new TaUserVerify();
|
|
503
|
+ taUserVerify.setUserId(userId);
|
|
504
|
+ taUserVerify.setCommunityId(userElement.getCommunityId());
|
|
505
|
+ if (tpBuildingOwnerInfo.getRoleName().equals("户主")){
|
|
506
|
+ taUserVerify.setRoleId(1);
|
|
507
|
+ }else if (tpBuildingOwnerInfo.getRoleName().equals("家属")){
|
|
508
|
+ taUserVerify.setRoleId(3);
|
|
509
|
+ }else if (tpBuildingOwnerInfo.getRoleName().equals("租客")){
|
|
510
|
+ taUserVerify.setRoleId(2);
|
|
511
|
+ }
|
|
512
|
+ taUserVerify.setPhaseId(tpBuildingOwnerInfo.getPhaseId());
|
|
513
|
+ taUserVerify.setPhaseName(tpBuildingOwnerInfo.getPhaseName());
|
|
514
|
+ taUserVerify.setBuildingId(tpBuildingOwnerInfo.getBuildingId());
|
|
515
|
+ taUserVerify.setBuildingName(tpBuildingOwnerInfo.getBuildingName());
|
|
516
|
+ taUserVerify.setUnitId(tpBuildingOwnerInfo.getUnitId());
|
|
517
|
+ taUserVerify.setUnitName(tpBuildingOwnerInfo.getUnitName());
|
|
518
|
+ taUserVerify.setLevelId(tpBuildingOwnerInfo.getLevelId());
|
|
519
|
+ taUserVerify.setLevelName(tpBuildingOwnerInfo.getLevelName());
|
|
520
|
+ taUserVerify.setRoomNoId(tpBuildingOwnerInfo.getId());
|
|
521
|
+ taUserVerify.setRoomNoName(tpBuildingOwnerInfo.getName());
|
|
522
|
+ taUserVerify.setVerifyStatus("1");
|
|
523
|
+ taUserVerify.setCreateDate(LocalDateTime.now());
|
|
524
|
+ taUserVerify.setVerifyName(userElement.getUserName());
|
|
525
|
+ taUserVerifyMapper.insert(taUserVerify);
|
|
526
|
+ }
|
|
527
|
+
|
492
|
528
|
@Override
|
493
|
529
|
public ResponseBean updataApprove(String paramets) {
|
494
|
530
|
ResponseBean response = new ResponseBean();
|
|
@@ -562,7 +598,6 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
562
|
598
|
//从第一行开始第一行一般是标题
|
563
|
599
|
for (int j = 3; j <= lastRowNum; j++) {
|
564
|
600
|
Row row = sheet.getRow(j);
|
565
|
|
- TpBuildingOwnerInfo tpBuildingOwnerInfo = new TpBuildingOwnerInfo();
|
566
|
601
|
String buildingInfo = row.getCell(0).getStringCellValue().trim();
|
567
|
602
|
String roomNoId = row.getCell(1).getStringCellValue().trim();
|
568
|
603
|
String ownerName = row.getCell(2).getStringCellValue().trim();
|
|
@@ -610,14 +645,11 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
610
|
645
|
//把数据塞入temList校验是否有重复的数据
|
611
|
646
|
temBuildingList.add(roomNoId);
|
612
|
647
|
//构建数据
|
613
|
|
- tpBuildingOwnerInfo.setPhaseName(phase);
|
614
|
|
- tpBuildingOwnerInfo.setBuildingName(building);
|
615
|
|
- tpBuildingOwnerInfo.setUnitName(unit);
|
616
|
|
- tpBuildingOwnerInfo.setLevelName(level);
|
617
|
|
- tpBuildingOwnerInfo.setName(roomNo);
|
618
|
|
- tpBuildingOwnerInfo.setOwnerName(ownerName);
|
619
|
|
- tpBuildingOwnerInfo.setOwnerTel(ownerTel);
|
620
|
|
- list.add(tpBuildingOwnerInfo);
|
|
648
|
+ checkOwnerInfo.setRoleName(ownerRole);
|
|
649
|
+ checkOwnerInfo.setOwnerName(ownerName);
|
|
650
|
+ checkOwnerInfo.setOwnerTel(ownerTel);
|
|
651
|
+ checkOwnerInfo.setOwnerStatus("1");
|
|
652
|
+ list.add(checkOwnerInfo);
|
621
|
653
|
}
|
622
|
654
|
}
|
623
|
655
|
//构建分页
|