This commit is contained in:
suyl
2021-06-29 10:19:58 +08:00
parent 76996eca28
commit a1851188ad

View File

@@ -3,7 +3,6 @@ package event
import (
"encoding/hex"
"fmt"
"git.rosy.net.cn/baseapi/utils"
"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"
@@ -57,7 +56,7 @@ func ListenTcp() {
return
}
globals.SugarLogger.Debugf("begin listenTcp port 8000......")
go HandleTcpMessages()
//go HandleTcpMessages()
for {
c, err := l.Accept()
if err != nil {
@@ -88,10 +87,8 @@ func handleConn(c net.Conn) {
}
return
}
globals.SugarLogger.Debugf("handleConn map: [%v]", utils.Format4Output(tcpClient.Clients, false))
//看是心跳还是打印返回
data := hex.EncodeToString(buffer[:n])
globals.SugarLogger.Debugf("handleConn heart : [%v]", data)
//证明是心跳
if strings.Contains(data, heartText) {
printNoData, _ := hex.DecodeString(data[len(heartText) : len(data)-8])
@@ -130,12 +127,15 @@ func changePrintMsg(data string) (err error) {
status = printMsgFail
comment = printErrMap[data[12:14]]
}
if tcpClient.Clients[printNo] == nil {
return err
}
if printMsg, err = dao.GetPrintMsg(db, printNo, orderNo); err != nil {
globals.SugarLogger.Debugf("changePrintMsg err :[%v]", err)
return
} else if printMsg == nil {
globals.SugarLogger.Debugf("changePrintMsg err ,not found printMsg printNo:[%v], orderNo :[%v]", printNo, orderNo)
} else {
} else if printMsg.Status != status {
printMsg.Comment = comment
printMsg.Status = status
dao.UpdateEntity(db, printMsg, "Comment", "Status")