From c79081cca0f16191ff65e4fdb1741ee9d49dd56d Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期二, 28 五月 2019 18:03:22 +0800 Subject: [PATCH] BaseInfo --- esutil/EsClient.go | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 54 insertions(+), 3 deletions(-) diff --git a/esutil/EsClient.go b/esutil/EsClient.go index 5fdcfa1..5e7a606 100644 --- a/esutil/EsClient.go +++ b/esutil/EsClient.go @@ -90,12 +90,20 @@ if !exist { return errors.New("picSmUrl is not string"), nil } - //fmt.Println("picSmUrl: ",psm) + if !strings.HasPrefix(psm, "http") { source["picSmUrl"] = picurl + psm } - //videoUrl := getVideoUrl(source) + source["videoNum"] = getVideoUrl(source) + timeFormat := "2019-05-28 15:04:05" + picDateStr, err := time.Parse(timeFormat, source["picDate"].(string)) + if err == nil { + source["picDate"] = picDateStr + } + + baseInfo := getSourceBaseInfo(source) + source["baseInfo"] = baseInfo sources = append(sources, source) } @@ -104,6 +112,49 @@ } else { return nil, dat } +} + +type BaseInfo struct { + TaskId string `json:"taskId"` + TaskName string `json:"taskName"` + LikePer string `json:"likePer"` + TableId string `json:"tableId"` + TableName string `json:"tableName"` + PersonId string `json:"personId"` + PersonPicUrl string `json:"personPicUrl"` + PersonName string `json:"personName"` + Gender string `json:"gender"` + PhoneNum string `json:"phoneNum"` + IDCard string `json:"IDCard"` + MonitorLevel string `json:"monitorLevel"` + Content string `json:"content"` +} + +func getSourceBaseInfo(source map[string]interface{}) (baseInfoJson string) { + sdkType := source["sdkType"].(string) + if sdkType == "浜鸿劯" { + var baseInfo = BaseInfo{ + TaskId:"",//2.0鏂板瓧娈� + TaskName:"",//2.0鏂板瓧娈� + LikePer:source["likePer"].(string), + TableId:"",//2.0鏂板瓧娈� + TableName:source["BaseName"].(string), + PersonId:source["personId"].(string), + PersonName:source["idcard"].(string),//浜哄憳濮撳悕锛屼粠绠$悊骞冲彴鑾峰彇 + PersonPicUrl:source["personPicUrl"].(string), + Gender:source["Gender"].(string), + PhoneNum:"",//鎵嬫満鍙凤紝浠庣鐞嗗钩鍙拌幏鍙� + IDCard:source["idcard"].(string), + MonitorLevel:"",//2.0鏂板瓧娈� + Content:source["content"].(string), + } + bytes, err := json.Marshal(baseInfo) + if err !=nil { + return "" + } + return string(bytes) + } + return "" } func getVideoUrl(source map[string]interface{}) (videoUrl string){ @@ -213,7 +264,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\",\"imgKey\",\"sdkType\",\"ageDescription\",\"indeviceid\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"videoReqNum\"]" + + "\"_source\":[\"baseInfo\",\"Gender\",\"personId\",\"personPicUrl\",\"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) -- Gitblit v1.8.0