|
|
|
@ -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{ |
|
|
|
@ -165,7 +176,12 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
generate.setCreateDept(station.getRefDept()); |
|
|
|
|
generate.setCreateUser(station.getCreateUser()); |
|
|
|
|
generate.setUpdateUser(station.getUpdateUser()); |
|
|
|
|
Date time = DateUtil.parse(records.get(0).getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
Date time; |
|
|
|
|
if(records.get(0).getTs().contains(".0")){ |
|
|
|
|
time = DateUtil.parse(records.get(0).getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
}else{ |
|
|
|
|
time = DateUtil.parse(records.get(0).getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
} |
|
|
|
|
generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME)); |
|
|
|
|
generate.setDay(time.getDate()); |
|
|
|
|
if(StringUtil.isEmpty(records.get(0).getVal())){ |
|
|
|
@ -173,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); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -271,8 +297,8 @@ 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(()->{ |
|
|
|
|
try{ |
|
|
|
|
item.forEach(station->{ |
|
|
|
|
// 站点设备集合
|
|
|
|
|
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
@ -282,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(); |
|
|
|
@ -293,13 +320,33 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
generate.setCreateDept(station.getRefDept()); |
|
|
|
|
generate.setCreateUser(station.getCreateUser()); |
|
|
|
|
generate.setUpdateUser(station.getUpdateUser()); |
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
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.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME)); |
|
|
|
|
generate.setDay(time.getDate()); |
|
|
|
|
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())); |
|
|
|
@ -307,11 +354,11 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
}); |
|
|
|
|
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 : {}" ,e.getMessage()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// 等待所有线程执行完成
|
|
|
|
|
try { |
|
|
|
@ -342,8 +389,8 @@ 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(()->{ |
|
|
|
|
try{ |
|
|
|
|
item.forEach(station->{ |
|
|
|
|
// 站点设备集合
|
|
|
|
|
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
@ -353,6 +400,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
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(); |
|
|
|
@ -364,13 +412,33 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
generate.setCreateDept(station.getRefDept()); |
|
|
|
|
generate.setCreateUser(station.getCreateUser()); |
|
|
|
|
generate.setUpdateUser(station.getUpdateUser()); |
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
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())); |
|
|
|
|
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())); |
|
|
|
@ -380,11 +448,11 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
|
|
|
|
|
}); |
|
|
|
|
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 : {}" ,e.getMessage()); |
|
|
|
|
log.error("save_generation_execute_complete_error : {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// 等待所有线程执行完成
|
|
|
|
|
try { |
|
|
|
@ -432,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()); |
|
|
|
|
} |
|
|
|
|