Browse Source

add:orm日志配置,小程序传感器接口

zoie 2 years ago
parent
commit
09ada4ad83

+ 1 - 0
.gitignore

@@ -30,6 +30,7 @@ _testmain.go
 /.cache
 .vscode/
 /logs/logx
+/logs/sql
 lastupdate.tmp
 main
 Cold_Api6200

+ 3 - 1
conf/app.conf

@@ -22,6 +22,7 @@ MysqlServer_Username = "cold"
 MysqlServer_Password = "yjwyEckZS7rE5H!"
 MysqlServer_MaxIdleConnections = 100
 MysqlServer_MaxOpenConnections = 200
+MysqlServer_Debug = true
 
 # Redis
 # Redis
@@ -39,4 +40,5 @@ Qiniu_Url = "https://coldoss.coldbaozhida.com/"
 Panel_url = "http://127.0.0.1:6204/Cold_Panel"
 
 FilterExcludeURL = /Login_verification
-FilterOnlyLoginCheckURL = /Menu/List,/User/Info,/User/Home,/User/Post,/UpFileToken,/User/WxQRCode,/Company/Get
+# 小程序接口 /DeviceWarning/DeviceSensor_List,/DeviceSensor/Stat,/DeviceSensor/Stat_List,/DeviceSensorType/List
+FilterOnlyLoginCheckURL = /Menu/List,/User/Info,/User/Home,/User/Post,/UpFileToken,/User/WxQRCode,/Company/Get,/DeviceWarning/DeviceSensor_List,/DeviceSensor/Stat,/DeviceSensor/Stat_List,/DeviceSensorType/List

+ 1 - 0
conf/config.go

@@ -22,6 +22,7 @@ var MysqlServer_Username, _ = beego.AppConfig.String("MysqlServer_Username")
 var MysqlServer_Password, _ = beego.AppConfig.String("MysqlServer_Password")
 var MysqlServer_MaxIdleConnections, _ = beego.AppConfig.Int("MysqlServer_MaxIdleConnections")
 var MysqlServer_MaxOpenConnections, _ = beego.AppConfig.Int("MysqlServer_MaxOpenConnections")
+var MysqlServer_Debug = beego.AppConfig.DefaultBool("MysqlServer_Debug", true)
 
 // Redis
 var Redis_address, _ = beego.AppConfig.String("Redis_address")

+ 8 - 1
controllers/Data.go

@@ -87,14 +87,21 @@ func (c *DataController) Device_Sensor_List() {
 	}
 	T_name := c.GetString("T_name")
 
+	// 数据展示页面
 	T_RealTime, T_RealTime_err := c.GetInt("T_RealTime")
 	if T_RealTime_err != nil {
 		T_RealTime = 0
 	}
 
+	// 轨迹展示页面
+	T_MapShow, T_MapShow_err := c.GetInt("T_MapShow")
+	if T_MapShow_err != nil {
+		T_MapShow = 0
+	}
+
 	var cnt int64
 	Device.Read_DeviceSensorParameter_All_Map("", 0)
-	r_jsons.DeviceSensor_lite, cnt = Device.Read_DeviceSensor_List_For_Data(c.T_pid, T_name, T_Class_id, T_type, T_RealTime, page, page_z)
+	r_jsons.DeviceSensor_lite, cnt = Device.Read_DeviceSensor_List_For_Data(c.T_pid, T_name, T_Class_id, T_type, T_RealTime, T_MapShow, page, page_z)
 
 	page_size := math.Ceil(float64(cnt) / float64(page_z))
 	r_jsons.Page = int(page)

+ 53 - 141
controllers/Device.go

@@ -581,7 +581,6 @@ func (c *DeviceController) DeviceSensor_List() {
 			return
 		}
 	}
-	Device.Read_DeviceSensorParameter_All_Map(T_sn, 0)
 	r_jsons.Data, r_jsons.Num = Device.Read_DeviceSensorList(c.Admin_r, c.T_pid, T_sn, T_name, T_class_id, T_datashow, T_type, T_State, page, page_z)
 	r_jsons.Page = page
 	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
@@ -844,74 +843,6 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() {
 
 }
 
