This commit is contained in:
suyl
2021-07-20 17:43:28 +08:00
parent 807f16107a
commit 5ee7e6326c
2 changed files with 27 additions and 16 deletions

View File

@@ -267,9 +267,11 @@ func printFail() (err error) {
if err = checkPrintMsg(printMsg); err == nil {
tcpClient.s.RLock()
if tcpClient.Clients[printMsg.PrintNo] != nil {
if tcpClient.Clients[printMsg.PrintNo].C != nil {
c = tcpClient.Clients[printMsg.PrintNo].C
data, err = buildMsg(printMsg)
if tcpClient.Clients[printMsg.PrintNo].Status == printerStatusOnline {
if tcpClient.Clients[printMsg.PrintNo].C != nil {
c = tcpClient.Clients[printMsg.PrintNo].C
data, err = buildMsg(printMsg)
}
}
}
tcpClient.s.RUnlock()
@@ -417,7 +419,7 @@ func HandleCheckTcpHeart() {
}
}
func buildMsg(printMsg *model.PrintMsg) (data []byte, err error) {
func buildMsg(printMsg *dao.GetPrintMsgsResult) (data []byte, err error) {
var (
content = printMsg.Content
orderNo = printMsg.OrderNo
@@ -452,7 +454,7 @@ func getCheckSum(str string) (check string) {
}
//内容中的标签替换成指令
func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
func replaceContent(content string, printMsg *dao.GetPrintMsgsResult) (result string) {
var (
lenqr int
hexLenqr string
@@ -550,7 +552,10 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
return result
}
func checkPrintMsg(printMsg *model.PrintMsg) (err error) {
func checkPrintMsg(printMsg *dao.GetPrintMsgsResult) (err error) {
if printMsg.FlowFlag == 1 {
return fmt.Errorf("打印机当月流量已经超过30MB请及时充值printNo:[%v]", printMsg.PrintNo)
}
if printMsg.Content == "" {
return fmt.Errorf("此打印信息内容为空printMsg printNo:[%v], orderNo :[%v]", printMsg.PrintNo, printMsg.OrderNo)
}