siked 2 years ago
parent
commit
9c94dd68c0

+ 3 - 9
Nats/Nats.go

@@ -8,40 +8,34 @@ import (
 )
 
 var Nats *nats.Conn
+
 func init() {
 	var err error
 	// 连接Nats服务器
-	Nats, err = nats.Connect("nats://"+conf.NatsServer_Url)
+	Nats, err = nats.Connect("nats://" + conf.NatsServer_Url)
 	if err != nil {
 		fmt.Println("nats 连接失败!")
-		panic("nats 连接失败!")
+		panic(err)
 	}
 	logs.Println("nats OK!")
 }
 
-
 func NatsInit() {
 
-
-
-
 	//// 发布-订阅 模式,异步订阅 test1
 	//_, _ = Nats.Subscribe("test1", func(m *nats.Msg) {
 	//	fmt.Printf("Received a message: %s\n", string(m.Data))
 	//})
 
-
 	//// 队列 模式,订阅 test2, 队列为queue, test2 发向所有队列,同一队列只有一个能收到消息
 	//_, _ = Nats.QueueSubscribe("test2", "queue", func(msg *nats.Msg) {
 	//	fmt.Printf("Queue a message: %s\n", string(msg.Data))
 	//})
 
-
 	//// 请求-响应, 响应 test3 消息。
 	//_, _ = Nats.Subscribe("test3", func(m *nats.Msg) {
 	//	fmt.Printf("Reply a message: %s\n", string(m.Data))
 	//	_ = Nats.Publish(m.Reply, []byte("I can help!!"))
 	//})
 
-
 }

+ 17 - 21
Nats/NatsQiniu.go

@@ -1,20 +1,22 @@
 package Nats
 
 import (
+	"Cold_Api/controllers/lib"
+	"Cold_Api/logs"
 	"fmt"
 	"github.com/vmihailenco/msgpack/v5"
 	"time"
 )
 
