Ver código fonte

update:温湿度显示与屏蔽

zoie 2 anos atrás
pai
commit
5722275e61

+ 20 - 8
controllers/Data.go

@@ -232,17 +232,29 @@ func (c *DataController) Device_Sensor_Data_Excel() {
 
 		f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), line-1)
 		f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v.T_name+"["+strconv.Itoa(v.T_id)+"]")
-		f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.T_t)
-		f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.T_rh)
+
+		if v.T_ist == 1 {
+			f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.T_t)
+			if v.T_t < v.T_tl || v.T_t > v.T_tu {
+				f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleLower)
+			}
+		}
+		if v.T_ish == 1 {
+			f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.T_rh)
+			if v.T_rh < v.T_rhl || v.T_rh > v.T_rhu {
+				f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
+			}
+		}
+
 		f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), strconv.FormatFloat(float64(v.T_tl), 'f', 2, 64)+"~"+strconv.FormatFloat(float64(v.T_tu), 'f', 2, 64))
 		f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), strconv.FormatFloat(float64(v.T_rhl), 'f', 2, 64)+"~"+strconv.FormatFloat(float64(v.T_rhu), 'f', 2, 64))
 		f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.T_time)
-		if v.T_t < v.T_tl || v.T_t > v.T_tu {
-			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleLower)
-		}
-		if v.T_rh < v.T_rhl || v.T_rh > v.T_rhu {
-			f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
-		}
+		//if v.T_ist == 1 && (v.T_t < v.T_tl || v.T_t > v.T_tu) {
+		//	f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleLower)
+		//}
+		//if v.T_ish == 1 && (v.T_rh < v.T_rhl || v.T_rh > v.T_rhu) {
+		//	f.SetCellStyle("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("G%d", line), headStyleUpper)
+		//}
 
 	}
 	timeStr := time.Now().Format("20060102150405")

+ 24 - 3
controllers/Device.go

