|
|
@ -12,8 +12,10 @@ import com.hnac.hzims.electric.service.ThirtyService; |
|
|
|
import com.hnac.hzims.electric.service.ThreeService; |
|
|
|
import com.hnac.hzims.electric.service.ThreeService; |
|
|
|
import com.hnac.hzims.electric.vo.ComprehensiveElectricVo; |
|
|
|
import com.hnac.hzims.electric.vo.ComprehensiveElectricVo; |
|
|
|
import com.hnac.hzims.electric.vo.DeviceElectricVo; |
|
|
|
import com.hnac.hzims.electric.vo.DeviceElectricVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.electric.vo.RunParamVo; |
|
|
|
import com.hnac.hzims.electric.vo.TableHeadVo; |
|
|
|
import com.hnac.hzims.electric.vo.TableHeadVo; |
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.hzimsweather.feign.IRainfallClient; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.feign.IStationClient; |
|
|
|
import com.hnac.hzims.operational.station.feign.IStationClient; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
|
|
@ -52,6 +54,8 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IRainfallClient rainClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IStationClient stationClient; |
|
|
|
private final IStationClient stationClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
@ -128,7 +132,8 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
.ge(ThreeEntity::getStrMonth, DateUtil.format(start,DateUtil.PATTERN_DATE)) |
|
|
|
.ge(ThreeEntity::getStrMonth, DateUtil.format(start,DateUtil.PATTERN_DATE)) |
|
|
|
.le(ThreeEntity::getStrMonth, DateUtil.format(end,DateUtil.PATTERN_DATE)) |
|
|
|
.le(ThreeEntity::getStrMonth, DateUtil.format(end,DateUtil.PATTERN_DATE)) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
// 查询站点降雨量
|
|
|
|
|
|
|
|
List<Map<String, Object>> rains = this.rains(station.getData().getCode(),DateUtil.format(start,DateUtil.PATTERN_DATE),DateUtil.format(end,DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse(year,"yyyy")); |
|
|
|
calendar.setTime(DateUtil.parse(year,"yyyy")); |
|
|
|
calendar.add(Calendar.YEAR,1); |
|
|
|
calendar.add(Calendar.YEAR,1); |
|
|
@ -143,6 +148,26 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
comprehensive.setMonth(current.getMonth() + 1 + "月"); |
|
|
|
comprehensive.setMonth(current.getMonth() + 1 + "月"); |
|
|
|
String currentMon = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
String currentMon = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
String currentYear = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
|
String currentYear = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
|
|
|
|
|
if(calendar.getTime().compareTo(new Date()) > 0){ |
|
|
|
|
|
|
|
comprehensive.setMonthGenerate(-1.0); |
|
|
|
|
|
|
|
comprehensive.setLastMonthGenerate(-1.0); |
|
|
|
|
|
|
|
comprehensive.setYearGenerate(-1.0); |
|
|
|
|
|
|
|
comprehensive.setLastYearGenerate(-1.0); |
|
|
|
|
|
|
|
comprehensive.setLastMonthGenerateRate(-1.0); |
|
|
|
|
|
|
|
comprehensive.setLastYearGenerateRate(-1.0); |
|
|
|
|
|
|
|
comprehensive.setMonthEquivalent(-1.0); |
|
|
|
|
|
|
|
comprehensive.setLastMonthEquivalent(-1.0); |
|
|
|
|
|
|
|
comprehensive.setYearEquivalent(-1.0); |
|
|
|
|
|
|
|
comprehensive.setLastYearEquivalent(-1.0); |
|
|
|
|
|
|
|
comprehensive.setMonthRain(-1.0); |
|
|
|
|
|
|
|
comprehensive.setLastMonthRain(-1.0); |
|
|
|
|
|
|
|
comprehensive.setYearRain(-1.0); |
|
|
|
|
|
|
|
comprehensive.setLastYearRain(-1.0); |
|
|
|
|
|
|
|
electrics.add(comprehensive); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH,1); |
|
|
|
|
|
|
|
current = calendar.getTime(); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
String lastMon = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
String lastMon = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
String lastYear = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
|
String lastYear = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
@ -205,16 +230,43 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
comprehensive.setYearEquivalent(0.0); |
|
|
|
comprehensive.setYearEquivalent(0.0); |
|
|
|
comprehensive.setLastYearEquivalent(0.0); |
|
|
|
comprehensive.setLastYearEquivalent(0.0); |
|
|
|
} |
|
|
|
} |
|
|
|
// 降雨 : fixme 模拟降雨
|
|
|
|
// 降雨量
|
|
|
|
comprehensive.setMonthRain(BigDecimal.valueOf(random.nextDouble() * 10 * 8).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
if(CollectionUtil.isNotEmpty(rains)){ |
|
|
|
comprehensive.setLastMonthRain(BigDecimal.valueOf(random.nextDouble() * 10 * 8).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
comprehensive.setMonthRain(rains.stream().mapToDouble(map->{ |
|
|
|
if(CollectionUtil.isEmpty(electrics)){ |
|
|
|
if (map.get("fx_date").toString().contains(currentMon)) { |
|
|
|
comprehensive.setYearRain(comprehensive.getMonthRain()); |
|
|
|
Object object = map.get("precip"); |
|
|
|
comprehensive.setLastYearRain(comprehensive.getLastMonthRain()); |
|
|
|
if(ObjectUtil.isEmpty(object)){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return Double.parseDouble(object.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
}).sum()); |
|
|
|
|
|
|
|
comprehensive.setLastMonthRain(rains.stream().mapToDouble(map->{ |
|
|
|
|
|
|
|
if (map.get("fx_date").toString().contains(lastMon)) { |
|
|
|
|
|
|
|
Object object = map.get("precip"); |
|
|
|
|
|
|
|
if(ObjectUtil.isEmpty(object)){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return Double.parseDouble(object.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
}).sum()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(electrics)){ |
|
|
|
|
|
|
|
comprehensive.setYearRain(comprehensive.getMonthRain()); |
|
|
|
|
|
|
|
comprehensive.setLastYearRain(comprehensive.getLastMonthRain()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
// 累计降雨
|
|
|
|
|
|
|
|
comprehensive.setYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getMonthRain).sum() + comprehensive.getMonthRain()); |
|
|
|
|
|
|
|
comprehensive.setLastYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getLastMonthRain).sum() + comprehensive.getLastMonthRain()); |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
// 累计降雨
|
|
|
|
comprehensive.setMonthRain(0.0); |
|
|
|
comprehensive.setYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getMonthRain).sum() + comprehensive.getMonthRain()); |
|
|
|
comprehensive.setLastMonthRain(0.0); |
|
|
|
comprehensive.setLastYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getLastMonthRain).sum() + comprehensive.getLastMonthRain()); |
|
|
|
comprehensive.setYearRain(0.0); |
|
|
|
|
|
|
|
comprehensive.setLastYearRain(0.0); |
|
|
|
} |
|
|
|
} |
|
|
|
electrics.add(comprehensive); |
|
|
|
electrics.add(comprehensive); |
|
|
|
calendar.add(Calendar.MONTH,1); |
|
|
|
calendar.add(Calendar.MONTH,1); |
|
|
@ -223,6 +275,21 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
return electrics; |
|
|
|
return electrics; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 站点降雨量查询 |
|
|
|
|
|
|
|
* @param stationId |
|
|
|
|
|
|
|
* @param start |
|
|
|
|
|
|
|
* @param end |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<Map<String, Object>> rains(String stationId, String start, String end) { |
|
|
|
|
|
|
|
R<List<Map<String, Object>>> durations = rainClient.getDurationRainFall(stationId,start,end); |
|
|
|
|
|
|
|
if(!durations.isSuccess() || CollectionUtil.isEmpty(durations.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return durations.getData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 确认机构级别 |
|
|
|
* 确认机构级别 |
|
|
@ -307,6 +374,19 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
String day = DateUtil.format(start,DateUtil.PATTERN_DATE); |
|
|
|
String day = DateUtil.format(start,DateUtil.PATTERN_DATE); |
|
|
|
item.add(start.getDate() + "日"); |
|
|
|
item.add(start.getDate() + "日"); |
|
|
|
|
|
|
|
if(start.compareTo(new Date()) > 0){ |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
group.entrySet().stream().sorted(Map.Entry. |
|
|
|
|
|
|
|
comparingByKey()).forEach(entry->{ |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 总计:有功、无功
|
|
|
|
// 总计:有功、无功
|
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); |
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); |
|
|
@ -477,6 +557,18 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
String day = DateUtil.format(start,DateUtil.PATTERN_DATE); |
|
|
|
String day = DateUtil.format(start,DateUtil.PATTERN_DATE); |
|
|
|
item.add(start.getDate() + "日"); |
|
|
|
item.add(start.getDate() + "日"); |
|
|
|
|
|
|
|
if(start.compareTo(new Date()) > 0){ |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
areas.stream().sorted(Comparator.comparing(Dept::getDeptName)).forEach(area->{ |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 总计:有功、无功
|
|
|
|
// 总计:有功、无功
|
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); |
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum()); |
|
|
@ -485,10 +577,14 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
areas.stream().sorted(Comparator.comparing(Dept::getDeptName)).forEach(area->{ |
|
|
|
areas.stream().sorted(Comparator.comparing(Dept::getDeptName)).forEach(area->{ |
|
|
|
List<Long> childs = depts.stream().filter(o->o.getParentId().equals(area.getId())).map(Dept::getId).collect(Collectors.toList()); |
|
|
|
List<Long> childs = depts.stream().filter(o->o.getParentId().equals(area.getId())).map(Dept::getId).collect(Collectors.toList()); |
|
|
|
if(CollectionUtil.isEmpty(childs)){ |
|
|
|
if(CollectionUtil.isEmpty(childs)){ |
|
|
|
|
|
|
|
item.add(0.0); |
|
|
|
|
|
|
|
item.add(0.0); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> codes = stations.getData().stream().filter(o-> childs.contains(o.getRefDept()) && ObjectUtil.isNotEmpty(o.getType()) && o.getType().equals(0)).map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
List<String> codes = stations.getData().stream().filter(o-> childs.contains(o.getRefDept()) && ObjectUtil.isNotEmpty(o.getType()) && o.getType().equals(0)).map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
if(CollectionUtil.isEmpty(codes)){ |
|
|
|
if(CollectionUtil.isEmpty(codes)){ |
|
|
|
|
|
|
|
item.add(0.0); |
|
|
|
|
|
|
|
item.add(0.0); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day) && codes.contains(thirty.getStationId())).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day) && codes.contains(thirty.getStationId())).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
@ -656,6 +752,17 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
String hours = DateUtil.format(start,"yyyy-MM-dd HH"); |
|
|
|
String hours = DateUtil.format(start,"yyyy-MM-dd HH"); |
|
|
|
item.add(start.getHours() + "时"); |
|
|
|
item.add(start.getHours() + "时"); |
|
|
|
|
|
|
|
if(start.compareTo(new Date()) > 0){ |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
stationDevices.stream().sorted(Comparator.comparing(EminfoAndEmParamVo::getOrd)).forEach(device->{ |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
item.add(-1.0); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
// 总计:有功、无功
|
|
|
|
// 总计:有功、无功
|
|
|
|
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getReactiveGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getReactiveGenerate).sum()); |
|
|
@ -900,4 +1007,32 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
}); |
|
|
|
}); |
|
|
|
return electrics; |
|
|
|
return electrics; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 运行报表 |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Map<String, Object> run(RunParamVo param) { |
|
|
|
|
|
|
|
// 设备参数校验
|
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(param.getDeviceSignages())){ |
|
|
|
|
|
|
|
return new HashMap<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询站点
|
|
|
|
|
|
|
|
StationEntity query = new StationEntity(); |
|
|
|
|
|
|
|
query.setRefDept(param.getDeptId()); |
|
|
|
|
|
|
|
R<StationEntity> station = stationClient.getStationByCodeOrRedDept(query); |
|
|
|
|
|
|
|
if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ |
|
|
|
|
|
|
|
return new HashMap<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 开始时间、结束时间
|
|
|
|
|
|
|
|
Date start = DateUtil.parse(param.getTime() + " 00:00:00",DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
Date end = DateUtil.parse(param.getTime() + " 23:59:59",DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |