Browse Source

#首页接口优化

zhongwei
yang_shj 3 months ago
parent
commit
3db26b39e6
  1. 18
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/constant/HydroelectricConstant.java
  2. 48
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaStationVo.java
  3. 70
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaVo.java
  4. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java
  5. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java
  6. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java
  7. 21
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateYearVo.java
  8. 45
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupAreaVo.java
  9. 70
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupVo.java
  10. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java
  11. 72
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java
  12. 22
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java
  13. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java
  14. 1
      hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamController.java
  15. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java
  16. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java
  17. 529
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java
  18. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

18
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/constant/HydroelectricConstant.java

@ -0,0 +1,18 @@
package com.hnac.hzims.operational.homePage.hydroelectric.constant;
/**
* 水电站首页-常量
* @author ysj
*/
public interface HydroelectricConstant {
/**
* 水电站
*/
Integer HYDROPOWER = 0;
/**
* 代运维
*/
Integer PROXY_OPEARIONAL = 2;
}

48
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaStationVo.java

@ -0,0 +1,48 @@
package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 集团/区域占比
* @author ysj
*/
@Data
public class HydroelectricAreaStationVo {
@ApiModelProperty(value = "站点机构")
private Long deptId;
@ApiModelProperty(value = "机构ID")
private String stationCode;
@ApiModelProperty(value = "机构名称")
private String stationName;
@ApiModelProperty(value = "站点实时温度")
private String temp;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "年发电量")
private Double generateYear;
@ApiModelProperty(value = "发电完成率")
private Double generateRate;
@ApiModelProperty(value = "电站利用率")
private Double deviceUse;
@ApiModelProperty(value = "容量利用率")
private Double capacityUse;
@ApiModelProperty(value = "区域/集团发电占比")
private Double areaMakeUp;
@ApiModelProperty(value = "排序")
private Integer sort;
}

70
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricAreaVo.java

