Эх сурвалжийг харах

1.获取精简的小区接口 改成增加通过泵站获取关联的小区和楼号以及选择情况 2.给泵站关联小区楼号接口调整

王苗苗 1 долоо хоног өмнө
parent
commit
088492f358

+ 3 - 2
slibra-admin/src/main/java/com/slibra/web/controller/business/TPumpingStationController.java

@@ -124,12 +124,13 @@ public class TPumpingStationController extends BaseController
 
     /**
      * 获取所有的小区(简单信息 没有查询复杂数据)
+     * 2024年11月19日17:31:38 逻辑调整:前端再把对应的泵站ID传过来,然后查询绑定的小区楼号相关的信息
      * @return
      */
     @GetMapping("/getSimpleNeighbourhoodList")
     public R<List<TNeighborhood>> getSimpleNeighbourhoodList(TNeighborhood tNeighborhood){
         log.info("进入了 获取小区列表基本信息 接口");
-        return R.ok(this.tNeighborhoodMapper.selectTNeighborhoodList(tNeighborhood));
+        return R.ok(this.tPumpingStationService.getSimpleNeighbourhoodList(tNeighborhood));
     }
 
 
@@ -160,7 +161,7 @@ public class TPumpingStationController extends BaseController
      * @return
      */
     @PostMapping("/addPumpingStationAndNeighbourhoodBuildings")
