aa
This commit is contained in:
@@ -27,7 +27,7 @@ func ListenTcp() {
|
|||||||
go HandleTcpMessages()
|
go HandleTcpMessages()
|
||||||
go t.HandleCheckTcpHeart()
|
go t.HandleCheckTcpHeart()
|
||||||
go t.doPrint2(printMsgChan)
|
go t.doPrint2(printMsgChan)
|
||||||
go t.doPrint(printMsgChanFail)
|
//go t.doPrint(printMsgChanFail)
|
||||||
for {
|
for {
|
||||||
c, err := l.Accept()
|
c, err := l.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -153,55 +153,11 @@ func printFail() (err error) {
|
|||||||
)
|
)
|
||||||
prints, _ := dao.GetPrintMsgs(db, []int{printMsgFail, printMsgErr, printMsgAlreadyLoad, printMsgAlreadySend}, time.Now().Add(-time.Hour*3), time.Now(), 0, 999)
|
prints, _ := dao.GetPrintMsgs(db, []int{printMsgFail, printMsgErr, printMsgAlreadyLoad, printMsgAlreadySend}, time.Now().Add(-time.Hour*3), time.Now(), 0, 999)
|
||||||
for _, printMsg := range prints {
|
for _, printMsg := range prints {
|
||||||
printMsgChanFail <- printMsg
|
printMsgChan <- printMsg
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TcpClient) doPrint(printMsgChanFail chan *model.PrintMsg) (err error) {
|
|
||||||
var (
|
|
||||||
db = dao.GetDB()
|
|
||||||
)
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case printMsg, _ := <-printMsgChanFail:
|
|
||||||
var (
|
|
||||||
data []byte
|
|
||||||
c net.Conn
|
|
||||||
)
|
|
||||||
if printMsg != nil {
|
|
||||||
if err = checkPrintMsg(db, printMsg); err == nil {
|
|
||||||
//t.Lock()
|
|
||||||
//if t.Clients[printMsg.PrintNo] != nil {
|
|
||||||
// if t.Clients[printMsg.PrintNo].Status == printerStatusOnline {
|
|
||||||
// if t.Clients[printMsg.PrintNo].C != nil {
|
|
||||||
// c = t.Clients[printMsg.PrintNo].C
|
|
||||||
// data, err = buildMsg(printMsg)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//t.Unlock()
|
|
||||||
if c = t.getPrintConn(printMsg.PrintNo); c != nil {
|
|
||||||
data, err = buildMsg(printMsg)
|
|
||||||
if _, err = c.Write(data); err != nil {
|
|
||||||
globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err)
|
|
||||||
t.delConn(printMsg.PrintNo)
|
|
||||||
//delete(t.Clients, printMsg.PrintNo)
|
|
||||||
//c.Close()
|
|
||||||
} else {
|
|
||||||
globals.SugarLogger.Debugf("handleTcpMessages success, data: %v", hex.EncodeToString(data))
|
|
||||||
dataStr := <-printMsgCallbackChan
|
|
||||||
t.changePrintMsg(dataStr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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