Browse Source

#水电站发填报电量统计

zhongwei
yang_shj 2 years ago
parent
commit
74525df6f5
  1. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/UseEntity.java
  2. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java
  3. 54
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java
  4. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WebHomeController.java
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java
  6. 366
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  7. 72
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java
  8. 182
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/UseEntity.java

@ -5,12 +5,17 @@ import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
/**
* @author usj
*/
@EqualsAndHashCode(callSuper = true)
@Data @Data
@TableName("hzims_fill_use") @TableName("hzims_fill_use")
@ApiModel(value="UseEntity", description="保存用电量填报数据对象") @ApiModel(value="UseEntity", description="保存用电量填报数据对象")

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java

@ -6,12 +6,15 @@ import com.hnac.hzims.operational.fill.entity.RainfallEntity;
import com.hnac.hzims.operational.fill.vo.GenerateVo; import com.hnac.hzims.operational.fill.vo.GenerateVo;
import com.hnac.hzims.operational.fill.vo.QueryVo; import com.hnac.hzims.operational.fill.vo.QueryVo;
import com.hnac.hzims.operational.fill.vo.RainfallVo; import com.hnac.hzims.operational.fill.vo.RainfallVo;
import com.hnac.hzims.operational.main.vo.GenerationPowerVo;
import com.hnac.hzims.operational.main.vo.PowerMonthVo; import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import com.hnac.hzims.operational.main.vo.UsrPowerVo;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author ysj * @author ysj
@ -26,6 +29,12 @@ public interface GenerateService extends BaseService<GenerateEntity> {
// 新增/修改发电量填报数据 // 新增/修改发电量填报数据
boolean saveUpdate(GenerateEntity entity); boolean saveUpdate(GenerateEntity entity);
// 查询填报用电量
Float generate(String date,String station);
// 查询30天填报用电量
List<GenerationPowerVo> generate30Day(String day, String station);
// 获取站点填报发电量 // 获取站点填报发电量
List<PowerMonthVo> generateThreeYear(String start, String end, String station); List<PowerMonthVo> generateThreeYear(String start, String end, String station);
} }

54
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java

