ソースを参照

泵站 和 小区 关联的省市区返回对应的中文名称

王苗苗 2 週間 前
コミット
f1e39d5fc7

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

@@ -68,10 +68,23 @@ public class TNeighborhood extends BaseEntity
     //关联的泵站名称
     private String pumpingStationNames;
 
+
+    //省的名字
+    private String provinceName;
+
+    //市的名字
+    private String cityName;
+
+    //区县的名字
+    private String countryName;
+
+
     //请求参数
     private List<String> buildingNameList;
 
 
 
 
+
+
 }

+ 8 - 0
slibra-system/src/main/java/com/slibra/business/domain/TPumpingStation.java

@@ -64,4 +64,12 @@ public class TPumpingStation extends BaseEntity
     //关联的小区  复兴小区(A#、B#、C#),康华时代(1#、2#、3#)
     private String neighbourhoodAndBuildings;
 
+    //省的名字
+    private String provinceName;
+
+    //市的名字
+    private String cityName;
+
+    //区县的名字
+    private String countryName;
 }

+ 38 - 0
slibra-system/src/main/java/com/slibra/business/service/impl/TNeighborhoodServiceImpl.java

@@ -3,12 +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.TPumpingStation;
+import com.slibra.business.mapper.CityMapper;
 import com.slibra.business.mapper.TNeighborhoodBuildingMapper;
 import com.slibra.business.res.PumpAndBuildingNumberNames;
 import com.slibra.business.res.PumpAndNumber;
 import com.slibra.common.utils.DateUtils;
+import com.slibra.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.slibra.business.mapper.TNeighborhoodMapper;
@@ -32,6 +35,9 @@ public class TNeighborhoodServiceImpl implements ITNeighborhoodService
     @Autowired
     private TNeighborhoodBuildingMapper tNeighborhoodBuildingMapper;
 
+    @Autowired
+    private CityMapper cityMapper;
+
     /**
      * 查询服务小区
      * 
@@ -60,11 +66,43 @@ public class TNeighborhoodServiceImpl implements ITNeighborhoodService
                 Long id = neighborhood.getId();//小区ID
                 neighborhood.setBuildingsNames(this.tNeighborhoodMapper.getNeighbourhoodBuildingsNamesById(id));
                 neighborhood.setPumpingStationNames(this.tNeighborhoodMapper.getPumpingStationNamesById(id));
+                this.addExtraAddress(neighborhood);
             }
         }
         return tNeighborhoods;
     }
 
+    /**
+     * 额外处理省市区的名字
+     * @param neighborhood
+     */
+    private void addExtraAddress(TNeighborhood neighborhood) {
+        String provinceId = neighborhood.getProvinceId();
+        String cityId = neighborhood.getCityId();
+        String countryId = neighborhood.getCountryId();
+        //省
+        if(StringUtils.isNotBlank(provinceId)){
+            City city = this.cityMapper.selectCityById(provinceId);
+            if(!Objects.isNull(city)){
+                neighborhood.setProvinceName(city.getName());
+            }
+        }
+        //市
+        if(StringUtils.isNotBlank(cityId)){
+            City city = this.cityMapper.selectCityById(cityId);
+            if(!Objects.isNull(city)){
+                neighborhood.setCityName(city.getName());
+            }
+        }
+        //区县
+        if(StringUtils.isNotBlank(countryId)){
+            City city = this.cityMapper.selectCityById(countryId);
+            if(!Objects.isNull(city)){
+                neighborhood.setCountryName(city.getName());
+            }
+        }
+    }
+
     /**
      * 新增服务小区
      * 

+ 39 - 4
slibra-system/src/main/java/com/slibra/business/service/impl/TPumpingStationServiceImpl.java

@@ -1,19 +1,19 @@
 package com.slibra.business.service.impl;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+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.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;
@@ -41,6 +41,9 @@ public class TPumpingStationServiceImpl implements ITPumpingStationService
     @Autowired
     private TPumpingStationNeighbourhoodNumberMapper tPumpingStationNeighbourhoodNumberMapper;
 
+    @Autowired
+    private CityMapper cityMapper;
+
     /**
      * 查询泵站
      * 
@@ -67,11 +70,43 @@ public class TPumpingStationServiceImpl implements ITPumpingStationService
         if(!CollectionUtils.isEmpty(pumpingStations)){
             for (TPumpingStation pumpingStation : pumpingStations) {
                 this.addNeighbourhoodAndBuildings(pumpingStation);
+                this.addExtraAddress(pumpingStation);
             }
         }
         return pumpingStations;
     }
 
+    /**
+     * 额外处理省市区的名字
+     * @param pumpingStation
+     */
+    private void addExtraAddress(TPumpingStation pumpingStation) {
+        String provinceId = pumpingStation.getProvinceId();
+        String cityId = pumpingStation.getCityId();
+        String countryId = pumpingStation.getCountryId();
+        //省
+        if(StringUtils.isNotBlank(provinceId)){
+            City city = this.cityMapper.selectCityById(provinceId);
+            if(!Objects.isNull(city)){
+                pumpingStation.setProvinceName(city.getName());
+            }
+        }
+        //市
+        if(StringUtils.isNotBlank(cityId)){
+            City city = this.cityMapper.selectCityById(cityId);
+            if(!Objects.isNull(city)){
+                pumpingStation.setCityName(city.getName());
+            }
+        }
+        //区县
+        if(StringUtils.isNotBlank(countryId)){
+            City city = this.cityMapper.selectCityById(countryId);
+            if(!Objects.isNull(city)){
+                pumpingStation.setCountryName(city.getName());
+            }
+        }
+    }
+
     /**
      *  查询泵站关联的小区信息
      * @param pumpingStation