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>
<artifactId>blade-system-api</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>hzims-model</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<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 = "水位")
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)){
station.setWaters(this. water(model.getInstanceCode()));
station.setWaters(this.water(model.getInstanceCode()));
}
return station;
}).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<DeviceVo> list = new ArrayList<>();
Random random = new Random();
for(HydropowerUnitRealVo real : validRealList){
DeviceVo device= new DeviceVo();
// 设备编号
@ -231,10 +230,10 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
device.setState(real.getState());
device.setActive(real.getActivePower());
device.setReactive(real.getReactivePower());
device.setEcology(random.nextDouble() * 20000);
device.setAdjust(random.nextDouble() * 20000);
device.setDischarge(random.nextDouble() * 20000);
device.setGenerate(random.nextDouble() * 20000);
device.setEcology(0.0);
device.setAdjust(0.0);
device.setDischarge(0.0);
device.setGenerate(0.0);
list.add(device);
}
return list.stream().sorted(Comparator.comparing(DeviceVo::getDeviceCode)).collect(Collectors.toList());
@ -247,8 +246,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
* @param station
*/
private void handleWaterLeve(String code, StationVo station) {
Random random = new Random();
station.setWater(random.nextDouble() * 100);
station.setWater(0.0);
List<WaterLevelVo> levelList = (List<WaterLevelVo>) redisTemplate.opsForValue().get(loadwater_level_key);
if(CollectionUtil.isEmpty(levelList)){
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);
Random random = new Random();
if(CollectionUtil.isEmpty(records)){
List<WaterVo> waters = 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 new ArrayList<>();
}
return records.stream().map(record -> {
WaterVo water = new WaterVo();
@ -294,9 +283,8 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
water.setTime(DateUtil.format(time,DateUtil.PATTERN_DATE));
water.setWater(Double.valueOf(Optional.ofNullable(record.getVal()).orElse("0")));
if(Math.abs(water.getWater()) == 0){
water.setWater(random.nextDouble() * 100);
water.setWater(0.0);
}
water.setGenerate(random.nextDouble() * 50000);
return water;
}).collect(Collectors.toList());
}

Loading…
Cancel
Save