|
@@ -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);
|
|
|
+ }
|
|
|
}
|