From 1cf91e355038837f30f2d727507b2229263d7de7 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期二, 27 一月 2026 17:49:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New' into dev_New

---
 src/main/java/com/ruoyi/http/service/RealTimeEnergyConsumptionService.java          |    8 +
 src/main/java/com/ruoyi/approve/pojo/ApproveProcess.java                            |    3 
 src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java |  130 ++++++++++++++++
 src/main/java/com/ruoyi/home/controller/HomeController.java                         |    4 
 src/main/java/com/ruoyi/common/utils/http/HttpUtils.java                            |   89 +++++++++++
 src/main/java/com/ruoyi/common/enums/ApproveTypeEnum.java                           |   42 +++++
 src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java                      |  152 ++++++------------
 7 files changed, 327 insertions(+), 101 deletions(-)

diff --git a/src/main/java/com/ruoyi/approve/pojo/ApproveProcess.java b/src/main/java/com/ruoyi/approve/pojo/ApproveProcess.java
index 42ca0ba..52f500e 100644
--- a/src/main/java/com/ruoyi/approve/pojo/ApproveProcess.java
+++ b/src/main/java/com/ruoyi/approve/pojo/ApproveProcess.java
@@ -131,6 +131,9 @@
      */
     private Integer approveType;
 
+    @TableField(exist = false)
+    private String approveTypeName;
+
     /**
      * 瀹℃壒澶囨敞
      */
diff --git a/src/main/java/com/ruoyi/common/enums/ApproveTypeEnum.java b/src/main/java/com/ruoyi/common/enums/ApproveTypeEnum.java
new file mode 100644
index 0000000..e79119d
--- /dev/null
+++ b/src/main/java/com/ruoyi/common/enums/ApproveTypeEnum.java
@@ -0,0 +1,42 @@
+package com.ruoyi.common.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * <br>
+ * 瀹℃壒绫诲瀷鏋氫妇
+ * </br>
+ *
+ * @author deslrey
+ * @version 1.0
+ * @since 2026/1/27 17:10
+ */
+@Getter
+@AllArgsConstructor
+public enum ApproveTypeEnum {
+
+    PUBLIC_AFFAIRS(1, "鍏嚭绠$悊"),
+    LEAVE(2, "璇峰亣绠$悊"),
+    BUSINESS_TRIP(3, "鍑哄樊绠$悊"),
+    REIMBURSEMENT(4, "鎶ラ攢绠$悊"),
+    PURCHASE(5, "閲囪喘瀹℃壒"),
+    QUOTATION(6, "鎶ヤ环瀹℃壒"),
+    DELIVERY(7, "鍙戣揣瀹℃壒");
+
+    private final Integer code;
+    private final String name;
+
+    /**
+     * 鏍规嵁 code 鑾峰彇瀵瑰簲鐨勫悕绉�
+     */
+    public static String getNameByCode(Integer code) {
+        if (code == null) return null;
+        for (ApproveTypeEnum type : ApproveTypeEnum.values()) {
+            if (type.getCode().equals(code)) {
+                return type.getName();
+            }
+        }
+        return "";
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
index d505789..0a16b62 100644
--- a/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
+++ b/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
@@ -290,4 +290,93 @@
             return true;
         }
     }
