From 5530ab4d0109650587c5421ee5f9c835c132f000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 10 Jul 2024 11:17:00 +0800 Subject: [PATCH] 1 --- business/jxstore/event/event_tcp.go | 10 ++++------ business/jxstore/event/event_tcp_utils.go | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/business/jxstore/event/event_tcp.go b/business/jxstore/event/event_tcp.go index 83988e6ec..fd0365bd4 100644 --- a/business/jxstore/event/event_tcp.go +++ b/business/jxstore/event/event_tcp.go @@ -89,12 +89,10 @@ func handleConn(c net.Conn) error { callback = true } - t, ok := PrintObject[printNo] - if !ok { - t = NewTcpClient() - buildAllMap(t, printNo) - PrintObject[printNo] = t - } + t := NewTcpClient() + buildAllMap(t, printNo) + PrintObject[printNo] = t + if strings.Contains(string(buffer[0:n]), "print_no_clear") { // 清理缓存 param := struct { PrintNoClear json.Number `json:"print_no_clear"` diff --git a/business/jxstore/event/event_tcp_utils.go b/business/jxstore/event/event_tcp_utils.go index 4c825dc57..f8e95b0d7 100644 --- a/business/jxstore/event/event_tcp_utils.go +++ b/business/jxstore/event/event_tcp_utils.go @@ -652,7 +652,7 @@ func Heartbeat(c net.Conn, t *TcpClient, data string, printNo string) { buildAllMap(t, printNo) //t.TimeoutMap[printNo] <- true HandleTcpMessages(t, printNo) - doPrint(t, printNo) + //doPrint(t, printNo) if status == printerStatusOnline { //t.printFail() } @@ -667,10 +667,10 @@ func Heartbeat(c net.Conn, t *TcpClient, data string, printNo string) { //在加到连接池中已经更新了时间,所以放在else里 t.setPrintStatusTime(printNo) } + doPrint(t, printNo) //状态不一致再更新状态(可能缺纸了,过热了等) t.setPrintStatus(printNo, status) changePrinterStatus(printNo, status) - doPrint(t, printNo) } // Callback 打印成功回调