From 5e644156839fbb018fe63972ee74be550540a06a Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期一, 08 十二月 2025 13:24:31 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/utils/Utils.java |   49 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index b474b9e..f84672c 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -7,6 +7,7 @@
 import com.core.common.Arith;
 import com.core.common.Cools;
 import com.core.common.SpringUtils;
+import com.core.exception.CoolException;
 import com.zy.asrs.entity.BasCrnp;
 import com.zy.asrs.entity.WrkMast;
 import com.zy.asrs.service.BasCrnpService;
@@ -32,6 +33,8 @@
 
     private static final String LOC_NO_FLAG = "-";
     private static final DecimalFormat fmt = new DecimalFormat("##0.00");
+    private static Integer defaultDeviceLogCollectTime = 200;
+    private static Long lastUpdateDeviceLogCollectTime = -1L;
 
     public static float scale(Float f){
         if (f == null || f == 0f || Float.isNaN(f)) {
@@ -105,29 +108,37 @@
 
     //鑾峰彇璁惧鏃ュ織閲囬泦鏃堕棿
     public static int getDeviceLogCollectTime() {
-        int defaultTime = 200;
-        try {
-            RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
-            if (redisUtil == null) {
-                return defaultTime;
-            }
+        if (defaultDeviceLogCollectTime == null || System.currentTimeMillis() - lastUpdateDeviceLogCollectTime > 60 * 1000) {
+            int defaultTime = 200;
+            lastUpdateDeviceLogCollectTime = System.currentTimeMillis();
+            try {
+                RedisUtil redisUtil = null;
+                try {
+                    redisUtil = SpringUtils.getBean(RedisUtil.class);
+                } catch (CoolException coolException) {
 
-            Object object = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
-            if (object == null) {
-                return defaultTime;
-            }
+                }
+                if (redisUtil == null) {
+                    return defaultTime;
+                }
 
-            HashMap<String, String> systemConfigMap = (HashMap<String, String>) object;
-            String deviceLogCollectTime = systemConfigMap.get("deviceLogCollectTime");
-            if(deviceLogCollectTime == null){
-                return defaultTime;
-            }
+                Object object = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+                if (object == null) {
+                    return defaultTime;
+                }
 
-            return Integer.parseInt(deviceLogCollectTime);
-        }catch (Exception e){
-            e.printStackTrace();
+                HashMap<String, String> systemConfigMap = (HashMap<String, String>) object;
+                String deviceLogCollectTime = systemConfigMap.get("deviceLogCollectTime");
+                if(deviceLogCollectTime == null){
+                    return defaultTime;
+                }
+
+                return Integer.parseInt(deviceLogCollectTime);
+            }catch (Exception e){
+                e.printStackTrace();
+            }
         }
-        return defaultTime;
+        return defaultDeviceLogCollectTime;
     }
 
     //鑾峰彇鍏ュ簱浠诲姟鍙敤鎺�

--
Gitblit v1.9.1