|
|
|
@ -146,13 +146,24 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
List<AnalyseDataTaosVO> reactives = dataService.periodTargetData(start,end,5,3,device.getEmCode(),HomePageConstant.HYDROPOWER_REACTIVE_GENERATE); |
|
|
|
|
// 是否包含今日累计发电量数据
|
|
|
|
|
Optional<ThirtyGenerationEntity> optional = generations.stream().filter(o->o.getStationId().equals(station.getCode()) && o.getDeviceCode().equals(device.getEmCode())).findFirst(); |
|
|
|
|
if(optional.isPresent()){ |
|
|
|
|
if(StringUtil.isEmpty(records.get(0).getVal())){ |
|
|
|
|
optional.get().setGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
optional.get().setGenerate(BigDecimal.valueOf(Double.parseDouble(records.get(0).getVal()) * device.getRideCount())); |
|
|
|
|
optional.get().setGenerate(BigDecimal.valueOf(Double.parseDouble(records.get(0).getVal()) * device.getRideCount()).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
|
} |
|
|
|
|
// 无功电量
|
|
|
|
|
if(CollectionUtil.isEmpty(reactives)){ |
|
|
|
|
optional.get().setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
if(StringUtil.isEmpty(reactives.get(0).getVal())){ |
|
|
|
|
optional.get().setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
optional.get().setReactiveGenerate(BigDecimal.valueOf(Double.parseDouble(reactives.get(0).getVal()))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
saves.add(optional.get()); |
|
|
|
|
}else{ |
|
|
|
@ -178,6 +189,16 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
}else{ |
|
|
|
|
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(records.get(0).getVal()) * device.getRideCount())); |
|
|
|
|
} |
|
|
|
|
// 无功电量
|
|
|
|
|
if(CollectionUtil.isEmpty(reactives)){ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
if(StringUtil.isEmpty(reactives.get(0).getVal())){ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.valueOf(Double.parseDouble(reactives.get(0).getVal()))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
saves.add(generate); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -287,6 +308,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
List<AnalyseDataTaosVO> reactives = dataService.periodTargetData(start,end,5,3,device.getEmCode(),HomePageConstant.HYDROPOWER_REACTIVE_GENERATE); |
|
|
|
|
// 保存设备发电量
|
|
|
|
|
thirtyGenerateService.saveBatch(records.stream().map(record -> { |
|
|
|
|
ThirtyGenerationEntity generate = new ThirtyGenerationEntity(); |
|
|
|
@ -309,7 +331,22 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
if(StringUtil.isEmpty(record.getVal())){ |
|
|
|
|
generate.setGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount())); |
|
|
|
|
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount()).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
|
} |
|
|
|
|
// 无功电量
|
|
|
|
|
if(CollectionUtil.isEmpty(reactives)){ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
Optional<AnalyseDataTaosVO> optional = reactives.stream().filter(reactive-> record.getTs().equals(reactive.getTs())).findFirst(); |
|
|
|
|
if(optional.isPresent()){ |
|
|
|
|
if(StringUtil.isEmpty(optional.get().getVal())){ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.valueOf(Double.parseDouble(optional.get().getVal()))); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return generate; |
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
@ -352,60 +389,70 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList()); |
|
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(limits.size()); |
|
|
|
|
for(List<StationEntity> item : limits){ |
|
|
|
|
try{ |
|
|
|
|
pool.submit(()->{ |
|
|
|
|
item.forEach(station->{ |
|
|
|
|
// 站点设备集合
|
|
|
|
|
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
// 遍历查询发电量
|
|
|
|
|
eminfos.forEach(device->{ |
|
|
|
|
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); |
|
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
List<AnalyseDataTaosVO> reactives = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_REACTIVE_GENERATE); |
|
|
|
|
// 保存设备发电量
|
|
|
|
|
threeGenerateService.saveBatch(records.stream().map(record -> { |
|
|
|
|
ThreeGenerationEntity generate = new ThreeGenerationEntity(); |
|
|
|
|
generate.setStationId(station.getCode()); |
|
|
|
|
generate.setStationName(station.getName()); |
|
|
|
|
generate.setDeviceCode(device.getEmCode()); |
|
|
|
|
generate.setDeviceName(device.getName()); |
|
|
|
|
generate.setTenantId(station.getTenantId()); |
|
|
|
|
generate.setCreateDept(station.getRefDept()); |
|
|
|
|
generate.setCreateUser(station.getCreateUser()); |
|
|
|
|
generate.setUpdateUser(station.getUpdateUser()); |
|
|
|
|
Date time; |
|
|
|
|
if(record.getTs().contains(".0")){ |
|
|
|
|
time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
}else{ |
|
|
|
|
time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
} |
|
|
|
|
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); |
|
|
|
|
generate.setMonth(time.getMonth() + 1); |
|
|
|
|
if(StringUtil.isEmpty(record.getVal())){ |
|
|
|
|
generate.setGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount())); |
|
|
|
|
} |
|
|
|
|
// 无功电量
|
|
|
|
|
if(CollectionUtil.isEmpty(reactives)){ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
try{ |
|
|
|
|
item.forEach(station->{ |
|
|
|
|
// 站点设备集合
|
|
|
|
|
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
// 遍历查询发电量
|
|
|
|
|
eminfos.forEach(device->{ |
|
|
|
|
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); |
|
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return generate; |
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
List<AnalyseDataTaosVO> reactives = dataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_REACTIVE_GENERATE); |
|
|
|
|
// 保存设备发电量
|
|
|
|
|
threeGenerateService.saveBatch(records.stream().map(record -> { |
|
|
|
|
ThreeGenerationEntity generate = new ThreeGenerationEntity(); |
|
|
|
|
generate.setStationId(station.getCode()); |
|
|
|
|
generate.setStationName(station.getName()); |
|
|
|
|
generate.setDeviceCode(device.getEmCode()); |
|
|
|
|
generate.setDeviceName(device.getName()); |
|
|
|
|
generate.setTenantId(station.getTenantId()); |
|
|
|
|
generate.setCreateDept(station.getRefDept()); |
|
|
|
|
generate.setCreateUser(station.getCreateUser()); |
|
|
|
|
generate.setUpdateUser(station.getUpdateUser()); |
|
|
|
|
Date time; |
|
|
|
|
if(record.getTs().contains(".0")){ |
|
|
|
|
time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
}else{ |
|
|
|
|
time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
} |
|
|
|
|
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); |
|
|
|
|
generate.setMonth(time.getMonth() + 1); |
|
|
|
|
if(StringUtil.isEmpty(record.getVal())){ |
|
|
|
|
generate.setGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount()).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
|
} |
|
|
|
|
// 无功电量
|
|
|
|
|
if(CollectionUtil.isEmpty(reactives)){ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
Optional<AnalyseDataTaosVO> optional = reactives.stream().filter(reactive-> record.getTs().equals(reactive.getTs())).findFirst(); |
|
|
|
|
if(optional.isPresent()){ |
|
|
|
|
if(StringUtil.isEmpty(optional.get().getVal())){ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
}else{ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.valueOf(Double.parseDouble(optional.get().getVal()))); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
generate.setReactiveGenerate(BigDecimal.ZERO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return generate; |
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
}); |
|
|
|
|
// 填报发电量保存
|
|
|
|
|
threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end)); |
|
|
|
|
}); |
|
|
|
|
// 填报发电量保存
|
|
|
|
|
threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end)); |
|
|
|
|
}); |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
log.error("save_generation_execute_complete_error : {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 等待所有线程执行完成
|
|
|
|
|
try { |
|
|
|
@ -453,6 +500,9 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
}else{ |
|
|
|
|
generation.setGenerate(BigDecimal.valueOf(Double.parseDouble(power.getPower().toString())).setScale(2, RoundingMode.HALF_UP)); |
|
|
|
|
} |
|
|
|
|
generation.setReactiveGenerate(BigDecimal.ZERO |
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
return generation; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|