Browse Source

Merge branch 'prod-5.1.3' of http://175.6.40.68:8081/Jone/hzims-back into prod-5.1.3

zhongwei
liwen 4 months ago
parent
commit
c40da0adc2
  1. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java
  2. 22
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java
  3. 72
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceVo.java
  4. 28
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java
  5. 22
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricPowerRainVo.java
  6. 68
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java
  7. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/wind/vo/RainMon.java
  8. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java
  9. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/pv/PowerRainVo.java
  10. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java
  11. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java
  12. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  13. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  14. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/StorageServiceImpl.java
  15. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java
  16. 35
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java
  17. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java
  18. 316
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java
  19. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  20. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java

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

@ -0,0 +1,26 @@
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;
/**
* @author ysj
*/
@Data
@ApiModel(value = "站点首页-设备近30天发电量")
public class HydroelectricDeviceGenerateVo {
@ApiModelProperty(value = "日期")
private String date;
@ApiModelProperty(value = "发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float generate;
@ApiModelProperty(value = "功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float load;
}

22
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.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 = "站点首页-设备近24小时功率曲线")
public class HydroelectricDevicePowerVo {
@ApiModelProperty(value = "字符串时间")
private String strHour;
@ApiModelProperty(value = "小时")
private Integer hour;
@ApiModelProperty(value = "有功功率")
private String activePower;
}

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;
}

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

@ -0,0 +1,28 @@
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 = "月发电对象")
public class HydroelectricGenerateMonVo {
@ApiModelProperty(value = "年份")
private Integer year;
@ApiModelProperty(value = "月份")
private Integer month;
@ApiModelProperty(value = "字符串格式月份")
private String strMonth;
@ApiModelProperty(value = "月发电量")
private Double power;
@ApiModelProperty(value = "计划发电量")
private Double planPower;
}

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;
}

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

@ -0,0 +1,68 @@
package com.hnac.hzims.operational.homePage.Hydroelectric.vo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "水电站首页-站点")
public class HydroelectricStationVo {
@ApiModelProperty(value = "站点编号")
private String stationCode;
@ApiModelProperty(value = "站点名称")
private String stationName;
@ApiModelProperty(value = "总装机容量")
private Double installedCapacity;
@ApiModelProperty(value = "总发电负荷")
private Double powerSum;
@ApiModelProperty(value = "容量利用率")
private Double capacityRate;
@ApiModelProperty(value = "月计划发电量")
private Double powerMonPlan;
@ApiModelProperty(value = "月发电量")
private Double powerMon;
@ApiModelProperty(value = "月发电量完成率")
private Double powerRateMon;
@ApiModelProperty(value = "年计划发电量")
private Double powerYearPlan;
@ApiModelProperty(value = "年发电量")
private Double powerYear;
@ApiModelProperty(value = "年发电完成率")
private Double powerRateYear;
@ApiModelProperty(value = "今日发电量")
private Double powerDay;
@ApiModelProperty(value = "昨日发电量")
private Double powerYesterDay;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "设备集合")
private List<HydroelectricDeviceVo> devices;
@ApiModelProperty(value = "降雨/发电量曲线")
private List<HydroelectricPowerRainVo> powerRains;
@ApiModelProperty(value = "降雨/发电量曲线")
private List<HydroelectricGenerateMonVo> generateMons;
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java → hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/wind/vo/RainMon.java

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

4
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.main.vo.pv.PowerRainVo; 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;
@ -80,7 +80,7 @@ public class HydropowerStationVo {
private List<Daily> weather; private List<Daily> weather;
@ApiModelProperty(value = "降雨/发电量曲线") @ApiModelProperty(value = "降雨/发电量曲线")
private List<PowerRainVo> powerRains; private List<HydroelectricPowerRainVo> powerRains;
@ApiModelProperty(value = "前水位曲线数据") @ApiModelProperty(value = "前水位曲线数据")
private Map<Integer,String> frontCurveMap; private Map<Integer,String> frontCurveMap;

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

@ -1,26 +0,0 @@
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;
}

4
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java

@ -24,8 +24,4 @@ public class ScheduledApplication {
BladeApplication.run("hzims-scheduled", ScheduledApplication.class, args); BladeApplication.run("hzims-scheduled", ScheduledApplication.class, args);
} }
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled", ScheduledApplication.class);
// }
} }

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

