aa
This commit is contained in:
@@ -228,6 +228,13 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
|||||||
printMsg.Status = printMsgErr
|
printMsg.Status = printMsgErr
|
||||||
printMsg.Comment = err.Error()
|
printMsg.Comment = err.Error()
|
||||||
dao.UpdateEntity(db, printMsg, "Status", "Comment")
|
dao.UpdateEntity(db, printMsg, "Status", "Comment")
|
||||||
|
if t.isExist(key) {
|
||||||
|
timeoutChan <- 1
|
||||||
|
timeoutChan <- 1
|
||||||
|
timeoutChan <- 1
|
||||||
|
t.clear(key)
|
||||||
|
}
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
if c != nil {
|
if c != nil {
|
||||||
if _, err = c.Write(data); err != 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) {
|
func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
if !utils.IsTimeZero(t.getPrintStatusTime(key)) {
|
select {
|
||||||
//2分钟内没心跳判断打印机掉线了
|
case <-timeoutChan:
|
||||||
if time.Now().Sub(t.getPrintStatusTime(key)) > time.Minute*2 {
|
return
|
||||||
changePrinterStatus(key, printerStatusOffline)
|
default:
|
||||||
if t.isExist(key) {
|
if !utils.IsTimeZero(t.getPrintStatusTime(key)) {
|
||||||
globals.SugarLogger.Debugf("HandleCheckTcpHeart del key,%v", key)
|
//2分钟内没心跳判断打印机掉线了
|
||||||
timeoutChan <- 1
|
if time.Now().Sub(t.getPrintStatusTime(key)) > time.Minute*2 {
|
||||||
timeoutChan <- 1
|
changePrinterStatus(key, printerStatusOffline)
|
||||||
t.clear(key)
|
if t.isExist(key) {
|
||||||
return
|
timeoutChan <- 1
|
||||||
|
timeoutChan <- 1
|
||||||
|
timeoutChan <- 1
|
||||||
|
t.clear(key)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ var (
|
|||||||
regexpQrr = regexp.MustCompile(byteSignQrRight + "(.*?)" + byteSignQrRightE)
|
regexpQrr = regexp.MustCompile(byteSignQrRight + "(.*?)" + byteSignQrRightE)
|
||||||
regexpSound = regexp.MustCompile(byteSignSound + "(.*?)" + byteSignSoundE)
|
regexpSound = regexp.MustCompile(byteSignSound + "(.*?)" + byteSignSoundE)
|
||||||
|
|
||||||
timeoutChan = make(chan int, 2)
|
timeoutChan = make(chan int, 3)
|
||||||
)
|
)
|
||||||
|
|
||||||
type PrintInfo struct {
|
type PrintInfo struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user