From d15cae9e8d2cabf8d0f3ed41f2f88b04131f8c76 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 31 七月 2025 14:18:58 +0800
Subject: [PATCH] 增加查询单个设备(RTU或FBox)是否在线的功能接口
---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/TreadPoolFactory.java | 97 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/TreadPoolFactory.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/TreadPoolFactory.java
new file mode 100644
index 0000000..b20cbca
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/threadPool/TreadPoolFactory.java
@@ -0,0 +1,97 @@
+package com.dy.common.threadPool;
+
+
+public class TreadPoolFactory {
+
+ private static ThreadPool.Pool pool_short ;//鐭伐浣滀换鍔$嚎绋嬫睜锛岀嚎绋嬪伐浣滅敤鏃惰緝鐭�
+ private static ThreadPool.Pool pool_long ;//闀垮伐浣滀换鍔$嚎绋嬫睜锛岀嚎绋嬪伐浣滅敤鏃惰緝闀�
+
+
+ public final static Integer[] pool_short_state(){
+ Integer shortCurThread = 0 ;//鐭嚎绋嬫睜褰撳墠绾跨▼鏁�
+ Integer shortMaxThread = 0 ;//鐭嚎绋嬫睜鏈�澶х嚎绋嬫暟
+ Integer shortMinThread = 0 ;//鐭嚎绋嬫睜鏈�灏忕嚎绋嬫暟
+ shortCurThread = pool_short.size() ;
+ shortMaxThread = pool_short.maxThread() ;
+ shortMinThread = pool_short.minThread() ;
+ return new Integer[]{shortCurThread, shortMaxThread, shortMinThread} ;
+ }
+
+ public final static Integer[] pool_long_state(){
+ Integer longCurThread = 0 ;//鐭嚎绋嬫睜褰撳墠绾跨▼鏁�
+ Integer longMaxThread = 0 ;//鐭嚎绋嬫睜鏈�澶х嚎绋嬫暟
+ Integer longMinThread = 0 ;//鐭嚎绋嬫睜鏈�灏忕嚎绋嬫暟
+ longCurThread = pool_long.size() ;
+ longMaxThread = pool_long.maxThread() ;
+ longMinThread = pool_long.minThread() ;
+ return new Integer[]{longCurThread, longMaxThread, longMinThread} ;
+ }
+ /**
+ * 鍒濆鍖栫嚎绋嬫睜
+ * @param poolName 绾跨▼姹犲拰绾跨▼鍚嶇О
+ * @param maxNum 绾跨▼姹犳渶澶х嚎绋嬫暟 锛岃嫢涓�-1锛屼笉鍙楅檺鍒�
+ * @param minNum 绾跨▼姹犳渶灏忕嚎绋嬫暟锛屾垨鍒濆绾跨▼鏁�
+ * @param freeTimeout 绌洪棽绾跨▼瓒呮椂鏃堕暱(绉�)
+ * @param busyTimeout 蹇欑绾跨▼瓒呮椂鏃堕暱(绉�)锛岃嫢涓�-1锛屼笉鍙楅檺鍒�
+ * @return 绾跨▼姹犲疄渚�
+ */
+ public final static void initThreadPoolShort(String poolName,
+ int maxNum,
+ int minNum,
+ long freeTimeout,
+ long busyTimeout) throws Exception {
+ if(pool_short!= null){
+ throw new Exception("绾跨▼姹犱笉鑳介噸澶嶅垵濮嬪寲锛�");
+ }
+ if(pool_short == null){
+ pool_short = new ThreadPoolImp().new MyThreadPool(poolName, maxNum, minNum, freeTimeout, busyTimeout);
+ }
+ }
+
+ /**
+ * 鍒濆鍖栫嚎绋嬫睜
+ * @param poolName 绾跨▼姹犲拰绾跨▼鍚嶇О
+ * @param maxNum 绾跨▼姹犳渶澶х嚎绋嬫暟锛岃嫢涓�-1锛屼笉鍙楅檺鍒�
+ * @param minNum 绾跨▼姹犳渶灏忕嚎绋嬫暟锛屾垨鍒濆绾跨▼鏁�
+ * @param freeTimeout 绌洪棽绾跨▼瓒呮椂鏃堕暱(绉�)
+ * @param busyTimeout 蹇欑绾跨▼瓒呮椂鏃堕暱(绉�)锛岃嫢涓�-1锛屼笉鍙楅檺鍒�
+ * @return 绾跨▼姹犲疄渚�
+ */
+ public final static void initThreadPoolLong(String poolName,
+ int maxNum,
+ int minNum,
+ long freeTimeout,
+ long busyTimeout) throws Exception {
+ if(pool_long!= null){
+ throw new Exception("绾跨▼姹犱笉鑳介噸澶嶅垵濮嬪寲锛�");
+ }
+ if(pool_long == null){
+ pool_long = new ThreadPoolImp().new MyThreadPool(poolName, maxNum, minNum, freeTimeout, busyTimeout);
+ }
+ }
+ /**
+ * 寰楀埌鍞竴绾跨▼姹犲疄渚�
+ * @return
+ * @throws Exception
+ */
+ public final static ThreadPool.Pool getThreadPoolShort()
+ throws Exception {
+ if (pool_short == null) {
+ throw new Exception("寰楀埌绾跨▼姹犲墠棣栧厛蹇呴』鍒濆鍖栵紒");
+ }
+ return pool_short ;
+ }
+ /**
+ * 寰楀埌鍞竴绾跨▼姹犲疄渚�
+ * @return
+ * @throws Exception
+ */
+ public final static ThreadPool.Pool getThreadPoolLong()
+ throws Exception {
+ if (pool_long == null) {
+ throw new Exception("寰楀埌绾跨▼姹犲墠棣栧厛蹇呴』鍒濆鍖栵紒");
+ }
+ return pool_long ;
+ }
+
+}
--
Gitblit v1.8.0