|
|
@ -4,13 +4,14 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hnac.hzims.EquipmentConstants; |
|
|
|
import com.hnac.hzims.EquipmentConstants; |
|
|
|
|
|
|
|
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; |
|
|
|
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; |
|
|
|
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.fill.service.GenerateService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.fill.service.PowerService; |
|
|
|
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.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
@ -27,6 +28,7 @@ import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -41,20 +43,21 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* APP首页实现类 |
|
|
|
* APP首页实现类 |
|
|
|
|
|
|
|
* @author ysj |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
|
|
|
|
|
|
|
|
private final IWaterService waterService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IWeatherService weatherService; |
|
|
|
private final IWeatherService weatherService; |
|
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
|
|
private final GenerateService generateService; |
|
|
|
private final GenerateService generateService; |
|
|
|
|
|
|
|
|
|
|
|
private final IHomePageService homePageService; |
|
|
|
private final PowerService photovoltaicService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final AreaService areaService; |
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataService analyseDataService; |
|
|
|
private final IAnalyseDataService analyseDataService; |
|
|
|
|
|
|
|
|
|
|
@ -107,8 +110,10 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
real.setDeviceCode(device.getEmCode()); |
|
|
|
real.setDeviceCode(device.getEmCode()); |
|
|
|
real.setDeptName(device.getName()); |
|
|
|
real.setDeptName(device.getName()); |
|
|
|
real.setDeviceName(device.getName()); |
|
|
|
real.setDeviceName(device.getName()); |
|
|
|
|
|
|
|
// 装机容量
|
|
|
|
|
|
|
|
real.setInstalledCapacity(device.getInstalledCapacity()); |
|
|
|
// 开关机状态
|
|
|
|
// 开关机状态
|
|
|
|
real.setState(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY)); |
|
|
|
real.setState(Math.abs(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY)) > 0); |
|
|
|
// 有功功率
|
|
|
|
// 有功功率
|
|
|
|
real.setActivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER)); |
|
|
|
real.setActivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER)); |
|
|
|
// 无功功率
|
|
|
|
// 无功功率
|
|
|
@ -165,7 +170,7 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
// 当日发电量
|
|
|
|
// 当日发电量
|
|
|
|
target.setPowerDay(this.getGenerationPower(device,2)); |
|
|
|
target.setPowerDay(this.getGenerationPower(device,2)); |
|
|
|
// 当天有功功率
|
|
|
|
// 当天有功功率
|
|
|
|
target.setActivePowerVoList(waterService.getActivePowerVoList(device)); |
|
|
|
target.setActivePowerVoList(this.getLoadsByDay(device)); |
|
|
|
// 30天发电量
|
|
|
|
// 30天发电量
|
|
|
|
target.setGenerationPowerVoList(this.getGenerationPowerList(device)); |
|
|
|
target.setGenerationPowerVoList(this.getGenerationPowerList(device)); |
|
|
|
return target; |
|
|
|
return target; |
|
|
@ -178,6 +183,112 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets); |
|
|
|
redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 近年发电量数据 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param param 时间 |
|
|
|
|
|
|
|
* @param serveType 站点类型 |
|
|
|
|
|
|
|
* @param year 近几年 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void loadPowerData(String param, List<Integer> types, Integer serveType, int year) { |
|
|
|
|
|
|
|
// 站点查询
|
|
|
|
|
|
|
|
List<StationEntity> stationList = stationService.getStationType(serveType, types, null); |
|
|
|
|
|
|
|
// 设备信息
|
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> devices = maintenanceTaskService.getEmInfoList(); |
|
|
|
|
|
|
|
// 开始时间
|
|
|
|
|
|
|
|
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) - year); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; |
|
|
|
|
|
|
|
// 存储数据map :<站点id,<月份,发电量>>
|
|
|
|
|
|
|
|
Map<Long, Map<String, Float>> powerMap = new HashMap<>(); |
|
|
|
|
|
|
|
stationList.forEach(station -> { |
|
|
|
|
|
|
|
// 站点设备集合
|
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
Map<String, Float> generateMap = this.getGenerateYear(station,stationDevices,start,end); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(generateMap)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
powerMap.put(station.getId(),generateMap); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(recent_year_power_data, powerMap); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 当天有功功率 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<ActivePowerVo> getLoadsByDay(EminfoAndEmParamVo device) { |
|
|
|
|
|
|
|
// FIXME 当天功率测试数据
|
|
|
|
|
|
|
|
Calendar start = Calendar.getInstance(); |
|
|
|
|
|
|
|
start.add(Calendar.HOUR_OF_DAY,-start.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
List<ActivePowerVo> list = new ArrayList<>(); |
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
|
|
while (start.getTime().compareTo(new Date()) <= 0){ |
|
|
|
|
|
|
|
ActivePowerVo load = new ActivePowerVo(); |
|
|
|
|
|
|
|
load.setHour(start.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
load.setActivePower(String.valueOf(random.nextDouble() * 500)); |
|
|
|
|
|
|
|
list.add(load); |
|
|
|
|
|
|
|
start.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
/*String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; |
|
|
|
|
|
|
|
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(records)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return records.stream().map(record -> { |
|
|
|
|
|
|
|
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); |
|
|
|
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
|
|
|
load.setHour(DateUtil.format(time,"yyyy-mm-dd HH")); |
|
|
|
|
|
|
|
load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); |
|
|
|
|
|
|
|
return load; |
|
|
|
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取年发电量 |
|
|
|
|
|
|
|
* @param devices |
|
|
|
|
|
|
|
* @param start |
|
|
|
|
|
|
|
* @param end |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<String, Float> getGenerateYear(StationEntity station,List<EminfoAndEmParamVo> devices, String start, String end) { |
|
|
|
|
|
|
|
List<PowerMonthVo> datas = new ArrayList<>(); |
|
|
|
|
|
|
|
// 设备采集发电量
|
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(devices)){ |
|
|
|
|
|
|
|
devices.forEach(device->{ |
|
|
|
|
|
|
|
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
datas.addAll(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.toList())); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 补充填报数据
|
|
|
|
|
|
|
|
datas.addAll(this.generateFill(station,start,end)); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(datas)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取填报用电量 |
|
|
|
* 获取填报用电量 |
|
|
|
* @param stations |
|
|
|
* @param stations |
|
|
@ -206,6 +317,23 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 补充填报数据 |
|
|
|
|
|
|
|
* @param station |
|
|
|
|
|
|
|
* @param start |
|
|
|
|
|
|
|
* @param end |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<PowerMonthVo> generateFill(StationEntity station, String start, String end) { |
|
|
|
|
|
|
|
start = DateUtil.format(DateUtil.parse(start,DateUtil.PATTERN_DATETIME),"yyyy-MM"); |
|
|
|
|
|
|
|
end = DateUtil.format(DateUtil.parse(end,DateUtil.PATTERN_DATETIME),"yyyy-MM"); |
|
|
|
|
|
|
|
// 光伏
|
|
|
|
|
|
|
|
if(HomePageConstant.PHOTOVOLTAIC.equals(station.getType())){ |
|
|
|
|
|
|
|
return photovoltaicService.generateThreeYear(start,end,station.getRefDept()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 水电
|
|
|
|
|
|
|
|
return generateService.generateThreeYear(start,end,station.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 泵站设备 |
|
|
|
* 泵站设备 |
|
|
|
* @param stations |
|
|
|
* @param stations |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -236,28 +364,28 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取监测点实时数据 |
|
|
|
* 获取监测点实时数据 |
|
|
|
* @param em |
|
|
|
* @param device |
|
|
|
* @param targets |
|
|
|
* @param targets |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private String getSignageValue(EminfoAndEmParamVo em,Map<String, String> map, String targets) { |
|
|
|
private double getSignageValue(EminfoAndEmParamVo device,Map<String, String> map, String targets) { |
|
|
|
if(ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)){ |
|
|
|
if(ObjectUtil.isEmpty(device) || MapUtils.isEmpty(map)){ |
|
|
|
return "0"; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,String> point = em.getPoint(); |
|
|
|
Map<String,String> point = device.getPoint(); |
|
|
|
if(MapUtils.isEmpty(point)){ |
|
|
|
if(MapUtils.isEmpty(point)){ |
|
|
|
return "0"; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
String realId = point.get(targets); |
|
|
|
String realId = point.get(targets); |
|
|
|
if(StringUtil.isBlank(realId)){ |
|
|
|
if(StringUtil.isBlank(realId)){ |
|
|
|
return "0"; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
String value = map.get(realId); |
|
|
|
String value = map.get(realId); |
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
if(StringUtil.isBlank(value)){ |
|
|
|
return "0"; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
// 获取value
|
|
|
|
// 获取value
|
|
|
|
return value; |
|
|
|
return Double.parseDouble(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -345,11 +473,25 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) { |
|
|
|
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) { |
|
|
|
String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); |
|
|
|
// FIXME 测试数据
|
|
|
|
|
|
|
|
String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-29); |
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-29); |
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); |
|
|
|
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
|
|
List<GenerationPowerVo> generates = new ArrayList<>(); |
|
|
|
|
|
|
|
if(calendar.getTime().compareTo(new Date()) <= 0){ |
|
|
|
|
|
|
|
GenerationPowerVo generate = new GenerationPowerVo(); |
|
|
|
|
|
|
|
generate.setDate(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
generate.setGenerate(random.nextFloat() * 500000f); |
|
|
|
|
|
|
|
generates.add(generate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return generates; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); |
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
@ -359,7 +501,7 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); |
|
|
|
generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); |
|
|
|
generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); |
|
|
|
generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); |
|
|
|
return generate; |
|
|
|
return generate; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList());*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -388,6 +530,8 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
// 七天天气
|
|
|
|
// 七天天气
|
|
|
|
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode())); |
|
|
|
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode())); |
|
|
|
HydropowerStationVo response = new HydropowerStationVo(); |
|
|
|
HydropowerStationVo response = new HydropowerStationVo(); |
|
|
|
|
|
|
|
// 近年发电量数据
|
|
|
|
|
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
response.setDeptId(station.getRefDept()); |
|
|
|
response.setDeptId(station.getRefDept()); |
|
|
|
response.setDeptName(station.getName()); |
|
|
|
response.setDeptName(station.getName()); |
|
|
|
response.setStationCode(station.getCode()); |
|
|
|
response.setStationCode(station.getCode()); |
|
|
@ -417,7 +561,7 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
// 水位、水位曲线
|
|
|
|
// 水位、水位曲线
|
|
|
|
this.handleWaterLeve(station.getCode(),response); |
|
|
|
this.handleWaterLeve(station.getCode(),response); |
|
|
|
// 年发电量完成百分比
|
|
|
|
// 年发电量完成百分比
|
|
|
|
response.setPowerYearMap(this.handlePowerFinish(station)); |
|
|
|
response.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map)); |
|
|
|
// 设备信息
|
|
|
|
// 设备信息
|
|
|
|
response.setDeviceList(this.getDevices(station,realList,targetList)); |
|
|
|
response.setDeviceList(this.getDevices(station,realList,targetList)); |
|
|
|
return response; |
|
|
|
return response; |
|
|
@ -578,7 +722,7 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
if(CollectionUtil.isEmpty(realList)){ |
|
|
|
if(CollectionUtil.isEmpty(realList)){ |
|
|
|
return 0.0; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(o->Double.parseDouble(o.getActivePower())).sum(); |
|
|
|
return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -681,21 +825,18 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 年发电量完成百分比 |
|
|
|
* 年发电量完成百分比 |
|
|
|
* @param station |
|
|
|
* @param stations |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<PowerMonthVo> handlePowerFinish(StationEntity station) { |
|
|
|
private List<PowerMonthVo> handlePowerFinish(List<StationEntity> stations,Map<Long, Map<String, Float>> map) { |
|
|
|
String code = station.getCode(); |
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
if(StringUtil.isBlank(code)){ |
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
// 实际发电量
|
|
|
|
|
|
|
|
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
|
|
|
|
// 查询计划发电量
|
|
|
|
// 查询计划发电量
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTime(new Date()); |
|
|
|
calendar.setTime(new Date()); |
|
|
|
List<PlanPowerYearVo> planPowerList = planGenertionClient.getPlanPowerByYear(code,calendar.get(Calendar.YEAR)); |
|
|
|
List<PlanGenerationEntity> plans = planGenertionClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,String.valueOf(calendar.get(Calendar.YEAR))); |
|
|
|
// 获取月份集合
|
|
|
|
// 获取月份集合
|
|
|
|
List<String> monList = homePageService.getMonthList(0,12,false); |
|
|
|
List<String> monList = this.mons(0,12,false); |
|
|
|
return monList.stream().map(o->{ |
|
|
|
return monList.stream().map(o->{ |
|
|
|
PowerMonthVo vo = new PowerMonthVo(); |
|
|
|
PowerMonthVo vo = new PowerMonthVo(); |
|
|
|
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), o), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), o), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
@ -703,32 +844,55 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
vo.setYear(localDate.getYear()); |
|
|
|
vo.setYear(localDate.getYear()); |
|
|
|
vo.setMonth(localDate.getMonthValue()); |
|
|
|
vo.setMonth(localDate.getMonthValue()); |
|
|
|
// 实际发电量
|
|
|
|
// 实际发电量
|
|
|
|
if(CollectionUtil.isEmpty(powerMap)){ |
|
|
|
if(CollectionUtil.isEmpty(map)){ |
|
|
|
vo.setPower(0f); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
Map<String, Float> map = powerMap.get(station.getId()); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(map)){ |
|
|
|
|
|
|
|
vo.setPower(0f); |
|
|
|
vo.setPower(0f); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
vo.setPower(map.get(o)); |
|
|
|
float generate = (float) map.entrySet().stream(). |
|
|
|
} |
|
|
|
filter(entry->stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(entry.getKey())). |
|
|
|
|
|
|
|
mapToDouble(valueMap-> valueMap.getValue().entrySet().stream().filter(entry->entry.getKey().equals(o)) |
|
|
|
|
|
|
|
.mapToDouble(Map.Entry::getValue).sum()).sum(); |
|
|
|
|
|
|
|
vo.setPower(generate); |
|
|
|
} |
|
|
|
} |
|
|
|
// 计划发电量
|
|
|
|
// 计划发电量
|
|
|
|
if(CollectionUtil.isEmpty(planPowerList)){ |
|
|
|
if(CollectionUtil.isEmpty(plans)){ |
|
|
|
vo.setPlanPower(0f); |
|
|
|
vo.setPlanPower(0f); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
String mon = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); |
|
|
|
String mon = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); |
|
|
|
List<PlanPowerYearVo> list = planPowerList.stream().filter(s->mon.equals(s.getMon())).collect(Collectors.toList()); |
|
|
|
vo.setPlanPower((float)plans.stream().filter(plan->mon.equals(plan.getDateTime())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
|
|
|
|
vo.setPlanPower(0f); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
vo.setPlanPower(list.get(0).getPlanPower()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return vo; |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取近年月份集合 |
|
|
|
|
|
|
|
* @param year |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public List<String> mons(int year, int endMoth, boolean nextMon) { |
|
|
|
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
|
|
|
|
// 开始日期
|
|
|
|
|
|
|
|
Calendar endCal = Calendar.getInstance(); |
|
|
|
|
|
|
|
endCal.setTime(new Date()); |
|
|
|
|
|
|
|
endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth); |
|
|
|
|
|
|
|
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 结束日期
|
|
|
|
|
|
|
|
Calendar startCal = Calendar.getInstance(); |
|
|
|
|
|
|
|
startCal.setTime(new Date()); |
|
|
|
|
|
|
|
startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year); |
|
|
|
|
|
|
|
startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
// 获取日期之间的月份
|
|
|
|
|
|
|
|
while (endCal.after(startCal)) { |
|
|
|
|
|
|
|
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
startCal.add(Calendar.MONTH, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(nextMon){ |
|
|
|
|
|
|
|
list.add(DateUtil.format(endCal.getTime(),DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 水电站站点列表 |
|
|
|
* 水电站站点列表 |
|
|
@ -751,6 +915,8 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
Map<String, HeWeatherWeatherNowResponse> weather = this.getWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
Map<String, HeWeatherWeatherNowResponse> weather = this.getWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
// 七天天气
|
|
|
|
// 七天天气
|
|
|
|
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
|
|
|
// 站点近年发电数据 key - id value - 月份,发电量
|
|
|
|
|
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
return stations.stream().map(station->{ |
|
|
|
return stations.stream().map(station->{ |
|
|
|
HydropowerStationVo hydropower = new HydropowerStationVo(); |
|
|
|
HydropowerStationVo hydropower = new HydropowerStationVo(); |
|
|
|
hydropower.setDeptId(station.getRefDept()); |
|
|
|
hydropower.setDeptId(station.getRefDept()); |
|
|
@ -782,7 +948,7 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
// 水位、水位曲线
|
|
|
|
// 水位、水位曲线
|
|
|
|
this.handleWaterLeve(station.getCode(),hydropower); |
|
|
|
this.handleWaterLeve(station.getCode(),hydropower); |
|
|
|
// 年发电量完成百分比
|
|
|
|
// 年发电量完成百分比
|
|
|
|
hydropower.setPowerYearMap(this.handlePowerFinish(station)); |
|
|
|
hydropower.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map)); |
|
|
|
// 设备信息
|
|
|
|
// 设备信息
|
|
|
|
hydropower.setDeviceList(this.getDevices(station,realList,targetList)); |
|
|
|
hydropower.setDeviceList(this.getDevices(station,realList,targetList)); |
|
|
|
return hydropower; |
|
|
|
return hydropower; |
|
|
@ -795,7 +961,224 @@ public class HydropowerServiceImpl implements HydropowerService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public HydropowerStationVo area_target(Long deptId) { |
|
|
|
public HydropowerScoreVo KPIs(Long deptId) { |
|
|
|
|
|
|
|
// 查询水电站站点
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(stations)) { |
|
|
|
|
|
|
|
return new HydropowerScoreVo(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
HydropowerScoreVo kpi = new HydropowerScoreVo(); |
|
|
|
|
|
|
|
kpi.setDepartId(deptId); |
|
|
|
|
|
|
|
// 站点数量
|
|
|
|
|
|
|
|
kpi.setStationCount(stations.size()); |
|
|
|
|
|
|
|
// 实时数据
|
|
|
|
|
|
|
|
List<HydropowerUnitRealVo> deviceReals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(deviceReals)) { |
|
|
|
|
|
|
|
List<HydropowerUnitRealVo> reals = deviceReals.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(reals)) { |
|
|
|
|
|
|
|
// 容量
|
|
|
|
|
|
|
|
kpi.setInstalledCapacity(reals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); |
|
|
|
|
|
|
|
// 负荷
|
|
|
|
|
|
|
|
kpi.setLoad(reals.stream().mapToDouble(HydropowerUnitRealVo::getActivePower).sum()); |
|
|
|
|
|
|
|
// 容量利用率
|
|
|
|
|
|
|
|
if (Math.abs(kpi.getInstalledCapacity()) <= 0) { |
|
|
|
|
|
|
|
kpi.setCapacityRate(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
kpi.setCapacityRate(BigDecimal.valueOf(kpi.getLoad() / kpi.getInstalledCapacity() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 指标数据
|
|
|
|
|
|
|
|
List<HydropowerUnitTargetVo> deviceTargets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(deviceTargets)) { |
|
|
|
|
|
|
|
List<HydropowerUnitTargetVo> targets = deviceTargets.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(targets)) { |
|
|
|
|
|
|
|
// 年发电量
|
|
|
|
|
|
|
|
kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); |
|
|
|
|
|
|
|
// 月发电量
|
|
|
|
|
|
|
|
kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); |
|
|
|
|
|
|
|
// 日发电量
|
|
|
|
|
|
|
|
kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); |
|
|
|
|
|
|
|
// 年计划发电量
|
|
|
|
|
|
|
|
Double plan = planGenertionClient.getPlanPowerYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
|
|
|
kpi.setPlan(plan); |
|
|
|
|
|
|
|
if(Math.abs(plan) <= 0){ |
|
|
|
|
|
|
|
kpi.setPlanRate(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
kpi.setPlanRate(BigDecimal.valueOf(kpi.getGenerateYear() / plan * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 站点近年发电数据 key - id value - 月份,发电量
|
|
|
|
|
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
|
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
|
|
|
|
return kpi; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 今年发电趋势
|
|
|
|
|
|
|
|
kpi.setPowerMonthVoList(this.handlePowerFinish(stations,map)); |
|
|
|
|
|
|
|
// 近3年发电量
|
|
|
|
|
|
|
|
kpi.setPowerYearVoList(this.generateThreeYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList()),map)); |
|
|
|
|
|
|
|
return kpi; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 水电站集团/区域指标占比 |
|
|
|
|
|
|
|
* @param deptId |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<AreaScaleVo> proportion(Long deptId) { |
|
|
|
|
|
|
|
// 获取区域或者站点map结构
|
|
|
|
|
|
|
|
Map<Dept,List<StationEntity>> areas = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(areas)){ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<String> codes = new ArrayList<>(); |
|
|
|
|
|
|
|
areas.forEach((key,value)-> codes.addAll(value.stream().map(StationEntity::getCode).collect(Collectors.toList()))); |
|
|
|
|
|
|
|
// 获取站点编码集合
|
|
|
|
|
|
|
|
List<String> stations = areas.values().stream().map(values -> values.get(0).getCode()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 获取站点实时天气
|
|
|
|
|
|
|
|
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(stations); |
|
|
|
|
|
|
|
// 获取站点7日天气
|
|
|
|
|
|
|
|
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather(stations); |
|
|
|
|
|
|
|
// 计划发电量
|
|
|
|
|
|
|
|
List<PlanGenerationEntity> plans = planGenertionClient.getPlanGenerationByParam(codes, null, DateUtil.format(new Date(), "yyyy")); |
|
|
|
|
|
|
|
// 实时监测点数据
|
|
|
|
|
|
|
|
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); |
|
|
|
|
|
|
|
// 获取站点机组指标数据
|
|
|
|
|
|
|
|
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); |
|
|
|
|
|
|
|
// 获取总发电量
|
|
|
|
|
|
|
|
List<String> monList = this.mons(0,12,false); |
|
|
|
|
|
|
|
List<AreaScaleVo> scales = areas.entrySet().stream().map(entry->{ |
|
|
|
|
|
|
|
AreaScaleVo scale = new AreaScaleVo(); |
|
|
|
|
|
|
|
scale.setDeptId(entry.getKey().getId()); |
|
|
|
|
|
|
|
scale.setSort(entry.getKey().getSort()); |
|
|
|
|
|
|
|
scale.setDeptName(entry.getKey().getDeptName()); |
|
|
|
|
|
|
|
// 天气
|
|
|
|
|
|
|
|
this.getAreaWearther(scale,nowWeather,weekWeather,entry.getValue().get(0).getCode()); |
|
|
|
|
|
|
|
// 指标数据: 发电量完成率
|
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(targets)){ |
|
|
|
|
|
|
|
// 当年发电量
|
|
|
|
|
|
|
|
double generate = targets.stream().filter(target->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(target.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); |
|
|
|
|
|
|
|
scale.setPowerYear((float) generate); |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(plans)){ |
|
|
|
|
|
|
|
// 当年计划发电量
|
|
|
|
|
|
|
|
double generatePlan = plans.stream().filter(plan-> entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(plan.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); |
|
|
|
|
|
|
|
if(Math.abs(generatePlan) > 0){ |
|
|
|
|
|
|
|
scale.setGenerationRate(BigDecimal.valueOf(generate / generatePlan * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
scale.setGenerationRate(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
scale.setGenerationRate(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 实时数据: 容量利用率、电站利用率
|
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(reals)){ |
|
|
|
|
|
|
|
// 实时功率
|
|
|
|
|
|
|
|
double use = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum(); |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(plans)){ |
|
|
|
|
|
|
|
// 装机容量
|
|
|
|
|
|
|
|
double capacity = reals.stream().filter(real-> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum(); |
|
|
|
|
|
|
|
if(Math.abs(capacity) > 0){ |
|
|
|
|
|
|
|
scale.setCapacityUse(BigDecimal.valueOf(use / capacity * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
scale.setCapacityUse(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
scale.setCapacityUse(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 开机数量
|
|
|
|
|
|
|
|
long on = reals.stream().filter(real -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId()) && real.getState()).count(); |
|
|
|
|
|
|
|
long sum = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).count(); |
|
|
|
|
|
|
|
if(Math.abs(sum) > 0){ |
|
|
|
|
|
|
|
scale.setDeviceUse(BigDecimal.valueOf(on / sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return scale; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
double generate_sum = scales.stream().mapToDouble(AreaScaleVo::getPowerYear).sum(); |
|
|
|
|
|
|
|
// 返回结果集
|
|
|
|
|
|
|
|
if(Math.abs(generate_sum) > 0){ |
|
|
|
|
|
|
|
return scales.stream().peek(scale-> scale.setAreaMakeUp(BigDecimal.valueOf(scale.getPowerYear() / generate_sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue())). |
|
|
|
|
|
|
|
/*filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0 |
|
|
|
|
|
|
|
&& Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerationRate()) > 0) |
|
|
|
|
|
|
|
.*/sorted(Comparator.comparing(AreaScaleVo::getPowerYear).reversed()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return scales.stream().peek(scale-> scale.setAreaMakeUp(0.0))./*filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0 |
|
|
|
|
|
|
|
&& Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerationRate()) > 0) |
|
|
|
|
|
|
|
.*/sorted(Comparator.comparing(AreaScaleVo::getPowerYear).reversed()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 区域天气 |
|
|
|
|
|
|
|
* @param scale |
|
|
|
|
|
|
|
* @param nowWeather |
|
|
|
|
|
|
|
* @param weekWeather |
|
|
|
|
|
|
|
* @param code |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void getAreaWearther(AreaScaleVo scale,Map<String, HeWeatherWeatherNowResponse> nowWeather, Map<String, HeWeatherWeatherDailyResponse> weekWeather, String code) { |
|
|
|
|
|
|
|
// 实时天气
|
|
|
|
|
|
|
|
if(MapUtils.isNotEmpty(nowWeather) && nowWeather.containsKey(code)){ |
|
|
|
|
|
|
|
HeWeatherWeatherNowResponse nowData = nowWeather.get(code); |
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(nowData.getNow())){ |
|
|
|
|
|
|
|
scale.setTemp(nowData.getNow().getTemp()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 站点七日内天气
|
|
|
|
|
|
|
|
if(MapUtils.isNotEmpty(weekWeather) && weekWeather.containsKey(code)){ |
|
|
|
|
|
|
|
HeWeatherWeatherDailyResponse weekData = weekWeather.get(code); |
|
|
|
|
|
|
|
List<Daily> dailyList = weekData.getDaily(); |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(dailyList)) { |
|
|
|
|
|
|
|
scale.setWeather(dailyList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 近3年发电量 |
|
|
|
|
|
|
|
* @param stations |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<PowerYearVo> generateThreeYear(List<Long> stations,Map<Long, Map<String, Float>> map) { |
|
|
|
|
|
|
|
List<Map<String, Float>> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(filter)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 根据月份分组
|
|
|
|
|
|
|
|
List<PowerMonthVo> powerMonthVos = new ArrayList<>(); |
|
|
|
|
|
|
|
filter.forEach(item -> item.forEach((key, value) -> { |
|
|
|
|
|
|
|
PowerMonthVo powerMonthVo = new PowerMonthVo(); |
|
|
|
|
|
|
|
powerMonthVo.setStrMonth(key); |
|
|
|
|
|
|
|
powerMonthVo.setPower(value); |
|
|
|
|
|
|
|
powerMonthVos.add(powerMonthVo); |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); |
|
|
|
|
|
|
|
// 总和所有相同月份的发电量
|
|
|
|
|
|
|
|
List<PowerMonthVo> powerMonthVoList = months.entrySet().stream().map(entry -> { |
|
|
|
|
|
|
|
PowerMonthVo powerMonth = new PowerMonthVo(); |
|
|
|
|
|
|
|
powerMonth.setStrMonth(entry.getKey()); |
|
|
|
|
|
|
|
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
powerMonth.setYear(localDate.getYear()); |
|
|
|
|
|
|
|
powerMonth.setMonth(localDate.getMonthValue()); |
|
|
|
|
|
|
|
powerMonth.setPower((float) entry.getValue().stream().mapToDouble(PowerMonthVo::getPower).sum()); |
|
|
|
|
|
|
|
return powerMonth; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(powerMonthVoList)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 根据年份分组
|
|
|
|
|
|
|
|
Map<Integer, List<PowerMonthVo>> year = powerMonthVoList.stream().collect(Collectors.groupingBy(PowerMonthVo::getYear)); |
|
|
|
|
|
|
|
// 返回结果集
|
|
|
|
|
|
|
|
return year.entrySet().stream().map(entry -> { |
|
|
|
|
|
|
|
PowerYearVo powerYearVo = new PowerYearVo(); |
|
|
|
|
|
|
|
powerYearVo.setYear(entry.getKey()); |
|
|
|
|
|
|
|
List<PowerMonthVo> sortValue = entry.getValue().stream().sorted(Comparator.comparing(PowerMonthVo::getMonth)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
powerYearVo.setPowerMonthVoList(sortValue); |
|
|
|
|
|
|
|
return powerYearVo; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|