| | |
| | | } |
| | | |
| | | // 根据抓拍人员id查询抓拍人员信息 |
| | | func Videopersonsinfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.Videopersons, error) { |
| | | var videopersonsInfo []protomsg.Videopersons |
| | | func AIOceaninfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.AIOcean, error) { |
| | | var aIOceanInfo []protomsg.AIOcean |
| | | videopersonsPersonId := strings.Replace(strings.Trim(fmt.Sprint(id), "[]"), " ", "\",\"", -1) |
| | | var dbinfoRequest = ` |
| | | { |
| | |
| | | ` |
| | | buf, err := EsReq("POST", "http://"+serverIp+":"+serverPort+"/"+indexName+"/_search",[]byte(dbinfoRequest)) |
| | | if err != nil { |
| | | return videopersonsInfo, err |
| | | return aIOceanInfo, err |
| | | } |
| | | |
| | | sources, err := Sourcelist(buf) |
| | | if err != nil { |
| | | return videopersonsInfo , err |
| | | return aIOceanInfo , err |
| | | } |
| | | |
| | | videoperson := Videopersonsbyid(sources) |
| | | println(videoperson) |
| | | return videoperson,nil |
| | | aIOcean := AIOceanAnalysis(sources) |
| | | println(aIOcean) |
| | | return aIOcean,nil |
| | | } |
| | | |
| | | // 根据底库人员id查询底库人员信息 |
| | |
| | | } |
| | | |
| | | //初始化实时抓拍 |
| | | func InitRealTimeCapture(serverIp string, serverPort string, indexName string, isAlarm bool ,quantity int) ([]protomsg.Videopersons, error){ |
| | | var videopersonsInfo []protomsg.Videopersons |
| | | func InitRealTimeCapture(serverIp string, serverPort string, indexName string, isAlarm bool ,quantity int) ([]protomsg.AIOcean, error){ |
| | | var aIOceanInfo []protomsg.AIOcean |
| | | url := "http://" + serverIp + ":" + serverPort + |
| | | "/" + indexName + "/_search" |
| | | queryStr := "" |
| | |
| | | "filter":[ |
| | | { |
| | | "term":{ |
| | | "isAlarm":1 |
| | | "isAlarm":true |
| | | } |
| | | } |
| | | ] |
| | |
| | | "size":`+strconv.Itoa(quantity)+`, |
| | | `+queryStr+` |
| | | "sort":[{"picDate":{"order":"desc"}}], |
| | | "_source": ["baseInfo", "alarmRules", "sex", "analyServerName", "sdkName", "ageDescription", "content", "id", "cameraAddr", "picMaxUrl", "picDate", "race", "videoUrl", "picSmUrl", "taskName", "personIsHub", "isAlarm", "analyServerIp", "cameraId"] |
| | | "_source": {"includes":[],"excludes":["*.feature"]} |
| | | }` |
| | | buf, err := EsReq("POST", url, []byte(DSLJson)) |
| | | if err != nil { |
| | | return videopersonsInfo, err |
| | | return aIOceanInfo, err |
| | | } |
| | | |
| | | sources, err := Sourcelist(buf) |
| | | if err != nil { |
| | | return videopersonsInfo, err |
| | | return aIOceanInfo, err |
| | | } |
| | | |
| | | videoperson := Videopersonsbyid(sources) |
| | | aIOcean := AIOceanAnalysis(sources) |
| | | //fmt.Println(len(videoperson)) |
| | | return videoperson, nil |
| | | return aIOcean, nil |
| | | } |
| | | |
| | | //实时抓拍 |
| | | func RealTimeCapture(serverIp string, serverPort string, indexName string, isAlarm bool ) ([]protomsg.Videopersons, error){ |
| | | var videopersonsInfo []protomsg.Videopersons |
| | | func RealTimeCapture(serverIp string, serverPort string, indexName string, isAlarm bool ) ([]protomsg.AIOcean, error){ |
| | | var aIOceanInfo []protomsg.AIOcean |
| | | url := "http://" + serverIp + ":" + serverPort + |
| | | "/" + indexName + "/_search" |
| | | queryStr := "" |
| | |
| | | |
| | | buf, err := EsReq("POST", url, []byte(DSLJson)) |
| | | if err != nil { |
| | | return videopersonsInfo, err |
| | | return aIOceanInfo, err |
| | | } |
| | | |
| | | sources, err := Sourcelist(buf) |
| | | if err != nil { |
| | | return videopersonsInfo, err |
| | | return aIOceanInfo, err |
| | | } |
| | | |
| | | videoperson := Videopersonsbyid(sources) |
| | | fmt.Println(len(videoperson)) |
| | | return videoperson, nil |
| | | aIOcean := AIOceanAnalysis(sources) |
| | | fmt.Println(len(aIOcean)) |
| | | return aIOcean, nil |
| | | } |
| | | |
| | | //综合统计 |
| | | func StatisticsComprehensive(serverIp string, serverPort string, indexName string, isAlarm bool) (total int, err error){ |
| | | isAlarmStr := "" |
| | | if isAlarm == true { |
| | | isAlarmStr = `,{"term":{"isAlarm":1}}` |
| | | isAlarmStr = `,{"term":{"isAlarm":true}}` |
| | | } |
| | | url := "http://" + serverIp + ":" + serverPort + |
| | | "/" + indexName + "/_search" |
| | |
| | | } |
| | | }, |
| | | "aggs":{ |
| | | "sdkName_status":{ |
| | | "sdkId_status":{ |
| | | "terms":{ |
| | | "field":"taskName.raw" |
| | | "field":"taskId" |
| | | } |
| | | } |
| | | } |
| | |
| | | if !ok { |
| | | return nil, errors.New("first hits change error!") |
| | | } |
| | | sdkName_status, ok := middle["sdkName_status"].(map[string]interface{}) |
| | | sdkName_status, ok := middle["sdkId_status"].(map[string]interface{}) |
| | | if !ok { |
| | | return nil, errors.New("first hits change error!") |
| | | } |
| | |
| | | fmt.Println("change to source error!") |
| | | continue |
| | | } |
| | | sdkName := tmpbuf["key"].(string) |
| | | sdkId := tmpbuf["key"].(string) |
| | | count := int(tmpbuf["doc_count"].(float64)) |
| | | source["name"] = sdkName |
| | | source["id"] = sdkId |
| | | source["value"] = count |
| | | sources = append(sources, source) |
| | | } |
| | |
| | | return sources,nil |
| | | } |
| | | |
| | | |
| | | //聚合任务列表,taskId+taskName |
| | | func AggregateTaskList(serverIp string, serverPort string, indexName string, analyServerId string) (sources []map[string]interface{},err error){ |
| | | url := "http://" + serverIp + ":" + serverPort + |