Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
ty 9 months ago
parent
commit
4d537605b9
  1. 25
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java
  2. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  3. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterMonDataVo.java
  4. 4
      hzims-service-api/weather-api/src/main/java/com/hnac/hzims/hzimsweather/feign/IHeWeatherWeatherClient.java
  5. 5
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java
  6. 14
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/RainFallMapper.java
  7. 13
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  8. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/RainFallService.java
  9. 21
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/RainFallServiceImpl.java
  10. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java
  11. 136
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  12. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  13. 6
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RainFallMapper.xml
  14. 76
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java
  15. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/mapper/xml/WorkTicketInfoMapper.xml

25
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;
}

3
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_WATER_PUMP_TARGET = "loadWaterPumpTarget";
// 水利-降雨指标数据
String LOAD_RAINFALL_TARGET = "loadRainfallTarget";
String LOAD_HOME_TARGET = "loadHomeTarget"; String LOAD_HOME_TARGET = "loadHomeTarget";
// 水利-泵站实时数据 // 水利-泵站实时数据

2
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; private Float use;
@ApiModelProperty(value = "降雨量") @ApiModelProperty(value = "降雨量")
private Float rainfall; private Double rainfall;
} }

4
hzims-service-api/weather-api/src/main/java/com/hnac/hzims/hzimsweather/feign/IHeWeatherWeatherClient.java

