aa
This commit is contained in:
@@ -194,33 +194,7 @@ func handleConn(c net.Conn) {
|
|||||||
Status: printStatus2JxStatus(data[len(data)-8 : len(data)-6]),
|
Status: printStatus2JxStatus(data[len(data)-8 : len(data)-6]),
|
||||||
}
|
}
|
||||||
tcpClient.Clients[printNo] = printInfo
|
tcpClient.Clients[printNo] = printInfo
|
||||||
//新开机的打印失败和错误的
|
printFail()
|
||||||
var (
|
|
||||||
db = dao.GetDB()
|
|
||||||
)
|
|
||||||
prints, _ := dao.GetPrintMsgsFail(db, time.Now().Add(-time.Hour*3), time.Now())
|
|
||||||
for _, printMsg := range prints {
|
|
||||||
var (
|
|
||||||
data []byte
|
|
||||||
c net.Conn
|
|
||||||
)
|
|
||||||
if printMsg != nil {
|
|
||||||
if err = checkPrintMsg(printMsg); err == nil {
|
|
||||||
data, err = buildMsg(printMsg)
|
|
||||||
if c != nil {
|
|
||||||
if _, err = c.Write(data); err != nil {
|
|
||||||
globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err)
|
|
||||||
delete(tcpClient.Clients, printMsg.PrintNo)
|
|
||||||
c.Close()
|
|
||||||
} else {
|
|
||||||
globals.SugarLogger.Debugf("handleTcpMessages success, data: %v", hex.EncodeToString(data))
|
|
||||||
printMsg.Status = printMsgAlreadySend
|
|
||||||
dao.UpdateEntity(db, printMsg, "Status", "Comment")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//改变打印机状态
|
//改变打印机状态
|
||||||
//changePrinterStatus(printNo, printerStatusOnline)
|
//changePrinterStatus(printNo, printerStatusOnline)
|
||||||
@@ -238,6 +212,41 @@ func handleConn(c net.Conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printFail() (err error) {
|
||||||
|
//新开机的打印失败和错误的
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
prints, _ := dao.GetPrintMsgsFail(db, time.Now().Add(-time.Hour*3), time.Now())
|
||||||
|
for _, printMsg := range prints {
|
||||||
|
var (
|
||||||
|
data []byte
|
||||||
|
c net.Conn
|
||||||
|
)
|
||||||
|
if printMsg != nil {
|
||||||
|
if err = checkPrintMsg(printMsg); err == nil {
|
||||||
|
if tcpClient.Clients[printMsg.PrintNo] != nil {
|
||||||
|
if tcpClient.Clients[printMsg.PrintNo].C != nil {
|
||||||
|
c = tcpClient.Clients[printMsg.PrintNo].C
|
||||||
|
data, err = buildMsg(printMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if c != nil {
|
||||||
|
if _, err = c.Write(data); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err)
|
||||||
|
delete(tcpClient.Clients, printMsg.PrintNo)
|
||||||
|
c.Close()
|
||||||
|
} else {
|
||||||
|
globals.SugarLogger.Debugf("handleTcpMessages success, data: %v", hex.EncodeToString(data))
|
||||||
|
printMsg.Status = printMsgAlreadySend
|
||||||
|
dao.UpdateEntity(db, printMsg, "Status", "Comment")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func printStatus2JxStatus(printStatus string) (status int) {
|
func printStatus2JxStatus(printStatus string) (status int) {
|
||||||
if printStatus == heartErrWithoutPaper {
|
if printStatus == heartErrWithoutPaper {
|
||||||
return printerStatusOnlineWithoutPaper
|
return printerStatusOnlineWithoutPaper
|
||||||
|
|||||||
Reference in New Issue
Block a user