| 
					
				 | 
			
			
				@@ -9,12 +9,11 @@ import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"Cold_Api/models/Device" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"Cold_Api/models/System" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"Cold_Api/models/Warning" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	"fmt" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	beego "github.com/beego/beego/v2/server/web" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	"github.com/xuri/excelize/v2" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"github.com/shopspring/decimal" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"math" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	"os" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"strconv" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"strings" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"time" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -139,9 +138,18 @@ func (c *DeviceController) Device_Add() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// 添加设备后自动重启 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	MqttIds := strings.Split(conf.MqttIds, ",") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for _, id := range MqttIds { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		NatsServer.Set_RestartShutdown(Device.Device_task{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			T_sn:   T_sn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			T_task: "1", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}, id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "设备添加", var_) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	NatsServer.Read_DeviceParameter(T_sn) // 获取主机信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	NatsServer.Read_DeviceParameter(T_sn, "") // 获取主机信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.ServeJSON() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -224,16 +232,84 @@ func (c *DeviceController) Device_Edit() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (c *DeviceController) Device_Applet_Get() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	T_snid := c.GetString("T_snid") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	sn_id := strings.Split(strings.Trim(T_snid, "|"), ",") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if len(sn_id) != 2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_snid err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	T_sn, T_id := sn_id[0], lib.To_int(sn_id[1]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Device_r, err := Device.Read_Device_ByT_sn(T_sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if Device_r.T_pid != c.T_pid { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "无权查看!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Dsp, _ := Device.Read_DeviceSensorParameter(T_sn, T_id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	DeviceData := Device.Read_DeviceData(T_sn, T_id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	type JSONS struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_name    string // 设备名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_monitor int    // 监控状态 0 未监控 1 监控 停止记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_ist     int    // 温度   1开启   2关闭 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_ish     int    // 湿度   1开启   2关闭 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_t  float32 // 温度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_rh float32 // 湿度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_Tlower  float32 //  温度下限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_Tupper  float32 //  温度上限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_RHlower float32 //  湿度下限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_RHupper float32 //  湿度上限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	r_jsons := JSONS{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_name:    Device_r.T_devName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_monitor: Device_r.T_monitor, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_ist:     Device_r.T_ist, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_ish:     Device_r.T_ish, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_t:       DeviceData.T_t, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_rh:      DeviceData.T_rh, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_Tlower:  Dsp.T_Tlower, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_Tupper:  Dsp.T_Tupper, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_RHlower: Dsp.T_RHlower, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_RHupper: Dsp.T_RHupper, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 重启/关机 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (c *DeviceController) Device_RestartShutdown() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_sn := c.GetString("T_sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_task := c.GetString("T_task") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	device, err := Device.Read_Device_ByT_sn(T_sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	NatsServer.Set_RestartShutdown(Device.Device_task{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_sn:   T_sn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_task: T_task, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	}, device.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	System.Add_UserLogs(c.Admin_r.T_uuid, "设备管理", "重启/关机", T_sn+"-"+T_task) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -247,8 +323,13 @@ func (c *DeviceController) Device_ProductUpgrade() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_sn := c.GetString("T_sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_version := c.GetString("T_version") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_file := c.GetString("T_file") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	NatsServer.Up_ProductUpgrade(T_sn, T_version, T_file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	device, err := Device.Read_Device_ByT_sn(T_sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	NatsServer.Up_ProductUpgrade(T_sn, T_version, T_file, device.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	System.Add_UserLogs(c.Admin_r.T_uuid, "设备管理", "版本升级", T_sn+"-"+T_version+"-"+T_file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -350,9 +431,16 @@ func (c *DeviceController) Device_Parameter_List() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (c *DeviceController) Device_Parameter_Get() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Sn := c.GetString("T_sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	device, err := Device.Read_Device_ByT_sn(Sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	DeviceParameter_lite := Device.Read_DeviceParameter_SN(Sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if len(DeviceParameter_lite) == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		NatsServer.Read_DeviceParameter(Sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		NatsServer.Read_DeviceParameter(Sn, device.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "未同步参数,请检查设备是否正常!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -468,6 +556,9 @@ func (c *DeviceController) Device_Parameter_Pu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, err := c.GetInt("T_dormancy"); err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		DeviceParameter.T_dormancy = v 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if v, err := c.GetInt("T_snum"); err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		DeviceParameter.T_snum = v 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v := c.GetString("T_btname"); len(v) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		DeviceParameter.T_btname = v 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -488,6 +579,8 @@ func (c *DeviceController) Device_Parameter_Pu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	DeviceParameter.T_State = 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	DeviceParameter.T_uuid = c.Admin_r.T_uuid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	DeviceParameter.T_SendState = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	DeviceParameter.CreateTime = time.Now() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	DeviceParameter.UpdateTime = time.Now() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Deviceparameter, is := Device.Add_DeviceParameter(DeviceParameter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if !is { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -496,7 +589,7 @@ func (c *DeviceController) Device_Parameter_Pu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "设备参数操作", Deviceparameter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	NatsServer.Pu_DeviceParameter(Deviceparameter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	NatsServer.Pu_DeviceParameter(Deviceparameter, Device_r.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v := c.GetString("T_name"); len(v) > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 更新名称 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -517,6 +610,12 @@ func (c *DeviceController) Device_Parameter_Del_Device() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Sn := c.GetString("Sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Id, _ := c.GetInt("Id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	device, err := Device.Read_Device_ByT_sn(Sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "传感器 删除操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -525,7 +624,7 @@ func (c *DeviceController) Device_Parameter_Del_Device() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	NatsServer.Del_DeviceSensor(Device.DeviceSensor_Del{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_sn: Sn, T_id: Id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	}, device.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "OK"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.ServeJSON() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -605,7 +704,7 @@ func (c *DeviceController) DeviceSensor_Edit() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	// 数据视图3D视图订阅 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, err := c.GetInt("T_type"); err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if v == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "类型错误!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			c.Data["json"] = lib.JSONS{Code: 202, Msg: "类型不能为默认!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -645,6 +744,13 @@ func (c *DeviceController) DeviceSensor_Del() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Sn := c.GetString("T_sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Id, _ := c.GetInt("T_id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	device, err := Device.Read_Device_ByT_sn(Sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	_, is := Device.Read_DeviceSensor_ByT_sn(Sn, Id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if !is { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "信息错误!"} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -659,7 +765,7 @@ func (c *DeviceController) DeviceSensor_Del() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Device.Delete_DeviceSensor_ById(Sn, Id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		NatsServer.Del_DeviceSensor(Device.DeviceSensor_Del{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			T_sn: Sn, T_id: Id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}, device.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "传感器 删除操作", "SN:"+Sn+" ["+strconv.Itoa(Id)+"]") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Device.Delete_DeviceSensor_ById(Sn, Id) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -677,10 +783,17 @@ func (c *DeviceController) DeviceSensor_Parameter_Get() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Sn := c.GetString("T_sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Id, _ := c.GetInt("T_id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	device, err := Device.Read_Device_ByT_sn(Sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//c.Data["DeviceSensor"], _ = Device.Read_DeviceSensor_ByTsn_Tid(Sn, Id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	DeviceSensorParameter_lite := Device.Read_DeviceSensorParameter_T_sn_T_id(Sn, Id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if len(DeviceSensorParameter_lite) == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		NatsServer.Read_DeviceSensorParameter(Sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		NatsServer.Read_DeviceSensorParameter(Sn, device.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "未同步参数,请检查设备是否正常!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -716,7 +829,7 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_SN := c.GetString("T_sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_id, _ := c.GetInt("T_id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	_, err := Device.Read_Device_ByT_sn(T_SN) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	device, err := Device.Read_Device_ByT_sn(T_SN) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		c.ServeJSON() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -744,19 +857,23 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_Tlower := DeviceSensorParameter.T_Tlower 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_Tlower_err := c.GetFloat("T_Tlower"); T_Tlower_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_Tlower = float32(v) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		temp, _ := decimal.NewFromFloat(v).Round(2).Float64() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_Tlower = float32(temp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_Tupper := DeviceSensorParameter.T_Tupper 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_Tupper_err := c.GetFloat("T_Tupper"); T_Tupper_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_Tupper = float32(v) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		temp, _ := decimal.NewFromFloat(v).Round(2).Float64() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_Tupper = float32(temp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_RHlower := DeviceSensorParameter.T_RHlower 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_RHlower_err := c.GetFloat("T_RHlower"); T_RHlower_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_RHlower = float32(v) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		temp, _ := decimal.NewFromFloat(v).Round(2).Float64() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_RHlower = float32(temp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_RHupper := DeviceSensorParameter.T_RHupper 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_RHupper_err := c.GetFloat("T_RHupper"); T_RHupper_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_RHupper = float32(v) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		temp, _ := decimal.NewFromFloat(v).Round(2).Float64() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_RHupper = float32(temp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_enprel := DeviceSensorParameter.T_enprel 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -765,25 +882,33 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_tprel := DeviceSensorParameter.T_tprel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_tprel_err := c.GetFloat("T_tprel"); T_tprel_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_tprel = float32(v) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		temp, _ := decimal.NewFromFloat(v).Round(2).Float64() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_tprel = float32(temp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_tpreu := DeviceSensorParameter.T_tpreu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_tpreu_err := c.GetFloat("T_tpreu"); T_tpreu_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_tpreu = float32(v) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		temp, _ := decimal.NewFromFloat(v).Round(2).Float64() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_tpreu = float32(temp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_hprel := DeviceSensorParameter.T_hprel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_hprel_err := c.GetFloat("T_hprel"); T_hprel_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_hprel = float32(v) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		temp, _ := decimal.NewFromFloat(v).Round(2).Float64() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_hprel = float32(temp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_hpreu := DeviceSensorParameter.T_hpreu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_hpreu_err := c.GetFloat("T_hpreu"); T_hpreu_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_hpreu = float32(v) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		temp, _ := decimal.NewFromFloat(v).Round(2).Float64() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_hpreu = float32(temp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_speed := DeviceSensorParameter.T_speed 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_speed_err := c.GetInt("T_speed"); T_speed_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_speed = v 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	T_sense := DeviceSensorParameter.T_sense 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if v, T_sense_err := c.GetInt("T_sense"); T_sense_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_sense = v 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_en := DeviceSensorParameter.T_en 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if v, T_en_err := c.GetInt("T_en"); T_en_err == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_en = v 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -801,6 +926,7 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_RHlower: T_RHlower, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_RHupper: T_RHupper, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_speed:   T_speed, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_sense:   T_sense, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_en:      T_en, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		T_free:    T_free, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -834,7 +960,7 @@ func (c *DeviceController) DeviceSensor_Parameter_Pu() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		System.Add_UserLogs_T(c.Admin_r.T_uuid, "设备管理", "修改传感器名称", DeviceSensor) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	NatsServer.Pu_DeviceParameter_Sensor(dsp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	NatsServer.Pu_DeviceParameter_Sensor(dsp, device.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.ServeJSON() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -972,347 +1098,23 @@ func (c *DeviceController) DeviceTask_Post() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_sn := c.GetString("T_sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	T_task := c.GetString("T_task") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	NatsServer.Set_DeviceTask(Device.Device_task{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_sn:   T_sn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_task: T_task, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	System.Add_UserLogs(c.Admin_r.T_uuid, "设备管理", "远程启停", T_sn+"-"+T_task) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 设备告警 ------------------------------------------ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 告警列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) DeviceWarning_List() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	type R_JSONS struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//必须的大写开头 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Data      []Warning.Warning_R 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Num       int64 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Page      int 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Page_size int 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var r_jsons R_JSONS 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	page, _ := c.GetInt("page") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if page < 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		page = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	page_z, _ := c.GetInt("page_z") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if page_z < 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		page_z = conf.Page_size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_name := c.GetString("T_name") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_tp := c.GetString("T_tp") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Time_start := c.GetString("Time_start") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Time_end := c.GetString("Time_end") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_handle, _ := c.GetInt("T_handle") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_admin, _ := c.GetInt("T_admin") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_history, _ := c.GetInt("T_history") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var T_year, T_month string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if T_history == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		date, err := time.Parse("2006-01-02 15:04:05", Time_start) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_year, T_month = date.Format("2006"), date.Format("01") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if T_admin == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if T_history == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			// 获取备份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			r_jsons.Data, r_jsons.Num = Warning.Read_Admin_Warning_Backups(c.Admin_r.T_pids, T_year, T_month, T_tp, T_name, T_handle, Time_start, Time_end, page, page_z) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			// 获取最新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			r_jsons.Data, r_jsons.Num = Warning.Read_Admin_Warning_List(c.Admin_r.T_pids, T_tp, T_name, T_handle, Time_start, Time_end, page, page_z) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	device, err := Device.Read_Device_ByT_sn(T_sn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_sn Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if T_history == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 获取备份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		r_jsons.Data, r_jsons.Num = Warning.Read_Warning_Backups(c.T_pid, T_year, T_month, T_tp, T_name, T_handle, Time_start, Time_end, page, page_z) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 获取最新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		r_jsons.Data, r_jsons.Num = Warning.Read_Warning_List(c.T_pid, T_tp, T_name, T_handle, Time_start, Time_end, page, page_z) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	r_jsons.Page = page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 查询告警 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) DeviceWarning_Get() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	id, _ := c.GetInt("T_id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_history, _ := c.GetInt("T_history") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T := Warning.Read_Warning_ById(int64(id)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Warning.WarningToWarning_R(T_history, T)} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 编辑告警(处理告警) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) DeviceWarning_Post() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	id, _ := c.GetInt("T_id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_Text := c.GetString("T_Text") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_time := c.GetString("T_time") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_history, _ := c.GetInt("T_history") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var T_year, T_month string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var warning Warning.Warning 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Wtab := "warning" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if T_history == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		date, err := time.Parse("2006-01-02 15:04:05", T_time) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_year, T_month = date.Format("2006"), date.Format("01") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Wtab += "_" + T_year + "_" + T_month 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning, err = Warning.Read_Warning_ById_Backups(id, T_year, T_month) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning.T_Text = T_Text 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning.T_State = 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if is := Warning.Update_Warning_Backups(warning, T_year, T_month); !is { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning = Warning.Read_Warning_ById(int64(id)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if warning.Id == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning.T_Text = T_Text 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning.T_State = 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if is := Warning.Update_Warning(warning, "T_Text", "T_State"); !is { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	NatsServer.Set_DeviceTask(Device.Device_task{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_sn:   T_sn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_task: T_task, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	}, device.T_mqttid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	System.Add_UserLogs(c.Admin_r.T_uuid, "设备管理", "远程启停", T_sn+"-"+T_task) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	System.Add_UserLogs(c.Admin_r.T_uuid, "设备管理", "报警处理操作", Wtab+":"+strconv.Itoa(id)+"->"+T_Text) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 删除告警 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) DeviceWarning_Del() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	id, _ := c.GetInt("T_id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_time := c.GetString("T_time") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_history, _ := c.GetInt("T_history") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var T_year, T_month string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var warning Warning.Warning 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Wtab := "warning" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if T_history == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		date, err := time.Parse("2006-01-02 15:04:05", T_time) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_year, T_month = date.Format("2006"), date.Format("01") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Wtab += "_" + T_year + "_" + T_month 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning, err = Warning.Read_Warning_ById_Backups(id, T_year, T_month) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning.T_State = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if is := Warning.Update_Warning_Backups(warning, T_year, T_month); !is { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning = Warning.Read_Warning_ById(int64(id)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if warning.Id == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		warning.T_State = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if is := Warning.Update_Warning(warning, "T_Text", "T_State"); !is { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	System.Add_UserLogs(c.Admin_r.T_uuid, "设备管理", "报警删除操作", Wtab+":"+strconv.Itoa(id)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 导出告警 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) DeviceWarning_Data_Excel() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_name := c.GetString("T_name") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_tp := c.GetString("T_tp") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Time_start := c.GetString("Time_start") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Time_end := c.GetString("Time_end") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_handle, _ := c.GetInt("T_handle") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_history, _ := c.GetInt("T_history") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var T_year, T_month string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if T_history == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		date, err := time.Parse("2006-01-02 15:04:05", Time_start) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_year, T_month = date.Format("2006"), date.Format("01") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var Device_data []Warning.Warning_R 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if T_history == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 获取备份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Device_data, _ = Warning.Read_Warning_Backups(c.T_pid, T_year, T_month, T_tp, T_name, T_handle, Time_start, Time_end, 0, 9999) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 获取最新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Device_data, _ = Warning.Read_Warning_List(c.T_pid, T_tp, T_name, T_handle, Time_start, Time_end, 0, 9999) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f := excelize.NewFile() // 设置单元格的值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	// 这里设置表头 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetCellValue("Sheet1", "A1", "报警类型") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetCellValue("Sheet1", "B1", "Sn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetCellValue("Sheet1", "C1", "设备名称") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetCellValue("Sheet1", "D1", "传感器") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetCellValue("Sheet1", "E1", "报警内容") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetCellValue("Sheet1", "F1", "记录时间") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetCellValue("Sheet1", "G1", "处理") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetCellValue("Sheet1", "H1", "处理时间") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	// 设置列宽 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetColWidth("Sheet1", "A", "A", 20) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetColWidth("Sheet1", "B", "B", 25) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetColWidth("Sheet1", "C", "C", 30) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetColWidth("Sheet1", "D", "D", 30) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetColWidth("Sheet1", "G", "E", 30) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetColWidth("Sheet1", "H", "F", 15) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetColWidth("Sheet1", "I", "G", 30) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	f.SetColWidth("Sheet1", "J", "H", 15) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	line := 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	// 循环写入数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	for _, v := range Device_data { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		line++ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), Warning.Read_WarningType_Get(v.T_tp)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), fmt.Sprintf("%s[%d]", v.T_sn, v.Id)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.T_D_name) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.T_DS_name) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), v.T_Remark) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), v.T_Ut) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.T_Text) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), v.CreateTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	timeStr := time.Now().Format("20060102150405") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	// 保存文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		fmt.Println(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	url, is := NatsServer.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if !is { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		c.Data["json"] = lib.JSONS{Code: 202, 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: url} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 告警提示列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) DeviceWarningList_T_Tips() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Warning.Read_WarningType_All_T_Notice_mechanism()} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 告警类型列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) WarningType_List_All() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Warning.Read_WarningType_All()} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 告警类型列表 - 权限关联列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) WarningType_Power_List_All() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	power, err := Account.Read_Power_ById(c.Admin_r.T_power) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		c.Data["json"] = lib.JSONS{Code: 200, Msg: "获取菜单失败"} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Warning.Read_WarningType_Power_All(power.T_warning)} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 通过传感器类型获取报警列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (c *DeviceController) Read_Warning_List_By_DS_T_type() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var r_jsons lib.R_JSONS 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	page, _ := c.GetInt("page") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if page < 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		page = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	page_z, _ := c.GetInt("page_z") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if page_z < 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		page_z = conf.Page_size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_type, _ := c.GetInt("T_type") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	T_name := c.GetString("T_name") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	r_jsons.Data, r_jsons.Num = Warning.Read_Warning_List_By_DS_T_type(c.T_pid, T_type, T_name, page, page_z) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	r_jsons.Page = page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c.ServeJSON() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 设备分类 ------------------------------------------ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2121,6 +1923,12 @@ func (c *DeviceController) DeviceSensor_Applet_List_View2() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	var deviceMap = make(map[string][]Device.DeviceSensor_Applet) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	var num int64 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	type DeviceList struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		T_sn             string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		DeviceSensorList []Device.DeviceSensor_Applet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	var deviceList []DeviceList 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	for _, ds := range dsList { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		_, ok := deviceMap[ds.T_sn] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if !ok { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2128,24 +1936,17 @@ func (c *DeviceController) DeviceSensor_Applet_List_View2() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			var list []Device.DeviceSensor_Applet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			list = append(list, ds) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			deviceMap[ds.T_sn] = list 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			device := DeviceList{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				T_sn: ds.T_sn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			deviceList = append(deviceList, device) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			deviceMap[ds.T_sn] = append(deviceMap[ds.T_sn], ds) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	type DeviceList struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		T_sn             string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		DeviceSensorList []Device.DeviceSensor_Applet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	var deviceList []DeviceList 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	for k, v := range deviceMap { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		device := DeviceList{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			T_sn:             k, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			DeviceSensorList: v, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		deviceList = append(deviceList, device) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for i := 0; i < len(deviceList); i++ { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		deviceList[i].DeviceSensorList = deviceMap[deviceList[i].T_sn] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	var offset int 
			 |