Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java
#	ruoyi-admin/src/test/java/com/ruoyi/Test.java
GYEE 6 months ago
parent
commit
baa10cc89d

+ 119 - 164
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -1,6 +1,5 @@
 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;
@@ -329,6 +328,61 @@ 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当天零点
@@ -1095,7 +1149,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
             System.out.println(ztPI.getSpare());
             System.out.println(e.getMessage());
         }
-        System.out.println("拟合完成" + glyc);
         return glyc;
     }
 
@@ -1190,9 +1243,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) {
 
@@ -1341,8 +1394,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
 //        //批量更新
 //        turbineInfoDayService.updateBatchById(update);
 //        //批量插入或更新
-//        turbineInfoDayService.saveOrUpdateBatch(interest);
-//        turbineInfoDayService.saveOrUpdateBatch(update);
+        turbineInfoDayService.saveOrUpdateBatch(interest);
+        turbineInfoDayService.saveOrUpdateBatch(update);
     }
 
     //算额定风速
@@ -1386,9 +1439,10 @@ 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) {
@@ -1469,11 +1523,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
                     update.add(one);
                 }
 
-            } catch (Exception e) {
+            }catch (Exception e) {
                 System.out.println(wtId + " " + start);
             }
 
 
+
         }
 
 
@@ -1486,179 +1541,79 @@ public class JavaFunctionJobHandler extends IJobHandler {
         turbineInfoDayService.saveOrUpdateBatch(update);
 
 
+
+
 //        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
     }
 
-
-    public void writeReportPool(Date date) {
+    //环境温度
+    public void ambientTemperature() {
         //date当天零点
-        DateTime time = DateUtil.beginOfDay(date);
+        DateTime timeNow = DateUtil.beginOfDay(new Date());
         //date昨天零点
-        DateTime time0 = DateUtil.offsetDay(time, -1);
-        DateTime beginOfMonth = DateUtil.beginOfMonth(time0);
-        DateTime beginOfYear = DateUtil.beginOfYear(time0);
+        DateTime timeBegin = DateUtil.offsetDay(timeNow, -1);
 
-        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);
-    }
+        //所有风机的温度
+        QueryWrapper<PointInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("uniform_code", "AI072");
 
-    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);
+        List<PointInfo> pointInfos = getEntity("AI072", "turbine");
 
-        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()));
+        //插入集合
+        List<TurbineInfoDay > interest = new ArrayList<>();
+        //更新集合
+        List<TurbineInfoDay > update = new ArrayList<>();
 
-        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());
-            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);
-    }
+        //遍历pointInfos
+        for (PointInfo turbine : pointInfos) {
+            List<PointData> pointDatas = adapter.getHistorySnap(goldenUri(), turbine.getPointKey(), timeBegin.getTime(), timeNow.getTime(), 10);
+            //遍历pointDatas,取出数据算平均值
+            double avgCutInWindSpeed = 0;
+            for (PointData pointData : pointDatas) {
+                avgCutInWindSpeed += pointData.getValue();
+            }
+            avgCutInWindSpeed /= pointDatas.size();
 
-    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);
+            //存入数据库
+            String turbineId = turbine.getTurbineId();
+            Date jdkDate = timeBegin.toJdkDate();
+            System.out.println(turbineId + " " + jdkDate);
+            QueryWrapper<TurbineInfoDay> turbineInfoDayQueryWrapper = new QueryWrapper<>();
+            turbineInfoDayQueryWrapper.eq("turbine_id", turbine.getTurbineId());
+            turbineInfoDayQueryWrapper.eq("record_date", timeBegin.toJdkDate());
+            TurbineInfoDay one = turbineInfoDayService.getOne(turbineInfoDayQueryWrapper);
+            System.out.println(one);
+            if (one == null) {
+                TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
+                turbineInfoDay.setTurbineId(turbine.getTurbineId());
+                turbineInfoDay.setRecordDate(timeBegin.toJdkDate());
+                turbineInfoDay.setHjwd(avgCutInWindSpeed);
+                System.out.println(turbineInfoDay);
+                interest.add(turbineInfoDay);
+//                turbineInfoDayService.save(turbineInfoDay);
+            } else {
+                one.setHjwd(avgCutInWindSpeed);
+                System.out.println(one);
+                update.add(one);
+//                turbineInfoDayService.updateById(one);
+            }
 
-        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()));
+        }
+//        //批量插入
+//        turbineInfoDayService.saveBatch(interest);
+//        //批量更新
+//        turbineInfoDayService.updateBatchById(update);
+//        //批量插入或更新
+        turbineInfoDayService.saveOrUpdateBatch(interest);
+        turbineInfoDayService.saveOrUpdateBatch(update);
 
-        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);
     }
 
 
+
 }
 
 

+ 4 - 5
ruoyi-admin/src/test/java/com/ruoyi/Test.java

@@ -37,13 +37,13 @@ public class Test {
 
     @org.junit.Test
     public void test() {
-//        javaFunctionJobHandler.cutInWindSpeed();
+        javaFunctionJobHandler.cutInWindSpeed();
         javaFunctionJobHandler.calcGlqxnh_edfs();
     }
 
     //平均温度
     @org.junit.Test
-    public void wendu() {
+    public void ambientTemperature() {
         //date当天零点
         DateTime timeNow = DateUtil.beginOfDay(new Date());
         //date昨天零点
@@ -97,14 +97,13 @@ public class Test {
             }
 
         }
-
 //        //批量插入
 //        turbineInfoDayService.saveBatch(interest);
 //        //批量更新
 //        turbineInfoDayService.updateBatchById(update);
 //        //批量插入或更新
-        turbineInfoDayService.saveOrUpdateBatch(interest);
-        turbineInfoDayService.saveOrUpdateBatch(update);
+//        turbineInfoDayService.saveOrUpdateBatch(interest);
+//        turbineInfoDayService.saveOrUpdateBatch(update);
 
 
     }