| | |
| | | |
| | | if startTime.After(endTime) { |
| | | // 跨越日期的情况 |
| | | //fmt.Println("跨日期",timeStamp, timeStamp.After(startTime), timeStamp.Before(endTime)) |
| | | return timeStamp.After(startTime) || timeStamp.Before(endTime) |
| | | } else { |
| | | // 不跨越日期的情况 |
| | | //fmt.Println("不跨日期",timeStamp, timeStamp.After(startTime), timeStamp.Before(endTime)) |
| | | return timeStamp.After(startTime) && timeStamp.Before(endTime) |
| | | } |
| | | } |
| | |
| | | hits := topHits["hits"].(map[string]interface{}) |
| | | hitsResult := hits["hits"].([]interface{}) |
| | | dataId := make([]string, 0) |
| | | picUrl := "" |
| | | if hitsResult[0].(map[string]interface{})["_source"].(map[string]interface{})["baseInfo"] != nil { |
| | | baseInfo := hitsResult[0].(map[string]interface{})["_source"].(map[string]interface{})["baseInfo"] |
| | | if v, ok := baseInfo.([]interface{}); ok { |
| | | picUrl = v[0].(map[string]interface{})["targetPicUrl"].(string) |
| | | } else if v, ok := baseInfo.(map[string]interface{}); ok { |
| | | picUrl = v["targetPicUrl"].(string) |
| | | } |
| | | } else { |
| | | if hitsResult[0].(map[string]interface{})["_source"].(map[string]interface{})["targetInfo"] != nil { |
| | | picUrl = hitsResult[0].(map[string]interface{})["_source"].(map[string]interface{})["targetInfo"].([]interface{})[0].(map[string]interface{})["picSmUrl"].(string) |
| | | } |
| | | } |
| | | |
| | | //if hitsResult[0].(map[string]interface{})["baseInfo"] != nil { |
| | | // fmt.Println("picUrl1: ", picUrl) |
| | | // picUrl = hitsResult[0].(map[string]interface{})["baseInfo"].([]interface{})[0].(map[string]interface{})["targetPicUrl"].(string) |
| | | //} else { |
| | | // if hitsResult[0].(map[string]interface{})["targetInfo"] != nil { |
| | | // fmt.Println("picUrl2: ", picUrl) |
| | | // picUrl = hitsResult[0].(map[string]interface{})["targetInfo"].([]interface{})[0].(map[string]interface{})["picSmUrl"].(string) |
| | | // } |
| | | //} |
| | | tmpInfo["picUrl"] = picUrl |
| | | for sIndex, sourceInfo := range hitsResult { |
| | | rSourceInfo := sourceInfo.(map[string]interface{}) |
| | | source := rSourceInfo["_source"].(map[string]interface{}) |
| | | captureTime := source["picDate"].(string) |
| | | dDate := strings.Split(captureTime, " ")[0] |
| | | dTime := strings.Split(captureTime[:19], " ")[1] |
| | | //fmt.Println(captureTime, dDate, dTime) |
| | | id := source["id"].(string) |
| | | //fmt.Println("sindex: ", sIndex, "documentNumber", tmpInfo["documentNumber"], "id: ", id, "captureTime: ", captureTime) |
| | | if !isTimeInRange(dTime, aHFormat.startTime, aHFormat.endTime) { |
| | | if sDate != "" && len(dataId) >= frequency { |
| | | activeId = append(activeId, dataId...) |
| | | dataId = resetDataId(dataId, id, dDate, dTime, &sDate, &sTime) |
| | | } |
| | | //if sDate != "" && len(dataId) >= frequency { |
| | | // activeId = append(activeId, dataId...) |
| | | // dataId = resetDataId(dataId, id, dDate, dTime, &sDate, &sTime) |
| | | //} |
| | | continue |
| | | } |
| | | if sDate == "" { |
| | |
| | | "top_hits": { |
| | | "_source": [ |
| | | "id", |
| | | "picDate" |
| | | "picDate", |
| | | "baseInfo.targetPicUrl", |
| | | "targetInfo.picSmUrl" |
| | | ], |
| | | "size": 100000, |
| | | "sort": [ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | rdbaseIds := removeDuplicates(baseIds) |
| | | rdtargetIds := removeDuplicates(targetIds) |
| | | baseInfos, err := GetInfosByIds(rdbaseIds, indexName, serverIp, serverPort) |
| | |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | | docNumberMap := make(map[string][]interface{}) |
| | | for _, tinfo := range targetInfos { |
| | | docNumber := tinfo["documentNumber"].(string) |
| | | docNumberMap[docNumber] = append(docNumberMap[docNumber], tinfo) |
| | | } |
| | | targetRecordInfos := make([]map[string]interface{}, 0) |
| | | for docNumber, infos := range docNumberMap { |
| | | ifs := make(map[string]interface{}) |
| | | ifs["documentNumber"] = docNumber |
| | | ifs["recordInfos"] = infos |
| | | targetRecordInfos = append(targetRecordInfos, ifs) |
| | | } |
| | | result := make(map[string]interface{}) |
| | | result["baseRecordInfo"] = baseInfos |
| | | result["targetRecordInfo"] = targetInfos |
| | | result["targetRecordInfo"] = targetRecordInfos |
| | | return result, nil |
| | | } |
| | | |
| | |
| | | "terms":{ |
| | | "documentNumber":["` + docNumbers + `"] |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |