Forráskód Böngészése

报警处理修改----最新代码

huangyan 1 hónapja
szülő
commit
8596358579

+ 3 - 3
controllers/DeviceController.go

@@ -791,9 +791,9 @@ func (c *DeviceController) DeviceWarning_Del() {
 	}
 
 	Id, _ := c.GetInt("Id")
-
-	if Id > 1000 {
-		Warning.Delete_Warning(admin_r.T_pid, Id)
+	Ut := c.GetString("Ut")
+	if Id > 1000 && len(Ut) > 0 {
+		Warning.Delete_Warning(admin_r.T_pid, Id, Ut)
 	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}

+ 1 - 1
lastupdate.tmp

@@ -1 +1 @@
-{"E:\\WebstormProjects\\ColdP_server\\controllers":1737603276796091100}
+{"E:\\WebstormProjects\\ColdP_server\\controllers":1744938641913989300}

+ 23 - 0
logs/logx/logx.log

@@ -629,3 +629,26 @@
 2025/01/23 13:22:41.355 [E] [Mqtt.go:536]  ColdP_server/controllers/MqttServer.FindClodpServerBySnAndId <QuerySeter> no row found
 2025/01/23 13:22:41.362 [E] [Mqtt.go:536]  ColdP_server/controllers/MqttServer.FindClodpServerBySnAndId <QuerySeter> no row found
 2025/01/24 11:33:19.691 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/17 16:22:49.436 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/17 16:24:14.203 [D] [DeviceData.go:177]  SELECT t_id,t_sp,t_t,t_rh,t_site,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time,t_time AS t_time1 FROM z_device_data_2024332675927850 WHERE t_id = 1 ORDER BY t_time1 DESC LIMIT 0,1
+2025/04/17 16:24:14.246 [D] [DeviceData.go:177]  SELECT t_id,t_sp,t_t,t_rh,t_site,DATE_FORMAT(t_time,'%Y-%m-%d %H:%i:%s') AS t_time,t_time AS t_time1 FROM z_device_data_2024462674079198 WHERE t_id = 1 ORDER BY t_time1 DESC LIMIT 0,1
+2025/04/17 16:29:25.136 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/17 16:33:42.874 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/17 16:36:26.453 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/17 16:54:16.891 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/17 17:03:37.616 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/17 17:26:39.683 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:09:09.233 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:12:43.956 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:13:28.979 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:17:23.846 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:21:20.775 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:21:48.734 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:23:12.737 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:29:19.473 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 09:33:11.485 [I] [WarningType.go:193]  =========== 初始化报警类型 =========
+2025/04/18 10:34:33.544 [E] [Mqtt.go:452]  查询参数失败
+2025/04/18 10:34:33.559 [E] [WarningType.go:202]  ColdP_server/models/Warning.Read_WarningType_All_Maps dial tcp 192.168.0.88:3306: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
+2025/04/18 12:21:59.120 [E] [Mqtt.go:452]  查询参数失败
+2025/04/18 12:51:00.019 [E] [Mqtt.go:452]  查询参数失败
+2025/04/18 13:33:54.137 [E] [Mqtt.go:452]  查询参数失败

+ 14 - 6
models/Warning/Warning.go

@@ -266,19 +266,24 @@ func Update_Warning(r Warning, cols ...string) bool {
 }
 
 // 删除
-func Delete_Warning(t_pid, Id int) (err error) {
+func Delete_Warning(t_pid, Id int, warninTime string) (err error) {
 	fmt.Println("Delete_Warning  : Id", Id)
 
 	o := orm.NewOrm()
+	parse, _ := time.Parse("2006-01-02 15:04:05", warninTime)
 
 	o.Raw("UPDATE warning SET t__state = 0 WHERE t_pid = ? AND ID = ?", t_pid, Id).Exec()
+	//o.Raw("DELETE FROM warning  WHERE t_pid = ? AND ID = ?", t_pid, Id).Exec()
+	format := parse.Format("2006_01")
 
 	// 后 一个月
-	dd, _ := time.ParseDuration(fmt.Sprintf("-%dh", 24*30*1))
-	dd1 := time.Now().Add(dd)
-	println(int(dd1.Month()))
-	xx := fmt.Sprintf("%d_%02d", int(dd1.Year()), int(dd1.Month()))
-	o.Raw("UPDATE warning_"+xx+"  SET t__state = 0  WHERE t_pid = ? AND ID = ?", t_pid, Id).Exec()
+	//dd, _ := time.ParseDuration(fmt.Sprintf("-%dh", 24*30*1))
+	//dd1 := time.Now().Add(dd)
+	//println(int(dd1.Month()))
+	//xx := fmt.Sprintf("%d_%02d", int(dd1.Year()), int(dd1.Month()))
+	tablenamew := fmt.Sprintf("warning_%v", format)
+	o.Raw("UPDATE "+tablenamew+"  SET t__state = 0  WHERE t_pid = ? AND ID = ?", t_pid, Id).Exec()
+	//o.Raw("DELETE FROM warning_"+xx+" WHERE t_pid = ? AND ID = ?", t_pid, Id).Exec()
 
 	return
 }
@@ -299,9 +304,12 @@ func Delete_Warning_List(id, ut string, pid int) (err error) {
 	interval := now.Sub(parse)
 	if interval.Hours() > 40*24 {
 		o.Raw("UPDATE warning SET t__state = 0 WHERE t_pid = ? AND ID = ?", pid, atoi).Exec()
+		//o.Raw("DELETE FROM warning  WHERE t_pid = ? AND ID = ?", pid, atoi).Exec()
 	} else {
 		o.Raw("UPDATE "+Wtab+"  SET t__state = 0  WHERE t_pid = ? AND ID = ?", pid, atoi).Exec()
+		//o.Raw("DELETE FROM "+Wtab+"  WHERE t_pid = ? AND ID = ?", pid, atoi).Exec()
 		o.Raw("UPDATE warning SET t__state = 0 WHERE t_pid = ? AND ID = ?", pid, atoi).Exec()
+		//o.Raw("DELETE FROM warning  WHERE t_pid = ? AND ID = ?", pid, atoi).Exec()
 	}
 	return
 }

+ 1 - 1
routers/DeviceRouter.go

@@ -42,7 +42,7 @@ func init() {
 	//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/DeviceWarning_Del", &controllers.DeviceController{}, "*:DeviceWarning_Del") // 删除报警信
 	//根据pid获取sn
 	beego.Router("/Device/DeviceWarning_ALL_SN", &controllers.DeviceController{}, "*:GetDeviceALLSN")
 	//根据sn获取tid