From c3a93b2e243a50e06506b2bc34df19f00e126f69 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@qq.com> Date: 星期二, 28 五月 2019 16:28:24 +0800 Subject: [PATCH] get videoNum url from 241-244 --- /dev/null | 0 go.sum | 22 ++--------- androidAlarmServer | 0 go.mod | 6 +-- esutil/EsClient.go | 63 +++++++++++++++++++------------ 5 files changed, 44 insertions(+), 47 deletions(-) diff --git a/andriodAlarmServer b/andriodAlarmServer deleted file mode 100755 index dd0badb..0000000 --- a/andriodAlarmServer +++ /dev/null Binary files differ diff --git a/androidAlarmServer b/androidAlarmServer new file mode 100755 index 0000000..77cd5a9 --- /dev/null +++ b/androidAlarmServer Binary files differ diff --git a/esutil/EsClient.go b/esutil/EsClient.go index ef5c658..5fdcfa1 100644 --- a/esutil/EsClient.go +++ b/esutil/EsClient.go @@ -76,6 +76,7 @@ } pmax, exist := source["picMaxUrl"].(string) + //fmt.Println("picMaxUrl: ",pmax) if !exist { return errors.New("picMaxurl is not string"), nil } @@ -89,7 +90,7 @@ if !exist { return errors.New("picSmUrl is not string"), nil } - + //fmt.Println("picSmUrl: ",psm) if !strings.HasPrefix(psm, "http") { source["picSmUrl"] = picurl + psm } @@ -105,45 +106,57 @@ } } -func getVideoUrl(source map[string]interface{}) (videoUrl string) { +func getVideoUrl(source map[string]interface{}) (videoUrl string){ imgKey := source["imgKey"].(string) - picDte := source["picDate"].(string) //鎶撴媿鏃ユ湡 - cameraId := source["videoReqNum"].(string) //鎽勫儚鏈篿d - indeviceId := source["indeviceid"].(string) //鍒嗘瀽璁惧id + picDte := source["picDate"].(string)//鎶撴媿鏃ユ湡 + cameraId := source["videoReqNum"].(string)//鎽勫儚鏈篿d + indeviceId := source["indeviceid"].(string)//鍒嗘瀽璁惧id + deviceMap := make(map[string]string,0) + deviceMap["DSVAD010120181119"] = "http://172.17.50.241:11111/getRecordVideoPath" + deviceMap["DSVAD010220181119"] = "http://172.17.50.242:11111/getRecordVideoPath" + deviceMap["DSVAD010320181119"] = "http://172.17.50.243:11111/getRecordVideoPath" + deviceMap["DSVAD010420181119"] = "http://172.17.50.244:11111/getRecordVideoPath" - var deviceMap map[string]string - deviceMap["DSVAD010120181119"] = "http://58.118.225.79:41241/ManCarAnaly/perVideoPic/uploadRtnVideo" - deviceMap["DSVAD010220181119"] = "http://58.118.225.79:41242/ManCarAnaly/perVideoPic/uploadRtnVideo" - deviceMap["DSVAD010320181119"] = "http://58.118.225.79:41243/ManCarAnaly/perVideoPic/uploadRtnVideo" - deviceMap["DSVAD010420181119"] = "http://58.118.225.79:41244/ManCarAnaly/perVideoPic/uploadRtnVideo" + ngxMap := make(map[string]string,0) + ngxMap["DSVAD010120181119"] = "http://58.118.225.79:44180/videosource" + ngxMap["DSVAD010220181119"] = "http://58.118.225.79:44280/videosource" + ngxMap["DSVAD010320181119"] = "http://58.118.225.79:44380/videosource" + ngxMap["DSVAD010420181119"] = "http://58.118.225.79:44480/videosource" + reqUrl := deviceMap[indeviceId] - var paramMap map[string]interface{} + paramMap := make(map[string]interface{},0) paramMap["imgKey"] = imgKey paramMap["picDate"] = picDte - paramMap["videoPath"] = cameraId + paramMap["videoNum"] = cameraId - respBytes, err := doPostRequest(reqUrl, "application/x-www-form-urlencoded", paramMap, nil, nil) - if err != nil { + respBytes, err := doPostRequest(reqUrl, "application/json", paramMap, nil, nil) + if err !=nil{ return "" } var resp RespVideo err = json.Unmarshal(respBytes, &resp) - if err != nil { + if err !=nil { return "" } - return resp.VideoPath + filePath := resp.FilePath + + if !strings.Contains(filePath, "/cut"){ + return "" + } else { + strArr := strings.Split(filePath, "/cut") + ngxUrl := ngxMap[indeviceId] + if ngxUrl !="" && len(strArr) >0 { + return ngxUrl + strArr[1] + } + } + + return "" } -type RespVideo struct { - Code int32 `json:"code"` - ErrorStr string `json:"errorStr"` - Msg string `json:"msg"` - Resp interface{} - Status string `json:"status"` - VideoPath string `json:"videoPath"` +type RespVideo struct{ + FilePath string `json:"file_path"` } - func doPostRequest(url string, contentType string, body map[string]interface{}, params map[string]string, headers map[string]string) ([]byte, error) { var resultBytes []byte var bodyJson []byte @@ -200,7 +213,7 @@ seccond := strconv.Itoa(sec) prama := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"personIsHub\":\"1\"}},{\"range\":{\"picDate\":{\"gte\":\"now+8h-" + seccond + "s\",\"lt\":\"now+8h\"}}}]}},\"size\":\"1000\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + - "\"_source\":[\"baseInfo\",\"gender\",\"indeviceName\",\"imageKey\",\"sdkType\",\"ageDescription\",\"indeviceid\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"videoReqNum\"]" + + "\"_source\":[\"baseInfo\",\"gender\",\"indeviceName\",\"imgKey\",\"sdkType\",\"ageDescription\",\"indeviceid\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"videoReqNum\"]" + "}" err, tokenRes := GetEsDataReq(url, prama, picurl, true) diff --git a/go.mod b/go.mod index f761513..cccc624 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,9 @@ go 1.12 require ( - github.com/jonboulle/clockwork v0.1.0 // indirect github.com/lestrrat-go/file-rotatelogs v2.2.0+incompatible github.com/lestrrat-go/strftime v0.0.0-20180821113735-8b31f9c59b0f // indirect - github.com/pkg/errors v0.8.1 + github.com/pkg/errors v0.8.1 // indirect github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 - github.com/rs/zerolog v1.14.3 - github.com/sirupsen/logrus v1.4.1 + github.com/sirupsen/logrus v1.4.2 ) diff --git a/go.sum b/go.sum index 7ad115e..5f3a5cc 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,4 @@ -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/lestrrat-go/file-rotatelogs v2.2.0+incompatible h1:eXEwY0f2h6mcobdAxm4VRSWds4tqmlLdUqxu8ybiEEA= github.com/lestrrat-go/file-rotatelogs v2.2.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA= @@ -12,20 +9,9 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo= github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/zerolog v1.14.3 h1:4EGfSkR2hJDB0s3oFfrlPqjU1e4WLncergLil3nEKW0= -github.com/rs/zerolog v1.14.3/go.mod h1:3WXPzbXEEliJ+a6UFE4vhIxV8qR1EML6ngzP9ug4eYg= -github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/test b/test deleted file mode 100755 index dd0badb..0000000 --- a/test +++ /dev/null Binary files differ -- Gitblit v1.8.0