diff --git a/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java b/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java index 9a4c0b9..e297233 100644 --- a/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java +++ b/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java @@ -86,6 +86,7 @@ public class OsmoticPressRService extends ServiceImpl queryChart(OsmoticQuerySo osmoticQuerySo,Integer year) { List resList = new ArrayList<>(); + List stationCodes = osmoticQuerySo.getStationCodes(); //查询库水位 List list = mapper.queryRz(osmoticQuerySo); //查询测站降雨量 @@ -122,22 +123,25 @@ public class OsmoticPressRService extends ServiceImpl valueList = mapper.queryValue(osmoticQuerySo); //按测站分组 Map> map = valueList.stream().collect(Collectors.groupingBy(OsmoticValueVo::getStationCode)); - map.entrySet().forEach(o->{ + for(String code : stationCodes){ OsmoticChartVo vo = new OsmoticChartVo(); - List voList = o.getValue(); - OsmoticValueVo max = voList.stream().max(Comparator.comparing(OsmoticValueVo::getValue)).get(); - OsmoticValueVo min = voList.stream().min(Comparator.comparing(OsmoticValueVo::getValue)).get(); - vo.setStationCode(o.getKey()); - vo.setMaxValue(max.getValue()); - vo.setMaxTm(max.getTm()); - vo.setMinValue(min.getValue()); - vo.setMinTm(min.getTm()); - vo.setDiff(max.getValue().subtract(min.getValue())); - if(year == null){ - vo.setDetailVos(bindData(MyBeanUtil.collectionCopy(list,OsmoticChartDetailVo.class),MyBeanUtil.collectionCopy(voList,OsmoticChartDetailVo.class))); + vo.setStationCode(code); + if(map.containsKey(code)){ + List voList = map.get(code); + OsmoticValueVo max = voList.stream().max(Comparator.comparing(OsmoticValueVo::getValue)).get(); + OsmoticValueVo min = voList.stream().min(Comparator.comparing(OsmoticValueVo::getValue)).get(); + vo.setStationCode(code); + vo.setMaxValue(max.getValue()); + vo.setMaxTm(max.getTm()); + vo.setMinValue(min.getValue()); + vo.setMinTm(min.getTm()); + vo.setDiff(max.getValue().subtract(min.getValue())); + if(year == null){ + vo.setDetailVos(bindData(MyBeanUtil.collectionCopy(list,OsmoticChartDetailVo.class),MyBeanUtil.collectionCopy(voList,OsmoticChartDetailVo.class))); + } } resList.add(vo); - }); + } return resList; }