dingxin hace 6 años
padre
commit
b3e303f1fa

+ 148
- 97
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BuildingTreeServiceImpl.java Ver fichero

@@ -71,6 +71,10 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
71 71
 	
72 72
 	@Autowired
73 73
 	private TaUserVerifyMapper taUserVerifyMapper;
74
+
75
+	@Autowired
76
+	private TpBuildingOwnerInfoMapper tpBuildingOwnerInfoMapper;
77
+
74 78
 	
75 79
 	/**
76 80
 	 * 获取整个小区的基础数据
@@ -293,6 +297,15 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
293 297
 		//楼栋
294 298
 		/*查询出期*/
295 299
 		if(type.equals("phase")) {
300
+			//是否存在同样的名字
301
+			QueryWrapper<TpPhase> tpPhaseQuery = new QueryWrapper<>();
302
+			tpPhaseQuery.eq("community_id",communityId);
303
+			tpPhaseQuery.eq("NAME",nodeNumber);
304
+			TpPhase phase= tpPhaseMapper.selectOne(tpPhaseQuery);
305
+			if (null!=phase){
306
+				responseBean.addError("节点名称已存在");
307
+				return responseBean;
308
+			}
296 309
 			TpPhase tpPhase= new TpPhase();
297 310
 					tpPhase.setCommunityId(communityId);
298 311
 					tpPhase.setName(nodeNumber);
@@ -301,21 +314,40 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
301 314
 		}
302 315
 		TpPhase	tpPhase= tpPhaseMapper.selectById(id);
303 316
 		if(type.equals("building")){
317
+			//是否存在同样的名字
318
+			QueryWrapper<TpBuilding> tpBuildingQuery = new QueryWrapper<>();
319
+			tpBuildingQuery.eq("community_id",communityId);
320
+			tpBuildingQuery.eq("phase_id",tpPhase.getId());
321
+			tpBuildingQuery.eq("phase_name",tpPhase.getName());
322
+			tpBuildingQuery.eq("name",nodeNumber);
323
+			TpBuilding building= tpBuildingMapper.selectOne(tpBuildingQuery);
324
+			if (null!=building){
325
+				responseBean.addError("节点名称已存在");
326
+				return responseBean;
327
+			}
304 328
 		 TpBuilding tpBuilding= new TpBuilding();
305 329
 					tpBuilding.setCommunityId(tpPhase.getCommunityId())
306 330
 						 .setPhaseId(tpPhase.getId())
307 331
 						 .setPhaseName(tpPhase.getName())
308 332
 						 .setName(nodeNumber)
309 333
 						 .setCreateDate(LocalDateTime.now());
310
-		 //判断书否为期
311
-
312 334
 			tpBuildingMapper.insert(tpBuilding);
313 335
 		}
314 336
 		//单元
315 337
 		//查询栋,维护单元
316
-
317 338
 		 TpBuilding selectTpBuilding= tpBuildingMapper.selectById(id);
318 339
 		if (type.equals("unit")){
340
+			// 校验节点名称
341
+			QueryWrapper<TpUnit> unitQuery=new QueryWrapper<>();
342
+			unitQuery.eq("community_id",selectTpBuilding.getCommunityId());
343
+			unitQuery.eq("phase_id",selectTpBuilding.getPhaseId());
344
+			unitQuery.eq("building_id",selectTpBuilding.getId());
345
+			unitQuery.eq("name",nodeNumber);
346
+			TpUnit unit= tpUnitMapper.selectOne(unitQuery);
347
+			if (null!=unit){
348
+				responseBean.addError("节点名称已存在");
349
+				return responseBean;
350
+			}
319 351
 		 TpUnit tpUnit= new TpUnit();
320 352
 				tpUnit.setCommunityId(selectTpBuilding.getCommunityId())
321 353
 						.setPhaseId(selectTpBuilding.getPhaseId())
@@ -323,7 +355,6 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
323 355
 						.setBuildingId(selectTpBuilding.getId())
324 356
 						.setName(nodeNumber)
325 357
 						.setCreateDate(LocalDateTime.now());
326
-		//判断是否为单
327 358
 		 	 tpUnitMapper.insert(tpUnit);
328 359
 		 }
329 360
 
@@ -331,6 +362,18 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
331 362
 		//查询单元,维护楼层
332 363
 		 TpUnit selectTpUnit= tpUnitMapper.selectById(id);
