xushili пре 8 месеци
родитељ
комит
1e6a1ab2eb

+ 19 - 7
ruoyi-admin/src/main/java/com/ruoyi/web/runner/LoadDataSourceRunner.java

@@ -13,10 +13,7 @@ import com.ruoyi.framework.datasource.DynamicDataSource;
 import com.ruoyi.quartz.glue.GlueFactory;
 import com.ruoyi.quartz.handler.IJobHandler;
 import com.ruoyi.quartz.handler.impl.MyJobHandler;
-import com.ruoyi.ucp.entity.Formula;
-import com.ruoyi.ucp.entity.Method;
-import com.ruoyi.ucp.entity.ProBasicModelPowerRd;
-import com.ruoyi.ucp.entity.UcpDataSource;
+import com.ruoyi.ucp.entity.*;
 import com.ruoyi.ucp.feign.AdapterApi;
 import com.ruoyi.ucp.service.*;
 import com.ruoyi.ucp.util.CalcCache;
@@ -33,6 +30,7 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
 
 @Component
 public class LoadDataSourceRunner implements CommandLineRunner {
@@ -116,20 +114,34 @@ public class LoadDataSourceRunner implements CommandLineRunner {
             Map<Double, Double> collect = powerList.stream().collect(Collectors.toMap(ProEconWtCurveFittingMonth::getSpeed, ProEconWtCurveFittingMonth::getActualPower,(v1,v2)->v1));
             CalcCache.wtMcfMap.put(powerList.get(0).getWindturbineId(), collect);
         }*/
+        PointInfo pi = new PointInfo();
+        pi.setUniformCode("MX000");
+        pi.setInstitutionType("state");
+        List<PointInfo> trubineModel = pointService.getByEntity(pi);
+        pi.setUniformCode("AI422");
+        List<PointInfo> trubineModel1 = pointService.getByEntity(pi);
+        trubineModel.addAll(trubineModel1);
+        Map<String, String> wtModelMap = trubineModel.stream().collect(Collectors.toMap(PointInfo::getSpare, PointInfo::getTurbineId));
 
         String zllgl = stringRedisTemplate.opsForValue().get("ZLLGL");
         //字符串类型转换为list月拟合曲线集合
         Map<String, Map<Double, ProBasicModelPowerRd>> bzgl = JSON.parseObject(zllgl, new TypeReference<Map<String, Map<Double, ProBasicModelPowerRd>>>() {
         }.getType());
-        Map<String, ConcurrentHashMap<Double, Double>> bz = new HashMap<>();
         bzgl.forEach((modeId, map) -> {
             ConcurrentHashMap<Double, Double> mdd = new ConcurrentHashMap<>();
             map.forEach((speed, mprd) -> {
                 mdd.put(speed, mprd.getEnsurePower());
             });
-            bz.put(modeId, mdd);
+            CalcCache.bzgl.put(modeId, mdd);
         });
-        CalcCache.bzgl = bz;
+        for (PointInfo info : trubineModel) {
+            Map<Double, ProBasicModelPowerRd> rdMap = bzgl.get(info.getSpare());
+            ConcurrentHashMap<Double, Double> mdd = new ConcurrentHashMap<>();
+            rdMap.forEach((fs,rd)->{
+                mdd.put(fs,rd.getTheoryPower());
+            });
+            CalcCache.llgl.put(info.getTurbineId(),mdd);
+        }
 
         factory.setDatabase(database);
         factory.afterPropertiesSet();

+ 232 - 59
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -53,6 +53,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
     private ITurbineInfoDayService turbineInfoDayService;
     @Resource
     private IProEconReportIndicatorPoolService reportIndicatorPoolService;
+    @Resource
+    private ITurbineInfoMinService turbineInfoMinService;
+    @Resource
+    private IStationInfoMinService stationInfoMinService;
 
     @Override
     public void execute() throws Exception {
@@ -79,15 +83,45 @@ public class JavaFunctionJobHandler extends IJobHandler {
 
     public List<StationInfoHour> getStationinfoByHour(Date hour) {
         QueryWrapper<StationInfoHour> wrapper = new QueryWrapper<>();
-        wrapper.eq("record_date", DateUtil.beginOfHour(hour));
+        wrapper.eq("record_date", hour);
         return stationInfoHourService.list(wrapper);
     }
 
+    public List<StationInfoHour> getStationinfoByHour(Date hour, List<PointInfo> entity) {
+        List<StationInfoHour> byDate = getStationinfoByHour(hour);
+        if (CollUtil.isEmpty(byDate)) {
+            entity.forEach(pi -> {
+                StationInfoHour day = new StationInfoHour();
+                day.setStationId(pi.getStationId());
+                day.setRecordDate(hour);
+                byDate.add(day);
+            });
+        }
+        return byDate;
+    }
+
     public List<StationInfoDay> getStationinfoByDate(Date date) {
         QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
         wrapper.eq("record_date", date);
         return stationInfoDayService.list(wrapper);
     }
+    public List<StationInfoMin> getStationinfoMinByDate(Date date) {
+        QueryWrapper<StationInfoMin> wrapper = new QueryWrapper<>();
+        wrapper.eq("record_date", date);
+        return stationInfoMinService.list(wrapper);
+    }
+    public List<StationInfoMin> getStationinfoMinByDate(Date date, List<PointInfo> entity) {
+        List<StationInfoMin> byDate = getStationinfoMinByDate(date);
+        if (CollUtil.isEmpty(byDate)) {
+            entity.forEach(pi -> {
+                StationInfoMin day = new StationInfoMin();
+                day.setStationId(pi.getStationId());
+                day.setRecordDate(date);
+                byDate.add(day);
+            });
+        }
+        return byDate;
+    }
 
     public StationInfoDay getStationinfoByDate(Date date, String stId) {
         QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
@@ -803,31 +837,17 @@ public class JavaFunctionJobHandler extends IJobHandler {
     }
 
     public void calcStationHourPJGL(Date hour) {
-        PointInfo pointInfo = new PointInfo();
-        pointInfo.setInstitutionType("station");
-        pointInfo.setUniformCode("SSZGL");
-        List<PointInfo> entity = pointService.getByEntity(pointInfo);
-        List<StationInfoHour> byHours = getStationinfoByHour(hour);
-        Map<String, StationInfoHour> collect = new HashMap<>();
-        if (!byHours.isEmpty()) {
-            collect = byHours.stream().collect(Collectors.toMap(StationInfoHour::getStationId, Function.identity()));
-        }
-        DoubleStatData stat;
-        List<StationInfoHour> byHours2 = new ArrayList<>();
-        for (PointInfo point : entity) {
-            stat = adapter.getHistoryStat(taosGoldenUriTest(), point.getPointKey(), DateUtil.offsetHour(hour, -1).getTime(), hour.getTime());
-            if (byHours.isEmpty()) {
-                StationInfoHour info = new StationInfoHour();
-                info.setStationId(point.getStationId());
-                info.setRecordDate(DateUtil.beginOfHour(hour));
-                if (stat == null || stat.getAvg() == null) info.setPjgl(0.0);
-                info.setPjgl(stat.getAvg().getDoubleValue());
-                byHours2.add(info);
-            } else {
-                collect.get(point.getStationId()).setPjgl(stat.getAvg().getDoubleValue());
-            }
+        hour = DateUtil.beginOfHour(hour);
+        DateTime start = DateUtil.offsetHour(hour, -1);
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC001", "booster");
+        Map<String, PointInfo> statMapCx = getStatDataByEntityMap(entityCx, goldenUri(), start, hour, PointInfo::getTurbineId);
+
+        List<StationInfoHour> byHours = getStationinfoByHour(hour,entityCx);
+        for (StationInfoHour byHour : byHours) {
+            byHour.setPjgl(statMapCx.get(byHour.getStationId()).getPointDatas().get(0).getValue());
         }
-        stationInfoHourService.saveOrUpdateBatch(byHours.isEmpty() ? byHours2 : byHours);
+        stationInfoHourService.saveOrUpdateBatch(byHours);
     }
 
     public void calcStationRfdlFj(Date date) {
@@ -1320,6 +1340,30 @@ public class JavaFunctionJobHandler extends IJobHandler {
         return data2;
     }
 
+    public List<PointData> doublePointDatasFull(double v, List<PointData> data, long startTime, long endTime, int interval) {
+        int j = 0, m = 0;
+        List<PointData> data2 = new ArrayList<>();
+        for (long i = startTime; i < endTime; i += interval * 1000L) {
+            PointData dt = new PointData();
+            dt.setTs(i);
+            data2.add(dt);
+            //超出范围
+            if (j >= data.size() - 1) continue;
+            if (i < data.get(j).getTs()) {
+                if (m == 0) {
+                    dt.setDoubleValue(v);
+                } else {
+                    dt.setDoubleValue(data.get(j - 1).getValue());
+                }
+            } else {
+                dt.setDoubleValue(data.get(j).getValue());
+                j++;
+                m++;
+            }
+        }
+        return data2;
+    }
+
     public void calcGlqxnh(Date start, Date end) {
         //风速
         List<PointInfo> entityFs = getEntity("AI066", "turbine");
@@ -2580,14 +2624,23 @@ public class JavaFunctionJobHandler extends IJobHandler {
         });
 
         Map<String, String> entityMxzt = getEntityMap("MXZT", "turbine");
-        Map<String, String>  entityQfzt = getEntityMap("SSQFZT", "turbine");
+        Map<String, String> entityQfzt = getEntityMap("SSQFZT", "turbine");
+        //Map<String, String> entityKygl = getEntityMap("KYGL", "turbine");
 
-        List<PointData> qfztDataList = entityFs.stream().map(qfzt->{
-            String wtId = qfzt.getTurbineId();
-            PointData data = qfzt.getPointDatas().get(qfzt.getPointDatas().size()-1);
+        List<PointInfo> fsEntity = entityFs.stream().peek(fs -> {
+            PointData data = fs.getPointDatas().get(fs.getPointDatas().size() - 1);
+            if (data != null) {
+                fs.setPointDatas(Collections.singletonList(data));
+            } else {
+                fs.setPointDatas(Collections.singletonList(new PointData()));
+            }
+        }).collect(Collectors.toList());
+        List<PointData> qfztDataList = fsEntity.stream().map(fs -> {
+            String wtId = fs.getTurbineId();
+            PointData data = fs.getPointDatas().get(0);
             data.setTs(date.getTime());
             data.setTagName(entityQfzt.get(wtId));
-            data.setDoubleValue(calcQfzt(glMap.get(wtId).get(0).getValue(),CalcCache.fitcoef.get(wtId).get(data.getValue())));
+            data.setDoubleValue(calcQfzt(glMap.get(wtId).get(0).getValue(), CalcCache.fitcoef.get(wtId).get(data.getValue())));
             return data;
         }).collect(Collectors.toList());
 
@@ -2610,7 +2663,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
                     return true;
                 }
             }).collect(Collectors.toList());
-            List<PointData> collect2 = qfztDataList.stream().filter(d -> {
+            List<PointData> qfztDatas = qfztDataList.stream().filter(d -> {
                 if (Objects.equals(CalcCache.qfztCache.get(d.getTagName()), d.getValue())) {
                     return false;
                 } else {
@@ -2619,7 +2672,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
                 }
             }).collect(Collectors.toList());
             adapter.writeHistoryBatch(taosUri(), collect);
-            adapter.writeHistoryBatch(taosUri(), collect2);
+            adapter.writeHistoryBatch(taosUri(), qfztDatas);
         }
     }
     //此处加公式
@@ -2685,6 +2738,21 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }
     }
 
+    public void getStatDataByEntity(List<PointInfo> entity, URI uri, Date start, Date end) {
+        for (PointInfo info : entity) {
+            DoubleStatData stat = adapter.getHistoryStat(uri, info.getPointKey(), start.getTime(), end.getTime());
+            ThreadUtil.sleep(5);
+            info.getPointDatas().add(stat.getAvg());
+            info.getPointDatas().add(stat.getMax());
+            info.getPointDatas().add(stat.getMin());
+        }
+    }
+
+    public Map<String, PointInfo> getStatDataByEntityMap(List<PointInfo> entity, URI uri, Date start, Date end,Function<PointInfo,String> function) {
+        getStatDataByEntity(entity, uri, start, end);
+        return entity.stream().collect(Collectors.toMap(function, Function.identity()));
+    }
+
     // 主函数或测试方法(如果需要)
     public static void main(String[] args) {
         Double b = 2.0;
@@ -2702,10 +2770,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
         points.add(new PointData(2000, 1));
         points.add(new PointData(2500, 3));
 
-//        Map<Integer, Long> durations = calculateStateDurations(points);
-//        for (Map.Entry<Integer, Long> entry : durations.entrySet()) {
-//            System.out.println("State " + entry.getKey() + ": " + entry.getValue() + "ms");
-//        }
+        //        Map<Integer, Long> durations = calculateStateDurations(points);
+        //        for (Map.Entry<Integer, Long> entry : durations.entrySet()) {
+        //            System.out.println("State " + entry.getKey() + ": " + entry.getValue() + "ms");
+        //        }
     }
 
     public List<PointInfo> getLatest(String uniformCode, String institutionType) {
@@ -2937,24 +3005,24 @@ public class JavaFunctionJobHandler extends IJobHandler {
         DateTime time0 = DateUtil.offsetDay(time, -1);
         DateTime beginOfMonth = DateUtil.beginOfMonth(time0);
         DateTime beginOfYear = DateUtil.beginOfYear(time0);
-        
+
         QueryWrapper<TurbineInfoDay> wrapper = new QueryWrapper<>();
         wrapper.select("sum(llfdl) llfdl,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(xdss) xdss,sum(slss) slss,sum(xnss) xnss," +
-                "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
+                        "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
                         "sum(jx_min) jx_min,sum(xd_min) xd_min,sum(lx_min) lx_min,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("sum(llfdl) llfdl,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(xdss) xdss,sum(slss) slss,sum(xnss) xnss," +
-                "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
+                        "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
                         "sum(jx_min) jx_min,sum(xd_min) xd_min,sum(lx_min) lx_min,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("sum(llfdl) llfdl,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(xdss) xdss,sum(slss) slss,sum(xnss) xnss," +
-                "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
+                        "sum(gzss) gzss,sum(djss) djss,avg(pjfs) pjfs,sum(dj_min) dj_min,sum(tj_min) tj_min,sum(yx_min) yx_min,sum(gz_min) gz_min," +
                         "sum(jx_min) jx_min,sum(xd_min) xd_min,sum(lx_min) lx_min,project_id,station_id")
                 .between("record_date", beginOfYear, time0).groupBy("project_id,station_id");
         List<TurbineInfoDay> yearDays = turbineInfoDayService.list(wrapper);
@@ -3032,12 +3100,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
         pool.setRxnssdl(day.getXnss());
         pool.setRxdjclssdl(day.getXdss());
         pool.setRllfdl(day.getLlfdl());
-        pool.setRhjdjxs(day.getDjMin()/60);
-        pool.setRhjgztjxs(day.getGzMin()/60);
-        pool.setRhjtxzdxs(day.getLxMin()/60);
-        pool.setRhjjxtjxs(day.getJxMin()/60);
-        pool.setRhjxdxs(day.getXdMin()/60);
-        pool.setRhjyxxs(day.getYxMin()/60);
+        pool.setRhjdjxs(day.getDjMin() / 60);
+        pool.setRhjgztjxs(day.getGzMin() / 60);
+        pool.setRhjtxzdxs(day.getLxMin() / 60);
+        pool.setRhjjxtjxs(day.getJxMin() / 60);
+        pool.setRhjxdxs(day.getXdMin() / 60);
+        pool.setRhjyxxs(day.getYxMin() / 60);
         pool.setRhjslxs(0.0);
 
         pool.setYpjfs(month.getPjfs());
@@ -3047,12 +3115,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
         pool.setYxnssdl(month.getXnss());
         pool.setYxdjclssdl(month.getXdss());
         pool.setYllfdl(month.getLlfdl());
-        pool.setYhjdjxs(month.getDjMin()/60);
-        pool.setYhjgztjxs(month.getGzMin()/60);
-        pool.setYhjtxzdxs(month.getLxMin()/60);
-        pool.setYhjjxtjxs(month.getJxMin()/60);
-        pool.setYhjxdxs(month.getXdMin()/60);
-        pool.setYhjyxxs(month.getYxMin()/60);
+        pool.setYhjdjxs(month.getDjMin() / 60);
+        pool.setYhjgztjxs(month.getGzMin() / 60);
+        pool.setYhjtxzdxs(month.getLxMin() / 60);
+        pool.setYhjjxtjxs(month.getJxMin() / 60);
+        pool.setYhjxdxs(month.getXdMin() / 60);
+        pool.setYhjyxxs(month.getYxMin() / 60);
         pool.setYhjslxs(0.0);
 
         pool.setNpjfs(year.getPjfs());
@@ -3062,12 +3130,12 @@ public class JavaFunctionJobHandler extends IJobHandler {
         pool.setNxnssdl(year.getXnss());
         pool.setNxdjclssdl(year.getXdss());
         pool.setNllfdl(year.getLlfdl());
-        pool.setNhjdjxs(year.getDjMin()/60);
-        pool.setNhjgztjxs(year.getGzMin()/60);
-        pool.setNhjtxzdxs(year.getLxMin()/60);
-        pool.setNhjjxtjxs(year.getJxMin()/60);
-        pool.setNhjxdxs(year.getXdMin()/60);
-        pool.setNhjyxxs(year.getYxMin()/60);
+        pool.setNhjdjxs(year.getDjMin() / 60);
+        pool.setNhjgztjxs(year.getGzMin() / 60);
+        pool.setNhjtxzdxs(year.getLxMin() / 60);
+        pool.setNhjjxtjxs(year.getJxMin() / 60);
+        pool.setNhjxdxs(year.getXdMin() / 60);
+        pool.setNhjyxxs(year.getYxMin() / 60);
         pool.setNhjslxs(0.0);
     }
 
@@ -3087,7 +3155,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         pool.setRhjxdxs(p.getRhjxdxs());
         pool.setRhjyxxs(p.getRhjyxxs());
         pool.setRhjslxs(0.0);
-        
+
         pool.setYpjfs(p.getYpjfs() / pools.size());
         pool.setYgzssdl(p.getYgzssdl());
         pool.setYjxssdl(p.getYjxssdl());
@@ -3199,6 +3267,111 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }
         return qfzt;
     }
+
+    public List<TurbineInfoMin> getTurbineinfoMin(Date date) {
+        QueryWrapper<TurbineInfoMin> wrapper = new QueryWrapper<>();
+        wrapper.eq("record_date", date);
+        return turbineInfoMinService.list(wrapper);
+    }
+
+    public List<TurbineInfoMin> getTurbineinfoMinByEntity(Date date, List<PointInfo> entity) {
+        List<TurbineInfoMin> list = getTurbineinfoMin(date);
+        if (list.isEmpty()) {
+            entity.forEach(pi -> {
+                TurbineInfoMin day = new TurbineInfoMin();
+                day.setStationId(pi.getStationId());
+                day.setProjectId(pi.getProjectId());
+                day.setLineId(pi.getLineId());
+                day.setTurbineId(pi.getTurbineId());
+                day.setRecordDate(date);
+                list.add(day);
+            });
+        }
+        return list;
+    }
+
+    public Map<String, TurbineInfoMin> getTurbineinfoMinMap(Date date) {
+        List<TurbineInfoMin> tims = getTurbineinfoMin(date);
+        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);
+        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) {
+        getRawDataByEntity(entity, uri, start, end);
+        return entity.stream().collect(Collectors.toMap(function, Function.identity()));
+    }
+
+    public void calcTurbinePjfsPjglKyglLlglMin(Date date, int granularity) {
+        date = DateUtil.beginOfMinute(date);
+        DateTime start = DateUtil.offsetMinute(date, -granularity);
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        Map<String, PointInfo> rawMapFs = getRawDataMapByEntity(entityFs, goldenUri(), start, date, PointInfo::getTurbineId);
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        Map<String, PointInfo> rawMapGl = getRawDataMapByEntity(entityGl, goldenUri(), start, date, PointInfo::getTurbineId);
+        List<PointInfo> entityZt = getEntity("MXZT", "turbine");
+        Map<String, PointInfo> rawMapZt = getRawDataMapByEntity(entityZt, goldenUri(), start, date, PointInfo::getTurbineId);
+
+        List<TurbineInfoMin> mins = getTurbineinfoMinByEntity(date, entityFs);
+        for (TurbineInfoMin min : mins) {
+            String tbId = min.getTurbineId();
+            List<PointData> fsDatas = rawMapFs.get(tbId).getPointDatas();
+            List<PointData> ztDatas = rawMapZt.get(tbId).getPointDatas();
+            ztDatas = doublePointDatasFull(2, ztDatas, start.getTime(), date.getTime(), 1);
+            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 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);
+
+            double v = llgl * 0.9;
+            if (kygl > v) kygl = v;
+            if (kygl < sjgl) kygl = sjgl;
+            min.setPjfs(pjfs);
+            min.setPjgl(sjgl);
+            min.setLlgl(llgl);
+            min.setKygl(kygl);
+        }
+        turbineInfoMinService.saveOrUpdateBatch(mins);
+    }
+
+    public void calcStationLlglKyglSjglAgcMin(Date date, int granularity) {
+        date = DateUtil.beginOfMinute(date);
+        DateTime start = DateUtil.offsetMinute(date, -granularity);
+
+        //AGC
+        List<PointInfo> entityAgc = getEntity("AGC002", "booster");
+        Map<String, PointInfo> statMapAgc = getStatDataByEntityMap(entityAgc, goldenUri(), start, date, PointInfo::getTurbineId);
+        //出线
+        List<PointInfo> entityCx = getEntity("AGC001", "booster");
+        Map<String, PointInfo> statMapCx = getStatDataByEntityMap(entityCx, goldenUri(), start, date, PointInfo::getTurbineId);
+
+        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");
+        List<TurbineInfoMin> list = turbineInfoMinService.list(wrapper);
+        Map<String, TurbineInfoMin> minMap = list.stream().collect(Collectors.toMap(TurbineInfoMin::getStationId, Function.identity()));
+        List<StationInfoMin> byDate = getStationinfoMinByDate(date,entityAgc);
+
+        for (StationInfoMin day : byDate) {
+            String stId = day.getStationId();
+            TurbineInfoMin min = minMap.get(stId);
+            day.setLlgl(min.getLlgl());
+            day.setKygl(min.getKygl());
+            day.setAgc(statMapAgc.get(stId).getPointDatas().get(0).getValue());
+            day.setPjgl(statMapCx.get(stId).getPointDatas().get(0).getValue());
+            day.setPjfs(min.getPjfs());
+        }
+        stationInfoMinService.saveOrUpdateBatch(byDate);
+    }
 }
 
 

+ 3 - 0
ruoyi-admin/src/test/java/com/ruoyi/NewTests.java

@@ -84,6 +84,7 @@ public class NewTests {
             task.calcRealtimeTurbineZt();
             ThreadUtil.sleep(1000);
         }*/
+        task.calcRealtimeTurbineZt();
     }
 
     @Test
@@ -101,5 +102,7 @@ public class NewTests {
 //            task.writeReportPool(date);
             task.writeReportPoolProject(date);
         }
+        DateTime date = DateUtil.date();
+        task.calcStationHourPJGL(date);
     }
 }

+ 2 - 1
ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java

@@ -16,5 +16,6 @@ public enum DataSourceType {
      */
     SLAVE,
 
-    TAOS
+    TAOS,
+    GLYC
 }

+ 2 - 2
universal-computing-platform/pom.xml

@@ -102,11 +102,11 @@
             <artifactId>commons-pool2</artifactId>
         </dependency>
 
-        <!--<dependency>
+        <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
             <version>3.5.3.2</version>
-        </dependency>-->
+        </dependency>
     </dependencies>
     <!--<dependencyManagement>
         <dependencies>

+ 127 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/StationInfoMin.java

@@ -0,0 +1,127 @@
+package com.ruoyi.ucp.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+@TableName("station_info_min")
+public class StationInfoMin implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String stationId;
+
+    private Date recordDate;
+
+    private Double pjfs;
+
+    private Double pjgl;
+
+    private Double llgl;
+
+    private Double kygl;
+
+    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;
+    }
+
+    public void setCdqyc(Double cdqyc) {
+        this.cdqyc = cdqyc;
+    }
+
+    @Override
+    public String toString() {
+        return "StationInfoMin{" +
+            "id = " + id +
+            ", stationId = " + stationId +
+            ", recordDate = " + recordDate +
+            ", pjfs = " + pjfs +
+            ", pjgl = " + pjgl +
+            ", llgl = " + llgl +
+            ", kygl = " + kygl +
+            ", agc = " + agc +
+            ", cdqyc = " + cdqyc +
+        "}";
+    }
+}

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

@@ -0,0 +1,42 @@
+package com.ruoyi.ucp.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+@Data
+@TableName("turbine_info_min")
+public class TurbineInfoMin implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+
+    private String stationId;
+
+    private String projectId;
+
+    private String lineId;
+
+    private String turbineId;
+
+    private Date recordDate;
+
+    private Double pjfs;
+
+    private Double pjgl;
+
+    private Double llgl;
+
+    private Double kygl;
+}

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

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.ucp.entity.StationInfoMin;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+public interface StationInfoMinMapper extends BaseMapper<StationInfoMin> {
+
+}

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

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.ucp.entity.TurbineInfoMin;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+public interface TurbineInfoMinMapper extends BaseMapper<TurbineInfoMin> {
+
+}

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

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.ucp.entity.StationInfoMin;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+public interface IStationInfoMinService extends IService<StationInfoMin> {
+
+}

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

@@ -0,0 +1,16 @@
+package com.ruoyi.ucp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.ucp.entity.TurbineInfoMin;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+public interface ITurbineInfoMinService extends IService<TurbineInfoMin> {
+
+}

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

@@ -0,0 +1,20 @@
+package com.ruoyi.ucp.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.ucp.entity.StationInfoMin;
+import com.ruoyi.ucp.mapper.StationInfoMinMapper;
+import com.ruoyi.ucp.service.IStationInfoMinService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+@Service
+public class StationInfoMinServiceImpl extends ServiceImpl<StationInfoMinMapper, StationInfoMin> implements IStationInfoMinService {
+
+}

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

