This commit is contained in:
邹宗楠
2024-07-15 15:13:20 +08:00
parent 42360e124f
commit df9e1ae124
5 changed files with 58 additions and 34 deletions

View File

@@ -28,7 +28,7 @@ const (
printMsgAlreadySend = 2 //已经发出打印消息
printMsgSuccess = 1 //打印成功
printMsgWait = 0 //待打印
PrintMsgWait = 0 //待打印
printMsgFail = -1 //打印失败(打印机报出)
printMsgErr = -2 //京西报出
PrintMsgAlreadyLoad = 3 //已放入队列
@@ -635,7 +635,7 @@ func xtob(x string) string {
}
// Heartbeat 心跳回调
func Heartbeat(c net.Conn, t *TcpClient, data string, printNo string) {
func Heartbeat(c net.Conn, t *TcpClient, data string, printNo string, printRemoteAddr string) {
//printNoData, _ := hex.DecodeString(data[len(heartText) : len(data)-8])
//printNo = string(printNoData)
status := printStatus2JxStatus(data[len(data)-8 : len(data)-6])
@@ -662,6 +662,10 @@ func Heartbeat(c net.Conn, t *TcpClient, data string, printNo string) {
if err := dao.NotExistsCreate(printNo); err != nil {
globals.SugarLogger.Debugf("监听打印机心跳,不存在则创建 :[%v],printNo[%s]", err, printNo)
}
PrintObject[printNo] = t
PrintAddrAndIp[printRemoteAddr] = printNo
PrintIpAndAddr[printNo] = printRemoteAddr
} else {
//在加到连接池中已经更新了时间所以放在else里
t.setPrintStatusTime(printNo)