Przeglądaj źródła

ADD:数据批量删除

zoie 4 miesięcy temu
rodzic
commit
eaf1ded530
2 zmienionych plików z 56 dodań i 0 usunięć
  1. 55 0
      controllers/TaskData.go
  2. 1 0
      routers/TaskData.go

+ 55 - 0
controllers/TaskData.go

@@ -2256,6 +2256,61 @@ func (c *TaskDataController) DataGeometricScale() {
 	return
 }
 
+// DataBatchDelete 批量删除
+func (c *TaskDataController) DataBatchDelete() {
+	T_uuid, _ := lib.GetAdminT_Uuid(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	//if !b_ {
+	//	c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
+	//	c.ServeJSON()
+	//	return
+	//}
+
+	StartTime := c.GetString("StartTime")
+	_, ok := lib.TimeStrToTime(StartTime)
+	if !ok {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误!"}
+		c.ServeJSON()
+		return
+	}
+	EndTime := c.GetString("EndTime")
+	_, ok = lib.TimeStrToTime(EndTime)
+	if !ok {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误!"}
+		c.ServeJSON()
+		return
+	}
+
+	SN_List := strings.Split(strings.Trim(c.GetString("SN_List"), "|"), "|")
+
+	T_task_id := c.GetString("T_task_id")
+	Task_r, err := NatsServer.Read_Task(T_task_id)
+	if err != nil {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
+		c.ServeJSON()
+		return
+	}
+	if Task_r.T_collection_state == 2 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: "数据采集中,请稍后!"}
+		c.ServeJSON()
+		return
+	}
+
+	for _, v := range SN_List {
+		sn_id := strings.Split(v, ",")
+		if len(sn_id) != 2 {
+			continue
+		}
+		sn, id_str := sn_id[0], sn_id[1]
+
+		Task.DeleteTaskDataByTimeRange(Task_r.T_task_id, sn, id_str, StartTime, EndTime)
+	}
+	System.Add_UserLogs_T(T_uuid, "批量删除", fmt.Sprintf("批量删除(%s)[%s|%s]", T_task_id, StartTime, EndTime), SN_List)
+
+	c.Data["json"] = lib.JSONS{200, "批量删除操作成功", nil}
+	c.ServeJSON()
+	return
+}
+
 // 存档列表
 func (c *TaskDataController) TaskDataCopy_List() {
 

+ 1 - 0
routers/TaskData.go

@@ -43,6 +43,7 @@ func init() {
 	beego.Router("/TaskData/DataSkewingInterval", &controllers.TaskDataController{}, "*:DataSkewingInterval")             // 数据偏移到给定区间内
 	beego.Router("/TaskData/DataGeometricScale", &controllers.TaskDataController{}, "*:DataGeometricScale")               // 数据等比咧缩放
 	beego.Router("/TaskData/DataRemoveDuplicates", &controllers.TaskDataController{}, "*:DataRemoveDuplicates")           // 数据去重
+	beego.Router("/TaskData/DataBatchDelete", &controllers.TaskDataController{}, "*:DataBatchDelete")                     // 批量删除
 
 	beego.Router("/TaskDataCopy/List", &controllers.TaskDataController{}, "*:TaskDataCopy_List")       // 数据存档列表
 	beego.Router("/TaskDataCopy/Add", &controllers.TaskDataController{}, "*:TaskDataCopy_Add")         // 添加数据存档