From 2ea23e2364f742f528fb8b97657212c174d1bbd7 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 21 十月 2023 14:06:59 +0800
Subject: [PATCH] 增加切换serf状态接口(调试用)

---
 nsq/msg_handler.go |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/nsq/msg_handler.go b/nsq/msg_handler.go
index d0cea52..63a0e9d 100644
--- a/nsq/msg_handler.go
+++ b/nsq/msg_handler.go
@@ -297,7 +297,7 @@
 	}
 	detail, err := json.Marshal(record.Details)
 	record.Detail = string(detail)
-
+	record.DeviceID = msg.ID
 	oldPlcRecord, err := model.NewDevicePlcSearch().SetDeviceId(msg.ID).First()
 	if err == gorm.ErrRecordNotFound {
 		err = model.NewDevicePlcSearch().Create(&record)
@@ -305,7 +305,12 @@
 		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