1
This commit is contained in:
@@ -159,25 +159,28 @@ func (t *TcpClient) HandleTcpMessages(printNo string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
//for {
|
||||||
select {
|
select {
|
||||||
case <-t.TimeoutMap[printNo]:
|
case <-t.TimeoutMap[printNo]:
|
||||||
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
//一直读?
|
//一直读?
|
||||||
prints, _ := dao.GetPrintMsgs(db, printNo, []int{printMsgWait}, time.Now().Add(-time.Hour*3), time.Now(), offset, pageSize)
|
timeNow := time.Now()
|
||||||
for _, printMsg := range prints {
|
timeStart := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, timeNow.Location())
|
||||||
printMsg.Status = printMsgAlreadyLoad
|
timeEnd := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 23, 59, 59, 0, timeNow.Location())
|
||||||
//先避免重复读再插到channel?
|
prints, _ := dao.GetPrintMsgs(db, printNo, []int{printMsgWait, printMsgAlreadyLoad}, timeStart, timeEnd, offset, pageSize)
|
||||||
if _, err := dao.UpdateEntity(db, printMsg, "Status"); err == nil {
|
for _, printMsg := range prints {
|
||||||
if err = t.addMsgChan(printMsg); err != nil {
|
printMsg.Status = printMsgAlreadyLoad
|
||||||
globals.SugarLogger.Debugf("HandleTcpMessages addMsgChan Err: %v", err)
|
//先避免重复读再插到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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
func (t *TcpClient) readTimeoutMap(key string) bool {
|
func (t *TcpClient) readTimeoutMap(key string) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user