From 705fa9706269ed5e68bc245be17cd8a78333b1f1 Mon Sep 17 00:00:00 2001
From: "qiyunfanbo126.com" <815699>
Date: Wed, 22 Jan 2025 16:09:03 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E8=BF=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/http/tcppool/single.go |  3 ++-
 app/utils/tcp.go           | 22 ++++++++++------------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/app/http/tcppool/single.go b/app/http/tcppool/single.go
index 85e9d99..7de61b9 100644
--- a/app/http/tcppool/single.go
+++ b/app/http/tcppool/single.go
@@ -145,7 +145,8 @@ func (t *TcpHelper) watch(conn net.Conn) {
 				} else {
 					atomic.StoreInt32(t.Full, 1)
 					utils.Log(nil, "连接关闭", err)
-					//t.reconnect(config.GetConf().OrderPort)
+					t.client.Close()
+					t.reconnect(config.GetConf().OrderPort)
 				}
 			}
 			time.Sleep(1 * time.Second)
diff --git a/app/utils/tcp.go b/app/utils/tcp.go
index 4746b80..c00206a 100644
--- a/app/utils/tcp.go
+++ b/app/utils/tcp.go
@@ -41,7 +41,7 @@ func handleConnection(conn net.Conn) {
 		}
 		// 将读取到的字符串转换为字节切片
 		buf = []byte(line)
-		if err == nil && len(buf) > 1 {
+		if err == nil && len(buf) > 2 {
 			if atomic.LoadInt32(workSingleNum) >= int32(maxNum) {
 				if atomic.LoadInt32(busySingle) == 0 {
 					fmt.Println("繁忙")
@@ -51,19 +51,17 @@ func handleConnection(conn net.Conn) {
 				}
 
 			} else {
-				if len(buf) > 2 {
-					var data map[string]interface{}
-					json.Unmarshal(buf, &data)
-					fmt.Println("收到", *workSingleNum, maxNum, string(buf))
-					conn.Write([]byte(data["serial_number"].(string) + "\n"))
-					go handLogacal(conn, buf)
-					atomic.AddInt32(workSingleNum, 1)
-				} else {
-					conn.Write([]byte("2\n"))
-				}
-
+				var data map[string]interface{}
+				json.Unmarshal(buf, &data)
+				fmt.Println("收到", *workSingleNum, maxNum, string(buf))
+				conn.Write([]byte(data["serial_number"].(string) + "\n"))
+				go handLogacal(conn, buf)
+				atomic.AddInt32(workSingleNum, 1)
+				conn.Write([]byte("2\n"))
 			}
 
+		} else {
+			conn.Write([]byte("6\n"))
 		}
 
 	}