Browse Source

#App光伏首页

zhongwei
yang_shj 2 years ago
parent
commit
d4d0001e4a
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  2. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java
  3. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java
  4. 21
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceStateVo.java
  5. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java
  6. 66
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadGenerateVo.java
  7. 31
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadVo.java
  8. 41
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationAppVo.java
  9. 72
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java
  10. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java
  11. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java
  12. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java
  13. 46
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java
  14. 464
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java
  15. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java
  16. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java

@ -178,6 +178,8 @@ public interface HomePageConstant {
// 光伏指标属性
String PHOTOVOLTAIC_GENERATE = "generation_capacity"; // 发电量
String PHOTOVOLTAIC_LOAD = "active_power"; // 功率
String PHOTOVOLTAIC_LOAD_TARGET = "0";
/*==========================================================================================*/
// 水电集团、区域指标关联
/**功率**/

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java

@ -12,5 +12,8 @@ public class GenerationPowerVo {
private String date;
@ApiModelProperty(value = "发电量")
private Float generationPower;
private Float generate;
@ApiModelProperty(value = "功率·")
private Float load;
}

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

@ -17,6 +17,6 @@ public class GenerationVo {
@ApiModelProperty(value = "周期")
private String period;
@ApiModelProperty(value = "发电量")
@ApiModelProperty(value = "发电量")
private Float power;
}

21
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceStateVo.java

@ -0,0 +1,21 @@
package com.hnac.hzims.operational.main.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
* @date 2023/04/03 16:57:22
* @version 4.0.0
*/
@Data
@ApiModel(value = "光伏站点设备状态对象")
public class PhotovoltaicDeviceStateVo {
@ApiModelProperty(value = "设备装态 : 0 - 离线 1 - 在线 2 - 故障")
private Integer state;
@ApiModelProperty(value = "数量")
private Integer count;
}

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java

@ -75,6 +75,11 @@ public class PhotovoltaicDeviceVo {
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double tec;
@ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double deforest;
@ApiModelProperty(value = "收益: 元")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double income;

66
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadGenerateVo.java

@ -22,68 +22,10 @@ import java.util.List;
@ApiModel(value = "水利站点首页对象")
public class PhotovoltaicLoadGenerateVo {
@ApiModelProperty(value = "机构Id")
private Long deptId;
@ApiModelProperty(value = "周期")
private String period;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "数据值")
private Float value;
@ApiModelProperty(value = "站点编码")
private String stationCode;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "投运时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime operationTime;
@ApiModelProperty(value = "总装机容量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@ApiModelProperty(value = "安全运行天数")
private Integer runDay;
@ApiModelProperty(value = "总发电负荷")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "日发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateDay;
@ApiModelProperty(value = "月发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateMon;
@ApiModelProperty(value = "年发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateYear;
@ApiModelProperty(value = "总发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate;
@ApiModelProperty(value = "站点实时温度")
private String temp;
@ApiModelProperty(value = "站点收益")
private Double income;
@ApiModelProperty(value = "逆变器数量")
private Integer inverterCount;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "发电排行")
private List<PhotovoltaicDeviceVo> devices;
@ApiModelProperty(value = "年发电量完成百分比")
private List<PowerYearVo> generateSurvey;
@ApiModelProperty(value = "设备信息")
private List<PhotovoltaicDeviceChartsVo> charts;
}

31
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicLoadVo.java

@ -0,0 +1,31 @@
package com.hnac.hzims.operational.main.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
* @date 2023/04/04 09:28:34
* @version 4.0.0
*/
@Data
@ApiModel(value = "发电量数据")
public class PhotovoltaicLoadVo {
@ApiModelProperty(value = "机构ID")
private Long deptId;
@ApiModelProperty(value = "站点编码")
private String code;
@ApiModelProperty(value = "站点名称")
private String name;
@ApiModelProperty(value = "实时功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
}

41
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationAppVo.java

@ -19,7 +19,7 @@ import java.util.List;
* @version 4.0.0
*/
@Data
@ApiModel(value = "水利站点首页对象")
@ApiModel(value = "光伏站点首页对象")
public class PhotovoltaicStationAppVo {
@ApiModelProperty(value = "机构Id")
@ -34,18 +34,6 @@ public class PhotovoltaicStationAppVo {
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "投运时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime operationTime;
@ApiModelProperty(value = "总装机容量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@ApiModelProperty(value = "安全运行天数")
private Integer runDay;
@ApiModelProperty(value = "总发电负荷")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ -58,10 +46,6 @@ public class PhotovoltaicStationAppVo {
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateMon;
@ApiModelProperty(value = "年发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateYear;
@ApiModelProperty(value = "总发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate;
@ -72,18 +56,19 @@ public class PhotovoltaicStationAppVo {
@ApiModelProperty(value = "站点收益")
private Double income;
@ApiModelProperty(value = "逆变器数量")
private Integer inverterCount;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "co2减排: kg")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double co2;
@ApiModelProperty(value = "发电排行")
private List<PhotovoltaicDeviceVo> devices;
@ApiModelProperty(value = "节约标准煤减排: kt")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double tec;
@ApiModelProperty(value = "年发电量完成百分比")
private List<PowerYearVo> generateSurvey;
@ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double deforest;
@ApiModelProperty(value = "设备信息")
private List<PhotovoltaicDeviceChartsVo> charts;
@ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553")
@JsonSerialize(nullsUsing = NullSerializer.class)
private List<PhotovoltaicDeviceStateVo> deviceState;
}

72
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicSubordinateAppVo.java

@ -25,63 +25,67 @@ public class PhotovoltaicSubordinateAppVo {
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "地市编码")
private String areaCode;
@ApiModelProperty(value = "地市名称")
private String areaName;
@ApiModelProperty(value = "温度")
private String temp;
@ApiModelProperty(value = "光伏站点类型:0-个体光伏站 1-厂房光伏站")
private Long type;
@ApiModelProperty("经度(东经)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lgtd;
@ApiModelProperty("纬度(北纬)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lttd;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "容量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@ApiModelProperty(value = "功率")
@ApiModelProperty(value = "今日发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateDay;
@ApiModelProperty(value = "实时功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "发电量")
@ApiModelProperty(value = "站点实时功率列表")
private List<PhotovoltaicLoadVo> stationLoads;
@ApiModelProperty(value = "日常任务数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generation;
private Integer maintenanceCount;
@ApiModelProperty(value = "发电占比")
@ApiModelProperty(value = "日常任务完成数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationRate;
private Integer maintenanceFinishCount;
@ApiModelProperty(value = "容量利用率")
@ApiModelProperty(value = "缺陷任务数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacityUse;
private Integer defectCount;
@ApiModelProperty(value = "电站利用率")
@ApiModelProperty(value = "缺陷任务完成数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double stationUse;
private Integer defectFinishCount;
@ApiModelProperty(value = "站点实时温度")
private String temp;
@ApiModelProperty(value = "检修任务数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer overhaulCount;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "检修任务完成数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer overhaulFinishCount;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "操作票任务数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer operateCount;
@ApiModelProperty(value = "站点数量")
@ApiModelProperty(value = "操作票任务完成数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long stationCount;
private Integer operateFinishCount;
@ApiModelProperty(value = "站点使用数量")
@ApiModelProperty(value = "操作票任务数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long stationUseCount;
private Integer workCount;
@ApiModelProperty(value = "操作票任务完成数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer workFinishCount;
@ApiModelProperty(value = "排序")
private Integer sort;
}

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java

@ -80,7 +80,8 @@ public class PhotovoltaicController extends BladeController {
@GetMapping("/app_load_generate")
@ApiOperationSupport(order = 3)
public R app_load_generate(@ApiParam(value = "区域/站点机构编号") Long deptId,
@ApiParam(value = "查询类型: 0 - 发电量 1 - 功率") Long type) {
return R.data(service.app_load_generate(deptId,type));
@ApiParam(value = "数据类型: 0 - 功率 1 - 发电量") String type,
@ApiParam(value = "查询类型: 0 - 日 1 - 周 2 - 月 3 - 年") String queryType) {
return R.data(service.app_load_generate(deptId,type,queryType));
}
}

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

@ -1,8 +1,9 @@
package com.hnac.hzims.operational.main.service;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
import java.util.function.Function;
@ -11,6 +12,10 @@ import java.util.function.Function;
* @author hx
*/
public interface IAnalyseDataService {
<T> List<AnalyzeCodeBySignagesVO> getAnalyzeCodeBySignages(Function<T, MultiAnalyzeCodePO> convert, T resource);
List<AnalyseDataTaosVO> periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages);
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java

@ -30,11 +30,11 @@ public interface PhotovoltaicService {
PhotovoltaicStationVo station(Long deptId);
// app区域数据
PhotovoltaicStationAppVo app_subordinate(Long deptId);
List<PhotovoltaicSubordinateAppVo> app_subordinate(Long deptId);
// app站点数据
PhotovoltaicStationAppVo app_station(Long deptId);
// App功率/发电量查询
PhotovoltaicLoadGenerateVo app_load_generate(Long deptId, Long type);
List<PhotovoltaicLoadGenerateVo> app_load_generate(Long deptId, String type,String queryType);
}

46
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java

@ -1,15 +1,25 @@
package com.hnac.hzims.operational.main.service.impl;
import com.google.common.collect.Lists;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -33,4 +43,40 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
}
return result;
}
/***
* 指标数据查询
* @param startTime 开始时间
* @param endTime 结束时间
* @param cycleType
* @param deviceCode
* @param signages
* @return
*/
@Override
public List<AnalyseDataTaosVO> periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setSignages(signages);
// 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
analyzeDataConditionPO.setAccessRules(accessRules);
// 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年)
analyzeDataConditionPO.setSaveTimeType(cycleType);
// 间隔
analyzeDataConditionPO.setTimeInterval(1);
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
signboardConditions.add(analyzeDataConditionPO);
po.setSignboardConditions(signboardConditions);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
return new ArrayList<>();
}
return result.getData().get(0).getList();
}
}

464
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

@ -13,7 +13,10 @@ import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.sdk.core.response.HzPage;
@ -38,15 +41,19 @@ import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
/**
* @author ysj
* @date 2023/03/23 16:51:43
* @version 4.0.0
* @date 2023/03/23 16:51:43
*/
@Service
@RequiredArgsConstructor
@ -62,23 +69,35 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
private final IWeatherService weatherService;
private final IAnalyseDataService analyseDataService;
private final IHistoryDataSearchClient historySearchClient;
private final IMainTaskStatisticService taskService;
private final ISysClient sysClient;
private final ITicketInfoClient ticketInfoClient;
private final RedisTemplate redisTemplate;
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key";
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key";
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 recent_year_load_data = "hzims:operation:key:load:data";
@Value("${hzims.operation.realIdKey}")
public String real_id_key;
// 线程数量
private final static int POOL_QUANTITY = 4;
/**
* 光伏站-逆变器实时加载
*
* @param param
*/
@Override
@ -117,6 +136,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 光伏站-逆变器指标加载
*
* @param param
*/
@Override
@ -183,6 +203,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 当天运行时长
*
* @param realId
* @return
*/
@ -215,7 +236,28 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
}
/**
* 当天运行时长
*
* @return
*/
private List<String> getDayHours() {
List<String> list = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
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));
// 获取时间
while (calendar.getTime().compareTo(new Date()) <= 0) {
list.add(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
calendar.add(Calendar.HOUR_OF_DAY, +1);
}
return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
}
/**
* 过滤相邻开关机状态相同数据
*
* @param list
* @return
*/
@ -248,6 +290,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取运行时长
*
* @param result
* @return
*/
@ -271,8 +314,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// 遍历至最后一条数据,累计至当前时间
if (i == result.size() - 1) {
endTime = endDate;
}
else {
} else {
endTime = DateUtil.parse(result.get(i + 1).getTime(), DateUtil.PATTERN_DATETIME);
}
time += endTime.getTime() - startTime.getTime();
@ -283,6 +325,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取年日发电量
*
* @param device
* @param scope
* @return
@ -327,19 +370,22 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 近30天发电量
*
* @param device
* @return
*/
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) {
List<GenerationPowerVo> generationPowerVoList = new ArrayList<>();
// 近30天日期集合
Random random = new Random();
List<String> dayList = this.getRecent30Day();
for (int i = 0; i < dayList.size() - 1; i++) {
GenerationPowerVo generationPowerVo = new GenerationPowerVo();
generationPowerVo.setDate(dayList.get(i));
// 某天发电量
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00", EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(), HomePageConstant.PHOTOVOLTAIC_GENERATE);
generationPowerVo.setGenerationPower(power);
generationPowerVo.setGenerate(power);
generationPowerVo.setLoad((float) (random.nextDouble() * 500));
generationPowerVoList.add(generationPowerVo);
}
return generationPowerVoList;
@ -347,6 +393,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 近7天发电量
*
* @param device
* @return
*/
@ -360,7 +407,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
generationPowerVo.setDate(sdf.format(DateUtil.parse(dayList.get(i), DateUtil.PATTERN_DATE)));
// 某天发电量
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00", EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(), HomePageConstant.PHOTOVOLTAIC_GENERATE);
generationPowerVo.setGenerationPower(power);
generationPowerVo.setGenerate(power);
generationPowerVoList.add(generationPowerVo);
}
return generationPowerVoList;
@ -369,6 +416,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 当天功率
*
* @return
*/
private List<String> getTestDay() {
@ -391,6 +439,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取近30天集合
*
* @return
*/
private List<String> getRecentWeek() {
@ -404,9 +453,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
list.add(df.format(calendar.getTime()));
// 获取日期之间的月
int i = 0;
while (i < 7) {
calendar.add(Calendar.DATE, - 1);
while (i <= 7) {
list.add(df.format(calendar.getTime()));
calendar.add(Calendar.DATE, -1);
i++;
}
return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
@ -414,6 +463,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取近30天集合
*
* @return
*/
private List<String> getRecent30Day() {
@ -437,6 +487,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取实时数据
*
* @return
*/
private Map<String, String> getRealData() {
@ -444,11 +495,13 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
if (StringUtil.isBlank(json)) {
return null;
}
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {
});
}
/**
* 获取光伏设备
*
* @return
*/
private List<EminfoAndEmParamVo> getPhotovoltaicDevice() {
@ -469,6 +522,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 集团/区域关键指标
*
* @param deptId
* @return
*/
@ -521,11 +575,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取近3年发电量
*
* @return
*/
private List<PowerYearVo> getPowerList(List<Long> stations) {
// 站点近年发电数据 key - stationCode value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
}
@ -571,6 +626,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 集团/区域发电量
*
* @param deptId
* @param type
* @return
@ -599,6 +655,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取发电量(/)
*
* @return
*/
private List<GenerationVo> getGeneration(List<Long> stations, boolean flag) {
@ -630,7 +687,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return generations.stream().filter(generation -> weeks.contains(generation.getDate())).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> {
GenerationVo generation = new GenerationVo();
generation.setPeriod(entry.getKey());
generation.setPower((float)entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerationPower).sum());
generation.setPower((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum());
return generation;
}).sorted(Comparator.comparing(GenerationVo::getPeriod)).collect(Collectors.toList());
}
@ -638,18 +695,19 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return generations.stream().collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> {
GenerationVo generation = new GenerationVo();
generation.setPeriod(entry.getKey());
generation.setPower((float)entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerationPower).sum());
generation.setPower((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum());
return generation;
}).sorted(Comparator.comparing(GenerationVo::getPeriod)).collect(Collectors.toList());
}
/**
* 获取发电量()
*
* @return
*/
private List<GenerationVo> getGenerationYear(List<Long> stations) {
// 站点近年发电数据 key - stationCode value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
}
@ -681,6 +739,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 集团/区域下属数据占比
*
* @param deptId
* @return
*/
@ -779,6 +838,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 站点数据
*
* @param deptId
* @return
*/
@ -832,37 +892,396 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* App区域下属数据
*
* @param deptId
* @return
*/
@Override
public PhotovoltaicStationAppVo app_subordinate(Long deptId) {
return null;
public List<PhotovoltaicSubordinateAppVo> app_subordinate(Long deptId) {
// 获取区域或者站点map结构
Map<Dept, List<StationEntity>> map = sideHustleService.getAreaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC));
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
}
// 实时数据
List<PhotovoltaicRealVo> deviceReals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 指标数据
List<PhotovoltaicTargetVo> deviceTargets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
// 遍历数据
List<PhotovoltaicSubordinateAppVo> subordinates = new ArrayList<>();
for (Map.Entry<Dept, List<StationEntity>> entry : map.entrySet()) {
PhotovoltaicSubordinateAppVo subordinate = new PhotovoltaicSubordinateAppVo();
if (ObjectUtil.isEmpty(entry.getValue())) {
continue;
}
StationEntity station = entry.getValue().get(0);
subordinate.setDeptId(entry.getKey().getId());
subordinate.setDeptName(entry.getKey().getDeptName());
subordinate.setSort(entry.getKey().getSort());
subordinate.setAddress(station.getAddress());
// 获取实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode()));
if (MapUtils.isNotEmpty(nowWeather)) {
subordinate.setTemp(nowWeather.get(station.getCode()).getNow().getTemp());
}
// 容量、实时功率、今日发电量
this.subordinateTargetData(subordinate, entry.getValue().stream().collect(Collectors.toList()), deviceReals, deviceTargets);
// 当月任务执行情况
this.subordinateTaskMon(subordinate,Collections.singletonList(entry.getKey().getId()));
subordinates.add(subordinate);
}
return subordinates;
}
/**
* 当月任务执行情况
* @param subordinate
*/
private void subordinateTaskMon(PhotovoltaicSubordinateAppVo subordinate,List<Long> depts) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
LocalDate firstDay = LocalDate.now().withDayOfMonth(1);
LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime endTime = LocalDateTime.now();
//通过线程池异步获取月报各模块内容 主要分为五块内容
ExecutorService exe = Executors.newFixedThreadPool(POOL_QUANTITY);
//监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
// 日常维护
exe.execute(()->{
MaintainVo maintainVo = taskService.getMaintain(dtf.format(startTime),dtf.format(endTime),depts);
subordinate.setMaintenanceCount(maintainVo.getMaintain());
subordinate.setMaintenanceFinishCount(maintainVo.getMaintainFinish());
countDownLatch.countDown();
});
// 消缺
exe.execute(()->{
ShortagesVo shortages = taskService.getShortages(depts);
subordinate.setDefectCount(shortages.getShortagesSum());
subordinate.setDefectFinishCount(shortages.getShortages());
countDownLatch.countDown();
});
// 检修
exe.execute(()->{
OverhaulVo overhaulVo = taskService.getOverhaul(dtf.format(startTime),dtf.format(endTime),depts);
int overhaul = overhaulVo.getOverhaul();
int overhaulFinish = overhaulVo.getOverhaulFinish();
subordinate.setOverhaulCount(overhaul);
subordinate.setOverhaulFinishCount(overhaulFinish);
countDownLatch.countDown();
});
// 操作票&工作票
exe.execute(()->{
Map<String,Object> map = new HashMap<>();
map.put("startDate",dtf.format(startTime));
map.put("endDate",dtf.format(endTime));
map.put("deptList",depts);
R<TicketMonthVO> R = ticketInfoClient.getOperateWorkStatistic(map);
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) {
return;
}
TicketMonthVO ticketMonthVO = R.getData();
// 操作票
subordinate.setOperateCount(ticketMonthVO.getOperate());
subordinate.setOperateFinishCount(ticketMonthVO.getOperateQualify());
// 工作票
subordinate.setWorkCount(ticketMonthVO.getWork());
subordinate.setWorkFinishCount(ticketMonthVO.getWorkQualify());
countDownLatch.countDown();
});
}
/**
* App集团/区域指标数据
*
* @param stations
* @param deviceReals
* @param deviceTargets
*/
private void subordinateTargetData(PhotovoltaicSubordinateAppVo subordinate, List<StationEntity> stations, List<PhotovoltaicRealVo> deviceReals, List<PhotovoltaicTargetVo> deviceTargets) {
if (CollectionUtil.isEmpty(deviceReals) && CollectionUtil.isEmpty(deviceTargets)) {
return;
}
List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList());
List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(reals)) {
// 容量 、 实时功率
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
subordinate.setStationLoads(
stations.stream().map(station -> {
PhotovoltaicLoadVo load = new PhotovoltaicLoadVo();
load.setDeptId(station.getRefDept());
load.setCode(station.getCode());
load.setName(station.getName());
load.setLoad(reals.stream().filter(o -> o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
return load;
}).sorted(Comparator.comparing(PhotovoltaicLoadVo::getLoad).reversed()).collect(Collectors.toList())
);
}
if (CollectionUtil.isNotEmpty(targets)) {
// 今日发电量
subordinate.setGenerateDay(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum());
}
}
/**
* App光伏站点数据
*
* @param deptId
* @return
*/
@Override
public PhotovoltaicStationAppVo app_station(Long deptId) {
return null;
// 参数检查
if (ObjectUtil.isEmpty(deptId)) {
return new PhotovoltaicStationAppVo();
}
// 查询站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getRefDept, deptId));
if (ObjectUtil.isEmpty(station)) {
return new PhotovoltaicStationAppVo();
}
PhotovoltaicStationAppVo photovoltaic = new PhotovoltaicStationAppVo();
// 站点温度
Map<String, HeWeatherWeatherNowResponse> weather = weatherService.getNowWeather(Collections.singletonList(station.getCode()));
photovoltaic.setStationCode(station.getCode());
photovoltaic.setDeptId(station.getRefDept());
photovoltaic.setDeptName(station.getName());
photovoltaic.setTemp(this.temp(weather, station.getCode()));
photovoltaic.setAddress(station.getAddress());
// 站点实时数据: 设备状态统计、实时功率、总发电量 、 日发电量 、 月发电量 、 co2减排 、 节约标准煤减排 、 减少森林砍伐
this.app_data(photovoltaic);
return photovoltaic;
}
/**
* 站点指标数据
*
* @param photovoltaic
*/
private void app_data(PhotovoltaicStationAppVo photovoltaic) {
// 实时监测点数据
List<PhotovoltaicRealVo> reals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 获取站点机组指标数据
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if (CollectionUtil.isEmpty(reals) && CollectionUtil.isEmpty(targets)) {
return;
}
List<PhotovoltaicRealVo> mateReals = reals.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList());
List<PhotovoltaicTargetVo> mateTargets = targets.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(mateReals) && CollectionUtil.isEmpty(mateTargets)) {
return;
}
// 实时数据 : 实时功率、总发电量
if (CollectionUtil.isNotEmpty(mateReals)) {
// 设备状态统计
photovoltaic.setDeviceState(
mateReals.stream().collect(Collectors.groupingBy(PhotovoltaicRealVo::getState)).entrySet().stream().map(entry -> {
PhotovoltaicDeviceStateVo state = new PhotovoltaicDeviceStateVo();
state.setState(entry.getKey());
state.setCount(entry.getValue().size());
return state;
}).collect(Collectors.toList())
);
photovoltaic.setLoad(mateReals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
photovoltaic.setGenerate(mateReals.stream().mapToDouble(PhotovoltaicRealVo::getGenerate).sum());
}
// 指标数据 : 日发电量 、 月发电量 、 co2减排 、 节约标准煤减排 、 减少森林砍伐
if (CollectionUtil.isNotEmpty(mateTargets)) {
photovoltaic.setGenerateDay(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum());
photovoltaic.setGenerateMon(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationMon).sum());
photovoltaic.setCo2(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getCo2).sum());
photovoltaic.setTec(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getTec).sum());
photovoltaic.setIncome(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getIncome).sum());
photovoltaic.setDeforest(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getDeforest).sum());
}
}
/**
* App功率/发电量查询
*
* @param deptId
* @param type
* @return
*/
@Override
public PhotovoltaicLoadGenerateVo app_load_generate(Long deptId, Long type) {
return null;
public List<PhotovoltaicLoadGenerateVo> app_load_generate(Long deptId, String type, String queryType) {
// 查询光伏站点
List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), HomePageConstant.HYDROPOWER_SERVETYPE);
if (CollectionUtil.isEmpty(stations)) {
return new ArrayList<>();
}
// 区别查询周期
switch (queryType) {
// 日
case "0":
return this.periodLoadDay(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
// 周
case "1":
return this.periodLoadGenerate(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()), type, true);
// 月
case "2":
return this.periodLoadGenerate(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()), type, false);
// 年
case "3":
return this.periodLoadGenerateYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList()));
default:
throw new ServiceException("无效查询类型!");
}
}
/**
* 查询光伏设备日数据
*
* @param stations
* @return
*/
private List<PhotovoltaicLoadGenerateVo> periodLoadDay(List<Long> stations) {
// FIXME 测试数据
List<String> hours = getDayHours();
Random random = new Random();
return hours.stream().map(hour -> {
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo();
target.setPeriod(hour);
target.setValue((float) (random.nextDouble() * 500));
return target;
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList());
/*// redis实时数据
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if(CollectionUtil.isEmpty(photovoltaics)){
return new ArrayList();
}
// 过滤有效光伏设备
List<PhotovoltaicTargetVo> devices = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATE);
// 开始日期
Calendar calendar = Calendar.getInstance();
String start = sdf.format(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));
String end = sdf.format(calendar.getTime());
List<AnalyseDataTaosVO> list = new ArrayList<>();
for(PhotovoltaicTargetVo device : devices){
list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PHOTOVOLTAIC_LOAD));
};
if(CollectionUtil.isEmpty(list)){
return new ArrayList<>();
}
return list.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)).entrySet().stream().map(entry ->{
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo();
LocalDateTime time = LocalDateTime.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME));
target.setPeriod(String.valueOf(time.getHour()));
target.setValue((float) entry.getValue().stream().mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum());
return target;
}).collect(Collectors.toList());*/
}
/**
* 查询周月数据
*
* @param type
* @param flag
* @return
*/
private List<PhotovoltaicLoadGenerateVo> periodLoadGenerate(List<Long> stations, String type, boolean flag) {
// redis实时数据
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if (CollectionUtil.isEmpty(photovoltaics)) {
return new ArrayList();
}
// 过滤有效光伏设备
List<PhotovoltaicTargetVo> filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(filters)) {
return new ArrayList<>();
}
// 数据集合
List<GenerationPowerVo> targets = new ArrayList<>();
for (PhotovoltaicTargetVo target : filters) {
if (CollectionUtil.isEmpty(target.getGenerationPowerVoList())) {
continue;
}
targets.addAll(target.getGenerationPowerVoList());
}
if (CollectionUtil.isEmpty(targets)) {
return new ArrayList<>();
}
List<String> weeks = this.getRecentWeek();
// 周
if (flag) {
// 根据日期分组
return targets.stream().filter(generation -> weeks.contains(generation.getDate())).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> {
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo();
target.setPeriod(entry.getKey());
if (HomePageConstant.PHOTOVOLTAIC_LOAD_TARGET.equals(type)) {
target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getLoad).sum());
} else {
target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum());
}
return target;
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList());
}
// 月
return targets.stream().collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> {
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo();
target.setPeriod(entry.getKey());
if (HomePageConstant.PHOTOVOLTAIC_LOAD_TARGET.equals(type)) {
target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getLoad).sum());
} else {
target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum());
}
return target;
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList());
}
/**
* 光伏站点年数据查询
*
* @param stations
* @return
*/
private List<PhotovoltaicLoadGenerateVo> periodLoadGenerateYear(List<Long> stations) {
// 站点近年发电数据 key - stationCode value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
}
List<Map<String, Float>> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
if (CollectionUtil.isEmpty(filter)) {
return new ArrayList<>();
}
// 根据月份分组
List<PowerMonthVo> powerMonthVos = new ArrayList<>();
filter.forEach(item -> {
item.forEach((key, value) -> {
PowerMonthVo powerMonthVo = new PowerMonthVo();
powerMonthVo.setStrMonth(key);
powerMonthVo.setPower(value);
powerMonthVos.add(powerMonthVo);
});
});
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth));
// 总和所有相同月份的发电量
String year = String.valueOf(LocalDate.now().getYear());
return months.entrySet().stream().filter(entry -> entry.getKey().contains(year)).map(entry -> {
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo();
target.setPeriod(entry.getKey());
target.setValue((float) entry.getValue().stream().mapToDouble(PowerMonthVo::getPower).sum());
return target;
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList());
}
/**
* 获取实时温度
*
* @param weather
* @param code
* @return
@ -880,6 +1299,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取七天天气
*
* @param weekWeather
* @param code
* @return
@ -897,6 +1317,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 获取站点运行天数
*
* @param station
* @return
*/
@ -911,6 +1332,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 站点实时数据统计
*
* @param photovoltaic
*/
private void real_data(PhotovoltaicStationVo photovoltaic) {
@ -936,6 +1358,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 光伏设备实时指标数据
*
* @param devices
* @param reals
* @param targets
@ -977,6 +1400,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
item.setGenerateDay(mateTargets.get(0).getGenerationDay());
item.setCo2(mateTargets.get(0).getCo2());
item.setTec(mateTargets.get(0).getTec());
item.setDeforest(mateTargets.get(0).getDeforest());
item.setIncome(mateTargets.get(0).getIncome());
item.setActivePowerVoList(mateTargets.get(0).getActivePowerVoList());
item.setGenerationPowerVoList(mateTargets.get(0).getGenerationPowerVoList());
@ -993,6 +1417,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 设备排行榜
*
* @param devices
* @return
*/
@ -1013,10 +1438,11 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 年发电量比较概括
*
* @return
*/
private List<PowerYearVo> generateSurvey(Long station) {
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
}

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

@ -1634,7 +1634,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
if(CollectionUtil.isEmpty(list)){
return 0;
}
return (float) list.stream().filter(v->o.equals(v.getDate())).mapToDouble(GenerationPowerVo::getGenerationPower).sum();
return (float) list.stream().filter(v->o.equals(v.getDate())).mapToDouble(GenerationPowerVo::getGenerate).sum();
}
/**

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

@ -322,7 +322,7 @@ public class WebHomeServiceImpl implements IWebHomeService {
generationPowerVo.setDate(dayList.get(i));
// 某天发电量
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00",EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
generationPowerVo.setGenerationPower(power);
generationPowerVo.setGenerate(power);
generationPowerVoList.add(generationPowerVo);
}
return generationPowerVoList;

Loading…
Cancel
Save