Sfoglia il codice sorgente

场内对标返回结果修改

王波 3 settimane fa
parent
commit
5ceac4732d

+ 34 - 4
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/EarlyWarning/NewGetWindReportService.java

@@ -48,6 +48,7 @@ public class NewGetWindReportService {
         //当月数据
         List<TurbineInfoDay> monthList = turbineInfoDayService.monthList(time);
         List<TurbineInfoDay> top3list = turbineInfoDayService.topList(time);
+        List<TurbineInfoDay> modellist = turbineInfoDayService.modelList(time);
         List<TurbineInfoDay> fntop3list = turbineInfoDayService.fntopList(time);
         List<TurbineInfoDay> ssdltop3list = turbineInfoDayService.ssdltopList(time);
         List<TurbineInfoDay> bottom3list = turbineInfoDayService.bottomList(time);
@@ -73,6 +74,7 @@ public class NewGetWindReportService {
         List<StationInfoMonth> qnmttlist = stationInfoMonthService.qnmttlist(time);
 
         setTurbineIdFromNemCode(wtls, top3list);
+        setTurbineIdFromNemCode(wtls, modellist);
         setTurbineIdFromNemCode(wtls, fntop3list);
         setTurbineIdFromNemCode(wtls, ssdltop3list);
         setTurbineIdFromNemCode(wtls, bottom3list);
@@ -178,6 +180,7 @@ public class NewGetWindReportService {
             avgklyltop3 = StringUtils.round(totalKlyl / 3, 2);
         }
         double top1ssdl = StringUtils.round(topXdssdl[0] + topJxssdl[0] + topGzssdl[0] + topXnssdl[0] + topSlssdl[0], 2);
+        double top2ssdl = StringUtils.round(topXdssdl[1] + topJxssdl[1] + topGzssdl[1] + topXnssdl[1] + topSlssdl[1], 2);
         double top3ssdl = StringUtils.round(topXdssdl[2] + topJxssdl[2] + topGzssdl[2] + topXnssdl[2] + topSlssdl[2], 2);
         // 处理bottom3list数据
         if (bottom3list.size() > 0) {
@@ -311,10 +314,37 @@ public class NewGetWindReportService {
         }
         fanBenchmark.setIndicators(fanIndicators);
 
-        // 1.3 设置结论
-        fanBenchmark.setConclusion(
-                topIds[2] + "号与" + topIds[0] + "号风机核心差异,损失电量差" + StringUtils.round(top1ssdl - top3ssdl, 2) + "万kWh"
-        );
+        // 使用 Map 存储风机数据,提高查找效率
+        Map<String, TurbineInfoDay> turbineMap = new HashMap<>();
+        for (TurbineInfoDay turbine : modellist) {
+            turbineMap.put(turbine.getStationId(), turbine);
+        }
+
+        List<String> resultTexts = new ArrayList<>();
+        double[] ssdlValues = {top1ssdl, top2ssdl, top3ssdl};
+
+        // 遍历 topIds 进行对比计算
+        for (int i = 0; i < topIds.length; i++) {
+            String topId = topIds[i];
+            double currentSsdl = ssdlValues[i];
+            String benchmarkTurbine = topId.startsWith("1") ? "1205" : topId.startsWith("2") ? "2401" : null;
+
+            if (benchmarkTurbine == null || !turbineMap.containsKey(benchmarkTurbine)) {
+                continue; // 跳过无标杆风机的情况
+            }
+
+            TurbineInfoDay turbine = turbineMap.get(benchmarkTurbine);
+            double turbineSsdl = turbine.getXdss() + turbine.getXnss() + turbine.getJhjxss() +
+                    turbine.getFjhjxss() + turbine.getSlss();
+            double result = Math.round((currentSsdl - turbineSsdl / bl) * 100.0) / 100.0; // 保留两位小数
+
+            String resultText = String.format("%s号风机和标杆风机%s进行对比,损失电量差为%.2f万kWh",
+                    topId, benchmarkTurbine, result);
+            resultTexts.add(resultText);
+        }
+
+        // 将结果文本合并为字符串并设置到 conclusion
+        fanBenchmark.setConclusion(String.join("; ", resultTexts));
 
         // 放入最终的 map
         map.put("cndb", fanBenchmark);

+ 1 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/ITurbineInfoDayService.java

@@ -39,6 +39,7 @@ public interface ITurbineInfoDayService extends IService<TurbineInfoDay> {
     List<TurbineInfoDay> monthList(String time);
     List<TurbineInfoDay> hbmonthList(String time);//当前月份减去一个月
     List<TurbineInfoDay> topList(String time);
+    List<TurbineInfoDay> modelList(String time);
     List<TurbineInfoDay> fntopList(String time);
     List<TurbineInfoDay> ssdltopList(String time);
     List<TurbineInfoDay> gzcstopList(String time);

+ 14 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/TurbineInfoDayServiceImpl.java

@@ -210,7 +210,21 @@ public class TurbineInfoDayServiceImpl extends ServiceImpl<TurbineInfoDayMapper,
         List<TurbineInfoDay> monthList = baseMapper.selectList(monthqw);
         return monthList;
     }
+    @Override
+    public List<TurbineInfoDay> modelList(String time) {
+        QueryWrapper<TurbineInfoDay> monthqw = new QueryWrapper<>();
+        monthqw.select("turbine_id, sum(rfdl) as rfdl,sum(llfdl) as llfdl, sum(xdss) as xdss,sum(jhjxss) as jhjxss,sum(fjhjxss) as fjhjxss,sum(xnss) as xnss,sum(slss) as slss,avg(klyl) as klyl,AVG(fnlyl) as fnlyl"); // 按风机分组,汇总rfdl,平均klyl
+        monthqw.eq("to_char(record_date,'yyyy-MM')", time);
+        monthqw.in("turbine_id",
+                "NX_FGS_HA_F_WT_0018_EQ",
+                "NX_FGS_HA_F_WT_0039_EQ");
+        monthqw.groupBy("turbine_id"); // 按风机ID分组
+        monthqw.orderByDesc("sum(rfdl)"); // 按总发电量降序排列
+        monthqw.last("LIMIT 3"); // 限制返回前3条记录
 
+        List<TurbineInfoDay> monthList = baseMapper.selectList(monthqw);
+        return monthList;
+    }
     @Override
     public List<TurbineInfoDay> fntopList(String time) {
         QueryWrapper<TurbineInfoDay> monthqw = new QueryWrapper<>();