1
This commit is contained in:
@@ -159,25 +159,28 @@ func (t *TcpClient) HandleTcpMessages(printNo string) {
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-t.TimeoutMap[printNo]:
|
||||
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
||||
return
|
||||
default:
|
||||
//一直读?
|
||||
prints, _ := dao.GetPrintMsgs(db, printNo, []int{printMsgWait}, time.Now().Add(-time.Hour*3), time.Now(), 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)
|
||||
}
|
||||
//for {
|
||||
select {
|
||||
case <-t.TimeoutMap[printNo]:
|
||||
globals.SugarLogger.Debugf("HandleTcpMessages timeout")
|
||||
return
|
||||
default:
|
||||
//一直读?
|
||||
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, printMsgAlreadyLoad}, timeStart, 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}()
|
||||
}
|
||||
func (t *TcpClient) readTimeoutMap(key string) bool {
|
||||
|
||||
Reference in New Issue
Block a user