@ -5,12 +5,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.operational.fill.entity.GenerateEntity; import com.hnac.hzims.operational.fill.entity.GenerateEntity;
import com.hnac.hzims.operational.fill.entity.UseEntity;
import com.hnac.hzims.operational.fill.mapper.GenerateMapper; import com.hnac.hzims.operational.fill.mapper.GenerateMapper;
import com.hnac.hzims.operational.fill.service.GenerateService; import com.hnac.hzims.operational.fill.service.GenerateService;
import com.hnac.hzims.operational.fill.vo.GenerateVo; import com.hnac.hzims.operational.fill.vo.GenerateVo;
import com.hnac.hzims.operational.fill.vo.QueryVo; import com.hnac.hzims.operational.fill.vo.QueryVo;
import com.hnac.hzims.operational.fill.wrapper.GenerateWrapper; import com.hnac.hzims.operational.fill.wrapper.GenerateWrapper;
import com.hnac.hzims.operational.main.vo.GenerationPowerVo;
import com.hnac.hzims.operational.main.vo.PowerMonthVo; import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import com.hnac.hzims.operational.main.vo.UsrPowerVo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
@ -25,6 +28,7 @@ import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -88,6 +92,56 @@ public class GenerateServiceImpl extends BaseServiceImpl<GenerateMapper, Generat
} }
/** /**
* 根据时间机构查询用电量
* @param date 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd
* @param station 所属机构
* @return
*/
@Override
public Float generate(String date, String station) {
List<GenerateEntity> powers = this.list(Wrappers.<GenerateEntity>lambdaQuery()
.likeRight(GenerateEntity::getFillDate,date)
.eq(GenerateEntity::getStationCode,station)
);
if(CollectionUtil.isEmpty(powers)){
return 0f;
}
return (float) powers.stream().mapToDouble(GenerateEntity::getGenerate).sum();
}
/**
* 查询30天填报用电量
* @param day : 结束日期 yyyy-MM-dd
* @param station 站点编码
* @return
*/
@Override
public List<GenerationPowerVo> generate30Day(String day, String station) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse(day,DateUtil.PATTERN_DATE));
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
calendar.add(Calendar.DAY_OF_MONTH,-29);
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
List<GenerateEntity> records = this.list(Wrappers.<GenerateEntity>lambdaQuery()
.between(GenerateEntity::getFillDate,start,end)
.eq(GenerateEntity::getStationCode,station)
);
if(CollectionUtil.isEmpty(records)){
return new ArrayList<>();
}
return records.stream().map(record->{
GenerationPowerVo generate = new GenerationPowerVo();
generate.setDate(record.getFillDate());
if(Math.abs(record.getGenerate()) <= 0){
generate.setGenerate(0f);
}else{
generate.setGenerate(Float.parseFloat(record.getGenerate().toString()));
}
return generate;
}).collect(Collectors.toList());
}
/**
* *
* @param start 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd * @param start 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd
* @param end 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd * @param end 时间: - yyyy/ yyyy-mm/ yyyy-mm-dd

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WebHomeController.java

@ -17,6 +17,9 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
/**
* @author ysj
*/
@RestController @RestController
@RequestMapping("/webHome") @RequestMapping("/webHome")
@Api(value = "app首页", tags = "app-首页") @Api(value = "app首页", tags = "app-首页")
@ -24,12 +27,13 @@ import java.util.List;
public class WebHomeController extends BladeController { public class WebHomeController extends BladeController {
private final HydropowerService service; private final HydropowerService service;
@ApiLog @ApiLog
@ApiOperation("水电站站点统计") @ApiOperation("水电站站点统计")
@GetMapping("/webStation") @GetMapping("/webStation")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R<HydropowerStationVo> hydropowerStation(@ApiParam(value = "站点机构ID") Long deptId) { public R<HydropowerStationVo> hydropowerStation(@ApiParam(value = "站点机构ID") Long deptId) {
HydropowerStationVo response = service.webStation(deptId); HydropowerStationVo response = service.station(deptId);
return R.data(response); return R.data(response);
} }
@ApiLog @ApiLog
@ -41,7 +45,6 @@ public class WebHomeController extends BladeController {
return R.data(list); return R.data(list);
} }
@ApiLog @ApiLog
@ApiOperation("水电站站点列表") @ApiOperation("水电站站点列表")
@GetMapping("/webStationList") @GetMapping("/webStationList")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java

@ -14,7 +14,7 @@ public interface HydropowerService {
void loadHydropowerTarget(String param); void loadHydropowerTarget(String param);
HydropowerStationVo webStation(Long deptId); HydropowerStationVo station(Long deptId);
List<HydropowerUnitVo> hydropowerDevice(Long deptId); List<HydropowerUnitVo> hydropowerDevice(Long deptId);

366
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

@ -2,6 +2,7 @@ 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.toolkit.Wrappers;
import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
@ -9,9 +10,10 @@ import com.hnac.hzims.equipment.vo.PlanPowerYearVo;
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.operational.fill.service.GenerateService;
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.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
@ -44,23 +46,25 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class HydropowerServiceImpl implements HydropowerService { public class HydropowerServiceImpl implements HydropowerService {
private final IAnalyseDataService analyseDataService; private final IWaterService waterService;
private final IHomePageService homePageService;
private final IMainSystemMonitoringService maintenanceTaskService; private final IWeatherService weatherService;
private final IStationService stationService; private final IStationService stationService;
private final IStationAttributeService attributeService; private final GenerateService generateService;
private final IWaterService waterService; private final IHomePageService homePageService;
private final IPlanGenertionClient planGenertionClient; private final IAnalyseDataService analyseDataService;
private final IStationAttributeService attributeService;
private final IMainSystemMonitoringService maintenanceTaskService;
private final ISoeClient soeClient; private final ISoeClient soeClient;
private final IWeatherService weatherService; private final IPlanGenertionClient planGenertionClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
@ -79,63 +83,54 @@ public class HydropowerServiceImpl implements HydropowerService {
*/ */
@Override @Override
public void loadHydropowerReal(String param) { public void loadHydropowerReal(String param) {
// 有效设备 // 水电站站点
List<EminfoAndEmParamVo> valid = this.getValidDeviceList(); List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
if(CollectionUtil.isEmpty(valid)){ .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
return;
}
// 水电站设备
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(devices)){
return; return;
} }
// 实时数据 // 实时数据
Map<String, String> map = this.getRealMap(); Map<String, String> map = this.getRealMap();
// 单位 // 单位
Map<String, String> unitMap = this.attributeService.getPointUnit(); Map<String, String> unitMap = this.attributeService.getPointUnit();
List<HydropowerUnitRealVo> list = new ArrayList<>(); // 实时数据
valid.forEach(device->{ List<HydropowerUnitRealVo> reals = devices.stream().map(device->{
HydropowerUnitRealVo realVo = new HydropowerUnitRealVo(); HydropowerUnitRealVo real = new HydropowerUnitRealVo();
realVo.setDeptId(device.getCreateDept()); real.setDeptId(device.getCreateDept());
realVo.setDeviceCode(device.getEmCode()); real.setDeviceCode(device.getEmCode());
realVo.setDeptName(device.getName()); real.setDeptName(device.getName());
realVo.setDeviceName(device.getName()); real.setDeviceName(device.getName());
// 开关机状态 // 开关机状态
String state = this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY); real.setState(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY));
realVo.setState(state);
// 有功功率 // 有功功率
String activePower = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER); real.setActivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER));
realVo.setActivePower(activePower);
// 无功功率 // 无功功率
String reactivePower = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_REACTIVE_POWER); real.setReactivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_REACTIVE_POWER));
realVo.setReactivePower(reactivePower);
// 功率因数 // 功率因数
String powerFactor = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_POWERFACTOR); real.setPowerFactor(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_POWERFACTOR));
realVo.setPowerFactor(powerFactor);
// 机组频率 // 机组频率
String frequency = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_FREQUENCY); real.setFrequency(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_FREQUENCY));
realVo.setFrequency(frequency);
// 导叶开度 // 导叶开度
String guideOpen = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_GUIDEOPEN); real.setGuideOpen(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_GUIDEOPEN));
realVo.setGuideOpen(guideOpen);
// 定子电压 // 定子电压
String statorVoltage = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_VOLTAGE); real.setStatorVoltage(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_VOLTAGE));
realVo.setStatorVoltage(statorVoltage);
// 定子电流 // 定子电流
String statorCurrent = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_CURRENT); real.setStatorCurrent(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_CURRENT));
realVo.setStatorCurrent(statorCurrent);
// 单位设置 // 单位设置
this.setttingUnit(device,unitMap,realVo); this.setttingUnit(device,unitMap,real);
list.add(realVo); return real;
}); }).collect(Collectors.toList());
redisTemplate.opsForValue().set(load_hydropower_unit_real_key,list); if(CollectionUtil.isEmpty(reals)){
} return;
/**
* 获取实时数据
* @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>>() {}); redisTemplate.opsForValue().set(load_hydropower_unit_real_key,reals);
} }
/** /**
@ -144,59 +139,98 @@ public class HydropowerServiceImpl implements HydropowerService {
*/ */
@Override @Override
public void loadHydropowerTarget(String param) { public void loadHydropowerTarget(String param) {
// 有效设备 // 水电站站点
List<EminfoAndEmParamVo> valid = this.getValidDeviceList(); List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
if(CollectionUtil.isEmpty(valid)){ .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
return; return;
} }
List<HydropowerUnitTargetVo> list = new ArrayList<>(); // 补充填补发电指标
valid.forEach(device->{ List<HydropowerUnitTargetVo> targets = this.generteFill(stations);
HydropowerUnitTargetVo targetVo = new HydropowerUnitTargetVo(); // 水电站设备
targetVo.setDeptId(device.getCreateDept()); List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
targetVo.setDeviceCode(device.getEmCode()); if(CollectionUtil.isNotEmpty(devices)){
targetVo.setDeviceName(device.getName()); targets.addAll(devices.stream().map(device->{
targetVo.setDeptName(device.getName()); HydropowerUnitTargetVo target = new HydropowerUnitTargetVo();
target.setDeptId(device.getCreateDept());
target.setDeviceCode(device.getEmCode());
target.setDeviceName(device.getName());
target.setDeptName(device.getName());
// 当年发电量 // 当年发电量
float powerYear = this.getGenerationPower(device,0); target.setPowerYear(this.getGenerationPower(device,0));
targetVo.setPowerYear(powerYear);
// 当月发电量 // 当月发电量
float powerMon = this.getGenerationPower(device,1); target.setPowerMon(this.getGenerationPower(device,1));
targetVo.setPowerMon(powerMon);
// 当日发电量 // 当日发电量
float powerDay = this.getGenerationPower(device,2); target.setPowerDay(this.getGenerationPower(device,2));
// 当天有功功率 // 当天有功功率
List<ActivePowerVo> activePowerVoList = waterService.getActivePowerVoList(device); target.setActivePowerVoList(waterService.getActivePowerVoList(device));
targetVo.setActivePowerVoList(activePowerVoList); // 30天发电量
target.setGenerationPowerVoList(this.getGenerationPowerList(device));
return target;
}).collect(Collectors.toList()));
}
// 站点指标数据为空
if(CollectionUtil.isEmpty(targets)){
return;
}
redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets);
}
/**
* 获取填报用电量
* @param stations
* @return
*/
private List<HydropowerUnitTargetVo> generteFill(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 ->{
HydropowerUnitTargetVo target = new HydropowerUnitTargetVo();
target.setDeptId(station.getRefDept());
target.setDeptName(station.getName());
// 当年发电量
target.setPowerYear(generateService.generate(year,station.getCode()));
// 当月发电量
target.setPowerMon(generateService.generate(mon,station.getCode()));
// 当日发电量
target.setPowerDay(generateService.generate(day,station.getCode()));
// 30天发电量 // 30天发电量
List<GenerationPowerVo> generationPowerVoList = this.getGenerationPowerList(device); target.setGenerationPowerVoList(generateService.generate30Day(day,station.getCode()));
targetVo.setGenerationPowerVoList(generationPowerVoList); return target;
targetVo.setPowerDay(powerDay); }).collect(Collectors.toList());
list.add(targetVo);
});
redisTemplate.opsForValue().set(load_hydropower_unit_target_key,list);
} }
/** /**
* 获取有效设备 * 泵站设备
* @param stations
* @return * @return
*/ */
private List<EminfoAndEmParamVo> getValidDeviceList() { private List<EminfoAndEmParamVo> pumpDevices(List<Long> stations){
// 水利站点(All) if(CollectionUtil.isEmpty(stations)){
List<StationEntity> stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), null); return new ArrayList<>();
if(CollectionUtil.isEmpty(stationList)){
return null;
} }
// 获取所有设备 List<EminfoAndEmParamVo> devices = maintenanceTaskService.getEmInfoList();
List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList(); if(CollectionUtil.isEmpty(devices)){
if(CollectionUtil.isEmpty(deviceList)){ return new ArrayList<>();
return null; }
return devices.stream().filter(device->stations.contains(device.getCreateDept())).collect(Collectors.toList());
} }
// 有效泵租设备
List<Long> deptIdList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); /**
if(CollectionUtil.isEmpty(deptIdList)){ * 获取实时数据
* @return
*/
private Map<String, String> getRealMap() {
String json = (String) redisTemplate.opsForValue().get(real_id_key);
if(StringUtil.isBlank(json)){
return null; return null;
} }
return deviceList.stream().filter(o->deptIdList.contains(o.getCreateDept())).collect(Collectors.toList()); return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
} }
@ -334,7 +368,7 @@ public class HydropowerServiceImpl implements HydropowerService {
* @return * @return
*/ */
@Override @Override
public HydropowerStationVo webStation(Long deptId) { public HydropowerStationVo station(Long deptId) {
if(ObjectUtil.isEmpty(deptId)){ if(ObjectUtil.isEmpty(deptId)){
return null; return null;
} }
@ -343,22 +377,6 @@ public class HydropowerServiceImpl implements HydropowerService {
if(ObjectUtil.isEmpty(station)){ if(ObjectUtil.isEmpty(station)){
return null; return null;
} }
List<HydropowerStationVo> list = this.getHydropowerStationList(Collections.singletonList(station));
if(CollectionUtil.isEmpty(list)){
return null;
}
return list.get(0);
}
/**
* 获取首页站点信息
* @param list
* @return
*/
private List<HydropowerStationVo> getHydropowerStationList(List<StationEntity> list) {
if(CollectionUtil.isEmpty(list)){
return null;
}
// 实时监测点数据 // 实时监测点数据
List<HydropowerUnitRealVo> realList = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); List<HydropowerUnitRealVo> realList = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
// 获取站点机组指标数据 // 获取站点机组指标数据
@ -366,63 +384,69 @@ public class HydropowerServiceImpl implements HydropowerService {
// 所有设备 // 所有设备
List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList(); List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList();
// 实时天气 // 实时天气
Map<String, HeWeatherWeatherNowResponse> weather = this.getWeather(list.stream().map(StationEntity::getCode).collect(Collectors.toList())); Map<String, HeWeatherWeatherNowResponse> weather = this.getWeather(Collections.singletonList(station.getCode()));
// 七天天气 // 七天天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(list.stream().map(StationEntity::getCode).collect(Collectors.toList())); Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode()));
List<HydropowerStationVo> result = new ArrayList<>();
list.forEach(station ->{
HydropowerStationVo response = new HydropowerStationVo(); HydropowerStationVo response = new HydropowerStationVo();
response.setDeptId(station.getRefDept()); response.setDeptId(station.getRefDept());
response.setDeptName(station.getName()); response.setDeptName(station.getName());
response.setStationCode(station.getCode()); response.setStationCode(station.getCode());
// 站点状态 // 站点状态
List<SoeData> soeDataList = soeClient.getByLastLimitTime(null, station.getCode(), 1).getData(); List<SoeData> soeDataList = soeClient.getByLastLimitTime(null, station.getCode(), 1).getData();
if (CollectionUtil.isNotEmpty(soeDataList)) { response.setStationStatus(!CollectionUtil.isNotEmpty(soeDataList));
response.setStationStatus(false);
} else {
response.setStationStatus(true);
}
// 站点实时天气 // 站点实时天气
String temp = this.getTemp(weather,station.getCode()); response.setTemp(this.getTemp(weather,station.getCode()));
response.setTemp(temp);
// 站点七天天气 // 站点七天天气
List<Daily> dailys = this.getDailyList(weekWeather,station.getCode()); response.setWeather(this.getDailyList(weekWeather,station.getCode()));
response.setWeather(dailys);
// 限制水位 // 限制水位
response.setLimitWaterLevel(station.getLimitWaterLevel()); response.setLimitWaterLevel(station.getLimitWaterLevel());
// 运行天数 // 运行天数
int runDay = this.getRunDay(station); response.setRunDay(this.getRunDay(station));
response.setRunDay(runDay);
// 装机容量 // 装机容量
double installedCapacity = this.getInstalledCapacity(deviceList,station.getRefDept()); response.setInstalledCapacity(this.getInstalledCapacity(deviceList,station.getRefDept()));
response.setInstalledCapacity(installedCapacity);
// 总有功功率(总发电负荷) // 总有功功率(总发电负荷)
double powerSum = this.getPowerSum(realList,station.getRefDept()); response.setPowerSum(this.getPowerSum(realList,station.getRefDept()));
response.setPowerSum(powerSum);
// 总有功单位 // 总有功单位
String unit = this.getPowerUnit(realList,station.getRefDept()); response.setPowerUnit(this.getPowerUnit(realList,station.getRefDept()));
response.setPowerUnit(unit);
// 月计划发电量 // 月计划发电量
float planPowerMon = this.getPlanPowerrMon(station.getCode()); response.setPlanPowerMon(this.getPlanPowerrMon(station.getCode()));
response.setPlanPowerMon(planPowerMon);
// 年计划发电量 // 年计划发电量
float planPowerYear = this.getPlanPowerYear(station.getCode()); response.setPlanPowerYear(this.getPlanPowerYear(station.getCode()));
response.setPlanPowerYear(planPowerYear);
// 月发电量、年发电量、年发电完成率 // 月发电量、年发电量、年发电完成率
this.handleStationInfo(station.getRefDept(),response); this.handleStationInfo(station.getRefDept(),response);
// 水位、水位曲线 // 水位、水位曲线
this.handleWaterLeve(station.getCode(),response); this.handleWaterLeve(station.getCode(),response);
// 年发电量完成百分比 // 年发电量完成百分比
List<PowerMonthVo> powerYearList = this.handlePowerFinish(station); response.setPowerYearMap(this.handlePowerFinish(station));
response.setPowerYearMap(powerYearList);
// 设备信息 // 设备信息
List<HydropowerUnitVo> devices = this.getDevices(station,realList,targetList); response.setDeviceList(this.getDevices(station,realList,targetList));
response.setDeviceList(devices); return response;
result.add(response);
});
return result;
} }
/**
* 水电站-机组列表
* @param deptId
* @return
*/
@Override
public List<HydropowerUnitVo> hydropowerDevice(Long deptId) {
if(ObjectUtil.isEmpty(deptId)){
return null;
}
// 查询站点
StationEntity station = stationService.getStationByCodeOrRefDept(null,deptId);
if(ObjectUtil.isEmpty(station)){
return null;
}
// 实时监测点数据
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);
return this.getDevices(station,realList,targetList);
}
/** /**
* 获取站点设备信息 * 获取站点设备信息
* @param station * @param station
@ -705,39 +729,63 @@ public class HydropowerServiceImpl implements HydropowerService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
/** /**
* 水电站-机组列表 * 水电站站点列表
* @param deptId * @param deptId
* @return * @return
*/ */
@Override @Override
public List<HydropowerUnitVo> hydropowerDevice(Long deptId) { public List<HydropowerStationVo> webStationList(Long deptId) {
if(ObjectUtil.isEmpty(deptId)){ List<StationEntity> stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE,Collections.singletonList(HomePageConstant.HYDROPOWER),null);
return null; if(CollectionUtil.isEmpty(stations)){
}
// 查询站点
StationEntity station = stationService.getStationByCodeOrRefDept(null,deptId);
if(ObjectUtil.isEmpty(station)){
return null; return null;
} }
// 实时监测点数据 // 实时监测点数据
List<HydropowerUnitRealVo> realList = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); 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<HydropowerUnitTargetVo> targetList = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
return this.getDevices(station,realList,targetList); // 所有设备
} List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList();
// 实时天气
/** Map<String, HeWeatherWeatherNowResponse> weather = this.getWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
* 水电站站点列表 // 七天天气
* @param deptId Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
* @return return stations.stream().map(station->{
*/ HydropowerStationVo hydropower = new HydropowerStationVo();
@Override hydropower.setDeptId(station.getRefDept());
public List<HydropowerStationVo> webStationList(Long deptId) { hydropower.setDeptName(station.getName());
List<StationEntity> list = stationService.getStationType(null,Collections.singletonList(HomePageConstant.HYDROPOWER),null); hydropower.setStationCode(station.getCode());
if(CollectionUtil.isEmpty(list)){ // 站点状态
return null; List<SoeData> soeDataList = soeClient.getByLastLimitTime(null, station.getCode(), 1).getData();
} hydropower.setStationStatus(!CollectionUtil.isNotEmpty(soeDataList));
return this.getHydropowerStationList(list); // 站点实时天气
hydropower.setTemp(this.getTemp(weather,station.getCode()));
// 站点七天天气
hydropower.setWeather(this.getDailyList(weekWeather,station.getCode()));
// 限制水位
hydropower.setLimitWaterLevel(station.getLimitWaterLevel());
// 运行天数
hydropower.setRunDay(this.getRunDay(station));
// 装机容量
hydropower.setInstalledCapacity(this.getInstalledCapacity(deviceList,station.getRefDept()));
// 总有功功率(总发电负荷)
hydropower.setPowerSum(this.getPowerSum(realList,station.getRefDept()));
// 总有功单位
hydropower.setPowerUnit(this.getPowerUnit(realList,station.getRefDept()));
// 月计划发电量
hydropower.setPlanPowerMon(this.getPlanPowerrMon(station.getCode()));
// 年计划发电量
hydropower.setPlanPowerYear(this.getPlanPowerYear(station.getCode()));
// 月发电量、年发电量、年发电完成率
this.handleStationInfo(station.getRefDept(),hydropower);
// 水位、水位曲线
this.handleWaterLeve(station.getCode(),hydropower);
// 年发电量完成百分比
hydropower.setPowerYearMap(this.handlePowerFinish(station));
// 设备信息
hydropower.setDeviceList(this.getDevices(station,realList,targetList));
return hydropower;
}).collect(Collectors.toList());
} }
} }

