Browse Source

指标池

malijun 5 months atrás
parent
commit
f475c14ede
1 changed files with 45 additions and 21 deletions
  1. 45 21
      ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

+ 45 - 21
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -1096,7 +1096,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             System.out.println(ztPI.getSpare());
             System.out.println(e.getMessage());
         }
-        System.out.println("拟合完成"+glyc);
+        System.out.println("拟合完成" + glyc);
         return glyc;
     }
 
@@ -1191,9 +1191,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
 
 
         //插入集合
-        List<TurbineInfoDay > interest = new ArrayList<>();
+        List<TurbineInfoDay> interest = new ArrayList<>();
         //更新集合
-        List<TurbineInfoDay > update = new ArrayList<>();
+        List<TurbineInfoDay> update = new ArrayList<>();
         //遍历每台风机,取出每台风机的pointDatas
         for (PointInfo turbine : turbineZt) {
 
@@ -1387,10 +1387,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
         int i = 0;
 
         //插入集合
-        List<TurbineInfoDay > interest = new ArrayList<>();
+        List<TurbineInfoDay> interest = new ArrayList<>();
         //更新集合
-        List<TurbineInfoDay > update = new ArrayList<>();
-
+        List<TurbineInfoDay> update = new ArrayList<>();
 
 
         for (PointInfo ef : entityFs) {
@@ -1407,7 +1406,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 PointInfo turbineAizt = calcTurbineAizt2(aiztMap.get(wtId), collectAi, start, end, 60);
 
 
-
                 Map<Double, Double> fit = new TreeMap<>();
                 double capacity = 2000;
                 if (turbineZt != null) {
@@ -1430,7 +1428,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 //存redis
 //            stringRedisTemplate.opsForValue().set("glqxnh:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
 
-                System.out.println("拟合曲线的大小"+fit.size()+":"+wtId);
+                System.out.println("拟合曲线的大小" + fit.size() + ":" + wtId);
 
                 //符合条件的风速和
                 List<Double> listDouble = new ArrayList<>();
@@ -1477,12 +1475,11 @@ public class JavaFunctionJobHandler extends IJobHandler {
                     update.add(one);
                 }
 
-            }catch (Exception e) {
+            } catch (Exception e) {
                 System.out.println(wtId + " " + start);
             }
 
 
-
         }
 
 
@@ -1495,8 +1492,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
         turbineInfoDayService.saveOrUpdateBatch(update);
 
 
-
-
 //        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
     }
 
@@ -1515,9 +1510,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
         List<PointInfo> pointInfos = getEntity("AI072", "turbine");
 
         //插入集合
-        List<TurbineInfoDay > interest = new ArrayList<>();
+        List<TurbineInfoDay> interest = new ArrayList<>();
         //更新集合
-        List<TurbineInfoDay > update = new ArrayList<>();
+        List<TurbineInfoDay> update = new ArrayList<>();
 
 
         //遍历pointInfos
@@ -1652,13 +1647,42 @@ 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);
-
-        LineInfoDay day, month, year;
-        List<ProEconReportIndicatorPool> poolList = new ArrayList<>();
-        String projectId;
-        for (ProEconReportIndicatorPool pool : pools) {
+        if (!pools.isEmpty()) {
+            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());
+                pool.setRgwgwdldb(day.getGwdl());
+                pool.setRfdcydldb(day.getCydl());
+                month = monthMap.get(projectId);
+                pool.setYfdldb(month.getRfdl().doubleValue());
+                pool.setYswdldb(month.getSwdl());
+                pool.setYgwgwdldb(month.getGwdl());
+                pool.setYfdcydldb(month.getCydl());
+                year = yearMap.get(projectId);
+                pool.setNfdldb(year.getRfdl().doubleValue());
+                pool.setNswdldb(year.getSwdl());
+                pool.setNgwgwdldb(year.getGwdl());
+                pool.setNfdcydldb(year.getCydl());
+                poolList.add(pool);
+            }
+            reportIndicatorPoolService.saveOrUpdateBatch(poolList);
+        } else {
+            ProEconReportIndicatorPool pool = new ProEconReportIndicatorPool();
+            LineInfoDay day, month, year;
+            List<ProEconReportIndicatorPool> poolList = new ArrayList<>();
+            String projectId;
             projectId = pool.getProjectId();
             day = dayMap.get(projectId);
+
+            pool.setRecordDate(time0.toLocalDateTime().toLocalDate());
+            pool.setForeignKeyId(projectId);
+
+
             pool.setRfdldb(day.getRfdl().doubleValue());
             pool.setRswdldb(day.getSwdl());
             pool.setRgwgwdldb(day.getGwdl());
@@ -1674,8 +1698,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
             pool.setNgwgwdldb(year.getGwdl());
             pool.setNfdcydldb(year.getCydl());
             poolList.add(pool);
+            reportIndicatorPoolService.saveOrUpdateBatch(poolList);
+
         }
-        reportIndicatorPoolService.saveOrUpdateBatch(poolList);
     }
 
     public void writeReportPoolPjfs(Date date) {
@@ -1736,7 +1761,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
     }
 
 
-
 }