Browse Source

#演示平台接口、30天发电量修改

zhongwei
yang_shj 10 months ago
parent
commit
5c7f9e7383
  1. 20
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/WeatherRainVo.java
  2. 23
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/WeatherWaterVo.java
  3. 16
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  4. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java
  5. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java
  6. 124
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java

20
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/WeatherRainVo.java

@ -0,0 +1,20 @@
package com.hnac.hzims.operational.data.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class WeatherRainVo {
@ApiModelProperty("时间")
private String time;
@ApiModelProperty("水位")
private Double water;
@ApiModelProperty("降雨量")
private Double rain;
}

23
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/WeatherWaterVo.java

@ -0,0 +1,23 @@
package com.hnac.hzims.operational.data.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 WeatherWaterVo {
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("天气")
private List<Daily> dailys;
@ApiModelProperty("发电量")
private List<WeatherRainVo> weatherRains;
}

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

@ -14,18 +14,17 @@ import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.service.equipment.DeviceParamService; import com.hnac.hzims.scheduled.service.equipment.DeviceParamService;
import com.hnac.hzims.scheduled.service.equipment.DeviceService; import com.hnac.hzims.scheduled.service.equipment.DeviceService;
import com.hnac.hzims.scheduled.service.operation.home.ModelStationService;
import com.hnac.hzims.scheduled.service.operation.home.RealTargetService;
import com.hnac.hzims.scheduled.service.operation.fill.GenerateService; import com.hnac.hzims.scheduled.service.operation.fill.GenerateService;
import com.hnac.hzims.scheduled.service.operation.fill.PowerService; import com.hnac.hzims.scheduled.service.operation.fill.PowerService;
import com.hnac.hzims.scheduled.service.operation.fill.UseService; import com.hnac.hzims.scheduled.service.operation.fill.UseService;
import com.hnac.hzims.scheduled.service.operation.home.ModelStationService;
import com.hnac.hzims.scheduled.service.operation.home.RealTargetService;
import com.hnac.hzims.scheduled.service.operation.plate.DataService;
import com.hnac.hzims.scheduled.service.operation.station.StationAttributeService; import com.hnac.hzims.scheduled.service.operation.station.StationAttributeService;
import com.hnac.hzims.scheduled.service.operation.station.StationService; import com.hnac.hzims.scheduled.service.operation.station.StationService;
import com.hnac.hzims.scheduled.service.operation.plate.DataService;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
@ -1589,8 +1588,13 @@ public class RealTargetServiceImpl implements RealTargetService {
* @return * @return
*/ */
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) { private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) {
String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; Calendar calendar = Calendar.getInstance();
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.DAY_OF_MONTH,-29);
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));
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){ if(CollectionUtil.isEmpty(records)){
return new ArrayList<>(); return new ArrayList<>();

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java

@ -51,11 +51,18 @@ public class HzimsDataController {
} }
@ApiLog @ApiLog
@GetMapping("/power") @GetMapping("/weather")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
@ApiOperation(value = "站点天气、降雨、水位", notes = "传入站点code")
public R weather(@RequestParam("stationCode") String stationCode) {
return R.data(service.weather(stationCode));
}
@ApiLog
@GetMapping("/power")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "站点功率换算电量", notes = "传入站点code") @ApiOperation(value = "站点功率换算电量", notes = "传入站点code")
public R power(@RequestParam("stationCode") String stationCode) { public R power(@RequestParam("stationCode") String stationCode) {
return R.data(service.power(stationCode)); return R.data(service.power(stationCode));
} }
} }

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java

@ -1,6 +1,7 @@
package com.hnac.hzims.operational.data.service; package com.hnac.hzims.operational.data.service;
import com.hnac.hzims.operational.data.vo.PowerConvertVo; import com.hnac.hzims.operational.data.vo.PowerConvertVo;
import com.hnac.hzims.operational.data.vo.WeatherWaterVo;
import com.hnac.hzims.operational.main.vo.HydropowerStationVo; import com.hnac.hzims.operational.main.vo.HydropowerStationVo;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -22,5 +23,7 @@ public interface HzimsDataService {
HydropowerStationVo station(String stationCode); HydropowerStationVo station(String stationCode);
WeatherWaterVo weather(String stationCode);
PowerConvertVo power(String stationCode); PowerConvertVo power(String stationCode);
} }

124
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java