-func Qiniu_UploadToken(T_suffix string,T_MimeLimit string) (string,bool) {
+func Qiniu_UploadToken(T_suffix string, T_MimeLimit string) (string, bool) {
 	type Qiniu_UploadToken struct {
-		T_suffix string
+		T_suffix    string
 		T_MimeLimit string
 	}
 
 	b, err := msgpack.Marshal(&Qiniu_UploadToken{
-		T_suffix:T_suffix,
-		T_MimeLimit:T_MimeLimit,
+		T_suffix:    T_suffix,
+		T_MimeLimit: T_MimeLimit,
 	})
 	if err != nil {
 		panic(err)
@@ -26,25 +28,21 @@ func Qiniu_UploadToken(T_suffix string,T_MimeLimit string) (string,bool) {
 		fmt.Println(err)
 	} else {
 		fmt.Printf("Qiniu_UploadToken : %s\n", string(msg.Data))
-		return string(msg.Data),true
+		return string(msg.Data), true
 	}
 
-	return string(msg.Data),false
+	return string(msg.Data), false
 }
 
-
-
-
-func Qiniu_UploadFile(localFile string,name string) (string,bool) {
+func Qiniu_UploadFile(localFile string, name string) (string, bool) {
+	logs.Println("Nats =>", lib.FuncName(), localFile, name)
 	type Qiniu_UploadFile struct {
-		localFile string
-		name string
+		File string
+		Name string
 	}
-
-	b, err := msgpack.Marshal(&Qiniu_UploadFile{
-		localFile:localFile,
-		name:name,
-	})
+	RR := Qiniu_UploadFile{File: localFile, Name: name}
+	println(":", RR.File)
+	b, err := msgpack.Marshal(&RR)
 	if err != nil {
 		panic(err)
 	}
@@ -55,10 +53,8 @@ func Qiniu_UploadFile(localFile string,name string) (string,bool) {
 		fmt.Println(err)
 	} else {
 		fmt.Printf("Qiniu_UploadFile : %s\n", string(msg.Data))
-		return string(msg.Data),true
+		return string(msg.Data), true
 	}
 
-	return string(msg.Data),false
+	return string(msg.Data), false
 }
-
-

+ 6 - 6
Nats/NatsWx.go

@@ -1,12 +1,14 @@
 package Nats
 
 import (
+	"Cold_Api/controllers/lib"
+	"Cold_Api/logs"
 	"fmt"
 	"time"
 )
 
-func Wx_GenerateQRCode(DeviceClass_id string) (string,bool) {
-
+func Wx_GenerateQRCode(DeviceClass_id string) (string, bool) {
+	logs.Println("Nats =>", lib.FuncName(), DeviceClass_id)
 
 	// 请求-响应, 向 test3 发布一个 `help me` 请求数据,设置超时间3秒,如果有多个响应,只接收第一个收到的消息
 	msg, err := Nats.Request("Wx_GenerateQRCode", []byte(DeviceClass_id), 3*time.Second)
@@ -14,10 +16,8 @@ func Wx_GenerateQRCode(DeviceClass_id string) (string,bool) {
 		fmt.Println(err)
 	} else {
 		fmt.Printf("Wx_GenerateQRCode : %s\n", string(msg.Data))
-		return string(msg.Data),true
+		return string(msg.Data), true
 	}
 
-	return string(msg.Data),false
+	return string(msg.Data), false
 }
-
-

+ 2 - 2
conf/app.conf

@@ -1,11 +1,11 @@
 appname = Cold_Api
-HTTPPort = 30332
+HTTPPort = 6200
 runmode = dev
 EnableDocs = true
 copyrequestbody = true
 
 # Nats
-NatsServer_Url = "127.0.0.1:4222"
+NatsServer_Url = "192.168.192.63:4222"
 
 
 # Mysql

+ 65 - 65
controllers/Data.go

@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"Cold_Api/Nats"
 	"Cold_Api/conf"
 	"Cold_Api/controllers/lib"
 	"Cold_Api/models/Admin"
@@ -136,14 +137,13 @@ func (c *DataController) Device_Sensor() {
 	T_id, _ := c.GetInt("T_id")
 	//c.Data["Class_List"] = Device.Read_Class_All_1()
 
-	DeviceSensor_r,err := Device.Read_DeviceSensor_ByTsn_Tid(T_sn, T_id)
+	DeviceSensor_r, err := Device.Read_DeviceSensor_ByTsn_Tid(T_sn, T_id)
 	if err != nil {
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "err!"}
 		c.ServeJSON()
 		return
 	}
 
-
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Device.DeviceSensorToDeviceSensor_R(DeviceSensor_r)}
 	c.ServeJSON()
 	return
@@ -372,19 +372,21 @@ func (c *DataController) Device_Sensor_Data_Excel() {
 	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
 		fmt.Println(err)
 	}
-	//
-	//if !lib.Pload_qiniu("ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx") {
-	//	c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
-	//	c.ServeJSON()
-	//	return
-	//}
+
+	// 上传 OSS
+	url, is := Nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
+	if !is {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
+		c.ServeJSON()
+		return
+	}
 	//删除目录
 	err := os.Remove("ofile/" + timeStr + ".xlsx")
 	if err != nil {
 		fmt.Println(err)
 	}
 
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: "https://osscold.baozhida.cn/" + "ofile/" + timeStr + ".xlsx"}
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
 	c.ServeJSON()
 	return
 }
@@ -446,8 +448,7 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 		   }
 		}`)
 
-
-	atime, _ := time.ParseDuration("-1m")  //  Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
+	atime, _ := time.ParseDuration("-1m") //  Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
 
 	// 循环写入数据
 	for v_i, v := range DeviceSensor_data {
@@ -473,18 +474,18 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
 		}
 
-		if(len(DeviceSensor_data) - 1 == v_i){
-			break;
+		if len(DeviceSensor_data)-1 == v_i {
+			break
 		}
 
-		cha_v := ((DeviceSensor_data[v_i + 1].T_t - v.T_t ) / 3)
-		println("cha_v:",cha_v)
+		cha_v := ((DeviceSensor_data[v_i+1].T_t - v.T_t) / 3)
+		//println("cha_v:",cha_v)
 
 		// -------
-		v.T_t = float32(lib.Decimal(float64(v.T_t+cha_v)))
-		println("v.T_t:",v.T_t)
+		v.T_t = float32(lib.Decimal(float64(v.T_t + cha_v)))
+		//println("v.T_t:",v.T_t)
 
-		fTime,_ := time.Parse("2006-1-2 15:04:05", v.T_time)
+		fTime, _ := time.Parse("2006-1-2 15:04:05", v.T_time)
 		fTime = fTime.Add(atime)
 		v.T_time = fTime.Format("2006-1-2 15:04:05")
 
@@ -510,10 +511,10 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 		}
 
 		// -------
-		v.T_t = float32(lib.Decimal(float64(v.T_t+cha_v)))
-		println("v.T_t:",v.T_t)
+		v.T_t = float32(lib.Decimal(float64(v.T_t + cha_v)))
+		//println("v.T_t:",v.T_t)
 
-		fTime,_ = time.Parse("2006-1-2 15:04:05", v.T_time)
+		fTime, _ = time.Parse("2006-1-2 15:04:05", v.T_time)
 		fTime = fTime.Add(atime)
 		v.T_time = fTime.Format("2006-1-2 15:04:05")
 
@@ -539,10 +540,10 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 		}
 
 		// -------
-		v.T_t = float32(lib.Decimal(float64(v.T_t+cha_v)))
-		println("v.T_t:",v.T_t)
+		v.T_t = float32(lib.Decimal(float64(v.T_t + cha_v)))
+		//println("v.T_t:",v.T_t)
 
-		fTime,_ = time.Parse("2006-1-2 15:04:05", v.T_time)
+		fTime, _ = time.Parse("2006-1-2 15:04:05", v.T_time)
 		fTime = fTime.Add(atime)
 		v.T_time = fTime.Format("2006-1-2 15:04:05")
 
@@ -598,17 +599,13 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 		//}
 
 		// -------
-		v.T_t = float32(lib.Decimal(float64(v.T_t+cha_v)))
-		println("v.T_t:",v.T_t)
+		v.T_t = float32(lib.Decimal(float64(v.T_t + cha_v)))
+		//println("v.T_t:",v.T_t)
 
-		fTime,_ = time.Parse("2006-1-2 15:04:05", v.T_time)
+		fTime, _ = time.Parse("2006-1-2 15:04:05", v.T_time)
 		fTime = fTime.Add(atime)
 		v.T_time = fTime.Format("2006-1-2 15:04:05")
 
-
-
-
-
 	}
 	timeStr := time.Now().Format("20060102150405")
 	// 保存文件
@@ -616,18 +613,21 @@ func (c *DataController) Device_Sensor_Data_Excel_m() {
 		fmt.Println(err)
 	}
 
-	//if !lib.Pload_qiniu("ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx") {
-	//	c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
-	//	c.ServeJSON()
-	//	return
-	//}
+	// 上传 OSS
+	url, is := Nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
+	if !is {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
+		c.ServeJSON()
+		return
+	}
+
 	//删除目录
 	err := os.Remove("ofile/" + timeStr + ".xlsx")
 	if err != nil {
 		fmt.Println(err)
 	}
 
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: "https://osscold.baozhida.cn/" + "ofile/" + timeStr + ".xlsx"}
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
 	c.ServeJSON()
 	return
 }
@@ -1081,7 +1081,7 @@ func (c *DataController) Device_Sensor_Data_PDF() {
 		T_Tlu := fmt.Sprintf(" %.1f ~ %.1f ", v.T_Tlower, v.T_Tupper)
 		T_Rlu := fmt.Sprintf(" %.1f ~ %.1f ", v.T_RHlower, v.T_RHupper)
 		T_time := fmt.Sprintf("%s", v.T_time)
-		if (user_r.Admin_rh == 0 && strings.Contains(v.T_sn, "YD")) {
+		if user_r.Admin_rh == 0 && strings.Contains(v.T_sn, "YD") {
 			T_rh = "-"
 			T_Rlu = "-"
 		}
@@ -1107,18 +1107,20 @@ func (c *DataController) Device_Sensor_Data_PDF() {
 		return
 	}
 
-	//if !lib.Pload_qiniu(timeStr, timeStr) {
-	//	c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
-	//	c.ServeJSON()
-	//	return
-	//}
+	// 上传 OSS
+	url, is := Nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/"+timeStr, timeStr)
+	if !is {
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
+		c.ServeJSON()
+		return
+	}
 	//删除目录
 	err = os.Remove(timeStr)
 	if err != nil {
 		fmt.Println(err)
 	}
 
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: "https://osscold.baozhida.cn/" + timeStr}
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
 	c.ServeJSON()
 	return
 
@@ -1145,37 +1147,35 @@ func (c *DataController) Raw() {
 		//strings.Contains(T_SQL, "DeviceSnOld")||
 		//strings.Contains(T_SQL, "DeviceTask")||
 		//strings.Contains(T_SQL, "DeviceWarning")||
-		strings.Contains(T_SQL, "Logs")||
-		strings.Contains(T_SQL, "SqlLogs")||
-		strings.Contains(T_SQL, "Tokey")||
-		strings.Contains(T_SQL, "UserLogs")||
-		strings.Contains(T_SQL_, "show")||
-		strings.Contains(T_SQL_, "create")||
-		strings.Contains(T_SQL_, "drop")||
-		strings.Contains(T_SQL_, "desc")||
-		strings.Contains(T_SQL_, "alter")||
-		strings.Contains(T_SQL_, "insert")||
-		strings.Contains(T_SQL_, "update")||
-		strings.Contains(T_SQL_, "delete"){
-		System.Add_SqlLogs(admin_r.Admin_uuid,"Err:"+admin_r.Admin_user, T_SQL)
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "Err SQL!",Data: admin_r.Admin_name+" :你的行为 也被记录"}
+		strings.Contains(T_SQL, "Logs") ||
+		strings.Contains(T_SQL, "SqlLogs") ||
+		strings.Contains(T_SQL, "Tokey") ||
+		strings.Contains(T_SQL, "UserLogs") ||
+		strings.Contains(T_SQL_, "show") ||
+		strings.Contains(T_SQL_, "create") ||
+		strings.Contains(T_SQL_, "drop") ||
+		strings.Contains(T_SQL_, "desc") ||
+		strings.Contains(T_SQL_, "alter") ||
+		strings.Contains(T_SQL_, "insert") ||
+		strings.Contains(T_SQL_, "update") ||
+		strings.Contains(T_SQL_, "delete") {
+		System.Add_SqlLogs(admin_r.Admin_uuid, "Err:"+admin_r.Admin_user, T_SQL)
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "Err SQL!", Data: admin_r.Admin_name + " :你的行为 也被记录"}
 		c.ServeJSON()
 		return
 	}
 
 	if //!strings.Contains(T_SQL, "Z_DeviceData_") ||
-		!strings.Contains(T_SQL_, "select"){
-		System.Add_SqlLogs(admin_r.Admin_uuid,"Err:"+admin_r.Admin_user, T_SQL)
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "Err SQL!",Data: admin_r.Admin_name+" :你的行为 也被记录"}
+	!strings.Contains(T_SQL_, "select") {
+		System.Add_SqlLogs(admin_r.Admin_uuid, "Err:"+admin_r.Admin_user, T_SQL)
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "Err SQL!", Data: admin_r.Admin_name + " :你的行为 也被记录"}
 		c.ServeJSON()
 		return
 	}
 
-	System.Add_SqlLogs(admin_r.Admin_uuid,"ok", T_SQL)
-
-
+	System.Add_SqlLogs(admin_r.Admin_uuid, "ok", T_SQL)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Device.Read_SqlRaw(T_SQL)}
 	c.ServeJSON()
 	return
-}
+}

+ 225 - 169
controllers/Device.go

@@ -12,7 +12,6 @@ import (
 	beego "github.com/beego/beego/v2/server/web"
 	"github.com/xuri/excelize/v2"
 	"math"
-	"os"
 	"strconv"
 	"strings"
 	"time"
@@ -36,15 +35,17 @@ func (c *DeviceController) Device_html() {
 	c.Data["Admin_Power"], _ = Admin.Read_AdminPower_ById(admin_r.Admin_power)
 	// 模板
 	type R_Device struct {
-		T_sn          string                // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
-		T_devName     string                //设备名称
-		T_sensor      int                   //  传感器数量
-		T_monitor      int                   //  监控状态 1 监控  0 未监控
-		T_sn_yd      int                   //  湿度显示
-		T_give      int                      // 0 丢弃  1 正常
-		T_sensor_list []Device.DeviceSensor //  传感器List
-		T_MSISDN     string                //设备名称
-		UpdateTime time.Time //auto_now 每次 model 保存时都会对时间自动更新
+		T_sn          string                  // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
+		T_devName     string                  //设备名称
+		T_sensor      int                     //  传感器数量
+		T_monitor     int                     //  监控状态 1 监控  0 未监控
+		T_sn_yd       int                     //  湿度显示
+		T_give        int                     // 0 丢弃  1 正常
+		T_online      int                     //  在线状态 1 在线  0 离线
+		T_Dattery     int                     //电量
+		T_sensor_list []Device.DeviceSensor_R //  传感器List
+		T_MSISDN      string                  //设备名称
+		UpdateTime    time.Time               //auto_now 每次 model 保存时都会对时间自动更新
 	}
 	var Device_lite_r []R_Device
 
@@ -65,25 +66,25 @@ func (c *DeviceController) Device_html() {
 	c.Data["T_sn"] = T_sn
 
 	var cnt int64
-	Device_lite, cnt := Device.Read_Device_ALL_bind_1(admin_r, page,0, T_sn, Name, Class_1,"")
+	Device_lite, cnt := Device.Read_Device_ALL_bind_1(admin_r, page, 0, T_sn, Name, Class_1, "")
 	for _, v := range Device_lite {
 		r_Device := R_Device{}
 
 		//  湿度显示
-		if admin_r.Admin_rh == 0{
+		if admin_r.Admin_rh == 0 {
 			r_Device.T_sn_yd = 0
-			if strings.Contains(v.T_sn, "YD"){
+			if strings.Contains(v.T_sn, "YD") {
 				r_Device.T_sn_yd = 1
 			}
 		}
 
-
-
 		r_Device.T_sn = v.T_sn
 		r_Device.T_MSISDN = v.T_MSISDN
 		r_Device.T_devName = v.T_devName
 		r_Device.T_give = v.T_give
-
+		r_Device.T_online = v.T_online
+		r_Device.T_monitor = v.T_monitor
+		r_Device.T_Dattery = v.T_Dattery
 
 		r_Device.T_sensor_list, r_Device.T_sensor = Device.Read_DeviceSensor_ByTsn(v.T_sn)
 
@@ -150,9 +151,9 @@ func (c *DeviceController) Device_Parameter_html() {
 	Sn := c.GetString("Sn")
 
 	DeviceParameter_lite := Device.Read_DeviceParameter_SN(Sn)
-	if len(DeviceParameter_lite) > 0{
+	if len(DeviceParameter_lite) > 0 {
 		c.Data["DeviceParameter"] = DeviceParameter_lite[0]
-	}else {
+	} else {
 		Nats.Read_DeviceParameter(Sn)
 	}
 	c.Data["DeviceParameter_lite_z"] = len(DeviceParameter_lite)
@@ -183,15 +184,14 @@ func (c *DeviceController) DeviceSensor_List_html() {
 	DeviceSensorParameter_list := Device.Read_DeviceSensorParameter_SN_T_id(Sn, Id)
 	c.Data["DeviceSensorParameter_lite"] = DeviceSensorParameter_list
 	c.Data["DeviceSensorParameter_T_SendState_0"] = 0
-	if (len(DeviceSensorParameter_list) > 0){
-		if DeviceSensorParameter_list[0].T_SendState == 0{
+	if len(DeviceSensorParameter_list) > 0 {
+		if DeviceSensorParameter_list[0].T_SendState == 0 {
 			c.Data["DeviceSensorParameter_T_SendState_0"] = 1
 		}
 	}
 
 	c.Data["Device"], _ = Device.Read_Device_ByT_sn(Sn)
 
-
 	c.TplName = "Device/Device_Sensor-.html"
 }
 func (c *DeviceController) Device_Parameter_Del_Device() {
@@ -206,17 +206,15 @@ func (c *DeviceController) Device_Parameter_Del_Device() {
 	Sn := c.GetString("Sn")
 	Id, _ := c.GetInt("Id")
 
-	System.Add_UserLogs_T(admin_r.Admin_uuid,"设备管理", "传感器 删除操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]")
+	System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "传感器 删除操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]")
 
 	//c.Data["Device_lite"] = Device.Read_DeviceParameter_SN(Sn)
 	Device.Delete_DeviceSensor_ById(Sn, Id)
 
-
 	Nats.Del_DeviceSensor(Device.DeviceSensor_Del{
-		T_sn:Sn,T_id:Id,
+		T_sn: Sn, T_id: Id,
 	})
 
-
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK"}
 	c.ServeJSON()
 	return
@@ -233,13 +231,11 @@ func (c *DeviceController) Device_Parameter_Del() {
 	Sn := c.GetString("Sn")
 	Id, _ := c.GetInt("Id")
 
-	System.Add_UserLogs_T(admin_r.Admin_uuid,"设备管理", "传感器 删除操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]")
+	System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "传感器 删除操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]")
 
 	//c.Data["Device_lite"] = Device.Read_DeviceParameter_SN(Sn)
 	Device.Delete_DeviceSensor_ById(Sn, Id)
 
-
-
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK"}
 	c.ServeJSON()
 	return
@@ -258,8 +254,7 @@ func (c *DeviceController) UpDeviceSensor_Tsort() {
 	Id, _ := c.GetInt("Id")
 	T_sort, _ := c.GetInt("T_sort")
 
-
-	DeviceSensor,is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
+	DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
 	if !is {
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "信息错误!"}
 		c.ServeJSON()
@@ -269,7 +264,7 @@ func (c *DeviceController) UpDeviceSensor_Tsort() {
 	//c.Data["Device_lite"] = Device.Read_DeviceParameter_SN(Sn)
 	Device.Update_DeviceSensor(DeviceSensor, "T_sort")
 
-	System.Add_UserLogs_T(admin_r.Admin_uuid,"设备管理", "传感器 排序操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]"+strconv.Itoa(T_sort))
+	System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "传感器 排序操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]"+strconv.Itoa(T_sort))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK"}
 	c.ServeJSON()
 	return
@@ -287,8 +282,7 @@ func (c *DeviceController) UpDeviceSensor_T_datashow() {
 	Id, _ := c.GetInt("Id")
 	T_datashow, _ := c.GetInt("T_datashow")
 
-
-	DeviceSensor,is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
+	DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id)
 	if !is {
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "信息错误!"}
 		c.ServeJSON()
@@ -298,7 +292,7 @@ func (c *DeviceController) UpDeviceSensor_T_datashow() {
 
 	Device.Update_DeviceSensor(DeviceSensor, "T_datashow")
 
-	System.Add_UserLogs_T(admin_r.Admin_uuid,"设备管理", "传感器 数据展示(0 屏蔽数据展示  1 正常数据展示)", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]"+strconv.Itoa(T_datashow))
+	System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "传感器 数据展示(0 屏蔽数据展示  1 正常数据展示)", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]"+strconv.Itoa(T_datashow))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK"}
 	c.ServeJSON()
 	return
@@ -311,27 +305,27 @@ func (c *DeviceController) Device_Post() {
 		return
 	}
 
-
 	var err error
 
 	T_sn := c.GetString("T_sn")
 	T_MSISDN := c.GetString("T_MSISDN")
 
 	var_ := Device.Device{
-		T_sn:    T_sn,
-		T_MSISDN:    T_MSISDN,
-		T_Bind:  "U" + strconv.Itoa(admin_r.Id) + "|",
-		T_l_p:   0,
-		T_give:   1,
-		T_State: 1,
-	}
-	if len(T_sn) < 8{
+		T_sn:      T_sn,
+		T_MSISDN:  T_MSISDN,
+		T_Bind:    "U" + strconv.Itoa(admin_r.Id) + "|",
+		T_l_p:     0,
+		T_give:    1,
+		T_monitor: 1,
+		T_State:   1,
+	}
+	if len(T_sn) < 8 {
 		c.Data["json"] = lib.JSONS{Code: 303, Msg: "SN 太短 必须8个字符以上"}
 		c.ServeJSON()
 		return
 	}
 
-	if !(strings.Contains(T_sn, "KF") || strings.Contains(T_sn, "YD")){
+	if !(strings.Contains(T_sn, "KF") || strings.Contains(T_sn, "YD")) {
 		c.Data["json"] = lib.JSONS{Code: 303, Msg: "必须包含 KF或YD!"}
 		c.ServeJSON()
 		return
@@ -358,7 +352,7 @@ func (c *DeviceController) Device_Post() {
 		return
 	}
 
-	System.Add_UserLogs_T(admin_r.Admin_uuid,"设备管理", "设备添加", var_)
+	System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "设备添加", var_)
 
 	//MqttServer.Get_Device_Realtime(T_sn)  // 更新传感器 !!!
 
@@ -376,7 +370,7 @@ func (c *DeviceController) Device_Del() {
 		c.ServeJSON()
 		return
 	}
-	if admin_r.Admin_master != 1{
+	if admin_r.Admin_master != 1 {
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "没有权限!"}
 		c.ServeJSON()
 		return
@@ -385,16 +379,16 @@ func (c *DeviceController) Device_Del() {
 
 	T_sn := c.GetString("T_sn")
 
-	Device_r,err := Device.Read_Device_ByT_sn(T_sn)
-	if err != nil{
+	Device_r, err := Device.Read_Device_ByT_sn(T_sn)
+	if err != nil {
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "T_sn Err!"}
 		c.ServeJSON()
 		return
 	}
 
 	Device.Delete_Device(Device_r)
-	DeviceSensor_list,_ := Device.Read_DeviceSensor_ByTsn(Device_r.T_sn)
-	for _,v := range DeviceSensor_list{
+	DeviceSensor_list, _ := Device.Read_DeviceSensor_ByTsn(Device_r.T_sn)
+	for _, v := range DeviceSensor_list {
 		Device.Delete_DeviceSensor_ById(Device_r.T_sn, v.T_id)
 	}
 	Device.DELETE_DeviceSensor(Device_r.T_sn)
@@ -402,12 +396,13 @@ func (c *DeviceController) Device_Del() {
 	Device.DELETE_DeviceParameter(Device_r.T_sn)
 	Device.DELETE_DeviceSensorParameter(Device_r.T_sn)
 
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "设备删除", T_sn)
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "设备删除", T_sn)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 
 }
+
 // 设备弃用
 func (c *DeviceController) Device_Give() {
 	// 验证登录
@@ -417,7 +412,7 @@ func (c *DeviceController) Device_Give() {
 		c.ServeJSON()
 		return
 	}
-	if admin_r.Admin_master != 1{
+	if admin_r.Admin_master != 1 {
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "没有权限!"}
 		c.ServeJSON()
 		return
@@ -426,20 +421,20 @@ func (c *DeviceController) Device_Give() {
 
 	T_sn := c.GetString("T_sn")
 
-	Device_r,err := Device.Read_Device_ByT_sn(T_sn)
-	if err != nil{
+	Device_r, err := Device.Read_Device_ByT_sn(T_sn)
+	if err != nil {
 		c.Data["json"] = lib.JSONS{Code: 201, Msg: "T_sn Err!"}
 		c.ServeJSON()
 		return
 	}
-	if Device_r.T_give == 0{
+	if Device_r.T_give == 0 {
 		Device_r.T_give = 1
-		System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "设备开启", T_sn)
-	}else {
+		System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "设备开启", T_sn)
+	} else {
 		Device_r.T_give = 0
-		System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "设备弃用", T_sn)
+		System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "设备弃用", T_sn)
 	}
-	Device.Update_Device(Device_r,"T_give")
+	Device.Update_Device(Device_r, "T_give")
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
@@ -459,12 +454,12 @@ func (c *DeviceController) Device_List() {
 	}
 	// 模板
 	type R_Device struct {
-		T_sn          string                // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
-		T_devName     string                //设备名称
-		T_sensor      int                   //  传感器数量
-		T_monitor      int                   //  监控状态
-		T_give      int                  // 0 丢弃  1 正常
-		T_sensor_list []Device.DeviceSensor //  传感器List
+		T_sn          string                  // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
+		T_devName     string                  //设备名称
+		T_sensor      int                     //  传感器数量
+		T_monitor     int                     //  监控状态
+		T_give        int                     // 0 丢弃  1 正常
+		T_sensor_list []Device.DeviceSensor_R //  传感器List
 
 		UpdateTime time.Time //auto_now 每次 model 保存时都会对时间自动更新
 	}
@@ -503,7 +498,7 @@ func (c *DeviceController) Device_List() {
 	}
 
 	var cnt int64
-	Device_lite, cnt := Device.Read_Device_ALL_bind_1(admin_r, page,0, T_sn, Name, Class_1,"")
+	Device_lite, cnt := Device.Read_Device_ALL_bind_1(admin_r, page, 0, T_sn, Name, Class_1, "")
 	for _, v := range Device_lite {
 		r_Device := R_Device{}
 
@@ -511,6 +506,7 @@ func (c *DeviceController) Device_List() {
 		r_Device.T_devName = v.T_devName
 		r_Device.T_sensor_list, r_Device.T_sensor = Device.Read_DeviceSensor_ByTsn(v.T_sn)
 		r_Device.T_give = v.T_give
+		r_Device.T_monitor = v.T_monitor
 		//监控状态
 		//r_Device.T_monitor = 1
 		//if(strings.Contains(r_Device.T_sn, "YD")){
@@ -693,12 +689,12 @@ func (c *DeviceController) Pu_DeviceParameter() {
 	T_tempPre, _ := c.GetFloat("T_tempPre")
 	T_humPre, _ := c.GetFloat("T_humPre")
 	T_enwarning, _ := c.GetInt("T_enwarning")
-	T_decTotal,_ := c.GetInt("T_decTotal")
+	T_decTotal, _ := c.GetInt("T_decTotal")
 	T_chDecTotal := c.GetString("T_chDecTotal")
 	T_company := c.GetString("T_company")
 	T_btname := c.GetString("T_btname")
-	T_btserverID,_ := c.GetInt("T_btserverID")
-	T_btchar,_ := c.GetInt("T_btchar")
+	T_btserverID, _ := c.GetInt("T_btserverID")
+	T_btchar, _ := c.GetInt("T_btchar")
 
 	Device_r, err := Device.Read_Device_ByT_sn(T_SN)
 	if err != nil {
@@ -707,7 +703,6 @@ func (c *DeviceController) Pu_DeviceParameter() {
 		return
 	}
 
-
 	Admin_Power_, _ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
 	if Admin_Power_.Power_DeviceSensor_Compensate_e == 0 {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "! U" + strconv.Itoa(admin_r.Id)}
@@ -734,22 +729,22 @@ func (c *DeviceController) Pu_DeviceParameter() {
 		T_chDecTotal:   T_chDecTotal,
 		T_decTotal:     strconv.Itoa(T_decTotal),
 		T_enwarning:    T_enwarning,
-		T_company:    T_company,
-		T_btname:    T_btname,
-		T_btserverID:    strconv.Itoa(T_btserverID),
-		T_btchar:    strconv.Itoa(T_btchar),
+		T_company:      T_company,
+		T_btname:       T_btname,
+		T_btserverID:   strconv.Itoa(T_btserverID),
+		T_btchar:       strconv.Itoa(T_btchar),
 	}
-	Deviceparameter,is :=Device.Add_DeviceParameter(Deviceparameter)
+	Deviceparameter, is := Device.Add_DeviceParameter(Deviceparameter)
 	if !is {
-		c.Data["json"] = lib.JSONS{Code: 203, Msg: "Add_DeviceParameter ERR" }
+		c.Data["json"] = lib.JSONS{Code: 203, Msg: "Add_DeviceParameter ERR"}
 		c.ServeJSON()
 		return
 	}
-	System.Add_UserLogs_T(admin_r.Admin_uuid,"设备管理", "设备参数操作", Deviceparameter)
+	System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "设备参数操作", Deviceparameter)
 	Nats.Pu_DeviceParameter(Deviceparameter)
 
 	Device_r.T_devName = Deviceparameter.T_devName
-	Device.Update_Device(Device_r,"T_devName")
+	Device.Update_Device(Device_r, "T_devName")
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
@@ -781,7 +776,7 @@ func (c *DeviceController) Pu_DeviceParameter_T_l_p() {
 	Device_r.T_l_p = T_l_p
 	Device.Update_Device(Device_r, "T_l_p")
 	Device.DeviceSensor_T_l_p_ALL(T_SN, T_l_p)
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "设备参数操作", "类型选择(1物流端   2药店端):"+string(T_l_p))
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "设备参数操作", "类型选择(1物流端   2药店端):"+string(T_l_p))
 
 	c.Data["json"] = lib.JSONS{Code: 222, Msg: "ok!"}
 	c.ServeJSON()
@@ -813,9 +808,9 @@ func (c *DeviceController) Pu_DeviceParameter_T_give() {
 	Device_r.T_give = T_give
 	Device.Update_Device(Device_r, "T_give")
 	Device.DeviceSensor_t_give_ALL(T_SN, T_give)
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "设备丢弃参数操作", "设备丢弃( 0 丢弃  1 正常):"+string(T_give))
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "设备丢弃参数操作", "设备丢弃( 0 丢弃  1 正常):"+string(T_give))
 
-	c.Data["json"] = lib.JSONS{Code: 222, Msg: "ok!"}
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 
@@ -885,14 +880,13 @@ func (c *DeviceController) Pu_DeviceParameter_Sensor() {
 
 	T_SN := c.GetString("T_SN")
 	T_name := c.GetString("T_name")
-	T_id,_ := c.GetInt("T_id")
-	T_Tlower,_ := c.GetFloat("T_Tlower")
-	T_Tupper,_ := c.GetFloat("T_Tupper")
-	T_RHlower,_ := c.GetFloat("T_RHlower")
-	T_RHupper,_ := c.GetFloat("T_RHupper")
-	T_en,_ := c.GetInt("T_en")
-	T_free,_ := c.GetInt("T_free")
-
+	T_id, _ := c.GetInt("T_id")
+	T_Tlower, _ := c.GetFloat("T_Tlower")
+	T_Tupper, _ := c.GetFloat("T_Tupper")
+	T_RHlower, _ := c.GetFloat("T_RHlower")
+	T_RHupper, _ := c.GetFloat("T_RHupper")
+	T_en, _ := c.GetInt("T_en")
+	T_free, _ := c.GetInt("T_free")
 
 	// 权限 过滤
 	Admin_Power_, _ := Admin.Read_AdminPower_ById(admin_r.Admin_power)
@@ -909,7 +903,7 @@ func (c *DeviceController) Pu_DeviceParameter_Sensor() {
 		return
 	}
 
-	DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(T_SN,T_id)
+	DeviceSensor, is := Device.Read_DeviceSensor_ByT_sn(T_SN, T_id)
 	if !is {
 		c.Data["json"] = lib.JSONS{Code: 208, Msg: "T_sn T_id Err!"}
 		c.ServeJSON()
@@ -931,7 +925,7 @@ func (c *DeviceController) Pu_DeviceParameter_Sensor() {
 		T_SendState: 0,
 		T_State:     2,
 	}
-	dsp_id,is := Device.Add_DeviceSensorParameter(Devicesensorparameter)
+	dsp_id, is := Device.Add_DeviceSensorParameter(Devicesensorparameter)
 	if !is {
 		c.Data["json"] = lib.JSONS{Code: 209, Msg: "添加失败!"}
 		c.ServeJSON()
@@ -941,18 +935,18 @@ func (c *DeviceController) Pu_DeviceParameter_Sensor() {
 
 	// 更新名称
 	DeviceSensor.T_name = T_name
-	Device.Update_DeviceSensor(DeviceSensor,"T_name")
+	Device.Update_DeviceSensor(DeviceSensor, "T_name")
 
-	System.Add_UserLogs_T(admin_r.Admin_uuid,"设备管理", "传感器参数操作", Devicesensorparameter)
+	System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "传感器参数操作", Devicesensorparameter)
 
 	Nats.Pu_DeviceParameter_Sensor(Devicesensorparameter)
 
-
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 
 }
+
 ////
 //func (c *DeviceController) Pu_DeviceParameter_Sensor_Cache() {
 //	// 验证登录
@@ -1028,7 +1022,6 @@ func (c *DeviceController) DeviceWarning_List_html() {
 	Time_start := c.GetString("Time_start")
 	Time_end := c.GetString("Time_end")
 
-
 	if len(Time_start) == 0 && len(Time_end) == 0 {
 		Time_start = time.Now().Format("2006-01-02") + " 00:00:00"
 		Time_end = time.Now().Format("2006-01-02") + " 23:59:59"
@@ -1044,14 +1037,14 @@ func (c *DeviceController) DeviceWarning_List_html() {
 	//}
 
 	var cnt int64
-	DeviceWarning_List, cnt := Device.Read_DeviceWarning_1(admin_r, page,"", T_Name, Time_start, Time_end)
+	DeviceWarning_List, cnt := Device.Read_DeviceWarning_1(admin_r, page, "", T_Name, Time_start, Time_end)
 
-	for i, v := range DeviceWarning_List {
-		DeviceWarning_List[i].T_State = 0
-		if strings.Contains(v.T_sn, "YD"){
-			DeviceWarning_List[i].T_State = 1
-		}
-	}
+	//for i, v := range DeviceWarning_List {
+	//	DeviceWarning_List[i].T_State = 0
+	//	if strings.Contains(v.T_sn, "YD") {
+	//		DeviceWarning_List[i].T_State = 1
+	//	}
+	//}
 
 	c.Data["List"] = DeviceWarning_List
 	page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
@@ -1075,12 +1068,12 @@ func (c *DeviceController) DeviceWarning_List() {
 
 	type R_JSONS struct {
 		//必须的大写开头
-		DeviceWarning      []Device.DeviceWarning
-		DeviceWarningclass []Device.DeviceWarningList
-		Num                int
-		Page               int
-		Page_size          int
-		Pages              []lib.Page_T
+		DeviceWarning []Device.DeviceWarning
+		//DeviceWarningclass []Device.DeviceWarningList
+		Num       int
+		Page      int
+		Page_size int
+		Pages     []lib.Page_T
 	}
 	var r_jsons R_JSONS
 	page, _ := c.GetInt("page")
@@ -1096,14 +1089,14 @@ func (c *DeviceController) DeviceWarning_List() {
 	Time_start := c.GetString("Time_start")
 	Time_end := c.GetString("Time_end")
 
-	r_jsons.DeviceWarningclass = Device.Read_DeviceWarningList_All_1()
+	//r_jsons.DeviceWarningclass = Device.Read_DeviceWarningList_All_1()
 	//T_Title := ""
 	//if Class_1 > 0 {
 	//	T_Title = Device.Read_DeviceWarningList_ById(Class_1).T_name
 	//}
 
 	var cnt int64
-	r_jsons.DeviceWarning, cnt = Device.Read_DeviceWarning_1(admin_r, page,T_sn, T_Name, Time_start, Time_end)
+	r_jsons.DeviceWarning, cnt = Device.Read_DeviceWarning_1(admin_r, page, T_sn, T_Name, Time_start, Time_end)
 
 	page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
 	r_jsons.Page = int(page)
@@ -1144,7 +1137,7 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
 	//	T_Title = Device.Read_DeviceWarningList_ById(Class_1).T_name
 	//}
 
-	Device_data, _ := Device.Read_DeviceWarning_1(admin_r, 9999,"", T_Name, Time_start, Time_end)
+	Device_data, _ := Device.Read_DeviceWarning_1(admin_r, 9999, "", T_Name, Time_start, Time_end)
 
 	f := excelize.NewFile() // 设置单元格的值
 	// 这里设置表头
@@ -1193,17 +1186,17 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
 		fmt.Println(err)
 	}
 
-	url,is := Nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
+	url, is := Nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
 	if !is {
 		c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
 		c.ServeJSON()
 		return
 	}
 	//删除目录
-	err := os.Remove("ofile/" + timeStr + ".xlsx")
-	if err != nil {
-		fmt.Println(err)
-	}
+	//err := os.Remove("ofile/" + timeStr + ".xlsx")
+	//if err != nil {
+	//	fmt.Println(err)
+	//}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
 	c.ServeJSON()
@@ -1240,7 +1233,7 @@ func (c *DeviceController) DeviceWarning_Post() {
 
 	Device.Update_DeviceWarning_ById(t_c)
 
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "报警处理操作", strconv.Itoa(Id)+"->"+T_Text)
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "报警处理操作", strconv.Itoa(Id)+"->"+T_Text)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -1255,12 +1248,12 @@ func (c *DeviceController) DeviceWarning_Del() {
 
 	Id, _ := c.GetInt("Id")
 	t_c := Device.DeviceWarning{
-		Id:     Id,
+		Id: Id,
 	}
 
 	Device.Update_DeviceWarning_Delete(t_c)
 
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "报警删除操作", strconv.Itoa(Id))
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "报警删除操作", strconv.Itoa(Id))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -1342,10 +1335,6 @@ func (c *DeviceController) DeviceBind_List() {
 		page_z = conf.Page_size
 	}
 
-
-
-
-
 	Class_1 := c.GetString("Class_1")
 	Name := c.GetString("Name")
 	T_sn := c.GetString("T_sn")
@@ -1360,7 +1349,7 @@ func (c *DeviceController) DeviceBind_List() {
 	//c.Data["T_sn"] = T_sn
 
 	var cnt int64
-	Device_lite, cnt := Device.Read_Device_ALL_bind_1(admin_r, page,page_z, T_sn, Name, Class_1,T_monitor)
+	Device_lite, cnt := Device.Read_Device_ALL_bind_1(admin_r, page, page_z, T_sn, Name, Class_1, T_monitor)
 	//for i, _ := range Device_lite {
 	//
 	//	//监控状态
@@ -1410,15 +1399,15 @@ func (c *DeviceController) DeviceBind_Sensor_List() {
 	}
 	// 模板
 	type R_DeviceSensor struct {
-		T_sn          string                // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
-		T_devName     string                //设备名称
-		T_sensor      int                   //  传感器数量
-		T_monitor      int                   //  监控状态 1 监控  0 未监控
-		T_sn_yd      int                   //  湿度显示
-		T_battery      int                   // 电量
-		T_sensor_list []Device.DeviceSensor //  传感器List
-		T_MSISDN     string                //设备名称
-		UpdateTime time.Time //auto_now 每次 model 保存时都会对时间自动更新
+		T_sn          string                  // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
+		T_devName     string                  //设备名称
+		T_sensor      int                     //  传感器数量
+		T_monitor     int                     //  监控状态 1 监控  0 未监控
+		T_sn_yd       int                     //  湿度显示
+		T_battery     int                     // 电量
+		T_sensor_list []Device.DeviceSensor_R //  传感器List
+		T_MSISDN      string                  //设备名称
+		UpdateTime    time.Time               //auto_now 每次 model 保存时都会对时间自动更新
 	}
 
 	type R_JSONS struct {
@@ -1442,10 +1431,6 @@ func (c *DeviceController) DeviceBind_Sensor_List() {
 		page_z = conf.Page_size
 	}
 
-
-
-
-
 	Class_1 := c.GetString("Class_1")
 	Name := c.GetString("Name")
 	T_sn := c.GetString("T_sn")
@@ -1460,11 +1445,11 @@ func (c *DeviceController) DeviceBind_Sensor_List() {
 	//c.Data["T_sn"] = T_sn
 
 	var cnt int64
-	Device_lite, cnt := Device.Read_Device_ALL_bind_1(admin_r, page,page_z, T_sn, Name, Class_1,T_monitor)
+	Device_lite, cnt := Device.Read_Device_ALL_bind_1(admin_r, page, page_z, T_sn, Name, Class_1, T_monitor)
 	for _, v := range Device_lite {
 		r_Device := R_DeviceSensor{}
 		r_Device.T_sn_yd = 0
-		if strings.Contains(v.T_sn, "YD"){
+		if strings.Contains(v.T_sn, "YD") {
 			r_Device.T_sn_yd = 1
 		}
 
@@ -1474,7 +1459,6 @@ func (c *DeviceController) DeviceBind_Sensor_List() {
 		r_Device.T_sensor_list, r_Device.T_sensor = Device.Read_DeviceSensor_ByTsn(v.T_sn)
 		r_Device.T_monitor = v.T_monitor
 
-
 		// 电量
 		DeviceSensorData, is := Device.Read_DeviceSensorData_ById_New(v.T_sn, 0)
 		if is {
@@ -1484,7 +1468,6 @@ func (c *DeviceController) DeviceBind_Sensor_List() {
 		r_jsons.Device_lite = append(r_jsons.Device_lite, r_Device)
 	}
 
-
 	page_size := math.Ceil(float64(cnt) / float64(page_z))
 	r_jsons.Page = page
 	r_jsons.Page_size = int(page_size)
@@ -1536,9 +1519,9 @@ func (c *DeviceController) DeviceBind_Add_All() {
 		}
 
 		T_Bind := Device.Device_Bind_Add(v.T_sn, user_r)
-		Device.DeviceSensor_T_Bind_ALL(v.T_sn,T_Bind)
+		Device.DeviceSensor_T_Bind_ALL(v.T_sn, T_Bind)
 
-		System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "设备绑定", v.T_sn+"+>"+c.GetString("Admin_uuid"))
+		System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "设备绑定", v.T_sn+"+>"+c.GetString("Admin_uuid"))
 		num_x = num_x + 1
 	}
 
@@ -1583,9 +1566,9 @@ func (c *DeviceController) DeviceBind_Add() {
 	}
 	// 同步权限
 	T_Bind := Device.Device_Bind_Add(T_sn, user_r)
-	Device.DeviceSensor_T_Bind_ALL(T_sn,T_Bind)
+	Device.DeviceSensor_T_Bind_ALL(T_sn, T_Bind)
 
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "设备绑定", T_sn+"+>"+c.GetString("Admin_uuid"))
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "设备绑定", T_sn+"+>"+c.GetString("Admin_uuid"))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -1627,9 +1610,9 @@ func (c *DeviceController) DeviceBind_Del() {
 
 	// 同步权限
 	T_Bind := Device.Device_Bind_Del(T_sn, user_r)
-	Device.DeviceSensor_T_Bind_ALL(T_sn,T_Bind)
+	Device.DeviceSensor_T_Bind_ALL(T_sn, T_Bind)
 
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "设备解除绑定", T_sn+"->"+c.GetString("Admin_uuid"))
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "设备解除绑定", T_sn+"->"+c.GetString("Admin_uuid"))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -1684,33 +1667,53 @@ func (c *DeviceController) DeviceClass_Post() {
 	Id, _ := c.GetInt("Id")
 	T_name := c.GetString("T_name")
 	T_Notice_wx := c.GetString("T_Notice_wx")
+	T_Notice_wx2 := c.GetString("T_Notice_wx2")
 	T_Notice_phone := c.GetString("T_Notice_phone")
 	T_Notice_message := c.GetString("T_Notice_message")
 	T_Notice_mailbox := c.GetString("T_Notice_mailbox")
+	T_Notice_mechanism := c.GetString("T_Notice_mechanism")
 	t_c := Device.DeviceClass{
-		Id:               Id,
-		T_name:           T_name,
-		T_Notice_wx:      T_Notice_wx,
-		T_Notice_phone:   T_Notice_phone,
-		T_Notice_message: T_Notice_message,
-		T_Notice_mailbox: T_Notice_mailbox,
+		Id:                 Id,
+		T_name:             T_name,
+		T_Notice_wx:        T_Notice_wx,
+		T_Notice_wx2:       T_Notice_wx2,
+		T_Notice_phone:     T_Notice_phone,
+		T_Notice_message:   T_Notice_message,
+		T_Notice_mailbox:   T_Notice_mailbox,
+		T_Notice_mechanism: T_Notice_mechanism,
 	}
 	if Id == 0 {
 		t_c.T_State = 1
 		t_c.T_uuid = admin_r.Admin_uuid
 		t_c.T_Notice_wx = ""
+		t_c.T_Notice_wx2 = ""
 		t_c.T_Notice_phone = ""
 		t_c.T_Notice_message = ""
 		t_c.T_Notice_mailbox = ""
+		t_c.T_Notice_mechanism = Device.Read_DeviceWarningList_All_T_Notice_mechanism()
 		Device.Add_Class(t_c)
 	} else {
 		Device.Update_Class_ById(t_c)
 	}
-	System.Add_UserLogs_T(admin_r.Admin_uuid,"设备管理", "分类操作", t_c)
+	System.Add_UserLogs_T(admin_r.Admin_uuid, "设备管理", "分类操作", t_c)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
 }
+
+func (c *DeviceController) DeviceWarningList_T_Tips() {
+	// 验证登录
+	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Device.Read_DeviceWarningList_All_T_Notice_mechanism()}
+	c.ServeJSON()
+	return
+}
 func (c *DeviceController) DeviceClass_Del() {
 	// 验证登录
 	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
@@ -1740,7 +1743,7 @@ func (c *DeviceController) DeviceClass_Del() {
 		Device.DeviceSensor_Bind_Del(v.T_sn, v.T_id, id)
 
 	}
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "删除分类操作", strconv.Itoa(id))
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "删除分类操作", strconv.Itoa(id))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -1805,17 +1808,16 @@ func (c *DeviceController) DeviceClass_Syn() {
 			//Device_r, _ := Device.Read_Device_ByT_sn(v_c.T_sn)
 			//Device.DeviceSensor_T_Bind_Add(v_c.T_sn, v_c.T_id, user_r)
 			T_Bind := Device.Device_Bind_Add(v_c.T_sn, user_r)
-			Device.DeviceSensor_T_Bind_ALL(v_c.T_sn,T_Bind)
+			Device.DeviceSensor_T_Bind_ALL(v_c.T_sn, T_Bind)
 		}
 		//
 	}
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "同步分类操作", "->"+user_r.Admin_uuid)
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "同步分类操作", "->"+user_r.Admin_uuid)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: num_x}
 	c.ServeJSON()
 	return
 }
 
-
 func (c *DeviceController) DeviceClassBind_html_() {
 	// 验证登录
 	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
@@ -1933,7 +1935,7 @@ func (c *DeviceController) DeviceClassBind_Add() {
 		return
 	}
 	Device.DeviceSensor_T_Calss_Add(T_sn, T_id, T_class_id)
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "分类绑定操作", strconv.Itoa(T_class_id)+"+>"+T_sn+"-"+strconv.Itoa(T_id))
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "分类绑定操作", strconv.Itoa(T_class_id)+"+>"+T_sn+"-"+strconv.Itoa(T_id))
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
 	return
@@ -1982,7 +1984,7 @@ func (c *DeviceController) DeviceClassBind_Del() {
 	}
 
 	Device.DeviceSensor_Bind_Del(T_sn, T_id, T_class_id)
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "分类删除绑定操作", strconv.Itoa(T_class_id)+"->"+T_sn+"-"+strconv.Itoa(T_id))
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "分类删除绑定操作", strconv.Itoa(T_class_id)+"->"+T_sn+"-"+strconv.Itoa(T_id))
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
@@ -2016,8 +2018,6 @@ func (c *DeviceController) Get_DeviceClassId() {
 	return
 }
 
-
-
 // 任务列表
 func (c *DeviceController) DeviceTask_List() {
 	// 验证登录
@@ -2032,8 +2032,7 @@ func (c *DeviceController) DeviceTask_List() {
 	Time_end := c.GetString("Time_end")
 	Time_start := c.GetString("Time_start")
 
-
-	DeviceTask_lite, _ := Device.Read_DeviceTask_All_50(T_sn,Time_end,Time_start)
+	DeviceTask_lite, _ := Device.Read_DeviceTask_All_50(T_sn, Time_end, Time_start)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: DeviceTask_lite}
 	c.ServeJSON()
@@ -2041,7 +2040,6 @@ func (c *DeviceController) DeviceTask_List() {
 
 }
 
-
 // 任务列表
 func (c *DeviceController) DeviceTask_Post() {
 	// 验证登录
@@ -2055,12 +2053,11 @@ func (c *DeviceController) DeviceTask_Post() {
 	T_sn := c.GetString("T_sn")
 	T_task := c.GetString("T_task")
 
-
 	Nats.Set_DeviceTask(Device.Device_task{
-		T_sn:T_sn,
-		T_task:T_task,
+		T_sn:   T_sn,
+		T_task: T_task,
 	})
-	System.Add_UserLogs(admin_r.Admin_uuid,"设备管理", "远程启停", T_sn+"-"+T_task)
+	System.Add_UserLogs(admin_r.Admin_uuid, "设备管理", "远程启停", T_sn+"-"+T_task)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
 	c.ServeJSON()
@@ -2068,3 +2065,62 @@ func (c *DeviceController) DeviceTask_Post() {
 
 }
 
+func (c *DeviceController) Get_DeviceClassId_QRCode() {
+	// 验证登录
+	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	T_calss_id := c.GetString("T_class_id")
+	if len(T_calss_id) == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_calss_id Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	T_calss_id_str, _ := Nats.Wx_GenerateQRCode("-|" + lib.AesEncryptCBC(T_calss_id, "0123456789012345") + "|- @宝智达 微信公众号通知")
+	if len(T_calss_id_str) == 0 {
+		c.Data["json"] = lib.JSONS{Code: 201, Msg: "Err!"}
+		c.ServeJSON()
+		return
+	}
+
+	type Text struct {
+		QR   string
+		Code string
+	}
+
+	T_calss_id_str = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + T_calss_id_str
+	Text_r := Text{
+		QR:   T_calss_id_str,
+		Code: "请将本内容发送到 深圳市宝智达科技有限公司 微信公众号-|" + lib.AesEncryptCBC(T_calss_id, "0123456789012345") + "|- @宝智达 微信公众号通知    ",
+	}
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Text_r}
+	c.ServeJSON()
+	return
+}
+
+// 列表 - 设备日志
+func (c *DeviceController) DeviceLogs() {
+	page, _ := c.GetInt("page")
+	println(page)
+	if page < 1 {
+		page = 1
+	}
+
+	T_sn := c.GetString("T_sn")
+	c.Data["T_sn"] = T_sn
+
+	var cnt int64
+	c.Data["List"], cnt = System.Read_DeviceLogs_ALL(page, T_sn)
+	page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
+	c.Data["Page"] = page
+	c.Data["Page_size"] = page_size
+	c.Data["Pages"] = lib.Func_page(int64(page), int64(page_size))
+	c.Data["cnt"] = cnt
+
+	c.TplName = "Device/DeviceLogs.html"
+}

+ 0 - 307
controllers/Wx.go

@@ -1,307 +0,0 @@
-package controllers
-
-import (
-	"Cold_Api/controllers/lib"
-	"Cold_Api/models/Device"
-	"crypto/sha1"
-	"encoding/json"
-	"encoding/xml"
-	"fmt"
-	beego "github.com/beego/beego/v2/server/web"
-	"io"
-	"sort"
-	"strconv"
-	"strings"
-	"time"
-)
-
-type WxController struct {
-	beego.Controller
-}
-/**
- * 实例化文字消息
- * toUser:openId
- * content:文本内容
- */
-//反序列化结构体定义
-type Person_QRCode struct {
-	ToUserName  string `xml:"ToUserName"`  //注意这里有个反引号
-	FromUserName  string `xml:"FromUserName"`  //注意这里有个反引号
-	CreateTime  string `xml:"CreateTime"`  //注意这里有个反引号
-	EventKey   string `xml:"EventKey"`
-}
-type Person_Msg struct {
-	ToUserName  string `xml:"ToUserName"`  //注意这里有个反引号
-	FromUserName  string `xml:"FromUserName"`  //注意这里有个反引号
-	CreateTime  string `xml:"CreateTime"`  //注意这里有个反引号
-	Content   string `xml:"Content"`
-}
-
-// 列表 - http://cloud.hoooooo.cn/
-func (c *WxController) Wx_handler() {
-	//Time_start :=
-
-	fmt.Println("RequestBody-",string(c.Ctx.Input.RequestBody))
-	var ob map[string]interface{}
-	var err error
-	if err = json.Unmarshal(c.Ctx.Input.RequestBody, &ob); err == nil {
-
-	} else {
-
-	}
-
-
-	if(strings.Contains(string(c.Ctx.Input.RequestBody), "EventKey")){
-		var person_QRCode Person_QRCode
-		err1:=xml.Unmarshal(c.Ctx.Input.RequestBody,&person_QRCode)
-		if err1!=nil{
-			fmt.Println("Unmarshal error")
-			return
-		}
-		// 进入 二维码配对
-		fmt.Println("FromUserName-",person_QRCode.FromUserName)
-		fmt.Println("EventKey-",person_QRCode.EventKey)
-
-		type xml struct {
-			ToUserName     string
-			FromUserName string
-			CreateTime int64
-			MsgType string
-			Content string
-		}
-		// 开始  处理消息
-		if(strings.Contains(string(person_QRCode.EventKey), "@宝智达 微信公众号通知")){
-			//"请将本内容发送到 深圳市宝智达科技有限公司 微信公众号-|"+lib.AesEncryptCBC(T_calss_id, "0123456789012345")+"|-",
-			Content_r := lib.GetBetweenStr(person_QRCode.EventKey,"-|","|-")
-			decryptCode := lib.AesDecryptCBC(Content_r, "0123456789012345")
-			decryptCode_int,err:=strconv.Atoi(decryptCode)
-			fmt.Println("解密结果:", decryptCode,"  decryptCode_int",decryptCode_int,"  Content_r:",Content_r)
-			R_DeviceClass,err := Device.Read_Class_ById(decryptCode_int);
-			if err != nil {
-
-
-				return
-			}
-
-			if(strings.Contains(R_DeviceClass.T_Notice_wx, person_QRCode.FromUserName)){
-				var p= xml{
-					ToUserName:person_QRCode.FromUserName,
-					FromUserName:person_QRCode.ToUserName,
-					CreateTime:time.Now().Unix(),
-					MsgType:"text",
-					Content: "已绑定,无需重复绑定!",
-				}
-
-				c.Data["xml"]=&p
-				c.ServeXML()
-				return
-			}
-
-			R_DeviceClass.T_Notice_wx = R_DeviceClass.T_Notice_wx + person_QRCode.FromUserName + "/重令名|"
-			Device.Update_Class_ById(R_DeviceClass)
-
-			var p= xml{
-				ToUserName:person_QRCode.FromUserName,
-				FromUserName:person_QRCode.ToUserName,
-				CreateTime:time.Now().Unix(),
-				MsgType:"text",
-				Content: "绑定成功!",
-			}
-
-			c.Data["xml"]=&p
-			c.ServeXML()
-			return
-		}
-
-
-		var p= xml{
-			ToUserName:person_QRCode.FromUserName,
-			FromUserName:person_QRCode.ToUserName,
-			CreateTime:time.Now().Unix(),
-			MsgType:"text",
-			Content: "",
-		}
-
-		c.Data["xml"]=&p
-		c.ServeXML()
-		return
-	}else {
-		var person_Msg Person_Msg
-		err1:=xml.Unmarshal(c.Ctx.Input.RequestBody,&person_Msg)
-		if err1!=nil{
-			fmt.Println("Unmarshal error")
-			return
-		}
-		if(len(person_Msg.Content) > 0){
-			fmt.Println("FromUserName-",person_Msg.FromUserName)
-			fmt.Println("Content-",person_Msg.Content)
-
-		}
-		// 开始  处理消息
-		type xml struct {
-			ToUserName     string
-			FromUserName string
-			CreateTime int64
-			MsgType string
-			Content string
-		}
-		if(strings.Contains(string(person_Msg.Content), "@宝智达 微信公众号通知")){
-			//"请将本内容发送到 深圳市宝智达科技有限公司 微信公众号-|"+lib.AesEncryptCBC(T_calss_id, "0123456789012345")+"|-",
-			Content_r := lib.GetBetweenStr(person_Msg.Content,"-|","|-")
-			decryptCode := lib.AesDecryptCBC(Content_r, "0123456789012345")
-			decryptCode_int,err:=strconv.Atoi(decryptCode)
-			fmt.Println("解密结果:", decryptCode,"  decryptCode_int",decryptCode_int,"  Content_r:",Content_r)
-			R_DeviceClass,err := Device.Read_Class_ById(decryptCode_int);
-			if err != nil {
-				c.Data["json"] = lib.JSONS{Code: 205, Msg: "T_class_id Err!"}
-				c.ServeJSON()
-				return
-			}
-			if(strings.Contains(R_DeviceClass.T_Notice_wx, person_Msg.FromUserName)){
-				var p= xml{
-					ToUserName:person_Msg.FromUserName,
-					FromUserName:person_Msg.ToUserName,
-					CreateTime:time.Now().Unix(),
-					MsgType:"text",
-					Content: "已绑定,无需重复绑定!",
-				}
-
-				c.Data["xml"]=&p
-				c.ServeXML()
-				return
-			}
-			R_DeviceClass.T_Notice_wx = R_DeviceClass.T_Notice_wx + person_Msg.FromUserName + "/重令名|"
-			Device.Update_Class_ById(R_DeviceClass)
-
-			var p= xml{
-				ToUserName:person_Msg.FromUserName,
-				FromUserName:person_Msg.ToUserName,
-				CreateTime:time.Now().Unix(),
-				MsgType:"text",
-				Content: "绑定成功!",
-			}
-
-			c.Data["xml"]=&p
-			c.ServeXML()
-			return
-		}
-
-
-
-
-
-		var p= xml{
-			ToUserName:person_Msg.FromUserName,
-			FromUserName:person_Msg.ToUserName,
-			CreateTime:time.Now().Unix(),
-			MsgType:"text",
-			Content: "",
-		}
-
-		c.Data["xml"]=&p
-		c.ServeXML()
-		return
-	}
-
-	//<xml><ToUserName><![CDATA[gh_cc23d9b3bca2]]></ToUserName>
-	//<FromUserName><![CDATA[o5EKB1buEEsyDP6u-6H3H326T4no]]></FromUserName>
-	//<CreateTime>1641111908</CreateTime>
-	//<MsgType><![CDATA[event]]></MsgType>
-	//<Event><![CDATA[SCAN]]></Event>
-	//<EventKey><![CDATA[3]]></EventKey>
-	//<Ticket><![CDATA[gQGM7zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyLUNscnRUQTJlMWwxWG9ycXh4YzYAAgRYYdFhAwSAOgkA]]></Ticket>
-	//</xml>
-
-
-	//
-	//fmt.Println("Per-",person_QRCode)
-	//fmt.Println("ob-",ob)
-
-
-	//var ob User//这是一个model,struct类型
-	//body := this.Ctx.Input.RequestBody//这是获取到的json二进制数据
-	//json.Unmarshal(body, &ob)//解析二进制json,把结果放进ob中
-	//user := &User{Id: ob.UserName, Mobile: ob.Mobile}
-	//err := user.AddUser()//这是添加用户函数
-	//if nil != err {
-	//	this.Data["json"] = map[string]interface{}{"result": false, "msg": err}
-	//} else {
-	//	this.Data["json"] = map[string]interface{}{"result": true, "msg": "新增成功"}
-	//}
-	//this.ServeJSON()
-
-	c.Ctx.WriteString("")
-	return
-}
-
-
-// 验证 服务器配置
-func (c *WxController) Wx() {
-	//
-	timestamp := c.GetString("timestamp")
-	nonce := c.GetString("nonce")
-	signatureIn := c.GetString("signature")
-	echostr := c.GetString("echostr")
-	println("timestamp:",timestamp)
-	println("nonce:",nonce)
-	println("signatureIn:",signatureIn)
-
-	signatureGen := MakeSignature("gPc", timestamp, nonce)
-	println("signatureGen:",signatureGen)
-
-	if signatureGen != signatureIn {
-		return
-	}
-
-	c.Ctx.WriteString(echostr)
-	return
-}
-
-
-func MakeSignature(token, timestamp, nonce string) string {
-	strs := []string{token, timestamp, nonce}
-	sort.Strings(strs)
-	sha := sha1.New()
-	io.WriteString(sha, strings.Join(strs, ""))
-	return fmt.Sprintf("%x", sha.Sum(nil))
-}
-
-func (c *WxController) Get_DeviceClassId_QRCode() {
-	// 验证登录
-	b_,_ := lib.Verification(c.Ctx.GetCookie("User_tokey"),c.GetString("User_tokey"))
-	if(!b_){
-		c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
-		c.ServeJSON()
-		return
-	}
-
-	T_calss_id := c.GetString("T_class_id")
-	if(len(T_calss_id) == 0){
-		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_calss_id Err!"}
-		c.ServeJSON()
-		return
-	}
-	//T_calss_id_str := lib.GenerateQRCode( "-|"+lib.AesEncryptCBC(T_calss_id, "0123456789012345")+"|- @宝智达 微信公众号通知")
-	//if(len(T_calss_id_str) == 0){
-	//	c.Data["json"] = lib.JSONS{Code: 201, Msg: "Err!"}
-	//	c.ServeJSON()
-	//	return
-	//}
-
-
-	type Text struct {
-		QR     string
-		Code string
-	}
-
-
-	//
-	//T_calss_id_str = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + T_calss_id_str
-	//Text_r := Text{
-	//	QR:T_calss_id_str,
-	//	Code:"请将本内容发送到 深圳市宝智达科技有限公司 微信公众号-|"+lib.AesEncryptCBC(T_calss_id, "0123456789012345")+"|- @宝智达 微信公众号通知    ",
-	//}
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!",Data: "Text_r"}
-	c.ServeJSON()
-	return
-}

+ 2 - 4
go.mod

@@ -11,7 +11,7 @@ require (
 	github.com/nats-io/nats.go v1.16.0
 	github.com/satori/go.uuid v1.2.0
 	github.com/signintech/gopdf v0.13.0
-	github.com/smartystreets/goconvey v1.6.4
+	github.com/vmihailenco/msgpack v4.0.4+incompatible
 	github.com/vmihailenco/msgpack/v5 v5.3.5
 	github.com/xuri/excelize/v2 v2.6.0
 )
@@ -21,9 +21,7 @@ require (
 	github.com/cespare/xxhash/v2 v2.1.1 // indirect
 	github.com/golang/protobuf v1.4.2 // indirect
 	github.com/gomodule/redigo v2.0.0+incompatible // indirect
-	github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
 	github.com/hashicorp/golang-lru v0.5.4 // indirect
-	github.com/jtolds/gls v4.20.0+incompatible // indirect
 	github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
 	github.com/mitchellh/mapstructure v1.3.3 // indirect
 	github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
@@ -39,7 +37,6 @@ require (
 	github.com/richardlehane/mscfb v1.0.4 // indirect
 	github.com/richardlehane/msoleps v1.0.1 // indirect
 	github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
-	github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
 	github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
 	github.com/xuri/efp v0.0.0-20220407160117-ad0f7a785be8 // indirect
 	github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
@@ -50,6 +47,7 @@ require (
 	golang.org/x/text v0.3.7 // indirect
 	golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58 // indirect
 	golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
+	google.golang.org/appengine v1.4.0 // indirect
 	google.golang.org/protobuf v1.23.0 // indirect
 	gopkg.in/yaml.v2 v2.2.8 // indirect
 )

+ 3 - 9
go.sum

@@ -79,8 +79,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
-github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
 github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
 github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
@@ -89,8 +87,6 @@ github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
 github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
-github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
-github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
@@ -183,10 +179,6 @@ github.com/signintech/gopdf v0.13.0 h1:1+pzfg2ll84NHvKvHCiXQ5XOqWaJ6M9xKmboBfyeP
 github.com/signintech/gopdf v0.13.0/go.mod h1:a+E8HlIuBwghPyoo7UaoB5UaL7zklDzmYVIAHoW/Rlw=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
-github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
-github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
-github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
-github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
 github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -199,6 +191,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
 github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
 github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
+github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
+github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
 github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
 github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
 github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
@@ -294,7 +288,6 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm
 golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
-golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@@ -310,6 +303,7 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=

BIN
go_build_main_go.exe


+ 1 - 1
lastupdate.tmp

@@ -1 +1 @@
-{"C:\\BZD\\Cold\\Cold_Api\\controllers":1657280451788999500}
+{"C:\\BZD\\Cold\\Cold_Api\\controllers":1657790871544273100}

+ 6 - 6
models/Device/Device.go

@@ -9,7 +9,6 @@ import (
 	_ "github.com/astaxie/beego/cache/redis"
 	orm2 "github.com/beego/beego/v2/client/orm"
 
-
 	"github.com/beego/beego/v2/adapter/orm"
 	_ "github.com/go-sql-driver/mysql"
 	"strconv"
@@ -32,8 +31,10 @@ type Device struct {
 	T_Putime_Parameter time.Time `orm:"type(timestamp);null;"` // 参数时间
 	T_Bind             string    `orm:"size(256);null"`        //设备绑定  Uid
 
-	T_monitor int `orm:"size(22);null"` //  监控状态 1 监控  0 未监控
-	T_err     int `orm:"size(2);1"`     // 0 正常  1 异常
+	T_monitor int `orm:"size(22);null"`  //  监控状态 1 监控  0 未监控
+	T_online  int `orm:"size(22);1"`     //  在线状态 1 在线  0 离线
+	T_Dattery int `orm:"size(256);null"` //电量
+	T_err     int `orm:"size(2);1"`      // 0 正常  1 异常
 
 	T_State    int       `orm:"size(2);1"`                                             // 0 删除   1 正常
 	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
@@ -41,7 +42,7 @@ type Device struct {
 }
 
 type Device_task struct {
-	T_sn string
+	T_sn   string
 	T_task string
 }
 
@@ -257,7 +258,7 @@ func Read_Device_ALL_bind_1(user_ Admin.Admin, page int, page_z int, T_sn string
 	}
 
 	// 非内部权限
-	println("user_.Admin_power:",user_.Admin_power)
+	println("user_.Admin_power:", user_.Admin_power)
 	if user_.Admin_power > 6 {
 		cond1 = cond.AndCond(cond1).AndCond(cond.And("T_give", 1))
 	}
@@ -265,7 +266,6 @@ func Read_Device_ALL_bind_1(user_ Admin.Admin, page int, page_z int, T_sn string
 	qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("Id").OrderBy("-T_give").All(&r)
 	cnt, _ = qs.SetCond((*orm2.Condition)(cond1)).Count()
 
-
 	return r, cnt
 }
 

+ 95 - 21
models/Device/DeviceClass.go

@@ -3,53 +3,121 @@ package Device
 import (
 	"Cold_Api/conf"
 	"Cold_Api/models/Admin"
+
+	"encoding/json"
 	"fmt"
+	"github.com/astaxie/beego/cache"
+	_ "github.com/astaxie/beego/cache/redis"
 	"github.com/beego/beego/v2/adapter/orm"
 	_ "github.com/go-sql-driver/mysql"
+	"strconv"
 	"time"
 )
 
 type DeviceClass struct {
-	Id         int       `orm:"column(ID);size(11);auto;pk"`
+	Id     int    `orm:"column(ID);size(11);auto;pk"`
 	T_uuid string `orm:"size(256);null"` //
-	T_name string    `orm:"size(256);null"`                  // 分类
-
-	T_Notice_wx       string `orm:"type(text);null"`  //微信公众号  appid/名字|
-	T_Notice_phone       string `orm:"type(text);null"`  //手机  1111111|
-	T_Notice_message       string `orm:"type(text);null"`  //短信   1111111|
-	T_Notice_mailbox       string `orm:"type(text);null"`  //邮箱    1111111|
+	T_name string `orm:"size(256);null"` // 分类
 
+	T_Notice_wx      string `orm:"type(text);null"` //w微信公众号  appid/名字|
+	T_Notice_wx2     string `orm:"type(text);null"` //w微信公众号  appid/名字|
+	T_Notice_phone   string `orm:"type(text);null"` //p手机  1111111|
+	T_Notice_message string `orm:"type(text);null"` //m短信   1111111|
+	T_Notice_mailbox string `orm:"type(text);null"` //e邮箱    1111111|
 
+	T_Notice_mechanism string `orm:"type(text);null"` // 报警机制
+	// 湿度超下限预警,处理,w启用,数量,上限,~|
+	// 湿度超下限预警,0,0,0,0,0,0,0,0,0,0,0,0|
 
-	T_State       int    `orm:"size(2);1"`       // 0 删除   1 正常
-	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"`   //auto_now_add 第一次保存时才设置时间
-	UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"`   //auto_now 每次 model 保存时都会对时间自动更新
+	T_State    int       `orm:"size(2);1"`                                             // 0 删除   1 正常
+	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
+	UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"`     //auto_now 每次 model 保存时都会对时间自动更新
 }
 
 func (t *DeviceClass) TableName() string {
 	return "DeviceClass" // 数据库名称   // ************** 替换 DesignClass **************
 }
 
