From b2627616ff5d391803d2ef2c68ff5d23e68a04e4 Mon Sep 17 00:00:00 2001 From: wany <13995595726@qq.com> Date: Fri, 12 Jul 2024 11:29:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E5=80=BC=E6=9F=A5=E8=AF=A2=E5=A4=9A?= =?UTF-8?q?=E5=9B=BE=E5=8D=95=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xyt/service/OsmoticPressRService.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) 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; }