Browse Source

报告代码

王波 2 weeks ago
parent
commit
2f4b62492f

+ 12 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/WindDirection/WindDirectionController.java

@@ -24,4 +24,16 @@ public class WindDirectionController {
         Object o = windDirectionService.fxRoses(wtid, kssj, jssj);
         return JsonResult.successData(ResultCode.SUCCESS, o);
     }
+
+    /**
+     * 对风偏差分析
+
+     * @return
+     */
+    @GetMapping("/deviation/ratio")
+    public JSONObject fsDeviationRatio(String wtid,String kssj,String jssj) throws ParseException {
+
+        Object o = windDirectionService.windDeviationRatio(wtid, kssj, jssj);
+        return JsonResult.successData(ResultCode.SUCCESS, o);
+    }
 }

+ 17 - 4
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/EarlyWarning/ReportService.java

@@ -165,11 +165,24 @@ public class ReportService {
                 .sum(); // 去年同期计划检修损失电量
 
         double currentPerformanceLossPower = turbineList.stream()
-                .mapToDouble(t -> t.getXnss() == null ? 0 : Math.round(t.getXnss().doubleValue() * 100.0) / 100.0)
+                .mapToDouble(t -> t.getXnss() == null ? 0 : new BigDecimal(t.getXnss().doubleValue())
+                        .setScale(2, BigDecimal.ROUND_HALF_UP) // 保留两位小数并四舍五入
+                        .doubleValue())
                 .sum(); // 本月性能未达标损失电量
+        currentPerformanceLossPower = new BigDecimal(currentPerformanceLossPower)
+                .setScale(2, BigDecimal.ROUND_HALF_UP) // 确保最后的结果保留两位小数
+                .doubleValue();
+
+
         double lastYearPerformanceLossPower = tqturbineList.stream()
-                .mapToDouble(t -> t.getXnss() == null ? 0 : Math.round(t.getXnss().doubleValue() * 100.0) / 100.0)
+                .mapToDouble(t -> t.getXnss() == null ? 0 : new BigDecimal(t.getXnss().doubleValue())
+                        .setScale(2, BigDecimal.ROUND_HALF_UP) // 保留两位小数并四舍五入
+                        .doubleValue())
                 .sum(); // 去年同期性能未达标损失电量
+        lastYearPerformanceLossPower = new BigDecimal(lastYearPerformanceLossPower)
+                .setScale(2, BigDecimal.ROUND_HALF_UP)
+                .doubleValue();
+
 
         double currentFaultDowntime = turbineList.stream()
                 .mapToDouble(t -> t.getGzMin() == null ? 0 : Math.round(t.getGzMin().doubleValue() * 100.0) / 100.0)
@@ -236,9 +249,9 @@ public class ReportService {
                 "设备可利用率"+ currentEquipmentUtilization +"%、同比"+ lastYearEquipmentUtilization +"%,等效可用系数"+ currentEfficiencyCoefficient +"%、同比"+ lastYearEfficiencyCoefficient +"%," +
                 "静风频率达到"+ currentCalmWindFrequency +"%、同比"+ lastYearCalmWindFrequency +"%。";
         String wz2 = collect.get(0).getName() + time +"月平均风速"+ currentWindSpeed +"m/s、同比"+ lastYearWindSpeed +"m/s,小风平均切入风速"+ currentSmallWindSpeed +"m/s、同比"+ lastYearSmallWindSpeed +"m/," +
-                "有效风时数"+ currentRunningWindHours +"小时、同比:"+ lastYearRunningWindHours +"小时,实际发电电"+ currentPower +"万kmh、同比"+ lastYearPower +"万kwh,同比增长率"+ fdlzzl +"%," +
+                "有效风时数"+ currentRunningWindHours +"小时、同比"+ lastYearRunningWindHours +"小时,实际发电电"+ currentPower +"万kmh、同比"+ lastYearPower +"万kwh,同比增长率"+ fdlzzl +"%," +
                 "各项损失电量累计"+ ssdllj +"万kmh、同比"+ tqssdllj +"万kmh,同比增长率"+ ssdlzzl +"%," +
-                "理论发电量"+ currentTheoryPower +"万kwh,实际发电量与理论发电相差"+ dlxc +"万kwh。";
+                "理论发电量"+ currentTheoryPower +"万kwh,实际发电量与理论发电相差"+ dlxc +"万kwh。";
         map.put("wz1",wz1);
         map.put("wz2",wz2);
         turbineList.sort(Comparator.comparing(TurbineInfoDay::getRecordDate));

+ 56 - 4
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/WindDirection/WindDirectionService.java

@@ -100,10 +100,6 @@ public class WindDirectionService {
             map.put("speeedtime", WindALG.speedtimeNewRoses(lslist));//风速
             map.put("roses", WindALG.fxysNewRoses(lslist));//风速、风向
             map.put("count", WindALG.fxNewCountRoses(lslist));//风速、风向
-            int[] count = WindALG.windDeviationRatio(lslist);//风向、对风误差
-            List<Point> scatter = WindALG.windDeviationScatter(lslist);//风速、风向、对风误差
-            map.put("countpcl", count);
-            map.put("scatter", scatter);
             map.put("radar", WindALG.fxRadarRoses(lslist));//对风误差
             map.put("frequency", WindALG.windDeviationPoint(lslist)); //风速、风向、明细状态、功率、偏航角度
             result.add(map);
@@ -111,7 +107,63 @@ public class WindDirectionService {
 
         return result;
     }
+    /**
+     * 对风偏差率
+
+     */
+    public List<Object> windDeviationRatio(String wtid, String kssj, String jssj) throws ParseException {
+
+        Date[] sjcl = sjcl(kssj, jssj);
+
+        // 获取 startDate 和 endDate
+        Date startDate = sjcl[0];
+        Date endDate = sjcl[1];
+
+        List<Object> list = new ArrayList<>();
+        // 初始化设备点
+        Map<EquipmentPointType, ProBasicEquipmentPoint> points = Arrays.stream(EquipmentPointType.values())
+                .collect(Collectors.toMap(type -> type, type -> getEquipmentPoint(wtid, type)));
+
+        // 获取历史数据
+        Map<EquipmentPointType, List<TsDoubleData>> historyData = points.entrySet().stream()
+                .collect(Collectors.toMap(Map.Entry::getKey,
+                        entry -> getSortedHistory(entry.getValue(), startDate.getTime(), endDate.getTime(), 900)));
+
+        // 创建时间戳到数据的映射表
+        Map<Long, TsDoubleData> pjfsMap = historyData.get(EquipmentPointType.PJFS).stream()
+                .collect(Collectors.toMap(TsDoubleData::getTs, Function.identity(), (a, b) -> a));
+        Map<Long, TsDoubleData> dfwcMap = historyData.get(EquipmentPointType.DFWC).stream()
+                .collect(Collectors.toMap(TsDoubleData::getTs, Function.identity(), (a, b) -> a));
 
+        // 构造结果数据
+        List<PowerPointData> lslist = new ArrayList<>();
+        for (TsDoubleData fxData : historyData.get(EquipmentPointType.PJFX)) {
+            long ts = fxData.getTs();
+            TsDoubleData fsData = pjfsMap.get(ts);
+            TsDoubleData dfwcData = dfwcMap.get(ts);
+
+            PowerPointData data = new PowerPointData();
+            data.setTime(formatTimestamp(ts));
+            data.setFx(fxData.getDoubleValue());
+            data.setSpeed(fsData != null ? fsData.getDoubleValue() : 0);
+            data.setDfwc(dfwcData != null ? dfwcData.getDoubleValue() : 0);
+            lslist.add(data);
+        }
+
+        List<ProBasicEquipment> listObj = CacheContext.wtls.stream().filter(wt -> wtid.equals(wt.getId())).collect(Collectors.toList());
+
+            listObj.forEach(obj -> {
+                int[] count = WindALG.windDeviationRatio(lslist);//风向、对风误差
+                List<Point> scatter = WindALG.windDeviationScatter(lslist);//风速、风向、对风误差
+                Map<String, Object> map = new HashMap<>();
+                map.put("wtId", obj.getAname());
+                map.put("count", count);
+                map.put("scatter", scatter);
+                list.add(map);
+            });
+
+        return list;
+    }
     private Date[] sjcl (String kssj,String jssj) throws ParseException {
 
         // 时间格式,格式是 "yyyy-MM-dd HH:mm"