From 02a84fb6fb2a39bfe7fc5cf6c0137bbf231b17fe Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 09 十一月 2023 14:14:17 +0800
Subject: [PATCH] 设备列表返回是否设置工艺参数字段

---
 service/problem/check.go |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/service/problem/check.go b/service/problem/check.go
index b379b7b..e91272c 100644
--- a/service/problem/check.go
+++ b/service/problem/check.go
@@ -6,7 +6,6 @@
 	"apsClient/model"
 	"apsClient/pkg/sqlitex"
 	"apsClient/service"
-	"apsClient/service/plc_address"
 	"fmt"
 	"net"
 	"sync"
@@ -17,7 +16,7 @@
 	constvar.ProblemCodeNetwork,
 	constvar.ProblemCodeDB,
 	constvar.ProblemCodeSerf,
-	constvar.ProblemCodeNsq,
+	constvar.ProblemCodeCloud,
 	constvar.ProblemCodeDevice,
 	constvar.ProblemCodeProcessModel,
 	constvar.ProblemCodePlcConfig,
@@ -30,7 +29,7 @@
 	constvar.ProblemCodeNetwork:                    "缃戠粶杩炴帴",
 	constvar.ProblemCodeDB:                         "鏁版嵁搴�",
 	constvar.ProblemCodeSerf:                       "serf闆嗙兢",
-	constvar.ProblemCodeNsq:                        "娑堟伅闃熷垪",
+	constvar.ProblemCodeCloud:                      "娑堟伅闃熷垪",
 	constvar.ProblemCodeDevice:                     "鐢熶骇璁惧缁戝畾",
 	constvar.ProblemCodeProcessModel:               "宸ヨ壓鍙傛暟",
 	constvar.ProblemCodePlcConfig:                  "plc閰嶇疆",
@@ -61,7 +60,7 @@
 			checkObj = &DB{}
 		case constvar.ProblemCodeSerf:
 			checkObj = &Serf{}
-		case constvar.ProblemCodeNsq:
+		case constvar.ProblemCodeCloud:
 			checkObj = &Nsq{}
 		case constvar.ProblemCodeDevice:
 			checkObj = &Device{}
@@ -168,6 +167,9 @@
 
 func (slf *PlcConfig) Check() bool {
 	plcConfig, _ := service.NewDevicePlcService().GetDevicePlc()
+	if plcConfig == nil {
+		return false
+	}
 	if plcConfig.Method == "" {
 		return false
 	}
@@ -188,13 +190,20 @@
 
 func (slf *PlcAddressList) Check() bool {
 	plcConfig, _ := service.NewDevicePlcService().GetDevicePlc()
-	return len(plcConfig.Details) > 0
+	return plcConfig != nil && len(plcConfig.Details) > 0
 }
 
 type PlcProcessModelAddressList struct{}
 
 func (slf *PlcProcessModelAddressList) Check() bool {
-	return plc_address.IsLoad()
+	record, err := model.NewProcessModelPlcAddressSearch().SetDeviceID(conf.Conf.CurrentDeviceID).First()
+	if err != nil {
+		return false
+	}
+	if len(record.AddressList) == 0 {
+		return false
+	}
+	return true
 }
 
 type PlcConnect struct{}

--
Gitblit v1.8.0