开机打印
This commit is contained in:
@@ -189,6 +189,48 @@ func handleConn(c net.Conn) {
|
||||
Status: printStatus2JxStatus(data[len(data)-8 : len(data)-6]),
|
||||
}
|
||||
tcpClient.Clients[printNo] = printInfo
|
||||
//新开机的打印失败和错误的
|
||||
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 err != nil {
|
||||
printMsg.Status = printMsgErr
|
||||
printMsg.Comment = err.Error()
|
||||
dao.UpdateEntity(db, printMsg, "Status", "Comment")
|
||||
delete(tcpClient.Clients, printMsg.PrintNo)
|
||||
if c != nil {
|
||||
c.Close()
|
||||
}
|
||||
} else {
|
||||
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 {
|
||||
//改变打印机状态
|
||||
//changePrinterStatus(printNo, printerStatusOnline)
|
||||
@@ -261,7 +303,7 @@ func HandleTcpMessages() {
|
||||
//一直读?
|
||||
var err error
|
||||
time.Sleep(time.Second / 2)
|
||||
prints, _ := dao.GetPrintMsgs(db, printMsgWait, offset, pageSize)
|
||||
prints, _ := dao.GetPrintMsgs(db, printMsgWait, time.Now().Add(time.Hour*3), time.Now(), offset, pageSize)
|
||||
for _, printMsg := range prints {
|
||||
var (
|
||||
data []byte
|
||||
|
||||
Reference in New Issue
Block a user