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

@@ -9,6 +9,7 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"net"
"regexp"
"time"
@@ -439,7 +440,9 @@ func GetPrinterStatus(appID int, printNo string) (status int, err error) {
db = dao.GetDB()
)
//看有没有
if printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0); len(printers) == 0 {
printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0)
globals.SugarLogger.Debugf("---------printers := %s", utils.Format4Output(printers, false))
if len(printers) == 0 {
return status, fmt.Errorf("该应用下未找到该打印机print_no : %v", printNo)
} else {
return printers[0].Status + printers[0].IsOnline, nil // 当两个值都唯一时->在线正常

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()
)