|
@@ -49,13 +49,11 @@ public class CalcEquipPowerGenDay {
|
|
* 风机id,1分钟理论发电量
|
|
* 风机id,1分钟理论发电量
|
|
*/
|
|
*/
|
|
private Map<String, List<RealtimeAverageTarget>> ratsListMap;
|
|
private Map<String, List<RealtimeAverageTarget>> ratsListMap;
|
|
- /**
|
|
|
|
- * 风机id,日信息
|
|
|
|
- */
|
|
|
|
- private Map<String, EquipPowerGenDay> sepgdMap;
|
|
|
|
|
|
|
|
@XxlJob("CalcEquipPowerGenDay")
|
|
@XxlJob("CalcEquipPowerGenDay")
|
|
public void calcEquipPowerGenDay() {
|
|
public void calcEquipPowerGenDay() {
|
|
|
|
+ //风机id,日信息
|
|
|
|
+ Map<String, EquipPowerGenDay> sepgdMap = new HashMap<>();
|
|
|
|
|
|
String command = XxlJobHelper.getJobParam();
|
|
String command = XxlJobHelper.getJobParam();
|
|
Map<String, String> map = new HashMap<>();
|
|
Map<String, String> map = new HashMap<>();
|
|
@@ -74,9 +72,9 @@ public class CalcEquipPowerGenDay {
|
|
DateTime startDateTime = DateUtil.beginOfDay(date);
|
|
DateTime startDateTime = DateUtil.beginOfDay(date);
|
|
DateTime endDateTime = DateUtil.endOfDay(date);
|
|
DateTime endDateTime = DateUtil.endOfDay(date);
|
|
|
|
|
|
- calcGeneratingCapacity(startDateTime, endDateTime);
|
|
|
|
- calcTheoryGeneration(startDateTime, endDateTime);
|
|
|
|
- calcLossPower(startDateTime, endDateTime);
|
|
|
|
|
|
+ calcGeneratingCapacity(sepgdMap, startDateTime, endDateTime);
|
|
|
|
+ calcTheoryGeneration(sepgdMap, startDateTime, endDateTime);
|
|
|
|
+ calcLossPower(sepgdMap, startDateTime, endDateTime);
|
|
|
|
|
|
//删除旧数据
|
|
//删除旧数据
|
|
QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
|
|
QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
|
|
@@ -90,6 +88,48 @@ public class CalcEquipPowerGenDay {
|
|
equipPowerGenDayService.saveBatch(clpsw);
|
|
equipPowerGenDayService.saveBatch(clpsw);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @XxlJob("FiveMinutesCalcGenDay")
|
|
|
|
+ public void fiveMinutesCalcGenDay() {
|
|
|
|
+ DateTime date = DateUtil.date();
|
|
|
|
+ DateTime startDateTime = DateUtil.beginOfDay(date);
|
|
|
|
+ DateTime endDateTime = date;
|
|
|
|
+
|
|
|
|
+ //风机id,日信息
|
|
|
|
+ Map<String, EquipPowerGenDay> sepgdMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ calcGeneratingCapacity(sepgdMap, startDateTime, endDateTime);
|
|
|
|
+ calcTheoryGeneration(sepgdMap, startDateTime, endDateTime);
|
|
|
|
+ calcLossPower(sepgdMap, startDateTime, endDateTime);
|
|
|
|
+
|
|
|
|
+ /*List<EquipPowerGenDay> list1 = sepgdMap.values().stream().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
|
|
|
|
+ epgdWrapper.eq("date", startDateTime.toLocalDateTime());
|
|
|
|
+ List<EquipPowerGenDay> list2 = equipPowerGenDayService.list(epgdWrapper);
|
|
|
|
+
|
|
|
|
+ if (list2.size() > 0) {
|
|
|
|
+ list1.forEach(equip1 ->
|
|
|
|
+ list2.stream().filter(equip2 ->
|
|
|
|
+ equip1.getStation().equals(equip2.getStation()) &&
|
|
|
|
+ equip1.getCategory().equals(equip2.getCategory()) &&
|
|
|
|
+ equip1.getFacilityId().equals(equip2.getFacilityId()) &&
|
|
|
|
+ equip1.getDate().equals(equip2.getDate()))
|
|
|
|
+ .findFirst().ifPresent(equip2 -> equip1.setId(equip2.getId())));
|
|
|
|
+ list1 = list1.stream().filter(l -> l.getId() != null).collect(Collectors.toList());
|
|
|
|
+ }*/
|
|
|
|
+ //删除旧数据
|
|
|
|
+ QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
|
|
|
|
+ epgdWrapper.eq("date", startDateTime.toLocalDateTime());
|
|
|
|
+ equipPowerGenDayService.remove(epgdWrapper);
|
|
|
|
+
|
|
|
|
+ //保存风机数据
|
|
|
|
+ equipPowerGenDayService.saveBatch(sepgdMap.values());
|
|
|
|
+
|
|
|
|
+ List<EquipPowerGenDay> clpsw = calcLineProjectStationWindpower(startDateTime.toLocalDateTime().toLocalDate());
|
|
|
|
+ //保存线路、期次、场站,风电数据
|
|
|
|
+ equipPowerGenDayService.saveOrUpdateBatch(clpsw);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 计算线路、期次、场站,风电的日电量信息(发电量、理论电量、损失电量、五损电量)
|
|
* 计算线路、期次、场站,风电的日电量信息(发电量、理论电量、损失电量、五损电量)
|
|
*/
|
|
*/
|
|
@@ -107,7 +147,7 @@ public class CalcEquipPowerGenDay {
|
|
genDay.setCategory("line");
|
|
genDay.setCategory("line");
|
|
genDay.setFacilityId(line);
|
|
genDay.setFacilityId(line);
|
|
List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
|
|
List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
|
|
- extracted(genDay, filterStream);
|
|
|
|
|
|
+ CacheContext.summation(genDay, filterStream);
|
|
equipPowerGenDayList.add(genDay);
|
|
equipPowerGenDayList.add(genDay);
|
|
});
|
|
});
|
|
CacheContext.projectEquipidMap.forEach((project, equipidList) -> {
|
|
CacheContext.projectEquipidMap.forEach((project, equipidList) -> {
|
|
@@ -117,7 +157,7 @@ public class CalcEquipPowerGenDay {
|
|
genDay.setCategory("project");
|
|
genDay.setCategory("project");
|
|
genDay.setFacilityId(project);
|
|
genDay.setFacilityId(project);
|
|
List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
|
|
List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
|
|
- extracted(genDay, filterStream);
|
|
|
|
|
|
+ CacheContext.summation(genDay, filterStream);
|
|
equipPowerGenDayList.add(genDay);
|
|
equipPowerGenDayList.add(genDay);
|
|
});
|
|
});
|
|
CacheContext.stationEquipidMap.forEach((station, equipidList) -> {
|
|
CacheContext.stationEquipidMap.forEach((station, equipidList) -> {
|
|
@@ -127,36 +167,23 @@ public class CalcEquipPowerGenDay {
|
|
genDay.setCategory("station");
|
|
genDay.setCategory("station");
|
|
genDay.setFacilityId(station);
|
|
genDay.setFacilityId(station);
|
|
List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
|
|
List<EquipPowerGenDay> filterStream = epgdList.stream().filter(epgd -> equipidList.contains(epgd.getFacilityId())).collect(Collectors.toList());
|
|
- extracted(genDay, filterStream);
|
|
|
|
|
|
+ CacheContext.summation(genDay, filterStream);
|
|
equipPowerGenDayList.add(genDay);
|
|
equipPowerGenDayList.add(genDay);
|
|
});
|
|
});
|
|
EquipPowerGenDay genDay = new EquipPowerGenDay();
|
|
EquipPowerGenDay genDay = new EquipPowerGenDay();
|
|
genDay.setDate(time1);
|
|
genDay.setDate(time1);
|
|
genDay.setCategory("windpower");
|
|
genDay.setCategory("windpower");
|
|
- genDay.setFacilityId("NX");
|
|
|
|
- extracted(genDay, epgdList);
|
|
|
|
|
|
+ genDay.setFacilityId("FD");
|
|
|
|
+ CacheContext.summation(genDay, epgdList);
|
|
equipPowerGenDayList.add(genDay);
|
|
equipPowerGenDayList.add(genDay);
|
|
|
|
|
|
return equipPowerGenDayList;
|
|
return equipPowerGenDayList;
|
|
}
|
|
}
|
|
|
|
|
|
- private void extracted(EquipPowerGenDay genDay, List<EquipPowerGenDay> filterStream) {
|
|
|
|
- genDay.setGeneratingCapacity(filterStream.stream().map(e -> e.getGeneratingCapacity() != null ? e.getGeneratingCapacity() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
- genDay.setTheoryGeneration(filterStream.stream().map(e -> e.getTheoryGeneration() != null ? e.getTheoryGeneration() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
- genDay.setLossPower(filterStream.stream().map(e -> e.getLossPower() != null ? e.getLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
-
|
|
|
|
- genDay.setFaultLossPower(filterStream.stream().map(e -> e.getFaultLossPower() != null ? e.getFaultLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
- genDay.setMaintainLossPower(filterStream.stream().map(e -> e.getMaintainLossPower() != null ? e.getMaintainLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
- genDay.setImplicateLossPower(filterStream.stream().map(e -> e.getImplicateLossPower() != null ? e.getImplicateLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
- genDay.setLimitLossPower(filterStream.stream().map(e -> e.getLimitLossPower() != null ? e.getLimitLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
- genDay.setPerformanceLossPower(filterStream.stream().map(e -> e.getPerformanceLossPower() != null ? e.getPerformanceLossPower() : BigDecimal.valueOf(0)).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
|
- genDay.setMeanWindSpeed(BigDecimal.valueOf(filterStream.stream().filter(e -> e.getMeanWindSpeed() != null && e.getMeanWindSpeed().doubleValue() != 0).mapToDouble(e -> e.getMeanWindSpeed().doubleValue()).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 计算损失电量
|
|
* 计算损失电量
|
|
*/
|
|
*/
|
|
- private void calcLossPower(DateTime time1, DateTime time2) {
|
|
|
|
|
|
+ private void calcLossPower(Map<String, EquipPowerGenDay> sepgdMap, DateTime time1, DateTime time2) {
|
|
|
|
|
|
//查询1分钟理论发电量
|
|
//查询1分钟理论发电量
|
|
QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
|
|
QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
|
|
@@ -180,7 +207,10 @@ public class CalcEquipPowerGenDay {
|
|
scWrapper.select("start_time", "end_time", "event", "time", "station_id", "equipment_id").ne("event", "待机")
|
|
scWrapper.select("start_time", "end_time", "event", "time", "station_id", "equipment_id").ne("event", "待机")
|
|
.ge("start_time", time1).le("end_time", time2);
|
|
.ge("start_time", time1).le("end_time", time2);
|
|
List<StateCause> scList = stateCauseService.list(scWrapper);
|
|
List<StateCause> scList = stateCauseService.list(scWrapper);
|
|
- Map<String, List<StateCause>> scsListMap = scList.stream().collect(Collectors.groupingBy(StateCause::getEquipmentId));
|
|
|
|
|
|
+ //读取用户标记并按风机分类
|
|
|
|
+ Map<String, List<StateCause>> scsListMap = scList.stream().peek(sc->{
|
|
|
|
+ if(StrUtil.isNotBlank(sc.getUserFlag())) sc.setEvent(sc.getUserFlag());
|
|
|
|
+ }).collect(Collectors.groupingBy(StateCause::getEquipmentId));
|
|
|
|
|
|
String equipId;
|
|
String equipId;
|
|
EquipPowerGenDay epgd;
|
|
EquipPowerGenDay epgd;
|
|
@@ -259,7 +289,7 @@ public class CalcEquipPowerGenDay {
|
|
/**
|
|
/**
|
|
* 计算理论电量
|
|
* 计算理论电量
|
|
*/
|
|
*/
|
|
- private void calcTheoryGeneration(DateTime time1, DateTime time2) {
|
|
|
|
|
|
+ private void calcTheoryGeneration(Map<String, EquipPowerGenDay> sepgdMap, DateTime time1, DateTime time2) {
|
|
|
|
|
|
//查询1分钟平均风速
|
|
//查询1分钟平均风速
|
|
QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
|
|
QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
|
|
@@ -308,15 +338,13 @@ public class CalcEquipPowerGenDay {
|
|
/**
|
|
/**
|
|
* 计算日发电量
|
|
* 计算日发电量
|
|
*/
|
|
*/
|
|
- private void calcGeneratingCapacity(DateTime time1, DateTime time2) {
|
|
|
|
|
|
+ private void calcGeneratingCapacity(Map<String, EquipPowerGenDay> sepgdMap, DateTime time1, DateTime time2) {
|
|
|
|
|
|
//开始时间00:00:01
|
|
//开始时间00:00:01
|
|
//DateTime dateTime1 = DateUtil.offsetSecond(time1, 1);
|
|
//DateTime dateTime1 = DateUtil.offsetSecond(time1, 1);
|
|
//结束时间第二天00:00:01
|
|
//结束时间第二天00:00:01
|
|
//DateTime dateTime2 = DateUtil.offsetSecond(time2, 2);
|
|
//DateTime dateTime2 = DateUtil.offsetSecond(time2, 2);
|
|
|
|
|
|
- sepgdMap = new HashMap<>();
|
|
|
|
-
|
|
|
|
//1,在testingpoint中根据 uniform_code=AI064 和code like "%_FJ_%" 取出所有风机的电量测点code
|
|
//1,在testingpoint中根据 uniform_code=AI064 和code like "%_FJ_%" 取出所有风机的电量测点code
|
|
List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>().eq("uniform_code", "AI064").eq("thing_type", "windturbine"));
|
|
List<TestingPoint> testingPointList = testingPointService.list(new QueryWrapper<TestingPoint>().eq("uniform_code", "AI064").eq("thing_type", "windturbine"));
|
|
//2,遍历list,每次取出一个code
|
|
//2,遍历list,每次取出一个code
|
|
@@ -387,6 +415,30 @@ public class CalcEquipPowerGenDay {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public synchronized void recalculationGeneratingCapacity(DateTime date){
|
|
|
|
+
|
|
|
|
+ //风机id,日信息
|
|
|
|
+ Map<String, EquipPowerGenDay> sepgdMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ //2,获取当前日期,当日开始时间
|
|
|
|
+ DateTime startDateTime = DateUtil.beginOfDay(date);
|
|
|
|
+ DateTime endDateTime = DateUtil.endOfDay(date);
|
|
|
|
+
|
|
|
|
+ calcGeneratingCapacity(sepgdMap, startDateTime, endDateTime);
|
|
|
|
+ calcTheoryGeneration(sepgdMap, startDateTime, endDateTime);
|
|
|
|
+ calcLossPower(sepgdMap, startDateTime, endDateTime);
|
|
|
|
+
|
|
|
|
+ //删除旧数据
|
|
|
|
+ QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
|
|
|
|
+ epgdWrapper.eq("date", startDateTime.toLocalDateTime());
|
|
|
|
+ equipPowerGenDayService.remove(epgdWrapper);
|
|
|
|
+ //保存风机数据
|
|
|
|
+ equipPowerGenDayService.saveBatch(sepgdMap.values());
|
|
|
|
+
|
|
|
|
+ List<EquipPowerGenDay> clpsw = calcLineProjectStationWindpower(startDateTime.toLocalDateTime().toLocalDate());
|
|
|
|
+ //保存线路、期次、场站,风电数据
|
|
|
|
+ equipPowerGenDayService.saveBatch(clpsw);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|