| | |
| | | source["picSmUrl"] = picurl + psm |
| | | } |
| | | |
| | | prace, exist := source["Race"] |
| | | if exist { |
| | | source["race"] = prace |
| | | } |
| | | |
| | | pGender, exist := source["Gender"] |
| | | if exist { |
| | | source["gender"] = pGender |
| | | } |
| | | |
| | | source["ageDescription"] = getAgeDesc(source["Age"]) |
| | | |
| | | source["videoNum"] = getVideoUrl(source) |
| | | timeFormat := "2019-05-28 15:04:05" |
| | | picDateStr, err := time.Parse(timeFormat, source["picDate"].(string)) |
| | | picDate := source["picDate"].(string) |
| | | lastIdx := strings.LastIndex(picDate,":") |
| | | picDateStr := picDate[:lastIdx] |
| | | if err == nil { |
| | | source["picDate"] = picDateStr |
| | | } |
| | |
| | | } else { |
| | | return nil, dat |
| | | } |
| | | } |
| | | |
| | | func getAgeDesc(age interface{})(ageDesc string) { |
| | | if age !=nil { |
| | | ageInt := age.(float64) |
| | | if ageInt >0 && ageInt<7 { |
| | | ageDesc = "童年" |
| | | } else if ageInt >=7 && ageInt<18 { |
| | | ageDesc = "少年" |
| | | } else if ageInt >=18 && ageInt<40 { |
| | | ageDesc = "青年" |
| | | } else if ageInt >=40 && ageInt<65 { |
| | | ageDesc = "中年" |
| | | } else if ageInt >=65 { |
| | | ageDesc = "老年" |
| | | } else { |
| | | ageDesc = "" |
| | | } |
| | | } |
| | | return ageDesc |
| | | } |
| | | |
| | | type BaseInfo struct { |
| | |
| | | Content string `json:"content"` |
| | | } |
| | | |
| | | func getSourceBaseInfo(source map[string]interface{}) (baseInfoJson string) { |
| | | func getSourceBaseInfo(source map[string]interface{}) []BaseInfo { |
| | | sdkType := source["sdkType"].(string) |
| | | baseInfoArr := make([]BaseInfo,0) |
| | | if sdkType == "人脸" { |
| | | likePer,baseName,personId,idCard,personPicUrl,gender,content :="","","","","","","" |
| | | if source["likePer"] !=nil { |
| | | likePer = source["likePer"].(string) |
| | | } |
| | | if source["BaseName"] !=nil { |
| | | baseName = source["BaseName"].(string) |
| | | } |
| | | if source["personId"] !=nil { |
| | | personId = source["personId"].(string) |
| | | } |
| | | if source["idcard"] !=nil { |
| | | idCard = source["idcard"].(string) |
| | | } |
| | | if source["personPicUrl"] !=nil { |
| | | personPicUrl = source["personPicUrl"].(string) |
| | | } |
| | | if source["Gender"] !=nil { |
| | | gender = source["Gender"].(string) |
| | | } |
| | | if source["content"] !=nil { |
| | | content = source["content"].(string) |
| | | } |
| | | var baseInfo = BaseInfo{ |
| | | TaskId:"",//2.0新字段 |
| | | TaskName:"",//2.0新字段 |
| | | LikePer:source["likePer"].(string), |
| | | LikePer:likePer, |
| | | TableId:"",//2.0新字段 |
| | | TableName:source["BaseName"].(string), |
| | | PersonId:source["personId"].(string), |
| | | PersonName:source["idcard"].(string),//人员姓名,从管理平台获取 |
| | | PersonPicUrl:source["personPicUrl"].(string), |
| | | Gender:source["Gender"].(string), |
| | | TableName:baseName, |
| | | PersonId:personId, |
| | | PersonName:idCard,//人员姓名,从管理平台获取 |
| | | PersonPicUrl:personPicUrl, |
| | | Gender:gender, |
| | | PhoneNum:"",//手机号,从管理平台获取 |
| | | IDCard:source["idcard"].(string), |
| | | IDCard:idCard, |
| | | MonitorLevel:"",//2.0新字段 |
| | | Content:source["content"].(string), |
| | | Content:content, |
| | | } |
| | | bytes, err := json.Marshal(baseInfo) |
| | | if err !=nil { |
| | | return "" |
| | | } |
| | | return string(bytes) |
| | | |
| | | baseInfoArr = append(baseInfoArr, baseInfo) |
| | | //bytes, err := json.Marshal(baseInfoArr) |
| | | //if err !=nil { |
| | | // return "" |
| | | //} |
| | | } |
| | | return "" |
| | | return baseInfoArr |
| | | } |
| | | |
| | | func getVideoUrl(source map[string]interface{}) (videoUrl string){ |
| | |
| | | seccond := strconv.Itoa(sec) |
| | | |
| | | prama := "{\"query\":{\"bool\":{\"filter\":[{\"range\":{\"picDate\":{\"gte\":\"now+8h-" + seccond + "s\",\"lt\":\"now+8h\"}}}]}},\"size\":\"1000\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"_source\":[\"baseInfo\",\"Gender\",\"personId\",\"personPicUrl\",\"indeviceName\",\"imgKey\",\"sdkType\",\"ageDescription\",\"indeviceid\",\"content\",\"Id\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"Race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"idcard\",\"videoIp\",\"videoReqNum\"]" + |
| | | "\"_source\":[\"baseInfo\",\"Gender\",\"BaseName\",\"Age\",\"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) |
| | | |