From 793989f6eb4e39f4b1f47931fdeefb4a12385424 Mon Sep 17 00:00:00 2001
From: baoshiwei <baoshiwei@shlanbao.cn>
Date: 星期三, 30 七月 2025 16:46:32 +0800
Subject: [PATCH] refactor(eims): 优化设备数据定时任务和报告服务

---
 eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/ReportServiceImpl.java |   73 +++++++++++++++++++++++++++++++++++-
 1 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/ReportServiceImpl.java b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/ReportServiceImpl.java
index 2a5c4a6..60f61ec 100644
--- a/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/ReportServiceImpl.java
+++ b/eims/ruoyi-modules/lb-eims/src/main/java/org/dromara/eims/service/impl/ReportServiceImpl.java
@@ -1,9 +1,11 @@
 package org.dromara.eims.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.utils.DateUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -281,11 +283,11 @@
                         if (allZero) {
                             return MAINT_0; // 寰呬繚鍏�
                         }
-                        boolean allGtOne = orders.stream().allMatch(o -> Integer.parseInt(o.getStatus()) > 1);
+                        boolean allGtOne = orders.stream().allMatch(o -> Integer.parseInt(o.getStatus()) == 1);
                         if (allGtOne) {
                             return MAINT_2; // 寰呴獙璇�
                         }
-                        boolean allGtTwo = orders.stream().allMatch(o -> Integer.parseInt(o.getStatus()) > 2);
+                        boolean allGtTwo = orders.stream().allMatch(o -> Integer.parseInt(o.getStatus()) == 2);
                         if (allGtTwo) {
                             return MAINT_3; // 宸插畬鎴�
                         }
@@ -318,4 +320,71 @@
 
         return item;
     }
+
+    @Override
+    public TableDataInfo<Map<String, Object>> queryEquEfficiencyList(Map<String, Object> queryParams, PageQuery pageQuery) {
+        Integer selectYear = getYearFromParams(queryParams);
+        String start = Year.of(selectYear).atDay(1).toString(); // yyyy-MM-dd
+        String end = Year.of(selectYear).atDay(Year.of(selectYear).length()).toString();
+
+        List<Map<String, Object>> statList = inspectStMapper.statEquEfficiency(start, end);
+
+        // 缁勮缁熻缁撴灉
+        Map<Integer, Integer> runTimes = new HashMap<>();
+        Map<Integer, Integer> faultTimes = new HashMap<>();
+        Map<Integer, Integer> totalTimes = new HashMap<>();
+        int runTotal = 0, faultTotal = 0, totalTotal = 0;
+
+        for (Map<String, Object> row : statList) {
+            int month = Integer.parseInt(row.get("month").toString());
+            int run = row.get("runTimes") == null ? 0 : Integer.parseInt(row.get("runTimes").toString());
+            int fault = row.get("faultTimes") == null ? 0 : Integer.parseInt(row.get("faultTimes").toString());
+            int total = run + fault;
+            runTimes.put(month, run);
+            faultTimes.put(month, fault);
+            totalTimes.put(month, total);
+            runTotal += run;
+            faultTotal += fault;
+            totalTotal += total;
+        }
+
+        // 缁勮杩斿洖鏁版嵁锛堝悓鍓嶏級
+        String targetValue = "98.00%";
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        Map<String, Object> row1 = new LinkedHashMap<>(); // 姝e父杩愯浆鏃堕棿
+        Map<String, Object> row2 = new LinkedHashMap<>(); // 鎬昏繍杞椂闂�
+        Map<String, Object> row3 = new LinkedHashMap<>(); // 鏁呴殰鏃堕棿
+        Map<String, Object> row4 = new LinkedHashMap<>(); // 鐩爣鍊�
+        Map<String, Object> row5 = new LinkedHashMap<>(); // 姝e父杩愯浆鐜囷紙绋煎姩鐜囷級
+
+        row1.put("item", "姝e父杩愯浆鏃堕棿");
+        row2.put("item", "鎬昏繍杞椂闂�");
+        row3.put("item", "鏁呴殰鏃堕棿");
+        row4.put("item", "鐩爣鍊�");
+        row5.put("item", "姝e父杩愯浆鐜囷紙绋煎姩鐜囷級");
+
+        for (int m = 1; m <= 12; m++) {
+            row1.put(m + "鏈�", runTimes.getOrDefault(m, 0));
+            row2.put(m + "鏈�", totalTimes.getOrDefault(m, 0));
+            row3.put(m + "鏈�", faultTimes.getOrDefault(m, 0));
+            row4.put(m + "鏈�", targetValue);
+            int run = runTimes.getOrDefault(m, 0);
+            int total = totalTimes.getOrDefault(m, 0);
+            String eff = total > 0 ? String.format("%.2f%%", run * 100.0 / total) : "-";
+            row5.put(m + "鏈�", eff);
+        }
+        row1.put("total", runTotal);
+        row2.put("total", totalTotal);
+        row3.put("total", faultTotal);
+        row4.put("total", targetValue);
+        row5.put("total", totalTotal > 0 ? String.format("%.2f%%", runTotal * 100.0 / totalTotal) : "-");
+
+        resultList.add(row1);
+        resultList.add(row2);
+        resultList.add(row3);
+        resultList.add(row4);
+        resultList.add(row5);
+
+        return TableDataInfo.build(resultList);
+    }
 }

--
Gitblit v1.9.3