@ -75,10 +75,9 @@ public class GenerationScheduledTask {
* @param param * @param param
* @return * @return
*/ */
//@XxlJob(LOAD_THREE_YEAR_POWER_GENERATION) @XxlJob(LOAD_THREE_YEAR_POWER_GENERATION)
@Scheduled(cron = "0/40 * * * * ? ") //@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadThreeYearPowerGeneration() { public ReturnT<String> loadThreeYearPowerGeneration(String param) {
String param = "";
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM"); param = DateUtil.format(new Date(), "yyyy-MM");
} }

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

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

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

@ -13,7 +13,7 @@ import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient; import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient;
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo;
import com.hnac.hzims.operational.fill.entity.RainfallEntity; import com.hnac.hzims.operational.fill.entity.RainfallEntity;
import com.hnac.hzims.operational.home.wind.RainMon; import com.hnac.hzims.operational.homePage.wind.vo.RainMon;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.StationConstants; import com.hnac.hzims.operational.station.StationConstants;
@ -1488,7 +1488,7 @@ public class RealTargetServiceImpl implements RealTargetService {
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.DAY_OF_MONTH,-1); calendar.add(Calendar.DAY_OF_MONTH,-1);
// 开始日期 // 开始日期
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; String start = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH") + ":00:00";
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); List<AnalyseDataTaosVO> records = dataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD);
if (CollectionUtil.isEmpty(records)) { if (CollectionUtil.isEmpty(records)) {
return new ArrayList<>(); return new ArrayList<>();

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/StorageServiceImpl.java

@ -69,11 +69,12 @@ public class StorageServiceImpl extends ServiceImpl<StorageMapper, StorageEntity
StorageEntity history = this.getOne(new LambdaQueryWrapper<StorageEntity>(){{ StorageEntity history = this.getOne(new LambdaQueryWrapper<StorageEntity>(){{
eq(StorageEntity::getStationCode, entity.getStationCode()); eq(StorageEntity::getStationCode, entity.getStationCode());
eq(StorageEntity::getFillDate,entity.getFillDate()); eq(StorageEntity::getFillDate,entity.getFillDate());
ne(ObjectUtil.isNotEmpty(entity.getId()),StorageEntity::getId,entity.getId());
}}); }});
if(ObjectUtil.isNotEmpty(history) && (ObjectUtil.isEmpty(entity.getId()) || !entity.getId().equals(history.getId()))){ if(ObjectUtil.isNotEmpty(history)){
throw new ServiceException("日期已经存在填报数据!"); throw new ServiceException("日期已经存在填报数据!");
} }
if(ObjectUtil.isEmpty(history)){ if(ObjectUtil.isEmpty(history) && ObjectUtil.isEmpty(entity.getId())){
return this.save(entity); return this.save(entity);
} }
return this.updateById(entity); return this.updateById(entity);

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.operational.fill.entity.StorageEntity;
import com.hnac.hzims.operational.fill.entity.UseEntity; import com.hnac.hzims.operational.fill.entity.UseEntity;
import com.hnac.hzims.operational.fill.mapper.UseMapper; import com.hnac.hzims.operational.fill.mapper.UseMapper;
import com.hnac.hzims.operational.fill.service.UseService; import com.hnac.hzims.operational.fill.service.UseService;
@ -97,11 +98,12 @@ public class UseServiceImpl extends ServiceImpl<UseMapper, UseEntity> implements
UseEntity history = this.getOne(new LambdaQueryWrapper<UseEntity>(){{ UseEntity history = this.getOne(new LambdaQueryWrapper<UseEntity>(){{
eq(UseEntity::getStationCode, entity.getStationCode()); eq(UseEntity::getStationCode, entity.getStationCode());
eq(UseEntity::getFillDate,entity.getFillDate()); eq(UseEntity::getFillDate,entity.getFillDate());
ne(ObjectUtil.isNotEmpty(entity.getId()), UseEntity::getId,entity.getId());
}}); }});
if(ObjectUtil.isNotEmpty(history) && (ObjectUtil.isEmpty(entity.getId()) || !entity.getId().equals(history.getId()))){ if(ObjectUtil.isNotEmpty(history)){
throw new ServiceException("日期已经存在填报数据!"); throw new ServiceException("日期已经存在填报数据!");
} }
if(ObjectUtil.isEmpty(history)){ if(ObjectUtil.isEmpty(history) && ObjectUtil.isEmpty(entity.getId())){
return this.save(entity); return this.save(entity);
} }
return this.updateById(entity); return this.updateById(entity);

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

@ -0,0 +1,35 @@
package com.hnac.hzims.operational.homePage.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStationVo;
import com.hnac.hzims.operational.homePage.service.HydroelectricService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ysj
*/
@RestController
@RequestMapping("/hydroelectric")
@Api(value = "水电站-首页", tags = "水电站-首页")
@AllArgsConstructor
public class HydroelectricController extends BladeController {
private final HydroelectricService hydroelectricService;
@ApiOperation("水电站站点指标")
@GetMapping("/station")
@ApiOperationSupport(order = 1)
public R<HydroelectricStationVo> station(@RequestParam("deptId") Long deptId) {
return R.data(hydroelectricService.station(deptId));
}
}

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

@ -0,0 +1,12 @@
package com.hnac.hzims.operational.homePage.service;
import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStationVo;
/**
* 水电站-首页接口
* @author ysj
*/
public interface HydroelectricService {
HydroelectricStationVo station(Long deptId);
}

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

@ -0,0 +1,316 @@
package com.hnac.hzims.operational.homePage.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.equipment.vo.PlanPowerYearVo;
import com.hnac.hzims.hzimsweather.feign.IRainfallClient;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.operational.homePage.Hydroelectric.vo.*;
import com.hnac.hzims.operational.homePage.service.HydroelectricService;
import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo;
import com.hnac.hzims.operational.main.vo.HydropowerUnitTargetVo;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
/**
* 水电站-首页接口实现类
* @author ysj
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class HydroelectricServiceImpl implements HydroelectricService {
private final IStationService stationService;
private final IWeatherService weatherService;
private final IRainfallClient rainClient;
private final IPlanGenertionClient planClient;
private final RedisTemplate redisTemplate;
private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data";
private final static String LOAD_HYDROPOWER_REAL_KEY = "hzims:operation:loadhydropowerunit:real:key";
private final static String LOAD_HYDROPOWER_TARGET_KEY = "hzims:operation:loadhydropowerunit:target:key";
private final static String DEVICE_CACHE_COFIG_FINAL = "hzims:equipment:emInfo:deviceCode.emInfoList";
/**
* 水电站首页-站点首页
* @param deptId
* @return
*/
@Override
public HydroelectricStationVo station(Long deptId) {
// 步骤1.查询站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getRefDept,deptId));
if(ObjectUtil.isEmpty(station)){
return new HydroelectricStationVo();
}
// 步骤2.数据准备
// 设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(DEVICE_CACHE_COFIG_FINAL).toString(),new TypeReference<List<EminfoAndEmParamVo>>() {});
// 实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_REAL_KEY);
// 指标数据
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_TARGET_KEY);
// 降雨数据
List<Map<String, Object>> rains = this.nearThirtyRains(station.getCode());
// 七日天气
Map<String, HeWeatherWeatherDailyResponse> weathers = this.weekWeather(Collections.singletonList(station.getCode()));
// 近3年发电量
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
// 计划发电量
List<PlanPowerYearVo> plans = planClient.getPlanPowerByYear(station.getCode(), Integer.parseInt(DateUtil.format(new Date(),"yyyy")));
// 步骤3.数据处理、赋值
HydroelectricStationVo result = new HydroelectricStationVo();
result.setStationCode(station.getCode());
result.setStationName(station.getName());
// 天气
if(MapUtils.isNotEmpty(weathers) && weathers.containsKey(station.getCode())){
HeWeatherWeatherDailyResponse week = weathers.get(station.getCode());
if(ObjectUtil.isNotEmpty(week) && CollectionUtil.isNotEmpty(week.getDaily())){
result.setWeather(week.getDaily());
}
}
// 设备
if(CollectionUtil.isNotEmpty(devices)){
result.setDevices(devices.stream().map(iter->{
HydroelectricDeviceVo device = new HydroelectricDeviceVo();
Optional<HydropowerUnitRealVo> real = reals.stream().filter(o-> iter.getEmCode().equals(o.getDeviceCode())).findFirst();
// 实时数据
if(real.isPresent()){
device.setState(real.get().getState());
device.setInstalledCapacity(real.get().getInstalledCapacity());
device.setActivePower(real.get().getActivePower());
device.setReactivePower(real.get().getReactivePower());
device.setGuideOpen(real.get().getGuideOpen());
if(device.getActivePower() > 0 && device.getReactivePower() > 0){
device.setCapacityRate(BigDecimal.valueOf(device.getActivePower() / device.getInstalledCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
device.setCapacityRate(0.0);
}
}
// 指标数据
Optional<HydropowerUnitTargetVo> target = targets.stream().filter(o-> iter.getEmCode().equals(o.getDeviceCode())).findFirst();
if(target.isPresent()){
device.setPowerDay(target.get().getPowerDay());
device.setPowerYesterDay(target.get().getPowerYesterDay());
device.setPowerYear(target.get().getPowerYear());
device.setPowerYesterYear(target.get().getPowerYesterYear());
device.setPowerMon(target.get().getPowerMon());
device.setStartDownTime(target.get().getStartDownTime());
device.setStartupDownDuration(target.get().getStartupDownDuration());
device.setStartupDurationYear(target.get().getStartupDurationYear());
device.setShutDownDurationYear(target.get().getShutDownDurationYear());
if(CollectionUtil.isNotEmpty(target.get().getActivePowerVoList())){
device.setPowers(target.get().getActivePowerVoList().stream().map(o-> BeanUtil.copy(o, HydroelectricDevicePowerVo.class)).collect(Collectors.toList()));
}
if(CollectionUtil.isNotEmpty(target.get().getActivePowerVoList())){
device.setGenerates(target.get().getGenerationPowerVoList().stream().map(o-> BeanUtil.copy(o, HydroelectricDeviceGenerateVo.class)).collect(Collectors.toList()));
}
}
return device;
}).collect(Collectors.toList()));
}
// 站点指标数据
if(CollectionUtil.isNotEmpty(result.getDevices())){
// 装机容量、发电负荷
result.setInstalledCapacity(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getInstalledCapacity).sum());
result.setPowerSum(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getActivePower).sum());
if(result.getInstalledCapacity() > 0 && result.getPowerSum() > 0 ){
result.setCapacityRate(BigDecimal.valueOf(result.getPowerSum() / result.getInstalledCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
result.setCapacityRate(0.0);
}
// 月计划发电量、月已发电量
if(CollectionUtil.isNotEmpty(plans)){
result.setPowerMonPlan(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(new Date(),"yyyy-NM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum());
}else{
result.setPowerMonPlan(0.0);
}
result.setPowerMon(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerMon).sum());
// 年计划发电量、年已发电量
if(CollectionUtil.isNotEmpty(plans)){
result.setPowerYearPlan(plans.stream().mapToDouble(PlanPowerYearVo::getPlanPower).sum());
}else{
result.setPowerYearPlan(0.0);
}
result.setPowerYear(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYear).sum());
// 今日发电量、昨日发电量
result.setPowerDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerDay).sum());
result.setPowerYesterDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYesterDay).sum());
// 近30日降雨量/发电量
result.setPowerRains(this.stationPowerRains(result.getDevices(),rains));
// 电站月发电/计划发电
result.setGenerateMons(this.stationGenerateMons(plans,map.get(station.getCode())));
}
return result;
}
/**
* 站点近30天降雨数据
* @param station
* @return
*/
private List<Map<String, Object>> nearThirtyRains(String station) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
calendar.add(Calendar.DAY_OF_MONTH,-29);
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
R<List<Map<String, Object>>> rains = rainClient.getDurationRainFall(station,start,end);
if(!rains.isSuccess() || CollectionUtil.isEmpty(rains.getData())){
return new ArrayList<>();
}
return rains.getData();
}
/**
* 站点七天天气
* @param stations
*/
private Map<String, HeWeatherWeatherDailyResponse> weekWeather(List stations) {
if(CollectionUtil.isEmpty(stations)){
return new HashMap<>();
}
// 实时天气
return weatherService.getWeekWeather(stations);
}
/**
* 站点近30天降雨量/发电量
* @param devices
* @return
*/
private List<HydroelectricPowerRainVo> stationPowerRains(List<HydroelectricDeviceVo> devices,List<Map<String, Object>> rains) {
List<HydroelectricDeviceGenerateVo> generates = new ArrayList<>();
devices.forEach(device->{
generates.addAll(device.getGenerates());
});
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-1);
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();
List<HydroelectricPowerRainVo> powerRains = new ArrayList<>();
while (start.compareTo(end) < 0) {
HydroelectricPowerRainVo powerRain = new HydroelectricPowerRainVo();
// 日期
powerRain.setDate(DateUtil.format(calendar.getTime(),"yyyy-MM-dd"));
// 发电量
powerRain.setGenerate(generates.stream().filter(o-> powerRain.getDate().equals(o.getDate())).mapToDouble(HydroelectricDeviceGenerateVo::getGenerate).sum());
// 降雨量
if(CollectionUtil.isNotEmpty(rains)){
powerRain.setRain(rains.stream().mapToDouble(map->{
if (map.get("fx_date").equals(powerRain.getDate())) {
Object object = map.get("precip");
if(ObjectUtil.isEmpty(object)){
return 0.0;
}else{
return Double.parseDouble(object.toString());
}
}
return 0.0;
}).sum());
}else{
powerRain.setRain(0.0);
}
powerRains.add(powerRain);
calendar.add(Calendar.DAY_OF_MONTH,1);
start = calendar.getTime();
}
return powerRains;
}
/**
* 站点电站月发电/计划发电
* @param plans
* @param map
* @return
*/
private List<HydroelectricGenerateMonVo> stationGenerateMons(List<PlanPowerYearVo> plans, Map<String, Float> map) {
// 获取月份集合
List<String> mons = this.mons(0,12,false);
return mons.stream().map(mon->{
Date date = DateUtil.parse(mon,DateUtil.PATTERN_DATE);
HydroelectricGenerateMonVo generateMon = new HydroelectricGenerateMonVo();
generateMon.setStrMonth(mon);
generateMon.setYear(date.getYear());
generateMon.setMonth(date.getMonth() + 1);
// 计划发电量
if(CollectionUtil.isNotEmpty(plans)){
generateMon.setPlanPower(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(date,"yyyy-MM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum());
}else{
generateMon.setPlanPower(0.0);
}
// 实际发电
if(MapUtils.isNotEmpty(map)){
generateMon.setPower(map.entrySet().stream().filter(entry->entry.getKey().equals(mon)).mapToDouble(Map.Entry::getValue).sum());
}else{
generateMon.setPlanPower(0.0);
}
return generateMon;
}).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;
}
}

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

@ -18,11 +18,11 @@ 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.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.*;
import com.hnac.hzims.operational.main.vo.*; 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.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
@ -193,7 +193,7 @@ public class HydropowerServiceImpl implements HydropowerService {
* @param rains * @param rains
* @return * @return
*/ */
private List<PowerRainVo> getPowerRains(StationEntity station,List<HydropowerUnitVo> devices, List<Map<String, Object>> rains) { private List<HydroelectricPowerRainVo> getPowerRains(StationEntity station,List<HydropowerUnitVo> devices, List<Map<String, Object>> rains) {
List<GenerationPowerVo> powers = new ArrayList<>(); List<GenerationPowerVo> powers = new ArrayList<>();
if(CollectionUtil.isNotEmpty(devices)){ if(CollectionUtil.isNotEmpty(devices)){
devices.forEach(device->{ devices.forEach(device->{
@ -205,7 +205,7 @@ public class HydropowerServiceImpl implements HydropowerService {
// 根据日期遍历 // 根据日期遍历
List<String> days = this.get30Day(); List<String> days = this.get30Day();
return days.stream().map(day->{ return days.stream().map(day->{
PowerRainVo powerRain = new PowerRainVo(); HydroelectricPowerRainVo powerRain = new HydroelectricPowerRainVo();
powerRain.setDate(day); powerRain.setDate(day);
if(CollectionUtil.isEmpty(powers)){ if(CollectionUtil.isEmpty(powers)){
powerRain.setGenerate(0.0); powerRain.setGenerate(0.0);
@ -383,6 +383,7 @@ public class HydropowerServiceImpl implements HydropowerService {
private List<String> get30Day() { private List<String> get30Day() {
List<String> times = new ArrayList<>(); List<String> times = new ArrayList<>();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-1);
Date end = calendar.getTime(); Date end = calendar.getTime();
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE));

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

@ -4,7 +4,7 @@ import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.operational.home.wind.RainMon; import com.hnac.hzims.operational.homePage.wind.vo.RainMon;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.AreaService; import com.hnac.hzims.operational.main.service.AreaService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;

Loading…
Cancel
Save