| | |
| | | package models |
| | | |
| | | import ( |
| | | "basic.com/valib/logger.git" |
| | | "fmt" |
| | | "strconv" |
| | | "strings" |
| | | "vamicro/config" |
| | | |
| | | "basic.com/valib/logger.git" |
| | | ) |
| | | |
| | | const ( |
| | |
| | | Camera_Status_Doing = 2 //处理中 |
| | | Camera_Status_Other = -1 //其他情况 |
| | | ) |
| | | |
| | | // 智查任务 |
| | | type Task struct { |
| | | TaskId int64 `db:"task_id" json:"taskId"` |
| | | TaskName string `db:"task_name" json:"taskName"` |
| | | } |
| | | |
| | | type Camera struct { |
| | | Id string `gorm:"primary_key;column:id;type:varchar(100);unique;" json:"id"` |
| | |
| | | Rtsp string `json:"rtsp"` |
| | | } |
| | | |
| | | func (camera *Camera) GetIdNameMap() (map[string]string) { |
| | | func (camera *Camera) GetIdNameMap() map[string]string { |
| | | cameraEMap :=make(map[string]string,0) |
| | | allCams, err := camera.FindAll() |
| | | if err ==nil && allCams !=nil && len(allCams) >0 { |
| | |
| | | return dbdel.RowsAffected, nil |
| | | |
| | | } |
| | | |
| | | // 查询列表数据 |
| | | func GetListTask(ids []string) (items []Task, err error) { |
| | | //idList := strings.Join(ids, ",") |
| | | idList := "'" + strings.Join(ids, "','") + "'" |
| | | // 主查询SQL |
| | | //sqlStr := `select c.task_id, c.task_name from mal_task_video_link a left join mal_smart_task c on a.task_id = c.task_id where a.video_id in(?) ORDER BY a.task_id desc` |
| | | sqlStr := fmt.Sprintf(` |
| | | SELECT c.task_id, c.task_name |
| | | FROM mal_task_video_link a |
| | | LEFT JOIN mal_smart_task c ON a.task_id = c.task_id |
| | | WHERE a.video_id IN (%s) |
| | | ORDER BY a.task_id DESC |
| | | `, idList) |
| | | if err := db.Raw(sqlStr).Scan(&items).Error; err != nil { |
| | | fmt.Println(err.Error()) |
| | | return nil, err |
| | | } |
| | | return |
| | | } |