王苗苗 2 tháng trước cách đây
mục cha
commit
f017ff3f20

+ 13 - 7
slibra-admin/src/main/java/com/slibra/web/controller/business/ExcelController.java

@@ -88,7 +88,7 @@ public class ExcelController extends BaseController {
      * @return
      */
     @GetMapping("/moreExcel2DB")
-//    @Transactional
+    @Transactional
     public String moreExcel2DB(){
         //Excel转JSON
         List<BZXQLHInfo> excelFormBZXQLH = getExcelFormBZXQLH();
@@ -136,12 +136,18 @@ public class ExcelController extends BaseController {
                 }
                 //有了泵站信息,处理其他逻辑
                 //再通过小区和楼号查询对应的数据,绑定关系
-                List<TNeighborhoodBuilding> tNeighborhoodBuildings = this.tNeighborhoodBuildingMapper.selectTNeighborhoodBuildingList(TNeighborhoodBuilding.builder().name(bzxqlhInfo.getBuildingName()).build());
-                if(!CollectionUtils.isEmpty(tNeighborhoodBuildings)){
-                    TNeighborhoodBuilding tNeighborhoodBuilding = tNeighborhoodBuildings.get(0);
-                    //泵关联小区楼号对象
-                    TPumpingStationNeighbourhoodNumber tPumpingStationNeighbourhoodNumber = TPumpingStationNeighbourhoodNumber.builder().pumpingStationId(pumpingStationId).neighborhoodId(tNeighborhoodBuilding.getNeighborhoodId()).neighborhoodBuildingId(tNeighborhoodBuilding.getId()).build();
-                    this.tPumpingStationNeighbourhoodNumberMapper.insertTPumpingStationNeighbourhoodNumber(tPumpingStationNeighbourhoodNumber);
+                //2024年12月31日18:28:22 这里不能直接通过楼号去查询,因为楼号很多都是重复的 通过小区查询、,因为小区名字是唯一的。
+                List<TNeighborhood> tNeighborhoods = this.tNeighborhoodMapper.selectTNeighborhoodList(TNeighborhood.builder().name(bzxqlhInfo.getNeighbourName()).build());
+                if(CollectionUtils.isEmpty(tNeighborhoods)){
+                    TNeighborhood tNeighborhood = tNeighborhoods.get(0);
+                    //通过小区ID和楼号名称【2者组合是唯一的】
+                    List<TNeighborhoodBuilding> tNeighborhoodBuildings = this.tNeighborhoodBuildingMapper.selectTNeighborhoodBuildingList(TNeighborhoodBuilding.builder().neighborhoodId(tNeighborhood.getId()).name(bzxqlhInfo.getBuildingName()).build());
+                    if(!CollectionUtils.isEmpty(tNeighborhoodBuildings)){
+                        TNeighborhoodBuilding tNeighborhoodBuilding = tNeighborhoodBuildings.get(0);
+                        //泵关联小区楼号对象
+                        TPumpingStationNeighbourhoodNumber tPumpingStationNeighbourhoodNumber = TPumpingStationNeighbourhoodNumber.builder().pumpingStationId(pumpingStationId).neighborhoodId(tNeighborhoodBuilding.getNeighborhoodId()).neighborhoodBuildingId(tNeighborhoodBuilding.getId()).build();
+                        this.tPumpingStationNeighbourhoodNumberMapper.insertTPumpingStationNeighbourhoodNumber(tPumpingStationNeighbourhoodNumber);
+                    }
                 }
             }
         }