From c9d334e61ff33aa2f90b71e34d5a7a0340765bfe Mon Sep 17 00:00:00 2001 From: 野心家 <1051256694@qq.com> Date: 星期二, 27 五月 2025 18:44:37 +0800 Subject: [PATCH] #ZH --- src/main/java/com/zy/core/cache/RgvErrCache.java | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 102 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/core/cache/RgvErrCache.java b/src/main/java/com/zy/core/cache/RgvErrCache.java new file mode 100644 index 0000000..c8ce8f9 --- /dev/null +++ b/src/main/java/com/zy/core/cache/RgvErrCache.java @@ -0,0 +1,102 @@ +package com.zy.core.cache; + +import com.core.common.Cools; +import com.zy.core.model.protocol.RgvErrProtocol; +import com.zy.core.model.protocol.RgvRunProtocol; + +import java.util.concurrent.ConcurrentHashMap; + +/** + * Created by IX on 2025/02/21 + */ +public class RgvErrCache { + // 鏈湴缂撳瓨锛岄敭涓� currentPosition锛屽�间负 DeviceStatus + private static final ConcurrentHashMap<Integer, RgvErrProtocol> cache = new ConcurrentHashMap<>(); + + /** + * 鏇存柊璁惧鐘舵�� + */ + public static void updateRgvStatus(RgvErrProtocol status) { + try { + cache.put(status.getRgvNo(), status); + } finally { + } + } + + + /** + * 鏇存柊璁惧鐘舵�� + */ + public static void updateRgvErr(Integer rgvNo,String error) { + try { + RgvErrProtocol rgvErrProtocol = cache.get(rgvNo); + if (rgvErrProtocol == null){ + rgvErrProtocol = new RgvErrProtocol(); + rgvErrProtocol.setRgvNo(rgvNo); + } + if (!rgvErrProtocol.getError().equals(error)){ + rgvErrProtocol.setError(error); + cache.put(rgvErrProtocol.getRgvNo(), rgvErrProtocol); + } + } finally { + } + } + + + /** + * 鏇存柊璁惧鐘舵�� + */ + public static void updateRgvErr(Integer rgvNo) { + try { + RgvErrProtocol rgvErrProtocol = cache.get(rgvNo); + if (rgvErrProtocol == null){ + rgvErrProtocol = new RgvErrProtocol(); + rgvErrProtocol.setRgvNo(rgvNo); + } + if (!rgvErrProtocol.getError().equals("-")){ + rgvErrProtocol.setError("-"); + cache.put(rgvErrProtocol.getRgvNo(), rgvErrProtocol); + } + } finally { + } + } + + + + + /** + * 鏇存柊璁惧鐘舵�� + */ + public static String getErrorDev(Integer rgvNo) { + try { + RgvErrProtocol rgvErrProtocol = cache.get(rgvNo); + if (rgvErrProtocol == null){ + rgvErrProtocol = new RgvErrProtocol(); + rgvErrProtocol.setRgvNo(rgvNo); + } + return rgvErrProtocol.getError(); + } finally { + } + } + + /** + * 鑾峰彇璁惧鐘舵�� + */ + public static RgvErrProtocol getRgvStatus(Integer rgvNo) { + try { + return cache.get(rgvNo); + } finally { + } + } + + /** + * 鑾峰彇鎵�鏈夎澶囩姸鎬� + */ + public static ConcurrentHashMap<Integer, RgvErrProtocol> getAllRgvStatus() { + try { + return new ConcurrentHashMap<>(cache); // 杩斿洖鍓湰 + } finally { + } + } + +} -- Gitblit v1.9.1