|
@@ -1,15 +1,24 @@
|
1
|
1
|
package com.community.huiju.service.impl;
|
2
|
2
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
3
|
4
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
4
|
5
|
import com.community.commom.constant.Constant;
|
5
|
6
|
import com.community.commom.mode.ResponseBean;
|
6
|
7
|
import com.community.commom.session.UserElement;
|
7
|
8
|
import com.community.commom.utils.AccountValidatorUtil;
|
|
9
|
+import com.community.huiju.dao.TpBuildingMapper;
|
|
10
|
+import com.community.huiju.dao.TpBuildingOwnerInfoMapper;
|
|
11
|
+import com.community.huiju.dao.TpLevelMapper;
|
8
|
12
|
import com.community.huiju.dao.TpPhaseMapper;
|
|
13
|
+import com.community.huiju.dao.TpUnitMapper;
|
9
|
14
|
import com.community.huiju.model.TaUser;
|
|
15
|
+import com.community.huiju.model.TpBuilding;
|
10
|
16
|
import com.community.huiju.model.TpBuildingOwnerInfo;
|
|
17
|
+import com.community.huiju.model.TpLevel;
|
11
|
18
|
import com.community.huiju.model.TpPhase;
|
|
19
|
+import com.community.huiju.model.TpUnit;
|
12
|
20
|
import com.community.huiju.service.BuildingTreeServiceI;
|
|
21
|
+import org.apache.ibatis.annotations.Mapper;
|
13
|
22
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
14
|
23
|
import org.apache.poi.ss.usermodel.Row;
|
15
|
24
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
@@ -38,6 +47,19 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
|
38
|
47
|
|
39
|
48
|
@Autowired
|
40
|
49
|
private TpPhaseMapper tpPhaseMapper;
|
|
50
|
+
|
|
51
|
+ @Autowired
|
|
52
|
+ private TpBuildingMapper tpBuildingMapper;
|
|
53
|
+
|
|
54
|
+ @Autowired
|
|
55
|
+ private TpUnitMapper tpUnitMapper;
|
|
56
|
+
|
|
57
|
+ @Autowired
|
|
58
|
+ private TpLevelMapper tpLevelMapper;
|
|
59
|
+
|
|
60
|
+ @Autowired
|
|
61
|
+ private TpBuildingOwnerInfoMapper tpBuildingOwnerInfoMapper;
|
|
62
|
+
|
41
|
63
|
/**
|
42
|
64
|
* 获取整个小区的基础数据
|
43
|
65
|
*
|
|
@@ -157,16 +179,170 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
|
157
|
179
|
Integer communityId = userElement.getCommunityId();
|
158
|
180
|
|
159
|
181
|
//保存数据到表中--拆分数据
|
160
|
|
- String state = saveBuildingTreeData(communityId,list);
|
|
182
|
+ saveBuildingTreeData(communityId,list);
|
161
|
183
|
responseBean.addSuccess("success");
|
162
|
184
|
return responseBean;
|
163
|
185
|
}
|
164
|
186
|
|
165
|
|
- private String saveBuildingTreeData(Integer communityId, List<TpBuildingOwnerInfo> list) {
|
|
187
|
+ /**
|
|
188
|
+ * 获取树形数据
|
|
189
|
+ *
|
|
190
|
+ * @param communityId
|
|
191
|
+ * @param id
|
|
192
|
+ * @param treeType
|
|
193
|
+ * @return
|
|
194
|
+ */
|
|
195
|
+ @Override
|
|
196
|
+ public ResponseBean getTreeList(Integer communityId, Integer id, String treeType) {
|
|
197
|
+ ResponseBean responseBean = new ResponseBean();
|
|
198
|
+ List<Map<String,Object>> resultList = new ArrayList<>();
|
|
199
|
+ //获取区/期树形数据
|
|
200
|
+ if (treeType.equals("phase")){
|
|
201
|
+ QueryWrapper<TpPhase> queryWrapper = new QueryWrapper<>();
|
|
202
|
+ queryWrapper.eq("community_id",communityId);
|
|
203
|
+ List<TpPhase> list = tpPhaseMapper.selectList(queryWrapper);
|
|
204
|
+ list.stream().forEach(e -> {
|
|
205
|
+ Map<String,Object> map = new HashMap<>();
|
|
206
|
+ map.put("name",e.getName());
|
|
207
|
+ map.put("id",e.getId());
|
|
208
|
+ map.put("type","building");
|
|
209
|
+ resultList.add(map);
|
|
210
|
+ });
|
|
211
|
+ }else if (treeType.equals("building")){
|
|
212
|
+ QueryWrapper<TpBuilding> queryWrapper = new QueryWrapper<>();
|
|
213
|
+ queryWrapper.eq("community_id",communityId);
|
|
214
|
+ queryWrapper.eq("phase_id",id);
|
|
215
|
+ List<TpBuilding> list = tpBuildingMapper.selectList(queryWrapper);
|
|
216
|
+ list.stream().forEach(e -> {
|
|
217
|
+ Map<String,Object> map = new HashMap<>();
|
|
218
|
+ map.put("name",e.getName());
|
|
219
|
+ map.put("id",e.getId());
|
|
220
|
+ map.put("type","unit");
|
|
221
|
+ resultList.add(map);
|
|
222
|
+ });
|
|
223
|
+ }else if (treeType.equals("unit")){
|
|
224
|
+ QueryWrapper<TpUnit> queryWrapper = new QueryWrapper<>();
|
|
225
|
+ queryWrapper.eq("community_id",communityId);
|
|
226
|
+ queryWrapper.eq("building_id",id);
|
|
227
|
+ List<TpUnit> list = tpUnitMapper.selectList(queryWrapper);
|
|
228
|
+ list.stream().forEach(e -> {
|
|
229
|
+ Map<String,Object> map = new HashMap<>();
|
|
230
|
+ map.put("name",e.getName());
|
|
231
|
+ map.put("id",e.getId());
|
|
232
|
+ map.put("type","level");
|
|
233
|
+ resultList.add(map);
|
|
234
|
+ });
|
|
235
|
+ }else if (treeType.equals("level")){
|
|
236
|
+ QueryWrapper<TpLevel> queryWrapper = new QueryWrapper<>();
|
|
237
|
+ queryWrapper.eq("community_id",communityId);
|
|
238
|
+ queryWrapper.eq("unit_id",id);
|
|
239
|
+ List<TpLevel> list = tpLevelMapper.selectList(queryWrapper);
|
|
240
|
+ list.stream().forEach(e -> {
|
|
241
|
+ Map<String,Object> map = new HashMap<>();
|
|
242
|
+ map.put("name",e.getName());
|
|
243
|
+ map.put("id",e.getId());
|
|
244
|
+ map.put("type","roomNo");
|
|
245
|
+ resultList.add(map);
|
|
246
|
+ });
|
|
247
|
+ }else if (treeType.equals("roomNo")){
|
|
248
|
+ QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
|
|
249
|
+ queryWrapper.eq("community_id",communityId);
|
|
250
|
+ queryWrapper.eq("level_id",id);
|
|
251
|
+ List<TpBuildingOwnerInfo> list = tpBuildingOwnerInfoMapper.selectList(queryWrapper);
|
|
252
|
+ list.stream().forEach(e -> {
|
|
253
|
+ Map<String,Object> map = new HashMap<>();
|
|
254
|
+ map.put("name",e.getName());
|
|
255
|
+ map.put("id",e.getId());
|
|
256
|
+ map.put("type","end");
|
|
257
|
+ map.put("leaf",true);
|
|
258
|
+ resultList.add(map);
|
|
259
|
+ });
|
|
260
|
+ }
|
|
261
|
+ responseBean.addSuccess(resultList);
|
|
262
|
+ return responseBean;
|
|
263
|
+ }
|
|
264
|
+
|
|
265
|
+ private void saveBuildingTreeData(Integer communityId, List<TpBuildingOwnerInfo> list) {
|
166
|
266
|
String lastPhaseName = "";
|
167
|
|
- for (int i = 0; i < list.size(); i++){
|
|
267
|
+ String lastBuildingName = "";
|
|
268
|
+ String lastUnitName = "";
|
|
269
|
+ String lastLevelName = "";
|
|
270
|
+ String lastRoomNoName = "";
|
168
|
271
|
|
|
272
|
+ Integer lastPhaseId = null;
|
|
273
|
+ Integer lastBuildingId = null;
|
|
274
|
+ Integer lastUnitId = null;
|
|
275
|
+ Integer lastLevelId = null;
|
|
276
|
+
|
|
277
|
+ for (TpBuildingOwnerInfo tpBuildingOwnerInfo : list){
|
|
278
|
+ //插入期/区数据
|
|
279
|
+ if (!tpBuildingOwnerInfo.getPhaseName().equals(lastPhaseName)){
|
|
280
|
+ TpPhase tpPhase = new TpPhase();
|
|
281
|
+ tpPhase.setName(tpBuildingOwnerInfo.getPhaseName());
|
|
282
|
+ tpPhase.setCommunityId(communityId);
|
|
283
|
+ tpPhaseMapper.insert(tpPhase);
|
|
284
|
+ //重置Last
|
|
285
|
+ lastPhaseName = tpBuildingOwnerInfo.getPhaseName();
|
|
286
|
+ lastBuildingName = "";
|
|
287
|
+ lastUnitName = "";
|
|
288
|
+ lastLevelName = "";
|
|
289
|
+ lastRoomNoName = "";
|
|
290
|
+ lastPhaseId = tpPhase.getId();
|
|
291
|
+ }
|
|
292
|
+ //插入楼栋数据
|
|
293
|
+ if (!tpBuildingOwnerInfo.getBuildingName().equals(lastBuildingName)){
|
|
294
|
+ TpBuilding tpBuilding = new TpBuilding();
|
|
295
|
+ tpBuilding.setCommunityId(communityId);
|
|
296
|
+ tpBuilding.setPhaseId(lastPhaseId);
|
|
297
|
+ tpBuilding.setPhaseName(lastPhaseName);
|
|
298
|
+ tpBuilding.setName(tpBuildingOwnerInfo.getBuildingName());
|
|
299
|
+ tpBuildingMapper.insert(tpBuilding);
|
|
300
|
+ lastBuildingName = tpBuildingOwnerInfo.getBuildingName();
|
|
301
|
+ lastBuildingId = tpBuilding.getId();
|
|
302
|
+ }
|
|
303
|
+ //插入单元信息
|
|
304
|
+ if (!tpBuildingOwnerInfo.getUnitName().equals(lastUnitName)){
|
|
305
|
+ TpUnit tpUnit = new TpUnit();
|
|
306
|
+ tpUnit.setCommunityId(communityId);
|
|
307
|
+ tpUnit.setPhaseId(lastPhaseId);
|
|
308
|
+ tpUnit.setPhaseName(lastPhaseName);
|
|
309
|
+ tpUnit.setBuildingId(lastBuildingId);
|
|
310
|
+ tpUnit.setBuildingName(lastBuildingName);
|
|
311
|
+ tpUnit.setName(tpBuildingOwnerInfo.getUnitName());
|
|
312
|
+ tpUnitMapper.insert(tpUnit);
|
|
313
|
+ lastUnitName = tpBuildingOwnerInfo.getUnitName();
|
|
314
|
+ lastUnitId = tpUnit.getId();
|
|
315
|
+ }
|
|
316
|
+ //插入楼层信息
|
|
317
|
+ if (!tpBuildingOwnerInfo.getLevelName().equals(lastLevelName)){
|
|
318
|
+ TpLevel tpLevel = new TpLevel();
|
|
319
|
+ tpLevel.setCommunityId(communityId);
|
|
320
|
+ tpLevel.setPhaseId(lastPhaseId);
|
|
321
|
+ tpLevel.setPhaseName(lastPhaseName);
|
|
322
|
+ tpLevel.setBuildingId(lastBuildingId);
|
|
323
|
+ tpLevel.setBuildingName(lastBuildingName);
|
|
324
|
+ tpLevel.setUnitId(lastUnitId);
|
|
325
|
+ tpLevel.setUnitName(lastUnitName);
|
|
326
|
+ tpLevel.setName(tpBuildingOwnerInfo.getLevelName());
|
|
327
|
+ tpLevelMapper.insert(tpLevel);
|
|
328
|
+ lastLevelName = tpBuildingOwnerInfo.getLevelName();
|
|
329
|
+ lastLevelId = tpLevel.getId();
|
|
330
|
+ }
|
|
331
|
+ //插入房间号信息
|
|
332
|
+ if (!tpBuildingOwnerInfo.getName().equals(lastRoomNoName)){
|
|
333
|
+ TpBuildingOwnerInfo tpBuildingOwnerInfoNew = new TpBuildingOwnerInfo();
|
|
334
|
+ tpBuildingOwnerInfoNew.setCommunityId(communityId);
|
|
335
|
+ tpBuildingOwnerInfoNew.setPhaseId(lastPhaseId);
|
|
336
|
+ tpBuildingOwnerInfoNew.setPhaseName(lastPhaseName);
|
|
337
|
+ tpBuildingOwnerInfoNew.setBuildingId(lastBuildingId);
|
|
338
|
+ tpBuildingOwnerInfoNew.setBuildingName(lastBuildingName);
|
|
339
|
+ tpBuildingOwnerInfoNew.setUnitId(lastUnitId);
|
|
340
|
+ tpBuildingOwnerInfoNew.setUnitName(lastUnitName);
|
|
341
|
+ tpBuildingOwnerInfoNew.setLevelId(lastLevelId);
|
|
342
|
+ tpBuildingOwnerInfoNew.setLevelName(lastLevelName);
|
|
343
|
+ tpBuildingOwnerInfoNew.setName(tpBuildingOwnerInfo.getName());
|
|
344
|
+ tpBuildingOwnerInfoMapper.insert(tpBuildingOwnerInfoNew);
|
|
345
|
+ }
|
169
|
346
|
}
|
170
|
|
- return "";
|
171
|
347
|
}
|
172
|
348
|
}
|