GYEE 6 月之前
父節點
當前提交
d101c2c08e
共有 17 個文件被更改,包括 3625 次插入205 次删除
  1. 18 8
      ruoyi-admin/src/main/java/com/ruoyi/web/runner/LoadDataSourceRunner.java
  2. 3 1
      ruoyi-admin/src/main/resources/application.yml
  3. 30 19
      ruoyi-admin/src/test/java/com/ruoyi/GetDataTest.java
  4. 520 66
      ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java
  5. 82 19
      ruoyi-admin/src/test/java/com/ruoyi/NewTests.java
  6. 2446 0
      ruoyi-admin/src/test/java/com/ruoyi/dd.java
  7. 1 0
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java
  8. 395 0
      universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/ProBasicEquipment.java
  9. 6 86
      universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/StationInfoMin.java
  10. 7 0
      universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/TurbineInfoMin.java
  11. 16 0
      universal-computing-platform/src/main/java/com/ruoyi/ucp/mapper/ProBasicEquipmentMapper.java
  12. 16 0
      universal-computing-platform/src/main/java/com/ruoyi/ucp/service/IProBasicEquipmentService.java
  13. 34 0
      universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/ProBasicEquipmentServiceImpl.java
  14. 22 0
      universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/StationInfoMinServiceImpl.java
  15. 21 1
      universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/TurbineInfoMinServiceImpl.java
  16. 6 3
      universal-computing-platform/src/main/java/com/ruoyi/ucp/util/CalcCache.java
  17. 2 2
      universal-computing-platform/src/main/resources/application-druid.yml

+ 18 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/runner/LoadDataSourceRunner.java

