Browse Source

指标池

malijun 6 months ago
parent
commit
fec0696963

+ 178 - 55
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -1,5 +1,6 @@
 package com.ruoyi;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.thread.ThreadUtil;
@@ -328,61 +329,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
         stationInfoHourService.saveOrUpdateBatch(byHours);
     }
 
-    public void writeReportPool(Date date) {
-        //date当天零点
-        DateTime time = DateUtil.beginOfDay(date);
-        //date昨天零点
-        DateTime time0 = DateUtil.offsetDay(time, -1);
-        DateTime beginOfMonth = DateUtil.beginOfMonth(time0);
-        DateTime beginOfYear = DateUtil.beginOfYear(time0);
-
-        QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
-        wrapper.eq("record_date", time0);
-        List<StationInfoDay> days = stationInfoDayService.list(wrapper);
-        Map<String, StationInfoDay> dayMap = days.stream().collect(Collectors.toMap(StationInfoDay::getStationId, Function.identity()));
-        wrapper = new QueryWrapper<>();
-        wrapper.select("sum(rfdl) rfdl,sum(swdl) swdl,sum(gwdl) gwdl,sum(cydl) cydl,sum(zhcydl) zhcydl,station_id")
-                .between("record_date", beginOfMonth.toJdkDate(), time0.toJdkDate())
-                .groupBy("station_id");
-        List<StationInfoDay> monthDays = stationInfoDayService.list(wrapper);
-        Map<String, StationInfoDay> monthMap = monthDays.stream().collect(Collectors.toMap(StationInfoDay::getStationId, Function.identity()));
-        wrapper = new QueryWrapper<>();
-        wrapper.select("sum(rfdl) rfdl,sum(swdl) swdl,sum(gwdl) gwdl,sum(cydl) cydl,sum(zhcydl) zhcydl,station_id")
-                .between("record_date", beginOfYear.toJdkDate(), time0.toJdkDate())
-                .groupBy("station_id");
-        List<StationInfoDay> yearDays = stationInfoDayService.list(wrapper);
-        Map<String, StationInfoDay> yearMap = yearDays.stream().collect(Collectors.toMap(StationInfoDay::getStationId, Function.identity()));
-        QueryWrapper<ProEconReportIndicatorPool> wrapperrp = new QueryWrapper<>();
-        wrapperrp.eq("record_date", time0).last("and foreign_key_id = windpowerstation_id");
-        List<ProEconReportIndicatorPool> pools = reportIndicatorPoolService.list(wrapperrp);
-//        pools = pools.stream().filter(p -> p.getWindpowerstationId().equals("GJNY_SXGS_ZZ_FDC_STA")).collect(Collectors.toList());
-
-        StationInfoDay day, month, year;
-        List<ProEconReportIndicatorPool> poolList = new ArrayList<>();
-        for (ProEconReportIndicatorPool pool : pools) {
-            String stationId = pool.getWindpowerstationId();
-            day = dayMap.get(stationId);
-            pool.setRfdldb(day.getRfdl().doubleValue());
-            pool.setRswdldb(day.getSwdl().doubleValue());
-            pool.setRgwgwdldb(day.getGwdl().doubleValue());
-            pool.setRfdcydldb(day.getCydl().doubleValue());
-            pool.setRzhcydldb(day.getZhcydl().doubleValue());
-            month = monthMap.get(stationId);
-            pool.setYfdldb(month.getRfdl().doubleValue());
-            pool.setYswdldb(month.getSwdl().doubleValue());
-            pool.setYgwgwdldb(month.getGwdl().doubleValue());
-            pool.setYfdcydldb(month.getCydl().doubleValue());
-            pool.setYzhcydldb(month.getZhcydl().doubleValue());
-            year = yearMap.get(stationId);
-            pool.setNfdldb(year.getRfdl().doubleValue());
-            pool.setNswdldb(year.getSwdl().doubleValue());
-            pool.setNgwgwdldb(year.getGwdl().doubleValue());
-            pool.setNfdcydldb(year.getCydl().doubleValue());
-            pool.setNzhcydldb(year.getZhcydl().doubleValue());
-            poolList.add(pool);
-        }
-        reportIndicatorPoolService.saveOrUpdateBatch(poolList);
-    }
 
     public void calcLineDjlRfdl(Date date) {
         //date当天零点
@@ -1084,6 +1030,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
 
 
     public Map<Double, Double> dataProcessAndFit(PointInfo fsPI, PointInfo glPI, PointInfo ztPI, Map<Double, Double> modelPowerMap, double capacity) {
+        System.out.println("开始拟合");
         List<PointData> fsPds = fsPI.getPointDatas();
         List<PointData> glPds = glPI.getPointDatas();
         List<PointData> ztPds = ztPI.getPointDatas();
@@ -1149,6 +1096,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             System.out.println(ztPI.getSpare());
             System.out.println(e.getMessage());
         }
+        System.out.println("拟合完成"+glyc);
         return glyc;
     }
 
