This commit is contained in:
邹宗楠
2023-06-01 17:11:12 +08:00
parent 44e0edc404
commit 078ca7e9b2

View File

@@ -50,6 +50,7 @@ func ListenTcp() {
t := NewTcpClient()
if err := handleConn(c, t); err != nil {
c.Close()
t = nil
Poll.Wait()
Poll.Stop()
@@ -143,10 +144,10 @@ func handleConn(c net.Conn, t *TcpClient) error {
t.setPrintStatusTime(printNo)
}
//状态不一致再更新状态(可能缺纸了,过热了等)
if t.getPrintStatus(printNo) != status {
t.setPrintStatus(printNo, status)
changePrinterStatus(printNo, status)
}
//if t.getPrintStatus(printNo) != status {
t.setPrintStatus(printNo, status)
changePrinterStatus(printNo, status)
//}
} else if strings.Contains(data, printText) || strings.Contains(data, printTextNew) { //打印回调
//打印消息发送后打印机会回调该条打印消息的状态打印成功or失败失败原因..
//将回调的信息放到回调channel中打印成功后再打印下一条消息
@@ -214,8 +215,8 @@ func HandleTcpMessages(t *TcpClient, printNo string) {
fn := func() {
for {
time.Sleep(2 * time.Second)
if t.TimeoutMap[printNo] == true {
time.Sleep(2 * time.Second)
timeNow := time.Now()
timeStart := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, timeNow.Location())
timeEnd := time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 23, 59, 59, 0, timeNow.Location())
@@ -347,6 +348,8 @@ func doPrint(t *TcpClient, key string) (err error) {
} else {
globals.SugarLogger.Debugf("查询打印机扣费记录错误 %s", err)
}
// 回调重置打印机状态时间
t.Clients[b].StatusTime = time.Now()
//判断音频暂停?
//收到打印成功回调后,如果消息中有音频,需要等待一下,等上一个音频播完
//暂停时间就暂时取的sound标签内内容长度/2