72
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java

@ -23,9 +23,9 @@ import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.duty.vo.DutyInfoVo; import com.hnac.hzims.operational.duty.vo.DutyInfoVo;
import com.hnac.hzims.operational.duty.vo.DutyTaskVo; import com.hnac.hzims.operational.duty.vo.DutyTaskVo;
import com.hnac.hzims.operational.duty.vo.NextDutyInfoVo; import com.hnac.hzims.operational.duty.vo.NextDutyInfoVo;
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.maintenance.constants.MaintenanceConstant; import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
@ -66,6 +66,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/**
* @author ysj
*/
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
@ -308,13 +311,6 @@ public class SideHustleServiceImpl implements ISideHustleService {
}}); }});
List<String> faultList = operPhenomenonEntityList.stream().map(OperPhenomenonEntity::getEmCode).distinct().collect(Collectors.toList()); List<String> faultList = operPhenomenonEntityList.stream().map(OperPhenomenonEntity::getEmCode).distinct().collect(Collectors.toList());
deviceClassifyMap.put(HomePageConstant.FAULT,faultList); deviceClassifyMap.put(HomePageConstant.FAULT,faultList);
// 保养
/*List<OperMaintenanceTaskEntity> operMaintenanceTaskEntityList = operMaintenanceTaskService.list(new QueryWrapper<OperMaintenanceTaskEntity>() {{
in("EM_CODE", deviceCodeList);
ne("STATUS", MaintenanceConstant.TASK_STATUS_5);
}});
List<String> maintainList = operMaintenanceTaskEntityList.stream().map(OperMaintenanceTaskEntity::getEmCode).collect(Collectors.toList());
deviceClassifyMap.put(HomePageConstant.MAINTAIN,maintainList);*/
// 检修 // 检修
List<OperAccessTaskEntity> operAccessTaskEntityList = operAccessTaskService.list(new QueryWrapper<OperAccessTaskEntity>() {{ List<OperAccessTaskEntity> operAccessTaskEntityList = operAccessTaskService.list(new QueryWrapper<OperAccessTaskEntity>() {{
in("EM_CODE", deviceCodeList); in("EM_CODE", deviceCodeList);
@ -506,11 +502,11 @@ public class SideHustleServiceImpl implements ISideHustleService {
areaDutyVo.setGeneratingCapacity(generatingCapacity); areaDutyVo.setGeneratingCapacity(generatingCapacity);
} }
/** /***
* 根据当班时间查询发电量 * 根据当班时间查询发电量
* @param devices * @param devices
* @param startDate * @param start
* @param endDate * @param end
* @return * @return
*/ */
private float generateByDuty(List<EminfoAndEmParamVo> devices, Date start, Date end) { private float generateByDuty(List<EminfoAndEmParamVo> devices, Date start, Date end) {
@ -520,7 +516,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
} }
for(EminfoAndEmParamVo device : devices ){ for(EminfoAndEmParamVo device : devices ){
generate += analyseDataService.periodTargetFloat(DateUtil.format(start,DateUtil.PATTERN_DATETIME),DateUtil.format(end,DateUtil.PATTERN_DATETIME),3,5,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); generate += analyseDataService.periodTargetFloat(DateUtil.format(start,DateUtil.PATTERN_DATETIME),DateUtil.format(end,DateUtil.PATTERN_DATETIME),3,5,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
}; }
return generate; return generate;
} }
@ -585,7 +581,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE)); dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE));
dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND)); dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND));
return dateCal.getTime(); return dateCal.getTime();
}; }
/** /**
* 获取结束时间 * 获取结束时间
@ -608,7 +604,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
dateCal.set(Calendar.MINUTE, endCal.get(Calendar.MINUTE)); dateCal.set(Calendar.MINUTE, endCal.get(Calendar.MINUTE));
dateCal.set(Calendar.SECOND, endCal.get(Calendar.SECOND)); dateCal.set(Calendar.SECOND, endCal.get(Calendar.SECOND));
return dateCal.getTime(); return dateCal.getTime();
}; }
/** /**
* 当班运行数据 * 当班运行数据
@ -840,7 +836,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
return null; return null;
} }
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
List<String> monList = homePageService.getMonthList(0,12,false);; List<String> monList = homePageService.getMonthList(0,12,false);
// 获取总发电量 // 获取总发电量
float sumPower = this.getSumPower(map.values(),powerMap,monList); float sumPower = this.getSumPower(map.values(),powerMap,monList);
List<AreaPowerScaleVo> list = new ArrayList<>(); List<AreaPowerScaleVo> list = new ArrayList<>();
@ -854,7 +850,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
} }
areaPowerScaleVo.setPower(power); areaPowerScaleVo.setPower(power);
// 发电量占比 // 发电量占比
double scale = this.getPowerScale(power,sumPower);; double scale = this.getPowerScale(power,sumPower);
areaPowerScaleVo.setScale(scale); areaPowerScaleVo.setScale(scale);
list.add(areaPowerScaleVo); list.add(areaPowerScaleVo);
}); });
@ -874,7 +870,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
return null; return null;
} }
// 获取站点编码集合 // 获取站点编码集合
List<String> codes = map.entrySet().stream().map(o-> o.getValue().get(0).getCode()).collect(Collectors.toList()); List<String> codes = map.values().stream().map(stationEntities -> stationEntities.get(0).getCode()).collect(Collectors.toList());
// 获取站点实时天气 // 获取站点实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather( codes); Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather( codes);
// 获取站点7日天气 // 获取站点7日天气
@ -974,7 +970,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
* @return * @return
*/ */
private List<StationBodyVo> getStationData() { private List<StationBodyVo> getStationData() {
Map<String, StationBodyVo> map = new HashMap<>(); Map<String, StationBodyVo> map;
Object json = redisTemplate.opsForValue().get(station_data_key); Object json = redisTemplate.opsForValue().get(station_data_key);
if (ObjectUtil.isNotEmpty(json)) { if (ObjectUtil.isNotEmpty(json)) {
map = JSONObject.parseObject(json.toString(), new TypeReference<Map<String, StationBodyVo>>() { map = JSONObject.parseObject(json.toString(), new TypeReference<Map<String, StationBodyVo>>() {
@ -1166,9 +1162,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
} }
List<String> codeList = new ArrayList<>(); List<String> codeList = new ArrayList<>();
// 添加所有站点Code // 添加所有站点Code
map.values().forEach(item->{ map.values().forEach(item-> codeList.addAll(item.stream().map(StationEntity::getCode).collect(Collectors.toList())));
codeList.addAll(item.stream().map(StationEntity::getCode).collect(Collectors.toList()));
});
if(CollectionUtil.isEmpty(codeList)){ if(CollectionUtil.isEmpty(codeList)){
return null; return null;
} }
@ -1214,7 +1208,6 @@ public class SideHustleServiceImpl implements ISideHustleService {
return; return;
} }
// 存放设备信息集合 // 存放设备信息集合
List<DeviceVo> deviceVoList = new ArrayList<>();
List<String> equipmentCodeList = R.getData().stream().map(EmInfoEntity::getNumber).collect(Collectors.toList()); List<String> equipmentCodeList = R.getData().stream().map(EmInfoEntity::getNumber).collect(Collectors.toList());
// 总数 // 总数
@ -1224,7 +1217,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
// 故障 // 故障
List<DeviceVo> fault = this.handlerDeviceStatus(faultList,equipmentCodeList,"故障"); List<DeviceVo> fault = this.handlerDeviceStatus(faultList,equipmentCodeList,"故障");
equipmentCountVo.setFaultCount((long) fault.size()); equipmentCountVo.setFaultCount((long) fault.size());
deviceVoList.addAll(fault); List<DeviceVo> deviceVoList = new ArrayList<>(fault);
// 检修 // 检修
List<DeviceVo> overhaul = this.handlerDeviceStatus(overhaultList,equipmentCodeList,"检修"); List<DeviceVo> overhaul = this.handlerDeviceStatus(overhaultList,equipmentCodeList,"检修");
equipmentCountVo.setOverhaulCount((long) overhaul.size()); equipmentCountVo.setOverhaulCount((long) overhaul.size());
@ -1266,7 +1259,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
if(CollectionUtil.isEmpty(statusList) || CollectionUtil.isEmpty(equipmentCodeList)){ if(CollectionUtil.isEmpty(statusList) || CollectionUtil.isEmpty(equipmentCodeList)){
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> statusDevice = statusList.stream().filter(o->equipmentCodeList.contains(o)).distinct().collect(Collectors.toList()); List<String> statusDevice = statusList.stream().filter(equipmentCodeList::contains).distinct().collect(Collectors.toList());
if(CollectionUtil.isEmpty(statusDevice)){ if(CollectionUtil.isEmpty(statusDevice)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -1340,37 +1333,6 @@ public class SideHustleServiceImpl implements ISideHustleService {
} }
/** /**
* 递归查询子站点
*
* @param departList
* @param parentPart
* @param list
* @return
*/
private List<Dept> getAreaStation(List<Dept> departList, Dept parentPart, List<Dept> list) {
departList.forEach(dept -> {
if (dept.getParentId().equals(parentPart.getId())) {
// FIXME 是否只需要添加站点
if (dept.getDeptCategory().equals(4)) {
list.add(dept);
}
getAreaStation(departList, dept, list);
}
});
if(CollectionUtil.isEmpty(list)){
return null;
}
List<Long> deptList = list.stream().map(Dept::getId).collect(Collectors.toList());
List<StationEntity> stationList = this.getStation(Collections.singletonList(HomePageConstant.HYDROPOWER), deptList);
if(CollectionUtil.isEmpty(stationList)){
return null;
}
List<Long> refDeptList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
return list.stream().filter(o->refDeptList.contains(o.getId())).collect(Collectors.toList());
}
/**
* 区域机构下是否存在水电站 * 区域机构下是否存在水电站
* @param deptAuthList * @param deptAuthList
* @param area * @param area

182
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java

@ -100,41 +100,42 @@ public class WaterServiceImpl implements IWaterService {
*/ */
@Override @Override
public void loadWaterPumpReal(String param) { public void loadWaterPumpReal(String param) {
// 有效设备 // 水利站点
List<EminfoAndEmParamVo> valid = this.getValidDeviceList(); List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
if(CollectionUtil.isEmpty(valid)){ .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; return;
} }
// 实时数据 // 实时数据
Map<String, String> map = this.getRealMap(); Map<String, String> map = this.getRealMap();
List<WaterPumpRealVo> list = new ArrayList<>(); List<WaterPumpRealVo> list = devices.stream().map(device->{
valid.forEach(device->{ WaterPumpRealVo real = new WaterPumpRealVo();
WaterPumpRealVo waterPumpRealVo = new WaterPumpRealVo(); real.setDeptId(device.getCreateDept());
waterPumpRealVo.setDeptId(device.getCreateDept()); real.setDeviceCode(device.getEmCode());
waterPumpRealVo.setDeviceCode(device.getEmCode()); real.setDeptName(device.getName());
waterPumpRealVo.setDeptName(device.getName());
// 装机容量 // 装机容量
waterPumpRealVo.setInstalledCapacity(device.getInstalledCapacity()); real.setInstalledCapacity(device.getInstalledCapacity());
// 开机状态 // 开机状态
int state = this.getPumpState(device,map); real.setState(this.getPumpState(device,map));
waterPumpRealVo.setState(state);
// 功率因数 // 功率因数
double powerFactor = this.getPowerFactor(device,map); real.setPowerFactor(this.getPowerFactor(device,map));
waterPumpRealVo.setPowerFactor(powerFactor);
// 有功功率 // 有功功率
float activePower = this.getActivePower(device,map); real.setActivePower(this.getActivePower(device,map));
waterPumpRealVo.setActivePower(activePower);
// 无功功率 // 无功功率
float reactivePower = this.getReactivePower(device,map); real.setReactivePower(this.getReactivePower(device,map));
waterPumpRealVo.setReactivePower(reactivePower);
// 电压 // 电压
double voltage = this.getVoltage(device,map); real.setVoltage(this.getVoltage(device,map));
waterPumpRealVo.setVoltage(voltage);
// 电流 // 电流
double current = this.getCurrent(device,map); real.setCurrent(this.getCurrent(device,map));
waterPumpRealVo.setCurrent(current); return real;
list.add(waterPumpRealVo); }).collect(Collectors.toList());
});
redisTemplate.opsForValue().set(loadwaterpump_real_key,list); redisTemplate.opsForValue().set(loadwaterpump_real_key,list);
} }
@ -144,50 +145,47 @@ public class WaterServiceImpl implements IWaterService {
*/ */
@Override @Override
public void loadWaterPumpTarget(String param) { public void loadWaterPumpTarget(String param) {
List<EminfoAndEmParamVo> valid = this.getValidDeviceList(); // 水利站点
List<WaterPumpTargetVo> list = new ArrayList<>(); List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
if(CollectionUtil.isNotEmpty(valid)){ .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
valid.forEach(device->{ .in(StationEntity::getType,HomePageConstant.waterList)
WaterPumpTargetVo waterPumpTargetVo = new WaterPumpTargetVo(); );
waterPumpTargetVo.setDeptId(device.getCreateDept()); if(CollectionUtil.isEmpty(stations)){
waterPumpTargetVo.setDeviceCode(device.getEmCode()); return;
waterPumpTargetVo.setDeptName(device.getName()); }
// 泵站设备
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());
// 当年用电量 // 当年用电量
float usrPowerYear = this.getUsrPowerYear(device); target.setUsrPowerYear(this.getUsrPowerYear(device));
waterPumpTargetVo.setUsrPowerYear(usrPowerYear);
// 当月用电量 // 当月用电量
float usrPowerMon = this.getUsrPowerMon(device); target.setUsrPowerMon(this.getUsrPowerMon(device));
waterPumpTargetVo.setUsrPowerMon(usrPowerMon);
// 当日用电量 // 当日用电量
float usrPowerDay = this.getUsrPowerDay(device); target.setUsrPowerDay(this.getUsrPowerDay(device));
waterPumpTargetVo.setUsrPowerDay(usrPowerDay); // 当日机组有功功率
target.setActivePowerVoList(this.getActivePowerVoList(device));
// 近30天用电量
target.setUsrPowerVoList(this.getUsrPowerVoList(device));
// 近3年用电量
target.setUsrYearMap(this.getUsrYearMap(device));
// 月运行次数、时长 // 月运行次数、时长
WaterRunVo runMon = this.getRunData(device,1); WaterRunVo runMon = this.getRunData(device,1);
waterPumpTargetVo.setRunCountMon(runMon.getCount()); target.setRunCountMon(runMon.getCount());
waterPumpTargetVo.setRunDurationMon(runMon.getHour()); target.setRunDurationMon(runMon.getHour());
// 年运行次数、时长 // 年运行次数、时长
WaterRunVo runYear = this.getRunData(device,0); WaterRunVo runYear = this.getRunData(device,0);
waterPumpTargetVo.setRunCountYear(runYear.getCount()); target.setRunCountYear(runYear.getCount());
waterPumpTargetVo.setRunDurationYear(runYear.getHour()); target.setRunDurationYear(runYear.getHour());
// 当日机组有功功率 return target;
List<ActivePowerVo> activePowerVoList = this.getActivePowerVoList(device); }).collect(Collectors.toList()));
waterPumpTargetVo.setActivePowerVoList(activePowerVoList);
// 近30天用电量
List<UsrPowerVo> usrPowerVoList = this.getUsrPowerVoList(device);
waterPumpTargetVo.setUsrPowerVoList(usrPowerVoList);
// 近3年用电量
Map<String,Float> usrYearMap = this.getUsrYearMap(device);
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);
} }
@ -234,22 +232,19 @@ public class WaterServiceImpl implements IWaterService {
} }
/** /**
* 获取监测点位是否配置 * 泵站设备
* @param instanceCode * @param stations
* @return * @return
*/ */
private boolean getSetting(String instanceCode) { private List<EminfoAndEmParamVo> pumpDevices(List<Long> stations){
// 获取设备监测点位:未配置监测点位不进行统计设备 if(CollectionUtil.isEmpty(stations)){
List<MultiAnalyzeCodePO> list = new ArrayList<>(); return new ArrayList<>();
MultiAnalyzeCodePO po = new MultiAnalyzeCodePO(); }
po.setDeviceCode(instanceCode); List<EminfoAndEmParamVo> devices = maintenanceTaskService.getEmInfoList();
po.setSignages(Collections.singletonList(HomePageConstant.FRONT_WATER_LEVEL)); if(CollectionUtil.isEmpty(devices)){
list.add(po); return new ArrayList<>();
R<List<AnalyzeCodeBySignagesVO>> result = analyseDataSearchClient.getAnalyzeCodeBySignages(list);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return true;
} }
return false; return devices.stream().filter(device->stations.contains(device.getCreateDept())).collect(Collectors.toList());
} }
/** /**
@ -264,7 +259,7 @@ public class WaterServiceImpl implements IWaterService {
List<String> signages = Collections.singletonList(signage); List<String> signages = Collections.singletonList(signage);
realData.setSignages(signages); realData.setSignages(signages);
// 调用fegin接口查询实时数据 // 调用fegin接口查询实时数据
R<List<FieldsData>> R = null; R<List<FieldsData>> R;
try { try {
R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData); R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData);
} catch (Exception e) { } catch (Exception e) {
@ -333,29 +328,6 @@ public class WaterServiceImpl implements IWaterService {
} }
/** /**
* 获取有效设备
* @return
*/
private List<EminfoAndEmParamVo> getValidDeviceList() {
// 水利站点(All)
List<StationEntity> stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, HomePageConstant.waterList, null);
if(CollectionUtil.isEmpty(stationList)){
return null;
}
// 获取所有设备
List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList();
if(CollectionUtil.isEmpty(deviceList)){
return null;
}
// 有效泵租设备
List<Long> deptIdList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(deptIdList)){
return null;
}
return deviceList.stream().filter(o->deptIdList.contains(o.getCreateDept())).collect(Collectors.toList());
}
/**
* 获取有效站点模型 * 获取有效站点模型
* @return * @return
*/ */
@ -793,7 +765,7 @@ public class WaterServiceImpl implements IWaterService {
PowerMonthVo generate = new PowerMonthVo(); PowerMonthVo generate = new PowerMonthVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time, DateUtil.PATTERN_DATE)); generate.setStrMonth(DateUtil.format(time, DateUtil.PATTERN_DATE));
generate.setPower(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount());
return generate; return generate;
}).collect(Collectors.toMap(PowerMonthVo::getStrMonth,PowerMonthVo::getPower)); }).collect(Collectors.toMap(PowerMonthVo::getStrMonth,PowerMonthVo::getPower));
} }
@ -809,8 +781,6 @@ public class WaterServiceImpl implements IWaterService {
String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
String mon = DateUtil.format(calendar.getTime(),"yyyy-MM"); String mon = DateUtil.format(calendar.getTime(),"yyyy-MM");
String year = String.valueOf(calendar.get(Calendar.YEAR)); 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 ->{ return stations.stream().map(station ->{
WaterPumpTargetVo target = new WaterPumpTargetVo(); WaterPumpTargetVo target = new WaterPumpTargetVo();
target.setDeptId(station.getRefDept()); target.setDeptId(station.getRefDept());
@ -929,7 +899,7 @@ public class WaterServiceImpl implements IWaterService {
return null; return null;
} }
// 获取站点编码集合 // 获取站点编码集合
List<String> codes = map.entrySet().stream().map(o-> o.getValue().get(0).getCode()).collect(Collectors.toList()); List<String> codes = map.values().stream().map(stationEntities -> stationEntities.get(0).getCode()).collect(Collectors.toList());
// 获取实时天气 // 获取实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(codes); Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(codes);
// 获取七天天气 // 获取七天天气
@ -1018,7 +988,7 @@ public class WaterServiceImpl implements IWaterService {
* @return * @return
*/ */
private List<StationEntity> getStationList(Map<Dept, List<StationEntity>> map) { private List<StationEntity> getStationList(Map<Dept, List<StationEntity>> map) {
return map.values().stream().collect(Collectors.toList()).get(0); return new ArrayList<>(map.values()).get(0);
} }
/** /**
@ -1102,7 +1072,7 @@ public class WaterServiceImpl implements IWaterService {
if(CollectionUtil.isEmpty(stationList)){ if(CollectionUtil.isEmpty(stationList)){
return null; return null;
} }
List<String> codeList = stationList.stream().filter(o->StringUtil.isNotBlank(o.getCode())).map(StationEntity::getCode).collect(Collectors.toList()); List<String> codeList = stationList.stream().map(StationEntity::getCode).filter(StringUtil::isNotBlank).collect(Collectors.toList());
if(CollectionUtil.isEmpty(codeList)){ if(CollectionUtil.isEmpty(codeList)){
return null; return null;
} }
@ -1331,12 +1301,12 @@ public class WaterServiceImpl implements IWaterService {
response.setUsePowerMon((float) kwhMon); response.setUsePowerMon((float) kwhMon);
// 月运行时长 // 月运行时长
Optional<WaterPumpTargetVo> waterPumpTargetVoOptional = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationMon)); Optional<WaterPumpTargetVo> waterPumpTargetVoOptional = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationMon));
double monRunTime = waterPumpTargetVoOptional.isPresent() ? waterPumpTargetVoOptional.map(WaterPumpTargetVo::getRunDurationMon).orElse(0.0) : 0.0; double monRunTime = waterPumpTargetVoOptional.map(WaterPumpTargetVo::getRunDurationMon).orElse(0.0);
//double monRunTime = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationMon)).get().getRunDurationMon(); //double monRunTime = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationMon)).get().getRunDurationMon();
response.setRunDurationMon(monRunTime); response.setRunDurationMon(monRunTime);
// 年运行时长 // 年运行时长
Optional<WaterPumpTargetVo> optionalWaterPumpTargetVo = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationYear)); Optional<WaterPumpTargetVo> optionalWaterPumpTargetVo = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationYear));
double yearRunTime = optionalWaterPumpTargetVo.isPresent() ? optionalWaterPumpTargetVo.map(WaterPumpTargetVo::getRunDurationYear).orElse(0.0) : 0.0; double yearRunTime = optionalWaterPumpTargetVo.map(WaterPumpTargetVo::getRunDurationYear).orElse(0.0);
//double yearRunTime = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationYear)).get().getRunDurationYear(); //double yearRunTime = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationYear)).get().getRunDurationYear();
response.setRunDurationYear(yearRunTime); response.setRunDurationYear(yearRunTime);
// 水位曲线/年用电量 // 水位曲线/年用电量

Loading…
Cancel
Save