|
@@ -1,5 +1,7 @@
|
|
|
package com.gyee.runeconomy.service.specific;
|
|
|
|
|
|
+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;
|
|
|
import com.gyee.common.util.DateUtils;
|
|
@@ -9,8 +11,10 @@ import com.gyee.common.vo.specific.SpecificCenterVo;
|
|
|
import com.gyee.common.vo.specific.SpecificTarget;
|
|
|
import com.gyee.common.vo.specific.SpecificTargetVo;
|
|
|
import com.gyee.common.vo.specific.SpecificTopVo;
|
|
|
+import com.gyee.runeconomy.entity.StationInfoMonth;
|
|
|
import com.gyee.runeconomy.init.CacheContext;
|
|
|
import com.gyee.runeconomy.model.auto.*;
|
|
|
+import com.gyee.runeconomy.service.IStationInfoMonthService;
|
|
|
import com.gyee.runeconomy.service.TokenService;
|
|
|
import com.gyee.runeconomy.service.auto.*;
|
|
|
import com.gyee.runeconomy.service.bmk.BenchmarkingService;
|
|
@@ -22,6 +26,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.text.ParseException;
|
|
|
import java.time.Instant;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -53,6 +58,10 @@ public class SpecificService {
|
|
|
@Resource
|
|
|
private ITurbineInfoDayService iTurbineInfoDayService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IStationInfoMonthService stationInfoMonthService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取专题分析上面部分
|
|
|
*
|
|
@@ -1188,7 +1197,7 @@ public class SpecificService {
|
|
|
public List<SpecificTarget> fnlylList(String companys, String type, String year) {
|
|
|
//获取年份所有当月的数据
|
|
|
QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
|
|
|
- currentqw.select("station_id,max(record_date) record_date,sum(rfdl) rfdl,sum(llfdl) llfdl");
|
|
|
+ currentqw.select("station_id,max(record_date) record_date,avg(fnlyl) fnlyl");
|
|
|
currentqw.eq("to_char(record_date,'yyyy')", year);
|
|
|
if (type.equals("-1")) {
|
|
|
currentqw.like("station_id", "_FDC_");
|
|
@@ -1197,11 +1206,6 @@ public class SpecificService {
|
|
|
}
|
|
|
currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
|
|
|
List<TurbineInfoDay> currentList = iTurbineInfoDayService.list(currentqw);
|
|
|
-// currentqw.clear();
|
|
|
-// currentqw.select("station_id,max(record_date) record_date,sum(rfdl) rfdl,sum(llfdl) llfdl");
|
|
|
-// currentqw.eq("to_char(record_date,'yyyy')", year);
|
|
|
-// currentqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
|
|
|
-// currentList.addAll(iTurbineInfoDayService.list(currentqw));
|
|
|
int subYear = Integer.parseInt(year) - 1;
|
|
|
QueryWrapper<TurbineInfoDay> sameperiodqw = new QueryWrapper<>();
|
|
|
sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl) rfdl,sum(llfdl) llfdl");
|
|
@@ -1213,13 +1217,6 @@ public class SpecificService {
|
|
|
sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
|
|
|
sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
|
|
|
List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
|
|
|
-// sameperiodqw.clear();
|
|
|
-// sameperiodqw.select("station_id,max(record_date) record_date,sum(rfdl) rfdl,sum(llfdl) llfdl");
|
|
|
-// sameperiodqw.eq("station_id", CacheContext.wplsf.get(0).getId());
|
|
|
-// sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
|
|
|
-// sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
|
|
|
-// sameperiodList.addAll(iTurbineInfoDayService.list(sameperiodqw));
|
|
|
-
|
|
|
//合并当月与同期数据为返回结果
|
|
|
List<SpecificTargetVo> resultList = new ArrayList<>();
|
|
|
|
|
@@ -1227,24 +1224,12 @@ public class SpecificService {
|
|
|
SpecificTargetVo vo = new SpecificTargetVo();
|
|
|
String wpid = i.getStationId();
|
|
|
vo.setWpid(wpid);
|
|
|
-// if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
|
|
|
-// vo.setWpname(CacheContext.cpmap.get(companys).getAname());
|
|
|
-// } else if (wpid.contains("_RGN")) {
|
|
|
-// vo.setWpname(CacheContext.rgmap.get(companys).getAname());
|
|
|
-// } else {
|
|
|
vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
-// }
|
|
|
vo.setYear(DateUtils.getYear(i.getRecordDate()));
|
|
|
vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
|
|
|
-// vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? i.getRfdl().doubleValue() / i.getLlfdl().doubleValue() * 100 : 0, 2));
|
|
|
- double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
|
|
|
- double rfdl = i.getRfdl() != null ? i.getRfdl().doubleValue() : 0.0;
|
|
|
- if (llfdl != 0) {
|
|
|
- Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
|
|
|
- vo.setCurrent(calculatedValue);
|
|
|
- } else {
|
|
|
- vo.setCurrent(0.0);
|
|
|
- }
|
|
|
+ double fnlyl = i.getFnlyl() != null ? i.getFnlyl() : 0.0;
|
|
|
+ double fnl = NumberUtil.round(fnlyl, 2).doubleValue();
|
|
|
+ vo.setCurrent(fnl);
|
|
|
resultList.add(vo);
|
|
|
});
|
|
|
resultList.stream().forEach(i -> {
|
|
@@ -1253,15 +1238,9 @@ public class SpecificService {
|
|
|
.findFirst();
|
|
|
if (optional.isPresent()) {
|
|
|
TurbineInfoDay tqinfoday = optional.get();
|
|
|
-// i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getLlfdl().doubleValue() != 0 ? tqinfoday.getRfdl().doubleValue() / tqinfoday.getLlfdl().doubleValue() * 100 : 0, 2));
|
|
|
- double llfdl = tqinfoday.getLlfdl() != null ? tqinfoday.getLlfdl().doubleValue() : 0.0;
|
|
|
- double rfdl = tqinfoday.getRfdl() != null ? tqinfoday.getRfdl().doubleValue() : 0.0;
|
|
|
- if (llfdl != 0) {
|
|
|
- Double calculatedValue = DoubleUtils.keepPrecision(rfdl / llfdl * 100, 2);
|
|
|
- i.setSameperiod(calculatedValue);
|
|
|
- } else {
|
|
|
- i.setSameperiod(0.0);
|
|
|
- }
|
|
|
+ double fnlyl = tqinfoday.getFnlyl() != null ? tqinfoday.getFnlyl() : 0.0;
|
|
|
+ double fnl = NumberUtil.round(fnlyl, 2).doubleValue();
|
|
|
+ i.setSameperiod(fnl);
|
|
|
i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
|
|
|
} else {
|
|
|
i.setSameperiod(0.0);
|
|
@@ -1292,14 +1271,8 @@ public class SpecificService {
|
|
|
SpecificTarget vo = new SpecificTarget();
|
|
|
vo.setWpid(wpid);
|
|
|
int orderNum = 100;
|
|
|
-// if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
|
|
|
-// vo.setWpname(CacheContext.cpmap.get(companys).getAname());
|
|
|
-// } else if (wpid.contains("_RGN")) {
|
|
|
-// vo.setWpname(CacheContext.rgmap.get(companys).getAname());
|
|
|
-// } else {
|
|
|
vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
|
|
|
-// }
|
|
|
vo.setOrderNum(orderNum);
|
|
|
List<SpecificTargetVo> tempList = new ArrayList<>();
|
|
|
|
|
@@ -1310,13 +1283,7 @@ public class SpecificService {
|
|
|
} else {
|
|
|
SpecificTargetVo vo1 = new SpecificTargetVo();
|
|
|
vo1.setWpid(wpid);
|
|
|
-// if (wpid.contains("_ZGS") || wpid.contains("_FGS" + type)) {
|
|
|
-// vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
|
|
|
-// } else if (wpid.contains("_RGN")) {
|
|
|
-// vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
|
|
|
-// } else {
|
|
|
vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
-// }
|
|
|
vo1.setYear(Integer.parseInt(year));
|
|
|
vo1.setMonth(x);
|
|
|
tempList.add(vo1);
|
|
@@ -2865,7 +2832,7 @@ public class SpecificService {
|
|
|
} else {
|
|
|
currentqw.like("station_id", "_GDC_");
|
|
|
}
|
|
|
- sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear-1));
|
|
|
+ sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear - 1));
|
|
|
sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),station_id");
|
|
|
List<TurbineInfoDay> sameperiodList = iTurbineInfoDayService.list(sameperiodqw);
|
|
|
|
|
@@ -2879,7 +2846,7 @@ public class SpecificService {
|
|
|
vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
vo.setYear(DateUtils.getYear(i.getRecordDate()));
|
|
|
vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
|
|
|
- vo.setCurrent(i.getLyxs()/50);
|
|
|
+ vo.setCurrent(i.getLyxs() / 50);
|
|
|
resultList.add(vo);
|
|
|
});
|
|
|
resultList.stream().forEach(i -> {
|
|
@@ -2890,7 +2857,7 @@ public class SpecificService {
|
|
|
|
|
|
if (optional.isPresent()) {
|
|
|
TurbineInfoDay tqinfoday = optional.get();
|
|
|
- i.setSameperiod(tqinfoday.getLyxs()/50);
|
|
|
+ i.setSameperiod(tqinfoday.getLyxs() / 50);
|
|
|
i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
|
|
|
} else {
|
|
|
i.setSameperiod(0.0);
|
|
@@ -2951,6 +2918,7 @@ public class SpecificService {
|
|
|
|
|
|
return resultendList;
|
|
|
}
|
|
|
+
|
|
|
public List<SpecificTarget> lyxsList3(String companys, String type, String year) {
|
|
|
//获取年份所有当月的数据
|
|
|
QueryWrapper<StationInfoDay> currentqw = new QueryWrapper<>();
|
|
@@ -3337,8 +3305,8 @@ public class SpecificService {
|
|
|
// }
|
|
|
// Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
|
|
|
// Date date2 = Date.from(instant);
|
|
|
- vo.setYear(i.getRecordDate().getYear()+1900);
|
|
|
- vo.setMonth(i.getRecordDate().getMonth()+1);
|
|
|
+ vo.setYear(i.getRecordDate().getYear() + 1900);
|
|
|
+ vo.setMonth(i.getRecordDate().getMonth() + 1);
|
|
|
// vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? (i.getGzss().doubleValue()) / i.getLlfdl().doubleValue() * 100 : 0, 2));
|
|
|
double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
|
|
|
double rfdl = i.getGzss() != null ? i.getGzss().doubleValue() : 0.0;
|
|
@@ -3777,8 +3745,8 @@ public class SpecificService {
|
|
|
} else {
|
|
|
vo.setCurrent(0.0);
|
|
|
}
|
|
|
- vo.setYear(i.getRecordDate().getYear()+1900);
|
|
|
- vo.setMonth(i.getRecordDate().getMonth()+1);
|
|
|
+ vo.setYear(i.getRecordDate().getYear() + 1900);
|
|
|
+ vo.setMonth(i.getRecordDate().getMonth() + 1);
|
|
|
resultList.add(vo);
|
|
|
});
|
|
|
resultList.stream().forEach(i -> {
|
|
@@ -4072,8 +4040,8 @@ public class SpecificService {
|
|
|
// }
|
|
|
// Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
|
|
|
// Date date = Date.from(instant);
|
|
|
- vo.setYear(i.getRecordDate().getYear()+1900);
|
|
|
- vo.setMonth(i.getRecordDate().getMonth()+1);
|
|
|
+ vo.setYear(i.getRecordDate().getYear() + 1900);
|
|
|
+ vo.setMonth(i.getRecordDate().getMonth() + 1);
|
|
|
// vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? (i.getXdss().doubleValue()) / i.getLlfdl().doubleValue() * 100 : 0, 2));
|
|
|
double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
|
|
|
double rfdl = i.getXdss() != null ? i.getXdss().doubleValue() : 0.0;
|
|
@@ -4391,8 +4359,8 @@ public class SpecificService {
|
|
|
}
|
|
|
// Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
|
|
|
// Date date = Date.from(instant);
|
|
|
- vo.setYear(i.getRecordDate().getYear()+1900);
|
|
|
- vo.setMonth(i.getRecordDate().getMonth()+1);
|
|
|
+ vo.setYear(i.getRecordDate().getYear() + 1900);
|
|
|
+ vo.setMonth(i.getRecordDate().getMonth() + 1);
|
|
|
// vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? (i.getXnss().doubleValue()) / i.getLlfdl().doubleValue() * 100 : 0, 2));
|
|
|
double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
|
|
|
double rfdl = i.getXnss() != null ? i.getXnss().doubleValue() : 0.0;
|
|
@@ -4713,8 +4681,8 @@ public class SpecificService {
|
|
|
// }
|
|
|
// Instant instant = i.getRecordDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
|
|
|
// Date date = Date.from(instant);
|
|
|
- vo.setYear(i.getRecordDate().getYear()+1900);
|
|
|
- vo.setMonth(i.getRecordDate().getMonth()+1);
|
|
|
+ vo.setYear(i.getRecordDate().getYear() + 1900);
|
|
|
+ vo.setMonth(i.getRecordDate().getMonth() + 1);
|
|
|
// vo.setCurrent(DoubleUtils.keepPrecision(i.getLlfdl().doubleValue() != 0 ? (i.getSlss().doubleValue()) / i.getLlfdl().doubleValue() * 100 : 0, 2));
|
|
|
double llfdl = i.getLlfdl() != null ? i.getLlfdl().doubleValue() : 0.0;
|
|
|
double rfdl = i.getSlss() != null ? i.getSlss().doubleValue() : 0.0;
|
|
@@ -5261,7 +5229,7 @@ public class SpecificService {
|
|
|
return resultendList;
|
|
|
}
|
|
|
|
|
|
- public List<SpecificTarget> mtbfList(String companys, String type, String year) {
|
|
|
+ public List<SpecificTarget> mtbfList2(String companys, String type, String year) {
|
|
|
|
|
|
//获取年份所有当月的数据
|
|
|
QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
|
|
@@ -5408,7 +5376,7 @@ public class SpecificService {
|
|
|
return resultendList;
|
|
|
}
|
|
|
|
|
|
- public List<SpecificTarget> mttrList(String companys, String type, String year) {
|
|
|
+ public List<SpecificTarget> mttrList2(String companys, String type, String year) {
|
|
|
//获取年份所有当月的数据
|
|
|
QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
|
|
|
currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
|
|
@@ -5554,6 +5522,198 @@ public class SpecificService {
|
|
|
return resultendList;
|
|
|
}
|
|
|
|
|
|
+ public List<SpecificTarget> mtbfList(String companys, String type, String year) {
|
|
|
+ List<StationInfoMonth> list = stationInfoMonthService.list();
|
|
|
+ //合并当月与同期数据为返回结果
|
|
|
+ List<SpecificTargetVo> resultList = new ArrayList<>();
|
|
|
+ List<StationInfoMonth> currentList = list.stream()
|
|
|
+ .filter(item -> {
|
|
|
+ Date date = item.getRecordDate();
|
|
|
+ return date != null
|
|
|
+ && DateUtil.year(date) == DateUtil.thisYear();
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<StationInfoMonth> samePeriodList = list.stream()
|
|
|
+ .filter(item -> {
|
|
|
+ Date date = item.getRecordDate();
|
|
|
+ return date != null
|
|
|
+ && DateUtil.year(date) == DateUtil.thisYear() - 1;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ currentList.forEach(i -> {
|
|
|
+ SpecificTargetVo vo = new SpecificTargetVo();
|
|
|
+ String wpid = i.getStationId();
|
|
|
+ vo.setWpid(wpid);
|
|
|
+ vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
+ Date date = i.getRecordDate();
|
|
|
+ LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ vo.setYear(localDate.getYear());
|
|
|
+ vo.setMonth(localDate.getMonth().getValue());
|
|
|
+ vo.setCurrent(DoubleUtils.keepPrecision(i.getMtbf(), 2));
|
|
|
+ resultList.add(vo);
|
|
|
+ });
|
|
|
+ resultList.forEach(i -> {
|
|
|
+ Optional<StationInfoMonth> samePeriod = samePeriodList.stream().filter(s -> s.getRecordDate().getYear() == i.getYear() && s.getRecordDate().getMonth() == i.getMonth()).findFirst();
|
|
|
+ if (samePeriod.isPresent()) {
|
|
|
+ StationInfoMonth stationInfo = samePeriod.get();
|
|
|
+ i.setSameperiod(stationInfo.getMtbf());
|
|
|
+ i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
|
|
|
+ } else {
|
|
|
+ i.setSameperiod(0.0);
|
|
|
+ i.setCompare(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ List<SpecificTarget> resultendList = new ArrayList<>();
|
|
|
+ Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
|
|
|
+ resultList.forEach(i -> {
|
|
|
+ if (map.containsKey(i.getWpid())) {
|
|
|
+ Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
|
|
|
+ if (!integerListMap.containsKey(i.getMonth())) {
|
|
|
+ map.get(i.getWpid()).put(i.getMonth(), i);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
|
|
|
+ tempMap.put(i.getMonth(), i);
|
|
|
+ map.put(i.getWpid(), tempMap);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Set<String> wpids = map.keySet();
|
|
|
+ wpids.forEach(wpid -> {
|
|
|
+ SpecificTarget vo = new SpecificTarget();
|
|
|
+ vo.setWpid(wpid);
|
|
|
+ int orderNum = 100;
|
|
|
+ vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
+ orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
|
|
|
+ vo.setOrderNum(orderNum);
|
|
|
+ List<SpecificTargetVo> tempList = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
|
|
|
+ for (int x = 1; x <= 12; x++) {
|
|
|
+ if (listMap.containsKey(x)) {
|
|
|
+ tempList.add(listMap.get(x));
|
|
|
+ } else {
|
|
|
+ SpecificTargetVo vo1 = new SpecificTargetVo();
|
|
|
+ vo1.setWpid(wpid);
|
|
|
+ vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
+ vo1.setYear(Integer.parseInt(year));
|
|
|
+ vo1.setMonth(x);
|
|
|
+ tempList.add(vo1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setTargetList(tempList);
|
|
|
+ resultendList.add(vo);
|
|
|
+ SpecificTarget vo2 = new SpecificTarget();
|
|
|
+ vo2.setWpid(vo.getWpid());
|
|
|
+ vo2.setTargetList(vo.getTargetList());
|
|
|
+ vo2.setOrderNum(vo.getOrderNum() + 1);
|
|
|
+ vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
|
|
|
+ resultendList.add(vo2);
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
|
|
|
+ return resultendList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<SpecificTarget> mttrList(String companys, String type, String year) {
|
|
|
+ List<StationInfoMonth> list = stationInfoMonthService.list();
|
|
|
+ //合并当月与同期数据为返回结果
|
|
|
+ List<SpecificTargetVo> resultList = new ArrayList<>();
|
|
|
+ List<StationInfoMonth> currentList = list.stream()
|
|
|
+ .filter(item -> {
|
|
|
+ Date date = item.getRecordDate();
|
|
|
+ return date != null
|
|
|
+ && DateUtil.year(date) == DateUtil.thisYear();
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<StationInfoMonth> samePeriodList = list.stream()
|
|
|
+ .filter(item -> {
|
|
|
+ Date date = item.getRecordDate();
|
|
|
+ return date != null
|
|
|
+ && DateUtil.year(date) == DateUtil.thisYear() - 1;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ currentList.forEach(i -> {
|
|
|
+ SpecificTargetVo vo = new SpecificTargetVo();
|
|
|
+ String wpid = i.getStationId();
|
|
|
+ vo.setWpid(wpid);
|
|
|
+ vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
+ Date date = i.getRecordDate();
|
|
|
+ LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ vo.setYear(localDate.getYear());
|
|
|
+ vo.setMonth(localDate.getMonth().getValue());
|
|
|
+ vo.setCurrent(DoubleUtils.keepPrecision(i.getMttr(), 2));
|
|
|
+ resultList.add(vo);
|
|
|
+ });
|
|
|
+ resultList.forEach(i -> {
|
|
|
+ Optional<StationInfoMonth> samePeriod = samePeriodList.stream().filter(s -> s.getRecordDate().getYear() == i.getYear() && s.getRecordDate().getMonth() == i.getMonth()).findFirst();
|
|
|
+ if (samePeriod.isPresent()) {
|
|
|
+ StationInfoMonth stationInfo = samePeriod.get();
|
|
|
+ i.setSameperiod(stationInfo.getMttr());
|
|
|
+ i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
|
|
|
+ } else {
|
|
|
+ i.setSameperiod(0.0);
|
|
|
+ i.setCompare(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ List<SpecificTarget> resultendList = new ArrayList<>();
|
|
|
+ Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
|
|
|
+ resultList.forEach(i -> {
|
|
|
+ if (map.containsKey(i.getWpid())) {
|
|
|
+ Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
|
|
|
+ if (!integerListMap.containsKey(i.getMonth())) {
|
|
|
+ map.get(i.getWpid()).put(i.getMonth(), i);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
|
|
|
+ tempMap.put(i.getMonth(), i);
|
|
|
+ map.put(i.getWpid(), tempMap);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Set<String> wpids = map.keySet();
|
|
|
+ wpids.forEach(wpid -> {
|
|
|
+ SpecificTarget vo = new SpecificTarget();
|
|
|
+ vo.setWpid(wpid);
|
|
|
+ int orderNum = 100;
|
|
|
+ vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
+ orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
|
|
|
+ vo.setOrderNum(orderNum);
|
|
|
+ List<SpecificTargetVo> tempList = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
|
|
|
+ for (int x = 1; x <= 12; x++) {
|
|
|
+ if (listMap.containsKey(x)) {
|
|
|
+ tempList.add(listMap.get(x));
|
|
|
+ } else {
|
|
|
+ SpecificTargetVo vo1 = new SpecificTargetVo();
|
|
|
+ vo1.setWpid(wpid);
|
|
|
+ vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
|
|
|
+ vo1.setYear(Integer.parseInt(year));
|
|
|
+ vo1.setMonth(x);
|
|
|
+ tempList.add(vo1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setTargetList(tempList);
|
|
|
+ resultendList.add(vo);
|
|
|
+ SpecificTarget vo2 = new SpecificTarget();
|
|
|
+ vo2.setWpid(vo.getWpid());
|
|
|
+ vo2.setTargetList(vo.getTargetList());
|
|
|
+ vo2.setOrderNum(vo.getOrderNum() + 1);
|
|
|
+ vo2.setWpname(CacheContext.cpmap.get(companys).getAname());
|
|
|
+ resultendList.add(vo2);
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
|
|
|
+ return resultendList;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public List<SpecificTarget> xtxlList(String companys, String type, String year) {
|
|
|
//获取年份所有当月的数据
|