@ -80,7 +80,9 @@ public interface IHeWeatherWeatherClient {
* @return 降雨量月统计对象 * @return 降雨量月统计对象
*/ */
@GetMapping(API_PREFIX + "/getRainFallMonthCount/{year}/{stationCodes}") @GetMapping(API_PREFIX + "/getRainFallMonthCount/{year}/{stationCodes}")
R<Map<String,List<RainFallCountByMonthVo>>> getRainFallMonthCount(@PathVariable("year") @ApiParam("降雨量统计年份") String year, R<Map<String,List<RainFallCountByMonthVo>>>
getRainFallMonthCount(@PathVariable("year") @ApiParam("降雨量统计年份") String year,
@PathVariable("stationCodes") @ApiParam("降雨量站点统计,多个按逗号分隔") String stationCodes); @PathVariable("stationCodes") @ApiParam("降雨量站点统计,多个按逗号分隔") String stationCodes);
/** /**

5
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<AlarmMapper, AlarmEntity>
if(!StringUtil.isEmpty(alarm.getAlarmType())){ if(!StringUtil.isEmpty(alarm.getAlarmType())){
wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); wrapper.eq("ALARM_TYPE",alarm.getAlarmType());
} }
// 处理告警过滤 :当天处理告警
List<String> handles = alarmHandleService.handles();
if(!CollectionUtil.isEmpty(handles)){
wrapper.notIn("ALARM_ID",handles);
}
// 查询告警数据 // 查询告警数据
List<AlarmEntity> alarms = this.list(wrapper); List<AlarmEntity> alarms = this.list(wrapper);
// 查询数量 // 查询数量

14
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<RainfallEntity> {
}

13
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<String> 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) @XxlJob(LOAD_WATER_LEVEL)

11
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<RainfallEntity> {
}

21
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<RainFallMapper, RainfallEntity> implements RainFallService {
}

12
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 { public interface RealTargetService {
void loadEmInfo(String param); void loadEmInfo(String param);
// 水电站实时数据加载
void loadHydropowerReal(String param); void loadHydropowerReal(String param);
// 水电站指标数据加载
void loadHydropowerTarget(String param); void loadHydropowerTarget(String param);
// 泵站实时数据加载
void loadWaterPumpReal(String param); void loadWaterPumpReal(String param);
// 泵站指标数据加载
void loadWaterPumpTarget(String param); void loadWaterPumpTarget(String param);
// 站点水位指标数据 void loadRainfallTarget(String param);
void loadWaterLevel(String param); void loadWaterLevel(String param);
// 光伏站实时数据加载
void loadPhotovoltaicReal(String param); void loadPhotovoltaicReal(String param);
// 光伏站指标数据加载
void loadPhotovoltaicTarget(String param); void loadPhotovoltaicTarget(String param);
// 光伏、水电站近3年发电量
void loadPowerData(String param, List<Integer> types, Integer serveType, int year); void loadPowerData(String param, List<Integer> types, Integer serveType, int year);
void loadPowerDataByWindEnergy(String param, List<Integer> types, Integer serveType, int year,String key); void loadPowerDataByWindEnergy(String param, List<Integer> types, Integer serveType, int year,String key);
} }

136
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.EquipmentConstants;
import com.hnac.hzims.equipment.entity.EmParamEntity; import com.hnac.hzims.equipment.entity.EmParamEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; 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.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.StationConstants; import com.hnac.hzims.operational.station.StationConstants;
@ -46,6 +50,8 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -63,12 +69,18 @@ public class RealTargetServiceImpl implements RealTargetService {
private final DataService dataService; private final DataService dataService;
private final WindService windService;
private final PowerService powerService; private final PowerService powerService;
private final DeviceService deviceService; private final DeviceService deviceService;
private final StationService stationService; private final StationService stationService;
private final StorageService storageService;
private final RainFallService rainFallService;
private final GenerateService generateService; private final GenerateService generateService;
private final DeviceParamService deviceParamService; private final DeviceParamService deviceParamService;
@ -78,8 +90,8 @@ public class RealTargetServiceImpl implements RealTargetService {
private final ModelStationService modelStationService; private final ModelStationService modelStationService;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final WindService windService;
private final StorageService storageService; private final IHeWeatherWeatherClient heWeatherWeatherClient;
private final IHistoryDataSearchClient historyDataSearchClient; 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 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_target_key = "hzims:operation:loadwaterpump:target:key";
private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real: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 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_real_key = "hzims:operation:photovoltaic:real:key";
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target: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<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.in(StationEntity::getType,HomePageConstant.waterList)
);
if(CollectionUtil.isEmpty(stations)){
return;
}
// 查询水利站点天气降雨
Map<String,List<RainFallCountByMonthVo>> weathers = this.weatherRains(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 查询填报降雨量
Map<String,List<RainfallEntity>> fills = this.rainFills(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
if(MapUtils.isEmpty(weathers) && MapUtils.isEmpty(fills)){
return;
}
Map<String,List<RainMon>> rainMap = new HashMap<>();
stations.forEach(item->{
List<RainMon> 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<String, List<RainFallCountByMonthVo>> weatherRains(List<String> stationCodes) {
Calendar calendar = Calendar.getInstance();
// 当年
String first = DateUtil.format(calendar.getTime(),"yyyy");
R<Map<String, List<RainFallCountByMonthVo>>> firsts = heWeatherWeatherClient.getRainFallMonthCount(first,String.join(",",stationCodes));
// 上一年
calendar.add(Calendar.YEAR,-1);
String second = DateUtil.format(calendar.getTime(),"yyyy");
R<Map<String, List<RainFallCountByMonthVo>>> 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<RainFallCountByMonthVo> rains = new ArrayList<>();
rains.addAll(value1);
rains.addAll(value2);
return rains;
}));
}
/**
* 查询填报降雨量
* @param stationCodes
* @return
*/
private Map<String, List<RainfallEntity>> rainFills(List<String> 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<RainfallEntity> rains = rainFallService.list(Wrappers.<RainfallEntity>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 * @param param
*/ */
@ -1217,9 +1344,8 @@ public class RealTargetServiceImpl implements RealTargetService {
* @return * @return
*/ */
private Map<String, Float> getGenerateYearByWindEnergy(StationEntity station, String start, String end) { private Map<String, Float> getGenerateYearByWindEnergy(StationEntity station, String start, String end) {
List<PowerMonthVo> datas = new ArrayList<>(); // 补充填报数据
// 补充填报数据 List<PowerMonthVo> datas = new ArrayList<>(this.generateFill(station, start, end));
datas.addAll(this.generateFill(station,start,end));
if(CollectionUtil.isEmpty(datas)){ if(CollectionUtil.isEmpty(datas)){
return null; return null;
} }

2
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 map
* @param device * @param device
*/ */

6
hzims-service/hzims-scheduled/src/main/resources/mapper/operation/RainFallMapper.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.RainFallMapper">
</mapper>

76
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.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo;
import com.hnac.hzims.operational.fill.service.UseService; 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.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
@ -88,11 +89,9 @@ public class WaterServiceImpl implements IWaterService {
@Value("${hzims.operation.realIdKey}") @Value("${hzims.operation.realIdKey}")
public String real_id_key; public String real_id_key;
private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump: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_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 loadwater_level_key = "hzims:operation:loadwater:level:key";
/** /**
@ -1058,51 +1057,48 @@ public class WaterServiceImpl implements IWaterService {
*/ */
@Override @Override
public List<WaterYearDataVo> waterYearRain(Long deptId) { public List<WaterYearDataVo> waterYearRain(Long deptId) {
R<List<Dept>> R = sysClient.getDeptByCurrentUser(); Map<String, List<RainMon>> rainMap = (Map<String, List<RainMon>>) redisTemplate.opsForValue().get(loadwaterpump_rain_key);
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { if(MapUtils.isEmpty(rainMap)){
return null; return new ArrayList<>();
}
// 获取水利站点
List<StationEntity> stationList = stationService.getStationList(R.getData(),deptId,HomePageConstant.waterList,HomePageConstant.HYDROPOWER_SERVETYPE,false);
if(CollectionUtil.isEmpty(stationList)){
return null;
} }
List<String> codeList = stationList.stream().map(StationEntity::getCode).filter(StringUtil::isNotBlank).collect(Collectors.toList()); R<List<Dept>> depts = sysClient.getDeptChild(deptId);
if(CollectionUtil.isEmpty(codeList)){ if (!depts.isSuccess() || ObjectUtil.isEmpty(depts.getData())) {
return null; return new ArrayList<>();
} }
// 获取降雨数据 // 获取水利站点
Map<String,List<RainFallCountByMonthVo>> map = this.getYearRain(codeList,1); List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
if(MapUtils.isEmpty(map)){ .in(StationEntity::getRefDept,depts.getData().stream().map(Dept::getId).collect(Collectors.toList()))
return null; .in(StationEntity::getType,HomePageConstant.waterList)
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE));
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
} }
// 对象转换 List<RainMon> rains = new ArrayList<>();
List<WaterMonDataVo> waterMonDataVoList = new ArrayList<>(); stations.forEach(station->{
map.forEach((key,value) -> { if(!rainMap.containsKey(station.getCode())){
WaterMonDataVo waterMonDataVo = new WaterMonDataVo(); return;
waterMonDataVo.setStrMonth(key); }
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), key+"-01"), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); rains.addAll(rainMap.get(station.getCode()));
waterMonDataVo.setYear(localDate.getYear());
waterMonDataVo.setMonth(localDate.getMonthValue());
float rain = (float) value.stream().mapToDouble(RainFallCountByMonthVo::getRainFallCount).sum();
waterMonDataVo.setRainfall(rain);
waterMonDataVoList.add(waterMonDataVo);
}); });
if (CollectionUtil.isEmpty(waterMonDataVoList)) { if (CollectionUtil.isEmpty(rains)) {
return null; return null;
} }
// 根据年份分组 // 根据年份分组
Map<Integer, List<WaterMonDataVo>> yearMap = waterMonDataVoList.stream().collect(Collectors.groupingBy(WaterMonDataVo::getYear)); Map<Integer, List<RainMon>> years = rains.stream().collect(Collectors.groupingBy(RainMon::getYear));
// 遍历为返回结构 // 遍历为返回结构
List<WaterYearDataVo> result = new ArrayList<>(); return years.entrySet().stream().map(entry-> {
yearMap.forEach((key, value) -> { WaterYearDataVo year = new WaterYearDataVo();
WaterYearDataVo vo = new WaterYearDataVo(); year.setYear(entry.getKey());
vo.setYear(key); year.setMonList(entry.getValue().stream().collect(Collectors.groupingBy(RainMon::getStrMon)).entrySet().stream().map(mon -> {
List<WaterMonDataVo> sortValue = value.stream().sorted(Comparator.comparing(WaterMonDataVo::getMonth)).collect(Collectors.toList()); WaterMonDataVo waterMon = new WaterMonDataVo();
vo.setMonList(sortValue); LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon.getKey() + "-01"), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
result.add(vo); waterMon.setStrMonth(mon.getKey());
}); waterMon.setMonth(localDate.getMonthValue());
return result; waterMon.setRainfall(mon.getValue().stream().mapToDouble(RainMon::getRain).sum());
return waterMon;
}).sorted(Comparator.comparing(WaterMonDataVo::getStrMonth)).collect(Collectors.toList()));
return year;
}).collect(Collectors.toList());
} }
/** /**

2
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, 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 = '结束', 1, 0 )) AS finish,
SUM( IF ( info.flow_description IN ( '作废', '错票' ), 1, 0 )) AS invalid, 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 from hzims_work_ticket_info info
LEFT JOIN hzims_ticket_info_evaluate eval ON info.id = eval.ticket_id LEFT JOIN hzims_ticket_info_evaluate eval ON info.id = eval.ticket_id
<where> <where>

Loading…
Cancel
Save