333 364
 		if(type.equals("level")){
365
+			//校验楼层名称
366
+			QueryWrapper<TpLevel>  levelQuery=new  QueryWrapper<>();
367
+			levelQuery.eq("community_id",selectTpUnit.getCommunityId());
368
+			levelQuery.eq("phase_id",selectTpUnit.getPhaseId());
369
+			levelQuery.eq("building_id",selectTpUnit.getBuildingId());
370
+			levelQuery.eq("unit_id",selectTpUnit.getId());
371
+			levelQuery.eq("name",nodeNumber);
372
+			TpLevel level= tpLevelMapper.selectOne(levelQuery);
373
+			if (null!=level){
374
+				responseBean.addError("节点名称已存在");
375
+				return responseBean;
376
+			}
334 377
 		 TpLevel tpLevel= new TpLevel();
335 378
 		tpLevel.setId(selectTpUnit.getId())
336 379
 				.setCommunityId(selectTpUnit.getCommunityId())
@@ -342,15 +385,23 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
342 385
 				.setUnitName(selectTpUnit.getName())
343 386
 				.setName(nodeNumber)
344 387
 				.setCreateDate(LocalDateTime.now());
345
-		//判断是否是楼层
346
-
347 388
 			 tpLevelMapper.insert(tpLevel);
348 389
 			}
349
-
350 390
 		 //房间号
351 391
 	 	TpLevel selectTpLevel= tpLevelMapper.selectById(id);
352 392
 		if(type.equals("roomNo")){
353
-		 TpRoomNo tpRoomNo= new TpRoomNo();
393
+			 QueryWrapper<TpRoomNo> tpRoomNoQuery= new QueryWrapper<>();
394
+			tpRoomNoQuery.eq("community_id",selectTpLevel.getCommunityId());
395
+			tpRoomNoQuery.eq("phase_id",selectTpLevel.getPhaseId());
396
+			tpRoomNoQuery.eq("building_id",selectTpLevel.getBuildingId());
397
+			tpRoomNoQuery.eq("unit_id",selectTpLevel.getUnitId());
398
+			tpRoomNoQuery.eq("name",nodeNumber);
399
+			TpRoomNo roomNo= tpRoomNoMapper.selectOne(tpRoomNoQuery);
400
+			if (null!=roomNo){
401
+				responseBean.addError("节点名称已存在");
402
+				return  responseBean;
403
+			}
404
+			TpRoomNo tpRoomNo= new TpRoomNo();
354 405
 			tpRoomNo.setCommunityId(selectTpLevel.getCommunityId())
355 406
 							.setPhaseId(selectTpLevel.getPhaseId())
356 407
 							.setPhaseName(selectTpLevel.getPhaseName())
@@ -362,8 +413,6 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
362 413
 							.setLevelName(selectTpLevel.getName())
363 414
 							.setName(nodeNumber)
364 415
 							.setCreateDate(LocalDateTime.now());
365
-
366
-
367 416
 			tpRoomNoMapper.insert(tpRoomNo);
368 417
 		}
369 418
 		responseBean.addSuccess("成功");
@@ -383,7 +432,11 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
383 432
 		String nodeNumber= object.getString("nodeNumber");
384 433
 
385 434
 		//审核是否通过
386
-		InfoPass(type,id);
435
+		  Boolean isA= InfoPass(type,id);
436
+		  if (isA==false){
437
+		  	responseBean.addError("需要先删除相关人员");
438
+		  	return responseBean;
439
+		  }
387 440
 		if (type.equals("end")) {
388 441
 			tpRoomNoMapper.deleteById(id);
389 442
 		}
@@ -413,18 +466,19 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
413 466
 			//查询楼层ID
414 467
 			Integer tpLevelID=null;
415 468
 