+var redisCache_DeviceClass cache.Cache
+
 func init() {
 	//注册模型
 	orm.RegisterModel(new(DeviceClass))
 
+	config := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
+		"redis_DeviceClass", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
+	fmt.Println(config)
+	var err error
+	redisCache_DeviceClass, err = cache.NewCache("redis", config)
+	if err != nil || redisCache_DeviceClass == nil {
+		errMsg := "failed to init redis"
+		fmt.Println(errMsg, err)
+		panic(errMsg)
+	}
+
 }
 
-// ---------------- 特殊方法 -------------------
+//Redis_Set(m.T_sn,m) // Redis 更新缓存
+func Redis_DeviceClass_Set(r DeviceClass) (err error) {
+	key := strconv.Itoa(r.Id)
+
+	//json序列化
+	str, err := json.Marshal(r)
+	if err != nil {
+		fmt.Print(err)
+		return
+	}
+
+	err = redisCache_DeviceClass.Put(key, str, 2*time.Hour)
+	if err != nil {
+		fmt.Println("set key:", key, ",value:", str, err)
+	}
+	return
+}
+
+//if r,is :=Redis_Get(T_sn);is{
+//return r,nil
+//}
+func Redis_DeviceClass_Get(key string) (DeviceClass, bool) {
+	println("找到key:", key)
+	if redisCache_DeviceClass.IsExist(key) {
+		//println("找到key:",key)
+		v := redisCache_DeviceClass.Get(key)
+		var r DeviceClass
+		json.Unmarshal(v.([]byte), &r)
+
+		return r, true
+	}
 
+	return DeviceClass{}, false
+}
+func Redis_DeviceClass_DelK(key string) (err error) {
+	err = redisCache_DeviceClass.Delete(key)
+	return
+}
 