+
+    /**
+     * 鍚戞寚瀹歎RL鍙戦�丣SON鏍煎紡鐨凱OST璇锋眰锛堟帹鑽愰�氱敤鏂规硶锛岄粯璁TF-8缂栫爜锛�
+     * @param url 鍙戦�佽姹傜殑URL
+     * @param jsonParam JSON鏍煎紡鐨勮姹傚弬鏁帮紙鐩存帴浼犲叆JSON瀛楃涓诧級
+     * @return 杩滅▼璧勬簮鐨勫搷搴旂粨鏋�
+     */
+    public static String sendPostJson(String url, String jsonParam) {
+        // 閲嶈浇璋冪敤锛岄粯璁や娇鐢║TF-8缂栫爜锛孋ontent-Type鍥哄畾涓篴pplication/json
+        return sendPostJson(url, jsonParam, StandardCharsets.UTF_8.name(),null);
+    }
+
+    /**
+     * 鍚戞寚瀹歎RL鍙戦�丣SON鏍煎紡鐨凱OST璇锋眰锛堣嚜瀹氫箟缂栫爜锛岀伒娲婚�傞厤鐗规畩鍦烘櫙锛�
+     * @param url 鍙戦�佽姹傜殑URL
+     * @param jsonParam JSON鏍煎紡鐨勮姹傚弬鏁帮紙鐩存帴浼犲叆JSON瀛楃涓诧級
+     * @param headerValue 璇锋眰澶寸殑鍊�
+     * @return 杩滅▼璧勬簮鐨勫搷搴旂粨鏋�
+     */
+    public static String sendPostJson(String url, String jsonParam, String headerValue) {
+        // 閲嶈浇璋冪敤锛岄粯璁や娇鐢║TF-8缂栫爜锛孋ontent-Type鍥哄畾涓篴pplication/json
+        return sendPostJson(url, jsonParam, StandardCharsets.UTF_8.name(),headerValue);
+    }
+
+    /**
+     * 鍚戞寚瀹歎RL鍙戦�丣SON鏍煎紡鐨凱OST璇锋眰锛堣嚜瀹氫箟缂栫爜锛岀伒娲婚�傞厤鐗规畩鍦烘櫙锛�
+     * @param url 鍙戦�佽姹傜殑URL
+     * @param jsonParam JSON鏍煎紡鐨勮姹傚弬鏁帮紙鐩存帴浼犲叆JSON瀛楃涓诧級
+     * @param charset 缂栫爜绫诲瀷锛堝UTF-8銆丟BK绛夛紝寤鸿浣跨敤StandardCharsets甯搁噺锛�
+     * @return 杩滅▼璧勬簮鐨勫搷搴旂粨鏋�
+     */
+    public static String sendPostJson(String url, String jsonParam, String charset,String headerValue) {
+        PrintWriter out = null;
+        BufferedReader in = null;
+        StringBuilder result = new StringBuilder();
+        try {
+            log.info("sendPostJson - {}", url);
+            URL realUrl = new URL(url);
+            URLConnection conn = realUrl.openConnection();
+
+            // 1. 璁剧疆璇锋眰澶达細鍥哄畾Content-Type涓篴pplication/json锛岄�傞厤JSON浼犲弬瑙勮寖
+            conn.setRequestProperty("accept", "*/*");
+            conn.setRequestProperty("connection", "Keep-Alive");
+            conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
+            conn.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON_VALUE); // 鏍稿績锛欽SON涓撳睘Content-Type
+            conn.setRequestProperty("Accept-Charset", charset);
+            // 1.1 璁剧疆璇锋眰澶达細鍙�夛紝鏍规嵁瀹為檯闇�瑕佽缃�
+            if(StringUtils.isNotEmpty(headerValue)){
+                conn.setRequestProperty("Authorization", headerValue);
+            }
+            // 2. 寮�鍚緭鍏ヨ緭鍑烘祦锛圥OST璇锋眰蹇呴』锛�
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+
+            // 3. 鍐欏叆JSON鍙傛暟锛堜娇鐢ㄦ寚瀹氱紪鐮侊紝閬垮厤涓枃涔辩爜锛�
+            out = new PrintWriter(conn.getOutputStream(), true);
+            out.print(jsonParam);
+            out.flush();
+
+            // 4. 璇诲彇鍝嶅簲缁撴灉锛堜笌璇锋眰缂栫爜涓�鑷达紝淇濊瘉瑙f瀽姝g‘锛�
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), charset));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result.append(line);
+            }
+            log.info("recv - {}", result);
+        } catch (ConnectException e) {
+            log.error("璋冪敤HttpUtils.sendPostJson ConnectException, url=" + url + ",jsonParam=" + jsonParam, e);
+        } catch (SocketTimeoutException e) {
+            log.error("璋冪敤HttpUtils.sendPostJson SocketTimeoutException, url=" + url + ",jsonParam=" + jsonParam, e);
+        } catch (IOException e) {
+            log.error("璋冪敤HttpUtils.sendPostJson IOException, url=" + url + ",jsonParam=" + jsonParam, e);
+        } catch (Exception e) {
+            log.error("璋冪敤HttpUtils.sendPostJson Exception, url=" + url + ",jsonParam=" + jsonParam, e);
+        } finally {
+            // 5. 鍏抽棴娴佽祫婧愶紙閬垮厤鍐呭瓨娉勬紡锛屼笌鍘熶唬鐮乫inally閫昏緫淇濇寔涓�鑷达級
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                log.error("璋冪敤娴佸叧闂紓甯� sendPostJson, url=" + url + ",jsonParam=" + jsonParam, ex);
+            }
+        }
+        return result.toString();
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/home/controller/HomeController.java b/src/main/java/com/ruoyi/home/controller/HomeController.java
index d6fe834..9cbb122 100644
--- a/src/main/java/com/ruoyi/home/controller/HomeController.java
+++ b/src/main/java/com/ruoyi/home/controller/HomeController.java
@@ -70,14 +70,14 @@
 
     @GetMapping("/supplierPurchaseRanking")
     @ApiOperation("渚涘簲鍟嗛噰璐帓鍚�")
