This commit is contained in:
邹宗楠
2022-07-26 14:41:06 +08:00
parent 53ef22f8e7
commit 4c521ccbde
2 changed files with 16 additions and 16 deletions

View File

@@ -479,23 +479,23 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
if sounds := regexpSound.FindStringSubmatch(result); len(sounds) > 0 {
sound := sounds[1]
printer := model.Printer{}
printer.Volume = 4
printer.Sound = "sounda"
//printer := model.Printer{}
//printer.Volume = 4
//printer.Sound = "sounda"
//if printer, _ := dao.GetPrinter(dao.GetDB(), printMsg.PrintNo); printer != nil {
//先把结束标签消了
result = strings.ReplaceAll(result, byteSignSoundE, "")
//fd 固定
//001a (声音数据长度高八位低八位)
//0101 固定
soundPrefix := ""
if printer.Sound != "" {
soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound
} else {
soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
}
hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
hexPrefixStr := hex.EncodeToString(hexPrefix)
//soundPrefix := ""
//if printer.Sound != "" {
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound
//} else {
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
//}
//hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
//hexPrefixStr := hex.EncodeToString(hexPrefix)
// 将语音包转换为十六进制
voice := ""
@@ -509,16 +509,16 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
voiceData := hex.EncodeToString(voiceDataGBK)
//[8]sounda14 ->5b385d736f756e64613134
realSound := hexPrefixStr + voiceData
allLen := fmt.Sprintf("%x", (len("fd001a0101")+len(realSound))/2)
//realSound := hexPrefixStr + voiceData
realSound := voiceData
allLen := fmt.Sprintf("%x", (len(realSound))/2)
if len(allLen) < 2 {
allLen = "0" + allLen
}
//soundLenH, soundLenX := int2h8l8(int64((len(realSound) + len("0101")) / 2))
//result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+"fd"+soundLenH+soundLenX+"0100"+hexPrefixStr)
result = strings.ReplaceAll(result, byteSignSound, hexSignSoundOld+hexPrefixStr)
result = strings.ReplaceAll(result, byteSignSoundE, "")
result = strings.ReplaceAll(result, byteSignSound, hexSignSoundOld+realSound)
//}
}
}

View File

@@ -13,7 +13,7 @@ func TestPrintMsg(t *testing.T) {
msg := &model.PrintMsg{
ModelIDCULD: model.ModelIDCULD{},
PrintNo: "20220707000002",
Content: "\t<sound>20</sound>\t\t<center><b>京西果园</b></center><br><br>\t\t<center>手机买菜上京西</center><br><center>极速到家送惊喜</center><br>--------------------------------<br>下单时间: 2021-08-27 21:57:26<br>预计送达: 2021-08-27 22:57:26<br>订单编号: 93154441730211100<br><br><b>美团外卖#19</b><br><qrc>93154441730211100</qrc><br>客户: 李大梦(先生)<br>电话: 15987200340<br>地址: 北浦伟业广场-2号楼 (伟业广场B区)@#云南省楚雄彝族自治州楚雄市鹿城镇伟业广场<br><br>客户备注: <br><b>【如遇缺货】: 缺货时电话与我沟通</b><br><br><br>商品明细: <br>品名 数量 单价 小计<br>--------------------------------<br>【自由拼】洗净红提160g/盒<br> x1 ¥9.20 ¥9.20<br>【果切】 牛奶木瓜约300g/份<br> x1 ¥9.70 ¥9.70<br>【自由拼】严选香蕉果切180g/盒<br> x1 ¥8.80 ¥8.80<br>[网红果切]乌梅小番茄25g/个<br> x10 ¥0.80 ¥8.00<br>[现剥]甜石榴籽约250g/份(1个)<br> x1 ¥3.50 ¥3.50<br>【爆品特惠】新鲜脆甜半斤哈密瓜 哈蜜瓜果切一盒250g/盒(230~260g)<br> x1 ¥0.01 ¥0.01<br>【爆品特惠】新鲜脆甜半斤哈密瓜 哈蜜瓜果切一盒250g/盒(230~260g)<br> x1 ¥8.60 ¥8.60<br><br>共7种16件商品<br>--------------------------------<br><center><hb>商品质量问题请联系:</hb></center><br><center><hb>京西果园·果切·水果捞(果果屋店):15841011397</hb></center><br><br>更多信息请关注官方微信: 京西菜市<br><br><br>--------------------------------<br>--------------------------------<br><br>\n",
Content: "<sound>20</sound>",
OrderNo: 2022071109,
Status: 0,
Comment: "",