Przeglądaj źródła

记录数据多数据问题1

bzd_lkh 1 miesiąc temu
rodzic
commit
7b75535cfd
2 zmienionych plików z 9 dodań i 7 usunięć
  1. 8 7
      MqttServer/V3MqttHandle.go
  2. 1 0
      models/Device/DeviceData.go

+ 8 - 7
MqttServer/V3MqttHandle.go

@@ -182,6 +182,8 @@ func AsyncFuncV3(r_Device *Device.Device, Ms_project Ms2m_Project, msg []byte) {
 				// 计算周期时间
 				DeviceData_t.T_time = lib.PeriodTime(DeviceData_t.T_time, DeviceParameter_r.T_saveT/60)
 				logs.Println("计算周期时间:", UT.Format("2006-01-02 15:04:05"), "=>", DeviceData_t.T_time.Format("2006-01-02 15:04:05"), "保存间隔:", DeviceParameter_r.T_saveT)
+			} else {
+				logs.Println("直接保存数据,SN_Redis 获取失败!")
 			}
 
 			if r_, _ := Device.Add_DeviceData(r_Device.T_sn, DeviceSensor_r.T_id, DeviceData_t, true); r_ {
@@ -332,25 +334,24 @@ func AsyncFuncV3(r_Device *Device.Device, Ms_project Ms2m_Project, msg []byte) {
 			// 11	湿度超下限预警
 			// 12	湿度预警恢复正常
 
-
 			// 首次时间缓存,防止乱传数据
 			Warning_r.T_fUt = Warning.Redis_WarningStart(Warning_r)
 
 			// 补丁
 			if Warning_r.T_tp == 3 || Warning_r.T_tp == 6 || Warning_r.T_tp == 9 || Warning_r.T_tp == 12 { // 恢复
-				Ws_time,Ws_is := Warning.Redis_WarningStart_DelK(Warning_r)
+				Ws_time, Ws_is := Warning.Redis_WarningStart_DelK(Warning_r)
 				if !Ws_is {
 					logs.Println("之前没有报警信息,跳过保存报警!")
 					continue
-				}else {
-					logs.Println("之前发送报警信息,首次报警时间:",Ws_time.Format("2006-01-02 15:04:05"))
+				} else {
+					logs.Println("之前发送报警信息,首次报警时间:", Ws_time.Format("2006-01-02 15:04:05"))
 				}
 			} else {
 				logs_s := "报警时间首次时间:" + Warning_r.T_fUt.Format("2006-01-02 15:04:05") + ",报警时间:" + Warning_r.T_Ut.Format("2006-01-02 15:04:05")
-				Warning_r.T_Ut = lib.PeriodWTime(Warning_r.T_fUt,Warning_r.T_Ut,2)
-				logs.Println("报警时间计算处理:", logs_s,"=>",Warning_r.T_Ut.Format("2006-01-02 15:04:05"))
+				Warning_r.T_Ut = lib.PeriodWTime(Warning_r.T_fUt, Warning_r.T_Ut, 2)
+				logs.Println("报警时间计算处理:", logs_s, "=>", Warning_r.T_Ut.Format("2006-01-02 15:04:05"))
 				if Warning.Redis_WarningTimeListIs(Warning_r) {
-					logs.Println("报警时间已经存在,跳过!:",Warning_r.T_Ut.Format("2006-01-02 15:04:05"))
+					logs.Println("报警时间已经存在,跳过!:", Warning_r.T_Ut.Format("2006-01-02 15:04:05"))
 					continue
 				}
 			}

+ 1 - 0
models/Device/DeviceData.go

@@ -100,6 +100,7 @@ func RedisDeviceData_Del(T_sn string, T_id int) {
 	key := T_sn + "|" + strconv.Itoa(T_id)
 	if redis_DeviceData.IsExist(key) {
 		redis_DeviceData.Delete(key)
+		logs.Println("RedisDeviceData_Del 清除标志位:", key)
 	}
 }