-    public AjaxResult supplierPurchaseRanking(@RequestParam(value = "type", defaultValue = "0") Integer type) {
+    public AjaxResult supplierPurchaseRanking(@RequestParam(value = "type", defaultValue = "1") Integer type) {
         List<SupplierPurchaseRankingDto> list = homeService.supplierPurchaseRanking(type);
         return AjaxResult.success(list);
     }
 
     @GetMapping("/customerRevenueAnalysis")
     @ApiOperation("瀹㈡埛钀ユ敹璐$尞鏁板�煎垎鏋�")
-    public AjaxResult customerRevenueAnalysis(@RequestParam("customerId") Long customerId, @RequestParam(value = "type", defaultValue = "0") Integer type) {
+    public AjaxResult customerRevenueAnalysis(@RequestParam("customerId") Long customerId, @RequestParam(value = "type", defaultValue = "1") Integer type) {
         CustomerRevenueAnalysisDto dto = homeService.customerRevenueAnalysis(customerId, type);
         return AjaxResult.success(dto);
     }
diff --git a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
index cb5d600..83948ce 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -16,6 +16,7 @@
 import com.ruoyi.basic.pojo.SupplierManage;
 import com.ruoyi.collaborativeApproval.mapper.NoticeMapper;
 import com.ruoyi.collaborativeApproval.pojo.Notice;
+import com.ruoyi.common.enums.ApproveTypeEnum;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.device.mapper.DeviceRepairMapper;
 import com.ruoyi.device.pojo.DeviceRepair;
@@ -32,9 +33,11 @@
 import com.ruoyi.production.mapper.ProductWorkOrderMapper;
 import com.ruoyi.production.pojo.ProductWorkOrder;
 import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.domain.SysUserDept;
 import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.project.system.mapper.SysUserDeptMapper;
+import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.purchase.mapper.PaymentRegistrationMapper;
 import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
 import com.ruoyi.purchase.pojo.PaymentRegistration;
@@ -44,8 +47,6 @@
 import com.ruoyi.sales.mapper.ReceiptPaymentMapper;
 import com.ruoyi.sales.mapper.SalesLedgerMapper;
 import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
-import com.ruoyi.project.system.domain.SysUser;
-import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.sales.pojo.ReceiptPayment;
 import com.ruoyi.sales.pojo.SalesLedger;
 import com.ruoyi.sales.pojo.SalesLedgerProduct;
@@ -399,6 +400,12 @@
         if (CollectionUtils.isEmpty(approveProcesses)) {
             approveProcesses = new ArrayList<>();
         }
+
+        approveProcesses.forEach(a -> {
+            if (a.getApproveType() != null) {
+                a.setApproveTypeName(ApproveTypeEnum.getNameByCode(a.getApproveType()));
+            }
+        });
 //        // 鏌ヨ鏈鐢ㄥ姵淇濊褰�
 //        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 //
@@ -416,6 +423,8 @@
 //                approveProcesses.add(approveProcess);
 //            }
 //        }
+
+
         return approveProcesses;
     }
 
@@ -695,15 +704,15 @@
         LocalDate startDate;
         LocalDate endDate;
         switch (type) {
-            case 0: // 鍛�
+            case 1: // 鍛�
                 startDate = today.with(DayOfWeek.MONDAY);
                 endDate = today.with(DayOfWeek.SUNDAY);
                 break;
-            case 1: // 鏈�
+            case 2: // 鏈�
                 startDate = today.with(TemporalAdjusters.firstDayOfMonth());
                 endDate = today.with(TemporalAdjusters.lastDayOfMonth());
                 break;
-            case 2: // 瀛e害
+            case 3: // 瀛e害
                 Month currentMonth = today.getMonth();
                 Month firstMonthOfQuarter = currentMonth.firstMonthOfQuarter();
                 Month lastMonthOfQuarter = Month.of(firstMonthOfQuarter.getValue() + 2);
@@ -745,15 +754,15 @@
         boolean groupByMonth = false;
 
         switch (type) {
-            case 0: // 鍛�
+            case 1: // 鍛�
                 start = today.with(DayOfWeek.MONDAY);
                 end = today.with(DayOfWeek.SUNDAY);
                 break;
-            case 1: // 鏈�
+            case 2: // 鏈�
                 start = today.with(TemporalAdjusters.firstDayOfMonth());
                 end = today.with(TemporalAdjusters.lastDayOfMonth());
                 break;
-            case 2: // 瀛e害
+            case 3: // 瀛e害
                 Month firstMonthOfQuarter = today.getMonth().firstMonthOfQuarter();
                 start = today.withMonth(firstMonthOfQuarter.getValue()).with(TemporalAdjusters.firstDayOfMonth());
                 end = today.withMonth(firstMonthOfQuarter.plus(2).getValue()).with(TemporalAdjusters.lastDayOfMonth());
@@ -814,109 +823,54 @@
         ProductCategoryDistributionDto dto = new ProductCategoryDistributionDto();
         List<ProductCategoryDistributionDto.MajorCategoryDto> majorItems = new ArrayList<>();
 
-        //  鎵�鏈夌殑浜у搧澶х被鍜屽皬绫�
-        List<Product> allProducts = productMapper.selectList(new LambdaQueryWrapper<Product>());
+        // 鏌ヨ鎵�鏈夌殑浜у搧绫诲埆
+        List<Product> allProducts = productMapper.selectList(new LambdaQueryWrapper<>());
         if (CollectionUtils.isEmpty(allProducts)) {
             dto.setItems(majorItems);
             return dto;
         }
 
-        List<Product> majorCategories = allProducts.stream().filter(p -> p.getParentId() == null).collect(Collectors.toList());
-        List<Product> minorCategories = allProducts.stream().filter(p -> p.getParentId() != null).collect(Collectors.toList());
+        // 鍒嗙澶х被鍜屽皬绫�
+        List<Product> majorCategories = allProducts.stream()
+                .filter(p -> p.getParentId() == null)
+                .collect(Collectors.toList());
+        List<Product> minorCategories = allProducts.stream()
+                .filter(p -> p.getParentId() != null)
+                .collect(Collectors.toList());
 
-        //  浠� sales_ledger_product 鎷垮埌姣忎釜浜у搧鐨勫瀷鍙峰簱瀛�
-        // 闇�鍖呭惈瑙勬牸鍨嬪彿浠ユ敮鎸佷笁绾у垎甯�
-        List<Map<String, Object>> quantityMaps = salesLedgerProductMapper.selectMaps(new QueryWrapper<SalesLedgerProduct>()
-                .select("product_id", "specification_model", "type", "SUM(quantity) as sum_qty")
-                .isNotNull("product_id")
-                .groupBy("product_id", "specification_model", "type"));
+        // 鎸夌埗绫籌D瀵瑰皬绫昏繘琛屽垎缁�
+        Map<Long, List<Product>> minorGroupMap = minorCategories.stream()
+                .collect(Collectors.groupingBy(Product::getParentId));
 
-        Map<Long, Map<String, Map<Integer, BigDecimal>>> modelStockGroups = new HashMap<>();
-        for (Map<String, Object> map : quantityMaps) {
-            Long productId = Long.parseLong(map.get("product_id").toString());
-            String model = map.get("specification_model") != null ? map.get("specification_model").toString() : "鏈煡鍨嬪彿";
-            Integer type = Integer.parseInt(map.get("type").toString());
-            BigDecimal sum = map.get("sum_qty") != null ? new BigDecimal(map.get("sum_qty").toString()) : BigDecimal.ZERO;
+        int totalMinorCount = minorCategories.size();
 
-            modelStockGroups.computeIfAbsent(productId, k -> new HashMap<>())
-                    .computeIfAbsent(model, k -> new HashMap<>())
-                    .put(type, sum);
-        }
-
-        //  搴撳瓨骞舵眹鎬�
-        Map<Long, List<MapDto>> productModelsMap = new HashMap<>();
-        Map<Long, BigDecimal> productTotalStockMap = new HashMap<>();
-
-        for (Long pid : modelStockGroups.keySet()) {
-            Map<String, Map<Integer, BigDecimal>> models = modelStockGroups.get(pid);
-            BigDecimal productStock = BigDecimal.ZERO;
-            List<MapDto> modelDtos = new ArrayList<>();
-
-            for (String modelName : models.keySet()) {
-                Map<Integer, BigDecimal> types = models.get(modelName);
-                BigDecimal procurement = types.getOrDefault(2, BigDecimal.ZERO);
-                BigDecimal sales = types.getOrDefault(1, BigDecimal.ZERO);
-                BigDecimal stock = procurement.subtract(sales);
-                if (stock.compareTo(BigDecimal.ZERO) < 0) stock = BigDecimal.ZERO;
-
-                MapDto modelDto = new MapDto();
-                modelDto.setName(modelName);
-                modelDto.setValue(stock.stripTrailingZeros().toPlainString());
-                modelDtos.add(modelDto);
-                productStock = productStock.add(stock);
-            }
-            productModelsMap.put(pid, modelDtos);
-            productTotalStockMap.put(pid, productStock);
-        }
-
-        BigDecimal totalInventory = productTotalStockMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add);
-
-        //  鍨嬪彿鍗犳瘮
-        if (totalInventory.compareTo(BigDecimal.ZERO) > 0) {
-            for (List<MapDto> dtos : productModelsMap.values()) {
-                for (MapDto m : dtos) {
-                    BigDecimal val = new BigDecimal(m.getValue());
-                    m.setRate(val.multiply(new BigDecimal("100"))
-                            .divide(totalInventory, 2, RoundingMode.HALF_UP).toString());
-                }
-            }
-        }
-
-        //  鍒嗗眰鏁版嵁
         for (Product major : majorCategories) {
             ProductCategoryDistributionDto.MajorCategoryDto majorDto = new ProductCategoryDistributionDto.MajorCategoryDto();
             majorDto.setName(major.getProductName());
 
-            List<ProductCategoryDistributionDto.MinorCategoryDto> minorDtos = new ArrayList<>();
-            BigDecimal majorStock = BigDecimal.ZERO;
+            List<Product> children = minorGroupMap.getOrDefault(major.getId(), new ArrayList<>());
+            int childrenSize = children.size();
+            // 璁剧疆灏忕被鐨勬�绘暟
+            majorDto.setValue(String.valueOf(childrenSize));
 
-            for (Product minor : minorCategories) {
-                if (major.getId().equals(minor.getParentId())) {
-                    BigDecimal stock = productTotalStockMap.getOrDefault(minor.getId(), BigDecimal.ZERO);
-                    ProductCategoryDistributionDto.MinorCategoryDto minorDto = new ProductCategoryDistributionDto.MinorCategoryDto();
-                    minorDto.setName(minor.getProductName());
-                    minorDto.setValue(stock.stripTrailingZeros().toPlainString());
-
-                    if (totalInventory.compareTo(BigDecimal.ZERO) > 0) {
-                        minorDto.setRate(stock.multiply(new BigDecimal("100"))
-                                .divide(totalInventory, 2, RoundingMode.HALF_UP).toString());
-                    } else {
-                        minorDto.setRate("0.00");
-                    }
-
-                    minorDto.setChildren(productModelsMap.getOrDefault(minor.getId(), new ArrayList<>()));
-                    minorDtos.add(minorDto);
-                    majorStock = majorStock.add(stock);
-                }
-            }
-
-            majorDto.setValue(majorStock.stripTrailingZeros().toPlainString());
-
-            if (totalInventory.compareTo(BigDecimal.ZERO) > 0) {
-                majorDto.setRate(majorStock.multiply(new BigDecimal("100"))
-                        .divide(totalInventory, 2, RoundingMode.HALF_UP).toString());
+            // 璁$畻鍗犳瘮
+            if (totalMinorCount > 0) {
+                BigDecimal rate = BigDecimal.valueOf(childrenSize)
+                        .multiply(new BigDecimal("100"))
+                        .divide(BigDecimal.valueOf(totalMinorCount), 2, RoundingMode.HALF_UP);
+                majorDto.setRate(rate.toString());
             } else {
                 majorDto.setRate("0.00");
+            }
+
+            List<ProductCategoryDistributionDto.MinorCategoryDto> minorDtos = new ArrayList<>();
+            for (Product minor : children) {
+                ProductCategoryDistributionDto.MinorCategoryDto minorDto = new ProductCategoryDistributionDto.MinorCategoryDto();
+                minorDto.setName(minor.getProductName());
+                minorDto.setValue("0");
+                minorDto.setRate("0.00");
+                minorDto.setChildren(new ArrayList<>());
+                minorDtos.add(minorDto);
             }
             majorDto.setChildren(minorDtos);
             majorItems.add(majorDto);
@@ -932,15 +886,15 @@
         LocalDate startDate = null;
         LocalDate endDate = null;
         switch (type) {
-            case 0:
+            case 1:
                 startDate = today.with(DayOfWeek.MONDAY);
                 endDate = today.with(DayOfWeek.SUNDAY);
                 break;
-            case 1:
+            case 2:
                 startDate = today.with(TemporalAdjusters.firstDayOfMonth());
                 endDate = today.with(TemporalAdjusters.lastDayOfMonth());
                 break;
-            case 2:
+            case 3:
                 Month currentMonth = today.getMonth();
                 Month firstMonthOfQuarter = currentMonth.firstMonthOfQuarter();
                 Month lastMonthOfQuarter = Month.of(firstMonthOfQuarter.getValue() + 2);
diff --git a/src/main/java/com/ruoyi/http/service/RealTimeEnergyConsumptionService.java b/src/main/java/com/ruoyi/http/service/RealTimeEnergyConsumptionService.java
new file mode 100644
index 0000000..5576f17
--- /dev/null
+++ b/src/main/java/com/ruoyi/http/service/RealTimeEnergyConsumptionService.java
@@ -0,0 +1,8 @@
+package com.ruoyi.http.service;
+
+/**
+ * @author :yys
+ * @date : 2026/1/27 16:02
+ */
+public interface RealTimeEnergyConsumptionService {
+}
diff --git a/src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java b/src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java
new file mode 100644
index 0000000..6b10ba2
--- /dev/null
+++ b/src/main/java/com/ruoyi/http/service/impl/RealTimeEnergyConsumptionServiceImpl.java
@@ -0,0 +1,130 @@
+package com.ruoyi.http.service.impl;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.common.utils.http.HttpUtils;
+import com.ruoyi.http.service.RealTimeEnergyConsumptionService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author :yys
+ * @date : 2026/1/27 16:02
+ */
+@Service
+@Slf4j
+public class RealTimeEnergyConsumptionServiceImpl implements RealTimeEnergyConsumptionService {
+
+    private static final String URL = "https://new.e-elitech.cn/api/data-api";
+
+    private static final String TOKEN_URL = "/elitechAccess/getToken";
+
+    private static final String REAL_TIME_URL = "/elitechAccess/v2/getRealTimeData"; //鑾峰彇璁惧瀹炴椂鏁版嵁
+
+    private static final String KET_ID = "75804708";
+
+    private static final String KEY_SECRET = "xTUGToozKpYgUPqTsZzB";
+
+    private static final String USER_NAME = "鐢ㄦ埛30773662";
+
+    private static final String PASS_WORD = "y17775163675";
+
+    private static final String DEVICE_GUID = "90444196515214284663";
+
+
+    /**
+     * 鏍规嵁paramCode鎻愬彇鎺㈠ご鍙傛暟
+     * @param paramList 璁惧鍙傛暟鏁扮粍
+     * @param targetCode 鐩爣鎺㈠ご缂栫爜
+     * @return 鎺㈠ご鍙傛暟瀵硅薄锛堝寘鍚玭ame/value/unit锛�
+     */
+    private static JSONObject getProbeParam(JSONArray paramList, String targetCode) {
+        for (int i = 0; i < paramList.size(); i++) {
+            JSONObject paramObj = paramList.getJSONObject(i);
+            if (targetCode.equals(paramObj.getString("paramCode"))) {
+                return paramObj;
+            }
+        }
+        return new JSONObject(); // 鏈尮閰嶅埌杩斿洖绌哄璞★紝閬垮厤绌烘寚閽�
+    }
+
+    /**
+     * 瀹炴椂鑾峰彇娓╂箍搴︼紝浜屾哀鍖栫⒊鏁版嵁
+     */
+    public static void main(String[] args) {
+        String realTimeData = getRealTimeData(getToken());
+        Map<String, Object> map = JSON.parseObject(realTimeData, Map.class);
+        if(map.get("code").equals(0)){
+            // 1. 瑙f瀽澶栧眰data涓篔SON鏁扮粍锛堟帴鍙h繑鍥炵殑璁惧鍒楄〃锛�
+            JSONArray deviceList = JSON.parseArray(map.get("data").toString());
+            // 2. 閬嶅巻璁惧鍒楄〃锛堟澶勪粎鍙栫涓�涓澶囷紝鑻ユ湁澶氫釜璁惧鍙惊鐜鐞嗭級
+            if (!deviceList.isEmpty()) {
+                JSONObject deviceObj = deviceList.getJSONObject(0);
+                // 3. 瑙f瀽璁惧鍐呯殑鍙傛暟鏁扮粍锛堟墍鏈塸aramCode瀵瑰簲鐨勫弬鏁帮級
+                JSONArray paramList = deviceObj.getJSONArray("data");
+
+                // 4. 瀹氫箟鐩爣鎺㈠ご鐨刾aramCode锛屾寜闇�鎵╁睍
+                String[] targetCodes = {"0100", "0110", "0120", "0130"};
+                for (String code : targetCodes) {
+                    // 5. 閬嶅巻鍙傛暟鏁扮粍锛屽尮閰嶇洰鏍噋aramCode
+                    for (int i = 0; i < paramList.size(); i++) {
+                        JSONObject paramObj = paramList.getJSONObject(i);
+                        String currentCode = paramObj.getString("paramCode");
+                        if (code.equals(currentCode)) {
+                            // 6. 鎻愬彇鏍稿績瀛楁锛堝�笺�佸崟浣嶃�佹帰澶村悕绉帮級
+                            String paramName = paramObj.getString("paramName"); // 鎺㈠ご1/鎺㈠ご2...
+                            String value = paramObj.getString("value");       // 鏁板�硷紙345.80/24.90...锛�
+                            String unitCode = paramObj.getString("unitCode"); // 鍗曚綅锛圠ux/鈩�/%RH/ppm锛�
+
+                            // 7. 涓氬姟澶勭悊锛氭墦鍗�/璧嬪��/瀛樺偍绛夛紙鎸夐渶淇敼锛�
+                            System.out.println(paramName + "锛�" + value + " " + unitCode);
+                            // 鍖归厤鍒板悗鐩存帴璺冲嚭鍐呭眰寰幆锛屾彁鍗囨晥鐜�
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println();
+    }
+
+    public static String getToken(){
+        Map<String, String> param = new HashMap<>();
+        param.put("keyId", KET_ID);
+        param.put("keySecret", KEY_SECRET);
+        param.put("userName", USER_NAME);
+        param.put("password", PASS_WORD);
+        log.info("璇锋眰鍙傛暟锛歿}", JSON.toJSONString( param));
+        String result = HttpUtils.sendPostJson(URL + TOKEN_URL, JSON.toJSONString(param));
+        log.info("杩斿洖缁撴灉锛歿}", result);
+        Map<String, Object> map = JSON.parseObject(result, Map.class);
+        if (map.get("code").equals(0)) {
+            Object token = map.get("data");
+            log.info("token:{}", token);
+            return token.toString();
+        }
+        return result;
+    }
+
+    public static String getRealTimeData(String  token){
+        Map<String, Object> param = new HashMap<>();
+        param.put("keyId", KET_ID);
+        param.put("keySecret", KEY_SECRET);
+        param.put("deviceGuids", Collections.singletonList(DEVICE_GUID));
+        log.info("璇锋眰鍙傛暟锛歿}", JSON.toJSONString( param));
+        String result = HttpUtils.sendPostJson(URL + REAL_TIME_URL, JSON.toJSONString(param),token);
+        log.info("杩斿洖缁撴灉锛歿}", result);
+        return result;
+    }
+
+
+
+
+
+}

--
Gitblit v1.9.3