|
@@ -2,7 +2,10 @@ package com.community.huiju.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.alibaba.fastjson.JSONObject;
|
4
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
5
|
+import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
5
|
6
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
7
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
8
|
+import com.baomidou.mybatisplus.core.toolkit.Constants;
|
6
|
9
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
7
|
10
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
8
|
11
|
import com.community.commom.constant.Constant;
|
|
@@ -23,7 +26,11 @@ import com.community.huiju.model.TpBuildingOwnerInfo;
|
23
|
26
|
|
24
|
27
|
import com.community.huiju.model.User;
|
25
|
28
|
import com.community.huiju.service.IBuildingOwnerInfoService;
|
|
29
|
+import com.community.huiju.service.ITaUserService;
|
|
30
|
+import com.google.common.collect.Lists;
|
26
|
31
|
import com.google.common.collect.Maps;
|
|
32
|
+import org.apache.ibatis.binding.MapperMethod;
|
|
33
|
+import org.apache.ibatis.session.SqlSession;
|
27
|
34
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
28
|
35
|
import org.apache.poi.ss.usermodel.Row;
|
29
|
36
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
@@ -39,10 +46,8 @@ import org.springframework.transaction.annotation.Transactional;
|
39
|
46
|
import org.springframework.web.multipart.MultipartFile;
|
40
|
47
|
|
41
|
48
|
import java.time.LocalDateTime;
|
42
|
|
-import java.util.ArrayList;
|
43
|
|
-import java.util.HashMap;
|
44
|
|
-import java.util.List;
|
45
|
|
-import java.util.Map;
|
|
49
|
+import java.util.*;
|
|
50
|
+import java.util.stream.Collectors;
|
46
|
51
|
|
47
|
52
|
|
48
|
53
|
/**
|
|
@@ -68,6 +73,9 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
68
|
73
|
|
69
|
74
|
@Autowired
|
70
|
75
|
private TaSysUserRoleMapper taSysUserRoleMapper;
|
|
76
|
+
|
|
77
|
+ @Autowired
|
|
78
|
+ private ITaUserService iTaUserService;
|
71
|
79
|
|
72
|
80
|
public static final Logger logger = LoggerFactory.getLogger(BuildingOwnerInfoServiceImpl.class);
|
73
|
81
|
|
|
@@ -146,18 +154,7 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
146
|
154
|
boolean phoneBool = false;
|
147
|
155
|
|
148
|
156
|
// 校验楼栋信息表
|
149
|
|
- QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
|
150
|
|
- // 小区ID
|
151
|
|
- queryWrapper.eq("community_id", user.getCommunityId());
|
152
|
|
- // 栋
|
153
|
|
- queryWrapper.eq("building", tpBuildingOwnerInfo.getBuilding());
|
154
|
|
- // 单元
|
155
|
|
- queryWrapper.eq("unit", tpBuildingOwnerInfo.getUnit());
|
156
|
|
- // 楼层
|
157
|
|
- queryWrapper.eq("level", tpBuildingOwnerInfo.getLevel());
|
158
|
|
- // 房号
|
159
|
|
- queryWrapper.eq("room_no", tpBuildingOwnerInfo.getRoomNo());
|
160
|
|
- TpBuildingOwnerInfo selectBuild = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
|
|
157
|
+ TpBuildingOwnerInfo selectBuild = getBuildingInfo(tpBuildingOwnerInfo, user.getId());
|
161
|
158
|
// 如果数据查询到了, 并且手机号和传上来的手机号是一样的是, 代表就是原数据, 直接返回操作成功
|
162
|
159
|
if (null != selectBuild && selectBuild.getOwnerTel().equals(tpBuildingOwnerInfo.getOwnerTel())) {
|
163
|
160
|
tpBuildingOwnerInfoMapper.updateById(tpBuildingOwnerInfo);
|
|
@@ -170,7 +167,7 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
170
|
167
|
// 校验楼栋信息表里面的业主手机号
|
171
|
168
|
QueryWrapper<TpBuildingOwnerInfo> queryWrapperPhone = new QueryWrapper<>();
|
172
|
169
|
queryWrapperPhone.eq("owner_tel", tpBuildingOwnerInfo.getOwnerTel());
|
173
|
|
- TpBuildingOwnerInfo selectBuildPhone = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
|
|
170
|
+ TpBuildingOwnerInfo selectBuildPhone = getBuildingInfo(tpBuildingOwnerInfo, user.getId());
|
174
|
171
|
|
175
|
172
|
// 如果 通过手机号查询出来的楼栋信息数据的 id 和 传上来的 楼栋,单元,楼层,单元,户号 查询出来的数据的id 匹配, 那么就表示这个手机号已经绑定了其他的楼栋信息
|
176
|
173
|
if (selectBuildPhone.getId().intValue() != selectBuild.getId().intValue()){
|
|
@@ -250,18 +247,7 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
250
|
247
|
}
|
251
|
248
|
|
252
|
249
|
// 校验楼栋信息表
|
253
|
|
- QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
|
254
|
|
- // 小区ID
|
255
|
|
- queryWrapper.eq("community_id", user.getCommunityId());
|
256
|
|
- // 栋
|
257
|
|
- queryWrapper.eq("building", tpBuildingOwnerInfo.getBuilding());
|
258
|
|
- // 单元
|
259
|
|
- queryWrapper.eq("unit", tpBuildingOwnerInfo.getUnit());
|
260
|
|
- // 楼层
|
261
|
|
- queryWrapper.eq("level", tpBuildingOwnerInfo.getLevel());
|
262
|
|
- // 房号
|
263
|
|
- queryWrapper.eq("room_no", tpBuildingOwnerInfo.getRoomNo());
|
264
|
|
- selectBuild = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
|
|
250
|
+ selectBuild = getBuildingInfo(tpBuildingOwnerInfo, user.getId());
|
265
|
251
|
if (null != selectBuild) {
|
266
|
252
|
responseBean.addError("该楼层的户号,已存在!");
|
267
|
253
|
return responseBean;
|
|
@@ -285,11 +271,8 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
285
|
271
|
}
|
286
|
272
|
|
287
|
273
|
// 开始匹配 APP 端用户表
|
288
|
|
- QueryWrapper<TaUser> taUserQueryWrapper = new QueryWrapper<>();
|
289
|
|
- taUserQueryWrapper.eq("login_name", tpBuildingOwnerInfo.getOwnerTel());
|
290
|
|
- taUserQueryWrapper.eq("community_id", tpBuildingOwnerInfo.getCommunityId());
|
291
|
274
|
// 查询 APP 端业主
|
292
|
|
- TaUser appOwnerUser = taUserMapper.selectOne(taUserQueryWrapper);
|
|
275
|
+ TaUser appOwnerUser = getByIdAndCommunityId(tpBuildingOwnerInfo.getOwnerTel(), tpBuildingOwnerInfo.getCommunityId());
|
293
|
276
|
if (null != appOwnerUser) {
|
294
|
277
|
// 更新 APP 端用户认证的状态
|
295
|
278
|
appOwnerUser.setBuildingOwnerInfoId(tpBuildingOwnerInfo.getId());
|
|
@@ -579,4 +562,86 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
|
579
|
562
|
|
580
|
563
|
return responseBean;
|
581
|
564
|
}
|
|
565
|
+
|
|
566
|
+ @Override
|
|
567
|
+ @Transactional(rollbackFor = Exception.class)
|
|
568
|
+ public ResponseBean deleteIds(List<Integer> ids, Integer propertyUserId) {
|
|
569
|
+
|
|
570
|
+ ResponseBean responseBean = new ResponseBean();
|
|
571
|
+
|
|
572
|
+ List<TpBuildingOwnerInfo> infoList = ids.stream().map(e->{
|
|
573
|
+ TpBuildingOwnerInfo tpBuildingOwnerInfo = new TpBuildingOwnerInfo();
|
|
574
|
+ tpBuildingOwnerInfo.setId(e);
|
|
575
|
+ tpBuildingOwnerInfo.setVerifyStatus("2");
|
|
576
|
+ tpBuildingOwnerInfo.setUpdateUser(propertyUserId);
|
|
577
|
+ return tpBuildingOwnerInfo;
|
|
578
|
+ }).collect(Collectors.toList());
|
|
579
|
+ boolean result = updateBatchById(infoList);
|
|
580
|
+
|
|
581
|
+ // APP 端用户
|
|
582
|
+ List<TaUser> taUserList = Lists.newArrayList();
|
|
583
|
+
|
|
584
|
+ ids.forEach(e-> {
|
|
585
|
+ TpBuildingOwnerInfo tpBuildingOwnerInfo = tpBuildingOwnerInfoMapper.selectById(e);
|
|
586
|
+ if (null == tpBuildingOwnerInfo) {
|
|
587
|
+ // 查询 APP 端业主
|
|
588
|
+ TaUser appOwnerUser = getByIdAndCommunityId(tpBuildingOwnerInfo.getOwnerTel(), tpBuildingOwnerInfo.getCommunityId());
|
|
589
|
+ appOwnerUser.setVerifyStatus(2+"");
|
|
590
|
+ taUserList.add(appOwnerUser);
|
|
591
|
+ }
|
|
592
|
+ });
|
|
593
|
+
|
|
594
|
+ result = iTaUserService.updateBatchById(taUserList);
|
|
595
|
+
|
|
596
|
+ if (result) {
|
|
597
|
+ responseBean.addSuccess("操作成功!");
|
|
598
|
+ }else {
|
|
599
|
+ responseBean.addError("操作失败!");
|
|
600
|
+ }
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+ return responseBean;
|
|
604
|
+ }
|
|
605
|
+
|
|
606
|
+ /**
|
|
607
|
+ * 根据 手机号 和 小区Id 查询用户
|
|
608
|
+ * @param phone
|
|
609
|
+ * @param communityId
|
|
610
|
+ * @return
|
|
611
|
+ */
|
|
612
|
+ private TaUser getByIdAndCommunityId(String phone, Integer communityId){
|
|
613
|
+ // 开始匹配 APP 端用户表
|
|
614
|
+ QueryWrapper<TaUser> taUserQueryWrapper = new QueryWrapper<>();
|
|
615
|
+ taUserQueryWrapper.eq("login_name", phone);
|
|
616
|
+ taUserQueryWrapper.eq("community_id", communityId);
|
|
617
|
+ // 查询 APP 端业主
|
|
618
|
+ TaUser appOwnerUser = taUserMapper.selectOne(taUserQueryWrapper);
|
|
619
|
+
|
|
620
|
+ return appOwnerUser;
|
|
621
|
+ }
|
|
622
|
+
|
|
623
|
+ /**
|
|
624
|
+ * 查询 楼栋信息
|
|
625
|
+ * 根据小区Id, 栋,单元,楼层,房号
|
|
626
|
+ * @param tpBuildingOwnerInfo 楼栋信息
|
|
627
|
+ * @param communityId 小区Id
|
|
628
|
+ * @return
|
|
629
|
+ */
|
|
630
|
+ private TpBuildingOwnerInfo getBuildingInfo(TpBuildingOwnerInfo tpBuildingOwnerInfo, Integer communityId) {
|
|
631
|
+ // 校验楼栋信息表
|
|
632
|
+ QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
|
|
633
|
+ // 小区ID
|
|
634
|
+ queryWrapper.eq("community_id", communityId);
|
|
635
|
+ // 栋
|
|
636
|
+ queryWrapper.eq("building", tpBuildingOwnerInfo.getBuilding());
|
|
637
|
+ // 单元
|
|
638
|
+ queryWrapper.eq("unit", tpBuildingOwnerInfo.getUnit());
|
|
639
|
+ // 楼层
|
|
640
|
+ queryWrapper.eq("level", tpBuildingOwnerInfo.getLevel());
|
|
641
|
+ // 房号
|
|
642
|
+ queryWrapper.eq("room_no", tpBuildingOwnerInfo.getRoomNo());
|
|
643
|
+ TpBuildingOwnerInfo selectBuild = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
|
|
644
|
+
|
|
645
|
+ return selectBuild;
|
|
646
|
+ }
|
582
|
647
|
}
|