1
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
@@ -439,7 +440,9 @@ func GetPrinterStatus(appID int, printNo string) (status int, err error) {
|
|||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
//看有没有
|
//看有没有
|
||||||
if printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0); len(printers) == 0 {
|
printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0)
|
||||||
|
globals.SugarLogger.Debugf("---------printers := %s", utils.Format4Output(printers, false))
|
||||||
|
if len(printers) == 0 {
|
||||||
return status, fmt.Errorf("该应用下未找到该打印机!print_no : %v", printNo)
|
return status, fmt.Errorf("该应用下未找到该打印机!print_no : %v", printNo)
|
||||||
} else {
|
} else {
|
||||||
return printers[0].Status + printers[0].IsOnline, nil // 当两个值都唯一时->在线正常
|
return printers[0].Status + printers[0].IsOnline, nil // 当两个值都唯一时->在线正常
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ func ListenTcp() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
if err := handleConn(c); err != nil {
|
if err := handleConn(c); err != nil {
|
||||||
globals.SugarLogger.Debugf("=========err := %v", err)
|
|
||||||
c.Close()
|
c.Close()
|
||||||
Poll.Wait()
|
Poll.Wait()
|
||||||
Poll.Stop()
|
Poll.Stop()
|
||||||
@@ -65,7 +64,7 @@ func handleConn(c net.Conn) error {
|
|||||||
for {
|
for {
|
||||||
printRemoteAddr := c.RemoteAddr().String()
|
printRemoteAddr := c.RemoteAddr().String()
|
||||||
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
|
printRemoteAddr = strings.Split(printRemoteAddr, ":")[0]
|
||||||
globals.SugarLogger.Debugf("--------printRemoteAddr := %s", printRemoteAddr)
|
printNoByIP, _ := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr)
|
||||||
buffer, n, err := ConnRead(c)
|
buffer, n, err := ConnRead(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
@@ -73,10 +72,13 @@ func handleConn(c net.Conn) error {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Println("ReadString err:", err)
|
fmt.Println("ReadString err:", err)
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("--------printRemoteAddr := %s,printNo := %s", printRemoteAddr, printNoByIP)
|
||||||
if printNo, ok := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr); ok {
|
if printNo, ok := PrintAddrAndIp.GetPrintAddrAndIp(printRemoteAddr); ok {
|
||||||
|
globals.SugarLogger.Debugf("--------PrintObject := %s", utils.Format4Output(PrintObject, false))
|
||||||
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddr)
|
PrintAddrAndIp.DelPrintAddrAndIp(printRemoteAddr)
|
||||||
PrintObject.DelPrintObj(printNo)
|
PrintObject.DelPrintObj(printNo)
|
||||||
PrintIpAndAddr.DelPrintIpAndAddr(printRemoteAddr)
|
PrintIpAndAddr.DelPrintIpAndAddr(printRemoteAddr)
|
||||||
|
globals.SugarLogger.Debugf("--------PrintObject := %s", utils.Format4Output(PrintObject, false))
|
||||||
|
|
||||||
dao.ExecuteSQL(dao.GetDB(), `UPDATE printer SET status = -1,is_online = -1 WHERE print_no = ? `, []interface{}{printNo}...)
|
dao.ExecuteSQL(dao.GetDB(), `UPDATE printer SET status = -1,is_online = -1 WHERE print_no = ? `, []interface{}{printNo}...)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ func getCallbackMsgInfo(data string) (orderNo int64, printNo string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func changePrinterStatus(printNo string, status int) {
|
func changePrinterStatus(printNo string, status int) {
|
||||||
|
globals.SugarLogger.Debugf("---------changePrinterStatus := %s --- %d", printNo, status)
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user