@ -6,15 +6,15 @@ import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IEmInfoClient;
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.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.operational.data.service.HzimsDataService; import com.hnac.hzims.operational.data.service.HzimsDataService;
import com.hnac.hzims.operational.data.vo.AreaVo; import com.hnac.hzims.operational.data.vo.AreaVo;
import com.hnac.hzims.operational.data.vo.ConverElectricityVo; import com.hnac.hzims.operational.data.vo.*;
import com.hnac.hzims.operational.data.vo.LoadWaterLevelVo;
import com.hnac.hzims.operational.data.vo.PowerConvertVo;
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.IAnalyseDataService; import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
@ -67,16 +67,18 @@ public class HzimsDataServiceImpl implements HzimsDataService {
private final IStationService stationService; private final IStationService stationService;
private final IWeatherService weatherService;
private final IAnalyseDataService dataService; private final IAnalyseDataService dataService;
private final IHzimsAnalyzeModelStationService modelStationService; private final IHzimsAnalyzeModelStationService modelStationService;
private final IMainSystemMonitoringService maintenanceTaskService; private final IMainSystemMonitoringService maintenanceTaskService;
private final IEmInfoClient deviceClient;
private final ISysClient sysClient; private final ISysClient sysClient;
private final IEmInfoClient deviceClient;
private final IPlanGenertionClient planGenertionClient; private final IPlanGenertionClient planGenertionClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
@ -88,6 +90,8 @@ public class HzimsDataServiceImpl implements HzimsDataService {
private final static String conver_power_key = "hzims:operation:conver:power:"; private final static String conver_power_key = "hzims:operation:conver:power:";
private final static String conver_weather_key = "hzims:operation:conver:weather:";
private final static String recent_year_power_data = "hzims:operation:key:power:data"; private final static String recent_year_power_data = "hzims:operation:key:power:data";
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; private final static String loadwater_level_key = "hzims:operation:loadwater:level:key";
@ -235,6 +239,40 @@ public class HzimsDataServiceImpl implements HzimsDataService {
} }
/** /**
* 站点天气降雨水位
* @param stationCode
* @return
*/
@Override
public WeatherWaterVo weather(String stationCode) {
WeatherWaterVo redisCache = (WeatherWaterVo) redisTemplate.opsForValue().get(conver_weather_key + stationCode);
if(!ObjectUtil.isEmpty(redisCache)){
return redisCache;
}
WeatherWaterVo weatherWater = new WeatherWaterVo();
// 查询站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().
eq(StationEntity::getCode,stationCode)
);
if(ObjectUtil.isEmpty(station)){
return new WeatherWaterVo();
}
weatherWater.setStationName(station.getName());
// 七天天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode()));
if(!MapUtils.isEmpty(weekWeather)){
HeWeatherWeatherDailyResponse week = weekWeather.get(stationCode);
if(!ObjectUtil.isEmpty(week)){
weatherWater.setDailys(week.getDaily());
}
}
weatherWater.setWeatherRains(this.waterRain(stationCode));
redisTemplate.opsForValue().set(conver_weather_key + stationCode,weatherWater);
redisTemplate.expire(conver_weather_key + stationCode,30, TimeUnit.MINUTES);
return weatherWater;
}
/**
* 站点功率换算电量 * 站点功率换算电量
* @param stationCode * @param stationCode
* @return * @return
@ -263,6 +301,58 @@ public class HzimsDataServiceImpl implements HzimsDataService {
return convert; return convert;
} }
/**
* 获取七天天气
* @param codes
*/
private Map<String, HeWeatherWeatherDailyResponse> getWeekWeather(List codes) {
if(CollectionUtil.isEmpty(codes)){
return null;
}
// 实时天气
return this.weatherService.getWeekWeather(codes);
}
/**
* 30天水位降雨量
* @param stationCode
* @return
*/
private List<WeatherRainVo> waterRain(String stationCode) {
Calendar calendar = Calendar.getInstance();
String endTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
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);
// 查询水位数据
List<AnalyseDataTaosVO> waters = this.water(startTime,endTime,stationCode);
// TODO 查询降雨数据
// 近30天水位、降雨量
List<String> days = this.get30Day();
return days.stream().map(day->{
WeatherRainVo weatherRain = new WeatherRainVo();
weatherRain.setTime(day);
// 水位
if(CollectionUtil.isEmpty(waters)){
weatherRain.setWater(0.0);
}else{
weatherRain.setWater(waters.stream().filter(o->o.getTs().contains(day)).mapToDouble(water->{
if(StringUtil.isEmpty(water.getVal())){
return 0.0;
}else{
return Double.parseDouble(water.getVal());
}
}).sum());
}
// TODO 降雨量数据
weatherRain.setRain(0.0);
return weatherRain;
}).collect(Collectors.toList());
}
/** /**
* 查询近30天发电量 * 查询近30天发电量
* @param deptId * @param deptId
@ -375,7 +465,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
return new ArrayList<>(); return new ArrayList<>();
} }
// 水位查询 // 水位查询
return dataService.periodTargetData(startTime,endTime,3,2,model.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); return dataService.periodTargetData(startTime,endTime,3,3,model.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL);
} }
@ -400,6 +490,28 @@ public class HzimsDataServiceImpl implements HzimsDataService {
} }
/** /**
* 获取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;
}
/**
* 获取24小时 * 获取24小时
* @return * @return
*/ */

Loading…
Cancel
Save