From d02fc8f93b33f00fcea296dcca11593466a02997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 27 Jul 2022 18:05:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9F=B3=E9=A2=91=E8=A1=A5?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/event/event_tcp_utils.go | 9 ++++++++- business/jxstore/event/print_test.go | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/business/jxstore/event/event_tcp_utils.go b/business/jxstore/event/event_tcp_utils.go index e327efd98..4ea7d89ed 100644 --- a/business/jxstore/event/event_tcp_utils.go +++ b/business/jxstore/event/event_tcp_utils.go @@ -37,6 +37,9 @@ const ( printerStatusOnlineWithoutPaper = 2 //在线缺纸 printerStatusOnline = 1 //在线 printerStatusOffline = -1 //离线 + + PrintSoundMaxNumber = 16 // 十六进制最大补位 + PlaceFillingParam = "0" // 补位参数 ) //标签 @@ -487,7 +490,11 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) { soundNum, _ := hex.DecodeString(v) // 十六进制转字符串 intSound, _ := strconv.ParseInt(string(soundNum), 10, 64) int16Sound := strconv.FormatInt(intSound, 16) - voice += int16Sound + if intSound < PrintSoundMaxNumber { // 小于十六补位 + voice += PlaceFillingParam + int16Sound + } else { + voice += int16Sound + } } result = strings.ReplaceAll(result, sound, "") result = strings.ReplaceAll(result, byteSignSound, hexSignSoundSolidification+voice) diff --git a/business/jxstore/event/print_test.go b/business/jxstore/event/print_test.go index 230bec4fa..9241ec03c 100644 --- a/business/jxstore/event/print_test.go +++ b/business/jxstore/event/print_test.go @@ -5,6 +5,7 @@ import ( "fmt" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/model" + "strconv" "testing" ) @@ -13,7 +14,7 @@ func TestPrintMsg(t *testing.T) { msg := &model.PrintMsg{ ModelIDCULD: model.ModelIDCULD{}, PrintNo: "20220707000002", - Content: "21", + Content: "10", OrderNo: 202207261655, Status: 0, Comment: "", @@ -44,7 +45,14 @@ func Test10Two16(t *testing.T) { } func TestCheckSum(t *testing.T) { - aa := getCheckSum(``) - fmt.Println(aa) - + soundNum, _ := hex.DecodeString("3130") // 十六进制转字符串 + intSound, _ := strconv.ParseInt(string(soundNum), 10, 64) + int16Sound := strconv.FormatInt(intSound, 16) + b := strconv.FormatInt(16, 16) + if int16Sound < b { + fmt.Println("111111") + } else { + fmt.Println("22222") + } + fmt.Println("==========", int16Sound) }