|
@@ -1,12 +1,21 @@
|
|
|
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.stream.Collectors;
|
|
|
+
|
|
|
+import com.slibra.business.domain.TPumpingStation;
|
|
|
+import com.slibra.business.res.PumpAndBuildingNumberNames;
|
|
|
+import com.slibra.business.res.PumpAndNumber;
|
|
|
import com.slibra.common.utils.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.slibra.business.mapper.TNeighborhoodMapper;
|
|
|
import com.slibra.business.domain.TNeighborhood;
|
|
|
import com.slibra.business.service.ITNeighborhoodService;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
|
* 服务小区Service业务层处理
|
|
@@ -41,7 +50,16 @@ public class TNeighborhoodServiceImpl implements ITNeighborhoodService
|
|
|
@Override
|
|
|
public List<TNeighborhood> selectTNeighborhoodList(TNeighborhood tNeighborhood)
|
|
|
{
|
|
|
- return tNeighborhoodMapper.selectTNeighborhoodList(tNeighborhood);
|
|
|
+ List<TNeighborhood> tNeighborhoods = tNeighborhoodMapper.selectTNeighborhoodList(tNeighborhood);
|
|
|
+ if(!CollectionUtils.isEmpty(tNeighborhoods)){
|
|
|
+ for (TNeighborhood neighborhood : tNeighborhoods) {
|
|
|
+ //2024年11月12日10:58:29 额外返回楼号 关联泵站的信息
|
|
|
+ Long id = neighborhood.getId();//小区ID
|
|
|
+ neighborhood.setBuildingsNames(this.tNeighborhoodMapper.getNeighbourhoodBuildingsNamesById(id));
|
|
|
+ neighborhood.setPumpingStationNames(this.tNeighborhoodMapper.getPumpingStationNamesById(id));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tNeighborhoods;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -93,4 +111,35 @@ public class TNeighborhoodServiceImpl implements ITNeighborhoodService
|
|
|
{
|
|
|
return tNeighborhoodMapper.deleteTNeighborhoodById(id);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PumpAndNumber> getPumpingStationAndNeighbourhoodBuildingsById(Long id) {
|
|
|
+ //先通过小区的ID查询所有的关联的泵站的信息
|
|
|
+ /*List<TPumpingStation> pumpingStations = this.tNeighborhoodMapper.getPumpingStationByNeighbourhoodId(id);
|
|
|
+ if(CollectionUtils.isEmpty(pumpingStations))
|
|
|
+ return Collections.emptyList();
|
|
|
+ List<PumpAndNumber> result = new ArrayList<>(pumpingStations.size());
|
|
|
+ for (TPumpingStation pumpingStation : pumpingStations) {
|
|
|
+ Long pumpingStationId = pumpingStation.getId();
|
|
|
+ PumpAndNumber pumpAndNumber = new PumpAndNumber();
|
|
|
+ pumpAndNumber.setPumpingStationId(pumpingStationId);
|
|
|
+ pumpAndNumber.setPumpingStationName(pumpingStation.getName());
|
|
|
+ pumpAndNumber.setBuildingsNames(this.tNeighborhoodMapper.getNeighbourhoodBuildingNamesByPumpingStationId(pumpingStationId));
|
|
|
+ result.add(pumpAndNumber);
|
|
|
+ }
|
|
|
+ return result;*/
|
|
|
+ //2024年11月12日14:03:17 上述的查询太浪费性能,改成一次查出多条对应的数据,再在程序中处理
|
|
|
+ List<PumpAndBuildingNumberNames> pumpAndNumbers = this.tNeighborhoodMapper.getPumpAndBuildingNumberNamesByNeighbourhoodId(id);
|
|
|
+ if(CollectionUtils.isEmpty(pumpAndNumbers))
|
|
|
+ return Collections.emptyList();
|
|
|
+ Map<String, List<PumpAndBuildingNumberNames>> collect = pumpAndNumbers.stream().collect(Collectors.groupingBy(PumpAndBuildingNumberNames::getPumpingStationName));
|
|
|
+ List<PumpAndNumber> result = new ArrayList<>(collect.size());
|
|
|
+ collect.forEach((key, value) -> {
|
|
|
+ PumpAndNumber pumpAndNumber = new PumpAndNumber();
|
|
|
+ pumpAndNumber.setPumpingStationName(key);
|
|
|
+ pumpAndNumber.setBuildingsNames(value.stream().map(PumpAndBuildingNumberNames::getNeighborhoodBuildingName).collect(Collectors.joining("、")));
|
|
|
+ result.add(pumpAndNumber);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|