diff --git a/src/main/java/com/gis3c/spatial/service/RiverService.java b/src/main/java/com/gis3c/spatial/service/RiverService.java index 6a31597..9cc8edd 100644 --- a/src/main/java/com/gis3c/spatial/service/RiverService.java +++ b/src/main/java/com/gis3c/spatial/service/RiverService.java @@ -1,11 +1,25 @@ package com.gis3c.spatial.service; +import java.util.Map; import java.util.Set; /** * Created by hukekuan on 2018/4/12. */ public interface RiverService { - public String findRiversByStationCodes(Set stationCodes); - public String findRiversByRiverCodes(Set riverCodes); + /** + * 根据站点编号获取分段河流数据 + * @param stationCodes 站点编号 + * @param sufaceStations 站点编号和站点水质的集合 + * @return + */ + public String findRiversByStationCodes(Set stationCodes,Map sufaceStations); + + /** + * 根据河流编号获取分段河流数据 + * @param riverCodes 河流编号 + * @param sufaceStations 站点编号和站点水质的集合 + * @return + */ + public String findRiversByRiverCodes(Set riverCodes,Map sufaceStations); } diff --git a/src/main/java/com/gis3c/spatial/service/impl/RiverServiceImpl.java b/src/main/java/com/gis3c/spatial/service/impl/RiverServiceImpl.java index fc11e90..50e34e8 100644 --- a/src/main/java/com/gis3c/spatial/service/impl/RiverServiceImpl.java +++ b/src/main/java/com/gis3c/spatial/service/impl/RiverServiceImpl.java @@ -10,6 +10,7 @@ import org.springframework.stereotype.Service; import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -21,10 +22,19 @@ public class RiverServiceImpl implements RiverService { private RiverDao riverDao; @Override - public String findRiversByStationCodes(Set stationCodes) { + public String findRiversByStationCodes(Set stationCodes,Map sufaceStations) { String riverJson = null; List riverList = riverDao.findRiversByStationCodes(stationCodes); + if(sufaceStations != null){ + riverList.forEach(separatedRiver -> { + if(sufaceStations.keySet().contains(separatedRiver.getStationCode())){ + separatedRiver.setLevel(sufaceStations.get(separatedRiver.getStationCode())); + }else { + separatedRiver.setLevel("--"); + } + }); + } try { riverJson = FeatureUtilities.JavaBeans2Json(riverList); } catch (IllegalAccessException | IOException e) { @@ -34,10 +44,20 @@ public class RiverServiceImpl implements RiverService { } @Override - public String findRiversByRiverCodes(Set riverCodes) { + public String findRiversByRiverCodes(Set riverCodes,Map sufaceStations) { String riverJson = null; List riverList = riverDao.findRiversByRiverCodes(riverCodes); + if(sufaceStations != null){ + riverList.forEach(separatedRiver -> { + if(separatedRiver.getStationCode() != null + && sufaceStations.keySet().contains(separatedRiver.getStationCode())){ + separatedRiver.setLevel(sufaceStations.get(separatedRiver.getStationCode())); + }else { + separatedRiver.setLevel("--"); + } + }); + } try { riverJson = FeatureUtilities.JavaBeans2Json(riverList); } catch (IllegalAccessException | IOException e) {