This commit is contained in:
suyl
2021-08-26 15:22:07 +08:00
parent b375c08422
commit 97cb95647b

View File

@@ -2,7 +2,6 @@ package event
import ( import (
"encoding/hex" "encoding/hex"
"encoding/json"
"fmt" "fmt"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/model/dao"
@@ -41,9 +40,9 @@ func (t *TcpClient) handleConn(c net.Conn) {
defer c.Close() defer c.Close()
for { for {
var ( var (
printNo string //打印机编号 printNo string //打印机编号
printStatus *GetPrintStatus //printStatus *GetPrintStatus
buffer = make([]byte, 1024) buffer = make([]byte, 1024)
) )
n, err := c.Read(buffer) n, err := c.Read(buffer)
if err != nil { if err != nil {
@@ -55,14 +54,14 @@ func (t *TcpClient) handleConn(c net.Conn) {
return return
} }
//也可能是查状态的openAPI外部查询一次性的 //也可能是查状态的openAPI外部查询一次性的
if err = json.Unmarshal(buffer[:n], &printStatus); err == nil { //if err = json.Unmarshal(buffer[:n], &printStatus); err == nil {
fmt.Println("handleConn msg: ", string(buffer[:n])) // fmt.Println("handleConn msg: ", string(buffer[:n]))
if printStatus != nil { // if printStatus != nil {
status := t.getPrintStatus(printStatus.PrintNo) // status := t.getPrintStatus(printStatus.PrintNo)
c.Write([]byte(utils.Int2Str(status))) // c.Write([]byte(utils.Int2Str(status)))
c.Close() // c.Close()
} // }
} //}
//看是心跳还是打印回调 //看是心跳还是打印回调
data := hex.EncodeToString(buffer[:n]) data := hex.EncodeToString(buffer[:n])
//globals.SugarLogger.Debugf("handleConn msg ....................: %v", data) //globals.SugarLogger.Debugf("handleConn msg ....................: %v", data)