|
|
@ -1,39 +1,18 @@ |
|
|
|
package com.hnac.hzims.operational.main.service.impl; |
|
|
|
package com.hnac.hzims.operational.main.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.hnac.hzims.EquipmentConstants; |
|
|
|
|
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.Daily; |
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.Daily; |
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; |
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; |
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; |
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; |
|
|
|
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.fill.service.UseService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.home.wind.RainMon; |
|
|
|
import com.hnac.hzims.operational.home.wind.RainMon; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.service.*; |
|
|
|
import com.hnac.hzims.operational.main.service.AreaService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.service.IWaterService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.service.IWeatherService; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.station.StationConstants; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
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.hzims.operational.station.service.IStationService; |
|
|
|
import com.hnac.hzinfo.datasearch.PointData; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.HzPage; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
@ -65,26 +44,16 @@ import java.util.stream.Collectors; |
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
public class WaterServiceImpl implements IWaterService { |
|
|
|
public class WaterServiceImpl implements IWaterService { |
|
|
|
|
|
|
|
|
|
|
|
private final UseService useService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final AreaService areaService; |
|
|
|
private final AreaService areaService; |
|
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
|
|
private final IWeatherService weatherService; |
|
|
|
private final IWeatherService weatherService; |
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataService analyseDataService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IMainSystemMonitoringService maintenanceTaskService; |
|
|
|
private final IMainSystemMonitoringService maintenanceTaskService; |
|
|
|
|
|
|
|
|
|
|
|
private final IHzimsAnalyzeModelStationService modelStationService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IHistoryDataSearchClient historyDataSearchClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.realIdKey}") |
|
|
|
@Value("${hzims.operation.realIdKey}") |
|
|
@ -94,730 +63,6 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
private final static String loadwaterpump_rain_key = "hzims:operation:loadwaterpump:rain:key"; |
|
|
|
private final static String loadwaterpump_rain_key = "hzims:operation:loadwaterpump:rain:key"; |
|
|
|
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; |
|
|
|
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 水利-泵组实时加载 |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void loadWaterPumpReal(String param) { |
|
|
|
|
|
|
|
// 水利站点
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
|
|
|
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) |
|
|
|
|
|
|
|
.in(StationEntity::getType,HomePageConstant.waterList) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 泵站设备
|
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(devices)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 实时数据
|
|
|
|
|
|
|
|
Map<String, String> map = this.getRealMap(); |
|
|
|
|
|
|
|
List<WaterPumpRealVo> list = devices.stream().map(device->{ |
|
|
|
|
|
|
|
WaterPumpRealVo real = new WaterPumpRealVo(); |
|
|
|
|
|
|
|
real.setDeptId(device.getCreateDept()); |
|
|
|
|
|
|
|
real.setDeviceCode(device.getEmCode()); |
|
|
|
|
|
|
|
real.setDeptName(device.getName()); |
|
|
|
|
|
|
|
// 装机容量
|
|
|
|
|
|
|
|
real.setInstalledCapacity(device.getInstalledCapacity()); |
|
|
|
|
|
|
|
// 开机状态
|
|
|
|
|
|
|
|
real.setState(this.getPumpState(device,map)); |
|
|
|
|
|
|
|
// 功率因数
|
|
|
|
|
|
|
|
real.setPowerFactor(this.getPowerFactor(device,map)); |
|
|
|
|
|
|
|
// 有功功率
|
|
|
|
|
|
|
|
real.setActivePower(this.getActivePower(device,map)); |
|
|
|
|
|
|
|
// 无功功率
|
|
|
|
|
|
|
|
real.setReactivePower(this.getReactivePower(device,map)); |
|
|
|
|
|
|
|
// 电压
|
|
|
|
|
|
|
|
real.setVoltage(this.getVoltage(device,map)); |
|
|
|
|
|
|
|
// 电流
|
|
|
|
|
|
|
|
real.setCurrent(this.getCurrent(device,map)); |
|
|
|
|
|
|
|
return real; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(loadwaterpump_real_key,list); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 水利-泵组指标加载 |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void loadWaterPumpTarget(String param) { |
|
|
|
|
|
|
|
// 水利站点
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
|
|
|
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) |
|
|
|
|
|
|
|
.in(StationEntity::getType,HomePageConstant.waterList) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 泵站设备
|
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); |
|
|
|
|
|
|
|
// 补充站点填报发电量
|
|
|
|
|
|
|
|
List<WaterPumpTargetVo> list = this.useFill(stations); |
|
|
|
|
|
|
|
// 站点设备数据统计
|
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(devices)){ |
|
|
|
|
|
|
|
list.addAll(devices.stream().map(device->{ |
|
|
|
|
|
|
|
WaterPumpTargetVo target = new WaterPumpTargetVo(); |
|
|
|
|
|
|
|
target.setDeptId(device.getCreateDept()); |
|
|
|
|
|
|
|
target.setDeviceCode(device.getEmCode()); |
|
|
|
|
|
|
|
target.setDeptName(device.getName()); |
|
|
|
|
|
|
|
// 当年用电量
|
|
|
|
|
|
|
|
target.setUsrPowerYear(this.getUsrPowerYear(device)); |
|
|
|
|
|
|
|
// 当月用电量
|
|
|
|
|
|
|
|
target.setUsrPowerMon(this.getUsrPowerMon(device)); |
|
|
|
|
|
|
|
// 当日用电量
|
|
|
|
|
|
|
|
target.setUsrPowerDay(this.getUsrPowerDay(device)); |
|
|
|
|
|
|
|
// 当日机组有功功率
|
|
|
|
|
|
|
|
target.setActivePowerVoList(this.getActivePowerVoList(device)); |
|
|
|
|
|
|
|
// 近30天用电量
|
|
|
|
|
|
|
|
target.setUsrPowerVoList(this.getUsrPowerVoList(device)); |
|
|
|
|
|
|
|
// 近3年用电量
|
|
|
|
|
|
|
|
target.setUsrYearMap(this.getUsrYearMap(device)); |
|
|
|
|
|
|
|
// 月运行次数、时长
|
|
|
|
|
|
|
|
WaterRunVo runMon = this.getRunData(device,1); |
|
|
|
|
|
|
|
target.setRunCountMon(runMon.getCount()); |
|
|
|
|
|
|
|
target.setRunDurationMon(runMon.getHour()); |
|
|
|
|
|
|
|
// 年运行次数、时长
|
|
|
|
|
|
|
|
WaterRunVo runYear = this.getRunData(device,0); |
|
|
|
|
|
|
|
target.setRunCountYear(runYear.getCount()); |
|
|
|
|
|
|
|
target.setRunDurationYear(runYear.getHour()); |
|
|
|
|
|
|
|
return target; |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(loadwaterpump_target_key,list); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 水利-站点水位数据 |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void loadWaterLevel(String param) { |
|
|
|
|
|
|
|
// 有效站点模型
|
|
|
|
|
|
|
|
List<HzimsAnalyzeModelStationEntity> modelList = getModelStationList(); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(modelList)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<WaterLevelVo> list = new ArrayList<>(); |
|
|
|
|
|
|
|
modelList.forEach(item -> { |
|
|
|
|
|
|
|
List<MultiAnalyzeCodePO> multiAnalyzeCodePOList = new ArrayList<>(); |
|
|
|
|
|
|
|
MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); |
|
|
|
|
|
|
|
multiAnalyzeCodePO.setDeviceCode(item.getInstanceCode()); |
|
|
|
|
|
|
|
multiAnalyzeCodePO.setSignages(Collections.singletonList(HomePageConstant.FRONT_WATER_LEVEL)); |
|
|
|
|
|
|
|
multiAnalyzeCodePOList.add(multiAnalyzeCodePO); |
|
|
|
|
|
|
|
R<List<AnalyzeCodeBySignagesVO>> result = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); |
|
|
|
|
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
WaterLevelVo waterLevelVo = new WaterLevelVo(); |
|
|
|
|
|
|
|
waterLevelVo.setStationCode(item.getStationId()); |
|
|
|
|
|
|
|
// 前水位
|
|
|
|
|
|
|
|
double frontWaterLevel = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); |
|
|
|
|
|
|
|
waterLevelVo.setFrontWaterLevel(frontWaterLevel); |
|
|
|
|
|
|
|
// 后水位
|
|
|
|
|
|
|
|
double rearWaterLevel = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); |
|
|
|
|
|
|
|
waterLevelVo.setRearWaterLevel(rearWaterLevel); |
|
|
|
|
|
|
|
// 下泄流量
|
|
|
|
|
|
|
|
double dischargeFlow = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.DISCHARGE_FLOW); |
|
|
|
|
|
|
|
waterLevelVo.setDischargeFlow(dischargeFlow); |
|
|
|
|
|
|
|
// 前水位当日曲线
|
|
|
|
|
|
|
|
Map<Integer,String> frontCurveMap = this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); |
|
|
|
|
|
|
|
waterLevelVo.setFrontCurveMap(frontCurveMap); |
|
|
|
|
|
|
|
// 后水位当日曲线
|
|
|
|
|
|
|
|
Map<Integer,String> rearCurveMap = this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); |
|
|
|
|
|
|
|
waterLevelVo.setRearCurveMap(rearCurveMap); |
|
|
|
|
|
|
|
list.add(waterLevelVo); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(loadwater_level_key,list); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 泵站设备 |
|
|
|
|
|
|
|
* @param stations |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<EminfoAndEmParamVo> pumpDevices(List<Long> stations){ |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> devices = maintenanceTaskService.getEmInfoList(); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(devices)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return devices.stream().filter(device->stations.contains(device.getCreateDept())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取水位实时数据 |
|
|
|
|
|
|
|
* @param instanceCode |
|
|
|
|
|
|
|
* @param signage |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private double getWaterLevel(String instanceCode, String signage) { |
|
|
|
|
|
|
|
RealDataSearchPO realData = new RealDataSearchPO(); |
|
|
|
|
|
|
|
realData.setAnalyzeCode(instanceCode); |
|
|
|
|
|
|
|
List<String> signages = Collections.singletonList(signage); |
|
|
|
|
|
|
|
realData.setSignages(signages); |
|
|
|
|
|
|
|
// 调用fegin接口查询实时数据
|
|
|
|
|
|
|
|
R<List<FieldsData>> R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData); |
|
|
|
|
|
|
|
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 时间限制
|
|
|
|
|
|
|
|
String time = R.getData().get(0).getTime(); |
|
|
|
|
|
|
|
if(StringUtil.isEmpty(time) || "-".equals(time)){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Date date = DateUtil.parse(time, "yyyy-MM-dd HH:mm:ss.sss"); |
|
|
|
|
|
|
|
if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Double.parseDouble(R.getData().get(0).getValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取水位当年数据 |
|
|
|
|
|
|
|
* @param instanceCode |
|
|
|
|
|
|
|
* @param signage |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<Integer, String> getWaterLevelMap(String instanceCode, String signage) { |
|
|
|
|
|
|
|
LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), DateUtil.DATETIME_FORMATTER); |
|
|
|
|
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
|
|
|
|
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); |
|
|
|
|
|
|
|
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); |
|
|
|
|
|
|
|
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); |
|
|
|
|
|
|
|
analyzeDataConditionPO.setFull(1); |
|
|
|
|
|
|
|
analyzeDataConditionPO.setSignages(signage); |
|
|
|
|
|
|
|
// 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
|
|
|
|
|
|
|
|
analyzeDataConditionPO.setAccessRules(EquipmentConstants.AccessRulesEnum.FINAL_CYCLE.getType()); |
|
|
|
|
|
|
|
// 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年)
|
|
|
|
|
|
|
|
analyzeDataConditionPO.setSaveTimeType(2); |
|
|
|
|
|
|
|
// 间隔
|
|
|
|
|
|
|
|
analyzeDataConditionPO.setTimeInterval(1); |
|
|
|
|
|
|
|
analyzeDataConditionPO.setBeginTime(beginTime); |
|
|
|
|
|
|
|
analyzeDataConditionPO.setEndTime(endTime); |
|
|
|
|
|
|
|
signboardConditions.add(analyzeDataConditionPO); |
|
|
|
|
|
|
|
po.setDeviceCode(instanceCode); |
|
|
|
|
|
|
|
po.setSignboardConditions(signboardConditions); |
|
|
|
|
|
|
|
R<List<AnalyzeDataConditionVO>> R = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); |
|
|
|
|
|
|
|
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(R.getData().get(0).getList())){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.getData().get(0).getList().stream().collect(Collectors.toMap(key-> { |
|
|
|
|
|
|
|
Date dateTime = DateUtil.parse(key.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
|
|
|
return dateTime.getHours(); |
|
|
|
|
|
|
|
}, value -> { |
|
|
|
|
|
|
|
if(StringUtil.isBlank(value.getVal())){ |
|
|
|
|
|
|
|
return "0"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return value.getVal(); |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取有效站点模型 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<HzimsAnalyzeModelStationEntity> getModelStationList() { |
|
|
|
|
|
|
|
// 水利站点(All)
|
|
|
|
|
|
|
|
List<StationEntity> stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, null, null,false); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stationList)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 站点code集合
|
|
|
|
|
|
|
|
List<String> codes = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(codes)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询站点模型列表
|
|
|
|
|
|
|
|
List<HzimsAnalyzeModelStationEntity> list = modelStationService.list(new LambdaQueryWrapper<HzimsAnalyzeModelStationEntity>() {{ |
|
|
|
|
|
|
|
in(HzimsAnalyzeModelStationEntity::getStationId, codes); |
|
|
|
|
|
|
|
}}); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取实时数据 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<String, String> getRealMap() { |
|
|
|
|
|
|
|
String json = (String) redisTemplate.opsForValue().get(real_id_key); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(json)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取运行数据 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @param type |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private WaterRunVo getRunData(EminfoAndEmParamVo device, int type) { |
|
|
|
|
|
|
|
// 默认返回运行数据
|
|
|
|
|
|
|
|
WaterRunVo waterRunVo = new WaterRunVo(); |
|
|
|
|
|
|
|
waterRunVo.setCount(0); |
|
|
|
|
|
|
|
waterRunVo.setHour(0.0); |
|
|
|
|
|
|
|
Map<String,String> point = device.getPoint(); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(point)){ |
|
|
|
|
|
|
|
return waterRunVo; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 监测点
|
|
|
|
|
|
|
|
String realId = point.get(HomePageConstant.SWITCH_ON_OFF); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(realId)){ |
|
|
|
|
|
|
|
return waterRunVo; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 确定查询时间范围: 年、月
|
|
|
|
|
|
|
|
Date startDate,endDate; |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.setTime(new Date()); |
|
|
|
|
|
|
|
switch (type){ |
|
|
|
|
|
|
|
case 0: |
|
|
|
|
|
|
|
endDate = calendar.getTime(); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
startDate = calendar.getTime(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
endDate = calendar.getTime(); |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
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)); |
|
|
|
|
|
|
|
startDate = calendar.getTime(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
throw new IllegalStateException("Unexpected value: " + type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return this.getRunConvertData(realId,startDate,endDate,waterRunVo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取时间范围内开机次数、运行时长 |
|
|
|
|
|
|
|
* @param realId |
|
|
|
|
|
|
|
* @param startDate |
|
|
|
|
|
|
|
* @param endDate |
|
|
|
|
|
|
|
* @param waterRunVo |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private WaterRunVo getRunConvertData(String realId, Date startDate, Date endDate, WaterRunVo waterRunVo) { |
|
|
|
|
|
|
|
OriginalDataQuery originalDataQuery = new OriginalDataQuery(); |
|
|
|
|
|
|
|
originalDataQuery.setRealId(realId); |
|
|
|
|
|
|
|
originalDataQuery.setBeginTime(startDate); |
|
|
|
|
|
|
|
originalDataQuery.setEndTime(endDate); |
|
|
|
|
|
|
|
originalDataQuery.setLimit(100000); |
|
|
|
|
|
|
|
originalDataQuery.setPage(1); |
|
|
|
|
|
|
|
// 查询时间范围开关机监测点历史数据
|
|
|
|
|
|
|
|
Result<HzPage<PointData>> R = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); |
|
|
|
|
|
|
|
if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ |
|
|
|
|
|
|
|
return waterRunVo; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 过滤相邻开关机状态相同数据
|
|
|
|
|
|
|
|
List<PointData> result = this.getFilterList(R.getData().getRecords()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(result)){ |
|
|
|
|
|
|
|
return waterRunVo; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 开机次数
|
|
|
|
|
|
|
|
int count = (int) result.stream().filter(o->HomePageConstant.OFF.equals(o.getValue())).count(); |
|
|
|
|
|
|
|
waterRunVo.setCount(count); |
|
|
|
|
|
|
|
// 开机运行时长
|
|
|
|
|
|
|
|
long time = this.getRunTime(result,startDate,endDate); |
|
|
|
|
|
|
|
waterRunVo.setHour(BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
return waterRunVo; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 过滤相邻开关机状态相同数据 |
|
|
|
|
|
|
|
* @param list |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<PointData> getFilterList(List<PointData> list) { |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<PointData> result = new ArrayList<>(); |
|
|
|
|
|
|
|
// 遍历数据
|
|
|
|
|
|
|
|
for(int i = 0; i< list.size() ; i++){ |
|
|
|
|
|
|
|
// 第一个数据保存下来
|
|
|
|
|
|
|
|
if(i == 0){ |
|
|
|
|
|
|
|
result.add(list.get(i)); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 遍历数据状态
|
|
|
|
|
|
|
|
String value = list.get(i).getValue(); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 上一条数据状态
|
|
|
|
|
|
|
|
String up_value = list.get(i-1).getValue(); |
|
|
|
|
|
|
|
if(value.equals(up_value)){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.add(list.get(i)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取运行时长 |
|
|
|
|
|
|
|
* @param result |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private long getRunTime(List<PointData> result,Date startDate,Date endDate) { |
|
|
|
|
|
|
|
if(result.size() == 1){ |
|
|
|
|
|
|
|
// 一直开机
|
|
|
|
|
|
|
|
if(HomePageConstant.OFF.equals(result.get(0).getValue())){ |
|
|
|
|
|
|
|
return endDate.getTime() - startDate.getTime(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 一直关机
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
long time=0; |
|
|
|
|
|
|
|
// 遍历累计开机时长
|
|
|
|
|
|
|
|
for(int i = 0; i< result.size() ; i++){ |
|
|
|
|
|
|
|
// 记录为开机状态 就计算到下次关机的时间差
|
|
|
|
|
|
|
|
if(HomePageConstant.ON.equals(result.get(i).getValue())){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
// 遍历至最后一条数据,累计至当前时间
|
|
|
|
|
|
|
|
if(i == result.size() - 1){ |
|
|
|
|
|
|
|
endTime = endDate; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
time += endTime.getTime() - startTime.getTime(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return time; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取监测点实时数据 |
|
|
|
|
|
|
|
* @param em |
|
|
|
|
|
|
|
* @param map |
|
|
|
|
|
|
|
* @param targets |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String getSignageValue(EminfoAndEmParamVo em,Map<String,String> map, String targets) { |
|
|
|
|
|
|
|
if(ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)){ |
|
|
|
|
|
|
|
return "0"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map<String,String> point = em.getPoint(); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(point)){ |
|
|
|
|
|
|
|
return "0"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String realId = point.get(targets); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(realId)){ |
|
|
|
|
|
|
|
return "0"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String value = map.get(realId); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
|
|
|
|
return "0"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 获取value
|
|
|
|
|
|
|
|
return value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 当年用电量 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private float getUsrPowerYear(EminfoAndEmParamVo device) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
calendar.setTime(new Date()); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
// 当年用电量
|
|
|
|
|
|
|
|
return analyseDataService.periodTargetFloat(start,end,5,6,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 当月用电量 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private float getUsrPowerMon(EminfoAndEmParamVo device) { |
|
|
|
|
|
|
|
String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; |
|
|
|
|
|
|
|
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
// 当月用电量
|
|
|
|
|
|
|
|
return analyseDataService.periodTargetFloat(start,end,5,5,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 当日用电量 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private float getUsrPowerDay(EminfoAndEmParamVo device) { |
|
|
|
|
|
|
|
String time = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); |
|
|
|
|
|
|
|
// 当日用电量
|
|
|
|
|
|
|
|
return analyseDataService.periodTargetFloat(time + " 00:00:00",time + " 23:59:59",5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取开机状态 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private int getPumpState(EminfoAndEmParamVo device,Map<String,String> map) { |
|
|
|
|
|
|
|
// 获取开关机监测点实时数据
|
|
|
|
|
|
|
|
String value = this.getSignageValue(device,map,HomePageConstant.SWITCH_ON_OFF); |
|
|
|
|
|
|
|
// 开机状态
|
|
|
|
|
|
|
|
if (HomePageConstant.OFF.equals(value)) { |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取功率因数 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private double getPowerFactor(EminfoAndEmParamVo device,Map<String,String> map) { |
|
|
|
|
|
|
|
// 获取开关机监测点实时数据
|
|
|
|
|
|
|
|
String value = this.getSignageValue(device,map,HomePageConstant.POWER_FACTOR); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 开机状态
|
|
|
|
|
|
|
|
return Double.parseDouble(value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 有功功率 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private float getActivePower(EminfoAndEmParamVo device,Map<String,String> map) { |
|
|
|
|
|
|
|
// 获取有功功率监测点实时数据
|
|
|
|
|
|
|
|
String value = this.getSignageValue(device,map,HomePageConstant.ACTIVE_POWER); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
|
|
|
|
return 0f; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 有功功率
|
|
|
|
|
|
|
|
return Float.parseFloat(value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 无功功率 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private float getReactivePower(EminfoAndEmParamVo device,Map<String,String> map) { |
|
|
|
|
|
|
|
// 获取无功功率监测点实时数据
|
|
|
|
|
|
|
|
String value = this.getSignageValue(device,map,HomePageConstant.REACTIVE_POWER); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
|
|
|
|
return 0f; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 无功功率
|
|
|
|
|
|
|
|
return Float.parseFloat(value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 电压 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private double getVoltage(EminfoAndEmParamVo device,Map<String,String> map) { |
|
|
|
|
|
|
|
// 获取电压监测点实时数据
|
|
|
|
|
|
|
|
String value = this.getSignageValue(device,map,HomePageConstant.VOLTAGE); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 电压
|
|
|
|
|
|
|
|
return Double.parseDouble(value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 电流 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private double getCurrent(EminfoAndEmParamVo device,Map<String,String> map) { |
|
|
|
|
|
|
|
// 获取电流监测点实时数据
|
|
|
|
|
|
|
|
String value = this.getSignageValue(device,map,HomePageConstant.CURRENT); |
|
|
|
|
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 电流
|
|
|
|
|
|
|
|
return Double.parseDouble(value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 当日机组有功功率 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<ActivePowerVo> getActivePowerVoList(EminfoAndEmParamVo device) { |
|
|
|
|
|
|
|
String startTime = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"); |
|
|
|
|
|
|
|
String endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); |
|
|
|
|
|
|
|
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); |
|
|
|
|
|
|
|
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); |
|
|
|
|
|
|
|
analyzeDataConditionPO.setFull(0); |
|
|
|
|
|
|
|
analyzeDataConditionPO.setSignages(HomePageConstant.ACTIVE_POWER); |
|
|
|
|
|
|
|
// 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
|
|
|
|
|
|
|
|
analyzeDataConditionPO.setAccessRules(EquipmentConstants.AccessRulesEnum.AVG_CYCLE.getType()); |
|
|
|
|
|
|
|
// 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年)
|
|
|
|
|
|
|
|
analyzeDataConditionPO.setSaveTimeType(EquipmentConstants.CycleTypeEnum.H_CYCLE.getType()); |
|
|
|
|
|
|
|
// 间隔
|
|
|
|
|
|
|
|
analyzeDataConditionPO.setTimeInterval(1); |
|
|
|
|
|
|
|
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); |
|
|
|
|
|
|
|
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); |
|
|
|
|
|
|
|
signboardConditions.add(analyzeDataConditionPO); |
|
|
|
|
|
|
|
po.setDeviceCode(device.getEmCode()); |
|
|
|
|
|
|
|
po.setSignboardConditions(signboardConditions); |
|
|
|
|
|
|
|
R<List<AnalyzeDataConditionVO>> R = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); |
|
|
|
|
|
|
|
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<ActivePowerVo> list = new ArrayList<>(); |
|
|
|
|
|
|
|
// 遍历添加机组功率
|
|
|
|
|
|
|
|
for(AnalyzeDataConditionVO data : R.getData()){ |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(data.getList())){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for(AnalyseDataTaosVO item : data.getList()){ |
|
|
|
|
|
|
|
ActivePowerVo vo = new ActivePowerVo(); |
|
|
|
|
|
|
|
Date dateTime = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
|
|
|
vo.setHour(dateTime.getHours()); |
|
|
|
|
|
|
|
if (StringUtil.isBlank(item.getVal())) { |
|
|
|
|
|
|
|
vo.setActivePower("0"); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
vo.setActivePower(item.getVal()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
list.add(vo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 近30天用电量 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<UsrPowerVo> getUsrPowerVoList(EminfoAndEmParamVo device) { |
|
|
|
|
|
|
|
String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-29); |
|
|
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return records.stream().map(record -> { |
|
|
|
|
|
|
|
UsrPowerVo usr = new UsrPowerVo(); |
|
|
|
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
|
|
|
usr.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
usr.setUsrPower(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); |
|
|
|
|
|
|
|
return usr; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 近3年发电量 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<String, Float> getUsrYearMap(EminfoAndEmParamVo device) { |
|
|
|
|
|
|
|
// 开始时间
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; |
|
|
|
|
|
|
|
// 结束日期
|
|
|
|
|
|
|
|
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; |
|
|
|
|
|
|
|
// 查询数据
|
|
|
|
|
|
|
|
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
|
|
|
|
return new HashMap<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return records.stream().map(record -> { |
|
|
|
|
|
|
|
PowerMonthVo generate = new PowerMonthVo(); |
|
|
|
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
|
|
|
generate.setStrMonth(DateUtil.format(time, DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); |
|
|
|
|
|
|
|
return generate; |
|
|
|
|
|
|
|
}).collect(Collectors.toMap(PowerMonthVo::getStrMonth,PowerMonthVo::getPower)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取填报用电量 |
|
|
|
|
|
|
|
* @param stations |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<WaterPumpTargetVo> useFill(List<StationEntity> stations) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); |
|
|
|
|
|
|
|
String mon = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
|
|
|
|
String year = String.valueOf(calendar.get(Calendar.YEAR)); |
|
|
|
|
|
|
|
return stations.stream().map(station ->{ |
|
|
|
|
|
|
|
WaterPumpTargetVo target = new WaterPumpTargetVo(); |
|
|
|
|
|
|
|
target.setDeptId(station.getRefDept()); |
|
|
|
|
|
|
|
target.setDeptName(station.getName()); |
|
|
|
|
|
|
|
// 月运行次数、时长
|
|
|
|
|
|
|
|
target.setRunCountMon(0); |
|
|
|
|
|
|
|
target.setRunDurationMon(0.0); |
|
|
|
|
|
|
|
// 年运行次数、时长
|
|
|
|
|
|
|
|
target.setRunCountYear(0); |
|
|
|
|
|
|
|
target.setRunDurationYear(0.0); |
|
|
|
|
|
|
|
// 当年用电量
|
|
|
|
|
|
|
|
target.setUsrPowerYear(useService.use(year,station.getCode())); |
|
|
|
|
|
|
|
// 当月用电量
|
|
|
|
|
|
|
|
target.setUsrPowerMon(useService.use(mon,station.getCode())); |
|
|
|
|
|
|
|
// 当日用电量
|
|
|
|
|
|
|
|
target.setUsrPowerDay(useService.use(day,station.getCode())); |
|
|
|
|
|
|
|
if(StationConstants.DATA_ORIGIN_FILL.equals(station.getDataOrigin())){ |
|
|
|
|
|
|
|
// 30天用电量
|
|
|
|
|
|
|
|
target.setUsrPowerVoList(useService.use30Day(day,station.getCode())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 近3年用电量
|
|
|
|
|
|
|
|
target.setUsrYearMap(this.useThreeYear(station.getCode())); |
|
|
|
|
|
|
|
return target; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 填报近3年发电量 |
|
|
|
|
|
|
|
* @param station |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<String, Float> useThreeYear(String station) { |
|
|
|
|
|
|
|
// 开始时间
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
|
|
|
|
// 结束日期
|
|
|
|
|
|
|
|
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); |
|
|
|
|
|
|
|
return useService.generateThreeYear(start,end,station); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 水利首页-指标数据 |
|
|
|
* 水利首页-指标数据 |
|
|
@ -1098,34 +343,6 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取降水数据 |
|
|
|
|
|
|
|
* @param year |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<String,List<RainFallCountByMonthVo>> getYearRain(List<String> codes,int year) { |
|
|
|
|
|
|
|
List<RainFallCountByMonthVo> list = new ArrayList<>(); |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
// 查询当年降雨
|
|
|
|
|
|
|
|
Map<String,List<RainFallCountByMonthVo>> map = this.weatherService.getRainFallMonthCount(String.valueOf(calendar.get(Calendar.YEAR)),codes); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(map)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 添加至list
|
|
|
|
|
|
|
|
map.values().forEach(list::addAll); |
|
|
|
|
|
|
|
calendar.setTime(new Date()); |
|
|
|
|
|
|
|
// 遍历添加年份降雨
|
|
|
|
|
|
|
|
for(int i=1 ; i <= year ; i++){ |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,-i); |
|
|
|
|
|
|
|
Map<String,List<RainFallCountByMonthVo>> old = this.weatherService.getRainFallMonthCount(String.valueOf(calendar.get(Calendar.YEAR)),codes); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(old)){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 添加至list
|
|
|
|
|
|
|
|
old.values().forEach(list::addAll); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list.stream().collect(Collectors.groupingBy(RainFallCountByMonthVo::getYearAndMonth)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 用电量根据月份分组 |
|
|
|
* 用电量根据月份分组 |
|
|
|