-    public R<String> addPumpingStationAndNeighbourhoodBuildings(@RequestBody List<NeighbourhoodNumberAndAddFlag> req){
+    public R<String> addPumpingStationAndNeighbourhoodBuildings(@RequestBody List<TNeighborhood> req){
         log.info("进入了 给泵站关联小区的楼号 接口,请求参数为{}", JSON.toJSONString(req));
         return R.ok(this.tPumpingStationService.addPumpingStationAndNeighbourhoodBuildings(req));
     }

+ 7 - 0
slibra-system/src/main/java/com/slibra/business/domain/TNeighborhood.java

@@ -1,6 +1,7 @@
 package com.slibra.business.domain;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.slibra.business.res.NeighbourhoodNumberAndAddFlag;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -78,10 +79,16 @@ public class TNeighborhood extends BaseEntity
     //区县的名字
     private String countryName;
 
+    //关联的楼号和状态
+    private List<NeighbourhoodNumberAndAddFlag> neighbourhoodNumberAndAddFlags;
+
 
     //请求参数
     private List<String> buildingNameList;
 
+    //请求参数
+    private Long pumpingStationId;
+
 
 
 

+ 3 - 0
slibra-system/src/main/java/com/slibra/business/res/NeighbourhoodNumberAndAddFlag.java

@@ -1,6 +1,7 @@
 package com.slibra.business.res;
 
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -17,9 +18,11 @@ public class NeighbourhoodNumberAndAddFlag {
 //    private Long id;
 
     //泵站ID
+    @JsonIgnore
     private Long pumpingStationId;
 
     //小区ID
+    @JsonIgnore
     private Long neighbourhoodId;
 
     //楼号ID

+ 25 - 0
slibra-system/src/main/java/com/slibra/business/res/PumpingNeighbourNumber.java

@@ -0,0 +1,25 @@
+//package com.slibra.business.res;
+//
+//import lombok.AllArgsConstructor;
+//import lombok.Builder;
+//import lombok.Data;
+//import lombok.NoArgsConstructor;
+//
+//import java.util.List;
+//
+////泵站小区楼号同意返回和请求对象
+//@Builder
+//@Data
+//@AllArgsConstructor
+//@NoArgsConstructor
+//public class PumpingNeighbourNumber {
+//
+//    //小区ID
+//    private Long neighbourId;
+//
+//    //小区名称
+//    private String neighbourName;
+//
+//    //关联的楼号和状态
+//    private List<NeighbourhoodNumberAndAddFlag> neighbourhoodNumberAndAddFlags;
+//}

+ 5 - 1
slibra-system/src/main/java/com/slibra/business/service/ITPumpingStationService.java

@@ -1,6 +1,8 @@
 package com.slibra.business.service;
 
 import java.util.List;
+
+import com.slibra.business.domain.TNeighborhood;
 import com.slibra.business.domain.TPumpingStation;
 import com.slibra.business.req.NeighbourhoodNumberAndAddFlagReq;
 import com.slibra.business.res.NeighbourhoodNumberAndAddFlag;
@@ -63,5 +65,7 @@ public interface ITPumpingStationService
 
     List<NeighbourhoodNumberAndAddFlag> getBuildingsAndFlagByID2(NeighbourhoodNumberAndAddFlagReq req);
 
-    String addPumpingStationAndNeighbourhoodBuildings(List<NeighbourhoodNumberAndAddFlag> req);
+    String addPumpingStationAndNeighbourhoodBuildings(List<TNeighborhood> req);
+
+    List<TNeighborhood> getSimpleNeighbourhoodList(TNeighborhood tNeighborhood);
 }

+ 79 - 28
slibra-system/src/main/java/com/slibra/business/service/impl/TPumpingStationServiceImpl.java

@@ -3,22 +3,15 @@ package com.slibra.business.service.impl;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import com.slibra.business.domain.City;
-import com.slibra.business.domain.TNeighborhoodBuilding;
-import com.slibra.business.domain.TPumpingStationNeighbourhoodNumber;
-import com.slibra.business.mapper.CityMapper;
-import com.slibra.business.mapper.TNeighborhoodBuildingMapper;
-import com.slibra.business.mapper.TPumpingStationNeighbourhoodNumberMapper;
+import com.slibra.business.domain.*;
+import com.slibra.business.mapper.*;
 import com.slibra.business.req.NeighbourhoodNumberAndAddFlagReq;
 import com.slibra.business.res.*;
 import com.slibra.common.exception.ServiceException;
 import com.slibra.common.utils.DateUtils;
 import com.slibra.common.utils.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.slibra.business.mapper.TPumpingStationMapper;
-import com.slibra.business.domain.TPumpingStation;
 import com.slibra.business.service.ITPumpingStationService;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -44,6 +37,9 @@ public class TPumpingStationServiceImpl implements ITPumpingStationService
     @Autowired
     private CityMapper cityMapper;
 
+    @Autowired
+    private TNeighborhoodMapper tNeighborhoodMapper;
+
     /**
      * 查询泵站
      * 
@@ -225,11 +221,11 @@ public class TPumpingStationServiceImpl implements ITPumpingStationService
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String addPumpingStationAndNeighbourhoodBuildings(List<NeighbourhoodNumberAndAddFlag> req) {
+    public String addPumpingStationAndNeighbourhoodBuildings(List<TNeighborhood> req) {
         //需要把之前所有的关联数据全部删除掉
         if(!CollectionUtils.isEmpty(req)){
-            for (NeighbourhoodNumberAndAddFlag neighbourhoodNumberAndAddFlag : req) {
-                List<TPumpingStationNeighbourhoodNumber> tPumpingStationNeighbourhoodNumbersExists = this.tPumpingStationNeighbourhoodNumberMapper.selectTPumpingStationNeighbourhoodNumberList(TPumpingStationNeighbourhoodNumber.builder().pumpingStationId(neighbourhoodNumberAndAddFlag.getPumpingStationId()).build());
+            for (TNeighborhood tNeighborhood : req) {
+                List<TPumpingStationNeighbourhoodNumber> tPumpingStationNeighbourhoodNumbersExists = this.tPumpingStationNeighbourhoodNumberMapper.selectTPumpingStationNeighbourhoodNumberList(TPumpingStationNeighbourhoodNumber.builder().pumpingStationId(tNeighborhood.getPumpingStationId()).build());
                 if(!CollectionUtils.isEmpty(tPumpingStationNeighbourhoodNumbersExists)){
                     for (TPumpingStationNeighbourhoodNumber tPumpingStationNeighbourhoodNumber : tPumpingStationNeighbourhoodNumbersExists) {
                         this.tPumpingStationNeighbourhoodNumberMapper.deleteTPumpingStationNeighbourhoodNumberById(tPumpingStationNeighbourhoodNumber.getId());
@@ -237,24 +233,79 @@ public class TPumpingStationServiceImpl implements ITPumpingStationService
                 }
             }
             //保存新的数据
-            for (NeighbourhoodNumberAndAddFlag addReq : req) {
-                Long pumpingStationId = addReq.getPumpingStationId();
-                Long neighbourhoodId = addReq.getNeighbourhoodId();
-                Long buildingId = addReq.getBuildingId();
-                //判断是否已经添加过了,添加过了就抛出异常  不用判断是否已添加了,因为是每次都是覆盖添加
-                /*List<TPumpingStationNeighbourhoodNumber> tPumpingStationNeighbourhoodNumbers = this.tPumpingStationNeighbourhoodNumberMapper.selectTPumpingStationNeighbourhoodNumberList(TPumpingStationNeighbourhoodNumber.builder().pumpingStationId(pumpingStationId).neighborhoodId(neighbourhoodId).neighborhoodBuildingId(buildingId).build());
-                if(!CollectionUtils.isEmpty(tPumpingStationNeighbourhoodNumbers)){
-                   throw new ServiceException("有存在重复添加的数据,请检查!");
-                }*/
-                //赋值
-                TPumpingStationNeighbourhoodNumber build = TPumpingStationNeighbourhoodNumber.builder().build();
-                build.setPumpingStationId(pumpingStationId);
-                build.setNeighborhoodId(neighbourhoodId);
-                build.setNeighborhoodBuildingId(buildingId);
-                //保存
-                tPumpingStationNeighbourhoodNumberMapper.insertTPumpingStationNeighbourhoodNumber(build);
+            for (TNeighborhood addReq : req) {
+                List<NeighbourhoodNumberAndAddFlag> neighbourhoodNumberAndAddFlags = addReq.getNeighbourhoodNumberAndAddFlags();
+                if(!CollectionUtils.isEmpty(neighbourhoodNumberAndAddFlags)){
+                    Long pumpingStationId = addReq.getPumpingStationId();
+                    Long neighbourhoodId = addReq.getId();
+                    for (NeighbourhoodNumberAndAddFlag neighbourhoodNumberAndAddFlag : neighbourhoodNumberAndAddFlags) {
+                        Long buildingId = neighbourhoodNumberAndAddFlag.getBuildingId();
+                        //判断是否已经添加过了,添加过了就抛出异常  不用判断是否已添加了,因为是每次都是覆盖添加
+                        /*List<TPumpingStationNeighbourhoodNumber> tPumpingStationNeighbourhoodNumbers = this.tPumpingStationNeighbourhoodNumberMapper.selectTPumpingStationNeighbourhoodNumberList(TPumpingStationNeighbourhoodNumber.builder().pumpingStationId(pumpingStationId).neighborhoodId(neighbourhoodId).neighborhoodBuildingId(buildingId).build());
+                        if(!CollectionUtils.isEmpty(tPumpingStationNeighbourhoodNumbers)){
+                           throw new ServiceException("有存在重复添加的数据,请检查!");
+                        }*/
+                        //赋值
+                        TPumpingStationNeighbourhoodNumber build = TPumpingStationNeighbourhoodNumber.builder().build();
+                        build.setPumpingStationId(pumpingStationId);
+                        build.setNeighborhoodId(neighbourhoodId);
+                        build.setNeighborhoodBuildingId(buildingId);
+                        //保存
+                        tPumpingStationNeighbourhoodNumberMapper.insertTPumpingStationNeighbourhoodNumber(build);
+                    }
+                }
             }
         }
         return "操作成功";
     }
