From 656aa4f953eb52502a6414965e46642c31b6e8ee Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期二, 29 四月 2025 15:33:09 +0800 Subject: [PATCH] 设备会在多种功能码上报数据中携带报警与状态数据,这样数据库保存设备报警与状态数据可能很多,为此修改逻辑,当前实现为一设备一个小时内只保存一条报警与状态数据。 --- pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/tasks/SendMsConstantTask.java | 81 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 81 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/tasks/SendMsConstantTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/tasks/SendMsConstantTask.java new file mode 100644 index 0000000..a57a546 --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/tasks/SendMsConstantTask.java @@ -0,0 +1,81 @@ +package com.dy.rtuMw.server.tasks; + +import com.dy.common.mw.core.CoreTask; +import com.dy.common.queue.Node; +import com.dy.rtuMw.server.forMs.MsObj4Ding; +import com.dy.rtuMw.server.forMs.SendMsCache; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * @Author: liurunyu + * @Date: 2024/7/31 18:45 + * @Description + */ +public class SendMsConstantTask extends CoreTask { + + private static final Logger log = LogManager.getLogger(SendMsConstantTask.class.getName()); + + /** + * 鍦ㄥ崟绾跨▼鐜涓繍琛� + */ + @Override + public Integer execute() { + try{ + //log.info("褰撳墠娑堟伅闃熷垪涓繕鏈夌粨鐐规暟閲忥細" + SendMsCache.size()); + dealMs() ; + }catch(Exception e){ + log.error(e); + } + return SendMsCache.size()>0?0:1 ; + } + + /** + * 澶勭悊涓嬭鍛戒护 + */ + public void dealMs() { + Node first = SendMsCache.getFirstQueueNode() ; + if(first != null){ + Node last = SendMsCache.getLastQueueNode() ; + while (last != null){ + last = this.doDealMs(first, last); + } + } + } + /** + * 澶勭悊缂撳瓨鐨勪笅琛岃妭鐐� + * @param first 绗竴涓妭鐐� + * @param last 鏈�鍚庝竴涓妭鐐� + */ + private Node doDealMs(Node first, Node last){ + if(last != null){ + //鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸last浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秎ast.pre涓虹┖锛屾墍浠ユ彁鍓嶆妸last.pre鍙栧嚭鏉� + Node pre = last.pre ; + dealNode(last) ; + if(first != last){ + return pre ; + }else{ + //鍋滄 + return null ; + } + }else{ + return null ; + } + } + + /** + * 澶勭悊涓�涓妭鐐� + * @param node 鑺傜偣 + */ + private void dealNode(Node node){ + if(node != null && node.obj != null){ + MsObj4Ding obj = (MsObj4Ding)node.obj ; + boolean removeNode = obj.dealSelf() ; + if(removeNode){ + SendMsCache.removeNode(node); + } + } + } + + +} -- Gitblit v1.8.0