416
-			TpLevel levelevel = tpLevelMapper.selectOne(tpLevel);
417
-			QueryWrapper<TpRoomNo> Info = new QueryWrapper<>();
418
-			Info.eq("community_id", tpUnit.getCommunityId());
419
-			Info.eq("phase_id", tpUnit.getPhaseId());
420
-			Info.eq("building_id",tpUnit.getBuildingId());
421
-			Info.eq("unit_id", tpUnit.getId());
422
-			if (null!=levelevel) {
423
-				Info.eq("level_id", levelevel.getId());
469
+			List<TpLevel> levelevelList = tpLevelMapper.selectList(tpLevel);
470
+			for (TpLevel levelevel:levelevelList) {
471
+				QueryWrapper<TpRoomNo> Info = new QueryWrapper<>();
472
+				Info.eq("community_id", tpUnit.getCommunityId());
473
+				Info.eq("phase_id", tpUnit.getPhaseId());
474
+				Info.eq("building_id", tpUnit.getBuildingId());
475
+				Info.eq("unit_id", tpUnit.getId());
476
+				if (null != levelevel) {
477
+					Info.eq("level_id", levelevel.getId());
478
+				}
479
+				//先删除所有房间
480
+				tpRoomNoMapper.delete(Info);
424 481
 			}
425
-
426
-			//先删除所有房间
427
-			tpRoomNoMapper.delete(Info);
428 482
 			//再删除所有楼层
429 483
 			tpLevelMapper.delete(tpLevel);
430 484
 			//删除此单元
@@ -451,34 +505,36 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
451 505
 			//先删除所有房间
452 506
 			tpRoomNoMapper.delete(Info);
453 507
 			//先查询楼层
454
-			TpUnit unit= tpUnitMapper.selectOne(tpUnit);
508
+			List<TpUnit> unitList= tpUnitMapper.selectList(tpUnit);
455 509
 			QueryWrapper<TpLevel> tpLevel = new QueryWrapper<>();
456
-			if (null!=unit) {
457
-				tpLevel.eq("phase_id", unit.getPhaseId());
458
-				tpLevel.eq("community_id", unit.getCommunityId());
459
-				tpLevel.eq("building_id", unit.getBuildingId());
460
-				tpLevel.eq("unit_id", unit.getId());
461
-			}
462
-			//查询房间
463
-			List<TpLevel> levelList= tpLevelMapper.selectList(tpLevel);
464
-			QueryWrapper<TpRoomNo> tpRoomNoQueryWrapper = new QueryWrapper<>();
465
-			if (null!=levelList) {
466
-				for (TpLevel level:levelList) {
467
-					tpRoomNoQueryWrapper.eq("phase_id", level.getPhaseId());
468
-					tpRoomNoQueryWrapper.eq("community_id", level.getCommunityId());
469
-					tpRoomNoQueryWrapper.eq("building_id", level.getBuildingId());
470
-					tpRoomNoQueryWrapper.eq("unit_id", level.getUnitId());
471
-					tpRoomNoQueryWrapper.eq("level_id", level.getId());
472
-					//先删除所有房间
473
-					tpRoomNoMapper.delete(tpRoomNoQueryWrapper);
510
+			if (null!=unitList) {
511
+				for (TpUnit unit: unitList) {
512
+					tpLevel.eq("phase_id", unit.getPhaseId());
513
+					tpLevel.eq("community_id", unit.getCommunityId());
514
+					tpLevel.eq("building_id", unit.getBuildingId());
515
+					tpLevel.eq("unit_id", unit.getId());
516
+					//查询房间
517
+					List<TpLevel> levelList= tpLevelMapper.selectList(tpLevel);
518
+					QueryWrapper<TpRoomNo> tpRoomNoQueryWrapper = new QueryWrapper<>();
519
+					if (null!=levelList) {
520
+						for (TpLevel level:levelList) {
521
+							tpRoomNoQueryWrapper.eq("phase_id", level.getPhaseId());
522
+							tpRoomNoQueryWrapper.eq("community_id", level.getCommunityId());
523
+							tpRoomNoQueryWrapper.eq("building_id", level.getBuildingId());
524
+							tpRoomNoQueryWrapper.eq("unit_id", level.getUnitId());
525
+							tpRoomNoQueryWrapper.eq("level_id", level.getId());
526
+							//先删除所有房间
527
+							tpRoomNoMapper.delete(tpRoomNoQueryWrapper);
528
+						}
474 529
 				}
475 530
 			}
476 531
 
477
-			//再删除所有楼层
532
+			}
533
+			//删除所有楼层
478 534
 			tpLevelMapper.delete(tpLevel);
479 535
 			//删除此单元
480 536
 			tpUnitMapper.delete(tpUnit);
481
-			//判断是否为单
537
+			//删除栋
482 538
 			tpBuildingMapper.deleteById(id);
483 539
 		}
484 540
 
@@ -504,16 +560,18 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
504 560
 					tpLevel.eq("unit_id", unit.getId());
505 561
 
506 562
 					//查询房间
507
-					TpLevel level= tpLevelMapper.selectOne(tpLevel);
508
-					if (null!=level) {
509
-						QueryWrapper<TpRoomNo> tpRoomNoQueryWrapper = new QueryWrapper<>();
510
-						tpRoomNoQueryWrapper.eq("phase_id", level.getPhaseId());
511
-						tpRoomNoQueryWrapper.eq("community_id", level.getCommunityId());
512
-						tpRoomNoQueryWrapper.eq("building_id", level.getBuildingId());
513
-						tpRoomNoQueryWrapper.eq("unit_id", level.getUnitId());
514
-						tpRoomNoQueryWrapper.eq("level_id", level.getId());
515
-						//先删除所有房间
516
-						tpRoomNoMapper.delete(tpRoomNoQueryWrapper);
563
+					List<TpLevel> levelList= tpLevelMapper.selectList(tpLevel);
564
+					if (null!=levelList) {
565
+						for (TpLevel level :levelList) {
566
+							QueryWrapper<TpRoomNo> tpRoomNoQueryWrapper = new QueryWrapper<>();
567
+							tpRoomNoQueryWrapper.eq("phase_id", level.getPhaseId());
568
+							tpRoomNoQueryWrapper.eq("community_id", level.getCommunityId());
569
+							tpRoomNoQueryWrapper.eq("building_id", level.getBuildingId());
570
+							tpRoomNoQueryWrapper.eq("unit_id", level.getUnitId());
571
+							tpRoomNoQueryWrapper.eq("level_id", level.getId());
572
+							//先删除所有房间
573
+							tpRoomNoMapper.delete(tpRoomNoQueryWrapper);
574
+						}
517 575
 				}
518 576
 					//再删除所有楼层
519 577
 					tpLevelMapper.delete(tpLevel);
@@ -622,7 +680,7 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
622 680
 		}
623 681
 	}
624 682
 	//删除当前节点判断是否有审核通过的
625
-	private ResponseBean InfoPass(String type,Integer id ) {
683
+	private boolean InfoPass(String type,Integer id ) {
626 684
 		ResponseBean responseBean = new ResponseBean();
627 685
 		if (type.equals("end")) {
628 686
 			//判断书否有已审核人员
@@ -636,67 +694,60 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
636 694
 					.eq("room_no_id", id)
637 695
 					.eq("verify_status", 1);
638 696
 			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
639
-			if (null != taUserVerifyList) {
640
-				responseBean.addError("不可删除审核已通过人员");
641
-				return responseBean;
697
+			if (null != taUserVerifyList && taUserVerifyList.size()>0) {
698
+				return false;
642 699
 			}
643 700
 		}
644 701
 		if (type.equals("roomNo")) {
645 702
 			TpLevel tpLevel = tpLevelMapper.selectById(id);
646
-			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
647
-			taUserVerify.eq("community_id", tpLevel.getCommunityId())
648
-					.eq("phase_id", tpLevel.getPhaseId())
649
-					.eq("building_id", tpLevel.getBuildingId())
650
-					.eq("unit_id", tpLevel.getUnitId())
651
-					.eq("level_id", tpLevel.getId())
652
-					.eq("verify_status", 1);
653
-			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
654
-			if (null != taUserVerifyList) {
655
-				responseBean.addError("不可删除审核已通过人员");
656
-				return responseBean;
703
+			QueryWrapper<TpBuildingOwnerInfo> tpBuildingOwnerInfo = new QueryWrapper<>();
704
+			 tpBuildingOwnerInfo.eq("community_id", tpLevel.getCommunityId())
705
+								.eq("phase_id", tpLevel.getPhaseId())
706
+								.eq("building_id", tpLevel.getBuildingId())
707
+								.eq("unit_id", tpLevel.getUnitId())
708
+								.eq("level_id", tpLevel.getId())
709
+								.eq("verify_status", 1);
710
+			List<TpBuildingOwnerInfo> ifoBuid = tpBuildingOwnerInfoMapper .selectList(tpBuildingOwnerInfo);
711
+			if (null != ifoBuid && ifoBuid.size()>0) {
712
+				return false;
657 713
 			}
658 714
 		}
659 715
 		if (type.equals("level")) {
660 716
 			TpUnit tpUnit = tpUnitMapper.selectById(id);
661
-			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
662
-			taUserVerify.eq("community_id", tpUnit.getCommunityId())
663
-					.eq("phase_id", tpUnit.getPhaseId())
664
-					.eq("building_id", tpUnit.getBuildingId())
665
-					.eq("verify_status", 1);
666
-			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
667
-			if (null != taUserVerifyList) {
668
-				responseBean.addError("不可删除审核已通过人员");
669
-				return responseBean;
717
+			QueryWrapper<TpBuildingOwnerInfo> tpBuildingOwnerInfo = new QueryWrapper<>();
718
+			 tpBuildingOwnerInfo.eq("community_id", tpUnit.getCommunityId())
719
+								.eq("phase_id", tpUnit.getPhaseId())
720
+								.eq("building_id", tpUnit.getBuildingId())
721
+								.eq("verify_status", 1);
722
+			List<TpBuildingOwnerInfo> ifoBuid = tpBuildingOwnerInfoMapper.selectList(tpBuildingOwnerInfo);
723
+			if (null != ifoBuid && ifoBuid.size()>0) {
724
+				return false;
670 725
 			}
671 726
 		}
672 727
 		if (type.equals("unit")) {
673 728
 			//判断书否有已审核人员
674 729
 			TpBuilding tpBuilding = tpBuildingMapper.selectById(id);
675
-			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
676
-			taUserVerify.eq("community_id", tpBuilding.getCommunityId())
677
-					.eq("phase_id", tpBuilding.getPhaseId())
678
-					.eq("building_id", tpBuilding.getId())
679
-					.eq("verify_status", 1);
680
-			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
681
-			if (null != taUserVerifyList) {
682
-				responseBean.addError("不可删除审核已通过人员");
683
-
684
-				return responseBean;
730
+			QueryWrapper<TpBuildingOwnerInfo> tpBuildingOwnerInfo = new QueryWrapper<>();
731
+			 tpBuildingOwnerInfo.eq("community_id", tpBuilding.getCommunityId())
732
+								.eq("phase_id", tpBuilding.getPhaseId())
733
+								.eq("building_id", tpBuilding.getId())
734
+								.eq("verify_status", 1);
735
+			List<TpBuildingOwnerInfo> ifoBuid = tpBuildingOwnerInfoMapper.selectList(tpBuildingOwnerInfo);
736
+			if (null != ifoBuid && ifoBuid.size()>0) {
737
+				return false;
685 738
 			}
686 739
 		}
687 740
 		if (type.equals("building")) {
688 741
 			TpPhase phase = tpPhaseMapper.selectById(id);
689
-			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
690
-			taUserVerify.eq("community_id", phase.getCommunityId())
691
-					.eq("phase_id", phase.getId())
692
-					.eq("verify_status", 1);
693
-			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
694
-			if (null != taUserVerifyList) {
695
-				responseBean.addError("不可删除审核已通过人员");
696
-				return responseBean;
742
+			QueryWrapper<TpBuildingOwnerInfo> tpBuildingOwnerInfo = new QueryWrapper<>();
743
+			 tpBuildingOwnerInfo.eq("community_id", phase.getCommunityId())
744
+								.eq("phase_id", phase.getId())
745
+								.eq("verify_status", 1);
746
+			List<TpBuildingOwnerInfo> ifoBuid = tpBuildingOwnerInfoMapper.selectList(tpBuildingOwnerInfo);
747
+			if (null != ifoBuid && ifoBuid.size()>0) {
748
+				return false;
697 749
 			}
698 750
 		}
699
-		responseBean.addError("成功");
700
-		return responseBean;
751
+		return true;
701 752
 	}
702 753
 }

+ 12
- 4
VUECODE/smart-property-manage/src/views/building/buildingdata/index.vue Ver fichero

@@ -96,11 +96,18 @@ export default {
96 96
       aAddNode(id){
97 97
       // 添加当前节点
98 98
       this.$store.dispatch('AddNode', this.treeQuery).then((res) => {
99
-         
100
-          
99
+         console.log('res.code',res)
100
+        if(res.code=='1'){
101
+        this.$message({
102
+          showClose: true,
103
+          message: res.message,
104
+          type: 'warning'
105
+        })
106
+        return
107
+        }   
101 108
           this.$router.go(0)
102 109
            
103
-           this.suo()
110
+          //  this.suo()
104 111
 
105 112
       }).catch(() => {
106 113
         console.log('error addNode')
@@ -119,10 +126,11 @@ export default {
119 126
       console.log('当前名称',data.name)
120 127
       console.log('当前类型',data.type)
121 128
       this.$store.dispatch('DeleteNode', this.treeQuery).then((res) => {
129
+         location.reload()
130
+        // this.liste=[]    
122 131
       }).catch(() => {
123 132
         console.log('error addNode')
124 133
       })
125
-      location.reload()
126 134
       },
127 135
     ...mapActions('buildingTree', [
128 136
       'BuildingTreeList'