@ -0,0 +1,70 @@
package com.hnac.hzims.operational.homePage.hydroelectric.vo;
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;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "水电站首页-区域")
public class HydroelectricAreaVo {
@ApiModelProperty(value = "机构Id")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "站点数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer count;
@ApiModelProperty(value = "总装机容量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@ApiModelProperty(value = "电站总负荷")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "容量利用率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacityRate;
@ApiModelProperty(value = "年发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateYear;
@ApiModelProperty(value = "月发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateMon;
@ApiModelProperty(value = "日发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateDay;
@ApiModelProperty(value = "今年计划发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generatePlanYear;
@ApiModelProperty(value = "电量完成吕")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateRate;
@ApiModelProperty(value = "近3年发电对比")
private List<HydroelectricGenerateYearVo> recentYears;
@ApiModelProperty(value = "计划完成完成趋势")
private List<HydroelectricGenerateMonVo> completes;
@ApiModelProperty(value = "电站 :利用情况 && 天气 && 排名")
private List<HydroelectricAreaStationVo> stations;
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java

@ -1,4 +1,4 @@
package com.hnac.hzims.operational.homePage.Hydroelectric.vo; package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer; import com.fasterxml.jackson.databind.ser.std.NullSerializer;

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java

@ -1,4 +1,4 @@
package com.hnac.hzims.operational.homePage.Hydroelectric.vo; package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java

@ -1,4 +1,4 @@
package com.hnac.hzims.operational.homePage.Hydroelectric.vo; package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -21,8 +21,8 @@ public class HydroelectricGenerateMonVo {
private String strMonth; private String strMonth;
@ApiModelProperty(value = "月发电量") @ApiModelProperty(value = "月发电量")
private Double power; private Double generate;
@ApiModelProperty(value = "计划发电量") @ApiModelProperty(value = "计划发电量")
private Double planPower; private Double planGenerate;
} }

21
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateYearVo.java

@ -0,0 +1,21 @@
package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "年发电对象")
public class HydroelectricGenerateYearVo {
@ApiModelProperty(value = "年份")
private Integer year;
@ApiModelProperty(value = "月发电量集合:由1-12月组合")
private List<HydroelectricGenerateMonVo> generateMons;
}

45
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupAreaVo.java

@ -0,0 +1,45 @@
package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 集团/区域占比
* @author ysj
*/
@Data
public class HydroelectricGroupAreaVo {
@ApiModelProperty(value = "站点机构")
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "站点实时温度")
private String temp;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "年发电量")
private Double generateYear;
@ApiModelProperty(value = "发电完成率")
private Double generateRate;
@ApiModelProperty(value = "电站利用率")
private Double deviceUse;
@ApiModelProperty(value = "容量利用率")
private Double capacityUse;
@ApiModelProperty(value = "区域/集团发电占比")
private Double areaMakeUp;
@ApiModelProperty(value = "排序")
private Integer sort;
}

70
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGroupVo.java

@ -0,0 +1,70 @@
package com.hnac.hzims.operational.homePage.hydroelectric.vo;
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;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "水电站首页-站点")
public class HydroelectricGroupVo {
@ApiModelProperty(value = "机构Id")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "站点数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer count;
@ApiModelProperty(value = "总装机容量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@ApiModelProperty(value = "电站总负荷")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "容量利用率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacityRate;
@ApiModelProperty(value = "年发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateYear;
@ApiModelProperty(value = "月发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateMon;
@ApiModelProperty(value = "日发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateDay;
@ApiModelProperty(value = "今年计划发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generatePlanYear;
@ApiModelProperty(value = "电量完成吕")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateRate;
@ApiModelProperty(value = "近3年发电对比")
private List<HydroelectricGenerateYearVo> recentYears;
@ApiModelProperty(value = "计划完成完成趋势")
private List<HydroelectricGenerateMonVo> completes;
@ApiModelProperty(value = "电站 :利用情况 && 天气 && 排名")
private List<HydroelectricGroupAreaVo> areas;
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java

@ -1,4 +1,4 @@
package com.hnac.hzims.operational.homePage.Hydroelectric.vo; package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;

72
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java

@ -0,0 +1,72 @@
package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "站点首页-设备信息")
public class HydroelectricDeviceVo {
@ApiModelProperty(value = "设备编号")
private String deivceCode;
@ApiModelProperty(value = "设备名称")
private String deivceName;
@ApiModelProperty(value = "开关机状态: 0 - 关机 1 - 开机")
private Boolean state;
@ApiModelProperty(value = "总装机容量")
private Double installedCapacity;
@ApiModelProperty(value = "有功功率")
private Double activePower;
@ApiModelProperty(value = "容量利用率")
private Double capacityRate;
@ApiModelProperty(value = "无功功率")
private Double reactivePower;
@ApiModelProperty(value = "导叶开度")
private Double guideOpen;
@ApiModelProperty(value = "今日发电量")
private Float powerDay;
@ApiModelProperty(value = "昨日发电量")
private Float powerYesterDay;
@ApiModelProperty(value = "当年发电量")
private Float powerYear;
@ApiModelProperty(value = "去年发电量")
private Float powerYesterYear;
@ApiModelProperty(value = "当月发电量")
private Float powerMon;
@ApiModelProperty(value = "本次开机时间")
private String startDownTime;
@ApiModelProperty(value = "本次开机时长")
private Double startupDownDuration;
@ApiModelProperty(value = "年停机时长")
private Double shutDownDurationYear;
@ApiModelProperty(value = "年开机时长")
private Double startupDurationYear;
@ApiModelProperty(value = "设备近24小时有功功率")
private List<HydroelectricDevicePowerVo> powers;
@ApiModelProperty(value = "设备近30日发电量")
private List<HydroelectricDeviceGenerateVo> generates;
}

22
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java

@ -0,0 +1,22 @@
package com.hnac.hzims.operational.homePage.hydroelectric.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "站点首页-最近30日发电量/降雨量")
public class HydroelectricPowerRainVo {
@ApiModelProperty(value = "日期")
private String date;
@ApiModelProperty(value = "发电量")
private Double generate;
@ApiModelProperty(value = "降雨")
private Double rain;
}

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

@ -1,7 +1,7 @@
package com.hnac.hzims.operational.main.vo; package com.hnac.hzims.operational.main.vo;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricPowerRainVo; import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricPowerRainVo;
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;

1
hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/controller/ParamController.java

@ -30,6 +30,7 @@ public class ParamController extends BladeController {
} }
@PostMapping("/distribute") @PostMapping("/distribute")
@ApiOperation("下发参数") @ApiOperation("下发参数")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public Result<Object> distribute(@RequestBody ParamDistributeDTO req) { public Result<Object> distribute(@RequestBody ParamDistributeDTO req) {

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java

@ -1,11 +1,12 @@
package com.hnac.hzims.operational.homePage.controller; package com.hnac.hzims.operational.homePage.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStationVo; import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricAreaVo;
import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricGroupVo;
import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricStationVo;
import com.hnac.hzims.operational.homePage.service.HydroelectricService; import com.hnac.hzims.operational.homePage.service.HydroelectricService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -32,4 +33,18 @@ public class HydroelectricController extends BladeController {
public R<HydroelectricStationVo> station(@RequestParam("deptId") Long deptId) { public R<HydroelectricStationVo> station(@RequestParam("deptId") Long deptId) {
return R.data(hydroelectricService.station(deptId)); return R.data(hydroelectricService.station(deptId));
} }
@ApiOperation("水电站区域指标")
@GetMapping("/area")
@ApiOperationSupport(order = 1)
public R<HydroelectricAreaVo> area(@RequestParam(value = "deptId") Long deptId) {
return R.data(hydroelectricService.area(deptId));
}
@ApiOperation("水电站集团指标")
@GetMapping("/group")
@ApiOperationSupport(order = 1)
public R<HydroelectricGroupVo> group() {
return R.data(hydroelectricService.group());
}
} }

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java

@ -1,6 +1,8 @@
package com.hnac.hzims.operational.homePage.service; package com.hnac.hzims.operational.homePage.service;
import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStationVo; import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricAreaVo;
import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricGroupVo;
import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricStationVo;
/** /**
* 水电站-首页接口 * 水电站-首页接口
@ -9,4 +11,8 @@ import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStation
public interface HydroelectricService { public interface HydroelectricService {
HydroelectricStationVo station(Long deptId); HydroelectricStationVo station(Long deptId);
HydroelectricAreaVo area(Long deptId);
HydroelectricGroupVo group();
} }

529
hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java

@ -1,14 +1,19 @@
package com.hnac.hzims.operational.homePage.service.impl; package com.hnac.hzims.operational.homePage.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.baomidou.mybatisplus.core.toolkit.Wrappers;
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.equipment.vo.PlanPowerYearVo;
import com.hnac.hzims.hzimsweather.feign.IRainfallClient; 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.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.operational.homePage.Hydroelectric.vo.*; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.operational.homePage.hydroelectric.constant.HydroelectricConstant;
import com.hnac.hzims.operational.homePage.hydroelectric.vo.*;
import com.hnac.hzims.operational.homePage.service.HydroelectricService; import com.hnac.hzims.operational.homePage.service.HydroelectricService;
import com.hnac.hzims.operational.main.service.IWeatherService; import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo;
@ -23,11 +28,15 @@ import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil; 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.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -40,11 +49,12 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class HydroelectricServiceImpl implements HydroelectricService { public class HydroelectricServiceImpl implements HydroelectricService {
private final IStationService stationService; private final IStationService stationService;
private final IWeatherService weatherService; private final IWeatherService weatherService;
private final ISysClient sysClient;
private final IRainfallClient rainClient; private final IRainfallClient rainClient;
private final IPlanGenertionClient planClient; private final IPlanGenertionClient planClient;
@ -97,8 +107,10 @@ public class HydroelectricServiceImpl implements HydroelectricService {
} }
// 设备 // 设备
if(CollectionUtil.isNotEmpty(devices)){ if(CollectionUtil.isNotEmpty(devices)){
result.setDevices(devices.stream().map(iter->{ result.setDevices(devices.stream().filter(device-> station.getRefDept().equals(device.getCreateDept())).map(iter->{
HydroelectricDeviceVo device = new HydroelectricDeviceVo(); HydroelectricDeviceVo device = new HydroelectricDeviceVo();
device.setDeivceCode(iter.getEmCode());
device.setDeivceName(iter.getName());
Optional<HydropowerUnitRealVo> real = reals.stream().filter(o-> iter.getEmCode().equals(o.getDeviceCode())).findFirst(); Optional<HydropowerUnitRealVo> real = reals.stream().filter(o-> iter.getEmCode().equals(o.getDeviceCode())).findFirst();
// 实时数据 // 实时数据
if(real.isPresent()){ if(real.isPresent()){
@ -145,13 +157,18 @@ public class HydroelectricServiceImpl implements HydroelectricService {
}else{ }else{
result.setCapacityRate(0.0); result.setCapacityRate(0.0);
} }
// 月计划发电量、月已发电量 // 月计划发电量、月已发电量、月完成率
if(CollectionUtil.isNotEmpty(plans)){ if(CollectionUtil.isNotEmpty(plans)){
result.setPowerMonPlan(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(new Date(),"yyyy-NM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum()); result.setPowerMonPlan(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum());
}else{ }else{
result.setPowerMonPlan(0.0); result.setPowerMonPlan(0.0);
} }
result.setPowerMon(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerMon).sum()); result.setPowerMon(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerMon).sum());
if(result.getPowerMonPlan() <= 0 || result.getPowerMon() <= 0){
result.setPowerRateMon(0.0);
}else{
result.setPowerRateMon(BigDecimal.valueOf(result.getPowerMon() / result.getPowerMonPlan() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
// 年计划发电量、年已发电量 // 年计划发电量、年已发电量
if(CollectionUtil.isNotEmpty(plans)){ if(CollectionUtil.isNotEmpty(plans)){
@ -160,6 +177,11 @@ public class HydroelectricServiceImpl implements HydroelectricService {
result.setPowerYearPlan(0.0); result.setPowerYearPlan(0.0);
} }
result.setPowerYear(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYear).sum()); result.setPowerYear(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYear).sum());
if(result.getPowerYearPlan() <= 0 || result.getPowerYear() <= 0){
result.setPowerRateYear(0.0);
}else{
result.setPowerRateYear(BigDecimal.valueOf(result.getPowerYear() / result.getPowerYearPlan() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
// 今日发电量、昨日发电量 // 今日发电量、昨日发电量
result.setPowerDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerDay).sum()); result.setPowerDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerDay).sum());
@ -174,6 +196,493 @@ public class HydroelectricServiceImpl implements HydroelectricService {
} }
/** /**
* 水电站区域指标
* @param deptId
* @return
*/
@Override
public HydroelectricAreaVo area(Long deptId) {
HydroelectricAreaVo area = new HydroelectricAreaVo();
// 区域下站点
List<StationEntity> stations = this.stationByArea(deptId);
if(CollectionUtil.isEmpty(stations)){
return area;
}
// 站点计划发电量数据
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,DateUtil.format(new Date(),"yyyy"));
// 机构名称
R<Dept> dept = sysClient.getDept(deptId);
if(dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())){
area.setDeptId(dept.getData().getId());
area.setDeptName(dept.getData().getDeptName());
}
List<Long> refDepts = stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
// 站点数量
area.setCount(stations.size());
// 实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_REAL_KEY);
if (CollectionUtil.isNotEmpty(reals)) {
List<HydropowerUnitRealVo> stationReals = reals.stream().filter(real -> refDepts.contains(real.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(stationReals)) {
// 容量
area.setCapacity(stationReals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum());
// 负荷
area.setLoad(reals.stream().mapToDouble(o->{
if("MW".equalsIgnoreCase(o.getPowerUnit())){
return o.getActivePower() * 1000;
}
return o.getActivePower();
}).sum());
// 容量利用率
if (area.getCapacity() <= 0 || area.getLoad() <= 0) {
area.setCapacityRate(0.0);
}else{
area.setCapacityRate(BigDecimal.valueOf(area.getLoad() / area.getCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}
}
// 指标数据
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_TARGET_KEY);
if (CollectionUtil.isNotEmpty(targets)) {
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(device -> refDepts.contains(device.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(targets)) {
// 年发电量
area.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
// 月发电量
area.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum());
// 日发电量
area.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum());
// 年计划发电量
area.setGeneratePlanYear(planClient.getPlanPowerYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), DateUtil.format(new Date(),"yyyy")));
if(area.getGeneratePlanYear() <= 0 || area.getGenerateYear() <= 0){
area.setGenerateRate(0.0);
}else{
area.setGenerateRate(BigDecimal.valueOf(area.getGenerateYear() / area.getGeneratePlanYear() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}
}
// 站点近年发电数据 key - id value - 月份,发电量
Map<String, Map<String, Float>> maps = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
// 近3年发电量
area.setRecentYears(this.recentYears(stations,maps));
// 发电量完成趋势
area.setCompletes(this.completes(stations,maps,plans));
// 站点综合信息
area.setStations(this.comprehensive(stations,plans,reals,targets));
return area;
}
/**
* 水电站集团指标
* @return
*/
@Override
public HydroelectricGroupVo group() {
HydroelectricGroupVo group = new HydroelectricGroupVo();
// 查询用户当前权限站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HydroelectricConstant.PROXY_OPEARIONAL)
.eq(StationEntity::getType,HydroelectricConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
return group;
}
// 查询用户权限机构
R<List<Dept>> currents = sysClient.getDeptByCurrentUser();
if(!currents.isSuccess() || CollectionUtil.isEmpty(currents.getData())){
return group;
}
// 区域机构
List<Dept> areas = currents.getData().stream().filter(o->o.getDeptCategory().equals(3)).collect(Collectors.toList());
if(CollectionUtil.isEmpty(areas)){
return group;
}
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,DateUtil.format(new Date(),"yyyy"));
// 机构名称
Optional<Dept> dept = currents.getData().stream().min(Comparator.comparing(Dept::getDeptCategory));
if(dept.isPresent()){
group.setDeptId(dept.get().getId());
group.setDeptName(dept.get().getDeptName());
}
List<Long> refDepts = stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
// 站点数量
group.setCount(stations.size());
// 实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_REAL_KEY);
if (CollectionUtil.isNotEmpty(reals)) {
List<HydropowerUnitRealVo> stationReals = reals.stream().filter(real -> refDepts.contains(real.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(stationReals)) {
// 容量
group.setCapacity(stationReals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum());
// 负荷
group.setLoad(reals.stream().mapToDouble(o->{
if("MW".equalsIgnoreCase(o.getPowerUnit())){
return o.getActivePower() * 1000;
}
return o.getActivePower();
}).sum());
// 容量利用率
if (group.getCapacity() <= 0 || group.getLoad() <= 0) {
group.setCapacityRate(0.0);
}else{
group.setCapacityRate(BigDecimal.valueOf(group.getLoad() / group.getCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}
}
// 指标数据
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_TARGET_KEY);
if (CollectionUtil.isNotEmpty(targets)) {
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(device -> refDepts.contains(device.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(targets)) {
// 年发电量
group.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
// 月发电量
group.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum());
// 日发电量
group.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum());
// 年计划发电量
group.setGeneratePlanYear(planClient.getPlanPowerYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), DateUtil.format(new Date(),"yyyy")));
if(group.getGeneratePlanYear() <= 0 || group.getGenerateYear() <= 0){
group.setGenerateRate(0.0);
}else{
group.setGenerateRate(BigDecimal.valueOf(group.getGenerateYear() / group.getGeneratePlanYear() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}
}
// 站点近年发电数据 key - id value - 月份,发电量
Map<String, Map<String, Float>> maps = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
// 近3年发电量
group.setRecentYears(this.recentYears(stations,maps));
// 发电量完成趋势
group.setCompletes(this.completes(stations,maps,plans));
// 区域综合信息
Map<Dept,List<StationEntity>> groupArea = areas.stream().collect(Collectors.toMap(obj -> obj, obj -> {
List<Dept> groups = currents.getData().stream().filter(o->o.getParentId().equals(obj.getId())).collect(Collectors.toList());
return stations.stream().filter(station -> groups.stream().map(Dept::getId).collect(Collectors.toList()).contains(station.getRefDept())).collect(Collectors.toList());
}));
group.setAreas(this.comprehensiveArea(groupArea,plans,reals,targets));
return group;
}
/**
* 区域综合信息
* @param areas
* @param plans
* @param reals
* @param targets
* @return
*/
private List<HydroelectricGroupAreaVo> comprehensiveArea(Map<Dept,List<StationEntity>> areas, List<PlanGenerationEntity> plans, List<HydropowerUnitRealVo> reals, List<HydropowerUnitTargetVo> targets) {
// 站点 : 利用情况 && 天气 && 排名
List<String> codes = areas.values().stream().filter(CollectionUtil::isNotEmpty).map(values -> values.get(0).getCode()).collect(Collectors.toList());
// 获取站点实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(codes);
// 获取站点7日天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather(codes);
// 计划发电量
List<HydroelectricGroupAreaVo> result = areas.entrySet().stream().filter(entry->CollectionUtil.isNotEmpty(entry.getValue())).map(itr->{
HydroelectricGroupAreaVo groupArea = new HydroelectricGroupAreaVo();
groupArea.setDeptId(itr.getKey().getId());
groupArea.setDeptName(itr.getKey().getDeptName());
// 站点温度、近7日天气
groupArea.setTemp(this.stationTemp(nowWeather,itr.getValue().get(0).getCode()));
groupArea.setWeather(this.stationWeather(weekWeather,itr.getValue().get(0).getCode()));
List<Long> refDepts = itr.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList());
List<String> stationCodes = itr.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList());
// 指标数据: 发电量完成率
if(CollectionUtil.isNotEmpty(targets)){
// 当年发电量
groupArea.setGenerateYear(targets.stream().filter(target-> refDepts.contains(target.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
if(CollectionUtil.isNotEmpty(plans)){
// 当年计划发电量
double generatePlan = plans.stream().filter(plan-> stationCodes.contains(plan.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
if(groupArea.getGenerateYear() <= 0 || generatePlan <= 0.0){
groupArea.setGenerateRate(0.0);
}else{
groupArea.setGenerateRate(BigDecimal.valueOf(groupArea.getGenerateYear() / generatePlan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}else{
groupArea.setGenerateRate(0.0);
}
}
// 实时数据: 容量利用率、电站利用率
if(CollectionUtil.isNotEmpty(reals)){
// 实时功率
double use = reals.stream().filter(real-> refDepts.contains(real.getDeptId())).mapToDouble(o->{
if("MW".equalsIgnoreCase(o.getPowerUnit())){
return o.getActivePower() * 1000;
}
return o.getActivePower();
}).sum();
if(CollectionUtil.isNotEmpty(plans)){
// 装机容量
double capacity = reals.stream().filter(real-> refDepts.contains(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum();
if(Math.abs(capacity) > 0){
groupArea.setCapacityUse(BigDecimal.valueOf(use / capacity * 100).setScale(1, RoundingMode.HALF_UP).doubleValue());
}else{
groupArea.setCapacityUse(0.0);
}
}else{
groupArea.setCapacityUse(0.0);
}
// 开机数量
long on = reals.stream().filter(real -> refDepts.contains(real.getDeptId()) && real.getState()).count();
long sum = reals.stream().filter(real-> refDepts.contains(real.getDeptId())).count();
if(sum > 0){
groupArea.setDeviceUse(BigDecimal.valueOf(on / (double)sum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
groupArea.setDeviceUse(0.0);
}
}
return groupArea;
}).collect(Collectors.toList());
double generateSum = result.stream().mapToDouble(HydroelectricGroupAreaVo::getGenerateYear).sum();
// 返回结果集
if(generateSum <= 0){
return result.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.getGenerateRate()) > 0)
.sorted(Comparator.comparing(HydroelectricGroupAreaVo::getGenerateYear).reversed()).collect(Collectors.toList());
}
return result.stream().peek(scale-> scale.setAreaMakeUp(BigDecimal.valueOf(scale.getGenerateYear() / generateSum * 100).setScale(1, RoundingMode.HALF_UP).doubleValue())).
filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0
|| Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerateRate()) > 0)
.sorted(Comparator.comparing(HydroelectricGroupAreaVo::getGenerateYear).reversed()).collect(Collectors.toList());
}
/**
* 区域近3年发电量
* @param stations
* @return
*/
private List<HydroelectricGenerateYearVo> recentYears(List<StationEntity> stations, Map<String, Map<String, Float>> maps) {
// 过滤站点发电量数据
List<Map<String, Float>> generates = maps.entrySet().stream().filter(entry -> stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(entry.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
// 根据月份分组
List<HydroelectricGenerateMonVo> generateMons = new ArrayList<>();
if(CollectionUtil.isNotEmpty(generates)){
generates.forEach(item -> item.forEach((key, value) -> {
HydroelectricGenerateMonVo generateMon = new HydroelectricGenerateMonVo();
generateMon.setStrMonth(key);
generateMon.setGenerate(Double.valueOf(value));
generateMons.add(generateMon);
}));
}
// 月份发电量数据整合
List<String> mons = this.mons(2,12,false);
List<HydroelectricGenerateMonVo> integrations = mons.stream().map(mon->{
HydroelectricGenerateMonVo integration = new HydroelectricGenerateMonVo();
integration.setStrMonth(mon);
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
integration.setYear(localDate.getYear());
integration.setMonth(localDate.getMonthValue());
integration.setGenerate(generateMons.stream().filter(o->o.getStrMonth().equals(mon)).mapToDouble(HydroelectricGenerateMonVo::getGenerate).sum());
return integration;
}).collect(Collectors.toList());
// 根据年份分组
Map<Integer, List<HydroelectricGenerateMonVo>> year = integrations.stream().collect(Collectors.groupingBy(HydroelectricGenerateMonVo::getYear));
// 返回结果集
return year.entrySet().stream().map(entry -> {
HydroelectricGenerateYearVo generateYear = new HydroelectricGenerateYearVo();
generateYear.setYear(entry.getKey());
List<HydroelectricGenerateMonVo> sortValue = entry.getValue().stream().sorted(Comparator.comparing(HydroelectricGenerateMonVo::getMonth)).collect(Collectors.toList());
generateYear.setGenerateMons(sortValue);
return generateYear;
}).collect(Collectors.toList());
}
/**
* 计划完成完成趋势
* @param stations
* @param maps
* @param plans
* @return
*/
private List<HydroelectricGenerateMonVo> completes(List<StationEntity> stations, Map<String, Map<String, Float>> maps, List<PlanGenerationEntity> plans) {
// 获取月份集合
List<String> monList = this.mons(0,12,false);
return monList.stream().map(o->{
HydroelectricGenerateMonVo generate = new HydroelectricGenerateMonVo();
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), o), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
generate.setStrMonth(o);
generate.setYear(localDate.getYear());
generate.setMonth(localDate.getMonthValue());
// 实际发电量
if(CollectionUtil.isEmpty(maps)){
generate.setGenerate(0.0);
}else{
generate.setGenerate(maps.entrySet().stream().
filter(entry->stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(entry.getKey())).
mapToDouble(valueMap-> valueMap.getValue().entrySet().stream().filter(entry->entry.getKey().equals(o))
.mapToDouble(Map.Entry::getValue).sum()).sum());
}
// 计划发电量
if(CollectionUtil.isEmpty(plans)){
generate.setPlanGenerate(0.0);
}else{
String mon = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM"));
generate.setPlanGenerate(plans.stream().filter(plan->mon.equals(plan.getDateTime())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
}
return generate;
}).collect(Collectors.toList());
}
/**
* 站点综合信息
* @param reals
* @param targets
* @return
*/
private List<HydroelectricAreaStationVo> comprehensive(List<StationEntity> stations, List<PlanGenerationEntity> plans , List<HydropowerUnitRealVo> reals, List<HydropowerUnitTargetVo> targets) {
// 站点 : 利用情况 && 天气 && 排名
List<String> codes = stations.stream().map(StationEntity::getCode).collect(Collectors.toList());
// 获取站点实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(codes);
// 获取站点7日天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather(codes);
// 计划发电量
List<HydroelectricAreaStationVo> result = stations.stream().map(itr->{
HydroelectricAreaStationVo station = new HydroelectricAreaStationVo();
station.setDeptId(itr.getRefDept());
station.setStationCode(itr.getCode());
station.setStationName(itr.getName());
// 站点温度、近7日天气
station.setTemp(this.stationTemp(nowWeather,itr.getCode()));
station.setWeather(this.stationWeather(weekWeather,itr.getCode()));
// 指标数据: 发电量完成率
if(CollectionUtil.isNotEmpty(targets)){
// 当年发电量
station.setGenerateYear(targets.stream().filter(target-> itr.getRefDept().equals(target.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
if(CollectionUtil.isNotEmpty(plans)){
// 当年计划发电量
double generatePlan = plans.stream().filter(plan-> itr.getCode().equals(plan.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
if(station.getGenerateYear() <= 0 || generatePlan <= 0.0){
station.setGenerateRate(0.0);
}else{
station.setGenerateRate(BigDecimal.valueOf(station.getGenerateYear() / generatePlan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}else{
station.setGenerateRate(0.0);
}
}
// 实时数据: 容量利用率、电站利用率
if(CollectionUtil.isNotEmpty(reals)){
// 实时功率
double use = reals.stream().filter(real-> itr.getRefDept().equals(real.getDeptId())).mapToDouble(o->{
if("MW".equalsIgnoreCase(o.getPowerUnit())){
return o.getActivePower() * 1000;
}
return o.getActivePower();
}).sum();
if(CollectionUtil.isNotEmpty(plans)){
// 装机容量
double capacity = reals.stream().filter(real-> itr.getRefDept().equals(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum();
if(Math.abs(capacity) > 0){
station.setCapacityUse(BigDecimal.valueOf(use / capacity * 100).setScale(1, RoundingMode.HALF_UP).doubleValue());
}else{
station.setCapacityUse(0.0);
}
}else{
station.setCapacityUse(0.0);
}
// 开机数量
long on = reals.stream().filter(real -> itr.getRefDept().equals(real.getDeptId()) && real.getState()).count();
long sum = reals.stream().filter(real-> itr.getRefDept().equals(real.getDeptId())).count();
if(sum > 0){
station.setDeviceUse(BigDecimal.valueOf(on / (double)sum * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
station.setDeviceUse(0.0);
}
}
return station;
}).collect(Collectors.toList());
double generateSum = result.stream().mapToDouble(HydroelectricAreaStationVo::getGenerateYear).sum();
// 返回结果集
if(generateSum <= 0){
return result.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.getGenerateRate()) > 0)
.sorted(Comparator.comparing(HydroelectricAreaStationVo::getGenerateYear).reversed()).collect(Collectors.toList());
}
return result.stream().peek(scale-> scale.setAreaMakeUp(BigDecimal.valueOf(scale.getGenerateYear() / generateSum * 100).setScale(1, RoundingMode.HALF_UP).doubleValue())).
filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0
|| Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerateRate()) > 0)
.sorted(Comparator.comparing(HydroelectricAreaStationVo::getGenerateYear).reversed()).collect(Collectors.toList());
}
/**
* 温度
* @param nowWeather
* @param code
*/
private String stationTemp(Map<String, HeWeatherWeatherNowResponse> nowWeather, String code) {
// 实时天气
if(MapUtils.isNotEmpty(nowWeather) && nowWeather.containsKey(code)){
HeWeatherWeatherNowResponse nowData = nowWeather.get(code);
if(ObjectUtil.isNotEmpty(nowData.getNow())){
return nowData.getNow().getTemp();
}
}
return "21";
}
// 站点七日内天气
private List<Daily> stationWeather(Map<String, HeWeatherWeatherDailyResponse> weekWeather, String code) {
// 实时天气
if(MapUtils.isNotEmpty(weekWeather) && weekWeather.containsKey(code)){
HeWeatherWeatherDailyResponse weekData = weekWeather.get(code);
return weekData.getDaily();
}
return new ArrayList<>();
}
/**
* 区域下站点
* @param deptId
* @return
*/
private List<StationEntity> stationByArea(Long deptId) {
// 用户权限机构
R<List<Dept>> depts = sysClient.getDeptByCurrentUser();
if(!depts.isSuccess() || CollectionUtil.isEmpty(depts.getData())){
return new ArrayList<>();
}
List<Long> deptIds = depts.getData().stream().filter(dept->dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList());
if (CollectionUtil.isEmpty(deptIds)) {
return new ArrayList<>();
}
return stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getType, HydroelectricConstant.HYDROPOWER)
.eq(StationEntity::getServeType,HydroelectricConstant.PROXY_OPEARIONAL)
.in(StationEntity::getRefDept,deptIds)
);
}
/**
* 站点近30天降雨数据 * 站点近30天降雨数据
* @param station * @param station
* @return * @return
@ -209,7 +718,7 @@ public class HydroelectricServiceImpl implements HydroelectricService {
* @param devices * @param devices
* @return * @return
*/ */
private List<HydroelectricPowerRainVo> stationPowerRains(List<HydroelectricDeviceVo> devices,List<Map<String, Object>> rains) { private List<HydroelectricPowerRainVo> stationPowerRains(List<HydroelectricDeviceVo> devices, List<Map<String, Object>> rains) {
List<HydroelectricDeviceGenerateVo> generates = new ArrayList<>(); List<HydroelectricDeviceGenerateVo> generates = new ArrayList<>();
devices.forEach(device->{ devices.forEach(device->{
generates.addAll(device.getGenerates()); generates.addAll(device.getGenerates());
@ -269,15 +778,15 @@ public class HydroelectricServiceImpl implements HydroelectricService {
generateMon.setMonth(date.getMonth() + 1); generateMon.setMonth(date.getMonth() + 1);
// 计划发电量 // 计划发电量
if(CollectionUtil.isNotEmpty(plans)){ if(CollectionUtil.isNotEmpty(plans)){
generateMon.setPlanPower(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(date,"yyyy-MM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum()); generateMon.setPlanGenerate(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(date,"yyyy-MM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum());
}else{ }else{
generateMon.setPlanPower(0.0); generateMon.setPlanGenerate(0.0);
} }
// 实际发电 // 实际发电
if(MapUtils.isNotEmpty(map)){ if(MapUtils.isNotEmpty(map)){
generateMon.setPower(map.entrySet().stream().filter(entry->entry.getKey().equals(mon)).mapToDouble(Map.Entry::getValue).sum()); generateMon.setGenerate(map.entrySet().stream().filter(entry->entry.getKey().equals(mon)).mapToDouble(Map.Entry::getValue).sum());
}else{ }else{
generateMon.setPlanPower(0.0); generateMon.setGenerate(0.0);
} }
return generateMon; return generateMon;
}).collect(Collectors.toList()); }).collect(Collectors.toList());

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

@ -18,7 +18,7 @@ import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo; import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo;
import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricPowerRainVo; import com.hnac.hzims.operational.homePage.hydroelectric.vo.HydroelectricPowerRainVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.entity.UserDeptEntity; import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.service.*;

Loading…
Cancel
Save