Browse Source

#定时任务抽离

zhongwei
yang_shj 1 year ago
parent
commit
3f76936e76
  1. 8
      hzims-service-api/hzims-operational-api/pom.xml
  2. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/WaterVo.java
  3. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java

8
hzims-service-api/hzims-operational-api/pom.xml

@ -57,14 +57,6 @@
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-system-api</artifactId> <artifactId>blade-system-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>hzims-model</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<artifactId>hzims-biz-common</artifactId> <artifactId>hzims-biz-common</artifactId>

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/WaterVo.java

@ -15,8 +15,4 @@ public class WaterVo {
@ApiModelProperty(value = "水位") @ApiModelProperty(value = "水位")
private Double water; private Double water;
}
@ApiModelProperty(value = "发电流量")
private Double generate;
}

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java

@ -202,7 +202,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
}}); }});
// 水位曲线 // 水位曲线
if(ObjectUtil.isNotEmpty(model)){ if(ObjectUtil.isNotEmpty(model)){
station.setWaters(this. water(model.getInstanceCode())); station.setWaters(this.water(model.getInstanceCode()));
} }
return station; return station;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@ -222,7 +222,6 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
// 有效站点机组指标数据 // 有效站点机组指标数据
List<HydropowerUnitTargetVo> validTargetList = targetList.stream().filter(o-> null != station.getRefDept() && station.getRefDept().equals(o.getDeptId())).collect(Collectors.toList()); List<HydropowerUnitTargetVo> validTargetList = targetList.stream().filter(o-> null != station.getRefDept() && station.getRefDept().equals(o.getDeptId())).collect(Collectors.toList());
List<DeviceVo> list = new ArrayList<>(); List<DeviceVo> list = new ArrayList<>();
Random random = new Random();
for(HydropowerUnitRealVo real : validRealList){ for(HydropowerUnitRealVo real : validRealList){
DeviceVo device= new DeviceVo(); DeviceVo device= new DeviceVo();
// 设备编号 // 设备编号
@ -231,10 +230,10 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
device.setState(real.getState()); device.setState(real.getState());
device.setActive(real.getActivePower()); device.setActive(real.getActivePower());
device.setReactive(real.getReactivePower()); device.setReactive(real.getReactivePower());
device.setEcology(random.nextDouble() * 20000); device.setEcology(0.0);
device.setAdjust(random.nextDouble() * 20000); device.setAdjust(0.0);
device.setDischarge(random.nextDouble() * 20000); device.setDischarge(0.0);
device.setGenerate(random.nextDouble() * 20000); device.setGenerate(0.0);
list.add(device); list.add(device);
} }
return list.stream().sorted(Comparator.comparing(DeviceVo::getDeviceCode)).collect(Collectors.toList()); return list.stream().sorted(Comparator.comparing(DeviceVo::getDeviceCode)).collect(Collectors.toList());
@ -247,8 +246,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
* @param station * @param station
*/ */
private void handleWaterLeve(String code, StationVo station) { private void handleWaterLeve(String code, StationVo station) {
Random random = new Random(); station.setWater(0.0);
station.setWater(random.nextDouble() * 100);
List<WaterLevelVo> levelList = (List<WaterLevelVo>) redisTemplate.opsForValue().get(loadwater_level_key); List<WaterLevelVo> levelList = (List<WaterLevelVo>) redisTemplate.opsForValue().get(loadwater_level_key);
if(CollectionUtil.isEmpty(levelList)){ if(CollectionUtil.isEmpty(levelList)){
return; return;
@ -277,16 +275,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,3,3,code,HomePageConstant.FRONT_WATER_LEVEL); List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,3,3,code,HomePageConstant.FRONT_WATER_LEVEL);
Random random = new Random(); Random random = new Random();
if(CollectionUtil.isEmpty(records)){ if(CollectionUtil.isEmpty(records)){
List<WaterVo> waters = new ArrayList<>(); return new ArrayList<>();
while (calendar.getTime().compareTo(new Date()) <= 0){
WaterVo water = new WaterVo();
water.setTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE));
water.setWater(random.nextDouble() * 100);
water.setGenerate(random.nextDouble() * 50000);
waters.add(water);
calendar.add(Calendar.DAY_OF_MONTH,1);
}
return waters;
} }
return records.stream().map(record -> { return records.stream().map(record -> {
WaterVo water = new WaterVo(); WaterVo water = new WaterVo();
@ -294,9 +283,8 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
water.setTime(DateUtil.format(time,DateUtil.PATTERN_DATE)); water.setTime(DateUtil.format(time,DateUtil.PATTERN_DATE));
water.setWater(Double.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); water.setWater(Double.valueOf(Optional.ofNullable(record.getVal()).orElse("0")));
if(Math.abs(water.getWater()) == 0){ if(Math.abs(water.getWater()) == 0){
water.setWater(random.nextDouble() * 100); water.setWater(0.0);
} }
water.setGenerate(random.nextDouble() * 50000);
return water; return water;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }

Loading…
Cancel
Save