dingxin 6 years ago
parent
commit
283aae3d7e

+ 172
- 61
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BuildingTreeServiceImpl.java View File

@@ -7,18 +7,10 @@ import com.community.commom.constant.Constant;
7 7
 import com.community.commom.mode.ResponseBean;
8 8
 import com.community.commom.session.UserElement;
9 9
 import com.community.commom.utils.AccountValidatorUtil;
10
-import com.community.huiju.dao.TpBuildingMapper;
11
-import com.community.huiju.dao.TpBuildingOwnerInfoMapper;
12
-import com.community.huiju.dao.TpLevelMapper;
13
-import com.community.huiju.dao.TpPhaseMapper;
14
-import com.community.huiju.dao.TpUnitMapper;
15
-import com.community.huiju.model.TaUser;
16
-import com.community.huiju.model.TpBuilding;
17
-import com.community.huiju.model.TpBuildingOwnerInfo;
18
-import com.community.huiju.model.TpLevel;
19
-import com.community.huiju.model.TpPhase;
20
-import com.community.huiju.model.TpUnit;
10
+import com.community.huiju.dao.*;
11
+import com.community.huiju.model.*;
21 12
 import com.community.huiju.service.BuildingTreeServiceI;
13
+import jdk.nashorn.internal.ir.IfNode;
22 14
 import org.apache.ibatis.annotations.Mapper;
23 15
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
24 16
 import org.apache.poi.ss.usermodel.Row;
@@ -60,6 +52,8 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
60 52
 	
61 53
 	@Autowired
62 54
 	private TpBuildingOwnerInfoMapper tpBuildingOwnerInfoMapper;
55
+	@Autowired
56
+	private TaUserVerifyMapper taUserVerifyMapper;
63 57
 	
