This commit is contained in:
邹宗楠
2025-02-08 09:46:48 +08:00
parent 93aaf0f58a
commit 3cb005011c
3 changed files with 9 additions and 3 deletions

View File

@@ -47,7 +47,6 @@ func ListenTcp() {
}()
if err := handleConn(c); err != nil {
globals.SugarLogger.Debugf("=========err := %v", err)
c.Close()
Poll.Wait()
Poll.Stop()
@@ -65,7 +64,7 @@ func handleConn(c net.Conn) error {
for {
printRemoteAddr := c.RemoteAddr().String()
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
globals.SugarLogger.Debugf("--------printRemoteAddr := %s", printRemoteAddr)
printNoByIP, _ := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr)
buffer, n, err := ConnRead(c)
if err != nil {
if err == io.EOF {
@@ -73,10 +72,13 @@ func handleConn(c net.Conn) error {
} else {
fmt.Println("ReadString err:", err)
}
globals.SugarLogger.Debugf("--------printRemoteAddr := %s,printNo := %s", printRemoteAddr, printNoByIP)
if printNo, ok := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr); ok {
globals.SugarLogger.Debugf("--------PrintObject := %s", utils.Format4Output(PrintObject, false))
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddr)
PrintObject.DelPrintObj(printNo)
PrintIpAndAddr.DelPrintIpAndAddr(printRemoteAddr)
globals.SugarLogger.Debugf("--------PrintObject := %s", utils.Format4Output(PrintObject, false))
dao.ExecuteSQL(dao.GetDB(), `UPDATE printer SET status = -1,is_online = -1 WHERE print_no = ? `, []interface{}{printNo}...)
}

View File

@@ -368,6 +368,7 @@ func getCallbackMsgInfo(data string) (orderNo int64, printNo string) {
}
func changePrinterStatus(printNo string, status int) {
globals.SugarLogger.Debugf("---------changePrinterStatus := %s --- %d", printNo, status)
var (
db = dao.GetDB()
)