| | |
| | | Ids []string `json:"ids"` |
| | | VideoIds []string `json:"treeNodes"` |
| | | TaskIds []int64 `json:"taskIds` |
| | | TaskName []string `json:"taskName"` |
| | | Warning int64 `json:"warning` |
| | | Page int64 `json:"page"` |
| | | PageSize int64 `json:"pageSize"` |
| | |
| | | pageSize := info.PageSize |
| | | idsStr := info.Ids |
| | | TaskIds := info.TaskIds |
| | | TaskName := info.TaskName |
| | | videoIdStr := info.VideoIds |
| | | Warning := info.Warning |
| | | |
| | |
| | | filter += fmt.Sprintf(" and array_contains(task_id, %d)", TaskIds[0]) |
| | | } |
| | | |
| | | //根据任务名称 |
| | | if len(TaskName) > 0 { |
| | | quotedNames := make([]string, len(TaskName)) |
| | | for i, name := range TaskName { |
| | | quotedNames[i] = "'" + name + "'" // 每个元素加单引号 |
| | | } |
| | | filter += fmt.Sprintf(" and %s in [%s]", "task_name", strings.Join(quotedNames, ",")) |
| | | } else { |
| | | if Warning > 0 { |
| | | return &bhomeclient.Reply{Success: true, Msg: "获取成功", Data: nil} |
| | | } |
| | | } |
| | | |
| | | //是否预警 |
| | | if Warning > 0 { |
| | | filter += fmt.Sprintf(" and is_waning == %d", Warning) |
| | |
| | | // } |
| | | var ids []string = []string{} |
| | | ids = append(ids, cE.Id) |
| | | cri.AllTasks, _ = models.GetListTask(ids) |
| | | tasks, _ := models.GetListTask(ids) |
| | | //rules |
| | | ruleMap := models.GetAllRule() |
| | | |
| | | cri.AllTasks = []commonModel.TaskM{} |
| | | for _, item := range tasks { |
| | | temp := &commonModel.TaskM{ |
| | | TaskName: item.TaskName, |
| | | EventName: item.EventName, |
| | | TaskDescription: ruleMap[item.TaskId], |
| | | } |
| | | cri.AllTasks = append(cri.AllTasks, *temp) |
| | | } |
| | | |
| | | //处理摄像机的状态 |
| | | if cE.RunType == commonModel.TYPE_RUNTYPE_POLL || cE.RunType == commonModel.TYPE_RUNTYPE_REALTIME { |
| | |
| | | return |
| | | } |
| | | |
| | | func GetAllRule() map[int64]string { |
| | | var items []models.RuleOption |
| | | sqlStr := ` |
| | | SELECT a.file_name,a.rule_id,b.task_id |
| | | FROM mal_warning_rule a |
| | | LEFT JOIN mal_task_rule_link b ON a.rule_id = b.rule_id |
| | | WHERE task_id>0 |
| | | group BY a.rule_id |
| | | ` |
| | | if err := db2.Raw(sqlStr).Scan(&items).Error; err != nil { |
| | | fmt.Println(err.Error()) |
| | | return nil |
| | | } |
| | | |
| | | ruleMap := make(map[int64]string) |
| | | for _, d2 := range items { |
| | | if d2.TaskId > 0 { |
| | | ruleMap[d2.TaskId] = d2.FileName |
| | | } |
| | | } |
| | | return ruleMap |
| | | } |
| | | |
| | | type VideoLink struct { |
| | | ID int `gorm:"column:id" json:"id"` |
| | | VideoId string `gorm:"column:video_id" json:"videoId"` |