Browse Source

#新版电站首页

zhongwei
yang_shj 4 months ago
parent
commit
79264d7985
  1. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java
  2. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java
  3. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/pv/PowerRainVo.java
  4. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  5. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  6. 100
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java

@ -1,6 +1,7 @@
package com.hnac.hzims.operational.main.vo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.operational.main.vo.pv.PowerRainVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -78,6 +79,9 @@ public class HydropowerStationVo {
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "降雨/发电量曲线")
private List<PowerRainVo> powerRains;
@ApiModelProperty(value = "前水位曲线数据")
private Map<Integer,String> frontCurveMap;

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java

@ -41,10 +41,10 @@ public class HydropowerUnitTargetVo {
private Float powerYesterDay;
@ApiModelProperty(value = "本次开机时间")
private String startTime;
private String startDownTime;
@ApiModelProperty(value = "本次开机时长")
private Double startupDuration;
private Double startupDownDuration;
@ApiModelProperty(value = "年停机时长")
private Double shutDownDurationYear;

26
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/pv/PowerRainVo.java

@ -0,0 +1,26 @@
package com.hnac.hzims.operational.main.vo.pv;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "当日机组有功功率")
public class PowerRainVo {
@ApiModelProperty(value = "日期")
private String date;
@ApiModelProperty(value = "发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate;
@ApiModelProperty(value = "降雨")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double rain;
}

7
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java

@ -59,9 +59,10 @@ public class RealTargetScheduledTask {
/**
* 水电站-机组指标加载
*/
@XxlJob(LOAD_HYDROPOWER_UNIT_TARGET)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadHydropowerTarget(String param) {
//@XxlJob(LOAD_HYDROPOWER_UNIT_TARGET)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadHydropowerTarget() {
String param = "";
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}

12
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

@ -291,6 +291,7 @@ public class RealTargetServiceImpl implements RealTargetService {
List<HydropowerUnitTargetVo> targets = this.generteFill(stations);
// 水电站设备
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
Random random = new Random();
if(CollectionUtil.isNotEmpty(devices)){
CountDownLatch countDownLatch = new CountDownLatch(devices.size());
for(EminfoAndEmParamVo device : devices) {
@ -316,6 +317,16 @@ public class RealTargetServiceImpl implements RealTargetService {
target.setActivePowerVoList(this.getLoadsByDay(device));
// 30天发电量
target.setGenerationPowerVoList(this.getGenerationPowerList(generations,device));
// FIXME 本次开机/停机时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE,random.nextInt(1440));
target.setStartDownTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME));
// FIXME 本次开/停机时长
target.setStartupDownDuration(random.nextDouble() * 24);
// FIXME 今年开机时长
target.setStartupDurationYear(random.nextDouble() * 5024);
// FIXME 今年停机时长
target.setShutDownDurationYear(5024 - target.getStartupDurationYear());
targets.add(target);
countDownLatch.countDown();
}catch (Exception exception){
@ -334,6 +345,7 @@ public class RealTargetServiceImpl implements RealTargetService {
if(CollectionUtil.isEmpty(targets)){
return;
}
redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets);
}

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

@ -6,6 +6,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.feign.IRainfallClient;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
@ -17,11 +18,11 @@ import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo;
import com.hnac.hzims.operational.fill.entity.GenerateEntity;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.main.vo.pv.PowerRainVo;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.station.entity.StationEntity;
@ -92,6 +93,8 @@ public class HydropowerServiceImpl implements HydropowerService {
private final ISysClient sysClient;
private final IRainfallClient rainfallClient;
private final ITicketInfoClient ticketInfoClient;
private final IPlanGenertionClient planGenertionClient;
@ -139,6 +142,8 @@ public class HydropowerServiceImpl implements HydropowerService {
Map<String, HeWeatherWeatherNowResponse> weather = this.getWeather(Collections.singletonList(station.getCode()));
// 七天天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode()));
// 近30天降雨
List<Map<String, Object>> rains = this.get30DayRain(station.getCode());
HydropowerStationVo response = new HydropowerStationVo();
// 近年发电量数据
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
@ -169,7 +174,7 @@ public class HydropowerServiceImpl implements HydropowerService {
response.setPlanPowerYear(this.getPlanPowerYear(station.getCode()));
// 年发电量、月发电量
this.stationMonthPower(station.getCode(),map,response);
// 水位、水位曲线
// 水位
this.handleWaterLeve(station.getCode(),response);
// 今日,昨日发电量
this.powerDay(station,targetList,response);
@ -177,10 +182,56 @@ public class HydropowerServiceImpl implements HydropowerService {
response.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map));
// 设备信息
response.setDeviceList(this.getDevices(station,realList,targetList));
// 降雨
response.setPowerRains(this.getPowerRains(station,response.getDeviceList(),rains));
return response;
}
/**
* 站点发电降雨曲线
* @param devices
* @param rains
* @return
*/
private List<PowerRainVo> getPowerRains(StationEntity station,List<HydropowerUnitVo> devices, List<Map<String, Object>> rains) {
List<GenerationPowerVo> powers = new ArrayList<>();
if(CollectionUtil.isNotEmpty(devices)){
devices.forEach(device->{
if(ObjectUtil.isNotEmpty(device.getHydropowerPumpTargetVo()) && CollectionUtil.isNotEmpty(device.getHydropowerPumpTargetVo().getGenerationPowerVoList())){
powers.addAll(device.getHydropowerPumpTargetVo().getGenerationPowerVoList());
}
});
}
// 根据日期遍历
List<String> days = this.get30Day();
return days.stream().map(day->{
PowerRainVo powerRain = new PowerRainVo();
powerRain.setDate(day);
if(CollectionUtil.isEmpty(powers)){
powerRain.setGenerate(0.0);
}else{
powerRain.setGenerate(powers.stream().filter(o-> day.equals(o.getDate())).mapToDouble(GenerationPowerVo::getGenerate).sum());
}
if(CollectionUtil.isEmpty(rains)){
powerRain.setRain(0.0);
}else{
powerRain.setRain(rains.stream().mapToDouble(map->{
if (map.get("fx_date").equals(day)) {
Object object = map.get("precip");
if(ObjectUtil.isEmpty(object)){
return 0.0;
}else{
return Double.parseDouble(object.toString());
}
}
return 0.0;
}).sum());
}
return powerRain;
}).collect(Collectors.toList());
}
/**
* 容量利用率
* @param response
* @return
@ -326,6 +377,50 @@ public class HydropowerServiceImpl implements HydropowerService {
}
/**
* 获取30天
* @return
*/
private List<String> get30Day() {
List<String> times = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
Date end = calendar.getTime();
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND));
calendar.add(Calendar.DAY_OF_MONTH,-29);
Date start = calendar.getTime();
while (start.compareTo(end) < 0) {
times.add(DateUtil.format(calendar.getTime(),"yyyy-MM-dd"));
calendar.add(Calendar.DAY_OF_MONTH,1);
start = calendar.getTime();
}
return times;
}
/**
* 近30天降雨
* @param code
* @return
*/
private List<Map<String, Object>> get30DayRain(String code) {
Calendar calendar = Calendar.getInstance();
String endTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
String rainEnd = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND));
calendar.add(Calendar.DAY_OF_MONTH,-29);
String startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
String rainStart = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
R<List<Map<String, Object>>> rains = rainfallClient.getDurationRainFall(code,rainStart,rainEnd);
if(!rains.isSuccess() || CollectionUtil.isEmpty(rains.getData())){
return new ArrayList<>();
}
return rains.getData();
}
/**
* 获取设备装机容量
* @param list
* @param refDept
@ -472,7 +567,6 @@ public class HydropowerServiceImpl implements HydropowerService {
WaterLevelVo level = validList.get(0);
// 前池水位、当日水位曲线
response.setFrontWaterLevel(level.getFrontWaterLevel());
response.setFrontCurveMap(level.getFrontCurveMap());
}
/**

Loading…
Cancel
Save