| | |
| | | return feature, nil |
| | | } |
| | | |
| | | //根据目标id追加跟踪信息 |
| | | func AppendTargetInfo(id string,targetInfo string, indexName string, serverIp string, serverPort string)(string,error){ |
| | | if targetInfo == ""{ |
| | | return "",errors.New("append data is nil") |
| | | } |
| | | var info interface{} |
| | | url := "http://" + serverIp + ":" + serverPort + "/" + indexName + "/_update_by_query?refresh=true" |
| | | jsonDSL := `{ |
| | | "query": { |
| | | "term":{ |
| | | "id":"`+id+`" |
| | | } |
| | | }, |
| | | "script": { |
| | | "lang": "painless", |
| | | "inline": "ctx._source.linkTagInfo.add(params.newparam)", |
| | | "params": { |
| | | "newparam": `+targetInfo+` |
| | | } |
| | | } |
| | | }` |
| | | fmt.Println(jsonDSL) |
| | | buf, err := EsReq("POST", url, []byte(jsonDSL)) |
| | | if err != nil { |
| | | return "",err |
| | | } |
| | | json.Unmarshal(buf,&info) |
| | | out, ok := info.(map[string]interface{}) |
| | | fmt.Println(out) |
| | | if !ok { |
| | | return "",errors.New("http response interface can not change map[string]interface{}") |
| | | } |
| | | middle, ok := out["updated"].(float64) |
| | | if !ok { |
| | | return "",errors.New("first updated change error!") |
| | | } |
| | | mes := "" |
| | | if middle == 1 { |
| | | mes = "追加成功" |
| | | } |
| | | if middle == 0 { |
| | | mes = "已经追加" |
| | | } |
| | | return mes,nil |
| | | |
| | | } |
| | | |
| | | //根据抓拍人员id更新(videourl)摄像机地址 |
| | | func UpdateVideourlById(id string, videoUrl string, indexName string, serverIp string, serverPort string, command int) (statu int) { |
| | | |