This commit is contained in:
邹宗楠
2022-08-04 18:27:23 +08:00
parent 2451d1ca29
commit 84e54bf4d7
2 changed files with 10 additions and 9 deletions

View File

@@ -222,12 +222,6 @@ func (t *TcpClient) doPrint(key string) (err error) {
case printerStatusOnline:
if c = t.getPrintConn(printMsg.PrintNo); c != nil {
data, err = buildMsg(printMsg)
encryption := ""
for _, v := range data {
encryption += fmt.Sprintf("%d", v)
}
printMsg.ContentEncryption = encryption
dao.UpdateEntity(db, printMsg, "ContentEncryption")
}
case printerStatusOffline:
err = fmt.Errorf("打印机离线!")
@@ -246,6 +240,13 @@ func (t *TcpClient) doPrint(key string) (err error) {
close(t.TimeoutMap[key])
} else {
if c != nil {
encryption := ""
for _, v := range data {
encryption += fmt.Sprintf("%d", v)
}
printMsg.ContentEncryption = encryption
dao.UpdateEntity(db, printMsg, "ContentEncryption")
if _, err = c.Write(data); err != nil {
globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err)
//t.delConn(printMsg.PrintNo)

View File

@@ -52,9 +52,9 @@ func Init() {
orm.RegisterModel(&model.WithdrawalRecord{}) // 提现申请
} else {
orm.RegisterDataBase("default", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true")
//打印机
orm.RegisterModel(&model.PrintMsg{})
orm.RegisterModel(&model.Printer{})
// 打印机,迁移至api做
//orm.RegisterModel(&model.PrintMsg{})
//orm.RegisterModel(&model.Printer{})
}
// create table
orm.RunSyncdb("default", false, true)