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