@@ -1457,15 +1405,20 @@ public class JavaFunctionJobHandler extends IJobHandler {
             try {
                 PointInfo turbineZt = calcTurbineDizt2(wtUcPis.get(wtId), latest, start, end, 60);
                 PointInfo turbineAizt = calcTurbineAizt2(aiztMap.get(wtId), collectAi, start, end, 60);
+
+
+
                 Map<Double, Double> fit = new TreeMap<>();
                 double capacity = 2000;
                 if (turbineZt != null) {
+                    System.out.println("数据处理拟合");
                     capacity = map.get(turbineZt.getSpare()).getPowerProduction();
                     fit = dataProcessAndFit(ef, glInfo, turbineZt, CalcCache.bzgl.get(turbineZt.getSpare()), capacity);
 //                fitMap.put(wtId, fit);
                     turbineZt.setPointDatas(null);
                 }
                 if (turbineAizt != null) {
+                    System.out.println("数据处理拟合");
                     capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
                     fit = dataProcessAndFit(ef, glInfo, turbineAizt, CalcCache.bzgl.get(turbineAizt.getSpare()), capacity);
 //                fitMap.put(wtId, fit);
@@ -1477,6 +1430,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 //存redis
 //            stringRedisTemplate.opsForValue().set("glqxnh:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
 
+                System.out.println("拟合曲线的大小"+fit.size()+":"+wtId);
 
                 //符合条件的风速和
                 List<Double> listDouble = new ArrayList<>();
@@ -1613,6 +1567,175 @@ public class JavaFunctionJobHandler extends IJobHandler {
     }
 
 
+    public void writeReportPool(Date date) {
+        //date当天零点
+        DateTime time = DateUtil.beginOfDay(date);
+        //date昨天零点
+        DateTime time0 = DateUtil.offsetDay(time, -1);
+        DateTime beginOfMonth = DateUtil.beginOfMonth(time0);
+        DateTime beginOfYear = DateUtil.beginOfYear(time0);
+
+        QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
+        wrapper.eq("record_date", time0);
+        List<StationInfoDay> days = stationInfoDayService.list(wrapper);
+        Map<String, StationInfoDay> dayMap = days.stream().collect(Collectors.toMap(StationInfoDay::getStationId, Function.identity()));
+        wrapper = new QueryWrapper<>();
+        wrapper.select("sum(rfdl) rfdl,sum(swdl) swdl,sum(gwdl) gwdl,sum(cydl) cydl,sum(zhcydl) zhcydl,station_id")
+                .between("record_date", beginOfMonth.toJdkDate(), time0.toJdkDate())
+                .groupBy("station_id");
+        List<StationInfoDay> monthDays = stationInfoDayService.list(wrapper);
+        Map<String, StationInfoDay> monthMap = monthDays.stream().collect(Collectors.toMap(StationInfoDay::getStationId, Function.identity()));
+        wrapper = new QueryWrapper<>();
+        wrapper.select("sum(rfdl) rfdl,sum(swdl) swdl,sum(gwdl) gwdl,sum(cydl) cydl,sum(zhcydl) zhcydl,station_id")
+                .between("record_date", beginOfYear.toJdkDate(), time0.toJdkDate())
+                .groupBy("station_id");
+        List<StationInfoDay> yearDays = stationInfoDayService.list(wrapper);
+        Map<String, StationInfoDay> yearMap = yearDays.stream().collect(Collectors.toMap(StationInfoDay::getStationId, Function.identity()));
+        QueryWrapper<ProEconReportIndicatorPool> wrapperrp = new QueryWrapper<>();
+        wrapperrp.eq("record_date", time0).last("and foreign_key_id = windpowerstation_id");
+        List<ProEconReportIndicatorPool> pools = reportIndicatorPoolService.list(wrapperrp);
+
+        StationInfoDay day, month, year;
+        List<ProEconReportIndicatorPool> poolList = new ArrayList<>();
+        for (ProEconReportIndicatorPool pool : pools) {
+            String stationId = pool.getWindpowerstationId();
+            day = dayMap.get(stationId);
+            pool.setRfdldb(day.getRfdl().doubleValue());
+            pool.setRswdldb(day.getSwdl().doubleValue());
+            pool.setRgwgwdldb(day.getGwdl().doubleValue());
+            pool.setRfdcydldb(day.getCydl().doubleValue());
+            pool.setRzhcydldb(day.getZhcydl().doubleValue());
+            month = monthMap.get(stationId);
+            pool.setYfdldb(month.getRfdl().doubleValue());
+            pool.setYswdldb(month.getSwdl().doubleValue());
+            pool.setYgwgwdldb(month.getGwdl().doubleValue());
+            pool.setYfdcydldb(month.getCydl().doubleValue());
+            pool.setYzhcydldb(month.getZhcydl().doubleValue());
+            year = yearMap.get(stationId);
+            pool.setNfdldb(year.getRfdl().doubleValue());
+            pool.setNswdldb(year.getSwdl().doubleValue());
+            pool.setNgwgwdldb(year.getGwdl().doubleValue());
+            pool.setNfdcydldb(year.getCydl().doubleValue());
+            pool.setNzhcydldb(year.getZhcydl().doubleValue());
+            poolList.add(pool);
+        }
+        reportIndicatorPoolService.saveOrUpdateBatch(poolList);
+    }
+
+    public void writeReportPoolProject(Date date) {
+        //date当天零点
+        DateTime time = DateUtil.beginOfDay(date);
+        //date昨天零点
+        DateTime time0 = DateUtil.offsetDay(time, -1);
+        DateTime beginOfMonth = DateUtil.beginOfMonth(time0);
+        DateTime beginOfYear = DateUtil.beginOfYear(time0);
+
+        QueryWrapper<LineInfoDay> wrapper = new QueryWrapper<>();
+        wrapper.select("sum(rfdl) rfdl,sum(swdl) swdl,sum(gwdl) gwdl,sum(cydl) cydl,project_id")
+                .eq("record_date", time0)
+                .groupBy("project_id");
+        List<LineInfoDay> days = lineInfoDayService.list(wrapper);
+        Map<String, LineInfoDay> dayMap = days.stream().collect(Collectors.toMap(LineInfoDay::getProjectId, Function.identity()));
+        wrapper = new QueryWrapper<>();
+        wrapper.select("sum(rfdl) rfdl,sum(swdl) swdl,sum(gwdl) gwdl,sum(cydl) cydl,project_id")
+                .between("record_date", beginOfMonth, time0)
+                .groupBy("project_id");
+        List<LineInfoDay> monthDays = lineInfoDayService.list(wrapper);
+        Map<String, LineInfoDay> monthMap = monthDays.stream().collect(Collectors.toMap(LineInfoDay::getProjectId, Function.identity()));
+        wrapper = new QueryWrapper<>();
+        wrapper.select("sum(rfdl) rfdl,sum(swdl) swdl,sum(gwdl) gwdl,sum(cydl) cydl,project_id")
+                .between("record_date", beginOfYear, time0)
+                .groupBy("project_id");
+        List<LineInfoDay> yearDays = lineInfoDayService.list(wrapper);
+        Map<String, LineInfoDay> yearMap = yearDays.stream().collect(Collectors.toMap(LineInfoDay::getProjectId, Function.identity()));
+
+        QueryWrapper<ProEconReportIndicatorPool> wrapperrp = new QueryWrapper<>();
+        wrapperrp.eq("record_date", time0).last("and foreign_key_id = project_id");
+        List<ProEconReportIndicatorPool> pools = reportIndicatorPoolService.list(wrapperrp);
+
+        LineInfoDay day, month, year;
+        List<ProEconReportIndicatorPool> poolList = new ArrayList<>();
+        String projectId;
+        for (ProEconReportIndicatorPool pool : pools) {
+            projectId = pool.getProjectId();
+            day = dayMap.get(projectId);
+            pool.setRfdldb(day.getRfdl().doubleValue());
+            pool.setRswdldb(day.getSwdl().doubleValue());
+            pool.setRgwgwdldb(day.getGwdl().doubleValue());
+            pool.setRfdcydldb(day.getCydl().doubleValue());
+            month = monthMap.get(projectId);
+            pool.setYfdldb(month.getRfdl().doubleValue());
+            pool.setYswdldb(month.getSwdl().doubleValue());
+            pool.setYgwgwdldb(month.getGwdl().doubleValue());
+            pool.setYfdcydldb(month.getCydl().doubleValue());
+            year = yearMap.get(projectId);
+            pool.setNfdldb(year.getRfdl().doubleValue());
+            pool.setNswdldb(year.getSwdl().doubleValue());
+            pool.setNgwgwdldb(year.getGwdl().doubleValue());
+            pool.setNfdcydldb(year.getCydl().doubleValue());
+            poolList.add(pool);
+        }
+        reportIndicatorPoolService.saveOrUpdateBatch(poolList);
+    }
+
+    public void writeReportPoolPjfs(Date date) {
+        //date当天零点
+        DateTime time = DateUtil.beginOfDay(date);
+        //date昨天零点
+        DateTime time0 = DateUtil.offsetDay(time, -1);
+        DateTime beginOfMonth = DateUtil.beginOfMonth(time0);
+        DateTime beginOfYear = DateUtil.beginOfYear(time0);
+
+        QueryWrapper<TurbineInfoDay> wrapper = new QueryWrapper<>();
+        wrapper.select("avg(pjfs) pjfs,project_id")
+                .eq("record_date", time0)
+                .groupBy("project_id");
+        List<TurbineInfoDay> days = turbineInfoDayService.list(wrapper);
+        Map<String, TurbineInfoDay> dayMap = days.stream().collect(Collectors.toMap(TurbineInfoDay::getProjectId, Function.identity()));
+        wrapper = new QueryWrapper<>();
+        wrapper.select("avg(pjfs) pjfs,project_id")
+                .between("record_date", beginOfMonth, time0)
+                .groupBy("project_id");
+        List<TurbineInfoDay> monthDays = turbineInfoDayService.list(wrapper);
+        Map<String, TurbineInfoDay> monthMap = monthDays.stream().collect(Collectors.toMap(TurbineInfoDay::getProjectId, Function.identity()));
+        wrapper = new QueryWrapper<>();
+        wrapper.select("avg(pjfs) pjfs,project_id")
+                .between("record_date", beginOfYear, time0)
+                .groupBy("project_id");
+        List<TurbineInfoDay> yearDays = turbineInfoDayService.list(wrapper);
+        Map<String, TurbineInfoDay> yearMap = yearDays.stream().collect(Collectors.toMap(TurbineInfoDay::getProjectId, Function.identity()));
+
+        QueryWrapper<ProEconReportIndicatorPool> wrapperrp = new QueryWrapper<>();
+        wrapperrp.eq("record_date", time0).last("and foreign_key_id = project_id");
+        List<ProEconReportIndicatorPool> pools = reportIndicatorPoolService.list(wrapperrp);
+        wrapperrp = new QueryWrapper<>();
+        wrapperrp.eq("record_date", time0).eq("foreign_key_id", "GJNY_SXGS_DBXNY_ZGS0");
+        List<ProEconReportIndicatorPool> pools2 = reportIndicatorPoolService.list(wrapperrp);
+
+        TurbineInfoDay day, month, year;
+        String projectId;
+        for (ProEconReportIndicatorPool pool : pools) {
+            projectId = pool.getProjectId();
+            day = dayMap.get(projectId);
+            pool.setRpjfs(day.getPjfs());
+            month = monthMap.get(projectId);
+            pool.setYpjfs(month.getPjfs());
+            year = yearMap.get(projectId);
+            pool.setNpjfs(year.getPjfs());
+        }
+        double v1 = pools.stream().mapToDouble(ProEconReportIndicatorPool::getRpjfs).average().orElse(0);
+        double v2 = pools.stream().mapToDouble(ProEconReportIndicatorPool::getYpjfs).average().orElse(0);
+        double v3 = pools.stream().mapToDouble(ProEconReportIndicatorPool::getNpjfs).average().orElse(0);
+        if (CollUtil.isNotEmpty(pools2)) {
+            pools2.get(0).setRpjfs(v1);
+            pools2.get(0).setYpjfs(v2);
+            pools2.get(0).setNpjfs(v3);
+            reportIndicatorPoolService.saveOrUpdateBatch(pools2);
+        }
+        reportIndicatorPoolService.saveOrUpdateBatch(pools);
+    }
+
+
 
 }
 

+ 6 - 1
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/LineInfoDay.java

@@ -33,5 +33,10 @@ public class LineInfoDay implements Serializable {
 
     private Date recordDate;
 
-    private Integer rfdl;
+    private Integer  rfdl;
+    private Integer  swdl;
+    private Integer  gwdl;
+    private Integer  cydl;
+    private double  hjwd;
+
 }