64 58
 	/**
65 59
 	 * 获取整个小区的基础数据
@@ -357,12 +351,13 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
357 351
 			tpBuildingOwnerInfoMapper.insert(tpBuildingOwnerInfo);
358 352
 		}
359 353
 		responseBean.addSuccess("成功");
360
-		return null;
354
+		return responseBean;
361 355
 	}
362 356
 
363 357
 	@Override
364 358
 	public ResponseBean deleteNode(String parameter, Integer communityId) {
365 359
 		ResponseBean responseBean= new ResponseBean();
360
+		//注意刪除当前节点,根据type判断当前节点的位置,删除时先删除当前节点的最小节点。
366 361
 		JSONObject  object= JSONObject.parseObject(parameter);
367 362
 		//当前节点id
368 363
 		Integer id= object.getInteger("id");
@@ -370,13 +365,12 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
370 365
 		String type= object.getString("type");
371 366
 		//当前输入的节点内容
372 367
 		String nodeNumber= object.getString("nodeNumber");
373
-		if(type.equals("end")){
368
+
369
+		//审核是否通过
370
+		InfoPass(type,id);
371
+		if (type.equals("end")) {
374 372
 			tpBuildingOwnerInfoMapper.deleteById(id);
375 373
 		}
376
-
377
-
378
-
379
-
380 374
 		//删除楼层
381 375
 		if(type.equals("roomNo")){
382 376
 			TpLevel tpLevel= tpLevelMapper.selectById(id);
@@ -388,7 +382,6 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
388 382
 			Info.eq("level_id", tpLevel.getId());
389 383
 			tpBuildingOwnerInfoMapper.delete(Info);
390 384
 			tpLevelMapper.deleteById(id);
391
-			//删除楼层下面所有的房间
392 385
 		}
393 386
 
394 387
 		//删除单元
@@ -400,15 +393,20 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
400 393
 			tpLevel.eq("community_id", tpUnit.getCommunityId());
401 394
 			tpLevel.eq("building_id", tpUnit.getBuildingId());
402 395
 			tpLevel.eq("unit_id", tpUnit.getId());
403
-			tpLevel.eq("name", nodeNumber);
404 396
 			//删除单元-楼层-下的房间
405
-			//查询房间号
397
+			//查询楼层ID
398
+			Integer tpLevelID=null;
399
+
400
+			TpLevel levelevel = tpLevelMapper.selectOne(tpLevel);
406 401
 			QueryWrapper<TpBuildingOwnerInfo> Info = new QueryWrapper<>();
407 402
 			Info.eq("community_id", tpUnit.getCommunityId());
408 403
 			Info.eq("phase_id", tpUnit.getPhaseId());
409 404
 			Info.eq("building_id",tpUnit.getBuildingId());
410 405
 			Info.eq("unit_id", tpUnit.getId());
411
-//			Info.eq("level_id", tpLevelToo.getId());
406
+			if (null!=levelevel) {
407
+				Info.eq("level_id", levelevel.getId());
408
+			}
409
+
412 410
 			//先删除所有房间
413 411
 			tpBuildingOwnerInfoMapper.delete(Info);
414 412
 			//再删除所有楼层
@@ -418,59 +416,94 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
418 416
 
419 417
 		}
420 418
 		//删除楼栋
421
-		if (type.equals("building")){
419
+		if (type.equals("unit")){
422 420
 			TpBuilding tpBuilding= tpBuildingMapper.selectById(id);
423 421
 			//删除单元-楼层-房间
424 422
 			QueryWrapper<TpUnit> tpUnit = new QueryWrapper<>();
425 423
 			tpUnit.eq("community_id", tpBuilding.getCommunityId());
426 424
 			tpUnit.eq("phase_id", tpBuilding.getPhaseId());
427
-			tpUnit.eq("building_id",tpBuilding.getId());
428
-			tpUnit.eq("unit_id", tpBuilding.getId());
429
-			tpUnit.eq("level_id", tpBuilding.getId());
430
-			//根据楼层
431
-			TpUnit unit= tpUnitMapper.selectById(id);
432
-			QueryWrapper<TpLevel> tpLevel = new QueryWrapper<>();
433
-			tpLevel.eq("phase_id", unit.getPhaseId());
434
-			tpLevel.eq("community_id", unit.getCommunityId());
435
-			tpLevel.eq("building_id", unit.getBuildingId());
436
-			tpLevel.eq("unit_id", unit.getId());
437
-			tpLevel.eq("name", nodeNumber);
425
+			tpUnit.eq("building_id", tpBuilding.getId());
438 426
 
439
-			//删除单元-楼层-下的房间
440
-			TpLevel tpLevelToo= tpLevelMapper.selectById(id);
441
-			QueryWrapper<TpBuildingOwnerInfo> Info = new QueryWrapper<>();
442
-			Info.eq("community_id", tpLevelToo.getCommunityId());
443
-			Info.eq("phase_id", tpLevelToo.getPhaseId());
444
-			Info.eq("building_id",tpLevelToo.getBuildingId());
445
-			Info.eq("unit_id", tpLevelToo.getUnitId());
446
-			Info.eq("level_id", tpLevelToo.getId());
447
-			//先删除所有房间
448
-			tpBuildingOwnerInfoMapper.delete(Info);
427
+			//先查询楼层
428
+			TpUnit unit= tpUnitMapper.selectOne(tpUnit);
429
+			QueryWrapper<TpLevel> tpLevel = new QueryWrapper<>();
430
+			if (null!=unit) {
431
+				tpLevel.eq("phase_id", unit.getPhaseId());
432
+				tpLevel.eq("community_id", unit.getCommunityId());
433
+				tpLevel.eq("building_id", unit.getBuildingId());
434
+				tpLevel.eq("unit_id", unit.getId());
435
+			}
436
+			//查询房间
437
+			List<TpLevel> levelList= tpLevelMapper.selectList(tpLevel);
438
+			QueryWrapper<TpBuildingOwnerInfo> tpBuildingOwnerInfo = new QueryWrapper<>();
439
+			if (null!=levelList) {
440
+				for (TpLevel level:levelList) {
441
+					tpBuildingOwnerInfo.eq("phase_id", level.getPhaseId());
442
+					tpBuildingOwnerInfo.eq("community_id", level.getCommunityId());
443
+					tpBuildingOwnerInfo.eq("building_id", level.getBuildingId());
444
+					tpBuildingOwnerInfo.eq("unit_id", level.getUnitId());
445
+					tpBuildingOwnerInfo.eq("level_id", level.getId());
446
+					//先删除所有房间
447
+					tpBuildingOwnerInfoMapper.delete(tpBuildingOwnerInfo);
448
+				}
449
+			}
449 450
 			//再删除所有楼层
450 451
 			tpLevelMapper.delete(tpLevel);
451 452
 			//删除此单元
452
-			tpUnitMapper.deleteById(id);
453
-
454
-
455
-
453
+			tpUnitMapper.delete(tpUnit);
454
+			//判断是否为单
455
+			tpBuildingMapper.deleteById(id);
456
+		}
456 457
 
458
+		if (type.equals("building")){
459
+			TpPhase phase= tpPhaseMapper.selectById(id);
457 460
 
461
+			TpBuilding tpBuilding= tpBuildingMapper.selectById(phase.getId());
462
+			//删除单元-楼层-房间
463
+			QueryWrapper<TpUnit> tpUnit = new QueryWrapper<>();
464
+			if (null!=tpBuilding) {
465
+				tpUnit.eq("community_id", tpBuilding.getCommunityId());
466
+				tpUnit.eq("phase_id", tpBuilding.getPhaseId());
467
+				tpUnit.eq("building_id", tpBuilding.getId());
468
+			}
469
+			//先查询楼层
470
+			List<TpUnit> unitList= tpUnitMapper.selectList(tpUnit);
471
+			QueryWrapper<TpLevel> tpLevel = new QueryWrapper<>();
472
+			if (null!=unitList) {
473
+				for (TpUnit unit:unitList) {
474
+					tpLevel.eq("phase_id", unit.getPhaseId());
475
+					tpLevel.eq("community_id", unit.getCommunityId());
476
+					tpLevel.eq("building_id", unit.getBuildingId());
477
+					tpLevel.eq("unit_id", unit.getId());
458 478
 
459
-			//判断是否为单
479
+					//查询房间
480
+					TpLevel level= tpLevelMapper.selectOne(tpLevel);
481
+					if (null!=level) {
482
+						QueryWrapper<TpBuildingOwnerInfo> tpBuildingOwnerInfo = new QueryWrapper<>();
483
+						tpBuildingOwnerInfo.eq("phase_id", level.getPhaseId());
484
+						tpBuildingOwnerInfo.eq("community_id", level.getCommunityId());
485
+						tpBuildingOwnerInfo.eq("building_id", level.getBuildingId());
486
+						tpBuildingOwnerInfo.eq("unit_id", level.getUnitId());
487
+						tpBuildingOwnerInfo.eq("level_id", level.getId());
488
+						//先删除所有房间
489
+						tpBuildingOwnerInfoMapper.delete(tpBuildingOwnerInfo);
490
+				}
491
+					//再删除所有楼层
492
+					tpLevelMapper.delete(tpLevel);
493
+			 }
494
+			}
495
+			//删除此单元
460 496
 			tpUnitMapper.delete(tpUnit);
497
+			//删除栋
498
+			QueryWrapper<TpBuilding> building= new QueryWrapper<>();
499
+			tpLevel.eq("phase_id", phase.getId());
500
+			tpLevel.eq("community_id", phase.getCommunityId());
501
+			tpBuildingMapper.delete(building);
502
+			//删除整个期
503
+			tpPhaseMapper.deleteById(id);
461 504
 		}
462
-
463
-//		if(type.equals("building")){
464
-//
465
-//			QueryWrapper<TpBuilding> tpBuilding = new QueryWrapper<>();
466
-//			tpBuilding.eq("phase_id", tpPhase.getId());
467
-//			tpBuilding.eq("community_id", tpPhase.getCommunityId());
468
-//			tpBuilding.eq("phase_id", tpPhase.getId());
469
-//			tpBuilding.eq("name", nodeNumber);
470
-//			tpBuildingMapper.delete(tpBuilding);
471
-//		}
472
-
473
-		return null;
505
+		responseBean.addSuccess("成功");
506
+		return responseBean;
474 507
 	}
475 508
 
476 509
 	private void saveBuildingTreeData(Integer communityId, List<TpBuildingOwnerInfo> list) {
@@ -557,9 +590,87 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
557 590
 				tpBuildingOwnerInfoNew.setLevelName(lastLevelName);
558 591
 				tpBuildingOwnerInfoNew.setName(tpBuildingOwnerInfo.getName());
559 592
 				tpBuildingOwnerInfoNew.setCreateDate(LocalDateTime.now());
560
-				tpBuildingOwnerInfoNew.setTreeStatus("1");
593
+				tpBuildingOwnerInfoNew.setTreeStatus(1);
561 594
 				tpBuildingOwnerInfoMapper.insert(tpBuildingOwnerInfoNew);
562 595
 			}
563 596
 		}
564 597
 	}
598
+	//删除当前节点判断是否有审核通过的
599
+	private ResponseBean InfoPass(String type,Integer id ) {
600
+		ResponseBean responseBean = new ResponseBean();
601
+		if (type.equals("end")) {
602
+			//判断书否有已审核人员
603
+			TpBuildingOwnerInfo info = tpBuildingOwnerInfoMapper.selectById(id);
604
+			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
605
+			taUserVerify.eq("community_id", info.getCommunityId())
606
+					.eq("phase_id", info.getPhaseId())
607
+					.eq("building_id", info.getBuildingId())
608
+					.eq("unit_id", info.getUnitId())
609
+					.eq("level_id", info.getLevelId())
610
+					.eq("room_no_id", id)
611
+					.eq("verify_status", 1);
612
+			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
613
+			if (null != taUserVerifyList) {
614
+				responseBean.addError("不可删除审核已通过人员");
615
+				return responseBean;
616
+			}
617
+		}
618
+		if (type.equals("roomNo")) {
619
+			TpLevel tpLevel = tpLevelMapper.selectById(id);
620
+			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
621
+			taUserVerify.eq("community_id", tpLevel.getCommunityId())
622
+					.eq("phase_id", tpLevel.getPhaseId())
623
+					.eq("building_id", tpLevel.getBuildingId())
624
+					.eq("unit_id", tpLevel.getUnitId())
625
+					.eq("level_id", tpLevel.getId())
626
+					.eq("verify_status", 1);
627
+			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
628
+			if (null != taUserVerifyList) {
629
+				responseBean.addError("不可删除审核已通过人员");
630
+				return responseBean;
631
+			}
632
+		}
633
+		if (type.equals("level")) {
634
+			TpUnit tpUnit = tpUnitMapper.selectById(id);
635
+			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
636
+			taUserVerify.eq("community_id", tpUnit.getCommunityId())
637
+					.eq("phase_id", tpUnit.getPhaseId())
638
+					.eq("building_id", tpUnit.getBuildingId())
639
+					.eq("verify_status", 1);
640
+			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
641
+			if (null != taUserVerifyList) {
642
+				responseBean.addError("不可删除审核已通过人员");
643
+				return responseBean;
644
+			}
645
+		}
646
+		if (type.equals("unit")) {
647
+			//判断书否有已审核人员
648
+			TpBuilding tpBuilding = tpBuildingMapper.selectById(id);
649
+			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
650
+			taUserVerify.eq("community_id", tpBuilding.getCommunityId())
651
+					.eq("phase_id", tpBuilding.getPhaseId())
652
+					.eq("building_id", tpBuilding.getId())
653
+					.eq("verify_status", 1);
654
+			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
655
+			if (null != taUserVerifyList) {
656
+				responseBean.addError("不可删除审核已通过人员");
657
+
658
+				return responseBean;
659
+			}
660
+		}
661
+		if (type.equals("building")) {
662
+			TpPhase phase = tpPhaseMapper.selectById(id);
663
+			QueryWrapper<TaUserVerify> taUserVerify = new QueryWrapper<>();
664
+			taUserVerify.eq("community_id", phase.getCommunityId())
665
+					.eq("phase_id", phase.getId())
666
+					.eq("verify_status", 1);
667
+			List<TaUserVerify> taUserVerifyList = taUserVerifyMapper.selectList(taUserVerify);
668
+			if (null != taUserVerifyList) {
669
+				responseBean.addError("不可删除审核已通过人员");
670
+				return responseBean;
671
+			}
672
+		}
673
+		responseBean.addError("成功");
674
+		return responseBean;
675
+	}
565 676
 }