From 35c84687898153c664f3ef495c468cff3c6fc54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 11 May 2026 10:03:21 +0800 Subject: [PATCH] 1 --- business/jxstore/cms/api_print.go | 8 ++++---- business/jxstore/event/event_tcp.go | 6 +++--- business/jxstore/event/event_tcp_utils.go | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/business/jxstore/cms/api_print.go b/business/jxstore/cms/api_print.go index 8caa7c1a6..d0a61f6fb 100644 --- a/business/jxstore/cms/api_print.go +++ b/business/jxstore/cms/api_print.go @@ -386,11 +386,11 @@ func DoPrintMsg(appID int, msgID, printNo, content string, orderNo string) (err Status: event.PrintMsgWait, } - t, ok := event.TcpClientList[printNo] + t, ok := event.TcpClientList.Load(printNo) if ok { - t.Lock() - defer t.Unlock() - t.MsgMap[printNo] <- printMsg + t.(*event.TcpClient).Lock() + defer t.(*event.TcpClient).Unlock() + t.(*event.TcpClient).MsgMap[printNo] <- printMsg printMsg.Status = event.PrintMsgAlreadyLoad } /*else { t = event.NewTcpClient() diff --git a/business/jxstore/event/event_tcp.go b/business/jxstore/event/event_tcp.go index fc919ba4d..925298a7e 100644 --- a/business/jxstore/event/event_tcp.go +++ b/business/jxstore/event/event_tcp.go @@ -88,11 +88,11 @@ func handleConn(c net.Conn) error { callback = true } - if _, have := TcpClientList[printNo]; !have { + if value, have := TcpClientList.Load(printNo); !have { t = NewTcpClient() - TcpClientList[printNo] = t + TcpClientList.Store(printNo, t) } else { - t = TcpClientList[printNo] + t = value.(*TcpClient) } if heartbeat { // 证明是心跳 diff --git a/business/jxstore/event/event_tcp_utils.go b/business/jxstore/event/event_tcp_utils.go index 184f79a5c..25bdc8f43 100644 --- a/business/jxstore/event/event_tcp_utils.go +++ b/business/jxstore/event/event_tcp_utils.go @@ -17,7 +17,7 @@ import ( "unicode/utf8" ) -var TcpClientList = make(map[string]*TcpClient, 0) +var TcpClientList = new(sync.Map) const ( heartText = "1e000f02000151" // 老版心跳 @@ -843,6 +843,7 @@ func HandleCheckTcpHeart(t *TcpClient, key string) { close(t.CallBackMap[key]) //t.delConn(key) t.clear(key) + TcpClientList.Delete(key) return } }