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/core/thread/impl/ZyRgvThread.java | 7 +++
src/main/java/com/zy/core/network/ZyRgvConnectDriver.java | 3 +
src/main/java/com/zy/core/network/ZyCrnConnectDriver.java | 3 +
src/main/java/com/zy/asrs/utils/Utils.java | 49 +++++++++++++++---------
src/main/java/com/zy/core/network/ZyStationConnectDriver.java | 3 +
src/main/java/com/zy/core/thread/impl/ZyStationThread.java | 7 +++
src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java | 7 +++
src/main/java/com/zy/core/MainProcess.java | 7 +++
src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java | 12 +++---
9 files changed, 69 insertions(+), 29 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;
}
//鑾峰彇鍏ュ簱浠诲姟鍙敤鎺�
diff --git a/src/main/java/com/zy/core/MainProcess.java b/src/main/java/com/zy/core/MainProcess.java
index cd49feb..0d30d2b 100644
--- a/src/main/java/com/zy/core/MainProcess.java
+++ b/src/main/java/com/zy/core/MainProcess.java
@@ -1,6 +1,7 @@
package com.zy.core;
import com.core.common.SpringUtils;
+import com.core.exception.CoolException;
import com.zy.core.plugin.MainProcessPluginApi;
import com.zy.core.properties.SystemProperties;
import lombok.extern.slf4j.Slf4j;
@@ -31,7 +32,11 @@
if (mainProcessPluginApi == null) {
String className = mainProcessPlugin.contains(".") ? mainProcessPlugin : "com.zy.core.plugin." + mainProcessPlugin;
Class<? extends MainProcessPluginApi> clazz = Class.forName(className).asSubclass(MainProcessPluginApi.class);
- mainProcessPluginApi = SpringUtils.getBean(clazz);
+ try {
+ mainProcessPluginApi = SpringUtils.getBean(clazz);
+ } catch (CoolException coolException) {
+ continue;
+ }
}
// 绯荤粺杩愯鐘舵�佸垽鏂�
diff --git a/src/main/java/com/zy/core/network/ZyCrnConnectDriver.java b/src/main/java/com/zy/core/network/ZyCrnConnectDriver.java
index f006143..18b90e1 100644
--- a/src/main/java/com/zy/core/network/ZyCrnConnectDriver.java
+++ b/src/main/java/com/zy/core/network/ZyCrnConnectDriver.java
@@ -62,6 +62,9 @@
}
public ZyCrnStatusEntity getStatus() {
+ if (zyCrnConnectApi == null) {
+ return null;
+ }
return zyCrnConnectApi.getStatus();
}
diff --git a/src/main/java/com/zy/core/network/ZyRgvConnectDriver.java b/src/main/java/com/zy/core/network/ZyRgvConnectDriver.java
index 0bcfab7..23852ab 100644
--- a/src/main/java/com/zy/core/network/ZyRgvConnectDriver.java
+++ b/src/main/java/com/zy/core/network/ZyRgvConnectDriver.java
@@ -55,6 +55,9 @@
}
public ZyRgvStatusEntity getStatus() {
+ if (zyRgvConnectApi == null) {
+ return null;
+ }
return zyRgvConnectApi.getStatus();
}
diff --git a/src/main/java/com/zy/core/network/ZyStationConnectDriver.java b/src/main/java/com/zy/core/network/ZyStationConnectDriver.java
index b8d3520..d2beb2e 100644
--- a/src/main/java/com/zy/core/network/ZyStationConnectDriver.java
+++ b/src/main/java/com/zy/core/network/ZyStationConnectDriver.java
@@ -62,6 +62,9 @@
}
public List<ZyStationStatusEntity> getStatus() {
+ if (zyStationConnectApi == null) {
+ return null;
+ }
return zyStationConnectApi.getStatus();
}
diff --git a/src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java b/src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java
index 059ebf8..7e4bd32 100644
--- a/src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java
+++ b/src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java
@@ -37,10 +37,10 @@
if(connect.IsSuccess){
connected = true;
OutputQueue.CRN.offer(MessageFormat.format( "銆恵0}銆戝爢鍨涙満plc杩炴帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
- News.info("SiemensCrn"+" - 1"+" - 鍫嗗灈鏈簆lc杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
+ News.info("SiemensCrn 鍫嗗灈鏈簆lc杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
} else {
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戝爢鍨涙満plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
- News.error("SiemensCrn"+" - 2"+" - 鍫嗗灈鏈簆lc杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
+ News.error("SiemensCrn 鍫嗗灈鏈簆lc杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
}
// siemensNet.ConnectClose();
return connected;
@@ -84,12 +84,12 @@
return crnStatus;
} else {
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戣鍙栧爢鍨涙満plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
- News.error("SiemensCrn"+" - 4"+" - 璇诲彇鍫嗗灈鏈簆lc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
+ News.error("SiemensCrn 璇诲彇鍫嗗灈鏈簆lc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
}
} catch (Exception e) {
e.printStackTrace();
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戣鍙栧爢鍨涙満plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
- News.error("SiemensCrn"+" - 5"+" - 璇诲彇鍫嗗灈鏈簆lc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
+ News.error("SiemensCrn 璇诲彇鍨涙満plc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
}
return null;
}
@@ -190,12 +190,12 @@
}
if (result != null && result.IsSuccess) {
- News.info("SiemensCrn" + " - 7" + " - 鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command));
+ News.info("SiemensCrn鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command));
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), command.getCrnNo(), JSON.toJSON(command)));
response.setResult(true);
response.setMessage("鍛戒护涓嬪彂鎴愬姛");
} else {
- News.error("SiemensCrn" + " - 8" + " - 鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触 ===>> [id:{}]", command.getCrnNo());
+ News.error("SiemensCrn鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触 ===>> [id:{}]", command.getCrnNo());
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戝啓鍏ュ爢鍨涙満plc鏁版嵁澶辫触 ===>> [id:{1}]", DateUtils.convert(new Date()), command.getCrnNo()));
response.setResult(false);
response.setMessage("鍛戒护涓嬪彂澶辫触");
diff --git a/src/main/java/com/zy/core/thread/impl/ZyRgvThread.java b/src/main/java/com/zy/core/thread/impl/ZyRgvThread.java
index 461f6e8..f58b262 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyRgvThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyRgvThread.java
@@ -131,7 +131,12 @@
rgvProtocol.setDeviceDataLog(System.currentTimeMillis());
}
- BasRgvService basRgvService = SpringUtils.getBean(BasRgvService.class);
+ BasRgvService basRgvService = null;
+ try {
+ basRgvService = SpringUtils.getBean(BasRgvService.class);
+ } catch (Exception e) {
+
+ }
if (basRgvService != null) {
BasRgv basRgv = basRgvService.selectOne(new EntityWrapper<BasRgv>().eq("rgv_no", deviceConfig.getDeviceNo()));
if(basRgv == null) {
diff --git a/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java b/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
index 0bb8c61..3e871b1 100644
--- a/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
@@ -188,7 +188,12 @@
crnProtocol.setDeviceDataLog(System.currentTimeMillis());
}
- BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class);
+ BasCrnpService basCrnpService = null;
+ try {
+ basCrnpService = SpringUtils.getBean(BasCrnpService.class);
+ }catch (Exception e){
+
+ }
if (basCrnpService != null) {
BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", deviceConfig.getDeviceNo()));
if(basCrnp == null) {
diff --git a/src/main/java/com/zy/core/thread/impl/ZyStationThread.java b/src/main/java/com/zy/core/thread/impl/ZyStationThread.java
index 9552cc0..2624e46 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyStationThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyStationThread.java
@@ -97,7 +97,12 @@
}
if(statusList.isEmpty()) {
- BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
+ BasDevpService basDevpService = null;
+ try {
+ basDevpService = SpringUtils.getBean(BasDevpService.class);
+ } catch (Exception e) {
+
+ }
if (basDevpService == null) {
return;
}
--
Gitblit v1.9.1