瀏覽代碼

FIX:报警处理

zoie 3 月之前
父節點
當前提交
7959cb7776
共有 1 個文件被更改,包括 16 次插入20 次删除
  1. 16 20
      controllers/Warning.go

+ 16 - 20
controllers/Warning.go

@@ -560,7 +560,7 @@ func (c *DeviceController) DeviceWarning_Post() {
 		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 && err.Error() != "<QuerySeter> no row found" {
+		if err != nil && err.Error() != "<QuerySeter> no row found"{
 			c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
 			c.ServeJSON()
 			return
@@ -574,29 +574,25 @@ func (c *DeviceController) DeviceWarning_Post() {
 			return
 		}
 
-		if !conf.UseNewWarningQuery {
-			warning = Warning.Read_Warning_ById(int64(id))
-			if warning.Id > 0 {
-				warning.T_Text = T_Text
-				warning.T_State = 2
-				warning.UpdateTime = time.Now()
-				if is := Warning.Update_Warning(warning, "T_Text", "T_State", "UpdateTime"); !is {
-					c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
-					c.ServeJSON()
-					return
-				}
+
+		warning = Warning.Read_Warning_ById(int64(id))
+		if warning.Id > 0 {
+			warning.T_Text = T_Text
+			warning.T_State = 2
+			warning.UpdateTime = time.Now()
+			if is := Warning.Update_Warning(warning, "T_Text", "T_State", "UpdateTime"); !is {
+				c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
+				c.ServeJSON()
+				return
 			}
 		}
 
+
 	} else {
 		// 使用新的查询方式后 warning表不做更新
-		if !conf.UseNewWarningQuery {
-			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 = Warning.Read_Warning_ById(int64(id))
+		if warning.Id > 0 {
 			warning.T_Text = T_Text
 			warning.T_State = 2
 			warning.UpdateTime = time.Now()
@@ -608,7 +604,7 @@ func (c *DeviceController) DeviceWarning_Post() {
 		}
 
 		// 同步处理历史数据
-		date := warning.T_Ut
+		date, err := time.Parse("2006-01-02 15:04:05", T_time)
 		T_year, T_month = date.Format("2006"), date.Format("01")
 		Wtab += "_" + T_year + "_" + T_month
 		warningBackups, err := Warning.Read_Warning_ById_Backups(id, T_year, T_month)