+// ---------------- 特殊方法 -------------------
 
 // 获取 ById
 func Read_Class_ById(id int) (r DeviceClass, err error) {
+	key := strconv.Itoa(id)
+	if r, is := Redis_DeviceClass_Get(key); is {
+		//println("Redis_Get  OK")
+		return r, nil
+	}
+
 	o := orm.NewOrm()
 	r = DeviceClass{Id: id}
 	err = o.Read(&r) // o.Read(&r,"Tokey") 如果不是 主键 就得指定字段名
 	if err != nil {
 		fmt.Println(err)
+		return r, err
 	}
-	return r,err
+
+	Redis_DeviceClass_Set(r)
+	return r, err
 }
+
 // 添加
 func Add_Class(m DeviceClass) (id int64, err error) {
 	o := orm.NewOrm()
@@ -57,8 +125,10 @@ func Add_Class(m DeviceClass) (id int64, err error) {
 	if err != nil {
 		fmt.Println(err)
 	}
+	Redis_DeviceClass_Set(m)
 	return
 }
+
 // 修改
 func Update_Class_ById(m DeviceClass) (err error) {
 	o := orm.NewOrm()
@@ -66,15 +136,16 @@ func Update_Class_ById(m DeviceClass) (err error) {
 	// ascertain id exists in the database
 	if err = o.Read(&v); err == nil {
 		var num int64
-		if num, err = o.Update(&m, "T_name","T_Notice_wx","T_Notice_phone","T_Notice_message","T_Notice_mailbox"); err == nil {
+		if num, err = o.Update(&m, "T_name", "T_Notice_wx", "T_Notice_wx2", "T_Notice_phone", "T_Notice_message", "T_Notice_mailbox", "T_Notice_mechanism"); err == nil {
 			fmt.Println("Number of records updated in database:", num)
 		}
 	}
+	Redis_DeviceClass_Set(m)
 	return
 }
 
 // 删除
-func Delete_Class_ById(id int) (DeviceClass) {
+func Delete_Class_ById(id int) DeviceClass {
 	o := orm.NewOrm()
 	v := DeviceClass{Id: id}
 	// ascertain id exists in the database
@@ -84,22 +155,26 @@ func Delete_Class_ById(id int) (DeviceClass) {
 		if num, err = o.Update(&v, "T_State"); err == nil {
 			fmt.Println("Number of records updated in database:", num)
 		}
+		key := strconv.Itoa(v.Id)
+		Redis_DeviceClass_DelK(key)
 	}
 	return v
 }
+
 // 删除
-func Delete_Class_ByUuid_All(user_ Admin.Admin)  {
+func Delete_Class_ByUuid_All(user_ Admin.Admin) {
 	o := orm.NewOrm()
 	qs := o.QueryTable(new(DeviceClass))
 
 	var r []DeviceClass
 	qs.Filter("T_State", 1).All(&r)
-	for _,v := range r{
+	for _, v := range r {
 		v.T_State = 0
-		o.Update(&v, "T_State");
+		o.Update(&v, "T_State")
 	}
 
 }
+
 // 获取全部
 func Read_Class_All_1() (r []DeviceClass) {
 	o := orm.NewOrm()
@@ -109,7 +184,7 @@ func Read_Class_All_1() (r []DeviceClass) {
 }
 
 // 获取列表
-func Read_DeviceClass_ALL_1(T_uuid string,page int,T_name string) (r []DeviceClass,cnt int64) {
+func Read_DeviceClass_ALL_1(T_uuid string, page int, T_name string) (r []DeviceClass, cnt int64) {
 
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
@@ -125,9 +200,9 @@ func Read_DeviceClass_ALL_1(T_uuid string,page int,T_name string) (r []DeviceCla
 	qs.Limit(conf.Page_size, offset).Filter("T_uuid", T_uuid).Filter("T_name__icontains", T_name).OrderBy("-Id").Filter("T_State", 1).All(&r)
 	cnt, _ = qs.Filter("T_uuid", T_uuid).Filter("T_name__icontains", T_name).Filter("T_State", 1).Count()
 
-
-	return r,cnt
+	return r, cnt
 }
+
 // 获取列表
 func Read_DeviceClass_ALL_T_uuid_1(T_uuid string) (r []DeviceClass) {
 
@@ -140,4 +215,3 @@ func Read_DeviceClass_ALL_T_uuid_1(T_uuid string) (r []DeviceClass) {
 
 	return r
 }
-

+ 60 - 55
models/Device/DeviceSensor.go

@@ -5,13 +5,11 @@ import (
 	"Cold_Api/models/Admin"
 	"encoding/json"
 	"fmt"
-	orm2 "github.com/beego/beego/v2/client/orm"
-
-	beego "github.com/beego/beego/v2/server/web"
-
 	"github.com/astaxie/beego/cache"
 	_ "github.com/astaxie/beego/cache/redis"
 	"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/go-sql-driver/mysql"
 	"strconv"
 	"strings"
@@ -49,7 +47,7 @@ type DeviceSensor struct {
 	T_Calss    string    `orm:"size(256);null"`                                        //设备分类
 	T_l_p      int       `orm:"size(22);null"`                                         // 1物流端   2药店端
 	T_give     int       `orm:"size(2);1"`                                             // 0 丢弃  1 正常
-	T_datashow     int       `orm:"size(2);1"`                                             // 0 屏蔽数据展示  1 正常数据展示
+	T_datashow int       `orm:"size(2);1"`                                             // 0 屏蔽数据展示  1 正常数据展示
 	T_Visit    int       `orm:"size(200);1"`                                           // 浏览量
 	T_sort     int       `orm:"size(200);1"`                                           // 排序
 	T_State    int       `orm:"size(2);1"`                                             // 0 删除   1 正常
@@ -68,19 +66,19 @@ func (t *DeviceSensor) TableName() string {
 
 // 模板
 type DeviceSensor_R struct {
-	T_sn      string  // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
-	T_id      int     // 传感器编号
-	T_name    string  // 标题
-	T_t       float32 // 温度
-	T_rh      float32 // 湿度
-	T_Tlower  float32 //  温度下限
-	T_Tupper  float32 //  温度上限
-	T_RHlower float32 //  湿度下限
-	T_RHupper float32 //  湿度上限
-	T_time    string  // 采集时间
-	T_Site    string  //GPS
-	T_Dattery int     //电量
-	T_monitor int     //  记录状态
+	T_sn       string  // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
+	T_id       int     // 传感器编号
+	T_name     string  // 标题
+	T_t        float32 // 温度
+	T_rh       float32 // 湿度
+	T_Tlower   float32 //  温度下限
+	T_Tupper   float32 //  温度上限
+	T_RHlower  float32 //  湿度下限
+	T_RHupper  float32 //  湿度上限
+	T_time     string  // 采集时间
+	T_Site     string  //GPS
+	T_Dattery  int     //电量
+	T_monitor  int     //  记录状态
 	T_datashow int     //   0 屏蔽数据展示  1 正常数据展示
 
 }
@@ -147,17 +145,6 @@ func Redis_DeviceSensor_DelK(r DeviceSensor) (err error) {
 }
 
 func DeviceSensorToDeviceSensor_R(DeviceSensor_ DeviceSensor) (DeviceSensor_r DeviceSensor_R) {
-	key_data := DeviceSensor_.T_sn + "|" + strconv.Itoa(DeviceSensor_.T_id)
-	r, is := RedisDeviceData_Get_(key_data)
-	if is {
-		if DeviceSensor_.T_time.Unix() < r.T_time.Unix() {
-			DeviceSensor_r.T_t = r.T_t
-			DeviceSensor_r.T_rh = r.T_rh
-			DeviceSensor_r.T_time = r.T_time.Format("2006-01-02 15:04:05")
-			DeviceSensor_r.T_Site = r.T_Site
-			DeviceSensor_r.T_Dattery = r.T_Dattery
-		}
-	}
 
 	DeviceSensor_r.T_sn = DeviceSensor_.T_sn
 	DeviceSensor_r.T_id = DeviceSensor_.T_id
@@ -174,6 +161,25 @@ func DeviceSensorToDeviceSensor_R(DeviceSensor_ DeviceSensor) (DeviceSensor_r De
 	DeviceSensor_r.T_monitor = DeviceSensor_.T_monitor
 	DeviceSensor_r.T_datashow = DeviceSensor_.T_datashow
 
+	// 最新设备数据
+	d_r, d_r_err := Read_Device_ByT_sn(DeviceSensor_.T_sn)
+	if d_r_err == nil {
+		DeviceSensor_r.T_monitor = d_r.T_monitor
+	}
+
+	// 最新数据
+	key_data := DeviceSensor_.T_sn + "|" + strconv.Itoa(DeviceSensor_.T_id)
+	r, is := RedisDeviceData_Get_(key_data)
+	if is {
+		if DeviceSensor_.T_time.Unix() < r.T_time.Unix() {
+			DeviceSensor_r.T_t = r.T_t
+			DeviceSensor_r.T_rh = r.T_rh
+			DeviceSensor_r.T_time = r.T_time.Format("2006-01-02 15:04:05")
+			DeviceSensor_r.T_Site = r.T_Site
+			DeviceSensor_r.T_Dattery = r.T_Dattery
+		}
+	}
+
 	return
 }
 
@@ -332,8 +338,6 @@ func DeviceSensor_T_Calss_Add(T_sn string, T_id int, T_Calss_id int) (err error)
 	return err
 }
 
-
-
 // 修改
 func DeviceSensor_T_Calss_ALL_Del(T_Calss_id int) {
 	o := orm.NewOrm()
@@ -371,6 +375,7 @@ func DeviceSensor_T_Bind_Add(T_sn string, T_id int, admin_r Admin.Admin) (err er
 	}
 	return err
 }
+
 //
 //// 修改
 //func Update_DeviceSensor_ByTsn_All_T_Bind(T_sn string, T_Bind string) (err error) {
@@ -389,10 +394,10 @@ func DeviceSensor_T_Bind_Add(T_sn string, T_id int, admin_r Admin.Admin) (err er
 //}
 
 // 获取最新数据
-func DeviceSensor_T_Bind_ALL(T_sn string, T_Bind string)  {
+func DeviceSensor_T_Bind_ALL(T_sn string, T_Bind string) {
 	o := orm.NewOrm()
 
-	res, err := o.Raw("UPDATE DeviceSensor SET `t__bind` = '"+T_Bind+"' WHERE `t_sn` = '"+T_sn+"' ").Exec()
+	res, err := o.Raw("UPDATE DeviceSensor SET `t__bind` = '" + T_Bind + "' WHERE `t_sn` = '" + T_sn + "' ").Exec()
 	if err == nil {
 		num, _ := res.RowsAffected()
 		fmt.Println("mysql row affected nums: ", num)
@@ -400,31 +405,29 @@ func DeviceSensor_T_Bind_ALL(T_sn string, T_Bind string)  {
 
 }
 
-
-
-
-
 // 获取最新数据
-func DeviceSensor_T_l_p_ALL(T_sn string, T_l_p int)  {
+func DeviceSensor_T_l_p_ALL(T_sn string, T_l_p int) {
 	o := orm.NewOrm()
 
-	res, err := o.Raw("UPDATE DeviceSensor SET `t_l_p` = "+strconv.Itoa(T_l_p)+" WHERE `t_sn` = '"+T_sn+"' ").Exec()
+	res, err := o.Raw("UPDATE DeviceSensor SET `t_l_p` = " + strconv.Itoa(T_l_p) + " WHERE `t_sn` = '" + T_sn + "' ").Exec()
 	if err == nil {
 		num, _ := res.RowsAffected()
 		fmt.Println("mysql row affected nums: ", num)
 	}
 
 }
+
 // 获取最新数据
-func DeviceSensor_t_give_ALL(T_sn string, t_give int)  {
+func DeviceSensor_t_give_ALL(T_sn string, t_give int) {
 	o := orm.NewOrm()
 
-	res, err := o.Raw("UPDATE DeviceSensor SET `t_give` = "+strconv.Itoa(t_give)+" WHERE `t_sn` = '"+T_sn+"' ").Exec()
+	res, err := o.Raw("UPDATE DeviceSensor SET `t_give` = " + strconv.Itoa(t_give) + " WHERE `t_sn` = '" + T_sn + "' ").Exec()
 	if err == nil {
 		num, _ := res.RowsAffected()
 		fmt.Println("mysql row affected nums: ", num)
 	}
 }
+
 // 获取 ById
 func Read_DeviceSensor_ByTsn_Tid(T_sn string, T_id int) (r DeviceSensor, err error) {
 
@@ -436,7 +439,7 @@ func Read_DeviceSensor_ByTsn_Tid(T_sn string, T_id int) (r DeviceSensor, err err
 }
 
 // 获取列表
-func Read_DeviceSensor_ByTsn(T_sn string) ([]DeviceSensor, int) {
+func Read_DeviceSensor_ByTsn(T_sn string) ([]DeviceSensor_R, int) {
 
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
@@ -445,18 +448,21 @@ func Read_DeviceSensor_ByTsn(T_sn string) ([]DeviceSensor, int) {
 	var r []DeviceSensor
 	qs.Filter("T_sn", T_sn).OrderBy("T_id").All(&r)
 	cnt, _ := qs.Filter("T_sn", T_sn).Count()
-	for i, v := range r {
-		DeviceSensorData, is := Read_DeviceSensorData_ById_New(v.T_sn, v.T_id)
-		if !is {
-			continue
-		}
-		//fmt.Println(v.T_sn, v.T_id, DeviceSensorData.T_time)
-		r[i].T_t = DeviceSensorData.T_t
-		r[i].T_rh = DeviceSensorData.T_rh
-		r[i].T_time = DeviceSensorData.T_time
+	var DeviceSensor_r []DeviceSensor_R
+	for _, v := range r {
+		DeviceSensor_r = append(DeviceSensor_r, DeviceSensorToDeviceSensor_R(v))
+		//DeviceSensorData, is := Read_DeviceSensorData_ById_New(v.T_sn, v.T_id)
+		//if !is {
+		//	continue
+		//}
+		////fmt.Println(v.T_sn, v.T_id, DeviceSensorData.T_time)
+		//r[i].T_t = DeviceSensorData.T_t
+		//r[i].T_rh = DeviceSensorData.T_rh
+		//r[i].T_time = DeviceSensorData.T_time
+
 	}
 
-	return r, int(cnt)
+	return DeviceSensor_r, int(cnt)
 }
 
 // 获取列表
@@ -543,13 +549,12 @@ func Read_DeviceSensor_class_ALL_1(user_ Admin.Admin, T_Calss_id int, page int,
 	cond1 := cond.And("T_Bind__icontains", T_Bind).And("T_Calss__icontains", T_Calss).And("T_sn__icontains", SN_type).And("T_sn__icontains", T_sn).And("T_name__icontains", T_name).And("T_datashow", 1) // .AndNot("status__in", 1).Or("profile__age__gt", 2000)
 
 	// 非内部权限
-	println("user_.Admin_power:",user_.Admin_power)
+	println("user_.Admin_power:", user_.Admin_power)
 	if len(T_sn) < 6 {
 		cond1 = cond.AndCond(cond1).AndCond(cond.And("T_give", 1))
 	}
 
-
-	qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("T_sort","T_id").All(&r)
+	qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("T_sort", "T_id").All(&r)
 	cnt, _ = qs.SetCond((*orm2.Condition)(cond1)).Count()
 
 	//

+ 110 - 18
models/Device/DeviceWarningList.go

@@ -1,44 +1,136 @@
 package Device
 
 import (
-	"fmt"
+	"Cold_Api/logs"
+	_ "github.com/astaxie/beego/cache/redis"
 	"github.com/beego/beego/v2/adapter/orm"
 	_ "github.com/go-sql-driver/mysql"
+	"time"
 )
 
 // 模板
 type DeviceWarningList struct {
-	Id         int       `orm:"column(ID);size(11);auto;pk"`
-	T_name string    `orm:"size(256);null"`                  // 分类
-	T_Tips string    `orm:"type(text);size(256);null"`                  // 提示
+	Id     int    `orm:"column(ID);size(11);auto;pk"`
+	T_name string `orm:"size(256);null"`            // 分类
+	T_Tips string `orm:"type(text);size(256);null"` // 提示
 }
 
 func (t *DeviceWarningList) TableName() string {
 	return "DeviceWarningList" // 数据库名称   // ************** 替换 FormulaList **************
 }
 
+//var redisCache_DeviceWarningList cache.Cache
+
 func init() {
 	//注册模型
 	orm.RegisterModel(new(DeviceWarningList))
+	//
+	//config := fmt.Sprintf(`{"key":"%s","conn":"%s","dbNum":"%s","password":"%s"}`,
+	//	"redis_DeviceWarningList", conf.Redis_address, conf.Redis_dbNum, conf.Redis_password)
+	//fmt.Println(config)
+	//var err error
+	//redisCache_DeviceWarningList, err = cache.NewCache("redis", config)
+	//if err != nil || redisCache_DeviceWarningList == nil {
+	//	errMsg := "failed to init redis"
+	//	fmt.Println(errMsg, err)
+	//	panic(err)
+	//}
+
+	//go Read_DeviceWarningList_All_1()
 }
 
+// ---------------- Redis -------------------
+//Redis_Set(m.T_sn,m) // Redis 更新缓存
+//func Redis_DeviceWarningList_Set(r DeviceWarningList) (err error) {
+//	//json序列化
+//	str, err := json.Marshal(r)
+//	if err != nil {
+//		fmt.Print(err)
+//		return
+//	}
+//
+//	err = redisCache_DeviceWarningList.Put(r.T_name, str, 0)
+//	if err != nil {
+//		fmt.Println("set key:", r.T_name, ",value:", str, err)
+//	}
+//	return
+//}
+//
+////if r,is :=Redis_Get(T_sn);is{
+////return r,nil
+////}
+//func Redis_DeviceWarningList_Get(key string) (r DeviceWarningList, is bool) {
+//	if redisCache_DeviceWarningList.IsExist(key) {
+//		//println("找到key:",key)
+//		v := redisCache_DeviceWarningList.Get(key)
+//
+//		json.Unmarshal(v.([]byte), &r)
+//		return r, true
+//	}
+//	//println("没有 找到key:",key)
+//	return DeviceWarningList{}, false
+//}
 // ---------------- 特殊方法 -------------------
-
-// 获取 ById
-func Read_DeviceWarningList_ById(id int) (r DeviceWarningList) {
-	o := orm.NewOrm()
-	r = DeviceWarningList{Id: id}
-	err := o.Read(&r) // o.Read(&r,"Tokey") 如果不是 主键 就得指定字段名
-	if err != nil {
-		fmt.Println(err)
-	}
-	return r
-}
+//
+//// 获取 ById
+//func Read_DeviceWarningList(T_name string) (r DeviceWarningList) {
+//
+//	if r, is := Redis_DeviceWarningList_Get(T_name); is {
+//		//println("Redis_Get  OK")
+//		return r
+//	}
+//	o := orm.NewOrm()
+//	r = DeviceWarningList{T_name: T_name}
+//	err := o.Read(&r,"T_name") // o.Read(&r,"Tokey") 如果不是 主键 就得指定字段名
+//	if err != nil {
+//		o.Insert(&r)
+//		o.Read(&r,"T_name")
+//	}
+//
+//	Redis_DeviceWarningList_Set(r)
+//	return r
+//}
+//
+//// 修改
+//func Update_DeviceWarningList(r DeviceWarningList, cols ...string) bool {
+//	o := orm.NewOrm()
+//	if num, err := o.Update(&r, cols...); err == nil {
+//		fmt.Println("Number of records updated in database:", num)
+//		Redis_DeviceWarningList_Set(r) // Redis 更新缓存
+//		return true
+//	}
+//
+//	return false
+//}
+//
+//// 获取全部
+//func Read_DeviceWarningList_All_1(){
+//	logs.Println("=========== 初始化报警规则 =========")
+//	time.Sleep(3*time.Second)
+//	o := orm.NewOrm()
+//	var r []DeviceWarningList
+//	qs := o.QueryTable(new(DeviceWarningList))
+//	qs.All(&r)
+//
+//	for _,v := range r{
+//		Redis_DeviceWarningList_Set(v)
+//	}
+//
+//	return
+//}
 
 // 获取全部
-func Read_DeviceWarningList_All_1() (r []DeviceWarningList) {
+func Read_DeviceWarningList_All_T_Notice_mechanism() string {
+	logs.Println("=========== 初始化报警规则 =========")
+	time.Sleep(3 * time.Second)
 	o := orm.NewOrm()
+	var r []DeviceWarningList
 	qs := o.QueryTable(new(DeviceWarningList))
 	qs.All(&r)
-	return r
-}
+	str := ""
+	for _, v := range r {
+		str += v.T_Tips
+	}
+
+	return str
+}

+ 51 - 0
models/System/DeviceLogs.go

@@ -0,0 +1,51 @@
+package System
+
+import (
+	"Cold_Api/conf"
+	"github.com/beego/beego/v2/adapter/orm"
+	"time"
+)
+
+type DeviceLogs struct {
+	Id       int    `orm:"column(ID);size(11);auto;pk"`
+	T_sn     string `orm:"size(256);null"`  //
+	Logs_Txt string `orm:"type(text);null"` // 详情
+
+	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now 每次 model 保存时都会对时间自动更新
+}
+
+func (t *DeviceLogs) TableName() string {
+	return "DeviceLogs" // 数据库名称   // ************** 替换 FormulaList **************
+}
+
+func init() {
+	//注册模型
+	orm.RegisterModel(new(DeviceLogs))
+}
+
+// 添加  System.Add_DeviceLogs("MqttServer","参数请求 [Rt_Parameter]","base")
+func Add_DeviceLogs(T_sn string, Logs_Txt string) {
+	o := orm.NewOrm()
+	m := DeviceLogs{T_sn: T_sn, Logs_Txt: Logs_Txt}
+	o.Insert(&m)
+}
+
+// 获取列表
+func Read_DeviceLogs_ALL(page int, T_sn string) (r []DeviceLogs, cnt int64) {
+
+	o := orm.NewOrm()
+	// 也可以直接使用 Model 结构体作为表名
+
+	qs := o.QueryTable(new(DeviceLogs))
+	var offset int64
+	if page <= 1 {
+		offset = 0
+	} else {
+		offset = int64((page - 1) * conf.Page_size)
+	}
+
+	qs.Limit(conf.Page_size, offset).Filter("T_sn", T_sn).OrderBy("-Id").All(&r)
+	cnt, _ = qs.Filter("T_sn", T_sn).Count()
+
+	return r, cnt
+}

+ 21 - 26
routers/Data.go

@@ -12,31 +12,26 @@ func init() {
 	//3.3用户可添加和删除子账号。
 	//3.4用户可对子账号分配管理权限,包括:设备数据查看权限,设备运行参数修改权限。
 	//-----------
-	beego.Router("/Data/Device_Sensor", &controllers.DataController{}, "*:Device_Sensor")  // 设置 设备参数
-
-	beego.Router("/Data/DataReal_html", &controllers.DataController{}, "*:DataReal_html")  // 获取 基本信息
-	beego.Router("/Data/DataRealCalss_html", &controllers.DataController{}, "*:DataRealCalss_html")  // 获取 基本信息
-	beego.Router("/Data/DataList_html", &controllers.DataController{}, "*:DataList_html")  // 获取 基本信息
-	beego.Router("/Data/DataLine_html", &controllers.DataController{}, "*:DataLine_html")  // 获取 基本信息
-	beego.Router("/Data/DataMap_html", &controllers.DataController{}, "*:DataMap_html")  // 获取 基本信息
-	beego.Router("/Data/Device_Sensor_List", &controllers.DataController{}, "*:Device_Sensor_List")  // 设置 设备参数
-	beego.Router("/Data/Device_Sensor_Data", &controllers.DataController{}, "*:Device_Sensor_Data")  // 设置 设备参数
-	beego.Router("/Data/Device_Sensor_Data_More", &controllers.DataController{}, "*:Device_Sensor_Data_More")  // 设置 设备参数
-	beego.Router("/Data/Device_Sensor_Data_Excel", &controllers.DataController{}, "*:Device_Sensor_Data_Excel_m")  // 设置 设备参数
-	beego.Router("/Data/Device_Sensor_Data_Excel_m", &controllers.DataController{}, "*:Device_Sensor_Data_Excel_m")  // 设置 设备参数
-	beego.Router("/Data/Device_Sensor_Data_PDF", &controllers.DataController{}, "*:Device_Sensor_Data_PDF")  // 设置 设备参数
-	beego.Router("/Data/DataPlane", &controllers.DataController{}, "*:DataPlane")  // 设置 设备参数
-
-
-	beego.Router("/Data/DataScreen", &controllers.DataController{}, "*:DataScreen")  // 设置 设备参数
-	beego.Router("/Data/DataScreen_Data", &controllers.DataController{}, "*:DataScreen_Data")  // 设置 设备参数
-	beego.Router("/Data/DeviceSensor_Data_Print", &controllers.DataController{}, "*:DeviceSensor_Data_Print")  // 设置 设备参数
-	beego.Router("/Data/DataScreen_Map", &controllers.DataController{}, "*:DataScreen_Map")  // 设置 设备参数
-
-
-	beego.Router("/Data/Raw", &controllers.DataController{}, "*:Raw")  // 设置 设备参数
-
-
-
+	beego.Router("/Data/Device_Sensor", &controllers.DataController{}, "*:Device_Sensor") // 设置 设备参数
+
+	beego.Router("/Data/DataReal_html", &controllers.DataController{}, "*:DataReal_html")                           // 获取 基本信息
+	beego.Router("/Data/DataRealCalss_html", &controllers.DataController{}, "*:DataRealCalss_html")                 // 获取 基本信息
+	beego.Router("/Data/DataList_html", &controllers.DataController{}, "*:DataList_html")                           // 获取 基本信息
+	beego.Router("/Data/DataLine_html", &controllers.DataController{}, "*:DataLine_html")                           // 获取 基本信息
+	beego.Router("/Data/DataMap_html", &controllers.DataController{}, "*:DataMap_html")                             // 获取 基本信息
+	beego.Router("/Data/Device_Sensor_List", &controllers.DataController{}, "*:Device_Sensor_List")                 // 设置 设备参数
+	beego.Router("/Data/Device_Sensor_Data", &controllers.DataController{}, "*:Device_Sensor_Data")                 // 设置 设备参数
+	beego.Router("/Data/Device_Sensor_Data_More", &controllers.DataController{}, "*:Device_Sensor_Data_More")       // 设置 设备参数
+	beego.Router("/Data/Device_Sensor_Data_Excel", &controllers.DataController{}, "*:Device_Sensor_Data_Excel")     // 设置 设备参数
+	beego.Router("/Data/Device_Sensor_Data_Excel_m", &controllers.DataController{}, "*:Device_Sensor_Data_Excel_m") // 设置 设备参数
+	beego.Router("/Data/Device_Sensor_Data_PDF", &controllers.DataController{}, "*:Device_Sensor_Data_PDF")         // 设置 设备参数
+	beego.Router("/Data/DataPlane", &controllers.DataController{}, "*:DataPlane")                                   // 设置 设备参数
+
+	beego.Router("/Data/DataScreen", &controllers.DataController{}, "*:DataScreen")                           // 设置 设备参数
+	beego.Router("/Data/DataScreen_Data", &controllers.DataController{}, "*:DataScreen_Data")                 // 设置 设备参数
+	beego.Router("/Data/DeviceSensor_Data_Print", &controllers.DataController{}, "*:DeviceSensor_Data_Print") // 设置 设备参数
+	beego.Router("/Data/DataScreen_Map", &controllers.DataController{}, "*:DataScreen_Map")                   // 设置 设备参数
+
+	beego.Router("/Data/Raw", &controllers.DataController{}, "*:Raw") // 设置 设备参数
 
 }

+ 38 - 38
routers/Device.go

@@ -12,27 +12,30 @@ func init() {
 	//3.3用户可添加和删除子账号。
 	//3.4用户可对子账号分配管理权限,包括:设备数据查看权限,设备运行参数修改权限。
 	//-----------
-	beego.Router("/Device/Read_DeviceParameter", &controllers.DeviceController{}, "*:Read_DeviceParameter")           // 获取 基本信息
-	beego.Router("/Device/Read_DeviceSensorParameter", &controllers.DeviceController{}, "*:Read_DeviceSensorParameter")           // 获取 基本信息
+	// 设备日志
+	beego.Router("/Device/DeviceLogs", &controllers.DeviceController{}, "*:DeviceLogs") // 获取未读消息
+
+	beego.Router("/Device/Read_DeviceParameter", &controllers.DeviceController{}, "*:Read_DeviceParameter")             // 获取 基本信息
+	beego.Router("/Device/Read_DeviceSensorParameter", &controllers.DeviceController{}, "*:Read_DeviceSensorParameter") // 获取 基本信息
 	//beego.Router("/Device/Read_DeviceParameter", &controllers.DeviceController{}, "*:Read_DeviceParameter")           // 获取 基本信息
 	beego.Router("/Device/Pu_DeviceParameter", &controllers.DeviceController{}, "*:Pu_DeviceParameter")               // 设置 设备参数
 	beego.Router("/Device/Pu_DeviceParameter_Sensor", &controllers.DeviceController{}, "*:Pu_DeviceParameter_Sensor") // 设置 传感器参数
 	//beego.Router("/Device/Pu_DeviceParameter_Sensor_Cache", &controllers.DeviceController{}, "*:Pu_DeviceParameter_Sensor_Cache") // 设置 传感器参数
-	beego.Router("/Device/Pu_DeviceParameter_T_l_p", &controllers.DeviceController{}, "*:Pu_DeviceParameter_T_l_p") // 设置 传感器参数
+	beego.Router("/Device/Pu_DeviceParameter_T_l_p", &controllers.DeviceController{}, "*:Pu_DeviceParameter_T_l_p")   // 设置 传感器参数
 	beego.Router("/Device/Pu_DeviceParameter_T_give", &controllers.DeviceController{}, "*:Pu_DeviceParameter_T_give") // 设置 传感器参数
 
-	beego.Router("/Device/Device_html", &controllers.DeviceController{}, "*:Device_html") // 获取未读消息
-	beego.Router("/Device/Device_", &controllers.DeviceController{}, "*:Device_")         // 获取未读消息
-	beego.Router("/Device/Device_Post", &controllers.DeviceController{}, "*:Device_Post") // 获取未读消息
-	beego.Router("/Device/Device_Add", &controllers.DeviceController{}, "*:Device_Post") // 获取未读消息
-	beego.Router("/Device/Device_Del", &controllers.DeviceController{}, "*:Device_Del")   // 获取未读消息
-	beego.Router("/Device/DeviceBind_html", &controllers.DeviceController{}, "*:DeviceBind_html")       // 获取未读消息
-	beego.Router("/Device/DeviceBind_List", &controllers.DeviceController{}, "*:DeviceBind_List")       // 获取未读消息
-	beego.Router("/Device/DeviceBind_Sensor_List", &controllers.DeviceController{}, "*:DeviceBind_Sensor_List")       // 获取未读消息
-	beego.Router("/Device/DeviceBind_Del", &controllers.DeviceController{}, "*:DeviceBind_Del")         // 获取未读消息
-	beego.Router("/Device/DeviceBind_Add", &controllers.DeviceController{}, "*:DeviceBind_Add")         // 获取未读消息
-	beego.Router("/Device/DeviceBind_Add_All", &controllers.DeviceController{}, "*:DeviceBind_Add_All") // 获取未读消息
-	beego.Router("/Device/DeviceBind_html_", &controllers.DeviceController{}, "*:DeviceBind_html_")     // 获取未读消息
+	beego.Router("/Device/Device_html", &controllers.DeviceController{}, "*:Device_html")                       // 获取未读消息
+	beego.Router("/Device/Device_", &controllers.DeviceController{}, "*:Device_")                               // 获取未读消息
+	beego.Router("/Device/Device_Post", &controllers.DeviceController{}, "*:Device_Post")                       // 获取未读消息
+	beego.Router("/Device/Device_Add", &controllers.DeviceController{}, "*:Device_Post")                        // 获取未读消息
+	beego.Router("/Device/Device_Del", &controllers.DeviceController{}, "*:Device_Del")                         // 获取未读消息
+	beego.Router("/Device/DeviceBind_html", &controllers.DeviceController{}, "*:DeviceBind_html")               // 获取未读消息
+	beego.Router("/Device/DeviceBind_List", &controllers.DeviceController{}, "*:DeviceBind_List")               // 获取未读消息
+	beego.Router("/Device/DeviceBind_Sensor_List", &controllers.DeviceController{}, "*:DeviceBind_Sensor_List") // 获取未读消息
+	beego.Router("/Device/DeviceBind_Del", &controllers.DeviceController{}, "*:DeviceBind_Del")                 // 获取未读消息
+	beego.Router("/Device/DeviceBind_Add", &controllers.DeviceController{}, "*:DeviceBind_Add")                 // 获取未读消息
+	beego.Router("/Device/DeviceBind_Add_All", &controllers.DeviceController{}, "*:DeviceBind_Add_All")         // 获取未读消息
+	beego.Router("/Device/DeviceBind_html_", &controllers.DeviceController{}, "*:DeviceBind_html_")             // 获取未读消息
 
 	beego.Router("/Device/DeviceClass_html", &controllers.DeviceController{}, "*:DeviceClass_html") // 获取未读消息
 	beego.Router("/Device/DeviceClass_", &controllers.DeviceController{}, "*:DeviceClass_")         // 获取未读消息
@@ -45,31 +48,28 @@ func init() {
 	beego.Router("/Device/DeviceClassBind_Del", &controllers.DeviceController{}, "*:DeviceClassBind_Del")    // 获取未读消息
 	beego.Router("/Device/DeviceClassBind_Add", &controllers.DeviceController{}, "*:DeviceClassBind_Add")    // 获取未读消息
 
-	beego.Router("/Device/Get_DeviceClassId_QRCode", &controllers.WxController{}, "*:Get_DeviceClassId_QRCode") // 获取未读消息
-	beego.Router("/Device/Get_DeviceClassId", &controllers.DeviceController{}, "*:Get_DeviceClassId")           // 获取未读消息
-
-	beego.Router("/Device/Device_List", &controllers.DeviceController{}, "*:Device_List")                         // 获取未读消息
-	beego.Router("/Device/Device_Parameter", &controllers.DeviceController{}, "*:Device_Parameter_html")               // 获取未读消息
-	beego.Router("/Device/Device_Parameter_Del", &controllers.DeviceController{}, "*:Device_Parameter_Del")       // 获取未读消息
-	beego.Router("/Device/Device_Parameter_Del_Device", &controllers.DeviceController{}, "*:Device_Parameter_Del_Device")       // 获取未读消息
-	beego.Router("/Device/DeviceSensor_List", &controllers.DeviceController{}, "*:DeviceSensor_List")             // 获取未读消息
-	beego.Router("/Device/DeviceSensor_List_html", &controllers.DeviceController{}, "*:DeviceSensor_List_html")   // 获取未读消息
-	beego.Router("/Device/DeviceWarning_List_html", &controllers.DeviceController{}, "*:DeviceWarning_List_html") // 获取未读消息
-	beego.Router("/Device/DeviceWarning_List", &controllers.DeviceController{}, "*:DeviceWarning_List")           // 获取未读消息
-	beego.Router("/Device/DeviceWarning_", &controllers.DeviceController{}, "*:DeviceWarning_")                   // 获取未读消息
-	beego.Router("/Device/DeviceWarning_M", &controllers.DeviceController{}, "*:DeviceWarning_M")                   // 获取未读消息
-	beego.Router("/Device/DeviceWarning_Post", &controllers.DeviceController{}, "*:DeviceWarning_Post")           // 获取未读消息
-	beego.Router("/Device/DeviceWarning_Data_Excel", &controllers.DeviceController{}, "*:DeviceWarning_Data_Excel")           // 获取未读消息
-	beego.Router("/Device/DeviceWarning_Del", &controllers.DeviceController{}, "*:DeviceWarning_Del")                   // 获取未读消息
-
-
-	beego.Router("/Device/UpDeviceSensor_Tsort", &controllers.DeviceController{}, "*:UpDeviceSensor_Tsort")   // 获取未读消息
-	beego.Router("/Device/UpDeviceSensor_T_datashow", &controllers.DeviceController{}, "*:UpDeviceSensor_T_datashow")   // 获取未读消息
-
+	beego.Router("/Device/Get_DeviceClassId_QRCode", &controllers.DeviceController{}, "*:Get_DeviceClassId_QRCode") // 获取未读消息
+	beego.Router("/Device/Get_DeviceClassId", &controllers.DeviceController{}, "*:Get_DeviceClassId")               // 获取未读消息
 
-	beego.Router("/Device/DeviceTask_List", &controllers.DeviceController{}, "*:DeviceTask_List")  // 设置 设备参数
-	beego.Router("/Device/DeviceTask_Post", &controllers.DeviceController{}, "*:DeviceTask_Post")  // 设置 设备参数
+	beego.Router("/Device/Device_List", &controllers.DeviceController{}, "*:Device_List")                                 // 获取未读消息
+	beego.Router("/Device/Device_Parameter", &controllers.DeviceController{}, "*:Device_Parameter_html")                  // 获取未读消息
+	beego.Router("/Device/Device_Parameter_Del", &controllers.DeviceController{}, "*:Device_Parameter_Del")               // 获取未读消息
+	beego.Router("/Device/Device_Parameter_Del_Device", &controllers.DeviceController{}, "*:Device_Parameter_Del_Device") // 获取未读消息
+	beego.Router("/Device/DeviceSensor_List", &controllers.DeviceController{}, "*:DeviceSensor_List")                     // 获取未读消息
+	beego.Router("/Device/DeviceSensor_List_html", &controllers.DeviceController{}, "*:DeviceSensor_List_html")           // 获取未读消息
+	beego.Router("/Device/DeviceWarning_List_html", &controllers.DeviceController{}, "*:DeviceWarning_List_html")         // 获取未读消息
+	beego.Router("/Device/DeviceWarning_List", &controllers.DeviceController{}, "*:DeviceWarning_List")                   // 获取未读消息
+	beego.Router("/Device/DeviceWarning_", &controllers.DeviceController{}, "*:DeviceWarning_")                           // 获取未读消息
+	beego.Router("/Device/DeviceWarning_M", &controllers.DeviceController{}, "*:DeviceWarning_M")                         // 获取未读消息
+	beego.Router("/Device/DeviceWarning_Post", &controllers.DeviceController{}, "*:DeviceWarning_Post")                   // 获取未读消息
+	beego.Router("/Device/DeviceWarning_Data_Excel", &controllers.DeviceController{}, "*:DeviceWarning_Data_Excel")       // 获取未读消息
+	beego.Router("/Device/DeviceWarning_Del", &controllers.DeviceController{}, "*:DeviceWarning_Del")                     // 获取未读消息
+	beego.Router("/Device/DeviceWarningListT_Tips", &controllers.DeviceController{}, "*:DeviceWarningList_T_Tips")        // 获取未读消息
 
+	beego.Router("/Device/UpDeviceSensor_Tsort", &controllers.DeviceController{}, "*:UpDeviceSensor_Tsort")           // 获取未读消息
+	beego.Router("/Device/UpDeviceSensor_T_datashow", &controllers.DeviceController{}, "*:UpDeviceSensor_T_datashow") // 获取未读消息
 
+	beego.Router("/Device/DeviceTask_List", &controllers.DeviceController{}, "*:DeviceTask_List") // 设置 设备参数
+	beego.Router("/Device/DeviceTask_Post", &controllers.DeviceController{}, "*:DeviceTask_Post") // 设置 设备参数
 
 }

+ 12 - 20
routers/router.go

@@ -21,40 +21,32 @@ func init() {
 	// 网关 WebSocket
 	beego.Router("/ws/join", &WebSocket.WebSocketController{}, "get:Join")
 
-
 	beego.Router("/UpFile", &controllers.UpFileController{}, "*:UpFile") // *全部;  get,post:
 
-
 	beego.Router("/Login", &controllers.AdminController{}, "*:Login")                           // *全部;  get,post:
 	beego.Router("/Login_verification", &controllers.AdminController{}, "*:Login_verification") // *全部;  get,post:
 
-
 	beego.Router("/Index", &controllers.AdminController{}, "*:Index")
 	beego.Router("/Home", &controllers.AdminController{}, "*:Home")
 	beego.Router("/User/Info", &controllers.AdminController{}, "*:Info")
 
-	beego.Router("/Nows_rend", &controllers.AdminController{}, "*:Nows_rend")  // 获取未读消息
+	beego.Router("/Nows_rend", &controllers.AdminController{}, "*:Nows_rend") // 获取未读消息
 	// 日志
-	beego.Router("/System/Logs", &controllers.LogsController{}, "*:List")  // 获取未读消息
-
+	beego.Router("/System/Logs", &controllers.LogsController{}, "*:List") // 获取未读消息
 
 	// 微信服务端
-	beego.Router("/Wx/Wx_handler", &controllers.WxController{}, "*:Wx_handler")  // 获取未读消息
+	//beego.Router("/Wx/Wx_handler", &controllers.WxController{}, "*:Wx_handler")  // 获取未读消息
 	//beego.Router("/Wx/Wx_handler", &controllers.WxController{}, "*:Wx")  // 获取未读消息
 
 	// 模板路由
-	beego.Router("/Template/List", &controllers.TemplateController{}, "*:List")  // 获取未读消息
-	beego.Router("/Template/List_", &controllers.TemplateController{}, "*:List_")  // 获取未读消息
-	beego.Router("/Template/List_Post", &controllers.TemplateController{}, "*:List_Post")  // 获取未读消息
-	beego.Router("/Template/List_Del", &controllers.TemplateController{}, "*:List_Del")  // 获取未读消息
-
-	beego.Router("/Template/Class", &controllers.TemplateController{}, "*:Class")  // 获取未读消息
-	beego.Router("/Template/Class_", &controllers.TemplateController{}, "*:Class_")  // 获取未读消息
-	beego.Router("/Template/Class_Post", &controllers.TemplateController{}, "*:Class_Post")  // 获取未读消息
-	beego.Router("/Template/Class_Del", &controllers.TemplateController{}, "*:Class_Del")  // 获取未读消息
-
-
-
-
+	beego.Router("/Template/List", &controllers.TemplateController{}, "*:List")           // 获取未读消息
+	beego.Router("/Template/List_", &controllers.TemplateController{}, "*:List_")         // 获取未读消息
+	beego.Router("/Template/List_Post", &controllers.TemplateController{}, "*:List_Post") // 获取未读消息
+	beego.Router("/Template/List_Del", &controllers.TemplateController{}, "*:List_Del")   // 获取未读消息
+
+	beego.Router("/Template/Class", &controllers.TemplateController{}, "*:Class")           // 获取未读消息
+	beego.Router("/Template/Class_", &controllers.TemplateController{}, "*:Class_")         // 获取未读消息
+	beego.Router("/Template/Class_Post", &controllers.TemplateController{}, "*:Class_Post") // 获取未读消息
+	beego.Router("/Template/Class_Del", &controllers.TemplateController{}, "*:Class_Del")   // 获取未读消息
 
 }

+ 0 - 32
tests/default_test.go

@@ -1,42 +1,10 @@
 package test
 
 import (
-	"net/http"
-	"net/http/httptest"
 	"testing"
-	"runtime"
-	"path/filepath"
-
-    "github.com/beego/beego/v2/core/logs"
-
-	_ "Cold_Api/routers"
-
-	beego "github.com/beego/beego/v2/server/web"
-	. "github.com/smartystreets/goconvey/convey"
 )
 
-func init() {
-	_, file, _, _ := runtime.Caller(0)
-	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
-	beego.TestBeegoInit(apppath)
-}
-
-
 // TestBeego is a sample to run an endpoint test
 func TestBeego(t *testing.T) {
-	r, _ := http.NewRequest("GET", "/", nil)
-	w := httptest.NewRecorder()
-	beego.BeeApp.Handlers.ServeHTTP(w, r)
 
-	logs.Trace("testing", "TestBeego", "Code[%d]\n%s", w.Code, w.Body.String())
-
-	Convey("Subject: Test Station Endpoint\n", t, func() {
-	        Convey("Status Code Should Be 200", func() {
-	                So(w.Code, ShouldEqual, 200)
-	        })
-	        Convey("The Result Should Not Be Empty", func() {
-	                So(w.Body.Len(), ShouldBeGreaterThan, 0)
-	        })
-	})
 }
-

+ 66 - 0
tests/logs/logx/logx.log

@@ -0,0 +1,66 @@
+2022/07/12 16:54:19.474 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[nats OK!])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[{"key":"redis_PaneView","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[{"key":"redis_ConfigImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[{"key":"redis_PanelLayerMould","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[{"key":"redis_PanelTool","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[{"key":"redis_ConfiglibImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:19.477 [I]  2022-07-12 16:54:19>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:45.055 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[nats OK!])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[{"key":"redis_PaneView","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[{"key":"redis_ConfigImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[{"key":"redis_PanelLayerMould","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[{"key":"redis_PanelTool","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[{"key":"redis_ConfiglibImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:54:45.057 [I]  2022-07-12 16:54:45>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:02.236 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[nats OK!])
+2022/07/12 16:57:02.238 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[{"key":"redis_PaneView","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:02.238 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:02.238 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[{"key":"redis_ConfigImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:02.238 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:02.239 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[{"key":"redis_PanelLayerMould","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:02.239 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:02.239 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[{"key":"redis_PanelTool","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:02.239 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:02.239 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[{"key":"redis_ConfiglibImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:02.239 [I]  2022-07-12 16:57:02>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:11.223 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[nats OK!])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[{"key":"redis_PaneView","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[{"key":"redis_ConfigImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[{"key":"redis_PanelLayerMould","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[{"key":"redis_PanelTool","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[{"key":"redis_ConfiglibImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:11.225 [I]  2022-07-12 16:57:11>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:29.417 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[nats OK!])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[{"key":"redis_PaneView","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[{"key":"redis_ConfigImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[{"key":"redis_PanelLayerMould","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[{"key":"redis_PanelTool","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[{"key":"redis_ConfiglibImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:57:29.419 [I]  2022-07-12 16:57:29>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:58:00.464 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[nats OK!])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[{"key":"redis_PaneView","conn":"","dbNum":"","password":""}])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[{"key":"redis_ConfigImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[{"key":"redis_PanelLayerMould","conn":"","dbNum":"","password":""}])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[{"key":"redis_PanelTool","conn":"","dbNum":"","password":""}])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])
+2022/07/12 16:58:00.466 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[{"key":"redis_ConfiglibImg","conn":"","dbNum":"","password":""}])
+2022/07/12 16:58:00.467 [I]  2022-07-12 16:58:00>%!(EXTRA []interface {}=[failed to init redis dial tcp: missing address])

+ 99 - 12
views/Device/Device.html

@@ -12,6 +12,8 @@
         <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
         <script src="https://osscold.baozhida.cn/lib/layui/layui.js" charset="utf-8"></script>
         <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
+
+        <script src="https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js"></script>
     </head>
     
     <body>
@@ -47,7 +49,10 @@
 <!--                            <button class="layui-btn layui-btn-danger" onclick="delAll()">-->
 <!--                                <i class="layui-icon"></i>批量删除</button>-->
                             <button class="layui-btn  layui-btn-normal" onclick="xadmin.open('添加','Device_',450,300,false);">
-                                <i class="layui-icon"></i>添加</button></div>
+                                <i class="layui-icon"></i>添加</button>
+                            <button class="layui-btn  layui-btn-normal" style="float: right;color: #ffffff" onclick="f_tishi();">
+                                <i class="layui-icon">&#xe705;</i>  说明</button>
+                        </div>
                         {{end}}
                         <div class="layui-card-body ">
                             {{range $index, $elem := .Device_lite}}
@@ -57,23 +62,61 @@
                                     <div style="float: left;margin-left: 20px;margin-top: 4px;font-size: 15px">SN:{{$elem.T_sn}}</div>
                                     <div style="float: left;margin-left: 20px;margin-top: 4px;font-size: 15px">主机名称:{{$elem.T_devName}} {{if eq 0 $elem.T_give }}<span style="background-color: #ff8d8d">弃用设备</span>{{end}}</div>
                                     <div style="float: left;margin-left: 20px;margin-top: 4px;font-size: 15px">传感器数量:{{$elem.T_sensor}}</div>
-                                    <div style="float: left;margin-left: 20px;margin-top: 4px;font-size: 15px">状态:
-                                        {{if eq 1 $elem.T_monitor }}
-                                        <span style="color: #00FF00">监控状态 </span>
+                                    <div style="float: left;margin-left: 20px;margin-top: 4px;font-size: 15px">连接状态:
+                                        {{if eq 1 $elem.T_online }}
+                                        <span style="color: #00FF00">通讯正常 </span>
                                         {{else}}
-                                        <span style="color: #ff7d7d">未监控</span>
+                                            {{if eq 2 $elem.T_online }}
+                                            <span style="color: #ff7d7d">设备已关机 </span>
+                                            {{else}}
+                                            <span style="color: #ff7d7d">设备无网络</span>
+                                            {{end}}
+
                                         {{end}}
                                     </div>
+                                    <div style="float: left;margin-left: 20px;margin-top: 4px;font-size: 15px">监控状态:
+                                        {{if eq 1 $elem.T_online }}
+                                            {{if eq 1 $elem.T_monitor }}
+                                            <span style="color: #00FF00">监控状态 </span>
+                                            {{else}}
+                                            <span style="color: #ff7d7d">未监控</span>
+                                            {{end}}
+                                        {{else}}
+                                            {{if eq 2 $elem.T_online }}
+                                            <span style="color: #ff7d7d">未监控 </span>
+                                            {{else}}
+                                            <span style="color: #ff7d7d">未知状态</span>
+                                            {{end}}
+                                        {{end}}
+                                    </div>
+<!--                                    <div style="float: left;margin-left: 20px;margin-top: 4px;font-size: 15px">电量状态:-->
+<!--                                        {-{$elem.T_Dattery }-}-->
+
+<!--                                    </div>-->
                                     <div style="float: left;margin-left: 20px;margin-top: 4px;font-size: 15px">MSISDN(物联网卡号):{{$elem.T_MSISDN}}</div>
-                                    {{if eq 1 $.Admin_Power.Power_Device_Parameter_e }}
+
+
+
+
                                     <div class="layui-card-header" style="border-bottom-width: 0px;">
                                         <!--                            <button class="layui-btn layui-btn-danger" onclick="delAll()">-->
                                         <!--                                <i class="layui-icon"></i>批量删除</button>-->
-                                        <button class="layui-btn  layui-btn-normal" style="float: right;margin-top: 2px"
+
+
+
+                                        <button class="layui-btn  layui-btn-normal" style="float: right;margin-top: 2px;margin-left: 20px"
+                                                onclick="xadmin.open('设备日志','DeviceLogs?T_sn={{$elem.T_sn}}',700,'',false);"
+                                        >
+                                            <i class="layui-icon" style="margin-right: 4px">&#xe63c;</i> 设备日志</button>
+
+                                        {{if eq 1 $.Admin_Power.Power_Device_Parameter_e }}
+                                       ` <button class="layui-btn  layui-btn-normal" style="float: right;margin-top: 2px"
                                                 onclick="xadmin.open('设备管理','Device_Parameter?Sn={{$elem.T_sn}}','',800,false);"
                                                 >
-                                            <i class="iconfont" style="margin-right: 4px">&#xe6ae;</i> 设备管理</button></div>
-                                    {{end}}
+                                            <i class="iconfont" style="margin-right: 4px">&#xe6ae;</i> 设备管理</button>`
+                                        {{end}}
+
+                                    </div>
 
                                 </div>
                                 <div class="layui-col" style="margin-left: 40px;max-height: 163px;overflow-y: auto" >
@@ -112,7 +155,7 @@
                                                         {{end}}
                                                     </div>
                                                     <div class=" layui-col-md12 " style="padding-top: -2px;font-size: 16px;text-align: center;margin-top: -2px;border-top:1px solid  #000">
-                                                        {{ $elem_s.T_time.Format "2006-01-02 15:04:05"}}
+                                                        {{ $elem_s.T_time}}
                                                     </div>
                                                 </div>
 
@@ -183,7 +226,7 @@
             }
 
         }
-        layui.use(['laydate', 'form'],
+        layui.use(['laydate', 'form', 'layer'],
             function() {
                 var laydate = layui.laydate;
 
@@ -195,8 +238,31 @@
                 //执行一个laydate实例
                 laydate.render({
                     elem: '#end' //指定元素
+                });
+
+
+                // 鼠标悬浮提示文字
+                var tip_html = "<p>12312312312313123123</p>";
+                var tip_index = 0;
+
+
+
+        });
+
+        $(document).on('mouseenter', '.tishi_lianj', function(){  // 监听鼠标移入事件
+            console.log("mouseenter")
+            tip_index = layer.tips(tip_html, '#tableTopLeft', {
+                tips: [1, "#"],  //1-4表示上右下左四个方向,# 可带背景色
+                area: ['450px', 'auto'], // 提示框宽高
+                time: 0  //自动关闭所需毫秒,0表示不自动关闭
             });
+        }).on('mouseleave', '#tableTopLeft', function(){ // 监听鼠标移出事件
+            console.log("mouseleave")
+            layer.close(tip_index);
         });
+
+
+
         /*用户-删除*/
         function member_del(obj, id) {
             layer.confirm('确认要删除吗?',
@@ -230,5 +296,26 @@
             });
         }
     </script>
+    <script>
+
+    function f_tishi() {
+        layer.open({
+            title: '说明'
+            ,content: '<h2 style="color: #d80000">设备管理里面 温湿度 不是实时数据</h2>' +
+                '<h2>连接状态:</h2>' +
+                '<p>1、通讯正常</p>' +
+                '<p>2、设备已关机</p>' +
+                '<p>3、设备无网络(设备信号弱,或无信号)</p>' +
+                '<h2>监控状态:</h2>' +
+                '<p>1、监控状态</p>' +
+                '<p>2、未监控</p>' +
+                '<p>3、未知状态(由于设备异常断开网络,请以设备实际显示为准)</p>'+
+                '<h2>弃用设备:</h2>' +
+                '<p>1、本设备所有探头 在数据展示中将会隐藏,可以通过指定SN搜索到历史数据</p>'
+        });
+    }
+
+
+    </script>
+</html>
 
-</html>

+ 235 - 11
views/Device/DeviceClass-.html

@@ -28,6 +28,15 @@
                 -khtml-user-select: none; /*早期浏览器*/
                 user-select: none;
             }
+            .box_x{
+                border: 1px solid #1E9FFF;
+                width: 42px;
+                height: 16px;
+                margin: 0;
+                padding: 4px;
+                float: left;
+                text-align: center;
+            }
 
         </style>
     <body>
@@ -45,13 +54,19 @@
                     {{if ne .id 0 }}
                         <div class="layui-tab layui-tab-card">
                             <ul class="layui-tab-title">
-                                <li class="layui-this">微信通知</li>
+                                <li class="layui-this">通知规则</li>
+                                <li class="">微信通知</li>
                                 <li class="">电话通知</li>
                                 <li class="">短信通知</li>
                                 <li class="">邮箱通知</li>
                             </ul>
-                            <div class="layui-tab-content" style="height: 350px;">
-                                <div class="layui-tab-item layui-show" >
+                            <div class="layui-tab-content" style="height: 340px;overflow-y: auto;">
+                                <div id="T_Notice_mechanism" class="layui-tab-item layui-show" style="" >
+
+
+
+                                </div>
+                                <div class="layui-tab-item " >
                                     <div class="layui-row" style="margin: 0px 10px">
                                         <div class="layui-col-xs6" >
                                             <div class="layui-row no_select" style="margin: 10px 0px;font-size: 15px;color: #1E9FFF">
@@ -64,12 +79,12 @@
                                                 <img id="myimg" style="width: 150px;height: 150px;float: left" src="https://osscold.baozhida.cn/images/二维码.png">
 
                                             </div>
-                                            <div class="layui-row no_select" style="margin: 10px 0px;font-size: 15px;color: #1E9FFF;margin-top: 18px">
-                                                方式二:回复内容
-                                            </div>
-                                            <div id="Code" class="layui-row" style="height: 50px;margin: 0px 10px;border:1px solid  #cbcbcb;box-shadow: 0px 0px 8px #316fe7;padding: 6px;border-radius:5px;">
+<!--                                            <div class="layui-row no_select" style="margin: 10px 0px;font-size: 15px;color: #1E9FFF;margin-top: 18px">-->
+<!--                                                方式二:回复内容-->
+<!--                                            </div>-->
+<!--                                            <div id="Code" class="layui-row" style="height: 50px;margin: 0px 10px;border:1px solid  #cbcbcb;box-shadow: 0px 0px 8px #316fe7;padding: 6px;border-radius:5px;">-->
 
-                                            </div>
+<!--                                            </div>-->
                                         </div>
                                         <div id="Notice_wx_list" class="layui-col-xs6" style="padding-left: 6px;padding-right: 6px;height: 350px;border-left:1px solid  #cbcbcb;overflow-y:auto;">
 <!--                                            <div class="layui-col" style="height: 32px;background-color: #fafafa;border-radius:5px;margin-bottom: 4px;">-->
@@ -276,6 +291,7 @@
             var T_Notice_phone = "{{.T.T_Notice_phone}}"
             var T_Notice_message = "{{.T.T_Notice_message}}"
             var T_Notice_mailbox = "{{.T.T_Notice_mailbox}}"
+            var T_Notice_mechanism = "{{.T.T_Notice_mechanism}}"
             var Onload = true
             var forNotice_wx = true
             // 页面 加载完成后执行
@@ -283,6 +299,7 @@
                 console.log("页面 加载完成后执行")
                 if(Onload && parseInt(getPar("id")) > 0){
                     Onload =false;
+                    Show_Notice_T_Notice_mechanism();  // 报警机制
                     Show_Notice_phone_list();
                     Show_Notice_message_list();
                     Show_Notice_mailbox_list();
@@ -292,7 +309,7 @@
                     setInterval(function(){
                         if(forNotice_wx){
 
-                            Automaticupdate_Notice_wx();
+                            // Automaticupdate_Notice_wx();
                         }
                     },2000);
                 }
@@ -491,7 +508,7 @@
                         console.log(result)
                         if (result.Code == 200 ){
                             $("#myimg").attr('src',result.Data.QR);
-                            $('#Code').html(result.Data.Code);
+                            // $('#Code').html(result.Data.Code);
                         }else {
                             layer.msg('二维码生成失败!', {
                                 time: 2000
@@ -524,6 +541,10 @@
                 });
             }
             function DeviceClass_Post(){
+                var loading = layer.load(0, {
+                    shade: false,
+                    time: 99*1000
+                });
                 $.ajax({
                     type: 'POST',
                     url: 'DeviceClass_Post',//发送请求
@@ -534,19 +555,222 @@
                         T_Notice_phone:T_Notice_phone,
                         T_Notice_message:T_Notice_message,
                         T_Notice_mailbox:T_Notice_mailbox,
+                        T_Notice_mechanism:Get_Notice_T_Notice_mechanism(),
 
                     },
                     success: function(result) {
                         console.log(result)
-
+                        layer.close(loading)
                         //关闭当前frame
                         parent.layer.close();
                         parent.location.reload();
                     }
                 });
             }
+
+
         </script>
+        <script>
+            // 初始化 报警规则机制
+            function T_Notice_mechanism_initialization(){
+                var loading = layer.load(0, {
+                    shade: false,
+                    time: 99*1000
+                });
+                $.ajax({
+                    type: 'POST',
+                    url: 'DeviceWarningListT_Tips',//发送请求
+                    success: function(result) {
+                        console.log(result)
+                        layer.close(loading)
+                        //关闭当前frame
+                        // parent.layer.close();
+                        // parent.location.reload();
+                        T_Notice_mechanism = result.Data
+                        Show_Notice_T_Notice_mechanism()
+                    }
+                });
+            }
+            function Get_Notice_T_Notice_mechanism() {
+                box = $(".box_x")
+                if(box.length < 8){
+                    return ""
+                }
+                box_x = (box.length / 15) - 1
+                console.log("box_x:",box_x)
+                i_v = 15
+                str_ = ""
+                for (let i = 0; i < box_x; i++) {
+                    i_ = 15 + 15 * i
+
+
+                    str_ += box[i_+0].textContent + ","
+                    i_++
+                    if(box[i_].firstElementChild.checked == true){
+                        str_ += "1,"
+                    }else {
+                        str_ += "0,"
+                    }
+                    i_++
+                    if(box[i_].firstElementChild.checked == true){
+                        str_ += "1,"
+                    }else {
+                        str_ += "0,"
+                    }
+                    i_++
+                    if(box[i_].firstElementChild.checked == true){
+                        str_ += "1,"
+                    }else {
+                        str_ += "0,"
+                    }
+                    i_++
+                    str_ += box[i_].firstElementChild.value + ","
+                    i_++
+                    str_ += box[i_].firstElementChild.value + ","
+                    i_++
+                    if(box[i_].firstElementChild.checked == true){
+                        str_ += "1,"
+                    }else {
+                        str_ += "0,"
+                    }
+                    i_++
+                    str_ += box[i_].firstElementChild.value + ","
+                    i_++
+                    str_ += box[i_].firstElementChild.value + ","
+                    i_++
+                    if(box[i_].firstElementChild.checked == true){
+                        str_ += "1,"
+                    }else {
+                        str_ += "0,"
+                    }
+                    i_++
+                    str_ += box[i_].firstElementChild.value + ","
+                    i_++
+                    str_ += box[i_].firstElementChild.value + ","
+                    i_++
+                    if(box[i_].firstElementChild.checked == true){
+                        str_ += "1,"
+                    }else {
+                        str_ += "0,"
+                    }
+                    i_++
+                    str_ += box[i_].firstElementChild.value + ","
+                    i_++
+                    str_ += box[i_].firstElementChild.value + ""
+                    str_ += "|"
+                }
+                return str_
+            }
+            function Show_Notice_T_Notice_mechanism() {
+                console.log("======")
+                var scores = T_Notice_mechanism.split("|");
+                $('#T_Notice_mechanism').html("<div class=\"layui-row\">\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;width: 120px;\">报警类型</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: 1px;\">记录</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: 1px;\">处理</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: 1px;\">微信</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;\">触发数</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;\">上限数</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: 1px;\">短信</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;\">触发数</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;\">上限数</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: 1px;\">手机</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;\">触发数</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;\">上限数</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: 1px;\">邮箱</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;\">触发数</span>\n" +
+                    "                                        <span class=\"box_x\" style=\"margin-left: -1px;\">上限数</span>\n" +
+                    "                                    </div>");
+                for (let i = 0; i < scores.length; i++) {
+                    if(scores[i].length == 0){
+                        break
+                    }
+                    row = scores[i].split(",");
+                    $('#T_Notice_mechanism').append("" +
+                        "\n" +
+                        "                                    <div class=\"layui-row\">\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;width: 120px;\">"+row[0]+"</div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
+                        "                                            <input type=\"checkbox\">\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
+                        "                                            <input type=\"checkbox\">\n" +
+                        "                                        </div>\n" +
+                        "\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
+                        "                                            <input type=\"checkbox\">\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
+                        "                                            <input type=\"text\" style=\"width: 40px;\" value='"+row[4]+"'>\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
+                        "                                            <input type=\"text\" style=\"width: 40px;\" value='"+row[5]+"'>\n" +
+                        "                                        </div>\n" +
+                        "\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
+                        "                                            <input type=\"checkbox\">\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
+                        "                                            <input type=\"text\" style=\"width: 40px;\" value='"+row[7]+"'>\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
+                        "                                            <input type=\"text\" style=\"width: 40px;\" value='"+row[8]+"'>\n" +
+                        "                                        </div>\n" +
+                        "\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
+                        "                                            <input type=\"checkbox\">\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
+                        "                                            <input type=\"text\" style=\"width: 40px;\" value='"+row[10]+"'>\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
+                        "                                            <input type=\"text\" style=\"width: 40px;\" value='"+row[11]+"'>\n" +
+                        "                                        </div>\n" +
+                        "\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: 1px;\">\n" +
+                        "                                            <input type=\"checkbox\">\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
+                        "                                            <input type=\"text\" style=\"width: 40px;\" value='"+row[13]+"'>\n" +
+                        "                                        </div>\n" +
+                        "                                        <div class=\"box_x\" style=\"margin-left: -1px;\">\n" +
+                        "                                            <input type=\"text\" style=\"width: 40px;\" value='"+row[14]+"'>\n" +
+                        "                                        </div>\n" +
+                        "\n" +
+                        "\n" +
+                        "                                    </div>\n")
+
+
+                    box = $(".box_x")
+                    if(row[1] == 1){
+                        box[box.length-1-13].firstElementChild.checked = true
+                    }
+                    if(row[2] == 1){
+                        box[box.length-1-12].firstElementChild.checked = true
+                    }
+                    if(row[3] == 1){
+                        box[box.length-1-11].firstElementChild.checked = true
+                    }
+                    if(row[6] == 1){
+                        box[box.length-1-8].firstElementChild.checked = true
+                    }
+                    if(row[9] == 1){
+                        box[box.length-1-5].firstElementChild.checked = true
+                    }
+                    if(row[12] == 1){
+                        box[box.length-1-2].firstElementChild.checked = true
+                    }
+
+                }
+
+
+                $('#T_Notice_mechanism').append("<div class='layui-row' style='text-align: center;margin-top: 20px'> " +
+                    "<button class=\"layui-btn layui-btn-normal\" onclick=\"T_Notice_mechanism_initialization()\">重置数据</button><button class=\"layui-btn layui-btn-normal\" onclick=\"T_Notice_mechanism_initialization()\">说明</button>" +
+                    " </div>" )
 
+
+            }
+        </script>
     </body>
 
 </html>

+ 1 - 1
views/Device/DeviceClass.html

@@ -61,7 +61,7 @@
                             <td class="td-manage">
                                 <button class="layui-btn layui-btn layui-btn-normal"  onclick="xadmin.open('绑定传感器','DeviceClassBind_html?class_id={{$elem.Id}}')" ><i class="iconfont" style="margin-right: 8px;">&#xe6f7;</i>绑定传感器</button>
 
-                                <button class="layui-btn layui-btn layui-btn-xs" style="margin-left: 8px" onclick="xadmin.open('编辑','DeviceClass_?id={{$elem.Id}}',700,600)" ><i class="layui-icon">&#xe642;</i>编辑</button>
+                                <button class="layui-btn layui-btn layui-btn-xs" style="margin-left: 8px" onclick="xadmin.open('编辑','DeviceClass_?id={{$elem.Id}}',920,600)" ><i class="layui-icon">&#xe642;</i>编辑</button>
                                 <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(this,'{{$elem.Id}}')" href="javascript:;" ><i class="layui-icon" >&#xe640;</i>删除</button>
                             </td>
                         </tr>

+ 6 - 8
views/Device/DeviceClassBind-.html

@@ -314,11 +314,6 @@
 
     function Checkboxs_GetAll () {
 
-        var loading = layer.load(0, {
-            shade: false,
-            time: 99*1000
-        });
-
         for(var i = 0;i < checkboxs.length; i++){
             if(checkboxs[i].checked){
                 d_sn_id = checkboxs[i].value.split(",")
@@ -333,7 +328,7 @@
 
         setTimeout(function(){
             get_DeviceSensor_calss_list(0)
-            layer.close(loading)
+
             setTimeout(function(){
                 layer.msg('成功绑定传感器');
                 //要执行的代码
@@ -622,7 +617,10 @@
 
     // 绑定操作
     function DeviceBind_Add(T_sn,T_id,T_class_id,show) {
-
+        loading = layer.load(0, {
+            shade: false,
+            time: 99*1000
+        });
         $.ajax({
             type: 'POST',
             url: 'DeviceClassBind_Add',//发送请求
@@ -633,7 +631,7 @@
                 T_class_id: T_class_id,
             },
             success: function (result) {
-
+                layer.close(loading)
                 if(show){
                     console.log(result)
                     if (result.Code == 203) {

+ 87 - 0
views/Device/DeviceLogs.html

@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html class="x-admin-sm">
+    
+    <head>
+        <meta charset="UTF-8">
+        <meta name="renderer" content="webkit">
+        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
+        <link rel="shortcut icon" href="https://osscold.baozhida.cn/favicon.ico">
+        <link rel="bookmark" href="https://osscold.baozhida.cn/favicon.ico">
+        <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
+        <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
+        <script src="https://osscold.baozhida.cn/lib/layui/layui.js" charset="utf-8"></script>
+        <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
+    </head>
+    
+    <body>
+
+        <div class="layui-fluid">
+            <div class="layui-row layui-col-space15">
+                <div class="layui-col-md12">
+                    <div class="layui-card">
+
+                        <div class="layui-card-body " >
+                            <table class="layui-table layui-form">
+                                <thead>
+                                    <tr>
+                                        <th>内容</th>
+                                        <th>时间</th>
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                {{range $index, $elem := .List}}
+                                    <tr>
+                                        <td>{{$elem.Logs_Txt}}</td>
+                                        <td>{{$elem.CreateTime}}</td>
+                                    </tr>
+
+                                {{end}}
+
+
+                                </tbody>
+                            </table>
+                        </div>
+                        <div class="layui-card-body ">
+                            <div class="page">
+                                <div>
+
+                                    {{range $index, $elem := .Pages}}
+                                        {{if eq $elem.A 1}}
+                                        <a class="prev" href="?page={{$elem.V}}&T_sn={{$.T_sn}}">&lt;&lt;</a>
+                                        {{end}}
+                                        {{if eq $elem.A 2}}
+                                        <a class="num" href="?page={{$elem.V}}&T_sn={{$.T_sn}}">{{$elem.V}}</a>
+                                        {{end}}
+                                        {{if eq $elem.A 3}}
+                                        <span class="current">{{$elem.V}}</span>
+                                        {{end}}
+                                        {{if eq $elem.A 4}}
+                                        <a class="num" href="?page={{$elem.V}}&T_sn={{$.T_sn}}">{{$elem.V}}</a>
+                                        {{end}}
+                                        {{if eq $elem.A 5}}
+                                        <a class="next" href="?page={{$elem.V}}&T_sn={{$.T_sn}}">&gt;&gt;</a>
+                                        {{end}}
+
+
+
+                                    {{end}}
+
+
+
+                                </div>
+                                Page:{{.Page}}-
+                                Page_size:{{.Page_size}}-
+                                cnt:{{.cnt}}
+                            </div>
+                        </div>
+
+
+                    </div>
+                </div>
+            </div>
+        </div>
+    </body>
+
+
+</html>

+ 1 - 1
views/Device/DeviceWarning.html

@@ -84,7 +84,7 @@
                                 </thead>
                                 <tbody>
                                 {{range $index, $elem := .List}}
-                                    <tr {{if compare $elem.T_State 1 }} style="background-color: rgba(255,0,0,0.23)" {{end}} >
+                                    <tr {{if eq $elem.T_State 2 }} style="background-color: rgba(255,0,0,0.23)" {{end}} >
 
                                         <td style="min-width: 30px;">
                                              <input type="checkbox" name='checkboxxx' class='checkboxxx'  value='{{$elem.Id}}'  style='float: left;width: 10px;height: 10px;margin-top: 16px;margin-left: 10px;' />

+ 10 - 11
views/Device/Device_Sensor-.html

@@ -160,7 +160,7 @@
                 </form>
 
 
-                <fieldset class="layui-elem-field layui-field-title" style="margin-top: -10px;">
+                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                     <legend>设备操作</legend>
                 </fieldset>
 
@@ -266,9 +266,9 @@
                         console.log(result)
                         layer.close(loading)
                         //关闭当前frame
-                        parent.layer.close(parent.layer.getFrameIndex(window.name));
+                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
+                        parent.layer.close(index); //再执行关闭
                         parent.location.reload();
-
                         // return false;
                     }
                 });
@@ -294,11 +294,9 @@
                     },
                     success: function (result) {
                         console.log(result)
-                        layer.close(loading)
-                        //关闭当前frame
-                        parent.layer.close(parent.layer.getFrameIndex(window.name));
+                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
+                        parent.layer.close(index); //再执行关闭
                         parent.location.reload();
-
                         // return false;
                     }
                 });
@@ -322,9 +320,9 @@
                 console.log(result)
 
                 //关闭当前frame
-                parent.layer.close(parent.layer.getFrameIndex(window.name));
+                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
+                parent.layer.close(index); //再执行关闭
                 parent.location.reload();
-
                 // return false;
             }
         });
@@ -416,8 +414,9 @@
                         success: function (result) {
                             console.log(result)
                             //关闭当前frame
-                            parent.layer.close(parent.layer.getFrameIndex(window.name));
-
+                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
+                            parent.layer.close(index); //再执行关闭
+                            parent.location.reload();
 
                             // return false;
                         }