|
@@ -1,6 +1,7 @@
|
|
|
package com.gyee.runeconomy.service.homepage;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.gyee.common.util.DateUtils;
|
|
|
import com.gyee.common.vo.healthmanager.CompareVo;
|
|
@@ -135,6 +136,8 @@ public class EconomyPointHomePageService {
|
|
|
private Map<String, BigDecimal> yfdlCal = new HashMap<>();
|
|
|
private Map<String, BigDecimal> yllfdlCal = new HashMap<>();
|
|
|
private Map<Integer, BigDecimal> nfdlCal = new HashMap<>();
|
|
|
+
|
|
|
+ private Map<Integer, Double> nfdlLastCal = new HashMap<>();
|
|
|
private Map<Integer, BigDecimal> nllfdlCal = new HashMap<>();
|
|
|
private LocalDate lastCalDate;
|
|
|
|
|
@@ -1910,18 +1913,10 @@ public class EconomyPointHomePageService {
|
|
|
Map<String, Object> allmap = new HashMap<>();
|
|
|
Map<String, Object> zbtqdb = new HashMap<>();
|
|
|
List<ColumnVo> ls1 = new ArrayList<>();
|
|
|
- ColumnVo cl1 = new ColumnVo();
|
|
|
- cl1.setName("指标名称");
|
|
|
- cl1.setField("wtId");
|
|
|
- ColumnVo cl2 = new ColumnVo();
|
|
|
- cl2.setName(String.valueOf(LocalDate.now().getYear()));
|
|
|
- cl2.setField("recodedate");
|
|
|
- ColumnVo cl3 = new ColumnVo();
|
|
|
- cl3.setName(String.valueOf(LocalDate.now().getYear() - 1));
|
|
|
- cl3.setField("recodedate2");
|
|
|
- ColumnVo cl4 = new ColumnVo();
|
|
|
- cl4.setName("涨跌%");
|
|
|
- cl4.setField("operation");
|
|
|
+ ColumnVo cl1 = new ColumnVo("指标名称","wtId");
|
|
|
+ ColumnVo cl2 = new ColumnVo(String.valueOf(LocalDate.now().getYear()),"recodedate");
|
|
|
+ ColumnVo cl3 = new ColumnVo(String.valueOf(LocalDate.now().getYear() - 1),"recodedate2");
|
|
|
+ ColumnVo cl4 = new ColumnVo("涨跌%","operation");
|
|
|
ls1.add(cl1);
|
|
|
ls1.add(cl2);
|
|
|
ls1.add(cl3);
|
|
@@ -1930,6 +1925,7 @@ public class EconomyPointHomePageService {
|
|
|
List<GeneratingCapacityVo> ls = new ArrayList<>();
|
|
|
Double dayFdl = dayFdlCal(now);
|
|
|
Double dayLlfdl = dayLldlCal(now);
|
|
|
+
|
|
|
GeneratingCapacityVo rfdl = new GeneratingCapacityVo();
|
|
|
rfdl.setName("日发电量");
|
|
|
rfdl.setValue(Double.valueOf(String.format("%.2f", dayFdl)));
|
|
@@ -1962,61 +1958,38 @@ public class EconomyPointHomePageService {
|
|
|
thisYear.select("station_id,max(record_date) as record_date,sum(swdl) as swdl,sum(gwdl) as gwdl,sum(cydl) as cydl,sum(zhcydl) as zhcydl")
|
|
|
.apply("to_char(record_date,'yyyy') = '" + (LocalDate.now().getYear()) + "'")
|
|
|
.groupBy("station_id");
|
|
|
- List<StationInfoDay> list = iStationInfoDayService.list(thisYear);
|
|
|
+ List<StationInfoDay> stationInfoDayThisYearLs = iStationInfoDayService.list(thisYear);
|
|
|
|
|
|
QueryWrapper<StationInfoDay> lastYear = new QueryWrapper<>();
|
|
|
lastYear.select("station_id,max(record_date) as record_date,sum(swdl) as swdl,sum(gwdl) as gwdl,sum(cydl) as cydl,sum(zhcydl) as zhcydl")
|
|
|
.apply("record_date<= '" + LocalDate.now().minusYears(1) + "'")
|
|
|
.groupBy("station_id");
|
|
|
- List<StationInfoDay> list2 = iStationInfoDayService.list(lastYear);
|
|
|
-
|
|
|
- List<ComparetqVo> ls2 = new ArrayList<>();
|
|
|
- ComparetqVo cv = new ComparetqVo();
|
|
|
- cv.setWtId("年发电量");
|
|
|
- ComparetqVo cv1 = new ComparetqVo();
|
|
|
- cv1.setWtId("年上网电量");
|
|
|
- ComparetqVo cv2 = new ComparetqVo();
|
|
|
- cv2.setWtId("年购网电量");
|
|
|
- ComparetqVo cv4 = new ComparetqVo();
|
|
|
- cv4.setWtId("年场用电量");
|
|
|
- cv.setRecodedate(nfdl.getValue());
|
|
|
-
|
|
|
- if (null == list2 || list2.isEmpty()) {
|
|
|
- cv1.setRecodedate2(0);
|
|
|
- cv1.setOperation(100);
|
|
|
- cv2.setRecodedate2(0);
|
|
|
- cv2.setOperation(100);
|
|
|
- cv4.setRecodedate2(0);
|
|
|
- cv4.setOperation(100);
|
|
|
- } else {
|
|
|
- cv1.setRecodedate2(list2.get(0).getSwdl());
|
|
|
- cv2.setRecodedate2(list2.get(0).getGwdl());
|
|
|
- cv4.setRecodedate2(list2.get(0).getCydl());
|
|
|
- }
|
|
|
-
|
|
|
- if (null == list || list.isEmpty()) {
|
|
|
- cv1.setRecodedate(0);
|
|
|
- cv1.setOperation(-100);
|
|
|
- cv2.setRecodedate(0);
|
|
|
- cv2.setOperation(-100);
|
|
|
- cv4.setRecodedate(0);
|
|
|
- cv4.setOperation(-100);
|
|
|
- } else {
|
|
|
- cv1.setRecodedate(list.get(0).getSwdl());
|
|
|
- cv1.setOperation(100);
|
|
|
- cv2.setRecodedate(list.get(0).getGwdl());
|
|
|
- cv2.setOperation(100);
|
|
|
- cv4.setRecodedate(list.get(0).getCydl());
|
|
|
- cv4.setOperation(100);
|
|
|
- }
|
|
|
-
|
|
|
- ls2.add(cv);
|
|
|
- ls2.add(cv1);
|
|
|
- ls2.add(cv2);
|
|
|
- ls2.add(cv4);
|
|
|
+ List<StationInfoDay> stationInfoDayLastYearLs = iStationInfoDayService.list(lastYear);
|
|
|
+
|
|
|
+ //主要经济指标同期对比
|
|
|
+ List<ComparetqVo> compareTqLs = new ArrayList<>();
|
|
|
+ ComparetqVo cvNfdl = new ComparetqVo("年发电量",nfdl.getValue(),nfdlLastCal.get(now.getYear()-1),0.0);
|
|
|
+ ComparetqVo cvNswdl = new ComparetqVo("年上网电量",0.0,0.0,0.0);
|
|
|
+ ComparetqVo cvNgwdl = new ComparetqVo("年购网电量",0.0,0.0,0.0);
|
|
|
+ ComparetqVo cvNcydl = new ComparetqVo("年场用电量",0.0,0.0,0.0);
|
|
|
+
|
|
|
+ //添加同期和本期的数据
|
|
|
+ addData(stationInfoDayLastYearLs,cvNswdl,cvNgwdl,cvNcydl,true);
|
|
|
+ addData(stationInfoDayThisYearLs,cvNswdl,cvNgwdl,cvNcydl,false);
|
|
|
+
|
|
|
+ //计算同比增长率
|
|
|
+ compareRate(cvNfdl,cvNfdl.getRecodedate(),cvNfdl.getRecodedate2());
|
|
|
+ compareRate(cvNswdl,cvNswdl.getRecodedate(),cvNswdl.getRecodedate2());
|
|
|
+ compareRate(cvNgwdl,cvNgwdl.getRecodedate(),cvNgwdl.getRecodedate2());
|
|
|
+ compareRate(cvNcydl,cvNcydl.getRecodedate(),cvNcydl.getRecodedate2());
|
|
|
+
|
|
|
+ compareTqLs.add(cvNfdl);
|
|
|
+ compareTqLs.add(cvNswdl);
|
|
|
+ compareTqLs.add(cvNgwdl);
|
|
|
+ compareTqLs.add(cvNcydl);
|
|
|
|
|
|
zbtqdb.put("column", ls1);
|
|
|
- zbtqdb.put("data", ls2);
|
|
|
+ zbtqdb.put("data", compareTqLs);
|
|
|
|
|
|
allmap.put("fdl", ls);
|
|
|
allmap.put("zbtqdb", zbtqdb);
|
|
@@ -2024,6 +1997,45 @@ public class EconomyPointHomePageService {
|
|
|
return allmap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算同比增长率
|
|
|
+ */
|
|
|
+ private void compareRate(ComparetqVo wtId,double recodedate, double recodedate2) {
|
|
|
+ if (recodedate2 != 0.0) {
|
|
|
+ wtId.setOperation(NumberUtil.round((recodedate-recodedate2) / recodedate2*100,2).doubleValue());
|
|
|
+ }else {
|
|
|
+ wtId.setOperation(100);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加同期和本期的数据
|
|
|
+ */
|
|
|
+ private void addData(List<StationInfoDay> stationInfoDays,ComparetqVo cvNswdl,ComparetqVo cvNgwdl,ComparetqVo cvNcydl, boolean isLastYear) {
|
|
|
+ if (stationInfoDays != null && !stationInfoDays.isEmpty()) {
|
|
|
+ StationInfoDay stationInfoDay = stationInfoDays.get(0);
|
|
|
+ if (isLastYear) {
|
|
|
+ cvNswdl.setRecodedate2(NumberUtil.round(stationInfoDay.getSwdl() / 1000.0,2).doubleValue());
|
|
|
+ cvNgwdl.setRecodedate2(NumberUtil.round(stationInfoDay.getGwdl() / 1000.0,2).doubleValue());
|
|
|
+ cvNcydl.setRecodedate2(NumberUtil.round(stationInfoDay.getCydl() / 100.0,2).doubleValue());
|
|
|
+ }else {
|
|
|
+ cvNswdl.setRecodedate(NumberUtil.round(stationInfoDay.getSwdl() / 1000.0,2).doubleValue());
|
|
|
+ cvNgwdl.setRecodedate(NumberUtil.round(stationInfoDay.getGwdl() / 1000.0,2).doubleValue());
|
|
|
+ cvNcydl.setRecodedate(NumberUtil.round(stationInfoDay.getCydl() / 100.0,2).doubleValue());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (isLastYear) {
|
|
|
+ cvNswdl.setRecodedate2(0);
|
|
|
+ cvNgwdl.setRecodedate2(0);
|
|
|
+ cvNcydl.setRecodedate2(0);
|
|
|
+ }else {
|
|
|
+ cvNswdl.setRecodedate(0);
|
|
|
+ cvNgwdl.setRecodedate(0);
|
|
|
+ cvNcydl.setRecodedate(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 缓存月、年发电量
|
|
@@ -2033,6 +2045,7 @@ public class EconomyPointHomePageService {
|
|
|
return;
|
|
|
}
|
|
|
LocalDate yesterday = LocalDate.now().atStartOfDay().toLocalDate();
|
|
|
+ Integer intYear = LocalDate.now().getYear();
|
|
|
QueryWrapper<TurbineInfoDay> currentqw = new QueryWrapper<>();
|
|
|
currentqw.select("station_id,SUM(rfdl) AS rfdl,sum(llfdl) as llfdl")
|
|
|
.ge("record_date", LocalDate.now().with(TemporalAdjusters.firstDayOfYear())) // 大于等于今年的第一天
|
|
@@ -2041,19 +2054,34 @@ public class EconomyPointHomePageService {
|
|
|
.groupBy("station_id");
|
|
|
List<TurbineInfoDay> yearData = iTurbineInfoDayService.list(currentqw);
|
|
|
if (yearData.isEmpty()) {
|
|
|
- Integer intYear = LocalDate.now().getYear();
|
|
|
double nfdlc = 0.0;
|
|
|
double nllfdlc = 0.0;
|
|
|
nfdlCal.put(intYear, new BigDecimal(nfdlc));
|
|
|
nllfdlCal.put(intYear, new BigDecimal(nllfdlc));
|
|
|
} else {
|
|
|
- Integer intYear = LocalDate.now().getYear();
|
|
|
Double nfdlc = calDivide(yearData.get(0).getRfdl(), 1000.0);
|
|
|
Double nllfdlc = calDivide(yearData.get(0).getLlfdl(), 1000.0);
|
|
|
nfdlCal.put(intYear, new BigDecimal(nfdlc));
|
|
|
nllfdlCal.put(intYear, new BigDecimal(nllfdlc));
|
|
|
}
|
|
|
currentqw.clear();
|
|
|
+
|
|
|
+ LocalDate lastYear = LocalDate.now().minusYears(1);
|
|
|
+ currentqw.select("station_id,SUM(rfdl) AS rfdl,sum(llfdl) as llfdl")
|
|
|
+ .ge("record_date", LocalDate.now().minusYears(1).with(TemporalAdjusters.firstDayOfYear())) // 大于等于今年的第一天
|
|
|
+ .lt("record_date", lastYear) // 小于去年今天0点的日期
|
|
|
+ .like("station_id", "_FDC_%")
|
|
|
+ .groupBy("station_id");
|
|
|
+ List<TurbineInfoDay> lastYearData = iTurbineInfoDayService.list(currentqw);
|
|
|
+ if (lastYearData.isEmpty()) {
|
|
|
+ double nfdlc = 0.0;
|
|
|
+ nfdlLastCal.put(intYear-1, nfdlc);
|
|
|
+ } else {
|
|
|
+ Double nfdlc = calDivide(lastYearData.get(0).getRfdl(), 1000.0);
|
|
|
+ nfdlLastCal.put(intYear-1, nfdlc);
|
|
|
+ }
|
|
|
+ currentqw.clear();
|
|
|
+
|
|
|
currentqw.select("station_id,MAX(record_date) AS record_date,SUM(rfdl) AS rfdl,SUM(llfdl) as llfdl")
|
|
|
.ge("record_date", LocalDate.now().with(TemporalAdjusters.firstDayOfMonth())) // 大于等于本月的第一天
|
|
|
.lt("record_date", yesterday) // 小于今天0点的日期
|