|
|
@ -3,15 +3,18 @@ package com.hnac.hzims.operational.main.service.impl; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
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.hnac.hzims.EquipmentConstants; |
|
|
|
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.hzimsweather.vo.RainFallCountByMonthVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.fill.service.UseService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.service.*; |
|
|
|
import com.hnac.hzims.operational.main.service.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.station.StationConstants; |
|
|
|
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; |
|
|
|
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.IHzimsAnalyzeModelStationService; |
|
|
@ -44,8 +47,6 @@ 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; |
|
|
|
import java.text.ParseException; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
|
|
import java.time.Duration; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
@ -60,26 +61,28 @@ import java.util.stream.Collectors; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class WaterServiceImpl implements IWaterService { |
|
|
|
public class WaterServiceImpl implements IWaterService { |
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataService analyseDataService; |
|
|
|
private final UseService useService; |
|
|
|
|
|
|
|
|
|
|
|
private final IHomePageService homePageService; |
|
|
|
private final IHomePageService homePageService; |
|
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IWeatherService weatherService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataService analyseDataService; |
|
|
|
|
|
|
|
|
|
|
|
private final ISideHustleService sideHustleService; |
|
|
|
private final ISideHustleService sideHustleService; |
|
|
|
|
|
|
|
|
|
|
|
private final IMainSystemMonitoringService maintenanceTaskService; |
|
|
|
private final IMainSystemMonitoringService maintenanceTaskService; |
|
|
|
|
|
|
|
|
|
|
|
private final IHzimsAnalyzeModelStationService modelStationService; |
|
|
|
private final IHzimsAnalyzeModelStationService modelStationService; |
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IWeatherService weatherService; |
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IHistoryDataSearchClient historyDataSearchClient; |
|
|
|
private final IHistoryDataSearchClient historyDataSearchClient; |
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.realIdKey}") |
|
|
|
@Value("${hzims.operation.realIdKey}") |
|
|
@ -91,13 +94,6 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
|
|
|
|
|
|
|
|
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; |
|
|
|
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; |
|
|
|
|
|
|
|
|
|
|
|
// 日期格式化yyyy-mm-dd
|
|
|
|
|
|
|
|
private final SimpleDateFormat df = new SimpleDateFormat(DateUtil.PATTERN_DATE); |
|
|
|
|
|
|
|
// 日期格式化yyyy-mm-dd
|
|
|
|
|
|
|
|
private final SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
// 时间格式化yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
|
|
|
private final DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 水利-泵组实时加载 |
|
|
|
* 水利-泵组实时加载 |
|
|
|
* @param param |
|
|
|
* @param param |
|
|
@ -149,43 +145,50 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void loadWaterPumpTarget(String param) { |
|
|
|
public void loadWaterPumpTarget(String param) { |
|
|
|
List<EminfoAndEmParamVo> valid = this.getValidDeviceList(); |
|
|
|
List<EminfoAndEmParamVo> valid = this.getValidDeviceList(); |
|
|
|
if(CollectionUtil.isEmpty(valid)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<WaterPumpTargetVo> list = new ArrayList<>(); |
|
|
|
List<WaterPumpTargetVo> list = new ArrayList<>(); |
|
|
|
valid.forEach(device->{ |
|
|
|
if(CollectionUtil.isNotEmpty(valid)){ |
|
|
|
WaterPumpTargetVo waterPumpTargetVo = new WaterPumpTargetVo(); |
|
|
|
valid.forEach(device->{ |
|
|
|
waterPumpTargetVo.setDeptId(device.getCreateDept()); |
|
|
|
WaterPumpTargetVo waterPumpTargetVo = new WaterPumpTargetVo(); |
|
|
|
waterPumpTargetVo.setDeviceCode(device.getEmCode()); |
|
|
|
waterPumpTargetVo.setDeptId(device.getCreateDept()); |
|
|
|
waterPumpTargetVo.setDeptName(device.getName()); |
|
|
|
waterPumpTargetVo.setDeviceCode(device.getEmCode()); |
|
|
|
// 当年用电量
|
|
|
|
waterPumpTargetVo.setDeptName(device.getName()); |
|
|
|
float usrPowerYear = this.getUsrPowerYear(device); |
|
|
|
// 当年用电量
|
|
|
|
waterPumpTargetVo.setUsrPowerYear(usrPowerYear); |
|
|
|
float usrPowerYear = this.getUsrPowerYear(device); |
|
|
|
// 当月用电量
|
|
|
|
waterPumpTargetVo.setUsrPowerYear(usrPowerYear); |
|
|
|
float usrPowerMon = this.getUsrPowerMon(device); |
|
|
|
// 当月用电量
|
|
|
|
waterPumpTargetVo.setUsrPowerMon(usrPowerMon); |
|
|
|
float usrPowerMon = this.getUsrPowerMon(device); |
|
|
|
// 当日用电量
|
|
|
|
waterPumpTargetVo.setUsrPowerMon(usrPowerMon); |
|
|
|
float usrPowerDay = this.getUsrPowerDay(device); |
|
|
|
// 当日用电量
|
|
|
|
waterPumpTargetVo.setUsrPowerDay(usrPowerDay); |
|
|
|
float usrPowerDay = this.getUsrPowerDay(device); |
|
|
|
// 月运行次数、时长
|
|
|
|
waterPumpTargetVo.setUsrPowerDay(usrPowerDay); |
|
|
|
WaterRunVo runMon = this.getRunData(device,1); |
|
|
|
// 月运行次数、时长
|
|
|
|
waterPumpTargetVo.setRunCountMon(runMon.getCount()); |
|
|
|
WaterRunVo runMon = this.getRunData(device,1); |
|
|
|
waterPumpTargetVo.setRunDurationMon(runMon.getHour()); |
|
|
|
waterPumpTargetVo.setRunCountMon(runMon.getCount()); |
|
|
|
// 年运行次数、时长
|
|
|
|
waterPumpTargetVo.setRunDurationMon(runMon.getHour()); |
|
|
|
WaterRunVo runYear = this.getRunData(device,0); |
|
|
|
// 年运行次数、时长
|
|
|
|
waterPumpTargetVo.setRunCountYear(runYear.getCount()); |
|
|
|
WaterRunVo runYear = this.getRunData(device,0); |
|
|
|
waterPumpTargetVo.setRunDurationYear(runYear.getHour()); |
|
|
|
waterPumpTargetVo.setRunCountYear(runYear.getCount()); |
|
|
|
// 当日机组有功功率
|
|
|
|
waterPumpTargetVo.setRunDurationYear(runYear.getHour()); |
|
|
|
List<ActivePowerVo> activePowerVoList = this.getActivePowerVoList(device); |
|
|
|
// 当日机组有功功率
|
|
|
|
waterPumpTargetVo.setActivePowerVoList(activePowerVoList); |
|
|
|
List<ActivePowerVo> activePowerVoList = this.getActivePowerVoList(device); |
|
|
|
// 近30天用电量
|
|
|
|
waterPumpTargetVo.setActivePowerVoList(activePowerVoList); |
|
|
|
List<UsrPowerVo> usrPowerVoList = this.getUsrPowerVoList(device); |
|
|
|
// 近30天用电量
|
|
|
|
waterPumpTargetVo.setUsrPowerVoList(usrPowerVoList); |
|
|
|
List<UsrPowerVo> usrPowerVoList = this.getUsrPowerVoList(device); |
|
|
|
// 近3年用电量
|
|
|
|
waterPumpTargetVo.setUsrPowerVoList(usrPowerVoList); |
|
|
|
Map<String,Float> usrYearMap = this.getUsrYearMap(device); |
|
|
|
// 近3年用电量
|
|
|
|
waterPumpTargetVo.setUsrYearMap(usrYearMap); |
|
|
|
Map<String,Float> usrYearMap = this.getUsrYearMap(device); |
|
|
|
list.add(waterPumpTargetVo); |
|
|
|
waterPumpTargetVo.setUsrYearMap(usrYearMap); |
|
|
|
}); |
|
|
|
list.add(waterPumpTargetVo); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 补充站点填报发电量
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
|
|
|
.in(StationEntity::getType, HomePageConstant.waterList) |
|
|
|
|
|
|
|
.eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(stations)){ |
|
|
|
|
|
|
|
list.addAll(this.useFill(stations)); |
|
|
|
|
|
|
|
} |
|
|
|
redisTemplate.opsForValue().set(loadwaterpump_target_key,list); |
|
|
|
redisTemplate.opsForValue().set(loadwaterpump_target_key,list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -279,12 +282,8 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
if(StringUtil.isBlank(time)){ |
|
|
|
if(StringUtil.isBlank(time)){ |
|
|
|
return 0.0; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
try{ |
|
|
|
Date date = DateUtil.parse(time,DateUtil.DATETIME_FORMAT); |
|
|
|
Date date = sdf.parse(time); |
|
|
|
if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ |
|
|
|
if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}catch (ParseException e){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
return Double.parseDouble(R.getData().get(0).getValue()); |
|
|
|
return Double.parseDouble(R.getData().get(0).getValue()); |
|
|
@ -297,7 +296,7 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Map<Integer, String> getWaterLevelMap(String instanceCode, String signage) { |
|
|
|
private Map<Integer, String> getWaterLevelMap(String instanceCode, String signage) { |
|
|
|
LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), dtf); |
|
|
|
LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), DateUtil.DATETIME_FORMATTER); |
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); |
|
|
|
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); |
|
|
|
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); |
|
|
|
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); |
|
|
@ -573,11 +572,11 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private float getUsrPowerYear(EminfoAndEmParamVo device) { |
|
|
|
private float getUsrPowerYear(EminfoAndEmParamVo device) { |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
String end = sdf.format(calendar.getTime()); |
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
calendar.setTime(new Date()); |
|
|
|
calendar.setTime(new Date()); |
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
String start = df.format(calendar.getTime()); |
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
// 当年用电量
|
|
|
|
// 当年用电量
|
|
|
|
return analyseDataService.periodTargetFloat(start,end,6,5,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); |
|
|
|
return analyseDataService.periodTargetFloat(start,end,6,5,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); |
|
|
|
} |
|
|
|
} |
|
|
@ -801,36 +800,82 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 获取填报用电量 |
|
|
|
|
|
|
|
* @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)); |
|
|
|
|
|
|
|
//calendar.add(Calendar.DAY_OF_MONTH,-1);
|
|
|
|
|
|
|
|
//String yesterday = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 水利首页-指标数据 |
|
|
|
* 水利首页-指标数据 |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public WaterConservancyVo waterConservancy(Long deptId) { |
|
|
|
public WaterConservancyVo waterConservancy(Long deptId) { |
|
|
|
//根据用户权限获取机构
|
|
|
|
// 查询水利站点
|
|
|
|
R<List<Dept>> R = sysClient.getDeptByCurrentUser(); |
|
|
|
List<StationEntity> stations = stationService.getHomeStationList(deptId, HomePageConstant.waterList, HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { |
|
|
|
if (CollectionUtil.isEmpty(stations)) { |
|
|
|
return null; |
|
|
|
return new WaterConservancyVo(); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取水利站点
|
|
|
|
|
|
|
|
List<StationEntity> stationList = stationService.getStationList(R.getData(),deptId,HomePageConstant.waterList,HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stationList)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 站点归属机构集合
|
|
|
|
|
|
|
|
List<Long> deptList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(deptList)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
WaterConservancyVo response = new WaterConservancyVo(); |
|
|
|
WaterConservancyVo response = new WaterConservancyVo(); |
|
|
|
// 查询指标标题机构
|
|
|
|
// 查询指标标题机构
|
|
|
|
Dept title = this.getTitleDetp(R.getData(),deptId); |
|
|
|
Dept title = this.getTitleDetp(deptId); |
|
|
|
if(ObjectUtil.isNotEmpty(title)){ |
|
|
|
if(ObjectUtil.isNotEmpty(title)){ |
|
|
|
response.setDepartId(title.getId()); |
|
|
|
response.setDepartId(title.getId()); |
|
|
|
response.setDepartName(title.getDeptName()); |
|
|
|
response.setDepartName(title.getDeptName()); |
|
|
|
} |
|
|
|
} |
|
|
|
response.setWaterStationCount((int) stationList.stream().filter(o->HomePageConstant.PUMPING.equals(o.getType())).count()); |
|
|
|
response.setWaterStationCount((int) stations.stream().filter(o->HomePageConstant.PUMPING.equals(o.getType())).count()); |
|
|
|
response.setSluiceGateCount((int) stationList.stream().filter(o->HomePageConstant.GATE.equals(o.getType())).count()); |
|
|
|
response.setSluiceGateCount((int) stations.stream().filter(o->HomePageConstant.GATE.equals(o.getType())).count()); |
|
|
|
response.setWaterInstall(0.0); |
|
|
|
response.setWaterInstall(0.0); |
|
|
|
response.setWaterPower(0.0); |
|
|
|
response.setWaterPower(0.0); |
|
|
|
response.setKWhYear(0f); |
|
|
|
response.setKWhYear(0f); |
|
|
@ -838,39 +883,35 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
response.setKWhDay(0f); |
|
|
|
response.setKWhDay(0f); |
|
|
|
// 获取设备实时数据
|
|
|
|
// 获取设备实时数据
|
|
|
|
List<WaterPumpRealVo> list = (List<WaterPumpRealVo>) redisTemplate.opsForValue().get(loadwaterpump_real_key); |
|
|
|
List<WaterPumpRealVo> list = (List<WaterPumpRealVo>) redisTemplate.opsForValue().get(loadwaterpump_real_key); |
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
if(CollectionUtil.isNotEmpty(list)){ |
|
|
|
return response; |
|
|
|
// 获取站点机构有效设备
|
|
|
|
} |
|
|
|
List<WaterPumpRealVo> valid = list.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); |
|
|
|
// 获取站点机构有效设备
|
|
|
|
if(CollectionUtil.isNotEmpty(valid)){ |
|
|
|
List<WaterPumpRealVo> valid = list.stream().filter(o->deptList.contains(o.getDeptId())).collect(Collectors.toList()); |
|
|
|
// 装机容量
|
|
|
|
if(CollectionUtil.isEmpty(valid)){ |
|
|
|
double waterInstall = valid.stream().mapToDouble(WaterPumpRealVo::getInstalledCapacity).sum(); |
|
|
|
return response; |
|
|
|
response.setWaterInstall(waterInstall); |
|
|
|
|
|
|
|
// 有功功率
|
|
|
|
|
|
|
|
double waterPower = valid.stream().mapToDouble(WaterPumpRealVo::getActivePower).sum(); |
|
|
|
|
|
|
|
response.setWaterPower(waterPower); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 装机容量
|
|
|
|
|
|
|
|
double waterInstall = valid.stream().mapToDouble(WaterPumpRealVo::getInstalledCapacity).sum(); |
|
|
|
|
|
|
|
response.setWaterInstall(waterInstall); |
|
|
|
|
|
|
|
// 有功功率
|
|
|
|
|
|
|
|
double waterPower = valid.stream().mapToDouble(WaterPumpRealVo::getActivePower).sum(); |
|
|
|
|
|
|
|
response.setWaterPower(waterPower); |
|
|
|
|
|
|
|
// 获取设备指标数据
|
|
|
|
// 获取设备指标数据
|
|
|
|
List<WaterPumpTargetVo> targetList = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(loadwaterpump_target_key); |
|
|
|
List<WaterPumpTargetVo> targetList = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(loadwaterpump_target_key); |
|
|
|
if(CollectionUtil.isEmpty(targetList)){ |
|
|
|
if(CollectionUtil.isNotEmpty(targetList)){ |
|
|
|
return response; |
|
|
|
// 获取站点机构有效设备
|
|
|
|
} |
|
|
|
List<WaterPumpTargetVo> validTarget = targetList.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); |
|
|
|
// 获取站点机构有效设备
|
|
|
|
if(CollectionUtil.isNotEmpty(validTarget)){ |
|
|
|
List<WaterPumpTargetVo> validTarget = targetList.stream().filter(o->deptList.contains(o.getDeptId())).collect(Collectors.toList()); |
|
|
|
// 年用电量
|
|
|
|
if(CollectionUtil.isEmpty(valid)){ |
|
|
|
double kwhYear = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerYear).sum(); |
|
|
|
return response; |
|
|
|
response.setKWhYear((float) kwhYear); |
|
|
|
|
|
|
|
// 月用电量
|
|
|
|
|
|
|
|
double kwhMon = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerMon).sum(); |
|
|
|
|
|
|
|
response.setKWhMon((float) kwhMon); |
|
|
|
|
|
|
|
// 日用电量
|
|
|
|
|
|
|
|
double kwhDay = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum(); |
|
|
|
|
|
|
|
response.setKWhDay((float) kwhDay); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 年用电量
|
|
|
|
|
|
|
|
double kwhYear = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerYear).sum(); |
|
|
|
|
|
|
|
response.setKWhYear((float) kwhYear); |
|
|
|
|
|
|
|
// 月用电量
|
|
|
|
|
|
|
|
double kwhMon = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerMon).sum(); |
|
|
|
|
|
|
|
response.setKWhMon((float) kwhMon); |
|
|
|
|
|
|
|
// 日用电量
|
|
|
|
|
|
|
|
double kwhDay = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum(); |
|
|
|
|
|
|
|
response.setKWhDay((float) kwhDay); |
|
|
|
|
|
|
|
return response; |
|
|
|
return response; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1154,16 +1195,17 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Dept getTitleDetp(List<Dept> authList, Long deptId) { |
|
|
|
public Dept getTitleDetp(Long deptId) { |
|
|
|
|
|
|
|
R<List<Dept>> depts = sysClient.getDeptByCurrentUser(); |
|
|
|
if(null == deptId){ |
|
|
|
if(null == deptId){ |
|
|
|
// 最小类型机构
|
|
|
|
// 最小类型机构
|
|
|
|
Dept dept = authList.stream().min(Comparator.comparing(Dept::getDeptCategory)).orElse(null); |
|
|
|
Dept dept = depts.getData().stream().min(Comparator.comparing(Dept::getDeptCategory)).orElse(null); |
|
|
|
if(ObjectUtil.isEmpty(dept)){ |
|
|
|
if(ObjectUtil.isEmpty(dept)){ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return dept; |
|
|
|
return dept; |
|
|
|
} |
|
|
|
} |
|
|
|
List<Dept> list = authList.stream().filter(o->deptId.equals(o.getId())).collect(Collectors.toList()); |
|
|
|
List<Dept> list = depts.getData().stream().filter(o->deptId.equals(o.getId())).collect(Collectors.toList()); |
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -1496,26 +1538,6 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取近30天集合 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<String> getRecent30Day() { |
|
|
|
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
|
|
|
|
// 开始日期
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.setTime(new Date()); |
|
|
|
|
|
|
|
list.add(df.format(calendar.getTime())); |
|
|
|
|
|
|
|
// 获取日期之间的月
|
|
|
|
|
|
|
|
int i = 0; |
|
|
|
|
|
|
|
while (i < 30) { |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, - 1); |
|
|
|
|
|
|
|
list.add(df.format(calendar.getTime())); |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 闸门列表 |
|
|
|
* 闸门列表 |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -1536,7 +1558,7 @@ public class WaterServiceImpl implements IWaterService { |
|
|
|
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { |
|
|
|
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
Dept title = this.getTitleDetp(R.getData(),deptId); |
|
|
|
Dept title = this.getTitleDetp(deptId); |
|
|
|
if(ObjectUtil.isEmpty(title)){ |
|
|
|
if(ObjectUtil.isEmpty(title)){ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|