|
@@ -604,14 +604,25 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
|
604
|
604
|
tpPhase.setName(tpBuildingOwnerInfo.getPhaseName());
|
605
|
605
|
tpPhase.setCommunityId(communityId);
|
606
|
606
|
tpPhase.setCreateDate(LocalDateTime.now());
|
607
|
|
- tpPhaseMapper.insert(tpPhase);
|
608
|
|
- //重置Last
|
609
|
|
- lastPhaseName = tpBuildingOwnerInfo.getPhaseName();
|
610
|
|
- lastBuildingName = "";
|
611
|
|
- lastUnitName = "";
|
612
|
|
- lastLevelName = "";
|
613
|
|
- lastRoomNoName = "";
|
614
|
|
- lastPhaseId = tpPhase.getId();
|
|
607
|
+
|
|
608
|
+ QueryWrapper<TpPhase> phaseQueryWrapper = new QueryWrapper<>();
|
|
609
|
+ phaseQueryWrapper.eq("community_id", communityId);
|
|
610
|
+ phaseQueryWrapper.eq("`NAME`", tpBuildingOwnerInfo.getPhaseName());
|
|
611
|
+ TpPhase selectOne = tpPhaseMapper.selectOne(phaseQueryWrapper);
|
|
612
|
+ // 判断是否存在库里
|
|
613
|
+ if (null != selectOne) {
|
|
614
|
+ lastPhaseName = selectOne.getName();
|
|
615
|
+ lastPhaseId = selectOne.getId();
|
|
616
|
+ } else {
|
|
617
|
+ tpPhaseMapper.insert(tpPhase);
|
|
618
|
+ //重置Last
|
|
619
|
+ lastPhaseName = tpBuildingOwnerInfo.getPhaseName();
|
|
620
|
+ lastBuildingName = "";
|
|
621
|
+ lastUnitName = "";
|
|
622
|
+ lastLevelName = "";
|
|
623
|
+ lastRoomNoName = "";
|
|
624
|
+ lastPhaseId = tpPhase.getId();
|
|
625
|
+ }
|
615
|
626
|
}
|
616
|
627
|
//插入楼栋数据
|
617
|
628
|
if (!tpBuildingOwnerInfo.getBuildingName().equals(lastBuildingName)){
|
|
@@ -621,9 +632,20 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
|
621
|
632
|
tpBuilding.setPhaseName(lastPhaseName);
|
622
|
633
|
tpBuilding.setName(tpBuildingOwnerInfo.getBuildingName());
|
623
|
634
|
tpBuilding.setCreateDate(LocalDateTime.now());
|
624
|
|
- tpBuildingMapper.insert(tpBuilding);
|
625
|
|
- lastBuildingName = tpBuildingOwnerInfo.getBuildingName();
|
626
|
|
- lastBuildingId = tpBuilding.getId();
|
|
635
|
+
|
|
636
|
+ QueryWrapper<TpBuilding> buildingQueryWrapper = new QueryWrapper<>();
|
|
637
|
+ buildingQueryWrapper.eq("community_id", communityId);
|
|
638
|
+ buildingQueryWrapper.eq("phase_id", lastPhaseId);
|
|
639
|
+ buildingQueryWrapper.eq("`name`", tpBuildingOwnerInfo.getBuildingName());
|
|
640
|
+ TpBuilding selectOne = tpBuildingMapper.selectOne(buildingQueryWrapper);
|
|
641
|
+ if (null != selectOne) {
|
|
642
|
+ lastBuildingName = selectOne.getName();
|
|
643
|
+ lastBuildingId = selectOne.getId();
|
|
644
|
+ } else {
|
|
645
|
+ tpBuildingMapper.insert(tpBuilding);
|
|
646
|
+ lastBuildingName = tpBuildingOwnerInfo.getBuildingName();
|
|
647
|
+ lastBuildingId = tpBuilding.getId();
|
|
648
|
+ }
|
627
|
649
|
}
|
628
|
650
|
//插入单元信息
|
629
|
651
|
if (!tpBuildingOwnerInfo.getUnitName().equals(lastUnitName)){
|
|
@@ -635,9 +657,22 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
|
635
|
657
|
tpUnit.setBuildingName(lastBuildingName);
|
636
|
658
|
tpUnit.setName(tpBuildingOwnerInfo.getUnitName());
|
637
|
659
|
tpUnit.setCreateDate(LocalDateTime.now());
|
638
|
|
- tpUnitMapper.insert(tpUnit);
|
639
|
|
- lastUnitName = tpBuildingOwnerInfo.getUnitName();
|
640
|
|
- lastUnitId = tpUnit.getId();
|
|
660
|
+
|
|
661
|
+ QueryWrapper<TpUnit> unitQueryWrapper = new QueryWrapper<>();
|
|
662
|
+ unitQueryWrapper.eq("community_id", communityId);
|
|
663
|
+ unitQueryWrapper.eq("phase_id", lastPhaseId);
|
|
664
|
+ unitQueryWrapper.eq("building_id", lastBuildingId);
|
|
665
|
+ unitQueryWrapper.eq("`name`",tpBuildingOwnerInfo.getUnitName());
|
|
666
|
+ TpUnit selectOne = tpUnitMapper.selectOne(unitQueryWrapper);
|
|
667
|
+ // 校验是否存在库里
|
|
668
|
+ if (null != selectOne) {
|
|
669
|
+ lastUnitName = selectOne.getName();
|
|
670
|
+ lastUnitId = selectOne.getId();
|
|
671
|
+ } else {
|
|
672
|
+ tpUnitMapper.insert(tpUnit);
|
|
673
|
+ lastUnitName = tpBuildingOwnerInfo.getUnitName();
|
|
674
|
+ lastUnitId = tpUnit.getId();
|
|
675
|
+ }
|
641
|
676
|
}
|
642
|
677
|
//插入楼层信息
|
643
|
678
|
if (!tpBuildingOwnerInfo.getLevelName().equals(lastLevelName)){
|
|
@@ -651,9 +686,23 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
|
651
|
686
|
tpLevel.setUnitName(lastUnitName);
|
652
|
687
|
tpLevel.setName(tpBuildingOwnerInfo.getLevelName());
|
653
|
688
|
tpLevel.setCreateDate(LocalDateTime.now());
|
654
|
|
- tpLevelMapper.insert(tpLevel);
|
655
|
|
- lastLevelName = tpBuildingOwnerInfo.getLevelName();
|
656
|
|
- lastLevelId = tpLevel.getId();
|
|
689
|
+
|
|
690
|
+ QueryWrapper<TpLevel> levelQueryWrapper = new QueryWrapper<>();
|
|
691
|
+ levelQueryWrapper.eq("community_id", communityId);
|
|
692
|
+ levelQueryWrapper.eq("phase_id", lastPhaseId);
|
|
693
|
+ levelQueryWrapper.eq("building_id", lastBuildingId);
|
|
694
|
+ levelQueryWrapper.eq("unit_id", lastUnitId);
|
|
695
|
+ levelQueryWrapper.eq("`name`", tpBuildingOwnerInfo.getLevelName());
|
|
696
|
+ TpLevel selectOne = tpLevelMapper.selectOne(levelQueryWrapper);
|
|
697
|
+ // 校验是否存在库里
|
|
698
|
+ if (null != selectOne) {
|
|
699
|
+ lastLevelName = selectOne.getName();
|
|
700
|
+ lastLevelId = selectOne.getId();
|
|
701
|
+ } else {
|
|
702
|
+ tpLevelMapper.insert(tpLevel);
|
|
703
|
+ lastLevelName = tpBuildingOwnerInfo.getLevelName();
|
|
704
|
+ lastLevelId = tpLevel.getId();
|
|
705
|
+ }
|
657
|
706
|
}
|
658
|
707
|
//插入房间号信息
|
659
|
708
|
if (!tpBuildingOwnerInfo.getRoomNoName().equals(lastRoomNoName)){
|
|
@@ -669,7 +718,18 @@ public class BuildingTreeServiceImpl implements BuildingTreeServiceI {
|
669
|
718
|
tpRoomNo.setLevelName(lastLevelName);
|
670
|
719
|
tpRoomNo.setName(tpBuildingOwnerInfo.getRoomNoName());
|
671
|
720
|
tpRoomNo.setCreateDate(LocalDateTime.now());
|
672
|
|
- tpRoomNoMapper.insert(tpRoomNo);
|
|
721
|
+
|
|
722
|
+ QueryWrapper<TpRoomNo> roomNoQueryWrapper = new QueryWrapper<>();
|
|
723
|
+ roomNoQueryWrapper.eq("community_id", communityId);
|
|
724
|
+ roomNoQueryWrapper.eq("phase_id", lastPhaseId);
|
|
725
|
+ roomNoQueryWrapper.eq("building_id", lastBuildingId);
|
|
726
|
+ roomNoQueryWrapper.eq("unit_id", lastUnitId);
|
|
727
|
+ roomNoQueryWrapper.eq("level_id", lastLevelId);
|
|
728
|
+ roomNoQueryWrapper.eq("`name`", tpBuildingOwnerInfo.getRoomNoName());
|
|
729
|
+ TpRoomNo selectOne = tpRoomNoMapper.selectOne(roomNoQueryWrapper);
|
|
730
|
+ if (null == selectOne) {
|
|
731
|
+ tpRoomNoMapper.insert(tpRoomNo);
|
|
732
|
+ }
|
673
|
733
|
}
|
674
|
734
|
}
|
675
|
735
|
}
|