Browse Source

指标池

malijun 5 months ago
parent
commit
ddd6885da7
1 changed files with 60 additions and 29 deletions
  1. 60 29
      ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

+ 60 - 29
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -1586,35 +1586,56 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 .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);
+
         QueryWrapper<ProEconReportIndicatorPool> wrapperrp = new QueryWrapper<>();
-        wrapperrp.eq("record_date", time0).last("and foreign_key_id = windpowerstation_id");
+        wrapperrp.eq("record_date", time0)
+                .in("foreign_key_id", days.stream().map(StationInfoDay::getStationId).collect(Collectors.toList()));
         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);
+        if (!pools.isEmpty()){
+            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);
+        }else {
+
+            List<ProEconReportIndicatorPool> poolList = new ArrayList<>();
+            for (StationInfoDay day : days) {
+                ProEconReportIndicatorPool pool = new ProEconReportIndicatorPool();
+                pool.setRecordDate(time0.toLocalDateTime().toLocalDate());
+                pool.setForeignKeyId(day.getStationId());
+                poolList.add(pool);
+            }
+            reportIndicatorPoolService.saveOrUpdateBatch(poolList);
+
         }
-        reportIndicatorPoolService.saveOrUpdateBatch(poolList);
+
+
     }
 
     public void writeReportPoolProject(Date date) {
@@ -1647,34 +1668,44 @@ public class JavaFunctionJobHandler extends IJobHandler {
         QueryWrapper<ProEconReportIndicatorPool> wrapperrp = new QueryWrapper<>();
         wrapperrp.eq("record_date", time0).last("and foreign_key_id = project_id");
         List<ProEconReportIndicatorPool> pools = reportIndicatorPoolService.list(wrapperrp);
-        if (!pools.isEmpty()) {
+
+
+        QueryWrapper<ProEconReportIndicatorPool> wrapperrp2 = new QueryWrapper<>();
+        wrapperrp2.eq("record_date", time0)
+                .in("foreign_key_id", days.stream().map(LineInfoDay::getProjectId).collect(Collectors.toList()));
+        List<ProEconReportIndicatorPool> pools2 = reportIndicatorPoolService.list(wrapperrp2);
+
+        if (!pools2.isEmpty()) {
             LineInfoDay day, month, year;
             List<ProEconReportIndicatorPool> poolList = new ArrayList<>();
             String projectId;
-            for (ProEconReportIndicatorPool pool : pools) {
-                projectId = pool.getProjectId();
+            for (ProEconReportIndicatorPool pool : pools2) {
+                projectId = pool.getForeignKeyId();
                 day = dayMap.get(projectId);
                 pool.setRfdldb(day.getRfdl().doubleValue());
                 pool.setRswdldb(day.getSwdl());
                 pool.setRgwgwdldb(day.getGwdl());
                 pool.setRfdcydldb(day.getCydl());
+                pool.setRzhcydldb(day.getRfdl().doubleValue()+day.getGwdl()-day.getSwdl());
                 month = monthMap.get(projectId);
                 pool.setYfdldb(month.getRfdl().doubleValue());
                 pool.setYswdldb(month.getSwdl());
                 pool.setYgwgwdldb(month.getGwdl());
                 pool.setYfdcydldb(month.getCydl());
+                pool.setRzhcydldb(month.getRfdl().doubleValue()+month.getGwdl()-month.getSwdl());
                 year = yearMap.get(projectId);
                 pool.setNfdldb(year.getRfdl().doubleValue());
                 pool.setNswdldb(year.getSwdl());
                 pool.setNgwgwdldb(year.getGwdl());
                 pool.setNfdcydldb(year.getCydl());
+                pool.setRzhcydldb(year.getRfdl().doubleValue()+year.getGwdl()-year.getSwdl());
                 poolList.add(pool);
             }
             reportIndicatorPoolService.saveOrUpdateBatch(poolList);
         } else {
 
             List<ProEconReportIndicatorPool> poolList = new ArrayList<>();
-            for (LineInfoDay day :days){
+            for (LineInfoDay day : days) {
                 ProEconReportIndicatorPool pool = new ProEconReportIndicatorPool();
                 pool.setRecordDate(time0.toLocalDateTime().toLocalDate());
                 pool.setForeignKeyId(day.getProjectId());