From 1441394923f8aa594b9a407e3d5f92e718be16b3 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Fri, 9 Jul 2021 15:35:10 +0800 Subject: [PATCH] aa --- business/jxstore/event/event_tcp.go | 34 ++++++++--------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/business/jxstore/event/event_tcp.go b/business/jxstore/event/event_tcp.go index 6ce15fae9..82cef4a9c 100644 --- a/business/jxstore/event/event_tcp.go +++ b/business/jxstore/event/event_tcp.go @@ -206,35 +206,19 @@ func handleConn(c net.Conn) { ) if printMsg != nil { if err = checkPrintMsg(printMsg); err == nil { - if tcpClient.Clients[printMsg.PrintNo] != nil { - if tcpClient.Clients[printMsg.PrintNo].C != nil { - c = tcpClient.Clients[printMsg.PrintNo].C - data, err = buildMsg(printMsg) + if c != nil { + if _, err = c.Write(data); err != nil { + globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err) + delete(tcpClient.Clients, printMsg.PrintNo) + c.Close() + } else { + globals.SugarLogger.Debugf("handleTcpMessages success, data: %v", hex.EncodeToString(data)) + printMsg.Status = printMsgAlreadySend + dao.UpdateEntity(db, printMsg, "Status", "Comment") } } } } - if err != nil { - printMsg.Status = printMsgErr - printMsg.Comment = err.Error() - dao.UpdateEntity(db, printMsg, "Status", "Comment") - delete(tcpClient.Clients, printMsg.PrintNo) - if c != nil { - c.Close() - } - } else { - if c != nil { - if _, err = c.Write(data); err != nil { - globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err) - delete(tcpClient.Clients, printMsg.PrintNo) - c.Close() - } else { - globals.SugarLogger.Debugf("handleTcpMessages success, data: %v", hex.EncodeToString(data)) - printMsg.Status = printMsgAlreadySend - dao.UpdateEntity(db, printMsg, "Status", "Comment") - } - } - } } } else { //改变打印机状态