+
+    @Override
+    public List<TNeighborhood> getSimpleNeighbourhoodList(TNeighborhood tNeighborhood) {
+        Long pumpingStationId = tNeighborhood.getPumpingStationId();
+        if(Objects.isNull(pumpingStationId))
+            throw new ServiceException("请输入泵站ID");
+        List<TNeighborhood> tNeighborhoods = this.tNeighborhoodMapper.selectTNeighborhoodList(tNeighborhood);
+        //处理其他信息
+        for (TNeighborhood neighborhood : tNeighborhoods) {
+            this.addNeighbourhoodBuildingsAndStatus(neighborhood, pumpingStationId);
+        }
+        return tNeighborhoods;
+    }
+
+    private void addNeighbourhoodBuildingsAndStatus(TNeighborhood neighborhood, Long pumpingStationId) {
+        //额外的信息
+        List<NeighbourhoodNumberAndAddFlag> neighbourhoodNumberAndAddFlags = new ArrayList<>();
+        Long neighbourhoodId = neighborhood.getId();
+        //先获取该小区下的所有的楼号
+        List<TNeighborhoodBuilding> tNeighborhoodBuildings = this.tNeighborhoodBuildingMapper.selectTNeighborhoodBuildingList(TNeighborhoodBuilding.builder().neighborhoodId(neighbourhoodId).build());
+        //有楼号
+        for (TNeighborhoodBuilding tNeighborhoodBuilding : tNeighborhoodBuildings) {
+            NeighbourhoodNumberAndAddFlag neighbourhoodNumberAndAddFlag = new NeighbourhoodNumberAndAddFlag();
+            //楼号
+            neighbourhoodNumberAndAddFlag.setBuildingId(tNeighborhoodBuilding.getId());
+            neighbourhoodNumberAndAddFlag.setBuildingsNames(tNeighborhoodBuilding.getName());
+            //小区
+            neighbourhoodNumberAndAddFlag.setNeighbourhoodId(neighbourhoodId);
+            //泵站ID
+            neighbourhoodNumberAndAddFlag.setPumpingStationId(pumpingStationId);
+            //通过楼号和泵站查询对应的楼号是否已经添加过了
+            List<TPumpingStationNeighbourhoodNumber> tPumpingStationNeighbourhoodNumbers = this.tPumpingStationNeighbourhoodNumberMapper.selectTPumpingStationNeighbourhoodNumberList(TPumpingStationNeighbourhoodNumber.builder().pumpingStationId(pumpingStationId).neighborhoodId(tNeighborhoodBuilding.getNeighborhoodId()).neighborhoodBuildingId(tNeighborhoodBuilding.getId()).build());
+            if(!CollectionUtils.isEmpty(tPumpingStationNeighbourhoodNumbers)){
+//                TPumpingStationNeighbourhoodNumber tPumpingStationNeighbourhoodNumber = tPumpingStationNeighbourhoodNumbers.get(0);
+//                neighbourhoodNumberAndAddFlag.setId(tPumpingStationNeighbourhoodNumber.getId());
+                neighbourhoodNumberAndAddFlag.setAddStatus(2);
+            }else{
+                //查看对应的楼号是不是被其他泵站添加了
+                List<TPumpingStationNeighbourhoodNumber> tPumpingStationNeighbourhoodNumbers1 = this.tPumpingStationNeighbourhoodNumberMapper.selectTPumpingStationNeighbourhoodNumberList(TPumpingStationNeighbourhoodNumber.builder().neighborhoodId(tNeighborhoodBuilding.getNeighborhoodId()).neighborhoodBuildingId(tNeighborhoodBuilding.getId()).build());
+                if(!CollectionUtils.isEmpty(tPumpingStationNeighbourhoodNumbers1)){
+                    neighbourhoodNumberAndAddFlag.setAddStatus(1);
+                }else{
+                    neighbourhoodNumberAndAddFlag.setAddStatus(0);
+                }
+            }
+            neighbourhoodNumberAndAddFlags.add(neighbourhoodNumberAndAddFlag);
+        }
+        neighborhood.setNeighbourhoodNumberAndAddFlags(neighbourhoodNumberAndAddFlags);
+        neighborhood.setPumpingStationId(pumpingStationId);
+    }
 }