From f9913ead4688e3b34217cc020240d8036bfb0de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 30 May 2023 09:13:00 +0800 Subject: [PATCH] 1 --- business/jxstore/event/event_tcp.go | 60 ++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/business/jxstore/event/event_tcp.go b/business/jxstore/event/event_tcp.go index 0f4cf8f94..34990b8c0 100644 --- a/business/jxstore/event/event_tcp.go +++ b/business/jxstore/event/event_tcp.go @@ -209,37 +209,10 @@ func (t *TcpClient) HandleTcpMessages(printNo string) { return } - fn := func() { - for { - if t.TimeoutMap[printNo] == true { - //if time.Now().Unix()%3 == 0 { - 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 { - // continue - //} - } else { - globals.SugarLogger.Debugf("HandleTcpMessages timeout") - return - } - } - } - Poll.AddJob(fn) - - //go func() { + //fn := func() { // for { // if t.TimeoutMap[printNo] == true { + // //if time.Now().Unix()%3 == 0 { // 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()) @@ -253,12 +226,39 @@ func (t *TcpClient) HandleTcpMessages(printNo string) { // } // } // } + // //} else { + // // continue + // //} // } else { // globals.SugarLogger.Debugf("HandleTcpMessages timeout") // 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 {