|
|
@ -2,19 +2,33 @@ package com.hnac.hzims.operational.ecology.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.hnac.hzims.EquipmentConstants; |
|
|
|
|
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
import com.hnac.hzims.operational.ecology.entity.EcologyFlowDataEntity; |
|
|
|
import com.hnac.hzims.operational.ecology.entity.EcologyFlowDataEntity; |
|
|
|
import com.hnac.hzims.operational.ecology.entity.EcologyFlowStationEntity; |
|
|
|
import com.hnac.hzims.operational.ecology.entity.EcologyFlowStationEntity; |
|
|
|
import com.hnac.hzims.operational.ecology.mapper.EcologyFlowStationMapper; |
|
|
|
import com.hnac.hzims.operational.ecology.mapper.EcologyFlowStationMapper; |
|
|
|
import com.hnac.hzims.operational.ecology.service.EcologyFlowDataService; |
|
|
|
import com.hnac.hzims.operational.ecology.service.EcologyFlowDataService; |
|
|
|
import com.hnac.hzims.operational.ecology.service.EcologyFlowStationService; |
|
|
|
import com.hnac.hzims.operational.ecology.service.EcologyFlowStationService; |
|
|
|
import com.hnac.hzims.operational.ecology.vo.DemonstrateTopVo; |
|
|
|
import com.hnac.hzims.operational.ecology.vo.*; |
|
|
|
import com.hnac.hzims.operational.ecology.vo.EcologFlowStationVo; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.ecology.vo.TrendChartVo; |
|
|
|
import com.hnac.hzims.operational.main.service.IAnalyseDataService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.vo.GenerationPowerVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.vo.HydropowerUnitTargetVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.vo.WaterLevelVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.service.IHzimsAnalyzeModelStationService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
@ -30,8 +44,23 @@ import java.util.stream.Collectors; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowStationMapper, EcologyFlowStationEntity> implements EcologyFlowStationService { |
|
|
|
public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowStationMapper, EcologyFlowStationEntity> implements EcologyFlowStationService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
|
|
private final EcologyFlowDataService dataService; |
|
|
|
private final EcologyFlowDataService dataService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataService analyseDataService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IMainSystemMonitoringService maintenanceTaskService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IHzimsAnalyzeModelStationService modelStationService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; |
|
|
|
|
|
|
|
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; |
|
|
|
|
|
|
|
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 数据初始化 |
|
|
|
* 数据初始化 |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -142,4 +171,133 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt |
|
|
|
} |
|
|
|
} |
|
|
|
return charts.stream().sorted(Comparator.comparing(TrendChartVo::getTs)).collect(Collectors.toList()); |
|
|
|
return charts.stream().sorted(Comparator.comparing(TrendChartVo::getTs)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 接入站点数据 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<StationVo> station() { |
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
|
|
|
.in(StationEntity::getCode,Arrays.asList("902400000054","902400052664"))); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 实时监测点数据
|
|
|
|
|
|
|
|
List<HydropowerUnitRealVo> realList = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); |
|
|
|
|
|
|
|
// 获取站点机组指标数据
|
|
|
|
|
|
|
|
List<HydropowerUnitTargetVo> targetList = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); |
|
|
|
|
|
|
|
// 所有设备
|
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList(); |
|
|
|
|
|
|
|
return stations.stream().map(item -> { |
|
|
|
|
|
|
|
StationVo station = new StationVo(); |
|
|
|
|
|
|
|
station.setStationId(item.getCode()); |
|
|
|
|
|
|
|
station.setStationName(item.getName()); |
|
|
|
|
|
|
|
station.setDevices(this.devices(item,realList,targetList)); |
|
|
|
|
|
|
|
// 实时水位
|
|
|
|
|
|
|
|
this.handleWaterLeve(item.getCode(),station); |
|
|
|
|
|
|
|
// 查询站点模型列表
|
|
|
|
|
|
|
|
HzimsAnalyzeModelStationEntity model = modelStationService.getOne(new LambdaQueryWrapper<HzimsAnalyzeModelStationEntity>() {{ |
|
|
|
|
|
|
|
eq(HzimsAnalyzeModelStationEntity::getStationId, item.getCode()); |
|
|
|
|
|
|
|
}}); |
|
|
|
|
|
|
|
// 水位曲线
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(model)){ |
|
|
|
|
|
|
|
station.setWaters(this. water(model.getInstanceCode())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return station; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取站点设备信息 |
|
|
|
|
|
|
|
* @param station |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<DeviceVo> devices(StationEntity station, List<HydropowerUnitRealVo> realList, List<HydropowerUnitTargetVo> targetList) { |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(realList) || CollectionUtil.isEmpty(targetList)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 有效站点机组数据
|
|
|
|
|
|
|
|
List<HydropowerUnitRealVo> validRealList = realList.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<>(); |
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
|
|
for(HydropowerUnitRealVo real : validRealList){ |
|
|
|
|
|
|
|
DeviceVo device= new DeviceVo(); |
|
|
|
|
|
|
|
// 设备编号
|
|
|
|
|
|
|
|
device.setDeviceCode(real.getDeviceCode()); |
|
|
|
|
|
|
|
device.setDeviceName(real.getDeviceName()); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
list.add(device); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list.stream().sorted(Comparator.comparing(DeviceVo::getDeviceCode)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 站点水位数据处理 |
|
|
|
|
|
|
|
* @param code |
|
|
|
|
|
|
|
* @param station |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void handleWaterLeve(String code, StationVo station) { |
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
|
|
station.setWater(random.nextDouble() * 100); |
|
|
|
|
|
|
|
List<WaterLevelVo> levelList = (List<WaterLevelVo>) redisTemplate.opsForValue().get(loadwater_level_key); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(levelList)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<WaterLevelVo> validList = levelList.stream().filter(o-> code.equals(o.getStationCode())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(validList)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
WaterLevelVo level = validList.get(0); |
|
|
|
|
|
|
|
station.setWater(level.getFrontWaterLevel()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取水位数据 |
|
|
|
|
|
|
|
* @param code |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<WaterVo> water(String code) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-7); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
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 records.stream().map(record -> { |
|
|
|
|
|
|
|
WaterVo water = new WaterVo(); |
|
|
|
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
|
|
|
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.setGenerate(random.nextDouble() * 50000); |
|
|
|
|
|
|
|
return water; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |