Browse Source

refactor(ucp): 修改数据查询接口参数类型

- 将 ILineInfoDayService、IMeterInfoDayService、IStationInfoDayService 和 ITurbineInfoDayService 接口中的 getDatasByPartSelects 方法的最后一个参数类型从 SFunction 变为 String
- 修改了这些接口的方法签名,以适应新的参数类型
xushili 2 months ago
parent
commit
3e4c3791b7

+ 398 - 33
ruoyi-admin/src/main/java/com/ruoyi/web/controller/JavaFunctionJobHandler.java

@@ -25,6 +25,7 @@ import org.apache.commons.math3.fitting.WeightedObservedPoints;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.lang.reflect.Field;
@@ -37,7 +38,7 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 
 //@Service
-//@Service
+@Service
 public class JavaFunctionJobHandler extends IJobHandler {
     private static final Logger logger = LoggerFactory.getLogger(JavaFunctionJobHandler.class);
 
@@ -777,18 +778,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
             swdlPi = swdlMap.get(stId);
             gwdlPi = gwdlMap.get(stId);
             cydlPi = cydlMap.get(stId);
-            List<PointData> swdlPds = swdlPi.getPointDatas().stream().filter(pd -> pd.getValue() != 0).collect(Collectors.toList());
-            double swdl = 0;
-            if (swdlPds.size() > 1)
-                swdl = Math.abs(swdlPds.get(0).getValue() - swdlPds.get(swdlPds.size() - 1).getValue()) * swdlPi.getCoef();
-            List<PointData> gwdlPds = gwdlPi.getPointDatas().stream().filter(pd -> pd.getValue() != 0).collect(Collectors.toList());
-            double gwdl = 0;
-            if (gwdlPds.size() > 1)
-                gwdl = Math.abs(gwdlPds.get(0).getValue() - gwdlPds.get(gwdlPds.size() - 1).getValue()) * gwdlPi.getCoef();
-            List<PointData> cydlPds = cydlPi.getPointDatas().stream().filter(pd -> pd.getValue() != 0).collect(Collectors.toList());
-            double cydl = 0;
-            if (cydlPds.size() > 1)
-                cydl = Math.abs(cydlPds.get(0).getValue() - cydlPds.get(cydlPds.size() - 1).getValue()) * cydlPi.getCoef();
+            double swdl = calcHaDl(swdlPi);
+            double gwdl = calcHaDl(gwdlPi);
+            double cydl = calcHaDl(cydlPi);
 
             if (swdl < 0 || swdl > 6000000) swdl = 0;
             if (gwdl < 0 || gwdl > 6000000) gwdl = 0;
@@ -838,6 +830,42 @@ public class JavaFunctionJobHandler extends IJobHandler {
         stationInfoDayService.saveOrUpdateBatch(byDate);
     }
 
+    public void calcStationSwGwCyDlSameDay_ha() {
+        DateTime date = DateUtil.date();
+        //date当天零点
+        DateTime time0 = DateUtil.beginOfDay(DateUtil.date());
+
+        List<PointInfo> swdlEt = getEntity("Z-ZXYG-CX", "meter");
+        List<PointInfo> gwdlEt = getEntity("Z-FXYG-CX", "meter");
+        List<PointInfo> cydlEt = getEntity("Z-ZXYG-ZYB", "meter");
+        getRawDataByEntity(swdlEt, goldenUri(), time0, date);
+        getRawDataByEntity(gwdlEt, goldenUri(), time0, date);
+        getRawDataByEntity(cydlEt, goldenUri(), time0, date);
+
+        Map<String, PointInfo> swdlMap = swdlEt.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
+        Map<String, PointInfo> gwdlMap = gwdlEt.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
+        Map<String, PointInfo> cydlMap = cydlEt.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
+
+        List<StationInfoDay> byDate = getStationinfoByDate(time0, swdlEt);
+        PointInfo swdlPi, gwdlPi, cydlPi;
+        for (StationInfoDay info : byDate) {
+            String stId = info.getStationId();
+            swdlPi = swdlMap.get(stId);
+            gwdlPi = gwdlMap.get(stId);
+            cydlPi = cydlMap.get(stId);
+            int swdl = (int) calcHaDl(swdlPi);
+            int gwdl = (int) calcHaDl(gwdlPi);
+            int cydl = (int) calcHaDl(cydlPi);
+            if (swdl < 0 || swdl > 6000000) swdl = 0;
+            if (gwdl < 0 || gwdl > 6000000) gwdl = 0;
+            if (cydl < 0 || cydl > 6000000) cydl = 0;
+            info.setSwdl(swdl);
+            info.setGwdl(gwdl);
+            info.setZyb(cydl);
+        }
+        stationInfoDayService.saveOrUpdateBatch(byDate);
+    }
+
     public void calcStationSwGwCyDlSameDay() {
         //date当天零点
         DateTime time0 = DateUtil.beginOfDay(DateUtil.date());
@@ -1202,6 +1230,26 @@ public class JavaFunctionJobHandler extends IJobHandler {
         lineInfoDayService.saveOrUpdateBatch(byDate);
     }
 
+    public void calcLineRfdlSameDay_ha() {
+        DateTime date = DateUtil.date();
+        //date当天零点
+        DateTime time0 = DateUtil.beginOfDay(date);
+
+        List<PointInfo> entity = getEntity("Z-ZXYG-JX", "meter");
+        entity = entity.stream().filter(e -> !"".equals(e.getProjectId())).collect(Collectors.toList());
+        getRawDataByEntity(entity, goldenUri(), time0, date);
+        Map<String, PointInfo> rfdlMap = entity.stream().collect(Collectors.toMap(PointInfo::getLineId, Function.identity()));
+        List<LineInfoDay> byDate = getLineinfoByDate(time0, entity);
+
+        for (LineInfoDay day : byDate) {
+            PointInfo rfdlPi = rfdlMap.get(day.getLineId());
+            int v = (int) calcHaDl(rfdlPi);
+            if (v < 0 || v > 30000000) v = 0;
+            day.setRfdl(v);
+        }
+        lineInfoDayService.saveOrUpdateBatch(byDate);
+    }
+
     public void calcLineRfdl(Date date, String stId) {
         //date当天零点
         DateTime time = DateUtil.beginOfDay(date);
@@ -1403,6 +1451,21 @@ public class JavaFunctionJobHandler extends IJobHandler {
         stationInfoHourService.saveOrUpdateBatch(byHours);
     }
 
+    public void calcStationRfdlFj(DateTime begin) {
+        QueryWrapper<TurbineInfoDay> wrapper = new QueryWrapper<>();
+        wrapper.select("sum(rfdl) rfdl,station_id").eq("record_date", begin).groupBy("station_id");
+        List<TurbineInfoDay> list = turbineInfoDayService.list(wrapper);
+        Map<String, TurbineInfoDay> dayMap = list.stream().collect(Collectors.toMap(TurbineInfoDay::getStationId, Function.identity()));
+        List<StationInfoDay> byDate = getStationinfoByDate(begin);
+
+        TurbineInfoDay tDay;
+        for (StationInfoDay day : byDate) {
+            tDay = dayMap.get(day.getStationId());
+            day.setRfdlFj(tDay.getRfdl());
+        }
+        stationInfoDayService.saveOrUpdateBatch(byDate);
+    }
+
     public void calcStationRfdlFj(Date date) {
         //date当天零点
         DateTime time = DateUtil.beginOfDay(date);
@@ -1662,6 +1725,53 @@ public class JavaFunctionJobHandler extends IJobHandler {
         turbineInfoDayService.saveOrUpdateBatch(infoDays);
     }
 
+    public void calcTurbine5s2_ha(Date date) {
+        //date当天零点
+        DateTime time = DateUtil.beginOfDay(date);
+        //date昨天零点
+        DateTime time0 = DateUtil.offsetDay(time, -1);
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        getSnapDataByEntity(entityFs, time0, time, 15);
+        getSnapDataByEntity(entityGl, time0, time, 15);
+
+        List<PointInfo> ztMapMap = calcTurbineZt(time0, time, entityFs, entityGl);
+        Map<String, Map<String, PointInfo>> ztMapMapInfos = ztMapMap.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, List<PointData>>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+        Map<String, Map<String, List<PointData>>> glMapMap = entityGl.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+
+        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);
+            Map<String, Double> loss = getTurbinePowerLoss(infoDay.getRfdl(), ztMapMapInfos.get(stId).get(wtId), fsMapMap.get(stId).get(wtId), glMapMap.get(stId).get(wtId));
+            infoDay.setJhjxss(loss.get("jxss") / 10 + loss.get("sdtj") / 10);
+            infoDay.setFjhjxss(loss.get("gzss") / 10 + loss.get("fdjcl") / 10);
+            infoDay.setXdss(loss.get("xdjcl") / 10 + loss.get("xdtj") / 10);
+            infoDay.setSlss(0.0);
+            infoDay.setDjss(loss.get("djss") / 10);
+            infoDay.setGzss(loss.get("gzss") / 10);
+            infoDay.setXnss(loss.get("xnss") / 10 + loss.get("djss") / 10);
+            //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 List<PointInfo> calcTurbineZt(Date start, Date end, List<PointInfo> fsInfos, List<PointInfo> glInfos) {
 
         List<PointInfo> turbineZt = calcTurbineDizt(start, end, 15);
@@ -3086,9 +3196,9 @@ public class JavaFunctionJobHandler extends IJobHandler {
     }
 
     //环境温度
-    public void ambientTemperature() {
+    public void ambientTemperature(Date date) {
         //date当天零点
-        DateTime timeNow = DateUtil.beginOfDay(new Date());
+        DateTime timeNow = DateUtil.beginOfDay(date);
         //date昨天零点
         DateTime timeBegin = DateUtil.offsetDay(timeNow, -1);
 
@@ -4048,33 +4158,49 @@ public class JavaFunctionJobHandler extends IJobHandler {
         zbgyc1Et.setUniformCode("B-ZXYG-ZBGYC1");
         zbgyc1Et.setStationId("NX_FGS_HA_FDC_STA");
         MeterInfoDay zbgyc1Day = getMeterinfoByDate(time0, zbgyc1Et);
+        zbgyc1Day.setParentId("ZB");
+        zbgyc1Day.setBoosterId("ZB1");
+        zbgyc1Day.setFdl(0d);
         zbgyc1Day.setHdl(0d);
         //1号主变低压侧正向有功
         MeterInfoDay zbdyc1Day = calcMeterSimple("B-ZXYG-ZBDYC1", time0, time, "ZB");
+        zbdyc1Day.setBoosterId("ZB1");
         calcMeterSimple("B-FXYG-ZBDYC1", time0, time, zbdyc1Day);
         //2号主变高压侧正向有功
         MeterInfoDay zbgyc2Day = calcMeterSimple("B-ZXYG-ZBGYC2", time0, time, "ZB");
+        zbgyc2Day.setBoosterId("ZB2");
         calcMeterSimple("B-FXYG-ZBGYC2", time0, time, zbgyc2Day);
         //2号主变低压侧正向有功
         MeterInfoDay zbdyc2Day = calcMeterSimple("B-ZXYG-ZBDYC2", time0, time, "ZB");
+        zbgyc2Day.setBoosterId("ZB2");
         calcMeterSimple("B-FXYG-ZBDYC2", time0, time, zbdyc2Day);
+
         //1号接地变兼站用变 B-ZXYG-ZDB1 B-FXYG-ZDB1
-        MeterInfoDay jdb1Day = calcMeterSimple("B-ZXYG-ZDB1", time0, time, "ZYB");
+        MeterInfoDay jdb1Day = calcMeterSimple("B-ZXYG-ZDB1", time0, time, "JDB");
+        jdb1Day.setBoosterId("JDB1");
         calcMeterSimple("B-FXYG-ZDB1", time0, time, jdb1Day);
         //2号接地变 B-ZXYG-ZDB1 B-FXYG-ZDB1
         MeterInfoDay jdb2Day = calcMeterSimple("B-ZXYG-ZDB2", time0, time, "JDB");
+        jdb2Day.setBoosterId("JDB2");
         calcMeterSimple("B-FXYG-ZDB2", time0, time, jdb2Day);
         //1号SVG B-ZXYG-SVG1 B-FXYG-SVG1
         MeterInfoDay svg1Day = calcMeterSimple("B-ZXYG-SVG1", time0, time, "SVG");
+        svg1Day.setBoosterId("SVG1");
         calcMeterSimple("B-FXYG-SVG1", time0, time, svg1Day);
         //2号SVG B-ZXYG-SVG2 B-FXYG-SVG2
         MeterInfoDay svg2Day = calcMeterSimple("B-ZXYG-SVG2", time0, time, "SVG");
+        svg2Day.setBoosterId("SVG2");
         calcMeterSimple("B-FXYG-SVG2", time0, time, svg2Day);
 
         List<MeterInfoDay> save = new ArrayList<>();
+        save.add(zbgyc1Day);
         save.add(zbdyc1Day);
         save.add(zbgyc2Day);
         save.add(zbdyc2Day);
+        save.add(jdb1Day);
+        save.add(jdb2Day);
+        save.add(svg1Day);
+        save.add(svg2Day);
         meterInfoDayService.saveOrUpdateBatch(save);
     }
 
@@ -4187,7 +4313,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             for (StationInfoMin min : mins) {
                 List<Double> doubles = dtlMap.get(min.getRecordDate());
                 List<PointData> kypd = kydlMap.get(min.getRecordDate().getTime());
-                if (CollUtil.isEmpty(kypd)) continue;
+                if (kypd == null || kypd.isEmpty()) continue;
                 //限电
                 if (calcXdRate(doubles) > 0.6) continue;
                 actualPower += min.getRfdl();
@@ -4232,6 +4358,88 @@ public class JavaFunctionJobHandler extends IJobHandler {
         turbineInfoDayService.saveOrUpdateBatch(byDate);
     }
 
+    public void calcTurbineRFDL(DateTime begin, DateTime end) {
+        List<PointInfo> entity = getEntity("AI121", "turbine");
+        getRawDataByEntity(entity, goldenUri(), begin, end);
+        Map<String, String> fsMap = getEntityMap("AI066", "turbine");
+
+        Map<String, TurbineInfoDay> byDate = getTurbineinfoMap(begin, entity);
+        List<TurbineInfoDay> infoDays = new ArrayList<>();
+        for (PointInfo info : entity) {
+            String tbId = info.getTurbineId();
+            TurbineInfoDay infoDay = byDate.get(tbId);
+            double v = calcHaDl(info);
+            if (v < 0 || v > 1000000) v = 0;
+            infoDay.setRfdl(v);
+            PointData stat = adapter.getHistoryAvg(goldenUri(), fsMap.get(tbId), begin.getTime(), end.getTime());
+            infoDay.setPjfs(stat.getValue());
+            infoDays.add(infoDay);
+        }
+        turbineInfoDayService.saveOrUpdateBatch(infoDays);
+    }
+
+    // 计算每种状态的总持续时间
+    public void calcTurbineStateMin(DateTime begin, DateTime end) {
+        List<PointInfo> entityMxzt = getEntity("MXZT", "turbine");
+        getRawDataByEntity(entityMxzt, taosUri(), begin, end);
+        Map<String, TurbineInfoDay> byDate = getTurbineinfoMap(begin, entityMxzt);
+        for (PointInfo info : entityMxzt) {
+            TurbineInfoDay infoDay = byDate.get(info.getTurbineId());
+            Map<String, Map<Double, Long>> dlmm = calcStateDurationFrequency(info.getPointDatas());
+            Map<Double, Long> durations = dlmm.get("duration");
+            Map<Double, Long> frequency = dlmm.get("frequency");
+            infoDay.setDjMin(durations.getOrDefault(0.0, 0L) / 60000.0);
+            infoDay.setTjMin(durations.getOrDefault(1.0, 0L) / 60000.0);
+            infoDay.setYxMin(durations.getOrDefault(2.0, 0L) / 60000.0);
+            infoDay.setGzMin(durations.getOrDefault(4.0, 0L) / 60000.0);
+            infoDay.setJxMin(durations.getOrDefault(6.0, 0L) / 60000.0);
+            infoDay.setXdMin(durations.getOrDefault(8.0, 0L) / 60000.0);
+            infoDay.setLxMin(durations.getOrDefault(12.0, 0L) / 60000.0);
+            infoDay.setDjcs(frequency.getOrDefault(0.0, 0L));
+            infoDay.setTjcs(frequency.getOrDefault(1.0, 0L));
+            infoDay.setYxcs(frequency.getOrDefault(2.0, 0L));
+            infoDay.setGzcs(frequency.getOrDefault(4.0, 0L));
+            infoDay.setJxcs(frequency.getOrDefault(6.0, 0L));
+            infoDay.setXdcs(frequency.getOrDefault(8.0, 0L));
+            infoDay.setLxcs(frequency.getOrDefault(12.0, 0L));
+        }
+        turbineInfoDayService.saveOrUpdateBatch(byDate.values());
+    }
+
+    public void calcTurbine5s(DateTime begin, DateTime end, double ssxs) {
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        getSnapDataByEntity(entityFs, begin, end, 15);
+        Map<String, Map<String, List<PointData>>> fsMapMap = entityFs.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+        //功率
+        List<PointInfo> entityGl = getEntity("AI114", "turbine");
+        getSnapDataByEntity(entityGl, begin, end, 15);
+        Map<String, Map<String, List<PointData>>> glMapMap = entityGl.stream().collect(Collectors.groupingBy(PointInfo::getStationId,
+                Collectors.toMap(PointInfo::getTurbineId, PointInfo::getPointDatas)));
+        //状态
+        List<PointInfo> ztMapMap = calcTurbineZt(begin, end, entityFs, entityGl);
+        Map<String, Map<String, PointInfo>> ztMapMapInfos = ztMapMap.stream().collect(
+                Collectors.groupingBy(PointInfo::getStationId, Collectors.toMap(PointInfo::getTurbineId, Function.identity())));
+
+        Map<String, TurbineInfoDay> dayMap = getTurbineinfoMap(begin, entityFs);
+        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);
+            Map<String, Double> loss = getTurbinePowerLoss(infoDay.getRfdl(), ztMapMapInfos.get(stId).get(wtId), fsMapMap.get(stId).get(wtId), glMapMap.get(stId).get(wtId));
+            infoDay.setJhjxss(loss.get("jxss") * ssxs);
+            infoDay.setFjhjxss(loss.get("gzss") * ssxs + loss.get("fdjcl") * ssxs + loss.get("sdtj") * ssxs);
+            infoDay.setXdss(loss.get("xdjcl") * ssxs + loss.get("xdtj") * ssxs);
+            infoDay.setSlss(0.0);
+            infoDay.setDjss(loss.get("djss") * ssxs);
+            infoDay.setGzss(loss.get("gzss") * ssxs);
+            infoDay.setXnss(loss.get("xnss") * ssxs + loss.get("djss") * ssxs);
+            infoDay.setLlfdl(infoDay.getRfdl() + infoDay.getJhjxss() + infoDay.getFjhjxss() + infoDay.getXdss() + infoDay.getSlss() + infoDay.getXnss());
+        }));
+        turbineInfoDayService.saveOrUpdateBatch(dayMap.values());
+    }
+
     //依赖calcTurbineRfdl、calcTurbineStateMin、calcTurbine5s2
     public void calcTurbineLyxs(Date date) {
         //date当天零点
@@ -4253,6 +4461,81 @@ public class JavaFunctionJobHandler extends IJobHandler {
         turbineInfoDayService.saveOrUpdateBatch(byDate);
     }
 
+    public void calcTurbineLyxs(DateTime begin) {
+        List<TurbineInfoDay> byDate = getTurbineinfoByDate(begin);
+        Map<String, PointInfo> entityAiZt = getEntity("AI422", "state", PointInfo::getTurbineId);
+
+        for (TurbineInfoDay day : byDate) {
+            String tbId = day.getTurbineId();
+            double lyxs = day.getRfdl() / entityAiZt.get(tbId).getSpare2();
+            double klyl = (24 * 60 - day.getGzMin()) / (24 * 60);
+            double fnlyl = day.getRfdl() / day.getLlfdl();
+            day.setLyxs(lyxs);
+            day.setKlyl(klyl * 100);
+            day.setFnlyl(fnlyl * 100);
+        }
+        turbineInfoDayService.saveOrUpdateBatch(byDate);
+    }
+    //依赖calcTurbineStateMin
+    public void calcStationCftfsfxQfxdl(DateTime begin, DateTime end) {
+        List<TurbineInfoDay> byDate = getTurbineinfoByDate(begin);
+        Map<String, List<TurbineInfoDay>> tidsMap = byDate.stream().collect(Collectors.groupingBy(TurbineInfoDay::getStationId));
+        List<PointInfo> fsEt = getEntity("FCCFTFS90", "station");
+        Map<String, PointInfo> rawFs = getRawDataByEntity(fsEt, goldenUri(), begin, end, PointInfo::getStationId);
+        List<PointInfo> fxEt = getEntity("FCCFTFX90", "station");
+        Map<String, PointInfo> rawFx = getRawDataByEntity(fxEt, goldenUri(), begin, end, PointInfo::getStationId);
+
+        List<StationInfoDay> sids = getStationinfoByDate(begin, fsEt);
+        QueryWrapper<TurbineInfoDay> wrapper = new QueryWrapper<>();
+        wrapper.select("sum(xdss) xdss,station_id").eq("record_date", begin).groupBy("station_id");
+        List<TurbineInfoDay> list = turbineInfoDayService.list(wrapper);
+        Map<String, TurbineInfoDay> dayMap = list.stream().collect(Collectors.toMap(TurbineInfoDay::getStationId, Function.identity()));
+        for (StationInfoDay sid : sids) {
+            String stId = sid.getStationId();
+            List<TurbineInfoDay> tids = tidsMap.get(stId);
+            double whsj = tids.stream().mapToDouble(tid -> tid.getJxMin()).sum();
+            double gzsj = tids.stream().mapToDouble(tid -> tid.getGzMin()).sum();
+            double yxfss = (tids.size() * 24 * 60 - whsj - gzsj) / (tids.size() * 60);
+            List<PointData> fsDatas = Optional.ofNullable(rawFs.get(stId)).map(PointInfo::getPointDatas).orElse(Collections.emptyList());
+            sid.setCftfs(fsDatas.stream().mapToDouble(PointData::getValue).average().orElse(0d));
+            List<PointData> fxDatas = Optional.ofNullable(rawFx.get(stId)).map(PointInfo::getPointDatas).orElse(Collections.emptyList());
+            sid.setCftfx(fxDatas.stream().mapToDouble(PointData::getValue).average().orElse(0d));
+            sid.setYxfss(yxfss);
+            //弃风电量=限电时段全风场理论上网电量-限电时段全风场实际上网电量
+            //弃风限电率 = 弃风电量 / (风电实际发电量 + 弃风电量) × 100%
+            double xdss = dayMap.get(stId).getXdss();
+            double qfxdl = xdss * 100 / (sid.getRfdl() + xdss);
+            sid.setQfxdl(qfxdl);
+        }
+        stationInfoDayService.saveOrUpdateBatch(sids);
+    }
+    //依赖calcTurbineStateMin
+    public void calcTurbineJfplFxYxfssBll(DateTime begin, DateTime end) {
+        //风速
+        List<PointInfo> entityFs = getEntity("AI066", "turbine");
+        Map<String, PointInfo> rawDataFs = getRawDataByEntity(entityFs, goldenUri(), begin, end, PointInfo::getTurbineId);
+        //风向
+        List<PointInfo> entityFx = getEntity("DI1392", "turbine");
+        Map<String, PointInfo> rawDataFx = getRawDataByEntity(entityFx, goldenUri(), begin, end, PointInfo::getTurbineId);
+
+        List<TurbineInfoDay> byDate = getTurbineinfoByDate(begin);
+        for (TurbineInfoDay day : byDate) {
+            String tbId = day.getTurbineId();
+            List<PointData> pds = Optional.ofNullable(rawDataFs.get(tbId)).map(PointInfo::getPointDatas).orElse(Collections.emptyList());
+            long jfsc = calcDuration(pds, pd -> pd.getValue() < 3d);
+            day.setJfpl(jfsc / (1000 * 60 * 60 * 24d));
+            double yxfss = (24 * 60 - day.getJxMin() - day.getGzMin()) / 60;
+            day.setYxfss(yxfss);
+            List<PointData> pdsFx = Optional.ofNullable(rawDataFx.get(tbId)).map(PointInfo::getPointDatas).orElse(Collections.emptyList());
+            double fx = pdsFx.stream().mapToDouble(PointData::getValue).average().orElse(0d);
+            day.setFx(fx);
+            //暴露率 = (运行小时 / 可用小时) × 100%
+            double bll = day.getYxMin() * 100 / (24 * 60 - day.getGzMin() - day.getJxMin());
+            day.setBll(bll);
+        }
+        turbineInfoDayService.saveOrUpdateBatch(byDate);
+    }
+
     public long calcDuration(List<PointData> pds, Function<PointData, Boolean> fun) {
         if (CollUtil.isEmpty(pds)) return 0;
         pds.sort(Comparator.comparingLong(PointData::getTs));
@@ -6872,7 +7155,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
     }
 
     public double calcXdRate(List<Double> doubles) {
-        if (CollUtil.isEmpty(doubles)) return 0; // 计算1.0的数量
+        if (doubles == null || doubles.isEmpty()) return 0; // 计算1.0的数量
         long countOfOnes = doubles.stream().filter(number -> number == 1.0).count();
         // 计算1.0在列表中的占比
         return (double) countOfOnes / doubles.size();
@@ -6948,21 +7231,99 @@ public class JavaFunctionJobHandler extends IJobHandler {
         }
     }
 
-    //计算惠安报表汇总
+    //计算惠安报表汇总实时
     public void calcHaBbHzSs() {
         DateTime date = DateUtil.date();
         DateTime begin = DateUtil.beginOfDay(date);
         //计算指标配置
         QueryWrapper<ProBaseBackfill> fillWrapper = new QueryWrapper<>();
-        fillWrapper.lambda().eq(ProBaseBackfill::getPushTime, "12");
+        fillWrapper.eq("push_time", "12");
+        List<ProBaseBackfill> fills = proBaseBackfillService.list(fillWrapper);
+        Map<String, Map<String, Map<String, ProBaseBackfill>>> fillMapMap = fills.stream().collect(Collectors.groupingBy(ProBaseBackfill::getType,
+                Collectors.groupingBy(ProBaseBackfill::getTaskDescription, Collectors.toMap(ProBaseBackfill::getOperatingMode, Function.identity()))));
+        //指标保存表
+        QueryWrapper<ProEconEquipmentInfoJs> eijWrapper = new QueryWrapper<>();
+        eijWrapper.eq("record_date", begin);
+        List<ProEconEquipmentInfoJs> eijs = proEconEquipmentInfoJsService.list(eijWrapper);
+        Map<String, ProEconEquipmentInfoJs> eijMap = eijs.stream().collect(Collectors.toMap(ProEconEquipmentInfoJs::getMeterName, Function.identity(), (k1, k2) -> k1));
+        Map<String, ProBaseBackfill> fillMapBq01 = fillMapMap.get("SJFDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq02 = fillMapMap.get("SWDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq03 = fillMapMap.get("GWDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq04 = fillMapMap.get("CYDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq05 = fillMapMap.get("CYDLV").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq06 = fillMapMap.get("ZHCYDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq07 = fillMapMap.get("ZHCYDLV").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq08 = fillMapMap.get("PJFS").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq09 = fillMapMap.get("DJWHDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq10 = fillMapMap.get("GZSSDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq11 = fillMapMap.get("JHFDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq12 = fillMapMap.get("LYXSS").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq13 = fillMapMap.get("SBKLYL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq14 = fillMapMap.get("SLSSDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq15 = fillMapMap.get("XDL").get("本期");
+        Map<String, ProBaseBackfill> fillMapBq16 = fillMapMap.get("XDLV").get("本期");
+        String select1 = SqlUtil.getSelectSum("swdl,gwdl,cydl,rfdl,hdl");
+        String select2 = SqlUtil.getSelectAvg("pjfs,klyl,fnlyl,bll") + SqlUtil.getSelectSum("gzss,xdss,xnss,lyxs,gzcs,gz_min,tj_min,dj_min,yx_min,llfdl,yxfss");
+        List<LineInfoDay> lidsBqQc = lineInfoDayService.getDatasByPartSelects(date, DatePart.CURRENT, select1, "project_id");
+        List<TurbineInfoDay> tidsBqQc = turbineInfoDayService.getDatasByPartSelects(date, DatePart.CURRENT, select2, "project_id");
+        List<ProBasicProjectPlan> plantsBqQc = proBasicProjectPlanService.getDatasByPartSelect(date, DatePart.CURRENT, "project_id");
+        List<LineInfoDay> lidsBqCz = lineInfoDayService.getDatasByPartSelects(date, DatePart.CURRENT, select1, "station_id");
+        List<TurbineInfoDay> tidsBqCz = turbineInfoDayService.getDatasByPartSelects(date, DatePart.CURRENT, select2, "station_id");
+        List<ProBasicProjectPlan> plantsBqCz = proBasicProjectPlanService.getDatasByPartSelect(date, DatePart.CURRENT, "windpowerstation_id");
+
+        lineCalcHz(lidsBqQc, fillMapBq01, LineInfoDay::getProjectId, lid -> Double.valueOf(lid.getRfdl()), eijMap, begin);
+        lineCalcHz(lidsBqQc, fillMapBq02, LineInfoDay::getProjectId, LineInfoDay::getSwdl, eijMap, begin);
+        lineCalcHz(lidsBqQc, fillMapBq03, LineInfoDay::getProjectId, LineInfoDay::getGwdl, eijMap, begin);
+        lineCalcHz(lidsBqQc, fillMapBq04, LineInfoDay::getProjectId, LineInfoDay::getCydl, eijMap, begin);
+        lineCalcHz(lidsBqQc, fillMapBq05, LineInfoDay::getProjectId, lid -> lid.getCydl() / lid.getRfdl() * 100, eijMap, begin);
+        lineCalcHz(lidsBqQc, fillMapBq06, LineInfoDay::getProjectId, lid -> lid.getRfdl() - lid.getSwdl() + lid.getGwdl(), eijMap, begin);
+        lineCalcHz(lidsBqQc, fillMapBq07, LineInfoDay::getProjectId, lid -> (lid.getRfdl() - lid.getSwdl() + lid.getGwdl()) / lid.getRfdl(), eijMap, begin);
+        lineCalcHz(tidsBqQc, fillMapBq08, TurbineInfoDay::getProjectId, TurbineInfoDay::getPjfs, eijMap, begin);
+        lineCalcHz(lidsBqQc, fillMapBq09, LineInfoDay::getProjectId, lid -> 0d, eijMap, begin);
+        lineCalcHz(tidsBqQc, fillMapBq10, TurbineInfoDay::getProjectId, TurbineInfoDay::getGzss, eijMap, begin);
+        lineCalcHz(plantsBqQc, fillMapBq11, ProBasicProjectPlan::getProjectId, pbpp -> pbpp.getGeneratingCapacity() / plantsBqQc.size(), eijMap, begin);
+        lineCalcHz(tidsBqQc, fillMapBq12, TurbineInfoDay::getProjectId, TurbineInfoDay::getLyxs, eijMap, begin);
+        lineCalcHz(tidsBqQc, fillMapBq13, TurbineInfoDay::getProjectId, TurbineInfoDay::getKlyl, eijMap, begin);
+        lineCalcHz(lidsBqQc, fillMapBq14, LineInfoDay::getProjectId, lid -> 0d, eijMap, begin);
+        lineCalcHz(tidsBqQc, fillMapBq15, TurbineInfoDay::getProjectId, TurbineInfoDay::getXdss, eijMap, begin);
+        lineCalcHz(tidsBqQc, fillMapBq16, TurbineInfoDay::getProjectId, TurbineInfoDay::getXdss, eijMap, begin);
+        lineCalcHz2(lidsBqQc, fillMapBq16, LineInfoDay::getProjectId, lid -> Double.valueOf(lid.getRfdl()), eijMap, begin);
+
+        lineCalcHz(lidsBqCz, fillMapBq01, LineInfoDay::getStationId, lid -> Double.valueOf(lid.getRfdl()), eijMap, begin);
+        lineCalcHz(lidsBqCz, fillMapBq02, LineInfoDay::getStationId, LineInfoDay::getSwdl, eijMap, begin);
+        lineCalcHz(lidsBqCz, fillMapBq03, LineInfoDay::getStationId, LineInfoDay::getGwdl, eijMap, begin);
+        lineCalcHz(lidsBqCz, fillMapBq04, LineInfoDay::getStationId, LineInfoDay::getCydl, eijMap, begin);
+        lineCalcHz(lidsBqCz, fillMapBq05, LineInfoDay::getStationId, lid -> lid.getCydl() / lid.getRfdl() * 100, eijMap, begin);
+        lineCalcHz(lidsBqCz, fillMapBq06, LineInfoDay::getStationId, lid -> lid.getRfdl() - lid.getSwdl() + lid.getGwdl(), eijMap, begin);
+        lineCalcHz(lidsBqCz, fillMapBq07, LineInfoDay::getStationId, lid -> (lid.getRfdl() - lid.getSwdl() + lid.getGwdl()) / lid.getRfdl(), eijMap, begin);
+        lineCalcHz(tidsBqCz, fillMapBq08, TurbineInfoDay::getStationId, TurbineInfoDay::getPjfs, eijMap, begin);
+        lineCalcHz(lidsBqCz, fillMapBq09, LineInfoDay::getStationId, lid -> 0d, eijMap, begin);
+        lineCalcHz(tidsBqCz, fillMapBq10, TurbineInfoDay::getStationId, TurbineInfoDay::getGzss, eijMap, begin);
+        lineCalcHz(plantsBqCz, fillMapBq11, ProBasicProjectPlan::getWindpowerstationId, pbpp -> pbpp.getGeneratingCapacity() / plantsBqCz.size(), eijMap, begin);
+        lineCalcHz(tidsBqCz, fillMapBq12, TurbineInfoDay::getStationId, TurbineInfoDay::getLyxs, eijMap, begin);
+        lineCalcHz(tidsBqCz, fillMapBq13, TurbineInfoDay::getStationId, TurbineInfoDay::getKlyl, eijMap, begin);
+        lineCalcHz(lidsBqCz, fillMapBq14, LineInfoDay::getStationId, lid -> 0d, eijMap, begin);
+        lineCalcHz(tidsBqCz, fillMapBq15, TurbineInfoDay::getStationId, TurbineInfoDay::getXdss, eijMap, begin);
+        lineCalcHz(tidsBqCz, fillMapBq16, TurbineInfoDay::getStationId, TurbineInfoDay::getXdss, eijMap, begin);
+        lineCalcHz2(lidsBqCz, fillMapBq16, LineInfoDay::getStationId, lid -> Double.valueOf(lid.getRfdl()), eijMap, begin);
+        proEconEquipmentInfoJsService.saveOrUpdateBatch(eijMap.values());
+    }
+
+    //计算惠安报表汇总
+    public void calcHaBbHzSs(Date date0) {
+        DateTime begin = DateUtil.offsetDay(DateUtil.beginOfDay(date0), -1);
+        DateTime date = DateUtil.endOfDay(begin);
+        //计算指标配置
+        QueryWrapper<ProBaseBackfill> fillWrapper = new QueryWrapper<>();
+        fillWrapper.eq("push_time", "12");
         List<ProBaseBackfill> fills = proBaseBackfillService.list(fillWrapper);
         Map<String, Map<String, Map<String, ProBaseBackfill>>> fillMapMap = fills.stream().collect(Collectors.groupingBy(ProBaseBackfill::getType,
                 Collectors.groupingBy(ProBaseBackfill::getTaskDescription, Collectors.toMap(ProBaseBackfill::getOperatingMode, Function.identity()))));
         //指标保存表
         QueryWrapper<ProEconEquipmentInfoJs> eijWrapper = new QueryWrapper<>();
-        eijWrapper.lambda().eq(ProEconEquipmentInfoJs::getRecordDate, begin);
+        eijWrapper.eq("record_date", begin);
         List<ProEconEquipmentInfoJs> eijs = proEconEquipmentInfoJsService.list(eijWrapper);
-        Map<String, ProEconEquipmentInfoJs> eijMap = eijs.stream().collect(Collectors.toMap(ProEconEquipmentInfoJs::getMeterId, Function.identity(), (k1, k2) -> k1));
+        Map<String, ProEconEquipmentInfoJs> eijMap = eijs.stream().collect(Collectors.toMap(ProEconEquipmentInfoJs::getMeterName, Function.identity(), (k1, k2) -> k1));
         Map<String, ProBaseBackfill> fillMapBq01 = fillMapMap.get("SJFDL").get("本期");
         Map<String, ProBaseBackfill> fillMapBq02 = fillMapMap.get("SWDL").get("本期");
         Map<String, ProBaseBackfill> fillMapBq03 = fillMapMap.get("GWDL").get("本期");
@@ -7032,15 +7393,15 @@ public class JavaFunctionJobHandler extends IJobHandler {
         DateTime yesterday = DateUtil.offsetDay(begin, -1);
         //计算指标配置
         QueryWrapper<ProBaseBackfill> fillWrapper = new QueryWrapper<>();
-        fillWrapper.lambda().eq(ProBaseBackfill::getPushTime, "12");
+        fillWrapper.eq("push_time", "12");
         List<ProBaseBackfill> fills = proBaseBackfillService.list(fillWrapper);
         Map<String, Map<String, Map<String, ProBaseBackfill>>> fillMapMap = fills.stream().collect(Collectors.groupingBy(ProBaseBackfill::getType,
                 Collectors.groupingBy(ProBaseBackfill::getTaskDescription, Collectors.toMap(ProBaseBackfill::getOperatingMode, Function.identity()))));
         //指标保存表
         QueryWrapper<ProEconEquipmentInfoJs> eijWrapper = new QueryWrapper<>();
-        eijWrapper.lambda().eq(ProEconEquipmentInfoJs::getRecordDate, yesterday);
+        eijWrapper.eq("record_date", yesterday);
         List<ProEconEquipmentInfoJs> eijs = proEconEquipmentInfoJsService.list(eijWrapper);
-        Map<String, ProEconEquipmentInfoJs> eijMap = eijs.stream().collect(Collectors.toMap(ProEconEquipmentInfoJs::getMeterId, Function.identity(), (k1, k2) -> k1));
+        Map<String, ProEconEquipmentInfoJs> eijMap = eijs.stream().collect(Collectors.toMap(ProEconEquipmentInfoJs::getMeterName, Function.identity(), (k1, k2) -> k1));
         //风机日月发电量
         Map<String, ProBaseBackfill> fillMapFdlR = fillMapMap.get("FDL").get("日");
         Map<String, ProBaseBackfill> fillMapFdlY = fillMapMap.get("FDL").get("月");
@@ -7144,7 +7505,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         Map<String, ProBaseBackfill> fillMapY34 = fillMapMap.get("ZRYSTJSC").get("月");
         Map<String, ProBaseBackfill> fillMapN34 = fillMapMap.get("ZRYSTJSC").get("年");
         String select1 = SqlUtil.getSelectSum("swdl,gwdl,cydl,rfdl,hdl");
-        String select2 = SqlUtil.getSelectAvg("pjfs,klyl,fnlyl,bll") + SqlUtil.getSelectSum("gzss,xdss,xnss,lyxs,gzcs,gz_min,tj_min,dj_min,yx_min,llfdl,yxfss");
+        String select2 = SqlUtil.getSelectAvg("pjfs,klyl,fnlyl,bll") + SqlUtil.getSelectSum("gzss,xdss,xnss,lyxs,gzcs,gz_min,tj_min,dj_min,yx_min,rfdl,llfdl,yxfss");
         String select3 = SqlUtil.getSelectSum("fdl,hdl");
         String select4 = SqlUtil.getSelectAvg("qfxdl") + SqlUtil.getSelectSum("rfdl,rfdl_fj,kqmd,hjwd");
         //线路
@@ -7170,8 +7531,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
         //电计量
         List<MeterInfoDay> midsRMt = meterInfoDayService.getDatasByPartSelects(yesterday, DatePart.DAY, select3, "meter_id");
         List<MeterInfoDay> midsYMt = meterInfoDayService.getDatasByPartSelects(yesterday, DatePart.MONTH, select3, "meter_id");
-        List<MeterInfoDay> midsRPrt = meterInfoDayService.getDatasByPartSelects(yesterday, DatePart.DAY, select3, "meter_id");
-        List<MeterInfoDay> midsYPrt = meterInfoDayService.getDatasByPartSelects(yesterday, DatePart.MONTH, select3, "meter_id");
+        List<MeterInfoDay> midsRPrt = meterInfoDayService.getDatasByPartSelects(yesterday, DatePart.DAY, select3, "parent_id");
+        List<MeterInfoDay> midsYPrt = meterInfoDayService.getDatasByPartSelects(yesterday, DatePart.MONTH, select3, "parent_id");
+        List<MeterInfoDay> midsRBst = meterInfoDayService.getDatasByPartSelects(yesterday, DatePart.DAY, select3, "booster_id");
+        List<MeterInfoDay> midsYBst = meterInfoDayService.getDatasByPartSelects(yesterday, DatePart.MONTH, select3, "booster_id");
         //计划电量
         List<ProBasicProjectPlan> plantsYQc = proBasicProjectPlanService.getDatasByPartSelect(yesterday, DatePart.MONTH, "project_id");
         List<ProBasicProjectPlan> plantsYCz = proBasicProjectPlanService.getDatasByPartSelect(yesterday, DatePart.MONTH, "windpowerstation_id");
@@ -7253,14 +7616,16 @@ public class JavaFunctionJobHandler extends IJobHandler {
         lineCalcHz(sidN, fillMapFdlN, StationInfoDay::getStationId, sid -> Double.valueOf(sid.getRfdl()), eijMap, yesterday);
         //耗电量日
         lineCalcHz(midsRMt, fillMapR17, MeterInfoDay::getMeterId, MeterInfoDay::getHdl, eijMap, yesterday);
+        lineCalcHz(midsRPrt, fillMapR17, MeterInfoDay::getParentId, MeterInfoDay::getHdl, eijMap, yesterday);
+        lineCalcHz(midsRBst, fillMapR17, MeterInfoDay::getBoosterId, MeterInfoDay::getHdl, eijMap, yesterday);
         lineCalcHz(lidsRXl, fillMapR17, LineInfoDay::getLineId, LineInfoDay::getHdl, eijMap, yesterday);
         lineCalcHz(lidsRCz, fillMapR17, LineInfoDay::getStationId, LineInfoDay::getHdl, eijMap, yesterday);
-        lineCalcHz(midsRPrt, fillMapR17, MeterInfoDay::getParentId, MeterInfoDay::getHdl, eijMap, yesterday);
         //耗电量月
         lineCalcHz(midsYMt, fillMapY17, MeterInfoDay::getMeterId, MeterInfoDay::getHdl, eijMap, yesterday);
+        lineCalcHz(midsYPrt, fillMapY17, MeterInfoDay::getParentId, MeterInfoDay::getHdl, eijMap, yesterday);
+        lineCalcHz(midsYBst, fillMapY17, MeterInfoDay::getBoosterId, MeterInfoDay::getHdl, eijMap, yesterday);
         lineCalcHz(lidsYXl, fillMapY17, LineInfoDay::getLineId, LineInfoDay::getHdl, eijMap, yesterday);
         lineCalcHz(lidsYCz, fillMapY17, LineInfoDay::getStationId, LineInfoDay::getHdl, eijMap, yesterday);
-        lineCalcHz(midsYPrt, fillMapY17, MeterInfoDay::getParentId, MeterInfoDay::getHdl, eijMap, yesterday);
         //期次月
         lineCalcHz(lidsYQc, fillMapY01, LineInfoDay::getProjectId, lid -> Double.valueOf(lid.getRfdl()), eijMap, yesterday);
         lineCalcHz(lidsYQc, fillMapY02, LineInfoDay::getProjectId, LineInfoDay::getSwdl, eijMap, yesterday);
@@ -7355,7 +7720,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
             double apply = algorithm.apply(item);
             double v;
             if (apply == 0) {
-                v = 100d;
+                v = 0d;
             } else {
                 v = js.getStopCode() / apply * 100;
                 if (v > 100) v = 100d;
@@ -7379,8 +7744,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
             js = new ProEconEquipmentInfoJs();
             js.setRecordDate(day);
             js.setWpid(fill.getStation());
-            js.setMeterId(fill.getCode());
-            js.setMeterName(fill.getOperatingMode());
+            js.setMeterId(fill.getOperatingMode());
+            js.setMeterName(fill.getCode());
             eijMap.put(fill.getCode(), js);
         }
         return js;

+ 164 - 111
ruoyi-admin/src/test/java/com/ruoyi/NewTests.java

@@ -9,9 +9,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
 import com.baomidou.mybatisplus.core.toolkit.support.LambdaMeta;
 import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
+import com.ruoyi.ucp.entity.StationInfoDay;
 import com.ruoyi.ucp.entity.StationInfoMin;
 import com.ruoyi.ucp.entity.TurbineInfoDay;
+import com.ruoyi.ucp.service.IStationInfoDayService;
 import com.ruoyi.ucp.service.IStationInfoMinService;
+import com.ruoyi.ucp.util.DatePart;
+import com.ruoyi.ucp.util.SqlUtil;
 import com.ruoyi.web.controller.JavaFunctionJobHandler;
 import org.apache.ibatis.reflection.property.PropertyNamer;
 import org.junit.Test;
@@ -34,11 +38,29 @@ public class NewTests {
     private JavaFunctionJobHandler task;
     @Resource
     private IStationInfoMinService stationInfoMinService;
+    @Resource
+    private IStationInfoDayService stationInfoDayService;
+
+    public static void main(String[] args) {
+        //QueryWrapper<TurbineInfoDay> queryWrapper = new QueryWrapper<>();
+        //queryWrapper.lambda().select(TurbineInfoDay::getRecordDate);
+        //System.out.println();
+        List<Double> list = new ArrayList<>();
+        Double o = list.get(0);
+        System.out.println();
+    }
+
+    private static void aadd(SFunction<TurbineInfoDay, String> a) {
+        LambdaMeta meta = LambdaUtils.extract(a);
+        String fieldName = PropertyNamer.methodToProperty(meta.getImplMethodName());
+        String string = a.toString();
+        System.out.println(a);
+    }
 
     @Test
     public void test() {
-//        task.calcTurbineRFDLSameDay();
-//        task.calcTurbine5s2SameDay();
+        //        task.calcTurbineRFDLSameDay();
+        //        task.calcTurbine5s2SameDay();
         /*Map<Double, Double> a1 = CalcCache.fitcoef.get("GJNY_SXGS_FSG_F_WT_0040_EQ");
         Map<Double, Double> a3 = CalcCache.fitcoef.get("GJNY_SXGS_FSG_F_WT_0047_EQ");
         TreeMap<Double, Double> b1 = new TreeMap<>();
@@ -63,37 +85,37 @@ public class NewTests {
         System.out.println();*/
 
         Date date = DateUtil.parse("2024-12-04");
-//        task.calcTurbineSsfsQx(date);
-//        task.ambientTemperature();
+        //        task.calcTurbineSsfsQx(date);
+        //        task.ambientTemperature();
 
-//        task.calcTurbine5s2(date);
+        //        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);
-//        calcNhglZs(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);
+        //        calcNhglZs(date);
         // 创建日期范围生成器
-//        DateTime date = DateUtil.date();
-//        task.calcTurbine5s2(date);
+        //        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());
+        //        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);
             //上网购网厂用电量
@@ -102,29 +124,29 @@ public class NewTests {
             task.calcStationZhcyRfDl(date);*/
 
 
-//            task.calcTurbineRFDL(date);
-//            task.writeReportPoolPjfs2(date);
+        //            task.calcTurbineRFDL(date);
+        //            task.writeReportPoolPjfs2(date);
         //安全天数
-//            calcAQTS(time.toJdkDate());
+        //            calcAQTS(time.toJdkDate());
             /*task.calcLineRfdl(date,"GJNY_SXGS_ZZ_FDC_STA");
             task.calcStationSwGwCyRdl(date);
             task.calcStationZhcyRfDl(date);
             task.calcLineSwGWCyDl(date);
             task.writeReportPool(date);
             task.writeReportPoolProject(date);*/
-//            task.calcLineSwGWCyDl(date,"GJNY_SXGS_XZ_FDC_STA");
-//            task.writeReportPoolProject(date);
-//            //计算综合厂用电量
-//            task.calcStationZhcydl(date);
-//
+        //            task.calcLineSwGWCyDl(date,"GJNY_SXGS_XZ_FDC_STA");
+        //            task.writeReportPoolProject(date);
+        //            //计算综合厂用电量
+        //            task.calcStationZhcydl(date);
+        //
             /*task.calcTurbineRFDL(date);
             task.calcStationRfdlFj(date);
             task.calcTurbine5s2(date);
             task.writeReportPool5SPjfsLlfdl(date);*/
 
-//            task.writeReportPool(date);
-//            int test = task.test(date, "zuozhuang.610825F02Y0AFA10GS009DQ0251DG02RAW00", 1320);
-//            System.out.println(test);
+        //            task.writeReportPool(date);
+        //            int test = task.test(date, "zuozhuang.610825F02Y0AFA10GS009DQ0251DG02RAW00", 1320);
+        //            System.out.println(test);
 
 
             /*task.calcLineRfdlSameDay();
@@ -133,13 +155,13 @@ public class NewTests {
             task.calcLineSwGWCyDlSameDay();
             task.writeReportPoolSameDay();
             task.writeReportPoolProjectSameDay();*/
-//    }
-//        calcTurbineRFDL(date);
-//        task.calcTurbine5s2(date);
-//        writeReportPool(date);
+        //    }
+        //        calcTurbineRFDL(date);
+        //        task.calcTurbine5s2(date);
+        //        writeReportPool(date);
 
-//        task.calcStationSspjfs();
-//        task.calcRealtimeTurbineZt();
+        //        task.calcStationSspjfs();
+        //        task.calcRealtimeTurbineZt();
     }
 
     @Test
@@ -150,23 +172,23 @@ public class NewTests {
         DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
         for (DateTime date : range) {
             System.out.println(DateUtil.date() + ":" + date);
-//            task.calcAQTS(date);
-//            task.calcLineRfdl(date,"GJNY_SXGS_JSL_FDC_STA");
-//            task.calcStationSwGwCyRdl(date,"GJNY_SXGS_JSL_FDC_STA");
-//            task.calcStationZhcyRfDl(date,"GJNY_SXGS_JSL_FDC_STA");
-//            task.calcLineSwGWCyDl(date,"GJNY_SXGS_JSL_FDC_STA");
-//            task.writeReportPool(date);
-//            task.writeReportPoolProject(date);
-//            task.calcStationHourPjglRfdl(DateUtil.date());
+            //            task.calcAQTS(date);
+            //            task.calcLineRfdl(date,"GJNY_SXGS_JSL_FDC_STA");
+            //            task.calcStationSwGwCyRdl(date,"GJNY_SXGS_JSL_FDC_STA");
+            //            task.calcStationZhcyRfDl(date,"GJNY_SXGS_JSL_FDC_STA");
+            //            task.calcLineSwGWCyDl(date,"GJNY_SXGS_JSL_FDC_STA");
+            //            task.writeReportPool(date);
+            //            task.writeReportPoolProject(date);
+            //            task.calcStationHourPjglRfdl(DateUtil.date());
             task.calcTurbine5s2(date);
         }
-//        task.calcStationHourPjglRfdl(DateUtil.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);
+        //        task.calcStationHourPJGL(date);
+        //        task.calcLineRfdl(date);
+        //        task.calcStationHourRFDL(date);
+        //        task.calcTurbinePjfsPjglKyglLlglMin(DateUtil.date(), 15);
+        //        task.calcStationLlglKyglSjglAgcMin(date, 15);
     }
 
     @Test
@@ -177,30 +199,17 @@ public class NewTests {
         DateRange range = DateUtil.range(start, end, DateField.MONTH);
         for (DateTime date : range) {
             System.out.println(DateUtil.date() + ":" + date);
-//            task.calcStationRjhfdl(date);
+            //            task.calcStationRjhfdl(date);
 
         }
     }
 
-    public static void main(String[] args) {
-        QueryWrapper<TurbineInfoDay> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().select(TurbineInfoDay::getRecordDate);
-        System.out.println();
-    }
-
-    private static void aadd(SFunction<TurbineInfoDay,String> a) {
-        LambdaMeta meta = LambdaUtils.extract(a);
-        String fieldName = PropertyNamer.methodToProperty(meta.getImplMethodName());
-        String string = a.toString();
-        System.out.println(a);
-    }
-
     @Test
     public void test4() {
-//        while (true){
-//            task.calcStationRealtimeLLgl();
-//            ThreadUtil.sleep(60000);
-//        }
+        //        while (true){
+        //            task.calcStationRealtimeLLgl();
+        //            ThreadUtil.sleep(60000);
+        //        }
         DateTime start = DateUtil.parse("2023-12-01");
         DateTime end = DateUtil.parse("2023-12-01");
         DateRange range = DateUtil.range(start, end, DateField.MONTH);
@@ -212,20 +221,20 @@ public class NewTests {
         stIds.add("GJNY_SXGS_XZ_FDC_STA");
         stIds.add("GJNY_SXGS_LJS_FDC_STA");
         for (DateTime date : range) {
-//            task.calcTurbineStateMin(date);
+            //            task.calcTurbineStateMin(date);
             task.predictExaminBc(stIds, date);
         }
-//        task.calcGlqxnhSurplus(start, end);
+        //        task.calcGlqxnhSurplus(start, end);
 
     }
 
     @Test
     public void test5() {
         DateTime date = DateUtil.date();
-//        DateTime date = DateUtil.parseDate("2023-01-01");
+        //        DateTime date = DateUtil.parseDate("2023-01-01");
         //task.calcTurbineStateMin(date);
-//        task.calcStationRjhfdl(date);
-//        task.calcKhfs(date);
+        //        task.calcStationRjhfdl(date);
+        //        task.calcKhfs(date);
 
         task.calcTurbine5s2(date);
         //风机状态时间
@@ -240,7 +249,7 @@ public class NewTests {
 
     @Test
     public void test6() {
-        DateTime begin = DateUtil.parse("2024-10-07 23:30:00");
+        DateTime begin = DateUtil.parse("2024-12-19 20:30:00");
         DateTime end = DateUtil.parse("2025-01-02 14:00:00");
         DateTime minEnd = begin;
         while (minEnd.isBefore(end)) {
@@ -271,7 +280,7 @@ public class NewTests {
         Map<String, List<StationInfoMin>> collect = list.stream().collect(Collectors.groupingBy(m -> DateUtil.date(m.getRecordDate()).toString()));
         while (minEnd.isBefore(end)) {
             minEnd = DateUtil.offsetMinute(begin, i * 15);
-//            task.ycbs(stIds,minBegin,minEnd,collect.get(minEnd.toString()));
+            //            task.ycbs(stIds,minBegin,minEnd,collect.get(minEnd.toString()));
             System.out.println(minBegin.toString() + "," + minEnd.toString());
             i++;
             minBegin = minEnd;
@@ -297,7 +306,7 @@ public class NewTests {
         Map<String, List<StationInfoMin>> collect = list.stream().collect(Collectors.groupingBy(m -> DateUtil.date(m.getRecordDate()).toString()));
         while (minEnd.isBefore(end)) {
             minEnd = DateUtil.offsetMinute(begin, i * 15);
-//            task.ycbs2(stIds,minBegin,minEnd,collect.get(minEnd.toString()));
+            //            task.ycbs2(stIds,minBegin,minEnd,collect.get(minEnd.toString()));
             System.out.println(minBegin.toString() + "," + minEnd.toString());
             i++;
             minBegin = minEnd;
@@ -306,43 +315,62 @@ public class NewTests {
 
     @Test
     public void test9() {
+        //task.calcHaBbHzSs();
         DateTime date = DateUtil.date();
-        //task.calcLineRfdlSameDay();
-        //task.calcStationSwGwCyDlSameDay();
+        //Date date = DateUtil.parse("2025-01-09");
+        //task.calcLineRfdlSameDay_ha();
+        //task.calcStationSwGwCyDlSameDay_ha();
         //task.calcStationZhcyRfDlSameDay();
         //task.calcLineSwGWCyDlSameDay();
-        //task.calcTurbineStateMin(date);
-        //task.calcTurbineLyxs(date);
-        task.calcTurbine5s2(date);
+        //task.calcTurbine5s2_ha(date);
+        task.calcStationRfdlFj(date);
+        task.calcHaBbHz(date);
+        //task.calcHaBbHzSs();
+        //task.calcHaBbHzSs(date);
     }
 
     @Test
     public void test10() {
-//        DateTime date = DateUtil.date();
+        //        DateTime date = DateUtil.date();
         // 创建日期范围生成器
-        DateTime start = DateUtil.parse("2024-12-26");
-        DateTime end = DateUtil.parse("2024-12-30");
+        DateTime start = DateUtil.parse("2025-01-02");
+        DateTime end = DateUtil.parse("2025-01-15");
         DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
         for (DateTime date : range) {
-            System.out.println(DateUtil.date() + ":" + date);
-            task.calcTurbineRFDL_ha(date);
-            task.calcLineRfdl_ha(date);
-            //上网购网厂用电量
-            task.calcStationSwGwCyRdl_ha(date);
-            //计算综合厂用电量
-            task.calcStationZhcyRfDl(date);
-            //风机日环境温度
-            task.ambientTemperature();
-            //计算日发电量--风机汇总方式
-            task.calcStationRfdlFj(date);
-            task.calcLineSwGWCyDl(date);
-            task.calcTurbine5s2(date);
-            //风机状态时间
-            task.calcTurbineStateMin(date);
-            //风机日切入
-            task.cutInWindSpeed(date);
-            //风机日额定风速
-            task.calcGlqxnh_edfs(date);
+            //System.out.println(DateUtil.date() + ":" + date);
+            //
+            //task.calcTurbineRFDL_ha(date);
+            //task.calcLineRfdl_ha(date);
+            //
+            ////上网购网厂用电量
+            //task.calcStationSwGwCyRdl_ha(date);
+            ////计算综合厂用电量
+            //task.calcStationZhcyRfDl(date);
+            ////风机日环境温度
+            //task.ambientTemperature(date);
+            ////计算日发电量--风机汇总方式
+            //task.calcStationRfdlFj(date);
+            //
+            //task.calcLineSwGWCyDl(date);
+            //
+            //task.calcTurbine5s2_ha(date);
+            ////风机状态时间
+            //task.calcTurbineStateMin(date);
+            ////风机日切入
+            //task.cutInWindSpeed(date);
+            ////风机日额定风速
+            //task.calcGlqxnh_edfs(date);
+            ////计算惠安报表汇总实时
+            //task.calcStationCftfsfxQfxdl(date);
+            //task.calcMeterDlHdl(date);
+            //task.calcStationKqmd(date);
+            //
+            //task.calcStationKydlzql(date);
+            //task.calcTurbineJfplFxYxfssBll(date);
+            //task.calcTurbineLyxs(date);
+            //task.calcMeterDlHdl(date);
+            //task.calcHaBbHz(date);
+            task.calcHaBbHzSs(date);
         }
     }
 
@@ -360,4 +388,29 @@ public class NewTests {
         DateTime start = DateUtil.offsetMonth(end, -3);
         task.calcGlqxnh_ha(start, end);
     }
+
+    @Test
+    public void test13() {
+        DateTime end = DateUtil.date();
+        DateTime begin = DateUtil.beginOfDay(end);
+        task.calcTurbineRFDL(begin, end);
+        task.calcTurbineStateMin(begin, end);
+        task.calcTurbine5s(begin, end, 0.1);
+        task.calcTurbineLyxs(begin);
+        task.calcStationCftfsfxQfxdl(begin, end);
+        task.calcTurbineJfplFxYxfssBll(begin, end);
+    }
+    @Test
+    public void test14() {
+        DateTime start = DateUtil.parse("2025-01-01");
+        DateTime end = DateUtil.parse("2025-01-14");
+        String select4 = SqlUtil.getSelectAvg("qfxdl") + SqlUtil.getSelectSum("rfdl,rfdl_fj,kqmd,hjwd");
+        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
+        for (DateTime date : range) {
+            System.out.println(date);
+            List<StationInfoDay> sidR = stationInfoDayService.getDatasByPartSelects(date, DatePart.DAY, select4, "station_id");
+            //List<StationInfoDay> sidY = stationInfoDayService.getDatasByPartSelects(date, DatePart.MONTH, select4, "station_id");
+            System.out.println(sidR.get(0).getRfdlFj());
+        }
+    }
 }

+ 26 - 7
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/LineInfoDay.java

@@ -33,11 +33,30 @@ public class LineInfoDay implements Serializable {
 
     private Date recordDate;
 
-    private Integer  rfdl;
-    private double  swdl;
-    private double  gwdl;
-    private double  cydl;
-    private double  zyb;
-    private double  hdl;
-
+    private Integer rfdl;
+    private double swdl;
+    private double gwdl;
+    private double cydl;
+    private double zyb;
+    private double hdl;
+
+    public double getSwdl() {
+        if (Double.isNaN(swdl)) swdl = 0d;
+        return swdl;
+    }
+
+    public double getGwdl() {
+        if (Double.isNaN(gwdl)) gwdl = 0d;
+        return gwdl;
+    }
+
+    public double getCydl() {
+        if (Double.isNaN(cydl)) cydl = 0d;
+        return cydl;
+    }
+
+    public double getZyb() {
+        if (Double.isNaN(zyb)) zyb = 0d;
+        return zyb;
+    }
 }

+ 11 - 1
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/ProEconEquipmentInfoJs.java

@@ -25,7 +25,7 @@ public class ProEconEquipmentInfoJs implements Serializable {
     /**
      * 编号
      */
-    @TableId(type=IdType.ASSIGN_ID)
+    @TableId(type = IdType.ASSIGN_ID)
     private String id;
 
     /**
@@ -62,4 +62,14 @@ public class ProEconEquipmentInfoJs implements Serializable {
      * 回填测点
      */
     private String backCode;
+
+    //public void setStopCode(Double stopCode) {
+    //    if (stopCode == null || stopCode.isNaN()) stopCode = 0.0;
+    //    this.stopCode = stopCode;
+    //}
+
+    public Double getStopCode() {
+        if (stopCode == null || stopCode.isNaN()) stopCode = 0.0;
+        return stopCode;
+    }
 }

+ 5 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/StationInfoDay.java

@@ -60,4 +60,9 @@ public class StationInfoDay implements Serializable {
     private Double qfxdl;
 
     private Double kqmd;
+
+    public Double getQfxdl() {
+        if (qfxdl == null || Double.isNaN(qfxdl)) qfxdl = 0d;
+        return qfxdl;
+    }
 }

+ 15 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/entity/TurbineInfoDay.java

@@ -64,4 +64,19 @@ public class TurbineInfoDay implements Serializable {
     private Double klyl;
     private Double fnlyl;
     private Double bll;
+
+    public Double getBll() {
+        if (bll == null || Double.isNaN(bll)) bll = 0d;
+        return bll;
+    }
+
+    public Double getFnlyl() {
+        if (fnlyl == null || Double.isNaN(fnlyl)) fnlyl = 0d;
+        return fnlyl;
+    }
+
+    public Double getKlyl() {
+        if (klyl == null || Double.isNaN(klyl)) klyl = 0d;
+        return klyl;
+    }
 }

+ 4 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/feign/AdapterApi.java

@@ -40,6 +40,10 @@ public interface AdapterApi {
                                   @RequestParam("startTs") long startTs,
                                   @RequestParam("endTs") long endTs);
     //@RequestParam("interval") int interval);
+    @GetMapping("/history/statso")
+    PointData getHistoryAvg(URI baseUri, @RequestParam("tagName") String tagName,
+                                  @RequestParam("startTs") long startTs,
+                                  @RequestParam("endTs") long endTs);
 
     @GetMapping("/history/stat")
     List<DoubleStatData> getHistoryStat2(URI baseUri, @RequestParam("tagName") String tagName,

+ 23 - 0
universal-computing-platform/src/main/java/com/ruoyi/ucp/util/SqlUtil.java

@@ -28,6 +28,29 @@ public class SqlUtil {
     public static DateTime[] getBeginEnd(Date date, DatePart datePart) {
         DateTime[] split = new DateTime[2];
         DateTime begin = null,end = null;
+        end = DateUtil.endOfDay(date);
+        switch (datePart){
+            case DAY:
+                begin = DateUtil.beginOfDay(date);
+                break;
+            case MONTH:
+                begin = DateUtil.beginOfMonth(date);
+                break;
+            case YEAR:
+                begin = DateUtil.beginOfYear(date);
+                break;
+            case CURRENT:
+                begin = DateUtil.beginOfDay(date);
+                end = DateUtil.date(date);
+                break;
+        }
+        split[0]=begin;
+        split[1]=end;
+        return split;
+    }
+    public static DateTime[] getBeginEnd2(Date date, DatePart datePart) {
+        DateTime[] split = new DateTime[2];
+        DateTime begin = null,end = null;
         switch (datePart){
             case DAY:
                 begin = DateUtil.beginOfDay(date);