1
This commit is contained in:
@@ -62,10 +62,10 @@ func handleConn(c net.Conn) error {
|
||||
return errors.New("conn is nil")
|
||||
}
|
||||
for {
|
||||
buffer, n, err := ConnRead(c)
|
||||
printRemoteAddr := c.RemoteAddr().String()
|
||||
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
|
||||
printNoByIP, _ := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr)
|
||||
buffer, n, err := ConnRead(c)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
fmt.Println("connection close")
|
||||
@@ -78,6 +78,32 @@ func handleConn(c net.Conn) error {
|
||||
PrintObject.DelPrintObj(printNo)
|
||||
PrintIpAndAddr.DelPrintIpAndAddr(printRemoteAddr)
|
||||
dao.ExecuteSQL(dao.GetDB(), `UPDATE printer SET status = -1,is_online = -1 WHERE print_no = ? `, []interface{}{printNo}...)
|
||||
} else {
|
||||
printStatusOff := make(map[string]int, 0)
|
||||
for ip, pn := range PrintAddrAndIp.PrintObject {
|
||||
if ip == printRemoteAddr {
|
||||
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddr)
|
||||
} else if pn != "" {
|
||||
printStatusOff[pn] = 1
|
||||
}
|
||||
}
|
||||
|
||||
for pn, ip := range PrintIpAndAddr.PrintObject {
|
||||
if ip == printRemoteAddr {
|
||||
PrintIpAndAddr.DelPrintIpAndAddr(pn)
|
||||
} else if pn != "" {
|
||||
printStatusOff[pn] = 1
|
||||
}
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("----可能存活打印机打印机:%s", utils.Format4Output(printStatusOff, false))
|
||||
for pn, _ := range PrintObject.PrintObject {
|
||||
if printStatusOff[pn] != 1 {
|
||||
globals.SugarLogger.Debugf("----已经不存在但是未删除打印机:%s", pn)
|
||||
PrintObject.DelPrintObj(pn)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -368,9 +368,6 @@ func getCallbackMsgInfo(data string) (orderNo int64, printNo string) {
|
||||
}
|
||||
|
||||
func changePrinterStatus(printNo string, status int) {
|
||||
if printNo == "120220915001467" {
|
||||
globals.SugarLogger.Debugf("------------printStatus := %s,%d", printNo, status)
|
||||
}
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user