-// 传感器 实时数据显示排序(未使用)
-func (c *DeviceController) UpDeviceSensor_Tsort() {
-
-	Sn := c.GetString("Sn")
-	Id, _ := c.GetInt("Id")
-	T_sort, _ := c.GetInt("T_sort")
-
-	DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
-	if !is {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "信息错误!"}
-		c.ServeJSON()
-		return
-	}
-	DeviceSensor.T_sort = T_sort
-	//c.Data["Device_lite"] = Device.Read_DeviceParameter_SN(Sn)
-	Device.Update_DeviceSensor(DeviceSensor, "T_sort")
-
-	System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "传感器 排序操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]"+strconv.Itoa(T_sort))
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK"}
-	c.ServeJSON()
-	return
-}
-
-// 传感器 3D视图 (未使用)
-func (c *DeviceController) UpDeviceSensor_T3dview() {
-
-	Sn := c.GetString("Sn")
-	Id, _ := c.GetInt("Id")
-	T_3dview := c.GetString("T_3dview")
-
-	DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
-	if !is {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "信息错误!"}
-		c.ServeJSON()
-		return
-	}
-	DeviceSensor.T_3dview = T_3dview
-	//c.Data["Device_lite"] = Device.Read_DeviceParameter_SN(Sn)
-	Device.Update_DeviceSensor(DeviceSensor, "T_3dview")
-
-	System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "3D 视图ID操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]"+T_3dview)
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK"}
-	c.ServeJSON()
-	return
-}
-
-// 传感器 屏蔽数据展示 0 屏蔽数据展示  1 正常数据展示 (未使用)
-func (c *DeviceController) UpDeviceSensor_T_datashow() {
-	Sn := c.GetString("Sn")
-	Id, _ := c.GetInt("Id")
-	T_datashow, _ := c.GetInt("T_datashow")
-
-	DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
-	if !is {
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "信息错误!"}
-		c.ServeJSON()
-		return
-	}
-	DeviceSensor.T_datashow = T_datashow
-
-	Device.Update_DeviceSensor(DeviceSensor, "T_datashow")
-
-	System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "传感器 数据展示(0 屏蔽数据展示  1 正常数据展示)", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]"+strconv.Itoa(T_datashow))
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK"}
-	c.ServeJSON()
-	return
-}
-
 // 传感器管理列表
 func (c *DeviceController) DeviceSensor_Manage_List() {
 
@@ -1342,6 +1273,30 @@ func (c *DeviceController) WarningType_Power_List_All() {
 	return
 }
 
+// 通过传感器类型获取报警列表
+func (c *DeviceController) Read_Warning_List_By_DS_T_type() {
+	var r_jsons lib.R_JSONS
+	page, _ := c.GetInt("page")
+	if page < 1 {
+		page = 1
+	}
+	page_z, _ := c.GetInt("page_z")
+	if page_z < 1 {
+		page_z = conf.Page_size
+	}
+
+	T_type, _ := c.GetInt("T_type")
+	T_name := c.GetString("T_name")
+
+	r_jsons.Data, r_jsons.Num = Warning.Read_Warning_List_By_DS_T_type(c.T_pid, T_type, T_name, page, page_z)
+	r_jsons.Page = page
+	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
+	c.ServeJSON()
+	return
+}
+
 // 设备分类 ------------------------------------------
 func (c *DeviceController) CompanyClass_List() {
 	type R_JSONS struct {
@@ -2048,26 +2003,41 @@ func (c *DeviceController) DeviceSensorType_List() {
 // 传感器统计 - 小程序
 func (c *DeviceController) DeviceSensor_Stat() {
 
-	type Monitor struct {
-		Count       int64
-		Monitor     int64
-		Unmonitored int64
-		NoNetwork   int64
+	type Online struct {
+		Count      int64
+		Online     int64 // 监控
+		NoNetwork  int64 // 无网络
+		NotEnabled int64 // 未启用
 	}
 
 	type R_JSONS struct {
 		//必须的大写开头
-		Data      interface{}
-		Monitor   Monitor
-		Num       int64
-		Page      int
-		Page_size int
+		Data Online
+	}
+
+	T_type, T_type_err := c.GetInt("T_type")
+	if T_type_err != nil {
+		T_type = -1
 	}
 
-	var monitor Monitor
-	var monitorList, unmonitoredList, noNetworkList []Device.DeviceSensor_R
 	var r_jsons R_JSONS
 
+	// 0 未启用  1 在线  2 离线
+	r_jsons.Data.Count = Device.Read_DeviceSensor_Count_ByT_online(c.T_pid, T_type, "")
+	r_jsons.Data.Online = Device.Read_DeviceSensor_Count_ByT_online(c.T_pid, T_type, "1")
+	r_jsons.Data.NoNetwork = Device.Read_DeviceSensor_Count_ByT_online(c.T_pid, T_type, "2")
+	r_jsons.Data.NotEnabled = Device.Read_DeviceSensor_Count_ByT_online(c.T_pid, T_type, "0")
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
+	c.ServeJSON()
+	return
+}
+
+// 传感器列表 - 小程序
+func (c *DeviceController) DeviceSensor_Stat_List() {
+
+	var r_jsons lib.R_JSONS
+
 	page, _ := c.GetInt("page")
 	if page < 1 {
 		page = 1
@@ -2078,70 +2048,12 @@ func (c *DeviceController) DeviceSensor_Stat() {
 	}
 
 	T_name := c.GetString("T_name")
-	T_monitor, _ := c.GetInt("T_monitor")
-
+	T_online := c.GetString("T_online")
 	T_type, T_type_err := c.GetInt("T_type")
 	if T_type_err != nil {
 		T_type = -1
 	}
-
-	list, num := Device.Read_DeviceSensor_List_For_Stat(c.T_pid, T_name, T_type)
-	monitor.Count = num
-	for _, v := range list {
-		// 0 未监控 1 监控 2 无网络
-		switch v.T_monitor {
-		case 0:
-			monitor.Unmonitored += 1
-			unmonitoredList = append(unmonitoredList, v)
-		case 1:
-			monitor.Monitor += 1
-			monitorList = append(monitorList, v)
-		case 2:
-			monitor.NoNetwork += 1
-			noNetworkList = append(noNetworkList, v)
-		}
-	}
-
-	var offset_z int
-	offset := conf.Page_size
-	if page <= 1 {
-		offset = 0
-	} else {
-		page -= 1
-		offset = page * page_z
-	}
-
-	offset_z = offset + page_z
-
-	// 0 未监控 1 监控 2 无网络
-	switch T_monitor {
-	case 0:
-		r_jsons.Num = monitor.Unmonitored
-		if r_jsons.Num < int64(offset_z) {
-			offset_z = int(r_jsons.Num)
-		}
-		r_jsons.Data = unmonitoredList[offset:offset_z]
-	case 1:
-		r_jsons.Num = monitor.Monitor
-		if r_jsons.Num < int64(offset_z) {
-			offset_z = int(r_jsons.Num)
-		}
-		r_jsons.Data = monitorList[offset:offset_z]
-	case 2:
-		r_jsons.Num = monitor.NoNetwork
-		if r_jsons.Num < int64(offset_z) {
-			offset_z = int(r_jsons.Num)
-		}
-		r_jsons.Data = noNetworkList[offset:offset_z]
-	case 3:
-		r_jsons.Num = monitor.Count
-		if r_jsons.Num < int64(offset_z) {
-			offset_z = int(r_jsons.Num)
-		}
-		r_jsons.Data = list[offset:offset_z]
-	}
-
-	r_jsons.Monitor = monitor
+	r_jsons.Data, r_jsons.Num = Device.Read_DeviceSensor_List_For_Stat(c.T_pid, T_name, T_online, 1, T_type, page, page_z)
 	r_jsons.Page = page
 	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
 

+ 29 - 7
controllers/DeviceReal.go

@@ -8,21 +8,43 @@ import (
 )
 
 // 循环刷新
+//func DeviceRealTime() {
+//	fmt.Println("=====================DeviceRealTime GO===============")
+//	time.Sleep(time.Second * 3)
+//	for true {
+//		for k, v := range lib.DeviceRealSnMap {
+//			fmt.Println("DeviceRealSnMap:", k, " num:", v)
+//			NatsServer.Get_Device_Realtime(k)
+//
+//			v--
+//			lib.DeviceRealSnMap[k] = v
+//			if v == 0 {
+//				delete(lib.DeviceRealSnMap, k)
+//			}
+//			time.Sleep(time.Millisecond * 100)
+//		}
+//		time.Sleep(time.Second * 10)
+//
+//	}
+//}
+
 func DeviceRealTime() {
 	fmt.Println("=====================DeviceRealTime GO===============")
 	time.Sleep(time.Second * 3)
 	for true {
-		for k, v := range lib.DeviceRealSnMap {
+		lib.DeviceRealSnMap.Range(func(k, v interface{}) bool {
 			fmt.Println("DeviceRealSnMap:", k, " num:", v)
-			NatsServer.Get_Device_Realtime(k)
+			NatsServer.Get_Device_Realtime(k.(string))
 
-			v--
-			lib.DeviceRealSnMap[k] = v
-			if v == 0 {
-				delete(lib.DeviceRealSnMap, k)
+			temp := v.(int)
+			temp--
+			lib.DeviceRealSnMap.Store(k, temp)
+			if temp == 0 {
+				lib.DeviceRealSnMap.Delete(k)
 			}
 			time.Sleep(time.Millisecond * 100)
-		}
+			return true
+		})
 		time.Sleep(time.Second * 10)
 
 	}

+ 5 - 2
controllers/lib/lib.go

@@ -8,6 +8,7 @@ import (
 	"os"
 	"path/filepath"
 	"runtime"
+	"sync"
 
 	"sort"
 	"strconv"
@@ -17,11 +18,13 @@ import (
 
 var Run_My_Server = false // 运行当期服务
 
-var DeviceRealSnMap map[string]int /*创建集合 */
+// var DeviceRealSnMap map[string]int /*创建集合 */
+var DeviceRealSnMap *sync.Map /*创建集合 */
 var Nats *nats.Conn
 
 func init() {
-	DeviceRealSnMap = make(map[string]int)
+	//DeviceRealSnMap = make(map[string]int)
+	DeviceRealSnMap = new(sync.Map)
 }
 
 type JSONS struct {

+ 3 - 8
logs/LogPrintln.go

@@ -3,24 +3,19 @@ package logs
 import (
 	"Cold_Api/conf"
 	"github.com/astaxie/beego/logs"
-	"runtime"
 )
 
 var logx *logs.BeeLogger
-var Test = true
 
 func init() {
 	logx = logs.NewLogger()
 	logx.SetLogger(logs.AdapterFile, `{"filename":"logs/logx/logx.log"}`)
 	logx.EnableFuncCallDepth(true)
 	logx.SetLogFuncCallDepth(3)
+	logx.SetLevel(logs.LevelInformational)
 	if conf.RunMode == "dev" {
-		logx.SetLogger("console")
-	}
-	if runtime.GOOS == "windows" {
-		Test = true
-	} else {
-		Test = false
+		logx.SetLevel(logs.LevelDebug)
+		logx.SetLogger(logs.AdapterConsole)
 	}
 }
 

+ 0 - 28
logs/logx/logx.2022-11-02.001.log

@@ -1,28 +0,0 @@
-2022/08/30 15:06:08.559 [I]  2022-08-30 15:06:08>%!(EXTRA []interface {}=[============Nats init============])
-2022/08/30 15:06:08.927 [I]  2022-08-30 15:06:08>%!(EXTRA []interface {}=[nats OK!])
-2022/08/30 15:09:28.039 [I]  2022-08-30 15:09:28>%!(EXTRA []interface {}=[============Nats init============])
-2022/08/30 15:09:28.174 [I]  2022-08-30 15:09:28>%!(EXTRA []interface {}=[nats OK!])
-2022/08/30 15:21:11.882 [I]  2022-08-30 15:21:11>%!(EXTRA []interface {}=[============Nats init============])
-2022/08/30 15:21:12.159 [I]  2022-08-30 15:21:12>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 09:13:27.464 [I]  2022-10-24 09:13:27>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 09:13:27.877 [I]  2022-10-24 09:13:27>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 09:15:07.958 [I]  2022-10-24 09:15:07>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 09:15:08.367 [I]  2022-10-24 09:15:08>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 09:30:16.793 [I]  2022-10-24 09:30:16>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 09:30:16.903 [I]  2022-10-24 09:30:16>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 15:41:24.137 [I]  2022-10-24 15:41:24>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 15:41:24.257 [I]  2022-10-24 15:41:24>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 15:52:32.547 [I]  2022-10-24 15:52:32>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 15:52:32.656 [I]  2022-10-24 15:52:32>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 16:02:32.021 [I]  2022-10-24 16:02:32>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 16:02:32.295 [I]  2022-10-24 16:02:32>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 16:03:26.367 [I]  2022-10-24 16:03:26>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 16:03:26.489 [I]  2022-10-24 16:03:26>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 16:06:20.058 [I]  2022-10-24 16:06:20>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 16:06:20.167 [I]  2022-10-24 16:06:20>%!(EXTRA []interface {}=[nats OK!])
-2022/10/24 16:08:00.729 [I]  2022-10-24 16:08:00>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/24 16:08:00.835 [I]  2022-10-24 16:08:00>%!(EXTRA []interface {}=[nats OK!])
-2022/10/31 17:52:37.963 [I]  2022-10-31 17:52:37>%!(EXTRA []interface {}=[============Nats init============])
-2022/10/31 17:52:38.327 [I]  2022-10-31 17:52:38>%!(EXTRA []interface {}=[nats OK!])
-2022/11/01 09:05:37.393 [I]  2022-11-01 09:05:37>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/01 09:05:38.414 [I]  2022-11-01 09:05:38>%!(EXTRA []interface {}=[nats OK!])

+ 0 - 14
logs/logx/logx.2022-11-04.001.log

@@ -1,14 +0,0 @@
-2022/11/03 14:07:47.881 [I]  2022-11-03 14:07:47>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/03 14:07:48.253 [I]  2022-11-03 14:07:48>%!(EXTRA []interface {}=[nats OK!])
-2022/11/03 14:14:05.303 [I]  2022-11-03 14:14:05>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/03 14:14:05.422 [I]  2022-11-03 14:14:05>%!(EXTRA []interface {}=[nats OK!])
-2022/11/03 14:14:51.528 [I]  2022-11-03 14:14:51>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/03 14:14:51.647 [I]  2022-11-03 14:14:51>%!(EXTRA []interface {}=[nats OK!])
-2022/11/03 14:17:57.593 [I]  2022-11-03 14:17:57>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/03 14:17:57.712 [I]  2022-11-03 14:17:57>%!(EXTRA []interface {}=[nats OK!])
-2022/11/03 14:22:28.032 [I]  2022-11-03 14:22:28>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/03 14:22:28.148 [I]  2022-11-03 14:22:28>%!(EXTRA []interface {}=[nats OK!])
-2022/11/03 14:25:25.342 [I]  2022-11-03 14:25:25>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/03 14:25:25.458 [I]  2022-11-03 14:25:25>%!(EXTRA []interface {}=[nats OK!])
-2022/11/03 14:34:06.765 [I]  2022-11-03 14:34:06>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/03 14:34:06.881 [I]  2022-11-03 14:34:06>%!(EXTRA []interface {}=[nats OK!])

+ 0 - 283
logs/logx/logx.log

@@ -1,283 +0,0 @@
-2022/11/08 16:34:07.640 [I]  2022-11-08 16:34:07>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/08 16:34:07.925 [I]  2022-11-08 16:34:07>%!(EXTRA []interface {}=[nats OK!])
-2022/11/08 16:34:36.861 [I]  2022-11-08 16:34:36>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/08 16:34:36.984 [I]  2022-11-08 16:34:36>%!(EXTRA []interface {}=[nats OK!])
-2022/11/08 16:50:12.010 [I]  2022-11-08 16:50:12>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/08 16:50:12.134 [I]  2022-11-08 16:50:12>%!(EXTRA []interface {}=[nats OK!])
-2022/11/11 16:04:30.932 [I]  2022-11-11 16:04:30>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/11 16:04:32.106 [I]  2022-11-11 16:04:32>%!(EXTRA []interface {}=[nats OK!])
-2022/11/14 09:54:56.828 [I]  2022-11-14 09:54:56>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/14 09:54:57.757 [I]  2022-11-14 09:54:57>%!(EXTRA []interface {}=[nats OK!])
-2022/11/14 09:55:59.235 [I]  2022-11-14 09:55:59>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/14 09:55:59.378 [I]  2022-11-14 09:55:59>%!(EXTRA []interface {}=[nats OK!])
-2022/11/16 15:35:09.590 [I]  2022-11-16 15:35:09>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/16 15:35:09.990 [I]  2022-11-16 15:35:09>%!(EXTRA []interface {}=[nats OK!])
-2022/11/18 16:02:46.940 [I]  2022-11-18 16:02:46>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/18 16:03:33.805 [I]  2022-11-18 16:03:33>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 15:22:27.153 [I]  2022-11-22 15:22:27>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 15:24:42.241 [I]  2022-11-22 15:24:42>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 15:24:42.441 [I]  2022-11-22 15:24:42>%!(EXTRA []interface {}=[nats OK!])
-2022/11/22 15:29:49.210 [I]  2022-11-22 15:29:49>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 15:29:49.354 [I]  2022-11-22 15:29:49>%!(EXTRA []interface {}=[nats OK!])
-2022/11/22 15:36:37.210 [I]  2022-11-22 15:36:37>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 15:36:37.419 [I]  2022-11-22 15:36:37>%!(EXTRA []interface {}=[nats OK!])
-2022/11/22 15:46:45.760 [I]  2022-11-22 15:46:45>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 15:52:00.878 [I]  2022-11-22 15:52:00>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 15:52:01.008 [I]  2022-11-22 15:52:01>%!(EXTRA []interface {}=[nats OK!])
-2022/11/22 15:54:36.101 [I]  2022-11-22 15:54:36>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 15:54:36.224 [I]  2022-11-22 15:54:36>%!(EXTRA []interface {}=[nats OK!])
-2022/11/22 16:12:45.151 [I]  2022-11-22 16:12:45>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 16:12:45.279 [I]  2022-11-22 16:12:45>%!(EXTRA []interface {}=[nats OK!])
-2022/11/22 16:21:06.629 [I]  2022-11-22 16:21:06>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/22 16:21:06.808 [I]  2022-11-22 16:21:06>%!(EXTRA []interface {}=[nats OK!])
-2022/11/23 11:15:10.751 [I]  2022-11-23 11:15:10>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/23 11:15:10.928 [I]  2022-11-23 11:15:10>%!(EXTRA []interface {}=[nats OK!])
-2022/11/24 15:53:09.012 [I]  2022-11-24 15:53:09>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/24 15:54:07.450 [I]  2022-11-24 15:54:07>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/24 15:54:41.759 [I]  2022-11-24 15:54:41>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/24 15:54:41.760 [I]  2022-11-24 15:54:41>%!(EXTRA []interface {}=[nats OK!])
-2022/11/24 15:54:41.847 [I]  2022-11-24 15:54:41>%!(EXTRA []interface {}=[{"key":"redis_PaneView","conn":"47.111.15.17:6379","dbNum":"1","password":""}])
-2022/11/24 15:54:41.934 [I]  2022-11-24 15:54:41>%!(EXTRA []interface {}=[{"key":"redis_ConfigImg","conn":"47.111.15.17:6379","dbNum":"1","password":""}])
-2022/11/24 15:54:42.023 [I]  2022-11-24 15:54:42>%!(EXTRA []interface {}=[{"key":"redis_PanelLayerMould","conn":"47.111.15.17:6379","dbNum":"1","password":""}])
-2022/11/24 15:54:42.115 [I]  2022-11-24 15:54:42>%!(EXTRA []interface {}=[{"key":"redis_PanelTool","conn":"47.111.15.17:6379","dbNum":"1","password":""}])
-2022/11/24 15:54:42.202 [I]  2022-11-24 15:54:42>%!(EXTRA []interface {}=[{"key":"redis_ConfiglibImg","conn":"47.111.15.17:6379","dbNum":"1","password":""}])
-2022/11/24 16:12:21.433 [I]  2022-11-24 16:12:21>%!(EXTRA []interface {}=[============Nats init============])
-2022/11/24 16:12:21.434 [I]  2022-11-24 16:12:21>%!(EXTRA []interface {}=[nats OK!])
-2022/12/02 10:40:57.476 [I]  2022-12-02 10:40:57>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/02 10:40:57.478 [I]  2022-12-02 10:40:57>%!(EXTRA []interface {}=[nats OK!])
-2022/12/02 10:41:13.811 [I]  2022-12-02 10:41:13>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/02 10:41:13.812 [I]  2022-12-02 10:41:13>%!(EXTRA []interface {}=[nats OK!])
-2022/12/12 15:03:04.411 [I]  2022-12-12 15:03:04>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/12 15:03:35.374 [I]  2022-12-12 15:03:35>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/12 15:03:35.376 [I]  2022-12-12 15:03:35>%!(EXTRA []interface {}=[nats OK!])
-2022/12/12 15:07:32.062 [I]  2022-12-12 15:07:32>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/12 15:07:32.063 [I]  2022-12-12 15:07:32>%!(EXTRA []interface {}=[nats OK!])
-2022/12/12 15:11:03.396 [I]  2022-12-12 15:11:03>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:11:13.509 [I]  2022-12-12 15:11:13>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:11:23.622 [I]  2022-12-12 15:11:23>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:11:33.741 [I]  2022-12-12 15:11:33>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:11:43.863 [I]  2022-12-12 15:11:43>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:11:53.979 [I]  2022-12-12 15:11:53>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:12:04.101 [I]  2022-12-12 15:12:04>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:12:14.218 [I]  2022-12-12 15:12:14>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:12:24.329 [I]  2022-12-12 15:12:24>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:12:34.454 [I]  2022-12-12 15:12:34>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:12:44.571 [I]  2022-12-12 15:12:44>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:12:54.693 [I]  2022-12-12 15:12:54>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:13:04.815 [I]  2022-12-12 15:13:04>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:13:14.924 [I]  2022-12-12 15:13:14>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:13:25.049 [I]  2022-12-12 15:13:25>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:13:35.162 [I]  2022-12-12 15:13:35>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:13:45.272 [I]  2022-12-12 15:13:45>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:13:55.384 [I]  2022-12-12 15:13:55>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:14:05.506 [I]  2022-12-12 15:14:05>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:14:15.622 [I]  2022-12-12 15:14:15>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:14:25.736 [I]  2022-12-12 15:14:25>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:14:35.860 [I]  2022-12-12 15:14:35>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:14:45.977 [I]  2022-12-12 15:14:45>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:14:56.085 [I]  2022-12-12 15:14:56>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:15:06.212 [I]  2022-12-12 15:15:06>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:15:16.322 [I]  2022-12-12 15:15:16>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:15:26.444 [I]  2022-12-12 15:15:26>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:15:36.560 [I]  2022-12-12 15:15:36>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:15:46.668 [I]  2022-12-12 15:15:46>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:15:56.791 [I]  2022-12-12 15:15:56>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:16:06.902 [I]  2022-12-12 15:16:06>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:16:17.018 [I]  2022-12-12 15:16:17>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:16:27.132 [I]  2022-12-12 15:16:27>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:16:37.242 [I]  2022-12-12 15:16:37>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:16:47.354 [I]  2022-12-12 15:16:47>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:16:57.477 [I]  2022-12-12 15:16:57>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:17:07.590 [I]  2022-12-12 15:17:07>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:17:17.706 [I]  2022-12-12 15:17:17>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:17:27.827 [I]  2022-12-12 15:17:27>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:17:37.939 [I]  2022-12-12 15:17:37>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:17:48.056 [I]  2022-12-12 15:17:48>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:17:58.169 [I]  2022-12-12 15:17:58>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:18:08.291 [I]  2022-12-12 15:18:08>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:18:18.405 [I]  2022-12-12 15:18:18>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:18:28.515 [I]  2022-12-12 15:18:28>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:18:38.627 [I]  2022-12-12 15:18:38>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:18:48.748 [I]  2022-12-12 15:18:48>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:18:58.867 [I]  2022-12-12 15:18:58>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:19:09.004 [I]  2022-12-12 15:19:09>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:19:19.116 [I]  2022-12-12 15:19:19>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:19:29.232 [I]  2022-12-12 15:19:29>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:19:39.349 [I]  2022-12-12 15:19:39>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:19:49.467 [I]  2022-12-12 15:19:49>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:19:59.589 [I]  2022-12-12 15:19:59>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:20:09.703 [I]  2022-12-12 15:20:09>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:20:19.824 [I]  2022-12-12 15:20:19>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:20:29.938 [I]  2022-12-12 15:20:29>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:20:40.055 [I]  2022-12-12 15:20:40>%!(EXTRA []interface {}=[Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime ])
-2022/12/12 15:20:49.338 [I]  2022-12-12 15:20:49>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/12 15:20:49.339 [I]  2022-12-12 15:20:49>%!(EXTRA []interface {}=[nats OK!])
-2022/12/12 15:28:03.992 [I]  2022-12-12 15:28:03>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/12 15:28:03.993 [I]  2022-12-12 15:28:03>%!(EXTRA []interface {}=[nats OK!])
-2022/12/12 15:33:17.413 [I]  2022-12-12 15:33:17>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/12 15:33:17.414 [I]  2022-12-12 15:33:17>%!(EXTRA []interface {}=[nats OK!])
-2022/12/12 16:39:53.509 [I]  2022-12-12 16:39:53>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/12 16:39:53.510 [I]  2022-12-12 16:39:53>%!(EXTRA []interface {}=[nats OK!])
-2022/12/12 17:02:38.394 [I]  2022-12-12 17:02:38>%!(EXTRA []interface {}=[============Nats init============])
-2022/12/12 17:02:38.395 [I]  2022-12-12 17:02:38>%!(EXTRA []interface {}=[nats OK!])
-2022/12/27 11:58:17.428 [I]  2022-12-27 11:58:17>%!(EXTRA []interface {}=[============Nats init============])
-2023/01/09 15:32:48.609 [I]  2023-01-09 15:32:48>%!(EXTRA []interface {}=[============Nats init============])
-2023/01/09 15:57:55.073 [I]  2023-01-09 15:57:55>%!(EXTRA []interface {}=[============Nats init============])
-2023/01/09 15:57:55.225 [I]  2023-01-09 15:57:55>%!(EXTRA []interface {}=[nats OK!])
-2023/01/09 15:58:48.999 [I]  2023-01-09 15:58:48>%!(EXTRA []interface {}=[============Nats init============])
-2023/01/09 15:58:50.065 [I]  2023-01-09 15:58:50>%!(EXTRA []interface {}=[nats OK!])
-2023/01/09 15:59:48.113 [I]  2023-01-09 15:59:48>%!(EXTRA []interface {}=[============Nats init============])
-2023/01/09 16:03:29.794 [I]  2023-01-09 16:03:29>%!(EXTRA []interface {}=[============Nats init============])
-2023/01/09 16:03:30.542 [I]  2023-01-09 16:03:30>%!(EXTRA []interface {}=[nats OK!])
-2023/01/09 16:04:24.546 [I]  2023-01-09 16:04:24>%!(EXTRA []interface {}=[============Nats init============])
-2023/01/09 16:04:25.751 [I]  2023-01-09 16:04:25>%!(EXTRA []interface {}=[nats OK!])
-2023/01/18 16:04:58.471 [I]  2023-01-18 16:04:58>%!(EXTRA []interface {}=[============Nats init============])
-2023/01/18 16:04:58.501 [I]  2023-01-18 16:04:58>%!(EXTRA []interface {}=[nats OK!])
-2023/02/22 11:37:56.577 [I] [Nats.go:22]  ============Nats init============
-2023/02/22 11:37:56.591 [I] [Nats.go:30]  nats OK!
-2023/02/22 11:37:56.755 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/22 11:37:57.302 [I] [ProductType.go:67]  =========== 初始化产品类型 =========
-2023/02/22 11:37:58.755 [I] [WarningType.go:165]  =========== 初始化报警类型 =========
-2023/02/22 11:46:04.144 [I] [Nats.go:22]  ============Nats init============
-2023/02/22 11:46:04.162 [I] [Nats.go:30]  nats OK!
-2023/02/22 11:46:04.360 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/22 11:46:05.046 [I] [ProductType.go:67]  =========== 初始化产品类型 =========
-2023/02/22 11:46:06.359 [I] [WarningType.go:165]  =========== 初始化报警类型 =========
-2023/02/22 11:47:02.938 [I] [Nats.go:22]  ============Nats init============
-2023/02/22 11:47:02.974 [I] [Nats.go:30]  nats OK!
-2023/02/22 11:47:03.143 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/22 11:47:03.826 [I] [ProductType.go:67]  =========== 初始化产品类型 =========
-2023/02/22 11:47:05.142 [I] [WarningType.go:165]  =========== 初始化报警类型 =========
-2023/02/22 12:41:46.085 [I] [Nats.go:22]  ============Nats init============
-2023/02/22 12:41:46.109 [I] [Nats.go:30]  nats OK!
-2023/02/22 12:41:46.212 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/22 12:41:46.945 [I] [ProductType.go:67]  =========== 初始化产品类型 =========
-2023/02/22 12:41:48.210 [I] [WarningType.go:165]  =========== 初始化报警类型 =========
-2023/02/22 12:43:16.752 [I] [User.go:1067]  登录用户 菜单 pid 为:%!(EXTRA int=33)
-2023/02/22 12:44:02.172 [I] [Nats.go:22]  ============Nats init============%!(EXTRA []interface {}=[])
-2023/02/22 12:44:02.198 [I] [Nats.go:30]  nats OK!%!(EXTRA []interface {}=[])
-2023/02/22 12:44:02.296 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========%!(EXTRA []interface {}=[])
-2023/02/22 12:44:03.079 [I] [ProductType.go:67]  =========== 初始化产品类型 =========%!(EXTRA []interface {}=[])
-2023/02/22 12:44:04.295 [I] [WarningType.go:165]  =========== 初始化报警类型 =========%!(EXTRA []interface {}=[])
-2023/02/22 12:45:24.310 [I] [Nats.go:22]  %!(EXTRA []interface {}=[============Nats init============])
-2023/02/22 12:45:24.360 [I] [Nats.go:30]  %!(EXTRA []interface {}=[nats OK!])
-2023/02/22 12:45:24.482 [I] [filter.go:21]  %!(EXTRA []interface {}=[=========== 初始化路由筛选信息 =========])
-2023/02/22 12:45:25.086 [I] [ProductType.go:67]  %!(EXTRA []interface {}=[=========== 初始化产品类型 =========])
-2023/02/22 12:45:26.481 [I] [WarningType.go:165]  %!(EXTRA []interface {}=[=========== 初始化报警类型 =========])
-2023/02/22 12:46:01.408 [I] [Nats.go:22]  [============Nats init============]
-2023/02/22 12:46:01.443 [I] [Nats.go:30]  [nats OK!]
-2023/02/22 12:46:01.587 [I] [filter.go:21]  [=========== 初始化路由筛选信息 =========]
-2023/02/22 12:46:02.321 [I] [ProductType.go:67]  [=========== 初始化产品类型 =========]
-2023/02/22 12:46:03.586 [I] [WarningType.go:165]  [=========== 初始化报警类型 =========]
-2023/02/22 12:46:34.017 [I] [Nats.go:22]  [============Nats init============]
-2023/02/22 12:46:34.084 [I] [Nats.go:30]  [nats OK!]
-2023/02/22 12:46:34.215 [I] [filter.go:21]  [=========== 初始化路由筛选信息 =========]
-2023/02/22 12:46:34.919 [I] [ProductType.go:67]  [=========== 初始化产品类型 =========]
-2023/02/22 12:46:36.213 [I] [WarningType.go:165]  [=========== 初始化报警类型 =========]
-2023/02/22 12:47:05.585 [I] [Nats.go:22]  ============Nats init============
-2023/02/22 12:47:05.675 [I] [Nats.go:30]  nats OK!
-2023/02/22 12:47:05.766 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/22 12:47:06.432 [I] [ProductType.go:67]  =========== 初始化产品类型 =========
-2023/02/22 12:47:07.766 [I] [WarningType.go:165]  =========== 初始化报警类型 =========
-2023/02/22 12:47:32.818 [I] [User.go:1067]  登录用户 菜单 pid 为:%!(EXTRA int=33)
-2023/02/22 12:50:11.570 [I] [Nats.go:22]  %!(EXTRA string=============Nats init============)
-2023/02/22 12:50:11.585 [I] [Nats.go:30]  nats OK!
-2023/02/22 12:50:11.657 [I] [filter.go:21]  %!(EXTRA string============ 初始化路由筛选信息 =========)
-2023/02/22 12:50:12.440 [I] [ProductType.go:67]  %!(EXTRA string============ 初始化产品类型 =========)
-2023/02/22 12:50:13.656 [I] [WarningType.go:165]  %!(EXTRA string============ 初始化报警类型 =========)
-2023/02/22 12:53:11.535 [I] [Nats.go:22]  2023-02-22 12:53:11>%!(EXTRA []interface {}=[============Nats init============])
-2023/02/22 12:53:11.556 [I] [Nats.go:30]  2023-02-22 12:53:11>%!(EXTRA []interface {}=[nats OK!])
-2023/02/22 12:53:11.715 [I] [filter.go:21]  2023-02-22 12:53:11>%!(EXTRA []interface {}=[=========== 初始化路由筛选信息 =========])
-2023/02/22 12:53:12.425 [I] [ProductType.go:67]  2023-02-22 12:53:12>%!(EXTRA []interface {}=[=========== 初始化产品类型 =========])
-2023/02/22 12:53:13.714 [I] [WarningType.go:165]  2023-02-22 12:53:13>%!(EXTRA []interface {}=[=========== 初始化报警类型 =========])
-2023/02/23 16:24:45.456 [I] [Nats.go:22]  ============Nats init============
-2023/02/23 16:24:45.474 [I] [Nats.go:30]  nats OK!
-2023/02/23 16:24:45.653 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/23 16:24:47.653 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/23 16:24:48.303 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/23 17:24:47.735 [E] [WarningType.go:196]  Cold_Api/models/Warning.Read_WarningType_All_Maps dial tcp 127.0.0.1:40306: connect: connection refused
-2023/02/23 17:24:48.406 [E] [ProductType.go:76]  Cold_Api/models/Product.Read_ProductType_All_Map dial tcp 127.0.0.1:40306: connect: connection refused
-2023/02/24 10:40:01.903 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 10:40:02.003 [I] [Nats.go:30]  nats OK!
-2023/02/24 10:40:02.182 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 10:40:04.181 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 10:40:04.611 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 10:58:55.665 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 10:58:55.692 [I] [Nats.go:30]  nats OK!
-2023/02/24 10:58:55.835 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 10:58:57.835 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 10:58:58.212 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 11:04:38.395 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 11:04:38.505 [I] [Nats.go:30]  nats OK!
-2023/02/24 11:04:38.593 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 11:04:40.593 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 11:04:41.275 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 11:06:00.565 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 11:06:00.580 [I] [Nats.go:30]  nats OK!
-2023/02/24 11:06:00.659 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 11:06:02.659 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 11:06:03.498 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 11:59:16.174 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 11:59:16.209 [I] [Nats.go:30]  nats OK!
-2023/02/24 11:59:16.275 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 11:59:18.275 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 11:59:19.016 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 12:02:47.453 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /private/var/folders/05/2mhb7py53cn_pkgr00xfjh9c0000gn/T/GoLand/ofile/20230224120247.xlsx ofile/20230224120247.xlsx
-2023/02/24 12:02:47.461 [I] [NatsQiniu.go:109]  七牛云 上传文件失败/private/var/folders/05/2mhb7py53cn_pkgr00xfjh9c0000gn/T/GoLand/ofile/20230224120247.xlsx open /private/var/folders/05/2mhb7py53cn_pkgr00xfjh9c0000gn/T/GoLand/ofile/20230224120247.xlsx: no such file or directory
-2023/02/24 12:05:26.251 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 12:05:26.283 [I] [Nats.go:30]  nats OK!
-2023/02/24 12:05:26.466 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 12:05:28.465 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 12:05:29.161 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 12:05:41.963 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224120541.xlsx ofile/20230224120541.xlsx
-2023/02/24 12:08:19.859 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 12:08:19.887 [I] [Nats.go:30]  nats OK!
-2023/02/24 12:08:20.031 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 12:08:22.031 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 12:08:22.687 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 12:08:31.278 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224120831.xlsx ofile/20230224120831.xlsx
-2023/02/24 12:10:30.039 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121029.xlsx ofile/20230224121029.xlsx
-2023/02/24 12:11:13.868 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121113.xlsx ofile/20230224121113.xlsx
-2023/02/24 12:12:48.955 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121248.xlsx ofile/20230224121248.xlsx
-2023/02/24 12:13:13.070 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121313.xlsx ofile/20230224121313.xlsx
-2023/02/24 12:16:01.027 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121600.xlsx ofile/20230224121600.xlsx
-2023/02/24 12:18:30.420 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 12:18:30.450 [I] [Nats.go:30]  nats OK!
-2023/02/24 12:18:30.685 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 12:18:32.685 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 12:18:33.246 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 12:18:42.875 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121842.xlsx ofile/20230224121842.xlsx
-2023/02/24 12:20:06.870 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224122006.xlsx ofile/20230224122006.xlsx
-2023/02/24 12:29:53.475 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
-2023/02/24 12:30:08.163 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 12:30:44.796 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 12:30:44.807 [I] [Nats.go:30]  nats OK!
-2023/02/24 12:30:44.926 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 12:30:46.925 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 12:30:47.567 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
-2023/02/24 12:31:31.414 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
-2023/02/24 12:31:41.516 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
-2023/02/24 12:31:51.619 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
-2023/02/24 12:32:21.722 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZK
-2023/02/24 12:32:21.823 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023078426071317
-2023/02/24 12:32:21.924 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023063368215572
-2023/02/24 12:32:22.026 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZ1
-2023/02/24 12:32:22.126 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
-2023/02/24 12:32:22.227 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023062759218739
-2023/02/24 12:32:32.329 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023078426071317
-2023/02/24 12:32:32.430 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023063368215572
-2023/02/24 12:32:32.531 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZ1
-2023/02/24 12:32:32.633 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
-2023/02/24 12:32:32.734 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023062759218739
-2023/02/24 12:32:32.837 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZK
-2023/02/24 12:32:42.941 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023063368215572
-2023/02/24 12:32:43.043 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZ1
-2023/02/24 12:32:43.145 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
-2023/02/24 12:32:43.248 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023062759218739
-2023/02/24 12:32:43.350 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZK
-2023/02/24 12:32:43.452 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023078426071317
-2023/02/24 14:17:30.798 [I] [Nats.go:22]  ============Nats init============
-2023/02/24 14:17:30.873 [I] [Nats.go:30]  nats OK!
-2023/02/24 14:17:31.064 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
-2023/02/24 14:17:33.064 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
-2023/02/24 14:17:33.603 [I] [ProductType.go:68]  =========== 初始化产品类型 =========

+ 51 - 0
main.go

@@ -10,8 +10,11 @@ import (
 	"Cold_Api/routers"
 	_ "Cold_Api/routers"
 	"fmt"
+	"github.com/astaxie/beego/logs"
 	"github.com/beego/beego/v2/adapter/orm"
+	orm2 "github.com/beego/beego/v2/client/orm"
 	beego "github.com/beego/beego/v2/server/web"
+	"github.com/beego/beego/v2/server/web/context"
 	"github.com/beego/beego/v2/server/web/filter/cors"
 	_ "github.com/go-sql-driver/mysql"
 	"runtime"
@@ -30,6 +33,19 @@ func init() {
 		conf.MysqlServer_MaxIdleConnections, conf.MysqlServer_MaxOpenConnections)
 	orm.RunSyncdb("default", false, false) // 创建数据库
 	println(conf.MysqlServer_Username + ":" + conf.MysqlServer_Password + "@tcp(" + conf.MysqlServer_UrlPort + ")/" + conf.MysqlServer_Database + "?charset=utf8mb4&loc=Local&parseTime=True")
+	orm2.Debug = conf.MysqlServer_Debug
+
+	// sql文件输出到日志
+	if orm2.Debug == true {
+		sqllog := logs.NewLogger()
+		//sqllog.SetLogger(logs.AdapterFile, `{"filename":"logs/sql/sql.log","level":7,"maxlines":10000,"maxsize":1024000,"daily":true,"maxdays":10,"color":true}`)
+		sqllog.SetLogger(logs.AdapterFile, `{"filename":"logs/sql/sql.log"}`)
+		if conf.RunMode == "dev" {
+			sqllog.SetLogger(logs.AdapterConsole)
+		}
+		orm2.DebugLog = orm2.NewLog(sqllog)
+	}
+
 }
 func main() {
 
@@ -54,6 +70,8 @@ func main() {
 	beego.BConfig.RunMode = conf.RunMode                    //  应用的运行模式
 	beego.BConfig.Listen.HTTPPort = HTTPPort_int            //监听端口  本地:8518  线上:8528
 	beego.BConfig.WebConfig.AutoRender = false
+	beego.BConfig.RecoverPanic = true
+	beego.BConfig.RecoverFunc = RecoverPanic
 
 	go controllers.DeviceRealTime() // 实时 数据
 
@@ -65,3 +83,36 @@ func main() {
 	beego.Run()
 
 }
+
+func RecoverPanic(ctx *context.Context, config *beego.Config) {
+	if err := recover(); err != nil {
+		ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", ctx.Request.Header.Get("Origin"))
+		var stack []string
+		for i := 1; ; i++ {
+			_, file, line, ok := runtime.Caller(i)
+			if !ok {
+				break
+			}
+			logs.Error(fmt.Sprintf("%s:%d", file, line))
+			stack = append(stack, fmt.Sprintln(fmt.Sprintf("%s:%d", file, line)))
+		}
+		//显示错误
+		data := map[string]interface{}{
+			"ret":           4000,
+			"AppError":      fmt.Sprintf("%v", err),
+			"RequestMethod": ctx.Input.Method(),
+			"RequestURL":    ctx.Input.URI(),
+			"RemoteAddr":    ctx.Input.IP(),
+			"Stack":         stack,
+			"GoVersion":     runtime.Version(),
+			"Code":          500,
+			"Msg":           "请稍后重试!",
+		}
+		_ = ctx.Output.JSON(data, true, true)
+		//if ctx.Output.Status != 0 {
+		//	ctx.ResponseWriter.WriteHeader(ctx.Output.Status)
+		//} else {
+		//	ctx.ResponseWriter.WriteHeader(500)
+		//}
+	}
+}

+ 27 - 10
models/Device/Device.go

@@ -14,7 +14,6 @@ import (
 
 	"github.com/beego/beego/v2/adapter/orm"
 	_ "github.com/go-sql-driver/mysql"
-	"strconv"
 	"time"
 )
 
@@ -130,7 +129,7 @@ func DeviceToDevice_R(r Device) (t Device_R) {
 	t.T_monitor = r.T_monitor
 	t.T_online = r.T_online
 	t.T_online_s = r.T_online_s
-	if r.T_online == 2 && (r.T_online_s == 0 || r.T_online_s == 2) && r.T_monitor == 1 {
+	if (r.T_online == 0 || r.T_online == 2) && (r.T_online_s == 0 || r.T_online_s == 2) && r.T_monitor == 1 {
 		t.T_monitor = 2
 	}
 	t.T_State = r.T_State
@@ -273,20 +272,38 @@ func Read_Device_List(admin *Account.Admin, T_pid int, T_name string, T_monitor
 		cond1 = cond1.AndCond(cond.Or("T_sn__icontains", T_name).Or("T_devName__icontains", T_name))
 	}
 
-	if len(T_monitor) > 0 {
-		T_monitor_int, err := strconv.Atoi(T_monitor)
-		if err == nil {
-			cond1 = cond1.AndCond(cond.And("T_monitor", T_monitor_int))
-		}
+	// 0 未监控 1 监控  2 未知状态
+	if T_monitor == "0" {
+		// 未监控
+		cond1 = cond1.And("T_monitor", 0)
+	} else if T_monitor == "1" {
+		// 在线 - 网络在线并且为监控状态
+		cond1 = cond1.And("T_monitor", 1).AndCond(cond.Or("T_online", 1).Or("T_online_s", 1))
+	} else if T_monitor == "2" {
+		// 未知状态 - 网络为未启用或离线状态 监控状态
+		cond1 = cond1.And("T_monitor", 1).AndCond(cond.And("T_online", 0).Or("T_online", 2)).
+			AndCond(cond.And("T_online_s", 0).Or("T_online_s", 2))
 	}
 
 	//0 未启用  1 在线  2 离线
+	// T_online	     T_online_s
+	// 0	         0	       未启用
+	// 0	         1	       在线
+	// 0	         2	       离线
+	// 1	         0	       在线
+	// 1	         1	       在线
+	// 1	         2	       在线
+	// 2	         0	       离线
+	// 2	         1	       在线
+	// 2	         2	       离线
+
 	if T_online == "1" {
-		cond1 = cond1.AndCond(cond.And("T_online", 1))
+		cond1 = cond1.AndCond(cond.Or("T_online", 1).Or("T_online_s", 1))
 	} else if T_online == "2" {
-		cond1 = cond1.AndCond(cond.And("T_online", 2))
+		cond1 = cond1.AndCond(cond.AndCond(cond.And("T_online", 2).And("T_online_s", 0)).
+			OrCond(cond.And("T_online", 0).And("T_online_s", 2)))
 	} else if T_online == "0" {
-		cond1 = cond1.AndCond(cond.And("T_online", 0).Or("T_online", 2))
+		cond1 = cond1.And("T_online", 0).And("T_online_s", 0)
 	}
 
 	var rx []Device

+ 20 - 0
models/Device/DeviceData.go

@@ -104,6 +104,26 @@ func DeviceData_ToDeviceData_R(d Device, r DeviceData_) (t DeviceData_R) {
 	return t
 }
 
+func DeviceDataToDeviceData_R2(d Device, sp DeviceSensorParameter_R, r DeviceData_) (t DeviceData_R) {
+
+	t.T_id = r.T_id
+	t.T_t = r.T_t
+	t.T_rh = r.T_rh
+	t.T_site = r.T_site
+	t.T_time = r.T_time.Format("2006-01-02 15:04:05")
+	t.T_sp = r.T_sp
+	t.T_name = sp.T_name
+	t.T_tl = sp.T_Tlower
+	t.T_tu = sp.T_Tupper
+	t.T_rhl = sp.T_RHlower
+	t.T_rhu = sp.T_RHupper
+
+	t.T_ist = d.T_ist
+	t.T_ish = d.T_ish
+
+	return t
+}
+
 // ---------------- Redis -------------------
 // Redis_Device_Set(m.T_sn,m) // Redis 更新缓存
 func RedisDeviceData_Set(key string, r DeviceData_) (err error) {

+ 85 - 15
models/Device/DeviceSensor.go

@@ -72,6 +72,7 @@ type DeviceSensor_R struct {
 	T_DeviceSensorData      DeviceData_R            // 传感器最新数据
 	T_DeviceSensorParameter DeviceSensorParameter_R //  设备参数
 	T_DeviceSensorType      DeviceSensorType_R      //  传感器类型
+	T_Device                Device                  //  传感器类型
 
 }
 
@@ -170,7 +171,8 @@ func Redis_DeviceSensor_DelK(r DeviceSensor) (err error) {
 // ---------------- 特殊方法 -------------------
 
 func DeviceSensorToDeviceSensor_R(DeviceSensor_ DeviceSensor) (DeviceSensor_r DeviceSensor_R) {
-	lib.DeviceRealSnMap[DeviceSensor_.T_sn] = 3 // 连续请求 实时数据
+	//lib.DeviceRealSnMap[DeviceSensor_.T_sn] = 3 // 连续请求 实时数据
+	lib.DeviceRealSnMap.Store(DeviceSensor_.T_sn, 3) // 连续请求 实时数据
 
 	DeviceSensor_r.T_sn = DeviceSensor_.T_sn
 	DeviceSensor_r.T_id = DeviceSensor_.T_id
@@ -199,10 +201,14 @@ func DeviceSensorToDeviceSensor_R(DeviceSensor_ DeviceSensor) (DeviceSensor_r De
 	//key_data := DeviceSensor_.T_sn + "|" + strconv.Itoa(DeviceSensor_.T_id)
 	//DeviceSensor_r.T_DeviceSensorData, _ = RedisDeviceData_Get(key_data)
 	DeviceData := Read_DeviceData(DeviceSensor_.T_sn, DeviceSensor_.T_id)
+	//DeviceData, _ := RedisDeviceData_Get(DeviceSensor_.T_sn + "|" + strconv.Itoa(DeviceSensor_.T_id))
+
 	device, _ := Read_Device_ByT_sn(DeviceSensor_.T_sn)
-	DeviceSensor_r.T_DeviceSensorData = DeviceData_ToDeviceData_R(device, DeviceData)
+	DeviceSensor_r.T_DeviceSensorData = DeviceDataToDeviceData_R2(device, DeviceSensor_r.T_DeviceSensorParameter, DeviceData)
+
 	deviceSensorType := Read_DeviceSensorType_Get(DeviceSensor_.T_type)
 	DeviceSensor_r.T_DeviceSensorType = DeviceSensorTypeToDeviceSensorType_R(deviceSensorType)
+	DeviceSensor_r.T_Device = device
 	return
 }
 
@@ -752,17 +758,19 @@ func Read_DeviceSensorManageList(admin_r *Account.Admin, T_pid int, T_name strin
 }
 
 // 数据展示菜单下 传感器参数列表
-func Read_DeviceSensor_List_For_Data(T_pid int, T_name string, T_Class_id, T_type, T_RealTime int, page int, page_z int) (DeviceSensor_r []DeviceSensor_R, cnt int64) {
+// 实时数据页面 温湿度一场数据往前排
+// 轨迹展示页面
+func Read_DeviceSensor_List_For_Data(T_pid int, T_name string, T_Class_id, T_type, T_RealTime, T_MapShow int, page int, page_z int) (DeviceSensor_r []DeviceSensor_R, cnt int64) {
 
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
 
 	qs := o.QueryTable(new(DeviceSensor))
-	var offset int64
+	var offset int
 	if page <= 1 {
 		offset = 0
 	} else {
-		offset = int64((page - 1) * page_z)
+		offset = (page - 1) * page_z
 	}
 
 	var r []DeviceSensor
@@ -781,16 +789,14 @@ func Read_DeviceSensor_List_For_Data(T_pid int, T_name string, T_Class_id, T_typ
 
 	if len(T_name) == 16 {
 		cond1 = cond1.And("T_sn", T_name)
-	} else {
+	} else if len(T_name) > 0 {
 		cond1 = cond1.And("T_name__icontains", T_name).And("T_datashow", 1)
 	}
 
-	_, err := qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("T_sort", "T_id").All(&r)
-	if err != nil {
-		logs.Error(lib.FuncName(), err)
-		return
+	if T_MapShow == 1 {
+		cond1 = cond1.AndNot("T_Site", "")
 	}
-	cnt, err = qs.SetCond((*orm2.Condition)(cond1)).Count()
+	cnt, err := qs.SetCond((*orm2.Condition)(cond1)).Count()
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 		return
@@ -798,6 +804,15 @@ func Read_DeviceSensor_List_For_Data(T_pid int, T_name string, T_Class_id, T_typ
 
 	// 实时数据页面,温度或者湿度不在正常区间,排在最前面
 	if T_RealTime == 1 {
+		offset_z := offset + page_z
+		if cnt < int64(offset_z) {
+			offset_z = int(cnt)
+		}
+		_, err = qs.SetCond((*orm2.Condition)(cond1)).OrderBy("T_sort", "T_id").All(&r)
+		if err != nil {
+			logs.Error(lib.FuncName(), err)
+			return
+		}
 		var DeviceSensor_unusual []DeviceSensor_R
 		for _, v := range r {
 			v_r := DeviceSensorToDeviceSensor_R(v)
@@ -810,7 +825,13 @@ func Read_DeviceSensor_List_For_Data(T_pid int, T_name string, T_Class_id, T_typ
 			}
 		}
 		DeviceSensor_unusual = append(DeviceSensor_unusual, DeviceSensor_r...)
-		return DeviceSensor_unusual, cnt
+		return DeviceSensor_unusual[offset:offset_z], cnt
+	}
+
+	_, err = qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("T_sort", "T_id").All(&r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return
 	}
 
 	for _, v := range r {
@@ -833,11 +854,18 @@ func Read_DeviceSensor_T_type(T_pid int) (lists orm2.ParamsList, err error) {
 }
 
 // 数据展示菜单下 传感器参数列表
-func Read_DeviceSensor_List_For_Stat(T_pid int, T_name string, T_type int) (DeviceSensor_r []DeviceSensor_R, cnt int64) {
+func Read_DeviceSensor_List_For_Stat(T_pid int, T_name, T_online string, T_RealTime, T_type, page, page_z int) (DeviceSensor_r []DeviceSensor_R, cnt int64) {
 
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
 
+	var offset int
+	if page <= 1 {
+		offset = 0
+	} else {
+		offset = (page - 1) * page_z
+	}
+
 	qs := o.QueryTable(new(DeviceSensor))
 
 	var r []DeviceSensor
@@ -850,11 +878,20 @@ func Read_DeviceSensor_List_For_Stat(T_pid int, T_name string, T_type int) (Devi
 
 	if len(T_name) == 16 {
 		cond1 = cond1.And("T_sn", T_name)
-	} else {
+	} else if len(T_name) > 0 {
 		cond1 = cond1.And("T_name__icontains", T_name).And("T_datashow", 1)
 	}
 
-	_, err := qs.SetCond((*orm2.Condition)(cond1)).OrderBy("T_sort", "T_id").All(&r)
+	if T_online == "1" {
+		cond1 = cond1.AndCond(cond.Or("T_online", 1).Or("T_online_s", 1))
+	} else if T_online == "2" {
+		cond1 = cond1.AndCond(cond.AndCond(cond.And("T_online", 2).And("T_online_s", 0)).
+			OrCond(cond.And("T_online", 0).And("T_online_s", 2)))
+	} else if T_online == "0" {
+		cond1 = cond1.And("T_online", 0).And("T_online_s", 0)
+	}
+
+	_, err := qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("T_sort", "T_id").All(&r)
 
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -871,3 +908,36 @@ func Read_DeviceSensor_List_For_Stat(T_pid int, T_name string, T_type int) (Devi
 	}
 	return DeviceSensor_r, cnt
 }
+
+// 数据展示菜单下 传感器参数列表
+func Read_DeviceSensor_Count_ByT_online(T_pid, T_type int, T_online string) (cnt int64) {
+
+	o := orm.NewOrm()
+	// 也可以直接使用 Model 结构体作为表名
+
+	qs := o.QueryTable(new(DeviceSensor))
+
+	cond := orm.NewCondition()
+	cond1 := cond.And("T_pid", T_pid).And("T_State", 1)
+	if T_type > 0 {
+		cond1 = cond1.And("T_type", T_type)
+	}
+
+	//0 未启用  1 在线  2 离线
+	if T_online == "1" {
+		cond1 = cond1.AndCond(cond.Or("T_online", 1).Or("T_online_s", 1))
+	} else if T_online == "2" {
+		cond1 = cond1.AndCond(cond.AndCond(cond.And("T_online", 2).And("T_online_s", 0)).
+			OrCond(cond.And("T_online", 0).And("T_online_s", 2)))
+	} else if T_online == "0" {
+		cond1 = cond1.And("T_online", 0).And("T_online_s", 0)
+	}
+
+	cnt, err := qs.SetCond((*orm2.Condition)(cond1)).Count()
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return
+	}
+
+	return cnt
+}

+ 2 - 1
models/Device/DeviceSensorParameter.go

@@ -51,7 +51,7 @@ type DeviceSensorParameter struct {
 }
 
 type DeviceSensorParameter_R struct {
-
+	T_name string
 	// 报警
 	T_Tlower  float32 //  温度下限
 	T_Tupper  float32 //  温度上限
@@ -86,6 +86,7 @@ type DeviceSensorParameter_T struct {
 }
 
 func DeviceSensorParameterToDeviceSensorParameter_R(r DeviceSensorParameter) (t DeviceSensorParameter_R) {
+	t.T_name = r.T_name
 	t.T_Tlower = r.T_Tlower
 	t.T_Tupper = r.T_Tupper
 	t.T_RHlower = r.T_RHlower

+ 69 - 1
models/Warning/Warning.go

@@ -56,6 +56,7 @@ type Warning_R struct {
 	T_DS_name  string   // 传感器名称
 	T_Remark   string   // 采集内容
 	T_Ut       string   // 采集时间
+	T_fUt      string   // 首次采集时间
 	T_Text     string   // 处理备注
 	T_Log      []string // 处理日志
 	T_Msid     int64    // 消息ID
@@ -70,11 +71,11 @@ func (t *Warning) TableName() string {
 
 func init() {
 	//注册模型
-	orm2.Debug = true
 	orm.RegisterModel(new(Warning))
 }
 
 // ---------------- 特殊方法 -------------------
+// T_history 0 40天 1 历史数据
 func WarningToWarning_R(T_history int, t Warning) (r Warning_R) {
 	r.Id = t.Id
 	r.T_pid = t.T_pid
@@ -86,6 +87,9 @@ func WarningToWarning_R(T_history int, t Warning) (r Warning_R) {
 	r.T_DS_name = t.T_DS_name
 	r.T_Remark = t.T_Remark
 	r.T_Ut = t.T_Ut.Format("2006-01-02 15:04:05")
+	if !t.T_fUt.IsZero() {
+		r.T_fUt = t.T_fUt.Format("2006-01-02 15:04:05")
+	}
 	r.T_Text = t.T_Text
 	if len(t.T_Log) > 0 {
 		r.T_Log = strings.Split(strings.TrimRight(t.T_Log, "\n"), "\n")
@@ -584,3 +588,67 @@ func Read_DeviceLogs_List(T_sn string, page, page_z int) (r []DeviceLogs, cnt in
 
 	return r, cnt
 }
+
+// 通过传感器类型获取报警列表
+func Read_Warning_List_By_DS_T_type(T_pid, DS_T_type int, T_name string, page int, page_z int) (r []Warning_R, cnt int64) {
+	o := orm.NewOrm()
+	// 也可以直接使用 Model 结构体作为表名
+	var maps []Warning
+	var maps_z []orm2.ParamsList
+	var offset int
+	if page <= 1 {
+		offset = 0
+	} else {
+		offset = (page - 1) * page_z
+	}
+
+	// T_State 0 删除   1 不处理   2 已处理   3 未处理
+	sql_WHERE := " t__state > 1 AND t_pid = " + strconv.Itoa(T_pid)
+
+	if DS_T_type > 0 {
+		sql_WHERE += " AND ds.t_type = " + strconv.Itoa(DS_T_type)
+	}
+
+	if len(T_name) > 0 {
+		sql_WHERE += " AND (t_sn like '%" + T_name + "%' OR t__d_name like '%" + T_name + "%' OR t_id like '%" + T_name + "%' OR t__d_s_name like '%" + T_name + "%')"
+	}
+
+	sql := "SELECT COUNT(w.ID) FROM warning w " +
+		"LEFT JOIN ( SELECT t_sn AS tsn,t_id AS tid,t_type FROM device_sensor) AS ds " +
+		"ON w.t_sn = ds.tsn AND w.t_id = ds.tid " +
+		"WHERE " + sql_WHERE
+	fmt.Println(sql)
+	_, err := o.Raw(sql).ValuesList(&maps_z)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return r, 0
+	}
+	if len(maps_z) == 0 {
+		return r, 0
+	}
+
+	sql = "SELECT * FROM warning w " +
+		"LEFT JOIN ( SELECT t_sn AS tsn,t_id AS tid,t_type FROM device_sensor) AS ds " +
+		"ON w.t_sn = ds.tsn AND w.t_id = ds.tid " +
+		"WHERE " + sql_WHERE + " ORDER BY t__ut DESC"
+
+	if page_z != 9999 {
+		sql = sql + " LIMIT " + strconv.Itoa(offset) + "," + strconv.Itoa(page_z)
+	}
+
+	fmt.Println(sql)
+	_, err = o.Raw(sql).QueryRows(&maps)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+		return
+	}
+
+	for _, v := range maps {
+		r = append(r, WarningToWarning_R(0, v))
+	}
+
+	cnt, _ = strconv.ParseInt(maps_z[0][0].(string), 10, 64)
+
+	return r, cnt
+
+}

+ 1 - 0
routers/Device.go

@@ -50,6 +50,7 @@ func init() {
 			// 传感器管理列表
 			beego.NSRouter("/Manage_List", &controllers.DeviceController{}, "*:DeviceSensor_Manage_List"), // 传感器管理列表
 			beego.NSRouter("/Stat", &controllers.DeviceController{}, "*:DeviceSensor_Stat"),               // 传感器统计 - 小程序
+			beego.NSRouter("/Stat_List", &controllers.DeviceController{}, "*:DeviceSensor_Stat_List"),     // 传感器列表统计 - 小程序
 
 		),
 		// 传感器类型

+ 6 - 5
routers/Warning.go

@@ -11,11 +11,12 @@ func init() {
 
 		// 设备报警
 		beego.NSNamespace("/DeviceWarning",
-			beego.NSRouter("/List", &controllers.DeviceController{}, "*:DeviceWarning_List"),          // 告警列表
-			beego.NSRouter("/Get", &controllers.DeviceController{}, "*:DeviceWarning_Get"),            // 获取告警
-			beego.NSRouter("/Edit", &controllers.DeviceController{}, "*:DeviceWarning_Post"),          // 修改告警 报警处理
-			beego.NSRouter("/Del", &controllers.DeviceController{}, "*:DeviceWarning_Del"),            // 删除告警
-			beego.NSRouter("/ToExcel", &controllers.DeviceController{}, "*:DeviceWarning_Data_Excel"), // 导出excel
+			beego.NSRouter("/List", &controllers.DeviceController{}, "*:DeviceWarning_List"),                          // 告警列表
+			beego.NSRouter("/Get", &controllers.DeviceController{}, "*:DeviceWarning_Get"),                            // 获取告警
+			beego.NSRouter("/Edit", &controllers.DeviceController{}, "*:DeviceWarning_Post"),                          // 修改告警 报警处理
+			beego.NSRouter("/Del", &controllers.DeviceController{}, "*:DeviceWarning_Del"),                            // 删除告警
+			beego.NSRouter("/ToExcel", &controllers.DeviceController{}, "*:DeviceWarning_Data_Excel"),                 // 导出excel
+			beego.NSRouter("/DeviceSensor_List", &controllers.DeviceController{}, "*:Read_Warning_List_By_DS_T_type"), // 告警列表 - 小程序
 
 		),
 		// 报警类型