|
|
@@ -1,5 +1,6 @@
|
|
|
package com.gyee.runeconomy.service.goodness;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -16,6 +17,7 @@ import com.gyee.runeconomy.init.CacheContext;
|
|
|
import com.gyee.runeconomy.model.auto.*;
|
|
|
import com.gyee.runeconomy.service.auto.IProEconEquipmentInfoDay6Service;
|
|
|
import com.gyee.runeconomy.service.auto.IProEconWindturbineGoodnessService;
|
|
|
+import com.gyee.runeconomy.service.auto.ITurbineInfoDayService;
|
|
|
import com.gyee.runeconomy.service.auto.ITurbineInfoMinService;
|
|
|
import com.gyee.runeconomy.util.DateUtils;
|
|
|
import com.gyee.runeconomy.util.StringUtils;
|
|
|
@@ -26,7 +28,11 @@ import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @ClassName : WindturbinegoodnessService
|
|
|
@@ -47,6 +53,9 @@ public class WindturbinegoodnessService {
|
|
|
@Resource
|
|
|
private ITurbineInfoMinService iTurbineInfoMinService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ITurbineInfoDayService iTurbineInfoDayService;
|
|
|
+
|
|
|
public Page<ProEconWindturbineGoodness> windturbinegoodnessList(Integer pageNum, Integer pageSize, String cmId, String type, String wpId, String recorddate) {
|
|
|
|
|
|
if (StringUtils.empty(pageNum)) {
|
|
|
@@ -56,6 +65,101 @@ public class WindturbinegoodnessService {
|
|
|
pageSize = 10;
|
|
|
}
|
|
|
//构造分页构造器
|
|
|
+ Page<TurbineInfoDay> pageInfo2 = new Page<>(pageNum, pageSize);
|
|
|
+ if (StringUtils.notEmp(type) && StringUtils.notEmp(recorddate)) {
|
|
|
+ Date date = com.gyee.common.util.DateUtils.parseDate(recorddate);
|
|
|
+
|
|
|
+ //构造条件构造器
|
|
|
+ QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
|
|
|
+ //添加过滤条件
|
|
|
+ if (StringUtils.notEmp(wpId)) {
|
|
|
+ qw.lambda().eq(TurbineInfoDay::getStationId, wpId).eq(TurbineInfoDay::getRecordDate, date).orderByAsc(TurbineInfoDay::getTurbineId);
|
|
|
+ }
|
|
|
+ //执行查询
|
|
|
+ iTurbineInfoDayService.page(pageInfo2, qw);
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTime parse = DateUtil.parse(recorddate, "yyyy-MM-dd");
|
|
|
+ List<TurbineInfoDay> dayls = iTurbineInfoDayService.getTurbineMonthList(wpId, DateUtil.date(parse).toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), DateUtil.date(parse).toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
|
|
+ List<TurbineInfoDay> daySorted = Optional.ofNullable(dayls)
|
|
|
+ .orElse(Collections.emptyList())
|
|
|
+ .stream()
|
|
|
+ .sorted(Comparator.comparing(TurbineInfoDay::getNhyd)
|
|
|
+ .reversed().thenComparing(TurbineInfoDay::getTurbineId)).collect(Collectors.toList());
|
|
|
+ Map<String, Integer> daySort = sort(daySorted);
|
|
|
+
|
|
|
+ List<TurbineInfoDay> monls = iTurbineInfoDayService.getTurbineMonthList(wpId, DateUtil.beginOfMonth(parse).toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), DateUtil.date(parse).toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
|
|
+ Map<String, List<TurbineInfoDay>> monMap = Optional.ofNullable(monls)
|
|
|
+ .orElse(Collections.emptyList())
|
|
|
+ .stream().collect(Collectors.groupingBy(TurbineInfoDay::getTurbineId));
|
|
|
+ List<TurbineInfoDay> monSorted = Optional.ofNullable(monls)
|
|
|
+ .orElse(Collections.emptyList())
|
|
|
+ .stream()
|
|
|
+ .sorted(Comparator.comparing(TurbineInfoDay::getNhyd).reversed()
|
|
|
+ .thenComparing(TurbineInfoDay::getTurbineId)).collect(Collectors.toList());
|
|
|
+ Map<String, Integer> monSort = sort(monSorted);
|
|
|
+
|
|
|
+ List<TurbineInfoDay> yearls = iTurbineInfoDayService.getTurbineMonthList(wpId, DateUtil.beginOfYear(parse).toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), DateUtil.date(parse).toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
|
|
+ Map<String, List<TurbineInfoDay>> yearMap = Optional.ofNullable(yearls)
|
|
|
+ .orElse(Collections.emptyList())
|
|
|
+ .stream().collect(Collectors.groupingBy(TurbineInfoDay::getTurbineId));
|
|
|
+ List<TurbineInfoDay> yearSorted = Optional.ofNullable(yearls)
|
|
|
+ .orElse(Collections.emptyList())
|
|
|
+ .stream()
|
|
|
+ .sorted(Comparator.comparing(TurbineInfoDay::getNhyd).reversed()
|
|
|
+ .thenComparing(TurbineInfoDay::getTurbineId)).collect(Collectors.toList());
|
|
|
+ Map<String, Integer> yearSort = sort(yearSorted);
|
|
|
+
|
|
|
+ Page<ProEconWindturbineGoodness> pageInfo = new Page<>(pageNum, pageSize);
|
|
|
+ List<ProEconWindturbineGoodness> goodls = new ArrayList<>();
|
|
|
+
|
|
|
+ pageInfo2.getRecords().forEach(tur -> {
|
|
|
+ ProEconWindturbineGoodness good = new ProEconWindturbineGoodness();
|
|
|
+ good.setWindturbineId(tur.getTurbineId());
|
|
|
+ good.setWindtpowerstationId(tur.getStationId());
|
|
|
+ good.setDayGoodness(tur.getNhyd());
|
|
|
+ good.setDaySpeed(NumberUtil.round(tur.getPjfs(),2).doubleValue());
|
|
|
+ good.setDayTop(daySort.get(tur.getTurbineId()));
|
|
|
+ if (monMap.containsKey(tur.getTurbineId())&&monSort.containsKey(tur.getTurbineId())) {
|
|
|
+ TurbineInfoDay month = monMap.get(tur.getTurbineId()).get(0);
|
|
|
+ good.setMonthGoodness(NumberUtil.round(month.getNhyd(),2).doubleValue());
|
|
|
+ good.setMonthSpeed(NumberUtil.round(month.getPjfs(),2).doubleValue());
|
|
|
+ good.setMonthTop(monSort.get(tur.getTurbineId()));
|
|
|
+ }
|
|
|
+ if (yearMap.containsKey(tur.getTurbineId())&&yearSort.containsKey(tur.getTurbineId())) {
|
|
|
+ TurbineInfoDay year = yearMap.get(tur.getTurbineId()).get(0);
|
|
|
+ good.setYearGoodness(NumberUtil.round(year.getNhyd(),2).doubleValue());
|
|
|
+ good.setYearSpeed(NumberUtil.round(year.getPjfs(),2).doubleValue());
|
|
|
+ good.setYearTop(yearSort.get(tur.getTurbineId()));
|
|
|
+ }
|
|
|
+ goodls.add(good);
|
|
|
+ });
|
|
|
+
|
|
|
+ pageInfo.setRecords(goodls);
|
|
|
+ pageInfo.setTotal(pageInfo2.getTotal());
|
|
|
+ pageInfo.setPages(pageInfo2.getPages());
|
|
|
+ pageInfo.setCurrent(pageNum);
|
|
|
+ pageInfo.setSize(pageSize);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Integer> sort(List<TurbineInfoDay> ls) {
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ for (int i = 0; i < ls.size(); i++) {
|
|
|
+ map.put(ls.get(i).getTurbineId(), i + 1);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Page<ProEconWindturbineGoodness> windturbinegoodnessList2(Integer pageNum, Integer pageSize, String cmId, String type, String wpId, String recorddate) {
|
|
|
+
|
|
|
+ if (StringUtils.empty(pageNum)) {
|
|
|
+ pageNum = 1;
|
|
|
+ }
|
|
|
+ if (StringUtils.empty(pageSize)) {
|
|
|
+ pageSize = 10;
|
|
|
+ }
|
|
|
+ //构造分页构造器
|
|
|
Page<ProEconWindturbineGoodness> pageInfo = new Page<>(pageNum, pageSize);
|
|
|
if (StringUtils.notEmp(type) && StringUtils.notEmp(recorddate)) {
|
|
|
Date date = com.gyee.common.util.DateUtils.parseDate(recorddate);
|