This commit is contained in:
邹宗楠
2024-07-10 10:13:33 +08:00
parent 113212b1dd
commit 6e4d330d35
2 changed files with 10 additions and 25 deletions

View File

@@ -197,35 +197,10 @@ func HandleTcpMessages(t *TcpClient, printNo string) {
}
} else {
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
//Poll.Stop()
return
}
//}
}
Poll.AddJob(fn)
//go func() {
// for {
// if t.TimeoutMap[printNo] == true {
// timeNow := time.Now()
// timeStart := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, timeNow.Location())
// timeEnd := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 23, 59, 59, 0, timeNow.Location())
// prints, _ := dao.GetPrintMsgs(db, printNo, []int{printMsgWait}, timeStart.AddDate(0, 0, -1), timeEnd, offset, pageSize)
// for _, printMsg := range prints {
// printMsg.Status = PrintMsgAlreadyLoad
// //先避免重复读再插到channel
// if _, err := dao.UpdateEntity(db, printMsg, "Status"); err == nil {
// if err = t.addMsgChan(printMsg); err != nil {
// globals.SugarLogger.Debugf("HandleTcpMessages addMsgChan Err: %v", err)
// }
// }
// }
// } else {
// globals.SugarLogger.Debugf("HandleTcpMessages timeout")
// return
// }
// }
//}()
}
func (t *TcpClient) readTimeoutMap(key string) bool {
@@ -240,6 +215,7 @@ func doPrint(t *TcpClient, key string) (err error) {
)
if !t.isExistMsg(key) {
globals.SugarLogger.Debugf("==============:= %v", err)
return err
}
@@ -248,6 +224,10 @@ func doPrint(t *TcpClient, key string) (err error) {
if t.TimeoutMap[key] == true {
select {
case printMsg, ok := <-t.MsgMap[key]:
if key == "120220915001467" {
globals.SugarLogger.Debugf("=msgMap=%s", utils.Format4Output(printMsg, false))
globals.SugarLogger.Debugf("=msgMapok=%s", utils.Format4Output(ok, false))
}
if !ok {
globals.SugarLogger.Debugf("doPrint err !ok ...")
return

View File

@@ -642,6 +642,11 @@ func Heartbeat(c net.Conn, t *TcpClient, data string, printNo string) {
//4、读打印channel并打印并切等待回调channel中的消息
//5、修改数据库中打印机状态没在连接池中说明是重新连接的
//6、监听心跳时间超过1分多钟就clear掉
if printNo == "120220915001467" {
globals.SugarLogger.Debugf("==%s", utils.Format4Output(t, false))
globals.SugarLogger.Debugf("=msgMap=%s", utils.Format4Output(t.MsgMap, false))
globals.SugarLogger.Debugf("=bool=%s", utils.Format4Output(t.getClients(printNo) == nil, false))
}
if t.getClients(printNo) == nil {
addConn(c, t, printNo, status)
buildAllMap(t, printNo)