@@ -0,0 +1,26 @@
+package com.ruoyi.ucp.service.impl;
+
+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.TurbineInfoMin;
+import com.ruoyi.ucp.mapper.TurbineInfoMinMapper;
+import com.ruoyi.ucp.service.ITurbineInfoMinService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2024-08-05
+ */
+@Service
+@DataSource(DataSourceType.GLYC)
+public class TurbineInfoMinServiceImpl extends ServiceImpl<TurbineInfoMinMapper, TurbineInfoMin> implements ITurbineInfoMinService {
+    @Override
+    public boolean saveOrUpdate(TurbineInfoMin entity) {
+        return super.saveOrUpdate(entity);
+    }
+}

+ 5 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/util/CalcCache.java

@@ -19,6 +19,11 @@ public class CalcCache {
      * 保证功率
      */
     public static Map<String, ConcurrentHashMap<Double, Double>> bzgl = new ConcurrentHashMap<>();
+    /**
+     * 理论功率
+     */
+    public static Map<String, ConcurrentHashMap<Double, Double>> llgl = new ConcurrentHashMap<>();
     public static DateTime minuteNow = DateTime.now();
     public static Map<String, Double> statusCache = new ConcurrentHashMap<>();
+    public static Map<String, Double> qfztCache = new ConcurrentHashMap<>();
 }