@@ -61,6 +61,8 @@ public class LoadDataSourceRunner implements CommandLineRunner {
     private StringRedisTemplate stringRedisTemplate;
     private StringRedisTemplate stringRedisTemplate;
     @Value("${ruoyi.profile}")
     @Value("${ruoyi.profile}")
     private String path;
     private String path;
+//    @Value("${power_curve_month}")
+//    private String powerCurveMonth;
 //    @Resource
 //    @Resource
 //    private JavaFunctionJobHandler task;
 //    private JavaFunctionJobHandler task;
 
 
@@ -121,7 +123,6 @@ public class LoadDataSourceRunner implements CommandLineRunner {
         pi.setUniformCode("AI422");
         pi.setUniformCode("AI422");
         List<PointInfo> trubineModel1 = pointService.getByEntity(pi);
         List<PointInfo> trubineModel1 = pointService.getByEntity(pi);
         trubineModel.addAll(trubineModel1);
         trubineModel.addAll(trubineModel1);
-        Map<String, String> wtModelMap = trubineModel.stream().collect(Collectors.toMap(PointInfo::getSpare, PointInfo::getTurbineId));
 
 
         String zllgl = stringRedisTemplate.opsForValue().get("ZLLGL");
         String zllgl = stringRedisTemplate.opsForValue().get("ZLLGL");
         //字符串类型转换为list月拟合曲线集合
         //字符串类型转换为list月拟合曲线集合
@@ -137,24 +138,33 @@ public class LoadDataSourceRunner implements CommandLineRunner {
         for (PointInfo info : trubineModel) {
         for (PointInfo info : trubineModel) {
             Map<Double, ProBasicModelPowerRd> rdMap = bzgl.get(info.getSpare());
             Map<Double, ProBasicModelPowerRd> rdMap = bzgl.get(info.getSpare());
             ConcurrentHashMap<Double, Double> mdd = new ConcurrentHashMap<>();
             ConcurrentHashMap<Double, Double> mdd = new ConcurrentHashMap<>();
-            rdMap.forEach((fs,rd)->{
-                mdd.put(fs,rd.getTheoryPower());
+            rdMap.forEach((fs, rd) -> {
+                mdd.put(fs, rd.getTheoryPower());
             });
             });
-            CalcCache.llgl.put(info.getTurbineId(),mdd);
+            CalcCache.llgl.put(info.getTurbineId(), mdd);
         }
         }
 
 
         factory.setDatabase(database);
         factory.setDatabase(database);
         factory.afterPropertiesSet();
         factory.afterPropertiesSet();
         factory.resetConnection();
         factory.resetConnection();
 
 
-
-        Set<String> keys = stringRedisTemplate.keys("glqxnh:5:*");
+        String powerCurveMonth = "glqxnh:" + DateUtil.date().getMonth() + ":";
+        Set<String> keys = stringRedisTemplate.keys(powerCurveMonth + "*");
+        CalcCache.keys = keys.stream().collect(Collectors.joining(","));
         for (String key : keys) {
         for (String key : keys) {
             String yc = stringRedisTemplate.opsForValue().get(key);
             String yc = stringRedisTemplate.opsForValue().get(key);
-            ConcurrentHashMap<Double, Double> wtyc = JSON.parseObject(yc, new TypeReference<ConcurrentHashMap<Double, Double>>() {}.getType());
-            CalcCache.fitcoef.put(key.replaceFirst("glqxnh:5:",""),wtyc);
+            ConcurrentHashMap<Double, Double> wtyc = JSON.parseObject(yc, new TypeReference<ConcurrentHashMap<Double, Double>>() {
+            }.getType());
+            CalcCache.fitcoef.put(key.replaceFirst(powerCurveMonth, ""), wtyc);
+            if (wtyc.size() == 2500) {
+                CalcCache.already.add(key.replaceFirst(powerCurveMonth, ""));
+            }
         }
         }
 
 
+        String swdlTime = stringRedisTemplate.opsForValue().get("swdlTime");
+        if (swdlTime != null)
+            CalcCache.swdlTime = JSON.parseObject(swdlTime, new TypeReference<Map<String, Long>>() {
+            });
 
 
 
 
 //        DateTime start = DateUtil.parse("2024-03-25");
 //        DateTime start = DateUtil.parse("2024-03-25");

+ 3 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -152,4 +152,6 @@ feign:
     config:
     config:
       default:
       default:
         connect-timeout: 5000
         connect-timeout: 5000
-        read-timeout: 300000
+        read-timeout: 900000
+
+power_curve_month: "glqxnh:8:"

+ 30 - 19
ruoyi-admin/src/test/java/com/ruoyi/GetDataTest.java

@@ -26,44 +26,55 @@ public class GetDataTest {
     private IPointInfoService pointInfoService;
     private IPointInfoService pointInfoService;
     @Resource
     @Resource
     private AdapterApi adapterApi;
     private AdapterApi adapterApi;
+
     @Test
     @Test
     public void test() {
     public void test() {
         DateTime start = DateUtil.parse("2023-06-01");
         DateTime start = DateUtil.parse("2023-06-01");
-        DateTime end = DateUtil.parse("2024-05-31");
+        DateTime end = DateUtil.parse("2024-10-14");
+        start = DateUtil.offsetMonth(end, -30);
 
 
-        String[] names = {"AI004","AI005","AI006","AI007","AI008","AI009","AI073","AI037","AI039","AI038","AI047","AI048","AI056","AI057","AI060","DI022","AI066","AI067","AI069","AI072","AI074","DI025","DI080","AI082","AI084","AI083","AI065"};
+        String[] names = {"AI004", "AI005", "AI006", "AI007", "AI008", "AI009", "AI073", "AI037", "AI039", "AI038", "AI047", "AI048", "AI056", "AI057", "AI060", "DI022", "AI066", "AI067", "AI069", "AI072", "AI074", "DI025", "DI080", "AI082", "AI084", "AI083", "AI065"};
         QueryWrapper<PointInfo> wrapper = new QueryWrapper<>();
         QueryWrapper<PointInfo> wrapper = new QueryWrapper<>();
         wrapper.lambda().eq(PointInfo::getInstitutionType, "turbine")
         wrapper.lambda().eq(PointInfo::getInstitutionType, "turbine")
 //                .eq(PointInfo::getStationId,"GJNY_SXGS_LJS_FDC_STA")
 //                .eq(PointInfo::getStationId,"GJNY_SXGS_LJS_FDC_STA")
-                .eq(PointInfo::getTurbineId,"GJNY_SXGS_LJS_F_WT_0001_EQ")
-                .in(PointInfo::getUniformCode,names);
+                .eq(PointInfo::getTurbineId, "GJNY_SXGS_LJS_F_WT_0011_EQ")
+                .in(PointInfo::getUniformCode, names);
         List<PointInfo> list = pointInfoService.list(wrapper);
         List<PointInfo> list = pointInfoService.list(wrapper);
         for (PointInfo pi : list) {
         for (PointInfo pi : list) {
             CsvWriter writer = null;
             CsvWriter writer = null;
-            if(pi.getPointKey().equals("INITIAL")){
+            if (pi.getPointKey().equals("INITIAL")) {
                 //指定路径和编码
                 //指定路径和编码
-                writer = CsvUtil.getWriter("D:/数据/"+pi.getTurbineId()+"/"+pi.getName()+"无测点"+
+                writer = CsvUtil.getWriter("D:/数据/" + pi.getTurbineId() + "/" + pi.getName() + "无测点" +
                         ".csv", CharsetUtil.CHARSET_GBK);
                         ".csv", CharsetUtil.CHARSET_GBK);
                 continue;
                 continue;
             }
             }
-            List<PointData> s = adapterApi.getHistorySnap(URI.create("http://172.16.12.103:8011/ts"), pi.getPointKey(),
-                    start.getTime(), end.getTime(), 60);
-
+            List<PointData> s = null;
+            try {
+                s = adapterApi.getHistorySnap(URI.create("http://172.16.12.103:8011/ts"), pi.getPointKey(),
+                        start.getTime(), end.getTime(), 60*5);
+            } catch (Exception e) {
+                e.printStackTrace();
                 //指定路径和编码
                 //指定路径和编码
-                writer = CsvUtil.getWriter("D:/数据/"+pi.getTurbineId()+"/"+pi.getName()+
+                writer = CsvUtil.getWriter("D:/数据/" + pi.getTurbineId() + "/" + pi.getName() + "获取数据出错" +
                         ".csv", CharsetUtil.CHARSET_GBK);
                         ".csv", CharsetUtil.CHARSET_GBK);
-                //按行写出
-                writer.write(new String[] {"时间","时间戳","对齐时间戳", "值"});
+                continue;
+            }
+
+            //指定路径和编码
+            writer = CsvUtil.getWriter("D:/数据/" + pi.getTurbineId() + "/" + pi.getName() +
+                    ".csv", CharsetUtil.CHARSET_GBK);
+            //按行写出
+            writer.write(new String[]{"时间", "时间戳", "对齐时间戳", "值"});
 
 
-                long j=start.getTime();
-            for (int i = 0; i <s.size(); i++) {
+            long j = start.getTime();
+            for (int i = 0; i < s.size(); i++) {
                 String[] r = new String[4];
                 String[] r = new String[4];
-                r[0]=DateUtil.formatDateTime(new Date(j));
-                r[1]=Long.toString(s.get(i).getTs());
-                r[2]=Long.toString(j);
-                r[3]=Double.toString(s.get(i).getValue());
+                r[0] = DateUtil.formatDateTime(new Date(j));
+                r[1] = Long.toString(s.get(i).getTs());
+                r[2] = Long.toString(j);
+                r[3] = Double.toString(s.get(i).getValue());
                 writer.write(r);
                 writer.write(r);
-                j+=60*1000;
+                j += 60 * 1000;
             }
             }
 
 
         }
         }

+ 520 - 66
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -30,9 +30,6 @@ import java.util.stream.Collectors;
 @Service
 @Service
 public class JavaFunctionJobHandler extends IJobHandler {
 public class JavaFunctionJobHandler extends IJobHandler {
 
 
-/*    @Resource
-    private PointInfo pointInfo;*/
-
     @Resource
     @Resource
     private AdapterApi adapter;
     private AdapterApi adapter;
     @Resource
     @Resource
@@ -105,13 +102,15 @@ public class JavaFunctionJobHandler extends IJobHandler {
         wrapper.eq("record_date", date);
         wrapper.eq("record_date", date);
         return stationInfoDayService.list(wrapper);
         return stationInfoDayService.list(wrapper);
     }
     }
-    public List<StationInfoMin> getStationinfoMinByDate(Date date) {
+
+    public List<StationInfoMin> getStationinfoByMin(Date date) {
         QueryWrapper<StationInfoMin> wrapper = new QueryWrapper<>();
         QueryWrapper<StationInfoMin> wrapper = new QueryWrapper<>();
         wrapper.eq("record_date", date);
         wrapper.eq("record_date", date);
         return stationInfoMinService.list(wrapper);
         return stationInfoMinService.list(wrapper);
     }
     }
-    public List<StationInfoMin> getStationinfoMinByDate(Date date, List<PointInfo> entity) {
-        List<StationInfoMin> byDate = getStationinfoMinByDate(date);
+
+    public List<StationInfoMin> getStationinfoByMin(Date date, List<PointInfo> entity) {
+        List<StationInfoMin> byDate = getStationinfoByMin(date);
         if (CollUtil.isEmpty(byDate)) {
         if (CollUtil.isEmpty(byDate)) {
             entity.forEach(pi -> {
             entity.forEach(pi -> {
                 StationInfoMin day = new StationInfoMin();
                 StationInfoMin day = new StationInfoMin();
@@ -123,11 +122,20 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return byDate;
         return byDate;
     }
     }
 
 
+
     public StationInfoDay getStationinfoByDate(Date date, String stId) {
     public StationInfoDay getStationinfoByDate(Date date, String stId) {
         QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
         QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
         wrapper.eq("record_date", date).eq("station_id", stId);
         wrapper.eq("record_date", date).eq("station_id", stId);
         List<StationInfoDay> list = stationInfoDayService.list(wrapper);
         List<StationInfoDay> list = stationInfoDayService.list(wrapper);
-        return CollUtil.isNotEmpty(list) ? list.get(0) : new StationInfoDay();
+        StationInfoDay day;
+        if (CollUtil.isEmpty(list)) {
+            day = new StationInfoDay();
+            day.setStationId(stId);
+            day.setRecordDate(date);
+        } else {
+            day = list.get(0);
+        }
+        return day;
     }
     }
 
 
     public List<StationInfoDay> getStationinfoByDate(Date date, List<PointInfo> entity) {
     public List<StationInfoDay> getStationinfoByDate(Date date, List<PointInfo> entity) {
@@ -264,14 +272,15 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return pointService.getByEntity(pi);
         return pointService.getByEntity(pi);
     }
     }
 
 
-    public Map<String, Double> getTurbinePowerLoss(double rfdl, PointInfo piZt, List<PointData> fsList, List<PointData> glList) {
+    public Map<String, Double> getTurbinePowerLoss(Double rfdl, PointInfo piZt, List<PointData> fsList, List<PointData> glList) {
+        if (rfdl == null) rfdl = 0.0;
         String tbId = piZt.getTurbineId();
         String tbId = piZt.getTurbineId();
         //        Map<Double, Long> collect = piZt.getPointDatas().stream().collect(Collectors.groupingBy(PointData::getValue, Collectors.counting()));
         //        Map<Double, Long> collect = piZt.getPointDatas().stream().collect(Collectors.groupingBy(PointData::getValue, Collectors.counting()));
-        double sum1 = glList.stream().mapToDouble(PointData::getValue).sum();
-        double xs = 1;
-        if (rfdl > 0 && sum1 > 0) {
-            xs = rfdl / (sum1 / 240);
-        }
+        double sumfs = fsList.stream().mapToDouble(PointData::getValue).sum();
+//        double xs = 1;
+//        if (rfdl > 0 && sum1 > 0) {
+//            xs = rfdl / (sum1 / 240);
+//        }
         //        double sum2 = fsList.stream().mapToDouble(pd -> {
         //        double sum2 = fsList.stream().mapToDouble(pd -> {
         //            Double v = CalcCache.fitcoef.get(tbId).get(pd.getValue());
         //            Double v = CalcCache.fitcoef.get(tbId).get(pd.getValue());
         //            if (v == null) v = 0.0;
         //            if (v == null) v = 0.0;
@@ -282,8 +291,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
         List<PointData> collectZt = piZt.getPointDatas();
         List<PointData> collectZt = piZt.getPointDatas();
         double jxss = 0, sdtj = 0, gzss = 0, djss = 0, xnss = 0, fdjcl = 0, xdjcl = 0, xdtj = 0;
         double jxss = 0, sdtj = 0, gzss = 0, djss = 0, xnss = 0, fdjcl = 0, xdjcl = 0, xdtj = 0;
         Map<String, Double> map = new HashMap<>();
         Map<String, Double> map = new HashMap<>();
-        if (collectZt.size() == fsList.size() && fsList.size() == glList.size()) {
-            for (int i = 0; i < collectZt.size(); i++) {
+        if (Math.abs(collectZt.size() - fsList.size()) < 9 && Math.abs(fsList.size() - glList.size()) < 9) {
+            int min = Math.min(collectZt.size(), Math.min(fsList.size(), glList.size()));
+            for (int i = 0; i < min; i++) {
                 Double v = CalcCache.fitcoef.get(tbId).get(fsList.get(i).getValue());
                 Double v = CalcCache.fitcoef.get(tbId).get(fsList.get(i).getValue());
                 if (v == null) v = 0.0;
                 if (v == null) v = 0.0;
                 v = v - glList.get(i).getValue();
                 v = v - glList.get(i).getValue();
@@ -336,14 +346,17 @@ public class JavaFunctionJobHandler extends IJobHandler {
         if (xdjcl > 30000) xdjcl = 0;
         if (xdjcl > 30000) xdjcl = 0;
         if (xdtj > 30000) xdtj = 0;
         if (xdtj > 30000) xdtj = 0;
         //15秒*60分钟
         //15秒*60分钟
-        map.put("jxss", jxss > 0 ? jxss / 240 * xs : 0);
-        map.put("sdtj", sdtj > 0 ? sdtj / 240 * xs : 0);
-        map.put("gzss", gzss > 0 ? gzss / 240 * xs : 0);
-        map.put("djss", djss > 0 ? djss / 240 * xs : 0);
-        map.put("xnss", xnss > 0 ? xnss / 240 * xs : 0);
-        map.put("fdjcl", fdjcl > 0 ? fdjcl / 240 * xs : 0);
-        map.put("xdjcl", xdjcl > 0 ? xdjcl / 240 * xs : 0);
-        map.put("xdtj", xdtj > 0 ? xdtj / 240 * xs : 0);
+        map.put("jxss", jxss > 0 ? jxss / 240 : 0);
+        map.put("sdtj", sdtj > 0 ? sdtj / 240 : 0);
+        map.put("gzss", gzss > 0 ? gzss / 240 : 0);
+        map.put("djss", djss > 0 ? djss / 240 : 0);
+        map.put("xnss", xnss > 0 ? xnss / 240 : 0);
+        map.put("fdjcl", fdjcl > 0 ? fdjcl / 240 : 0);
+        map.put("xdjcl", xdjcl > 0 ? xdjcl / 240 : 0);
+        map.put("xdtj", xdtj > 0 ? xdtj / 240 : 0);
+
+        double v = map.get("jxss") + map.get("sdtj") + map.get("gzss") + map.get("djss") + map.get("xnss") + map.get("fdjcl") + map.get("xdjcl") + map.get("xdtj");
+        System.out.println(piZt.getTurbineId() + ",日发" + rfdl + ",损失" + v + ",风速和" + sumfs / 240);
         return map;
         return map;
     }
     }
 
 
@@ -597,17 +610,102 @@ public class JavaFunctionJobHandler extends IJobHandler {
         stationInfoDayService.saveOrUpdateBatch(byDate);
         stationInfoDayService.saveOrUpdateBatch(byDate);
     }
     }
 
 
+    public void SwdlRepair(Date date) {
+        //date当天零点
+        DateTime time = DateUtil.beginOfDay(date);
+        //date昨天零点
+        DateTime time0 = DateUtil.offsetDay(time, -1);
+        List<PointInfo> swdlEt = getEntity("Z-ZXYG-CX", "meter");
+        Map<String, PointInfo> map = swdlEt.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
+        List<StationInfoDay> list = getStationinfoByDate(time0);
+        Map<String, StationInfoDay> dayMap = list.stream().collect(Collectors.toMap(StationInfoDay::getStationId, Function.identity()));
+        CalcCache.swdlTime.forEach((key, ts) -> {
+            int swdl = 0;
+            PointData data1, data0;
+            double ll = (double) (time.getTime() - ts) / 23 * 60 * 60 * 1000;
+            if (ts > 0 && (ll > 23 && ll < 25)) {
+                StationInfoDay day = dayMap.get(key);
+                PointInfo info = map.get(key);
+                List<PointData> raw1 = adapter.getHistoryRaw(goldenUri(), key, time.getTime(), DateUtil.offsetMinute(time, 6).getTime());
+                if (CollUtil.isEmpty(raw1)) {
+                    Map<String, PointData> section = adapter.getHistorySection(goldenUri(), key, time.getTime() + 1000);
+                    data1 = section.get(key);
+                } else {
+                    data1 = raw1.get(0);
+                }
+                Map<String, PointData> section = adapter.getHistorySection(goldenUri(), key, ts + 1000);
+                data0 = section.get(key);
+                swdl = (int) ((data1.getValue() - data0.getValue()) * info.getCoef());
+                if (swdl > day.getRfdl()) {
+                    List<PointData> rawl1 = adapter.getHistoryRaw(goldenUri(), key, DateUtil.offsetMinute(time, -60).getTime(), time.getTime());
+                    for (int i = rawl1.size() - 1; i >= 0; i--) {
+                        swdl = (int) ((rawl1.get(i).getValue() - data0.getValue()) * info.getCoef());
+                        if (swdl <= day.getRfdl()) {
+                            day.setSwdl(swdl);
+                            day.setZhcydl(day.getRfdl() + day.getGwdl() - day.getSwdl());
+                            day.setCydl(day.getZhcydl() - day.getZyb());
+                            CalcCache.swdlTime.put(info.getPointKey(), rawl1.get(i).getTs());
+                            break;
+                        }
+                    }
+                } else {
+                    day.setSwdl(swdl);
+                    day.setZhcydl(day.getRfdl() + day.getGwdl() - day.getSwdl());
+                    day.setCydl(day.getZhcydl() - day.getZyb());
+                }
+            }
+        });
+        for (StationInfoDay day : list) {
+            int swdl = 0;
+            if (day.getSwdl() > day.getRfdl()) {
+                PointInfo info = map.get(day.getStationId());
+                Long l = CalcCache.swdlTime.get(info.getPointKey());
+                PointData data0;
+                if (l == null || l == 0) {
+                    List<PointData> raw0 = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), time0.getTime(), DateUtil.offsetMinute(time0, 6).getTime());
+                    if (CollUtil.isEmpty(raw0)) {
+                        Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), time0.getTime() + 1000);
+                        data0 = section.get(info.getPointKey());
+                    } else {
+                        data0 = raw0.get(0);
+                    }
+                } else {
+                    double ll = (double) (time.getTime() - l) / 23 * 60 * 60 * 1000;
+                    if (ll > 23 && ll < 25) {
+                        Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), l + 1000);
+                        data0 = section.get(info.getPointKey());
+                    } else {
+                        continue;
+                    }
+                }
+                List<PointData> raw1 = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), DateUtil.offsetMinute(time, -60).getTime(), time.getTime());
+                for (int i = raw1.size() - 1; i >= 0; i--) {
+                    swdl = (int) ((raw1.get(i).getValue() - data0.getValue()) * info.getCoef());
+                    if (swdl <= day.getRfdl()) {
+                        day.setSwdl(swdl);
+                        day.setZhcydl(day.getRfdl() + day.getGwdl() - day.getSwdl());
+                        day.setCydl(day.getZhcydl() - day.getZyb());
+                        CalcCache.swdlTime.put(info.getPointKey(), raw1.get(i).getTs());
+                        break;
+                    }
+                }
+            }
+        }
+        stationInfoDayService.saveOrUpdateBatch(list);
+        stringRedisTemplate.opsForValue().set("swdlTime", JSON.toJSONString(CalcCache.swdlTime));
+    }
+
     public void getZeroNextData(List<PointInfo> entity, Date start0, Date start) {
     public void getZeroNextData(List<PointInfo> entity, Date start0, Date start) {
         List<PointData> snap0, snap;
         List<PointData> snap0, snap;
         for (PointInfo info : entity) {
         for (PointInfo info : entity) {
             PointData data0, data;
             PointData data0, data;
             List<PointData> datas = new ArrayList<>();
             List<PointData> datas = new ArrayList<>();
-            snap0 = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), start0.getTime(), DateUtil.offsetMinute(start0, 90).getTime());
+            snap0 = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), start0.getTime(), DateUtil.offsetMinute(start0, 6).getTime());
             if (CollUtil.isEmpty(snap0)) {
             if (CollUtil.isEmpty(snap0)) {
                 Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), start0.getTime());
                 Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), start0.getTime());
                 snap0 = new ArrayList<>(section.values());
                 snap0 = new ArrayList<>(section.values());
             }
             }
-            snap = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), start.getTime(), DateUtil.offsetMinute(start, 90).getTime());
+            snap = adapter.getHistoryRaw(goldenUri(), info.getPointKey(), start.getTime(), DateUtil.offsetMinute(start, 6).getTime());
             if (CollUtil.isEmpty(snap)) {
             if (CollUtil.isEmpty(snap)) {
                 Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), start.getTime());
                 Map<String, PointData> section = adapter.getHistorySection(goldenUri(), info.getPointKey(), start.getTime());
                 snap = new ArrayList<>(section.values());
                 snap = new ArrayList<>(section.values());
@@ -698,6 +796,91 @@ public class JavaFunctionJobHandler extends IJobHandler {
         lineInfoDayService.saveOrUpdateBatch(byDate);
         lineInfoDayService.saveOrUpdateBatch(byDate);
     }
     }
 
 
+    public void calcTurbineRFDLSameDay() {
+        DateTime time = DateUtil.date();
+        //date当天零点
+        DateTime time0 = DateUtil.beginOfDay(time);
+
+        List<PointInfo> entity = getEntity("AI121", "turbine");
+        getZeroNextData(entity, time0, time);
+        Map<String, PointInfo> turMap = entity.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
+        Map<String, String> fsMap = getEntityMap("AI066", "turbine");
+
+        Map<String, TurbineInfoDay> byDate = getTurbineinfoMap(time0, entity);
+
+        TurbineInfoDay infoDay;
+        PointInfo rfdlPi;
+        String turbineId;
+        List<TurbineInfoDay> infoDays = new ArrayList<>();
+        DoubleStatData stat;
+        for (PointInfo info : entity) {
+            turbineId = info.getTurbineId();
+            infoDay = byDate.get(turbineId);
+
+            rfdlPi = turMap.get(turbineId);
+            double v = (rfdlPi.getPointDatas().get(1).getValue() - rfdlPi.getPointDatas().get(0).getValue()) * rfdlPi.getCoef();
+            if (v < 0 || v > 1000000) {
+                v = 0;
+            } else if (v > 30000) {
+                v = v / (v % 30000 + 3);
+            }
+            infoDay.setRfdl(v);
+            stat = adapter.getHistoryStat(goldenUri(), fsMap.get(turbineId), time0.getTime(), time.getTime());
+            if (stat == null) {
+                infoDay.setPjfs(0.0);
+            } else {
+                infoDay.setPjfs(stat.getAvg().getValue());
+            }
+
+            infoDays.add(infoDay);
+        }
+        turbineInfoDayService.saveOrUpdateBatch(infoDays);
+    }
+
+    public void calcTurbine5s2SameDay() {
+        DateTime time = DateUtil.date();
+        //date当天零点
+        DateTime time0 = DateUtil.beginOfDay(time);
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        //状态
+        List<PointInfo> entityZT = getEntity("MXZT", "turbine");
+        Map<String, Map<String, PointInfo>> ztMapMapInfos = entityZT.stream().collect(Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
+        Map<String, TurbineInfoDay> dayMap = getTurbineinfoMap(time0, entityFs);
+        List<TurbineInfoDay> infoDays = new ArrayList<>();
+        Map<String, Map<String, PointInfo>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
+        Map<String, Map<String, PointInfo>> glMapMap = entityGl.stream().collect(Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
+
+        ztMapMapInfos.forEach((stId, ztMapInfo) -> ztMapInfo.forEach((wtId, ztInfo) -> {
+            //0 待机,1 手动停机,2 正常发电,3 发电降出力,4 故障,5 故障受累,6 检修,7 检修受累,8 限电降出力,
+            // 9 限电停机,10 电网受累,11 环境受累,12 通讯中断,13 设备离线
+            TurbineInfoDay infoDay = dayMap.get(wtId);
+            PointInfo fspi = fsMapMap.get(stId).get(wtId);
+            PointInfo glpi = glMapMap.get(stId).get(wtId);
+            getSnapDataByEntity(fspi, time0, time, 15);
+            getSnapDataByEntity(glpi, time0, time, 15);
+            getSnapDataByEntity(ztInfo, taosUri(), time0, time, 15);
+            List<PointData> fsData = fspi.getPointDatas();
+            fsData = fsData.stream().peek(pd -> pd.setDoubleValue(NumberUtil.round(pd.getValue() > 25 ? 25.0 : pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
+            Map<String, Double> loss = getTurbinePowerLoss(infoDay.getRfdl(), ztInfo, fsData, glpi.getPointDatas());
+            infoDay.setJhjxss(loss.get("jxss") + loss.get("sdtj"));
+            infoDay.setFjhjxss(loss.get("gzss") + loss.get("djss") + loss.get("fdjcl"));
+            infoDay.setXdss(loss.get("xdjcl") + loss.get("xdtj"));
+            infoDay.setSlss(0.0);
+            infoDay.setDjss(loss.get("djss"));
+            infoDay.setGzss(loss.get("gzss"));
+            if (infoDay.getRfdl() == 0) {
+                infoDay.setXnss(0.0);
+            } else {
+                infoDay.setXnss(loss.get("xnss"));
+            }
+            infoDay.setLlfdl(infoDay.getRfdl() + infoDay.getJhjxss() + infoDay.getFjhjxss() + infoDay.getXdss() + infoDay.getSlss() + infoDay.getXnss());
+            infoDays.add(infoDay);
+        }));
+        turbineInfoDayService.saveOrUpdateBatch(infoDays);
+    }
 
 
     public void calcLineRfdlSameDay() {
     public void calcLineRfdlSameDay() {
         //date当天零点
         //date当天零点
@@ -836,16 +1019,87 @@ public class JavaFunctionJobHandler extends IJobHandler {
         stationInfoDayService.saveOrUpdateBatch(infoDays);
         stationInfoDayService.saveOrUpdateBatch(infoDays);
     }
     }
 
 
+    public void calcStationHourPjglRfdl(Date hour) {
+        //hour整点
+        DateTime time = DateUtil.beginOfHour(hour);
+        //1小时前
+        DateTime time0 = DateUtil.offsetHour(time, -1);
+        //当天零点
+        DateTime rft = DateUtil.beginOfDay(time);
+
+        List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC001", "booster");
+        Map<String, PointInfo> statMapCx = getStatDataByEntity(entityCx, goldenUri(), time0, time, PointInfo::getStationId);
+        List<StationInfoHour> byHours = getStationinfoByHour(time, entityCx);
+
+        entity = entity.stream().filter(e -> !"".equals(e.getProjectId())).collect(Collectors.toList());
+        if (time.getHours() == 0) {
+            getSectionDataByEntity(entity, goldenUri(), DateUtil.offsetDay(rft, -1), time);
+        } else {
+            getSectionDataByEntity(entity, goldenUri(), rft, time);
+        }
+        Map<String, List<PointInfo>> stMap = entity.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+        for (StationInfoHour byHour : byHours) {
+            List<PointInfo> pis = stMap.get(byHour.getStationId());
+            double dl = 0, v = 0;
+            List<PointData> pds;
+            for (PointInfo pi : pis) {
+                pds = pi.getPointDatas();
+                if (pds.size() > 1) v = (pds.get(1).getValue() - pds.get(0).getValue()) * pi.getCoef();
+                dl += (v < 0 || v > 30000000) ? 0 : v;
+            }
+            byHour.setRfdl(dl);
+
+            PointInfo info = statMapCx.get(byHour.getStationId());
+            double v1 = info.getPointDatas().get(0).getValue();
+            byHour.setPjgl(v1 <= 0 ? 0 : v1 * info.getCoef());
+        }
+
+        stationInfoHourService.saveOrUpdateBatch(byHours);
+    }
+
+    public void calcStationMinRfdl(Date hour) {
+        //hour整分钟
+        DateTime time = DateUtil.beginOfMinute(hour);
+        //当天零点
+        DateTime rft = DateUtil.beginOfDay(time);
+        List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
+        entity = entity.stream().filter(e -> !"".equals(e.getProjectId())).collect(Collectors.toList());
+        List<StationInfoMin> byHours = getStationinfoByMin(time, entity);
+        getSectionDataByEntity(entity, goldenUri(), rft, time);
+        Map<String, List<PointInfo>> stMap = entity.stream().collect(Collectors.groupingBy(PointInfo::getStationId));
+        for (StationInfoMin byHour : byHours) {
+            List<PointInfo> pis = stMap.get(byHour.getStationId());
+            double dl = 0, v = 0;
+            List<PointData> pds;
+            for (PointInfo pi : pis) {
+                pds = pi.getPointDatas();
+                if (pds.size() > 1) v = (pds.get(1).getValue() - pds.get(0).getValue()) * pi.getCoef();
+                dl += (v < 0 || v > 30000000) ? 0 : v;
+            }
+            byHour.setRfdl(dl);
+        }
+        stationInfoMinService.saveOrUpdateBatch(byHours);
+    }
+
     public void calcStationHourPJGL(Date hour) {
     public void calcStationHourPJGL(Date hour) {
         hour = DateUtil.beginOfHour(hour);
         hour = DateUtil.beginOfHour(hour);
         DateTime start = DateUtil.offsetHour(hour, -1);
         DateTime start = DateUtil.offsetHour(hour, -1);
         //出线
         //出线
         List<PointInfo> entityCx = getEntity("AGC001", "booster");
         List<PointInfo> entityCx = getEntity("AGC001", "booster");
-        Map<String, PointInfo> statMapCx = getStatDataByEntityMap(entityCx, goldenUri(), start, hour, PointInfo::getTurbineId);
+        Map<String, PointInfo> statMapCx = getStatDataByEntity(entityCx, goldenUri(), start, hour, PointInfo::getStationId);
 
 
-        List<StationInfoHour> byHours = getStationinfoByHour(hour,entityCx);
+        List<StationInfoHour> byHours = getStationinfoByHour(hour, entityCx);
         for (StationInfoHour byHour : byHours) {
         for (StationInfoHour byHour : byHours) {
-            byHour.setPjgl(statMapCx.get(byHour.getStationId()).getPointDatas().get(0).getValue());
+            PointInfo info = statMapCx.get(byHour.getStationId());
+            double v = info.getPointDatas().get(0).getValue();
+            if (v < 0) {
+                v = 0;
+            } else {
+                v = v * info.getCoef();
+            }
+            byHour.setPjgl(v);
         }
         }
         stationInfoHourService.saveOrUpdateBatch(byHours);
         stationInfoHourService.saveOrUpdateBatch(byHours);
     }
     }
@@ -1085,7 +1339,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             //            List<PointData> firstGl = new ArrayList<>();
             //            List<PointData> firstGl = new ArrayList<>();
             List<PointData> firstZsgl = new ArrayList<>();
             List<PointData> firstZsgl = new ArrayList<>();
             double v1, v2, v3;
             double v1, v2, v3;
-            for (int i = 0; i < 5760; i++) {
+            for (int i = 0; i < agcInfo.getPointDatas().size(); i++) {
                 int finalI = i;
                 int finalI = i;
                 long ts = start.getTime() + i * 15000;
                 long ts = start.getTime() + i * 15000;
                 //                v1 = fsMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).average().orElse(0.0);
                 //                v1 = fsMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).average().orElse(0.0);
@@ -1097,7 +1351,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
             }
             }
 
 
             List<PointData> czxd = calcStationXd2(agcInfo, cxInfo.getPointDatas(), firstZsgl);
             List<PointData> czxd = calcStationXd2(agcInfo, cxInfo.getPointDatas(), firstZsgl);
+            String ybj = "GJNY_SXGS_FSG_F_WT_0013_EQ,GJNY_SXGS_FSG_F_WT_0042_EQ,GJNY_SXGS_FSG_F_WT_0062_EQ,GJNY_SXGS_FSG_F_WT_0064_EQ";
             ztMap.forEach((wtId, ztInfo) -> {
             ztMap.forEach((wtId, ztInfo) -> {
+                if (ybj.contains(wtId)) return;
                 List<PointData> fss = fsMap.get(wtId).getPointDatas();
                 List<PointData> fss = fsMap.get(wtId).getPointDatas();
                 List<PointData> gls = glMapMap.get(stId).get(wtId);
                 List<PointData> gls = glMapMap.get(stId).get(wtId);
                 //叶轮转速给定
                 //叶轮转速给定
@@ -1319,7 +1575,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
     public List<PointData> boolPointDatasFull(boolean v, List<PointData> data, long startTime, long endTime, int interval) {
     public List<PointData> boolPointDatasFull(boolean v, List<PointData> data, long startTime, long endTime, int interval) {
         int j = 0, m = 0;
         int j = 0, m = 0;
         List<PointData> data2 = new ArrayList<>();
         List<PointData> data2 = new ArrayList<>();
-        for (long i = startTime; i < endTime; i += interval * 1000L) {
+        for (long i = startTime; i <= endTime; i += interval * 1000L) {
             PointData dt = new PointData();
             PointData dt = new PointData();
             dt.setTs(i);
             dt.setTs(i);
             data2.add(dt);
             data2.add(dt);
@@ -1343,7 +1599,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
     public List<PointData> doublePointDatasFull(double v, List<PointData> data, long startTime, long endTime, int interval) {
     public List<PointData> doublePointDatasFull(double v, List<PointData> data, long startTime, long endTime, int interval) {
         int j = 0, m = 0;
         int j = 0, m = 0;
         List<PointData> data2 = new ArrayList<>();
         List<PointData> data2 = new ArrayList<>();
-        for (long i = startTime; i < endTime; i += interval * 1000L) {
+        for (long i = startTime; i <= endTime; i += interval * 1000L) {
             PointData dt = new PointData();
             PointData dt = new PointData();
             dt.setTs(i);
             dt.setTs(i);
             data2.add(dt);
             data2.add(dt);
@@ -1394,6 +1650,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
         Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
 
 
         //        Map<String, Map<Double,Double>> fitMap = new HashMap<>();
         //        Map<String, Map<Double,Double>> fitMap = new HashMap<>();
+//        entityFs = entityFs.stream().filter(ef -> !CalcCache.keys.contains(ef.getTurbineId())).collect(Collectors.toList());
         for (PointInfo ef : entityFs) {
         for (PointInfo ef : entityFs) {
             String wtId = ef.getTurbineId();
             String wtId = ef.getTurbineId();
             PointInfo glInfo = glMap.get(wtId);
             PointInfo glInfo = glMap.get(wtId);
@@ -1419,12 +1676,77 @@ public class JavaFunctionJobHandler extends IJobHandler {
             }
             }
             ef.setPointDatas(null);
             ef.setPointDatas(null);
             glInfo.setPointDatas(null);
             glInfo.setPointDatas(null);
-            stringRedisTemplate.opsForValue().set("edfs:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
+            String key = "glqxnh:" + (end.getMonth() + 1) + ":" + wtId;
+            stringRedisTemplate.opsForValue().set(key, JSON.toJSONString(fit));
+            CalcCache.fitcoef.put(key, new ConcurrentHashMap<>(fit));
         }
         }
         System.out.println("苹果天涯");
         System.out.println("苹果天涯");
         //        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
         //        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
     }
     }
 
 
+    public void calcGlqxnhSurplus(Date start, Date end) {
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        Map<String, PointInfo> glMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
+
+        Map<String, EquipmentModel> map = equipmentModelService.map();
+
+        List<PointInfo> entity = new ArrayList<>();
+        List<PointInfo> entity0 = getEntity("MX000", "state");
+        List<PointInfo> entity1 = getEntity("MX001", "state");
+        List<PointInfo> entity2 = getEntity("MX002", "state");
+        List<PointInfo> entity4 = getEntity("MX004", "state");
+        List<PointInfo> entity6 = getEntity("MX006", "state");
+        entity.addAll(entity0);
+        entity.addAll(entity1);
+        entity.addAll(entity2);
+        entity.addAll(entity4);
+        entity.addAll(entity6);
+        List<String> keys = entity.stream().map(PointInfo::getPointKey).collect(Collectors.toList());
+        Map<String, PointData> latest = adapter.getHistorySection(goldenUri(), String.join(",", keys), start.getTime());
+        Map<String, Map<String, PointInfo>> wtUcPis = entity.stream().collect(Collectors.groupingBy(PointInfo::getTurbineId, Collectors.toMap(PointInfo::getUniformCode, Function.identity())));
+
+        List<PointInfo> entityAiZt = getEntity("AI422", "state");
+        Map<String, PointInfo> aiztMap = entityAiZt.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
+        List<StateAi> list = stateAiService.list();
+        Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
+
+        //        Map<String, Map<Double,Double>> fitMap = new HashMap<>();
+        entityFs = entityFs.stream().filter(ef -> !CalcCache.already.contains(ef.getTurbineId())).collect(Collectors.toList());
+        for (PointInfo ef : entityFs) {
+            String wtId = ef.getTurbineId();
+            PointInfo glInfo = glMap.get(wtId);
+            getSnapDataByEntity(ef, start, end, 60);
+            getSnapDataByEntity(glInfo, start, end, 60);
+            List<PointData> peek = ef.getPointDatas().stream().peek(pd -> pd.setDoubleValue(NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
+            ef.setPointDatas(peek);
+
+            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<>();
+            if (turbineZt != null) {
+                double 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) {
+                double capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
+                fit = dataProcessAndFit(ef, glInfo, turbineAizt, CalcCache.bzgl.get(turbineAizt.getSpare()), capacity);
+                //                fitMap.put(wtId, fit);
+                turbineAizt.setPointDatas(null);
+            }
+            ef.setPointDatas(null);
+            glInfo.setPointDatas(null);
+            String key = "glqxnh:" + (end.getMonth() + 1) + ":" + wtId;
+            stringRedisTemplate.opsForValue().set(key, JSON.toJSONString(fit));
+            CalcCache.fitcoef.put(key, new ConcurrentHashMap<>(fit));
+        }
+        System.out.println("苹果天涯");
+        //        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
+    }
 
 
     public Map<Double, Double> dataProcessAndFit(PointInfo fsPI, PointInfo glPI, PointInfo ztPI, Map<Double, Double> modelPowerMap, double capacity) {
     public Map<Double, Double> dataProcessAndFit(PointInfo fsPI, PointInfo glPI, PointInfo ztPI, Map<Double, Double> modelPowerMap, double capacity) {
         System.out.println("开始拟合");
         System.out.println("开始拟合");
@@ -1432,6 +1754,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         List<PointData> glPds = glPI.getPointDatas();
         List<PointData> glPds = glPI.getPointDatas();
         List<PointData> ztPds = ztPI.getPointDatas();
         List<PointData> ztPds = ztPI.getPointDatas();
         WeightedObservedPoints points = new WeightedObservedPoints();
         WeightedObservedPoints points = new WeightedObservedPoints();
+        if (ztPds.size() - glPds.size() == 1) ztPds.remove(glPds.size());
         //数据过滤 0正常,1过滤掉
         //数据过滤 0正常,1过滤掉
         if (fsPds.size() != glPds.size() || glPds.size() != ztPds.size()) return new HashMap<>();
         if (fsPds.size() != glPds.size() || glPds.size() != ztPds.size()) return new HashMap<>();
 
 
@@ -1528,16 +1851,27 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }
         }
     }
     }
 
 
+    public void getSectionDataByEntity(List<PointInfo> entitys, URI uri, Date start, Date end) {
+        String collect = entitys.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
+        Map<String, PointData> section0 = adapter.getHistorySection(uri, collect, start.getTime());
+        Map<String, PointData> section1 = adapter.getHistorySection(uri, collect, end.getTime());
+        for (PointInfo entity : entitys) {
+            entity.setPointDatas(new ArrayList<>());
+            entity.getPointDatas().add(section0.get(entity.getPointKey()));
+            entity.getPointDatas().add(section1.get(entity.getPointKey()));
+        }
+    }
+
     public void getSnapDataByEntity(List<PointInfo> entity, URI uri, Date start, Date end, int interval) {
     public void getSnapDataByEntity(List<PointInfo> entity, URI uri, Date start, Date end, int interval) {
         for (PointInfo info : entity) {
         for (PointInfo info : entity) {
-            List<PointData> snap = adapter.getHistorySnap(uri, info.getPointKey(), start.getTime(), end.getTime(), interval);
+            getSnapDataByEntity(info, uri, start, end, interval);
             ThreadUtil.sleep(5);
             ThreadUtil.sleep(5);
-            info.setPointDatas(snap);
         }
         }
     }
     }
 
 
     public void getSnapDataByEntity(PointInfo entity, URI uri, Date start, Date end, int interval) {
     public void getSnapDataByEntity(PointInfo entity, URI uri, Date start, Date end, int interval) {
-        getSnapDataByEntity(Collections.singletonList(entity), uri, start, end, interval);
+        List<PointData> snap = adapter.getHistorySnap(uri, entity.getPointKey(), start.getTime(), end.getTime(), interval);
+        entity.setPointDatas(snap);
     }
     }
 
 
     public void getSnapDataByEntity(List<PointInfo> entity, Date start, Date end, int interval) {
     public void getSnapDataByEntity(List<PointInfo> entity, Date start, Date end, int interval) {
@@ -2742,19 +3076,27 @@ public class JavaFunctionJobHandler extends IJobHandler {
         for (PointInfo info : entity) {
         for (PointInfo info : entity) {
             DoubleStatData stat = adapter.getHistoryStat(uri, info.getPointKey(), start.getTime(), end.getTime());
             DoubleStatData stat = adapter.getHistoryStat(uri, info.getPointKey(), start.getTime(), end.getTime());
             ThreadUtil.sleep(5);
             ThreadUtil.sleep(5);
-            info.getPointDatas().add(stat.getAvg());
-            info.getPointDatas().add(stat.getMax());
-            info.getPointDatas().add(stat.getMin());
+            info.setPointDatas(new ArrayList<>(3));
+            if (stat != null) {
+                info.getPointDatas().add(stat.getAvg());
+                info.getPointDatas().add(stat.getMax());
+                info.getPointDatas().add(stat.getMin());
+            } else {
+                info.getPointDatas().add(new PointData());
+                info.getPointDatas().add(new PointData());
+                info.getPointDatas().add(new PointData());
+            }
         }
         }
     }
     }
 
 
-    public Map<String, PointInfo> getStatDataByEntityMap(List<PointInfo> entity, URI uri, Date start, Date end,Function<PointInfo,String> function) {
+    public Map<String, PointInfo> getStatDataByEntity(List<PointInfo> entity, URI uri, Date start, Date end, Function<PointInfo, String> function) {
         getStatDataByEntity(entity, uri, start, end);
         getStatDataByEntity(entity, uri, start, end);
         return entity.stream().collect(Collectors.toMap(function, Function.identity()));
         return entity.stream().collect(Collectors.toMap(function, Function.identity()));
     }
     }
 
 
     // 主函数或测试方法(如果需要)
     // 主函数或测试方法(如果需要)
     public static void main(String[] args) {
     public static void main(String[] args) {
+
         Double b = 2.0;
         Double b = 2.0;
         double c = 2.0;
         double c = 2.0;
         System.out.println(b == c);
         System.out.println(b == c);
@@ -3092,6 +3434,117 @@ public class JavaFunctionJobHandler extends IJobHandler {
         reportIndicatorPoolService.saveOrUpdate(poolsCompany);
         reportIndicatorPoolService.saveOrUpdate(poolsCompany);
     }
     }
 
 
+
+    public void writeReportPoolPjfs2(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,station_id")
+                .eq("record_date", time0).groupBy("project_id,station_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,station_id")
+                .between("record_date", beginOfMonth, time0).groupBy("project_id,station_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,station_id")
+                .between("record_date", beginOfYear, time0).groupBy("project_id,station_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> poolsProject = reportIndicatorPoolService.list(wrapperRp);
+        wrapperRp = new QueryWrapper<>();
+        wrapperRp.eq("record_date", time0).last("and foreign_key_id = windpowerstation_id");
+        List<ProEconReportIndicatorPool> poolsStation = reportIndicatorPoolService.list(wrapperRp);
+        wrapperRp = new QueryWrapper<>();
+        wrapperRp.eq("record_date", time0).eq("foreign_key_id", "GJNY_SXGS_DBXNY_ZGS0");
+        ProEconReportIndicatorPool poolsCompany = reportIndicatorPoolService.getOne(wrapperRp);
+
+        TurbineInfoDay day, month, year;
+        String projectId;
+        if (poolsProject.isEmpty()) {
+            for (TurbineInfoDay infoDay : days) {
+                projectId = infoDay.getProjectId();
+                ProEconReportIndicatorPool pool = new ProEconReportIndicatorPool();
+                pool.setRecordDate(time0);
+                pool.setForeignKeyId(projectId);
+                pool.setWindpowerstationId(infoDay.getStationId());
+                pool.setProjectId(projectId);
+                month = monthMap.get(projectId);
+                year = yearMap.get(projectId);
+
+                pool.setRpjfs(infoDay.getPjfs());
+                pool.setYpjfs(month.getPjfs());
+                pool.setNpjfs(year.getPjfs());
+
+                poolsProject.add(pool);
+            }
+        } else {
+            for (ProEconReportIndicatorPool pool : poolsProject) {
+                projectId = pool.getProjectId();
+                day = dayMap.get(projectId);
+                month = monthMap.get(projectId);
+                year = yearMap.get(projectId);
+
+                pool.setRpjfs(day.getPjfs());
+                pool.setYpjfs(month.getPjfs());
+                pool.setNpjfs(year.getPjfs());
+            }
+        }
+        reportIndicatorPoolService.saveOrUpdateBatch(poolsProject);
+        Map<String, List<ProEconReportIndicatorPool>> projectMap = poolsProject.stream().collect(Collectors.groupingBy(ProEconReportIndicatorPool::getWindpowerstationId));
+        if (poolsStation.isEmpty()) {
+            projectMap.forEach((StId, pis) -> {
+                ProEconReportIndicatorPool pool = new ProEconReportIndicatorPool();
+                pool.setRecordDate(time0);
+                pool.setForeignKeyId(StId);
+                pool.setWindpowerstationId(StId);
+
+                ProEconReportIndicatorPool p = sumProperties(pis, ProEconReportIndicatorPool.class);
+                pool.setRpjfs(p.getRpjfs() / pis.size());
+                pool.setYpjfs(p.getYpjfs() / pis.size());
+                pool.setNpjfs(p.getNpjfs() / pis.size());
+                poolsStation.add(pool);
+            });
+        } else {
+            for (ProEconReportIndicatorPool pool : poolsStation) {
+                List<ProEconReportIndicatorPool> pools = projectMap.get(pool.getWindpowerstationId());
+
+                ProEconReportIndicatorPool p = sumProperties(pools, ProEconReportIndicatorPool.class);
+                pool.setRpjfs(p.getRpjfs() / pools.size());
+                pool.setYpjfs(p.getYpjfs() / pools.size());
+                pool.setNpjfs(p.getNpjfs() / pools.size());
+            }
+        }
+        reportIndicatorPoolService.saveOrUpdateBatch(poolsStation);
+        if (poolsCompany == null) {
+            poolsCompany = new ProEconReportIndicatorPool();
+            poolsCompany.setRecordDate(time0);
+            poolsCompany.setForeignKeyId("GJNY_SXGS_DBXNY_ZGS0");
+            poolsCompany.setCompanyId("GJNY_SXGS_DBXNY_ZGS");
+
+            ProEconReportIndicatorPool p = sumProperties(poolsStation, ProEconReportIndicatorPool.class);
+            poolsCompany.setRpjfs(p.getRpjfs() / poolsStation.size());
+            poolsCompany.setYpjfs(p.getYpjfs() / poolsStation.size());
+            poolsCompany.setNpjfs(p.getNpjfs() / poolsStation.size());
+        } else {
+            ProEconReportIndicatorPool p = sumProperties(poolsStation, ProEconReportIndicatorPool.class);
+            poolsCompany.setRpjfs(p.getRpjfs() / poolsStation.size());
+            poolsCompany.setYpjfs(p.getYpjfs() / poolsStation.size());
+            poolsCompany.setNpjfs(p.getNpjfs() / poolsStation.size());
+        }
+        reportIndicatorPoolService.saveOrUpdate(poolsCompany);
+    }
+
     public void poolSetValue1(ProEconReportIndicatorPool pool, TurbineInfoDay day, TurbineInfoDay month, TurbineInfoDay year) {
     public void poolSetValue1(ProEconReportIndicatorPool pool, TurbineInfoDay day, TurbineInfoDay month, TurbineInfoDay year) {
         pool.setRpjfs(day.getPjfs());
         pool.setRpjfs(day.getPjfs());
         pool.setRgzssdl(day.getGzss() == null ? day.getFjhjxss() * 0.11 : day.getGzss());
         pool.setRgzssdl(day.getGzss() == null ? day.getFjhjxss() * 0.11 : day.getGzss());
@@ -3251,9 +3704,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return a + b;
         return a + b;
     }
     }
 
 
-    public double calcQfzt(double ssgl, double zsgl) {
+    public double calcQfzt(Double ssgl, Double zsgl) {
+        if (ssgl == null || ssgl < 0) ssgl = 0.0;
         double qfzt, ratioll;
         double qfzt, ratioll;
-        ratioll = zsgl != 0 ? (zsgl - ssgl) / zsgl : 0;
+        ratioll = (zsgl == null || zsgl <= 0) ? 0 : (zsgl - ssgl) / zsgl;
         if (ratioll < 0.05) {
         if (ratioll < 0.05) {
             qfzt = 0;
             qfzt = 0;
         } else if (ratioll < 0.1) {
         } else if (ratioll < 0.1) {
@@ -3268,14 +3722,14 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return qfzt;
         return qfzt;
     }
     }
 
 
-    public List<TurbineInfoMin> getTurbineinfoMin(Date date) {
+    public List<TurbineInfoMin> getTurbineinfoByMin(Date date) {
         QueryWrapper<TurbineInfoMin> wrapper = new QueryWrapper<>();
         QueryWrapper<TurbineInfoMin> wrapper = new QueryWrapper<>();
         wrapper.eq("record_date", date);
         wrapper.eq("record_date", date);
         return turbineInfoMinService.list(wrapper);
         return turbineInfoMinService.list(wrapper);
     }
     }
 
 
-    public List<TurbineInfoMin> getTurbineinfoMinByEntity(Date date, List<PointInfo> entity) {
-        List<TurbineInfoMin> list = getTurbineinfoMin(date);
+    public List<TurbineInfoMin> getTurbineinfoByMin(Date date, List<PointInfo> entity) {
+        List<TurbineInfoMin> list = getTurbineinfoByMin(date);
         if (list.isEmpty()) {
         if (list.isEmpty()) {
             entity.forEach(pi -> {
             entity.forEach(pi -> {
                 TurbineInfoMin day = new TurbineInfoMin();
                 TurbineInfoMin day = new TurbineInfoMin();
@@ -3290,17 +3744,17 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return list;
         return list;
     }
     }
 
 
-    public Map<String, TurbineInfoMin> getTurbineinfoMinMap(Date date) {
-        List<TurbineInfoMin> tims = getTurbineinfoMin(date);
+    public Map<String, TurbineInfoMin> getTurbineinfoByMinMap(Date date) {
+        List<TurbineInfoMin> tims = getTurbineinfoByMin(date);
         return tims.stream().collect(Collectors.toMap(TurbineInfoMin::getTurbineId, Function.identity()));
         return tims.stream().collect(Collectors.toMap(TurbineInfoMin::getTurbineId, Function.identity()));
     }
     }
 
 
-    public Map<String, TurbineInfoMin> getTurbineinfoMinMapByEntity(Date date, List<PointInfo> entity) {
-        List<TurbineInfoMin> tims = getTurbineinfoMinByEntity(date, entity);
+    public Map<String, TurbineInfoMin> getTurbineinfoByMinMap(Date date, List<PointInfo> entity) {
+        List<TurbineInfoMin> tims = getTurbineinfoByMin(date, entity);
         return tims.stream().collect(Collectors.toMap(TurbineInfoMin::getTurbineId, Function.identity()));
         return tims.stream().collect(Collectors.toMap(TurbineInfoMin::getTurbineId, Function.identity()));
     }
     }
 
 
-    public Map<String, PointInfo> getRawDataMapByEntity(List<PointInfo> entity, URI uri, Date start, Date end, Function<PointInfo, String> function) {
+    public Map<String, PointInfo> getRawDataByEntity(List<PointInfo> entity, URI uri, Date start, Date end, Function<PointInfo, String> function) {
         getRawDataByEntity(entity, uri, start, end);
         getRawDataByEntity(entity, uri, start, end);
         return entity.stream().collect(Collectors.toMap(function, Function.identity()));
         return entity.stream().collect(Collectors.toMap(function, Function.identity()));
     }
     }
@@ -3310,28 +3764,26 @@ public class JavaFunctionJobHandler extends IJobHandler {
         DateTime start = DateUtil.offsetMinute(date, -granularity);
         DateTime start = DateUtil.offsetMinute(date, -granularity);
         //风速
         //风速
         List<PointInfo> entityFs = getEntity("AI066", "turbine");
         List<PointInfo> entityFs = getEntity("AI066", "turbine");
-        Map<String, PointInfo> rawMapFs = getRawDataMapByEntity(entityFs, goldenUri(), start, date, PointInfo::getTurbineId);
+        Map<String, PointInfo> rawMapFs = getRawDataByEntity(entityFs, goldenUri(), start, date, PointInfo::getTurbineId);
         //功率
         //功率
         List<PointInfo> entityGl = getEntity("AI114", "turbine");
         List<PointInfo> entityGl = getEntity("AI114", "turbine");
-        Map<String, PointInfo> rawMapGl = getRawDataMapByEntity(entityGl, goldenUri(), start, date, PointInfo::getTurbineId);
+        Map<String, PointInfo> rawMapGl = getRawDataByEntity(entityGl, goldenUri(), start, date, PointInfo::getTurbineId);
         List<PointInfo> entityZt = getEntity("MXZT", "turbine");
         List<PointInfo> entityZt = getEntity("MXZT", "turbine");
-        Map<String, PointInfo> rawMapZt = getRawDataMapByEntity(entityZt, goldenUri(), start, date, PointInfo::getTurbineId);
+        Map<String, PointInfo> rawMapZt = getRawDataByEntity(entityZt, goldenUri(), start, date, PointInfo::getTurbineId);
 
 
-        List<TurbineInfoMin> mins = getTurbineinfoMinByEntity(date, entityFs);
+        List<TurbineInfoMin> mins = getTurbineinfoByMin(date, entityFs);
         for (TurbineInfoMin min : mins) {
         for (TurbineInfoMin min : mins) {
             String tbId = min.getTurbineId();
             String tbId = min.getTurbineId();
             List<PointData> fsDatas = rawMapFs.get(tbId).getPointDatas();
             List<PointData> fsDatas = rawMapFs.get(tbId).getPointDatas();
             List<PointData> ztDatas = rawMapZt.get(tbId).getPointDatas();
             List<PointData> ztDatas = rawMapZt.get(tbId).getPointDatas();
             ztDatas = doublePointDatasFull(2, ztDatas, start.getTime(), date.getTime(), 1);
             ztDatas = doublePointDatasFull(2, ztDatas, start.getTime(), date.getTime(), 1);
             Map<Long, Double> ztMap = ztDatas.stream().collect(Collectors.toMap(PointData::getTs, PointData::getValue));
             Map<Long, Double> ztMap = ztDatas.stream().collect(Collectors.toMap(PointData::getTs, PointData::getValue));
-            double pjfs = fsDatas.stream().mapToDouble(PointData::getValue).average().orElse(0);
-            fsDatas = fsDatas.stream().peek(pd -> pd.setDoubleValue(NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
-            double llgl = fsDatas.stream().peek(pd -> pd.setDoubleValue(CalcCache.llgl.get(tbId).get(pd.getValue())))
-                    .mapToDouble(PointData::getValue).average().orElse(0);
+            double pjfs = fsDatas.stream().mapToDouble(PointData::getValue).average().orElse(0.0);
+            fsDatas.stream().peek(pd -> pd.setDoubleValue(pd.getValue() > 25 ? 25 : pd.getValue() < 0 ? 0 : NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
+            double llgl = fsDatas.stream().mapToDouble(pd -> pd.getValue() < 3 ? 0d : CalcCache.llgl.get(tbId).get(pd.getValue())).average().orElse(0.0);
             double kygl = fsDatas.stream().filter(pd -> ztMap.get(pd.getTs()) != 4 || ztMap.get(pd.getTs()) != 6)
             double kygl = fsDatas.stream().filter(pd -> ztMap.get(pd.getTs()) != 4 || ztMap.get(pd.getTs()) != 6)
-                    .peek(pd -> pd.setDoubleValue(CalcCache.fitcoef.get(tbId).get(pd.getValue())))
-                    .mapToDouble(PointData::getValue).average().orElse(0);
-            double sjgl = rawMapGl.get(tbId).getPointDatas().stream().mapToDouble(PointData::getValue).average().orElse(0);
+                    .mapToDouble(pd -> CalcCache.fitcoef.get(tbId).get(pd.getValue())).average().orElse(0.0);
+            double sjgl = rawMapGl.get(tbId).getPointDatas().stream().mapToDouble(PointData::getValue).average().orElse(0.0);
 
 
             double v = llgl * 0.9;
             double v = llgl * 0.9;
             if (kygl > v) kygl = v;
             if (kygl > v) kygl = v;
@@ -3350,24 +3802,26 @@ public class JavaFunctionJobHandler extends IJobHandler {
 
 
         //AGC
         //AGC
         List<PointInfo> entityAgc = getEntity("AGC002", "booster");
         List<PointInfo> entityAgc = getEntity("AGC002", "booster");
-        Map<String, PointInfo> statMapAgc = getStatDataByEntityMap(entityAgc, goldenUri(), start, date, PointInfo::getTurbineId);
+        Map<String, PointInfo> statMapAgc = getStatDataByEntity(entityAgc, goldenUri(), start, date, PointInfo::getStationId);
         //出线
         //出线
         List<PointInfo> entityCx = getEntity("AGC001", "booster");
         List<PointInfo> entityCx = getEntity("AGC001", "booster");
-        Map<String, PointInfo> statMapCx = getStatDataByEntityMap(entityCx, goldenUri(), start, date, PointInfo::getTurbineId);
+        Map<String, PointInfo> statMapCx = getStatDataByEntity(entityCx, goldenUri(), start, date, PointInfo::getStationId);
 
 
         QueryWrapper<TurbineInfoMin> wrapper = new QueryWrapper<>();
         QueryWrapper<TurbineInfoMin> wrapper = new QueryWrapper<>();
-        wrapper.select("sum(llgl) llgl,sum(kygl) kygl,sum(pjfs) pjfs,station_id").eq("record_date", date).groupBy("station_id");
+        wrapper.select("sum(llgl) llgl,sum(kygl) kygl,avg(pjfs) pjfs,station_id").eq("record_date", date).groupBy("station_id");
         List<TurbineInfoMin> list = turbineInfoMinService.list(wrapper);
         List<TurbineInfoMin> list = turbineInfoMinService.list(wrapper);
         Map<String, TurbineInfoMin> minMap = list.stream().collect(Collectors.toMap(TurbineInfoMin::getStationId, Function.identity()));
         Map<String, TurbineInfoMin> minMap = list.stream().collect(Collectors.toMap(TurbineInfoMin::getStationId, Function.identity()));
-        List<StationInfoMin> byDate = getStationinfoMinByDate(date,entityAgc);
+        List<StationInfoMin> byDate = getStationinfoByMin(date, entityAgc);
 
 
         for (StationInfoMin day : byDate) {
         for (StationInfoMin day : byDate) {
             String stId = day.getStationId();
             String stId = day.getStationId();
             TurbineInfoMin min = minMap.get(stId);
             TurbineInfoMin min = minMap.get(stId);
+            PointInfo agcInfo = statMapAgc.get(stId);
+            PointInfo cxInfo = statMapCx.get(stId);
             day.setLlgl(min.getLlgl());
             day.setLlgl(min.getLlgl());
             day.setKygl(min.getKygl());
             day.setKygl(min.getKygl());
-            day.setAgc(statMapAgc.get(stId).getPointDatas().get(0).getValue());
-            day.setPjgl(statMapCx.get(stId).getPointDatas().get(0).getValue());
+            day.setAgc(agcInfo.getPointDatas().get(0).getValue() * agcInfo.getCoef());
+            day.setPjgl(cxInfo.getPointDatas().get(0).getValue() * cxInfo.getCoef());
             day.setPjfs(min.getPjfs());
             day.setPjfs(min.getPjfs());
         }
         }
         stationInfoMinService.saveOrUpdateBatch(byDate);
         stationInfoMinService.saveOrUpdateBatch(byDate);

+ 82 - 19
ruoyi-admin/src/test/java/com/ruoyi/NewTests.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateRange;
 import cn.hutool.core.date.DateRange;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.text.StrBuilder;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -20,6 +21,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.net.URI;
 import java.net.URI;
 import java.util.*;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Function;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -32,19 +34,73 @@ public class NewTests {
 
 
     @Test
     @Test
     public void test() {
     public void test() {
-        Date date = DateUtil.date();
-        task.calcTurbineStateMin(date);
+//        task.calcTurbineRFDLSameDay();
+//        task.calcTurbine5s2SameDay();
+        /*Map<Double, Double> a1 = CalcCache.fitcoef.get("GJNY_SXGS_JSL_F_WT_0001_EQ");
+        Map<Double, Double> a3 = CalcCache.fitcoef.get("GJNY_SXGS_JSL_F_WT_0003_EQ");
+        TreeMap<Double, Double> b1 = new TreeMap<>();
+        TreeMap<Double, Double> b3 = new TreeMap<>();
+        b1.putAll(a1);
+        b3.putAll(a3);
+        StrBuilder sb = new StrBuilder();
+        for (Double v : b1.keySet()) {
+            sb.append(v).append(",");
+        }
+        System.out.println(sb);
+        StrBuilder sb2 = new StrBuilder();
+        for (Double v : b1.values()) {
+            sb2.append(v).append(",");
+        }
+        System.out.println(sb2);
+        StrBuilder sb3 = new StrBuilder();
+        for (Double v : b3.values()) {
+            sb3.append(v).append(",");
+        }
+        System.out.println(sb3);
+        System.out.println();*/
+
+//        Date date = DateUtil.date();
+//        task.ambientTemperature();
+
+//        task.calcTurbine5s2(date);
+//        task.calcLineRfdl(date);
+
+//        task.calcStationZhcyRfDl(date,"GJNY_SXGS_XZ_FDC_STA");
+//        task.writeReportPool(date);
+//        task.writeReportPoolProject(date);
+
+//        task.calcTurbine5s2(date);
+//        task.calcStationSwGwCyRdl(date,"GJNY_SXGS_XZ_FDC_STA");
+//        task.calcStationZhcyRfDl(date);
+//        task.writeReportPool(date);
+//        task.writeReportPoolPjfs2(date);
+//        task.SwdlRepair(date);
+//        task.calcLineRfdl(date);
+//        task.calcTurbineStateMin(date);
 //        calcStationZhcydl(date);
 //        calcStationZhcydl(date);
 //        calcNhglZs(date);
 //        calcNhglZs(date);
         // 创建日期范围生成器
         // 创建日期范围生成器
-        DateTime start = DateUtil.parse("2024-07-02");
-//        DateTime start = DateUtil.parse("2024-05-01");
-        DateTime end = DateUtil.parse("2024-07-18");
-        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
-        for (DateTime time : range) {
-            date = time.toJdkDate();
-            System.out.println(DateUtil.date().toString() + ":" + time.toString());
-            //安全天数
+        DateTime date = DateUtil.date();
+        task.calcTurbine5s2(date);
+
+
+//        DateTime start = DateUtil.parse("2023-06-27");
+//        DateTime end = DateUtil.parse("2023-09-27");
+//        task.calcGlqxnhSurplus(start, end);
+//        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
+//        for (DateTime date : range) {
+//            System.out.println(DateUtil.date().toString() + ":" + date.toString());
+
+            /*task.calcLineRfdl(date);
+            //上网购网厂用电量
+            task.calcStationSwGwCyRdl(date);
+            //计算综合厂用电量
+            task.calcStationZhcyRfDl(date);*/
+
+
+//            task.calcTurbineRFDL(date);
+//            task.writeReportPoolPjfs2(date);
+        //安全天数
 //            calcAQTS(time.toJdkDate());
 //            calcAQTS(time.toJdkDate());
             /*task.calcLineRfdl(date,"GJNY_SXGS_ZZ_FDC_STA");
             /*task.calcLineRfdl(date,"GJNY_SXGS_ZZ_FDC_STA");
             task.calcStationSwGwCyRdl(date);
             task.calcStationSwGwCyRdl(date);
@@ -73,8 +129,7 @@ public class NewTests {
             task.calcLineSwGWCyDlSameDay();
             task.calcLineSwGWCyDlSameDay();
             task.writeReportPoolSameDay();
             task.writeReportPoolSameDay();
             task.writeReportPoolProjectSameDay();*/
             task.writeReportPoolProjectSameDay();*/
-        }
-//        task.calcGlqxnh(start,end);
+//    }
 //        calcTurbineRFDL(date);
 //        calcTurbineRFDL(date);
 //        task.calcTurbine5s2(date);
 //        task.calcTurbine5s2(date);
 //        writeReportPool(date);
 //        writeReportPool(date);
@@ -84,25 +139,33 @@ public class NewTests {
             task.calcRealtimeTurbineZt();
             task.calcRealtimeTurbineZt();
             ThreadUtil.sleep(1000);
             ThreadUtil.sleep(1000);
         }*/
         }*/
-        task.calcRealtimeTurbineZt();
+//        task.calcRealtimeTurbineZt();
     }
     }
 
 
     @Test
     @Test
     public void test2() {
     public void test2() {
         // 创建日期范围生成器
         // 创建日期范围生成器
-        DateTime start = DateUtil.parse("2024-07-10");
-        DateTime end = DateUtil.parse("2024-07-16");
-        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
+        DateTime start = DateUtil.parse("2024-10-12");
+        DateTime end = DateUtil.parse("2024-10-14");
+        DateRange range = DateUtil.range(start, end, DateField.HOUR_OF_DAY);
         for (DateTime date : range) {
         for (DateTime date : range) {
             System.out.println(DateUtil.date() + ":" + date);
             System.out.println(DateUtil.date() + ":" + date);
+            task.calcAQTS(date);
 //            task.calcLineRfdl(date,"GJNY_SXGS_JSL_FDC_STA");
 //            task.calcLineRfdl(date,"GJNY_SXGS_JSL_FDC_STA");
 //            task.calcStationSwGwCyRdl(date,"GJNY_SXGS_JSL_FDC_STA");
 //            task.calcStationSwGwCyRdl(date,"GJNY_SXGS_JSL_FDC_STA");
 //            task.calcStationZhcyRfDl(date,"GJNY_SXGS_JSL_FDC_STA");
 //            task.calcStationZhcyRfDl(date,"GJNY_SXGS_JSL_FDC_STA");
 //            task.calcLineSwGWCyDl(date,"GJNY_SXGS_JSL_FDC_STA");
 //            task.calcLineSwGWCyDl(date,"GJNY_SXGS_JSL_FDC_STA");
 //            task.writeReportPool(date);
 //            task.writeReportPool(date);
-            task.writeReportPoolProject(date);
+//            task.writeReportPoolProject(date);
+//            task.calcStationHourPjglRfdl(DateUtil.date());
         }
         }
-        DateTime date = DateUtil.date();
-        task.calcStationHourPJGL(date);
+//        task.calcStationHourPjglRfdl(DateUtil.date());
+//        DateTime date = DateUtil.date();
+//        task.calcStationHourPJGL(date);
+//        task.calcLineRfdl(date);
+//        task.calcStationHourRFDL(date);
+//        task.calcTurbinePjfsPjglKyglLlglMin(DateUtil.date(), 15);
+//        task.calcStationLlglKyglSjglAgcMin(date, 15);
     }
     }
+
 }
 }

文件差異過大導致無法顯示
+ 2446 - 0
ruoyi-admin/src/test/java/com/ruoyi/dd.java


+ 1 - 0
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java

@@ -48,6 +48,7 @@ public class JobInvokeUtil {
     private static String getJavaGlue() {
     private static String getJavaGlue() {
         String JavaGlue = "package com.ruoyi.quartz;\n" +
         String JavaGlue = "package com.ruoyi.quartz;\n" +
                 "import com.ruoyi.quartz.handler.IJobHandler;\n" +
                 "import com.ruoyi.quartz.handler.IJobHandler;\n" +
+                "import cn.hutool.core.date.DateTime;\n" +
                 "import cn.hutool.core.date.DateUtil;\n" +
                 "import cn.hutool.core.date.DateUtil;\n" +
                 "import cn.hutool.core.thread.ThreadUtil;\n" +
                 "import cn.hutool.core.thread.ThreadUtil;\n" +
                 "public class JavaGlueJobHandler extends IJobHandler {\n" +
                 "public class JavaGlueJobHandler extends IJobHandler {\n" +

+ 395 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/ProBasicEquipment.java

@@ -0,0 +1,395 @@
+package com.ruoyi.ucp.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * <p>
+ * ���&���
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-10-14
+ */
+@TableName("pro_basic_equipment")
+public class ProBasicEquipment implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ���
+     */
+    private String id;
+
+    /**
+     * ����
+     */
+    private String nemCode;
+
+    /**
+     * ��վ���(����)
+     */
+    private String windpowerstationId;
+
+    /**
+     * ���򾭶�
+     */
+    private BigDecimal longitude;
+
+    /**
+     * �����
+     */
+    private BigDecimal latitude;
+
+    /**
+     * �ͺű��
+     */
+    private String modelId;
+
+    /**
+     * ״̬
+     */
+    private String status;
+
+    /**
+     * ���̱��(����)
+     */
+    private String projectId;
+
+    /**
+     * ��·���
+     */
+    private String lineId;
+
+    /**
+     * �״β���ʱ��
+     */
+    private LocalDate firstIntegratedTime;
+
+    /**
+     * ͼƬ
+     */
+    private String photo;
+
+    /**
+     * ����
+     */
+    private String name;
+
+    /**
+     * ����
+     */
+    private String aname;
+
+    /**
+     * �Ƿ��DZ���豸
+     */
+    private Integer isStandard;
+
+    /**
+     * ������
+     */
+    private String regionId;
+
+    /**
+     * ��˾���
+     */
+    private String companyId;
+
+    /**
+     * �Ƿ����
+     */
+    private Integer isable;
+
+    /**
+     * 1½��|2����|3����|4�鴮
+     */
+    private Integer equipmentCategory;
+
+    private String parentId;
+
+    private String squareId;
+
+    /**
+     * ����1
+     */
+    private String spare1;
+
+    /**
+     * ����2
+     */
+    private String spare2;
+
+    /**
+     * ����3
+     */
+    private String spare3;
+
+    /**
+     * ����4
+     */
+    private String spare4;
+
+    /**
+     * ����
+     */
+    private Integer orderNum;
+
+    private String substationId;
+
+    /**
+     * ���θ߶�
+     */
+    private BigDecimal altitude;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getNemCode() {
+        return nemCode;
+    }
+
+    public void setNemCode(String nemCode) {
+        this.nemCode = nemCode;
+    }
+
+    public String getWindpowerstationId() {
+        return windpowerstationId;
+    }
+
+    public void setWindpowerstationId(String windpowerstationId) {
+        this.windpowerstationId = windpowerstationId;
+    }
+
+    public BigDecimal getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(BigDecimal longitude) {
+        this.longitude = longitude;
+    }
+
+    public BigDecimal getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(BigDecimal latitude) {
+        this.latitude = latitude;
+    }
+
+    public String getModelId() {
+        return modelId;
+    }
+
+    public void setModelId(String modelId) {
+        this.modelId = modelId;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getLineId() {
+        return lineId;
+    }
+
+    public void setLineId(String lineId) {
+        this.lineId = lineId;
+    }
+
+    public LocalDate getFirstIntegratedTime() {
+        return firstIntegratedTime;
+    }
+
+    public void setFirstIntegratedTime(LocalDate firstIntegratedTime) {
+        this.firstIntegratedTime = firstIntegratedTime;
+    }
+
+    public String getPhoto() {
+        return photo;
+    }
+
+    public void setPhoto(String photo) {
+        this.photo = photo;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getAname() {
+        return aname;
+    }
+
+    public void setAname(String aname) {
+        this.aname = aname;
+    }
+
+    public Integer getIsStandard() {
+        return isStandard;
+    }
+
+    public void setIsStandard(Integer isStandard) {
+        this.isStandard = isStandard;
+    }
+
+    public String getRegionId() {
+        return regionId;
+    }
+
+    public void setRegionId(String regionId) {
+        this.regionId = regionId;
+    }
+
+    public String getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(String companyId) {
+        this.companyId = companyId;
+    }
+
+    public Integer getIsable() {
+        return isable;
+    }
+
+    public void setIsable(Integer isable) {
+        this.isable = isable;
+    }
+
+    public Integer getEquipmentCategory() {
+        return equipmentCategory;
+    }
+
+    public void setEquipmentCategory(Integer equipmentCategory) {
+        this.equipmentCategory = equipmentCategory;
+    }
+
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getSquareId() {
+        return squareId;
+    }
+
+    public void setSquareId(String squareId) {
+        this.squareId = squareId;
+    }
+
+    public String getSpare1() {
+        return spare1;
+    }
+
+    public void setSpare1(String spare1) {
+        this.spare1 = spare1;
+    }
+
+    public String getSpare2() {
+        return spare2;
+    }
+
+    public void setSpare2(String spare2) {
+        this.spare2 = spare2;
+    }
+
+    public String getSpare3() {
+        return spare3;
+    }
+
+    public void setSpare3(String spare3) {
+        this.spare3 = spare3;
+    }
+
+    public String getSpare4() {
+        return spare4;
+    }
+
+    public void setSpare4(String spare4) {
+        this.spare4 = spare4;
+    }
+
+    public Integer getOrderNum() {
+        return orderNum;
+    }
+
+    public void setOrderNum(Integer orderNum) {
+        this.orderNum = orderNum;
+    }
+
+    public String getSubstationId() {
+        return substationId;
+    }
+
+    public void setSubstationId(String substationId) {
+        this.substationId = substationId;
+    }
+
+    public BigDecimal getAltitude() {
+        return altitude;
+    }
+
+    public void setAltitude(BigDecimal altitude) {
+        this.altitude = altitude;
+    }
+
+    @Override
+    public String toString() {
+        return "ProBasicEquipment{" +
+            "id = " + id +
+            ", nemCode = " + nemCode +
+            ", windpowerstationId = " + windpowerstationId +
+            ", longitude = " + longitude +
+            ", latitude = " + latitude +
+            ", modelId = " + modelId +
+            ", status = " + status +
+            ", projectId = " + projectId +
+            ", lineId = " + lineId +
+            ", firstIntegratedTime = " + firstIntegratedTime +
+            ", photo = " + photo +
+            ", name = " + name +
+            ", aname = " + aname +
+            ", isStandard = " + isStandard +
+            ", regionId = " + regionId +
+            ", companyId = " + companyId +
+            ", isable = " + isable +
+            ", equipmentCategory = " + equipmentCategory +
+            ", parentId = " + parentId +
+            ", squareId = " + squareId +
+            ", spare1 = " + spare1 +
+            ", spare2 = " + spare2 +
+            ", spare3 = " + spare3 +
+            ", spare4 = " + spare4 +
+            ", orderNum = " + orderNum +
+            ", substationId = " + substationId +
+            ", altitude = " + altitude +
+        "}";
+    }
+}

+ 6 - 86
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/StationInfoMin.java

@@ -3,6 +3,8 @@ package com.ruoyi.ucp.entity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
 import java.io.Serializable;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Date;
 
 
@@ -14,6 +16,7 @@ import java.util.Date;
  * @author gfhd
  * @author gfhd
  * @since 2024-08-05
  * @since 2024-08-05
  */
  */
+@Data
 @TableName("station_info_min")
 @TableName("station_info_min")
 public class StationInfoMin implements Serializable {
 public class StationInfoMin implements Serializable {
 
 
@@ -36,92 +39,9 @@ public class StationInfoMin implements Serializable {
 
 
     private Double agc;
     private Double agc;
 
 
-    private Double cdqyc;
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getStationId() {
-        return stationId;
-    }
-
-    public void setStationId(String stationId) {
-        this.stationId = stationId;
-    }
-
-    public Date getRecordDate() {
-        return recordDate;
-    }
-
-    public void setRecordDate(Date recordDate) {
-        this.recordDate = recordDate;
-    }
-
-    public Double getPjfs() {
-        return pjfs;
-    }
-
-    public void setPjfs(Double pjfs) {
-        this.pjfs = pjfs;
-    }
-
-    public Double getPjgl() {
-        return pjgl;
-    }
-
-    public void setPjgl(Double pjgl) {
-        this.pjgl = pjgl;
-    }
-
-    public Double getLlgl() {
-        return llgl;
-    }
-
-    public void setLlgl(Double llgl) {
-        this.llgl = llgl;
-    }
-
-    public Double getKygl() {
-        return kygl;
-    }
-
-    public void setKygl(Double kygl) {
-        this.kygl = kygl;
-    }
-
-    public Double getAgc() {
-        return agc;
-    }
-
-    public void setAgc(Double agc) {
-        this.agc = agc;
-    }
-
-    public Double getCdqyc() {
-        return cdqyc;
-    }
+    private Double dqycgl;
 
 
-    public void setCdqyc(Double cdqyc) {
-        this.cdqyc = cdqyc;
-    }
+    private Double cdqycgl;
 
 
-    @Override
-    public String toString() {
-        return "StationInfoMin{" +
-            "id = " + id +
-            ", stationId = " + stationId +
-            ", recordDate = " + recordDate +
-            ", pjfs = " + pjfs +
-            ", pjgl = " + pjgl +
-            ", llgl = " + llgl +
-            ", kygl = " + kygl +
-            ", agc = " + agc +
-            ", cdqyc = " + cdqyc +
-        "}";
-    }
+    private Double rfdl;
 }
 }

+ 7 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/TurbineInfoMin.java

@@ -1,5 +1,7 @@
 package com.ruoyi.ucp.entity;
 package com.ruoyi.ucp.entity;
 
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.Data;
 
 
@@ -20,6 +22,7 @@ public class TurbineInfoMin implements Serializable {
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
+    @TableId(value = "id", type = IdType.AUTO)
     private Integer id;
     private Integer id;
 
 
     private String stationId;
     private String stationId;
@@ -39,4 +42,8 @@ public class TurbineInfoMin implements Serializable {
     private Double llgl;
     private Double llgl;
 
 
     private Double kygl;
     private Double kygl;
+
+    private Double dqycgl;
+
+    private Double cdqycgl;
 }
 }

+ 16 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/mapper/ProBasicEquipmentMapper.java

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.mapper;
+
+import com.ruoyi.ucp.entity.ProBasicEquipment;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * ���&��� Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-10-14
+ */
+public interface ProBasicEquipmentMapper extends BaseMapper<ProBasicEquipment> {
+
+}

+ 16 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/IProBasicEquipmentService.java

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.service;
+
+import com.ruoyi.ucp.entity.ProBasicEquipment;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * ���&��� 服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-10-14
+ */
+public interface IProBasicEquipmentService extends IService<ProBasicEquipment> {
+
+}

+ 34 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/ProBasicEquipmentServiceImpl.java

@@ -0,0 +1,34 @@
+package com.ruoyi.ucp.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.ruoyi.common.annotation.DataSource;
+import com.ruoyi.common.enums.DataSourceType;
+import com.ruoyi.ucp.entity.ProBasicEquipment;
+import com.ruoyi.ucp.mapper.ProBasicEquipmentMapper;
+import com.ruoyi.ucp.service.IProBasicEquipmentService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * ���&��� 服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-10-14
+ */
+@Service
+@DataSource(DataSourceType.SLAVE)
+public class ProBasicEquipmentServiceImpl extends ServiceImpl<ProBasicEquipmentMapper, ProBasicEquipment> implements IProBasicEquipmentService {
+    @Override
+    public List<ProBasicEquipment> list(Wrapper<ProBasicEquipment> queryWrapper) {
+        return super.list(queryWrapper);
+    }
+
+    @Override
+    public List<ProBasicEquipment> list() {
+        return super.list();
+    }
+}

+ 22 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/StationInfoMinServiceImpl.java

@@ -1,11 +1,18 @@
 package com.ruoyi.ucp.service.impl;
 package com.ruoyi.ucp.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.annotation.DataSource;
+import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.ucp.entity.StationInfoMin;
 import com.ruoyi.ucp.entity.StationInfoMin;
 import com.ruoyi.ucp.mapper.StationInfoMinMapper;
 import com.ruoyi.ucp.mapper.StationInfoMinMapper;
 import com.ruoyi.ucp.service.IStationInfoMinService;
 import com.ruoyi.ucp.service.IStationInfoMinService;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.Collection;
+import java.util.List;
+
 /**
 /**
  * <p>
  * <p>
  *  服务实现类
  *  服务实现类
@@ -15,6 +22,21 @@ import org.springframework.stereotype.Service;
  * @since 2024-08-05
  * @since 2024-08-05
  */
  */
 @Service
 @Service
+@DataSource(DataSourceType.SLAVE)
 public class StationInfoMinServiceImpl extends ServiceImpl<StationInfoMinMapper, StationInfoMin> implements IStationInfoMinService {
 public class StationInfoMinServiceImpl extends ServiceImpl<StationInfoMinMapper, StationInfoMin> implements IStationInfoMinService {
 
 
+    @Override
+    public boolean saveOrUpdate(StationInfoMin entity) {
+        return super.saveOrUpdate(entity);
+    }
+
+    @Override
+    public boolean saveOrUpdateBatch(Collection<StationInfoMin> entityList) {
+        return super.saveOrUpdateBatch(entityList);
+    }
+
+    @Override
+    public List<StationInfoMin> list(Wrapper<StationInfoMin> queryWrapper) {
+        return super.list(queryWrapper);
+    }
 }
 }

+ 21 - 1
universal-computing-platform/src/main/java/com/ruoyi/ucp/service/impl/TurbineInfoMinServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.ucp.service.impl;
 package com.ruoyi.ucp.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.common.enums.DataSourceType;
@@ -8,6 +9,9 @@ import com.ruoyi.ucp.mapper.TurbineInfoMinMapper;
 import com.ruoyi.ucp.service.ITurbineInfoMinService;
 import com.ruoyi.ucp.service.ITurbineInfoMinService;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.Collection;
+import java.util.List;
+
 /**
 /**
  * <p>
  * <p>
  *  服务实现类
  *  服务实现类
@@ -17,10 +21,26 @@ import org.springframework.stereotype.Service;
  * @since 2024-08-05
  * @since 2024-08-05
  */
  */
 @Service
 @Service
-@DataSource(DataSourceType.GLYC)
+@DataSource(DataSourceType.SLAVE)
 public class TurbineInfoMinServiceImpl extends ServiceImpl<TurbineInfoMinMapper, TurbineInfoMin> implements ITurbineInfoMinService {
 public class TurbineInfoMinServiceImpl extends ServiceImpl<TurbineInfoMinMapper, TurbineInfoMin> implements ITurbineInfoMinService {
+
     @Override
     @Override
     public boolean saveOrUpdate(TurbineInfoMin entity) {
     public boolean saveOrUpdate(TurbineInfoMin entity) {
         return super.saveOrUpdate(entity);
         return super.saveOrUpdate(entity);
     }
     }
+
+    @Override
+    public boolean saveOrUpdateBatch(Collection<TurbineInfoMin> entityList) {
+        return super.saveOrUpdateBatch(entityList);
+    }
+
+    @Override
+    public List<TurbineInfoMin> list() {
+        return super.list();
+    }
+
+    @Override
+    public List<TurbineInfoMin> list(Wrapper<TurbineInfoMin> queryWrapper) {
+        return super.list(queryWrapper);
+    }
 }
 }

+ 6 - 3
universal-computing-platform/src/main/java/com/ruoyi/ucp/util/CalcCache.java

@@ -2,9 +2,7 @@ package com.ruoyi.ucp.util;
 
 
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateTime;
 
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 
 
 public class CalcCache {
 public class CalcCache {
@@ -26,4 +24,9 @@ public class CalcCache {
     public static DateTime minuteNow = DateTime.now();
     public static DateTime minuteNow = DateTime.now();
     public static Map<String, Double> statusCache = new ConcurrentHashMap<>();
     public static Map<String, Double> statusCache = new ConcurrentHashMap<>();
     public static Map<String, Double> qfztCache = new ConcurrentHashMap<>();
     public static Map<String, Double> qfztCache = new ConcurrentHashMap<>();
+    public static Map<String, Long> swdlTime = new HashMap<>();
+
+    public static List<String> already=new ArrayList<>();
+
+    public static String keys = "";
 }
 }

+ 2 - 2
universal-computing-platform/src/main/resources/application-druid.yml

@@ -7,12 +7,12 @@ spring:
 #    username: postgres
 #    username: postgres
 #    password: gyeepd@123
 #    password: gyeepd@123
     druid:
     druid:
-      master:
+      slave:
         url: jdbc:postgresql://192.168.126.128:5432/calc_hub
         url: jdbc:postgresql://192.168.126.128:5432/calc_hub
         username: gfhd
         username: gfhd
         password: zghww693
         password: zghww693
 #        driver-class-name: org.postgresql.Driver
 #        driver-class-name: org.postgresql.Driver
-      slave:
+      master:
         url: jdbc:postgresql://192.168.2.232:5432/power_lcm
         url: jdbc:postgresql://192.168.2.232:5432/power_lcm
         username: postgres
         username: postgres
         password: gd123
         password: gd123