aa
This commit is contained in:
@@ -228,6 +228,13 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
printMsg.Status = printMsgErr
|
||||
printMsg.Comment = err.Error()
|
||||
dao.UpdateEntity(db, printMsg, "Status", "Comment")
|
||||
if t.isExist(key) {
|
||||
timeoutChan <- 1
|
||||
timeoutChan <- 1
|
||||
timeoutChan <- 1
|
||||
t.clear(key)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
if c != nil {
|
||||
if _, err = c.Write(data); err != nil {
|
||||
@@ -253,16 +260,21 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||
go func() {
|
||||
for {
|
||||
if !utils.IsTimeZero(t.getPrintStatusTime(key)) {
|
||||
//2分钟内没心跳判断打印机掉线了
|
||||
if time.Now().Sub(t.getPrintStatusTime(key)) > time.Minute*2 {
|
||||
changePrinterStatus(key, printerStatusOffline)
|
||||
if t.isExist(key) {
|
||||
globals.SugarLogger.Debugf("HandleCheckTcpHeart del key,%v", key)
|
||||
timeoutChan <- 1
|
||||
timeoutChan <- 1
|
||||
t.clear(key)
|
||||
return
|
||||
select {
|
||||
case <-timeoutChan:
|
||||
return
|
||||
default:
|
||||
if !utils.IsTimeZero(t.getPrintStatusTime(key)) {
|
||||
//2分钟内没心跳判断打印机掉线了
|
||||
if time.Now().Sub(t.getPrintStatusTime(key)) > time.Minute*2 {
|
||||
changePrinterStatus(key, printerStatusOffline)
|
||||
if t.isExist(key) {
|
||||
timeoutChan <- 1
|
||||
timeoutChan <- 1
|
||||
timeoutChan <- 1
|
||||
t.clear(key)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user