@@ -108,6 +108,8 @@ func (c *DeviceController) Device_Add() {
 		T_sn:      T_sn,
 		T_monitor: 1, // 监控状态 已监控
 		T_State:   1, // 状态 正常
+		T_ist:     1, // 温度   1开启
+		T_ish:     1, // 湿度   1开启
 	}
 	if len(T_sn) < 8 {
 		c.Data["json"] = lib.JSONS{Code: 303, Msg: "SN 太短 必须8个字符以上"}
@@ -1158,8 +1160,27 @@ func (c *DeviceController) DeviceWarning_Data_Excel() {
 	Time_start := c.GetString("Time_start")
 	Time_end := c.GetString("Time_end")
 	T_handle, _ := c.GetInt("T_handle")
+	T_history, _ := c.GetInt("T_history")
 
-	Device_data, _ := Warning.Read_Warning_List(c.T_pid, T_tp, T_name, T_handle, Time_start, Time_end, 0, 9999)
+	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: 200, 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() // 设置单元格的值
 	// 这里设置表头
@@ -1402,7 +1423,7 @@ func (c *DeviceController) DeviceClassBind_List() {
 
 	type R_JSONS struct {
 		//必须的大写开头
-		DeviceSensor_lite []Device.DeviceSensor_R
+		DeviceSensor_lite []Device.DeviceSensor_
 		Num               int
 		Page              int
 		Page_size         int
@@ -1745,7 +1766,7 @@ func (c *DeviceController) CompanyNotice_Del() {
 func (c *DeviceController) DeviceNoticeBind_List() {
 	type R_JSONS struct {
 		//必须的大写开头
-		DeviceSensor_lite []Device.DeviceSensor_R
+		DeviceSensor_lite []Device.DeviceSensor_
 		Num               int
 		Page              int
 		Page_size         int

+ 3 - 0
controllers/User.go

@@ -324,6 +324,9 @@ func (c *UserController) User_Post() {
 		admin_r.T_mail = T_mail
 	}
 	if len(T_wx) > 0 {
+		if T_wx == "-" {
+			T_wx = ""
+		}
 		admin_r.T_wx = T_wx
 	}
 	is := Account.Update_Admin(admin_r, "T_name", "T_pass", "T_phone", "T_mail", "T_wx")

+ 91 - 0
logs/logx/logx.log

@@ -190,3 +190,94 @@
 2023/02/22 12:53:11.715 [I] [filter.go:21]  2023-02-22 12:53:11>%!(EXTRA []interface {}=[=========== 初始化路由筛选信息 =========])
 2023/02/22 12:53:12.425 [I] [ProductType.go:67]  2023-02-22 12:53:12>%!(EXTRA []interface {}=[=========== 初始化产品类型 =========])
 2023/02/22 12:53:13.714 [I] [WarningType.go:165]  2023-02-22 12:53:13>%!(EXTRA []interface {}=[=========== 初始化报警类型 =========])
+2023/02/23 16:24:45.456 [I] [Nats.go:22]  ============Nats init============
+2023/02/23 16:24:45.474 [I] [Nats.go:30]  nats OK!
+2023/02/23 16:24:45.653 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/23 16:24:47.653 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/23 16:24:48.303 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/23 17:24:47.735 [E] [WarningType.go:196]  Cold_Api/models/Warning.Read_WarningType_All_Maps dial tcp 127.0.0.1:40306: connect: connection refused
+2023/02/23 17:24:48.406 [E] [ProductType.go:76]  Cold_Api/models/Product.Read_ProductType_All_Map dial tcp 127.0.0.1:40306: connect: connection refused
+2023/02/24 10:40:01.903 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 10:40:02.003 [I] [Nats.go:30]  nats OK!
+2023/02/24 10:40:02.182 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 10:40:04.181 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 10:40:04.611 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 10:58:55.665 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 10:58:55.692 [I] [Nats.go:30]  nats OK!
+2023/02/24 10:58:55.835 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 10:58:57.835 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 10:58:58.212 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 11:04:38.395 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 11:04:38.505 [I] [Nats.go:30]  nats OK!
+2023/02/24 11:04:38.593 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 11:04:40.593 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 11:04:41.275 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 11:06:00.565 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 11:06:00.580 [I] [Nats.go:30]  nats OK!
+2023/02/24 11:06:00.659 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 11:06:02.659 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 11:06:03.498 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 11:59:16.174 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 11:59:16.209 [I] [Nats.go:30]  nats OK!
+2023/02/24 11:59:16.275 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 11:59:18.275 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 11:59:19.016 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 12:02:47.453 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /private/var/folders/05/2mhb7py53cn_pkgr00xfjh9c0000gn/T/GoLand/ofile/20230224120247.xlsx ofile/20230224120247.xlsx
+2023/02/24 12:02:47.461 [I] [NatsQiniu.go:109]  七牛云 上传文件失败/private/var/folders/05/2mhb7py53cn_pkgr00xfjh9c0000gn/T/GoLand/ofile/20230224120247.xlsx open /private/var/folders/05/2mhb7py53cn_pkgr00xfjh9c0000gn/T/GoLand/ofile/20230224120247.xlsx: no such file or directory
+2023/02/24 12:05:26.251 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 12:05:26.283 [I] [Nats.go:30]  nats OK!
+2023/02/24 12:05:26.466 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 12:05:28.465 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 12:05:29.161 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 12:05:41.963 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224120541.xlsx ofile/20230224120541.xlsx
+2023/02/24 12:08:19.859 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 12:08:19.887 [I] [Nats.go:30]  nats OK!
+2023/02/24 12:08:20.031 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 12:08:22.031 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 12:08:22.687 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 12:08:31.278 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224120831.xlsx ofile/20230224120831.xlsx
+2023/02/24 12:10:30.039 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121029.xlsx ofile/20230224121029.xlsx
+2023/02/24 12:11:13.868 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121113.xlsx ofile/20230224121113.xlsx
+2023/02/24 12:12:48.955 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121248.xlsx ofile/20230224121248.xlsx
+2023/02/24 12:13:13.070 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121313.xlsx ofile/20230224121313.xlsx
+2023/02/24 12:16:01.027 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121600.xlsx ofile/20230224121600.xlsx
+2023/02/24 12:18:30.420 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 12:18:30.450 [I] [Nats.go:30]  nats OK!
+2023/02/24 12:18:30.685 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 12:18:32.685 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 12:18:33.246 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 12:18:42.875 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224121842.xlsx ofile/20230224121842.xlsx
+2023/02/24 12:20:06.870 [I] [NatsQiniu.go:67]  Qiniu_UploadFile => /Users/zoie/work/bzd_project/Cold_Api/ofile/20230224122006.xlsx ofile/20230224122006.xlsx
+2023/02/24 12:29:53.475 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
+2023/02/24 12:30:08.163 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 12:30:44.796 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 12:30:44.807 [I] [Nats.go:30]  nats OK!
+2023/02/24 12:30:44.926 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 12:30:46.925 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 12:30:47.567 [I] [ProductType.go:68]  =========== 初始化产品类型 =========
+2023/02/24 12:31:31.414 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
+2023/02/24 12:31:41.516 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
+2023/02/24 12:31:51.619 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
+2023/02/24 12:32:21.722 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZK
+2023/02/24 12:32:21.823 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023078426071317
+2023/02/24 12:32:21.924 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023063368215572
+2023/02/24 12:32:22.026 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZ1
+2023/02/24 12:32:22.126 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
+2023/02/24 12:32:22.227 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023062759218739
+2023/02/24 12:32:32.329 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023078426071317
+2023/02/24 12:32:32.430 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023063368215572
+2023/02/24 12:32:32.531 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZ1
+2023/02/24 12:32:32.633 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
+2023/02/24 12:32:32.734 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023062759218739
+2023/02/24 12:32:32.837 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZK
+2023/02/24 12:32:42.941 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023063368215572
+2023/02/24 12:32:43.043 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZ1
+2023/02/24 12:32:43.145 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023073871432976
+2023/02/24 12:32:43.248 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023062759218739
+2023/02/24 12:32:43.350 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 202335OBJGV2PZK
+2023/02/24 12:32:43.452 [I] [NatsMqtt.go:94]  Nats => Cold_Api/Nats/NatsServer.Get_Device_Realtime 2023078426071317
+2023/02/24 14:17:30.798 [I] [Nats.go:22]  ============Nats init============
+2023/02/24 14:17:30.873 [I] [Nats.go:30]  nats OK!
+2023/02/24 14:17:31.064 [I] [filter.go:21]  =========== 初始化路由筛选信息 =========
+2023/02/24 14:17:33.064 [I] [WarningType.go:187]  =========== 初始化报警类型 =========
+2023/02/24 14:17:33.603 [I] [ProductType.go:68]  =========== 初始化产品类型 =========

+ 1 - 0
models/Device/Device.go

@@ -24,6 +24,7 @@ type Device struct {
 	T_pid             int       `orm:"index;size(256);null"` // Account.Company 绑定公司
 	T_devName         string    `orm:"size(256);null"`       // 设备名称  20字
 	T_protocol        int       `orm:"size(2);default(1)"`   // 冷链通讯协议 1 :1.0协议   2 :2.0协议    3 :3.0协议
+	T_mqttid          string    `orm:"size(256);null"`       // MQTT 服务ID
 	T_VerifyTime      time.Time `orm:"type(timestamp);null"` // 验证时间
 	T_CalibrationTime time.Time `orm:"type(timestamp);null"` // 校准时间
 	T_PatrolTime      time.Time `orm:"type(timestamp);null"` // 巡检时间

+ 12 - 3
models/Device/DeviceData.go

@@ -51,6 +51,8 @@ type DeviceData_R struct {
 	T_rhu  float32 // 湿度上限
 	T_time string  // 采集时间
 	T_sp   int     // 传感器参数id
+	T_ist  int     // 温度   1开启   2关闭
+	T_ish  int     // 湿度   1开启   2关闭
 }
 
 //func (t *DeviceData) TableName() string {
@@ -73,7 +75,8 @@ func init() {
 	}
 }
 
-func DeviceData_ToDeviceData_R(r DeviceData_) (t DeviceData_R) {
+func DeviceData_ToDeviceData_R(d Device, r DeviceData_) (t DeviceData_R) {
+
 	t.T_id = r.T_id
 	t.T_t = r.T_t
 	t.T_rh = r.T_rh
@@ -87,6 +90,9 @@ func DeviceData_ToDeviceData_R(r DeviceData_) (t DeviceData_R) {
 	t.T_rhl = sp.T_RHlower
 	t.T_rhu = sp.T_RHupper
 
+	t.T_ist = d.T_ist
+	t.T_ish = d.T_ish
+
 	return t
 }
 
@@ -268,9 +274,12 @@ func Read_DeviceData_ById_List(SN string, T_id int, Time_start_ string, Time_end
 
 	//value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cnt), 64)
 	key, _ := strconv.Atoi(maps_z[0][0].(string))
-
+	device, err := Read_Device_ByT_sn(SN)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+	}
 	for _, v := range maps {
-		r = append(r, DeviceData_ToDeviceData_R(v))
+		r = append(r, DeviceData_ToDeviceData_R(device, v))
 	}
 
 	return r, key

+ 18 - 5
models/Device/DeviceSensor.go

@@ -101,6 +101,12 @@ type DeviceSensor_P struct {
 
 }
 
+type DeviceSensor_ struct {
+	T_sn   string // 设备序列号 KF开头,环境监测主机。 YD开头,温途监测主机
+	T_id   int    // 传感器编号
+	T_name string // 标题
+}
+
 var redisCache_DeviceSensor cache.Cache
 
 func init() {
@@ -192,9 +198,16 @@ func DeviceSensorToDeviceSensor_R(DeviceSensor_ DeviceSensor) (DeviceSensor_r De
 	//key_data := DeviceSensor_.T_sn + "|" + strconv.Itoa(DeviceSensor_.T_id)
 	//DeviceSensor_r.T_DeviceSensorData, _ = RedisDeviceData_Get(key_data)
 	DeviceData := Read_DeviceData(DeviceSensor_.T_sn, DeviceSensor_.T_id)
+	device, _ := Read_Device_ByT_sn(DeviceSensor_.T_sn)
+	DeviceSensor_r.T_DeviceSensorData = DeviceData_ToDeviceData_R(device, DeviceData)
 
-	DeviceSensor_r.T_DeviceSensorData = DeviceData_ToDeviceData_R(DeviceData)
+	return
+}
 
+func DeviceSensorToDeviceSensor_(r DeviceSensor) (t DeviceSensor_) {
+	t.T_sn = r.T_sn
+	t.T_id = r.T_id
+	t.T_name = r.T_name
 	return
 }
 
@@ -405,7 +418,7 @@ func Read_DeviceSensor_ByTsn(T_sn string) ([]DeviceSensor, int) {
 }
 
 // 获取列表
-func Read_DeviceSensor_List_T_Class(T_pid int, T_Class_id int, T_sn string, T_name string, T_type int, page int, page_z int) (DeviceSensor_r []DeviceSensor_R, cnt int64) {
+func Read_DeviceSensor_List_T_Class(T_pid int, T_Class_id int, T_sn string, T_name string, T_type int, page int, page_z int) (DeviceSensor_r []DeviceSensor_, cnt int64) {
 
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
@@ -445,7 +458,7 @@ func Read_DeviceSensor_List_T_Class(T_pid int, T_Class_id int, T_sn string, T_na
 	}
 
 	for _, v := range r {
-		DeviceSensor_r = append(DeviceSensor_r, DeviceSensorToDeviceSensor_R(v))
+		DeviceSensor_r = append(DeviceSensor_r, DeviceSensorToDeviceSensor_(v))
 	}
 	return DeviceSensor_r, cnt
 }
@@ -593,7 +606,7 @@ func Read_DeviceSensor_ALL_Notice_Id(T_Notice_id int) (r []DeviceSensor) {
 }
 
 // 获取列表
-func Read_DeviceSensor_List_T_Notice(T_pid int, T_Notice_id int, page int, page_z int, T_sn string, T_name string, T_type int) (DeviceSensor_r []DeviceSensor_R, cnt int64) {
+func Read_DeviceSensor_List_T_Notice(T_pid int, T_Notice_id int, page int, page_z int, T_sn string, T_name string, T_type int) (DeviceSensor_r []DeviceSensor_, cnt int64) {
 
 	o := orm.NewOrm()
 	// 也可以直接使用 Model 结构体作为表名
@@ -633,7 +646,7 @@ func Read_DeviceSensor_List_T_Notice(T_pid int, T_Notice_id int, page int, page_
 	}
 
 	for _, v := range r {
-		DeviceSensor_r = append(DeviceSensor_r, DeviceSensorToDeviceSensor_R(v))
+		DeviceSensor_r = append(DeviceSensor_r, DeviceSensorToDeviceSensor_(v))
 	}
 	return DeviceSensor_r, cnt
 }

+ 1 - 1
models/Device/DeviceSensorParameter.go

@@ -241,7 +241,7 @@ func Read_DeviceSensorParameter_T_sn_T_id(T_sn string, T_id int) (r []DeviceSens
 	cond := orm.NewCondition()
 	cond = cond.And("T_sn", T_sn).And("T_id", T_id).And("T_State", 1)
 
-	_, err := qs.Limit(1, 0).SetCond((*orm2.Condition)(cond)).All(&r)
+	_, err := qs.Limit(1, 0).SetCond((*orm2.Condition)(cond)).OrderBy("-Id").All(&r)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 	}

+ 8 - 1
models/Warning/Warning.go

@@ -173,11 +173,18 @@ func Read_Warning_List(T_pid int, T_tp, T_name string, T_handle int, Time_start_
 		cond1 = cond1.And("T_State", 3)
 	}
 
-	_, err := qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("-T_Ut").All(&map_r)
+	var err error
+	if page_z == 9999 {
+		// 获取全部
+		_, err = qs.SetCond((*orm2.Condition)(cond1)).OrderBy("-T_Ut").All(&map_r)
+	} else {
+		_, err = qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond1)).OrderBy("-T_Ut").All(&map_r)
+	}
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 		return
 	}
+
 	cnt, err = qs.SetCond((*orm2.Condition)(cond1)).Count()
 	if err != nil {
 		logs.Error(lib.FuncName(), err)