Browse Source

#无功电量

zhongwei
yang_shj 3 months ago
parent
commit
ddbc0860e7
  1. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThirtyGenerationEntity.java
  2. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java
  3. 64
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java

3
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/ThirtyGenerationEntity.java

@ -40,4 +40,7 @@ public class ThirtyGenerationEntity extends TenantEntity {
@ApiModelProperty(value = "发电量") @ApiModelProperty(value = "发电量")
private BigDecimal generate; private BigDecimal generate;
@ApiModelProperty(value = "无功电量")
private BigDecimal reactiveGenerate;
} }

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java

@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
@ -33,6 +34,7 @@ public class GenerationScheduledTask {
* @return * @return
*/ */
@XxlJob(THREE_YEAR_POWER_GENERATION) @XxlJob(THREE_YEAR_POWER_GENERATION)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> threeYearPowerGeneration(String param) { public ReturnT<String> threeYearPowerGeneration(String param) {
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM"); param = DateUtil.format(new Date(), "yyyy-MM");

64
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java

@ -146,13 +146,24 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
if(CollectionUtil.isEmpty(records)){ if(CollectionUtil.isEmpty(records)){
return; 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(); Optional<ThirtyGenerationEntity> optional = generations.stream().filter(o->o.getStationId().equals(station.getCode()) && o.getDeviceCode().equals(device.getEmCode())).findFirst();
if(optional.isPresent()){ if(optional.isPresent()){
if(StringUtil.isEmpty(records.get(0).getVal())){ if(StringUtil.isEmpty(records.get(0).getVal())){
optional.get().setGenerate(BigDecimal.ZERO); optional.get().setGenerate(BigDecimal.ZERO);
}else{ }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()); saves.add(optional.get());
}else{ }else{
@ -178,6 +189,16 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
}else{ }else{
generate.setGenerate(BigDecimal.valueOf(Double.parseDouble(records.get(0).getVal()) * device.getRideCount())); 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); saves.add(generate);
} }
}); });
@ -287,6 +308,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
if(CollectionUtil.isEmpty(records)){ if(CollectionUtil.isEmpty(records)){
return; return;
} }
List<AnalyseDataTaosVO> reactives = dataService.periodTargetData(start,end,5,3,device.getEmCode(),HomePageConstant.HYDROPOWER_REACTIVE_GENERATE);
// 保存设备发电量 // 保存设备发电量
thirtyGenerateService.saveBatch(records.stream().map(record -> { thirtyGenerateService.saveBatch(records.stream().map(record -> {
ThirtyGenerationEntity generate = new ThirtyGenerationEntity(); ThirtyGenerationEntity generate = new ThirtyGenerationEntity();
@ -309,7 +331,22 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
if(StringUtil.isEmpty(record.getVal())){ if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(BigDecimal.ZERO); generate.setGenerate(BigDecimal.ZERO);
}else{ }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; return generate;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
@ -352,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()); 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()); CountDownLatch countDownLatch = new CountDownLatch(limits.size());
for(List<StationEntity> item : limits){ for(List<StationEntity> item : limits){
try{
pool.submit(()->{ pool.submit(()->{
try{
item.forEach(station->{ item.forEach(station->{
// 站点设备集合 // 站点设备集合
List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); List<EminfoAndEmParamVo> eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
@ -386,13 +423,23 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
if(StringUtil.isEmpty(record.getVal())){ if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(BigDecimal.ZERO); generate.setGenerate(BigDecimal.ZERO);
}else{ }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)){ if(CollectionUtil.isEmpty(reactives)){
generate.setReactiveGenerate(BigDecimal.ZERO); 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; return generate;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
}); });
@ -401,11 +448,11 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
}); });
countDownLatch.countDown(); countDownLatch.countDown();
log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
});
}catch (Exception e){ }catch (Exception e){
countDownLatch.countDown(); 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 { try {
@ -453,6 +500,9 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService {
}else{ }else{
generation.setGenerate(BigDecimal.valueOf(Double.parseDouble(power.getPower().toString())).setScale(2, RoundingMode.HALF_UP)); generation.setGenerate(BigDecimal.valueOf(Double.parseDouble(power.getPower().toString())).setScale(2, RoundingMode.HALF_UP));
} }
generation.setReactiveGenerate(BigDecimal.ZERO
);
return generation; return generation;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }

Loading…
Cancel
Save