tcp server 用于给andriod 客户端定时发送消息
liuxiaolong
2019-05-28 c3a93b2e243a50e06506b2bc34df19f00e126f69
get videoNum url from 241-244
2个文件已删除
1个文件已添加
3个文件已修改
91 ■■■■ 已修改文件
andriodAlarmServer 补丁 | 查看 | 原始文档 | blame | 历史
androidAlarmServer 补丁 | 查看 | 原始文档 | blame | 历史
esutil/EsClient.go 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.mod 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.sum 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test 补丁 | 查看 | 原始文档 | blame | 历史
andriodAlarmServer
Binary files differ
androidAlarmServer
Binary files differ
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)  //摄像机id
    indeviceId := source["indeviceid"].(string) //分析设备id
    picDte := source["picDate"].(string)//抓拍日期
    cameraId := source["videoReqNum"].(string)//摄像机id
    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)
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
)
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=
test
Binary files differ