This commit is contained in:
邹宗楠
2022-08-04 18:08:48 +08:00
parent f1761fa154
commit 9286e28acc
2 changed files with 23 additions and 1 deletions

View File

@@ -385,6 +385,9 @@ func buildMsg(printMsg *model.PrintMsg) (data []byte, err error) {
x1, x2 := int2h8l8(lenData / 2)
dataStr := str + x1 + x2 + const1 + orderNoHexH + orderNoHexL + printInit + printData
check := getCheckSum(dataStr)
// 测试
printMsg.Comment = dataStr + check
dao.UpdateEntity(dao.GetDB(), printMsg, "Comment")
return jxutils.Hextob(dataStr + check), err
}

View File

@@ -6,6 +6,7 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"strconv"
"strings"
"testing"
"unicode/utf8"
)
@@ -61,5 +62,23 @@ func TestCheckSum(t *testing.T) {
}
func TestTen216(t *testing.T) {
aa := `
3c736f756e643e
312c322c33
3c2f736f756e643e
1b6101bed3d6d0cec4d7d60a1b6100
3c736f756e643e
342c352c36
3c2f736f756e643e
1b6101bed3d6d00a1b6100
`
bb := `1B59415501 1B59415502 1B59415503`
kk := `1B59415501 1B59415502 1B59415503 1b6101bed3d6d0cec4d7d60a1b6100 1b6101bed3d6d0cec4d7d60a1b6100 1B59415504 1B59415505 1B59415506 1b6101bed3d6d00a1b6100`
// 第一个语音字段
index1 := strings.Index(aa, "3c736f756e643e")
index2 := strings.Index(aa, "3c2f736f756e643e")
str := aa[index1:index2]
gg := strings.Replace(aa, str, bb, 1)
fmt.Println(gg)
fmt.Println(kk)
}