|
|
@@ -1,5 +1,6 @@
|
|
|
package com.gyee.runeconomy.service.singleanalysis;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.gyee.common.model.StringUtils;
|
|
|
@@ -12,6 +13,8 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -1110,20 +1113,24 @@ public class SingleAnalysisService {
|
|
|
|
|
|
|
|
|
public Map<String, List<SingleAnalysisVo>> SingleAnalysisListByWtIdDetiml(String wtId, Date beginDate, Date endDate) {
|
|
|
-
|
|
|
Map<String, List<SingleAnalysisVo>> map = new HashMap<>();
|
|
|
List<SingleAnalysisVo> fdlfsls = new ArrayList<>();
|
|
|
List<SingleAnalysisVo> wsls = new ArrayList<>();
|
|
|
List<SingleAnalysisVo> jfpldjsjls = new ArrayList<>();
|
|
|
if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {
|
|
|
-
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ int year = DateUtil.year(beginDate);
|
|
|
+ int month = DateUtil.month(beginDate);
|
|
|
+ if (year == now.getYear() && month + 1 == now.getMonthValue()) {
|
|
|
+ endDate = DateUtil.beginOfDay(Date.from(now.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
+ }
|
|
|
|
|
|
Map<String, Map<Long, ProEconEquipmentInfoDay1>> day1map = new HashMap<>();
|
|
|
Map<String, Map<Long, ProEconEquipmentInfoDay2>> day2map = new HashMap<>();
|
|
|
|
|
|
QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("windturbine_id", wtId).ge("record_date", beginDate)
|
|
|
- .le("record_date", endDate)
|
|
|
+ .lt("record_date", endDate)
|
|
|
.orderByAsc("record_date");
|
|
|
List<ProEconEquipmentInfoDay1> wtday1ls = proEconEquipmentInfoDay1Service.list(queryWrapper);
|
|
|
if (!wtday1ls.isEmpty()) {
|
|
|
@@ -1141,8 +1148,9 @@ public class SingleAnalysisService {
|
|
|
}
|
|
|
QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper2 = new QueryWrapper<>();
|
|
|
queryWrapper2.eq("windturbine_id", wtId).ge("record_date", beginDate)
|
|
|
- .le("record_date", endDate)
|
|
|
- .orderByAsc("record_date");;
|
|
|
+ .lt("record_date", endDate)
|
|
|
+ .orderByAsc("record_date");
|
|
|
+ ;
|
|
|
List<ProEconEquipmentInfoDay2> wtday2ls = proEconEquipmentInfoDay2Service.list(queryWrapper2);
|
|
|
if (!wtday2ls.isEmpty()) {
|
|
|
for (ProEconEquipmentInfoDay2 wtday2 : wtday2ls) {
|
|
|
@@ -1159,7 +1167,7 @@ public class SingleAnalysisService {
|
|
|
}
|
|
|
QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper4 = new QueryWrapper<>();
|
|
|
queryWrapper4.eq("windturbine_id", wtId).ge("record_date", beginDate)
|
|
|
- .le("record_date", endDate)
|
|
|
+ .lt("record_date", endDate)
|
|
|
.orderByAsc("record_date");
|
|
|
List<ProEconEquipmentInfoDay4> wtday4ls = proEconEquipmentInfoDay4Service.list(queryWrapper4);
|
|
|
ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
|
|
|
@@ -1285,22 +1293,22 @@ public class SingleAnalysisService {
|
|
|
}
|
|
|
|
|
|
List<TurbineInfoDay> turbineSingle = turbineInfoDayService.getTurbineSingleList(wtId, beginDate, endDate);
|
|
|
- Map<Date, TurbineInfoDay> col= turbineSingle.stream().collect(Collectors.toMap(TurbineInfoDay::getRecordDate, Function.identity()));
|
|
|
+ Map<Date, TurbineInfoDay> col = turbineSingle.stream().collect(Collectors.toMap(TurbineInfoDay::getRecordDate, Function.identity()));
|
|
|
List<SingleAnalysisVo> ff = map.get("ff").stream().collect(Collectors.toList());
|
|
|
List<SingleAnalysisVo> ws = map.get("ws").stream().collect(Collectors.toList());
|
|
|
List<SingleAnalysisVo> jd = map.get("jd").stream().collect(Collectors.toList());
|
|
|
ff.forEach(f -> {
|
|
|
TurbineInfoDay tb = col.get(f.getRecorddate());
|
|
|
- f.setFdl(NumberUtil.round(tb.getRfdl() /1000 , 2).doubleValue());
|
|
|
+ f.setFdl(NumberUtil.round(tb.getRfdl() / 1000, 2).doubleValue());
|
|
|
f.setFs(NumberUtil.round(tb.getPjfs(), 2).doubleValue());
|
|
|
});
|
|
|
ws.forEach(w -> {
|
|
|
TurbineInfoDay tb = col.get(w.getRecorddate());
|
|
|
- w.setSlss(NumberUtil.round(tb.getSlss() /1000, 2).doubleValue());
|
|
|
- w.setXnss(NumberUtil.round(tb.getXnss() /1000, 2).doubleValue());
|
|
|
- w.setXdss(NumberUtil.round(tb.getXdss() /1000, 2).doubleValue());
|
|
|
- w.setJxss(NumberUtil.round(tb.getJhjxss() /1000, 2).doubleValue());
|
|
|
- w.setGzss(NumberUtil.round(tb.getGzss() /1000, 2).doubleValue());
|
|
|
+ w.setSlss(NumberUtil.round(tb.getSlss() / 1000, 2).doubleValue());
|
|
|
+ w.setXnss(NumberUtil.round(tb.getXnss() / 1000, 2).doubleValue());
|
|
|
+ w.setXdss(NumberUtil.round(tb.getXdss() / 1000, 2).doubleValue());
|
|
|
+ w.setJxss(NumberUtil.round(tb.getJhjxss() / 1000, 2).doubleValue());
|
|
|
+ w.setGzss(NumberUtil.round(tb.getGzss() / 1000, 2).doubleValue());
|
|
|
});
|
|
|
jd.forEach(j -> {
|
|
|
TurbineInfoDay tb = col.get(j.getRecorddate());
|
|
|
@@ -1574,10 +1582,16 @@ public class SingleAnalysisService {
|
|
|
|
|
|
|
|
|
public SingleAnalysisVo SingleAnalysisTurbineinfoday(String wtId, String year, String month, SingleAnalysisVo byzb) {
|
|
|
+ LocalDate now=LocalDate.now();
|
|
|
+ int yearCurrent = now.getYear();
|
|
|
+ int monthCurrent = now.getMonthValue();
|
|
|
String date = year + "-" + month;
|
|
|
QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
|
|
|
qw.lambda().eq(TurbineInfoDay::getTurbineId, wtId)
|
|
|
.apply("to_char(record_date,'YYYY-MM')='" + date + "'");
|
|
|
+ if (Integer.parseInt(year) == yearCurrent && Integer.parseInt(month) == monthCurrent) {
|
|
|
+ qw.lambda().lt(TurbineInfoDay::getRecordDate,now);
|
|
|
+ }
|
|
|
List<TurbineInfoDay> list = turbineInfoDayService.list(qw);
|
|
|
double rfdl = list.stream().mapToDouble(TurbineInfoDay::getRfdl).sum();
|
|
|
byzb.setFdl(NumberUtil.round(rfdl / 1000, 2).doubleValue());
|
|
|
@@ -1609,6 +1623,8 @@ public class SingleAnalysisService {
|
|
|
byzb.setLyxs(NumberUtil.round(sblyxs, 2).doubleValue());
|
|
|
double sbklyl = list.stream().mapToDouble(TurbineInfoDay::getKlyl).average().orElse(0.0);
|
|
|
byzb.setSbklyl(NumberUtil.round(sbklyl, 2).doubleValue());
|
|
|
+ double yxfss = list.stream().mapToDouble(TurbineInfoDay::getYxfss).sum();
|
|
|
+ byzb.setYxfss(NumberUtil.round(yxfss, 2).doubleValue());
|
|
|
return byzb;
|
|
|
}
|
|
|
}
|