| | |
| | | IsWarning int64 `json:"is_warning"`
|
| | | ZhDescClass string `json:"zh_desc_class"`
|
| | | TaskName string `json:"task_name"`
|
| | | WarnTaskName string `json:"warn_task_name"`
|
| | | WarnTaskId string `json:"warn_task_id"`
|
| | | EventLevelName string `json:"event_level_name"`
|
| | | DetectNum int64 `json:"detect_num"`
|
| | | Suggestion string `json:"suggestion"`
|
| | |
| | | TargetInfo []TargetInfo `json:"targetInfo"`
|
| | | FileId string `json:"fileId"` // 数据栈文件id
|
| | | DataSource string `json:"dataSource"` // 数据来源:摄像机, 数据栈
|
| | | DynamicLevel string `json:"dynamic_level"`
|
| | | }
|
| | |
|
| | | type Point struct {
|
| | |
| | | }
|
| | |
|
| | | type TaskOption struct {
|
| | | TaskId int64 `db:"task_id" json:"taskId"`
|
| | | TaskName string `db:"task_name" json:"taskName"`
|
| | | EventLevel int64 `db:"event_level" json:"eventLevel"`
|
| | | TaskId int64 `db:"task_id" json:"taskId"`
|
| | | TaskName string `db:"task_name" json:"taskName"`
|
| | | EventLevel int64 `db:"event_level" json:"eventLevel"`
|
| | | EventLevelName string `db:"event_level_name" json:"eventLevelName"`
|
| | | }
|
| | |
|
| | | type CheckOption struct {
|
| | |
| | | case "warn_task_id":
|
| | | WarnColumn := field.(*entity.ColumnVarChar).Data()
|
| | | if len(WarnColumn) > 0 {
|
| | | record.WarnTaskName = WarnColumn[i]
|
| | | record.WarnTaskId = WarnColumn[i]
|
| | | }
|
| | | case "event_level_name":
|
| | | EVColumn := field.(*entity.ColumnVarChar).Data()
|
| | |
| | |
|
| | | // 获取事件
|
| | | func GetEventByIds(ids []int64) (items []DictOption, err error) {
|
| | | placeholders := make([]string, len(ids))
|
| | | args := make([]interface{}, len(ids))
|
| | | // 动态生成 UNION ALL 子查询
|
| | | unionAllParts := make([]string, len(ids))
|
| | | for i, id := range ids {
|
| | | placeholders[i] = "?"
|
| | | args[i] = id
|
| | | unionAllParts[i] = fmt.Sprintf("SELECT %d AS dict_id", id)
|
| | | }
|
| | | sqlStr := `select dict_id,dict_name,dict_value from mal_dict_type where dict_id in (` + strings.Join(placeholders, ",") + `)`
|
| | | if err := db.Raw(sqlStr, args...).Scan(&items).Error; err != nil {
|
| | |
|
| | | // 拼接 UNION ALL 子查询
|
| | | unionAllQuery := strings.Join(unionAllParts, " UNION ALL ")
|
| | |
|
| | | // 拼接最终 SQL 查询
|
| | | sqlStr := fmt.Sprintf(`
|
| | | SELECT t.dict_id, t.dict_name, t.dict_value
|
| | | FROM mal_dict_type t
|
| | | JOIN (
|
| | | %s
|
| | | ) AS input_list
|
| | | ON t.dict_id = input_list.dict_id;`, unionAllQuery)
|
| | |
|
| | | if err := db.Raw(sqlStr).Scan(&items).Error; err != nil {
|
| | | return nil, err
|
| | | }
|
| | |
|