diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java new file mode 100644 index 0000000..b1ab2c2 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.operational.home.wind; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "降雨月数据") +public class RainMon { + + @ApiModelProperty(value = "年份") + private Integer year; + + @ApiModelProperty(value = "月份") + private Integer month; + + @ApiModelProperty(value = "字符串格式月份") + private String strMon; + + @ApiModelProperty(value = "降雨量") + private Double rain; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java index d0b2d43..7c079bf 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java @@ -32,6 +32,9 @@ public interface MainConstants { // 水利-泵站指标数据 String LOAD_WATER_PUMP_TARGET = "loadWaterPumpTarget"; + // 水利-降雨指标数据 + String LOAD_RAINFALL_TARGET = "loadRainfallTarget"; + String LOAD_HOME_TARGET = "loadHomeTarget"; // 水利-泵站实时数据 diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterMonDataVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterMonDataVo.java index ae59478..f60a0ce 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterMonDataVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterMonDataVo.java @@ -21,5 +21,5 @@ public class WaterMonDataVo { private Float use; @ApiModelProperty(value = "降雨量") - private Float rainfall; + private Double rainfall; } diff --git a/hzims-service-api/weather-api/src/main/java/com/hnac/hzims/hzimsweather/feign/IHeWeatherWeatherClient.java b/hzims-service-api/weather-api/src/main/java/com/hnac/hzims/hzimsweather/feign/IHeWeatherWeatherClient.java index d92fe1e..26cfdf4 100644 --- a/hzims-service-api/weather-api/src/main/java/com/hnac/hzims/hzimsweather/feign/IHeWeatherWeatherClient.java +++ b/hzims-service-api/weather-api/src/main/java/com/hnac/hzims/hzimsweather/feign/IHeWeatherWeatherClient.java @@ -80,7 +80,9 @@ public interface IHeWeatherWeatherClient { * @return 降雨量月统计对象 */ @GetMapping(API_PREFIX + "/getRainFallMonthCount/{year}/{stationCodes}") - R>> getRainFallMonthCount(@PathVariable("year") @ApiParam("降雨量统计年份") String year, + R>> + + getRainFallMonthCount(@PathVariable("year") @ApiParam("降雨量统计年份") String year, @PathVariable("stationCodes") @ApiParam("降雨量站点统计,多个按逗号分隔") String stationCodes); /** diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 862cbe0..2b54abb 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -135,6 +135,11 @@ public class AlarmServiceImpl extends BaseServiceImpl if(!StringUtil.isEmpty(alarm.getAlarmType())){ wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); } + // 处理告警过滤 :当天处理告警 + List handles = alarmHandleService.handles(); + if(!CollectionUtil.isEmpty(handles)){ + wrapper.notIn("ALARM_ID",handles); + } // 查询告警数据 List alarms = this.list(wrapper); // 查询数量 diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RainFallMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RainFallMapper.java new file mode 100644 index 0000000..edd40a9 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RainFallMapper.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.fill.entity.RainfallEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + * @date 2024/03/06 09:23:14 + * @version 4.0.0 + */ +public interface RainFallMapper extends UserDataScopeBaseMapper { + + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java index 641f775..9591c87 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java @@ -95,6 +95,19 @@ public class RealTargetScheduledTask { } /** + * 水利-降雨指标加载 + */ + @XxlJob(LOAD_RAINFALL_TARGET) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadRainfallTarget(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadRainfallTarget(param); + return new ReturnT<>("SUCCESS"); + } + + /** * 水利-站点水位数据 */ @XxlJob(LOAD_WATER_LEVEL) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/RainFallService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/RainFallService.java new file mode 100644 index 0000000..6e0f587 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/RainFallService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.operation.fill; + +import com.hnac.hzims.operational.fill.entity.RainfallEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface RainFallService extends BaseService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/RainFallServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/RainFallServiceImpl.java new file mode 100644 index 0000000..459d2d9 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/RainFallServiceImpl.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.scheduled.service.operation.fill.impl; + +import com.hnac.hzims.operational.fill.entity.RainfallEntity; +import com.hnac.hzims.scheduled.mapper.operation.RainFallMapper; +import com.hnac.hzims.scheduled.service.operation.fill.RainFallService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + * @date 2023/04/10 11:16:07 + * @version 4.0.0 + */ +@Slf4j +@Service +@AllArgsConstructor +public class RainFallServiceImpl extends BaseServiceImpl implements RainFallService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java index d608cf5..485fe48 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java @@ -8,31 +8,25 @@ import java.util.List; */ public interface RealTargetService { - void loadEmInfo(String param); - // 水电站实时数据加载 void loadHydropowerReal(String param); - // 水电站指标数据加载 void loadHydropowerTarget(String param); - // 泵站实时数据加载 void loadWaterPumpReal(String param); - // 泵站指标数据加载 void loadWaterPumpTarget(String param); - // 站点水位指标数据 + void loadRainfallTarget(String param); + void loadWaterLevel(String param); - // 光伏站实时数据加载 void loadPhotovoltaicReal(String param); - // 光伏站指标数据加载 void loadPhotovoltaicTarget(String param); - // 光伏、水电站近3年发电量 void loadPowerData(String param, List types, Integer serveType, int year); + void loadPowerDataByWindEnergy(String param, List types, Integer serveType, int year,String key); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index 8d7cb11..aacaa77 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -7,6 +7,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.equipment.entity.EmParamEntity; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient; +import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; +import com.hnac.hzims.operational.fill.entity.RainfallEntity; +import com.hnac.hzims.operational.home.wind.RainMon; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.station.StationConstants; @@ -46,6 +50,8 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -63,12 +69,18 @@ public class RealTargetServiceImpl implements RealTargetService { private final DataService dataService; + private final WindService windService; + private final PowerService powerService; private final DeviceService deviceService; private final StationService stationService; + private final StorageService storageService; + + private final RainFallService rainFallService; + private final GenerateService generateService; private final DeviceParamService deviceParamService; @@ -78,8 +90,8 @@ public class RealTargetServiceImpl implements RealTargetService { private final ModelStationService modelStationService; private final RedisTemplate redisTemplate; - private final WindService windService; - private final StorageService storageService; + + private final IHeWeatherWeatherClient heWeatherWeatherClient; private final IHistoryDataSearchClient historyDataSearchClient; @@ -96,6 +108,7 @@ public class RealTargetServiceImpl implements RealTargetService { private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real:key"; + private final static String loadwaterpump_rain_key = "hzims:operation:loadwaterpump:rain:key"; private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; @@ -377,6 +390,120 @@ public class RealTargetServiceImpl implements RealTargetService { } /** + * 降雨量数据加载 + * @param param + */ + @Override + public void loadRainfallTarget(String param) { + // 查询带运维泵站/闸门 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .in(StationEntity::getType,HomePageConstant.waterList) + ); + if(CollectionUtil.isEmpty(stations)){ + return; + } + // 查询水利站点天气降雨 + Map> weathers = this.weatherRains(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + // 查询填报降雨量 + Map> fills = this.rainFills(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + if(MapUtils.isEmpty(weathers) && MapUtils.isEmpty(fills)){ + return; + } + Map> rainMap = new HashMap<>(); + stations.forEach(item->{ + List rains = new ArrayList<>(); + if(weathers.containsKey(item.getCode())){ + rains.addAll(weathers.get(item.getCode()).stream().map(weather->{ + RainMon rain = new RainMon(); + LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), weather.getYearAndMonth() + "-01"), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + rain.setYear(localDate.getYear()); + rain.setStrMon(weather.getYearAndMonth()); + rain.setMonth(localDate.getMonthValue()); + rain.setRain(weather.getRainFallCount()); + return rain; + }).collect(Collectors.toList())); + } + if(fills.containsKey(item.getCode())){ + rains.addAll(fills.get(item.getCode()).stream().map(fill->{ + RainMon rain = new RainMon(); + LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), fill.getFillDate() + "-01"), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + rain.setYear(localDate.getYear()); + rain.setStrMon(fill.getFillDate()); + rain.setMonth(localDate.getMonthValue()); + rain.setRain(fill.getRain().doubleValue()); + return rain; + }).collect(Collectors.toList())); + } + rainMap.put(item.getCode(),rains); + }); + if(MapUtils.isEmpty(rainMap)){ + return; + } + redisTemplate.opsForValue().set(loadwaterpump_rain_key,rainMap); + } + + /** + * 查询天气降雨量 + * @param stationCodes + * @return + */ + private Map> weatherRains(List stationCodes) { + Calendar calendar = Calendar.getInstance(); + // 当年 + String first = DateUtil.format(calendar.getTime(),"yyyy"); + R>> firsts = heWeatherWeatherClient.getRainFallMonthCount(first,String.join(",",stationCodes)); + // 上一年 + calendar.add(Calendar.YEAR,-1); + String second = DateUtil.format(calendar.getTime(),"yyyy"); + R>> seconds = heWeatherWeatherClient.getRainFallMonthCount(second,String.join(",",stationCodes)); + if(!firsts.isSuccess() && !seconds.isSuccess()){ + return new HashMap<>(); + } + if(MapUtils.isEmpty(firsts.getData()) && MapUtils.isEmpty(seconds.getData())){ + return new HashMap<>(); + } + if(MapUtils.isEmpty(firsts.getData())){ + return seconds.getData(); + }else if(MapUtils.isEmpty(seconds.getData())){ + return firsts.getData(); + } + return Stream.of(firsts.getData(), seconds.getData()) + .flatMap(map -> map.entrySet().stream()) + .collect(Collectors.toMap(Map.Entry::getKey,Map.Entry::getValue,(value1, value2) -> { + List rains = new ArrayList<>(); + rains.addAll(value1); + rains.addAll(value2); + return rains; + })); + } + + /** + * 查询填报降雨量 + * @param stationCodes + * @return + */ + private Map> rainFills(List stationCodes) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.YEAR,1); + calendar.add(Calendar.MONTH,-(calendar.get(Calendar.MONTH) + 1)); + String end = DateUtil.format(calendar.getTime(),"yyyy-MM"); + calendar.add(Calendar.YEAR,-1); + calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH)); + String start = DateUtil.format(calendar.getTime(),"yyyy-MM"); + List rains = rainFallService.list(Wrappers.lambdaQuery() + .in(RainfallEntity::getStationCode,stationCodes) + .ge(RainfallEntity::getFillDate,start) + .le(RainfallEntity::getFillDate,end) + ); + if(CollectionUtil.isEmpty(rains)){ + return new HashMap<>(); + } + return rains.stream().collect(Collectors.groupingBy(RainfallEntity::getStationCode)); + } + + + /** * 水利-站点水位数据 * @param param */ @@ -1217,9 +1344,8 @@ public class RealTargetServiceImpl implements RealTargetService { * @return */ private Map getGenerateYearByWindEnergy(StationEntity station, String start, String end) { - List datas = new ArrayList<>(); - // 补充填报数据 - datas.addAll(this.generateFill(station,start,end)); + // 补充填报数据 + List datas = new ArrayList<>(this.generateFill(station, start, end)); if(CollectionUtil.isEmpty(datas)){ return null; } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index 921dd44..92c5a8c 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -372,7 +372,7 @@ public class MonitorServiceImpl implements MonitorService { /** * 设备处理 * - * @param list + * @param list、 * @param map * @param device */ diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RainFallMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RainFallMapper.xml new file mode 100644 index 0000000..1464d16 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RainFallMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java index 9346d01..1bbd7f3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java @@ -11,6 +11,7 @@ import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyRespons import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; import com.hnac.hzims.operational.fill.service.UseService; +import com.hnac.hzims.operational.home.wind.RainMon; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.vo.*; @@ -88,11 +89,9 @@ public class WaterServiceImpl implements IWaterService { @Value("${hzims.operation.realIdKey}") public String real_id_key; - private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; - private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real:key"; - + private final static String loadwaterpump_rain_key = "hzims:operation:loadwaterpump:rain:key"; private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; /** @@ -1058,51 +1057,48 @@ public class WaterServiceImpl implements IWaterService { */ @Override public List waterYearRain(Long deptId) { - R> R = sysClient.getDeptByCurrentUser(); - if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { - return null; - } - // 获取水利站点 - List stationList = stationService.getStationList(R.getData(),deptId,HomePageConstant.waterList,HomePageConstant.HYDROPOWER_SERVETYPE,false); - if(CollectionUtil.isEmpty(stationList)){ - return null; + Map> rainMap = (Map>) redisTemplate.opsForValue().get(loadwaterpump_rain_key); + if(MapUtils.isEmpty(rainMap)){ + return new ArrayList<>(); } - List codeList = stationList.stream().map(StationEntity::getCode).filter(StringUtil::isNotBlank).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(codeList)){ - return null; + R> depts = sysClient.getDeptChild(deptId); + if (!depts.isSuccess() || ObjectUtil.isEmpty(depts.getData())) { + return new ArrayList<>(); } - // 获取降雨数据 - Map> map = this.getYearRain(codeList,1); - if(MapUtils.isEmpty(map)){ - return null; + // 获取水利站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .in(StationEntity::getRefDept,depts.getData().stream().map(Dept::getId).collect(Collectors.toList())) + .in(StationEntity::getType,HomePageConstant.waterList) + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)); + if(CollectionUtil.isEmpty(stations)){ + return new ArrayList<>(); } - // 对象转换 - List waterMonDataVoList = new ArrayList<>(); - map.forEach((key,value) -> { - WaterMonDataVo waterMonDataVo = new WaterMonDataVo(); - waterMonDataVo.setStrMonth(key); - LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), key+"-01"), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - waterMonDataVo.setYear(localDate.getYear()); - waterMonDataVo.setMonth(localDate.getMonthValue()); - float rain = (float) value.stream().mapToDouble(RainFallCountByMonthVo::getRainFallCount).sum(); - waterMonDataVo.setRainfall(rain); - waterMonDataVoList.add(waterMonDataVo); + List rains = new ArrayList<>(); + stations.forEach(station->{ + if(!rainMap.containsKey(station.getCode())){ + return; + } + rains.addAll(rainMap.get(station.getCode())); }); - if (CollectionUtil.isEmpty(waterMonDataVoList)) { + if (CollectionUtil.isEmpty(rains)) { return null; } // 根据年份分组 - Map> yearMap = waterMonDataVoList.stream().collect(Collectors.groupingBy(WaterMonDataVo::getYear)); + Map> years = rains.stream().collect(Collectors.groupingBy(RainMon::getYear)); // 遍历为返回结构 - List result = new ArrayList<>(); - yearMap.forEach((key, value) -> { - WaterYearDataVo vo = new WaterYearDataVo(); - vo.setYear(key); - List sortValue = value.stream().sorted(Comparator.comparing(WaterMonDataVo::getMonth)).collect(Collectors.toList()); - vo.setMonList(sortValue); - result.add(vo); - }); - return result; + return years.entrySet().stream().map(entry-> { + WaterYearDataVo year = new WaterYearDataVo(); + year.setYear(entry.getKey()); + year.setMonList(entry.getValue().stream().collect(Collectors.groupingBy(RainMon::getStrMon)).entrySet().stream().map(mon -> { + WaterMonDataVo waterMon = new WaterMonDataVo(); + LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon.getKey() + "-01"), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + waterMon.setStrMonth(mon.getKey()); + waterMon.setMonth(localDate.getMonthValue()); + waterMon.setRainfall(mon.getValue().stream().mapToDouble(RainMon::getRain).sum()); + return waterMon; + }).sorted(Comparator.comparing(WaterMonDataVo::getStrMonth)).collect(Collectors.toList())); + return year; + }).collect(Collectors.toList()); } /** diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml index 22e2dd0..e3183c2 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml @@ -89,7 +89,7 @@ select info.em_code as emCode,info.`type`,count(*) as payment, SUM( IF ( info.flow_description = '结束', 1, 0 )) AS finish, SUM( IF ( info.flow_description IN ( '作废', '错票' ), 1, 0 )) AS invalid, - SUM( IF ( eval.evaluate = '合格!', 1, 0 )) AS qualified + SUM( IF ( eval.`status` = '1', 1, 0 )) AS qualified from hzims_work_ticket_info info LEFT JOIN hzims_ticket_info_evaluate eval ON info.id = eval.ticket_id