From 3251816066d6642f2d5ca7c7e4940a1f8a078904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 4 Nov 2024 10:53:16 +0800 Subject: [PATCH] 1 --- business/jxstore/event/event_print.go | 6 +++--- business/jxstore/event/event_tcp.go | 2 +- business/jxstore/event/event_tcp_utils.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/business/jxstore/event/event_print.go b/business/jxstore/event/event_print.go index 4ef00b9bc..382b2a76f 100644 --- a/business/jxstore/event/event_print.go +++ b/business/jxstore/event/event_print.go @@ -4,9 +4,9 @@ import ( "fmt" ) -var PrintObject = make(map[string]*TcpClient, 10) // 缓存的打印机对象 -var PrintAddrAndIp = make(map[string]string, 10) // 缓存打印机地址:[ip:printNo] event 文件包,connect只能获取到addr -var PrintIpAndAddr = make(map[string]string, 10) // 缓存打印机地址:[printNo:ip] api_controller 只能获取到printNo +var PrintObject = make(map[string]*TcpClient, 100) // 缓存的打印机对象 +var PrintAddrAndIp = make(map[string]string, 100) // 缓存打印机地址:[ip:printNo] event 文件包,connect只能获取到addr +var PrintIpAndAddr = make(map[string]string, 100) // 缓存打印机地址:[printNo:ip] api_controller 只能获取到printNo func init() { fmt.Println("初始化打印机对象") diff --git a/business/jxstore/event/event_tcp.go b/business/jxstore/event/event_tcp.go index 18308db01..78fe5bced 100644 --- a/business/jxstore/event/event_tcp.go +++ b/business/jxstore/event/event_tcp.go @@ -97,7 +97,7 @@ func handleConn(c net.Conn) error { } t, ok := PrintObject[printNo] - if !ok || t.Clients[printNo] == nil || t.Clients[printNo].StatusTime.Second()-time.Now().Second() >= 120 { + if !ok || t.Clients[printNo] == nil || t.Clients[printNo].StatusTime.Sub(time.Now()).Seconds() >= 120 { t = NewTcpClient() } diff --git a/business/jxstore/event/event_tcp_utils.go b/business/jxstore/event/event_tcp_utils.go index e8d198e9e..4957c9340 100644 --- a/business/jxstore/event/event_tcp_utils.go +++ b/business/jxstore/event/event_tcp_utils.go @@ -646,7 +646,7 @@ func Heartbeat(c net.Conn, t *TcpClient, data string, printNo string, printRemot //4、读打印channel并打印,并切等待回调channel中的消息 //5、修改数据库中打印机状态(没在连接池中说明是重新连接的) //6、监听心跳时间,超过1分多钟就clear掉 - if t.getClients(printNo) == nil || t == nil || t.getPrintStatusTime(printNo).IsZero() || t.Clients[printNo].StatusTime.Second()-time.Now().Second() >= 120 { + if t.getClients(printNo) == nil || t == nil || t.getPrintStatusTime(printNo).IsZero() || t.Clients[printNo].StatusTime.Sub(time.Now()).Seconds() >= 120 { addConn(c, t, printNo, status) buildAllMap(t, printNo) //t.TimeoutMap[printNo] <- true