From 1de287f0bc06923ca3874f33b3aef1e339a34e30 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期六, 21 十月 2023 12:49:57 +0800 Subject: [PATCH] fix --- nsq/msg_handler.go | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nsq/msg_handler.go b/nsq/msg_handler.go index 00d7edd..63a0e9d 100644 --- a/nsq/msg_handler.go +++ b/nsq/msg_handler.go @@ -299,15 +299,18 @@ record.Detail = string(detail) record.DeviceID = msg.ID oldPlcRecord, err := model.NewDevicePlcSearch().SetDeviceId(msg.ID).First() - logx.Errorf("-------------------------------plc record not found:%v", err) if err == gorm.ErrRecordNotFound { - logx.Errorf("-------------------------------plc record not found:%v", err) err = model.NewDevicePlcSearch().Create(&record) } else if record.Port != oldPlcRecord.Port || record.Method != oldPlcRecord.Method || record.Address != oldPlcRecord.Address || record.Detail != oldPlcRecord.Detail { - err = model.NewDevicePlcSearch().SetDeviceId(msg.ID).Save(&record) + + oldPlcRecord.Port = record.Port + oldPlcRecord.Method = record.Method + oldPlcRecord.Address = record.Address + oldPlcRecord.Detail = record.Detail + err = model.NewDevicePlcSearch().Save(oldPlcRecord) } if err != nil { return err -- Gitblit v1.8.0