| | |
| | | return tmpinfos |
| | | } |
| | | |
| | | |
| | | func FaceSourceAggregations(buf []byte, thresholdTime int,thresholdStayTime int) (sources []map[string]interface{}, err error) { |
| | | loc, err := time.LoadLocation("Asia/Shanghai") |
| | | if err != nil { |
| | |
| | | sTime := tmpTime |
| | | eTime := mTime.Add(time.Second*1).Format("2006-01-02 15:04:05") |
| | | stayTime := 1.0 |
| | | if startTime != "" && point < indexLength{ |
| | | if startTime != "" && point <= indexLength { |
| | | sinTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc) |
| | | passTime := math.Abs(mTime.Sub(sinTime).Seconds()) |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | //fmt.Println("passTime: ", passTime) |
| | | if int(passTime) <= thresholdTime || point == indexLength{ |
| | | startTime = tmpTime |
| | | hitsSources[len(hitsSources)-1]["endTime"] = tmpTime |
| | | if int(passTime) <= thresholdTime { |
| | | if point == indexLength{ |
| | | hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string) |
| | | realStartTime, _ := time.ParseInLocation("2006-01-02 15:04:05", hitStartTime, loc) |
| | | stayTime = math.Abs(mTime.Sub(realStartTime).Seconds()) |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | startTime = "" |
| | | } |
| | | } else { |
| | | startTime = tmpTime |
| | | hitsSources[len(hitsSources)-1]["endTime"] = tmpTime |
| | | continue |
| | | } |
| | | |
| | | } else { |
| | | hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string) |
| | | hitEndTime := hitsSources[len(hitsSources)-1]["endTime"].(string) |
| | |
| | | stayTime = 1 |
| | | } |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | if point == indexLength { |
| | | stayTime = 1 |
| | | } |
| | | startTime = "" |
| | | continue |
| | | //fmt.Println(hitsSources[len(hitsSources)-1]) |
| | | } |
| | | } |
| | | //fmt.Println("========================================================") |
| | |
| | | sTime := tmpTime |
| | | eTime := mTime.Add(time.Second*1).Format("2006-01-02 15:04:05") |
| | | stayTime := 1.0 |
| | | if startTime != "" && point < indexLength{ |
| | | if startTime != "" && point <= indexLength { |
| | | sinTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc) |
| | | passTime := math.Abs(mTime.Sub(sinTime).Seconds()) |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | //fmt.Println("passTime: ", passTime) |
| | | if passTime <= thresholdTime || point == indexLength{ |
| | | startTime = tmpTime |
| | | hitsSources[len(hitsSources)-1]["endTime"] = tmpTime |
| | | if passTime <= thresholdTime { |
| | | if point == indexLength{ |
| | | hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string) |
| | | realStartTime, _ := time.ParseInLocation("2006-01-02 15:04:05", hitStartTime, loc) |
| | | stayTime = math.Abs(mTime.Sub(realStartTime).Seconds()) |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | } |
| | | startTime = "" |
| | | } else { |
| | | startTime = tmpTime |
| | | hitsSources[len(hitsSources)-1]["endTime"] = tmpTime |
| | | continue |
| | | } |
| | | |
| | | } else { |
| | | hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string) |
| | | hitEndTime := hitsSources[len(hitsSources)-1]["endTime"].(string) |
| | |
| | | stayTime = 1 |
| | | } |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | if point == indexLength { |
| | | stayTime = 1 |
| | | } |
| | | startTime = "" |
| | | continue |
| | | //fmt.Println(hitsSources[len(hitsSources)-1]) |
| | | } |
| | | } |
| | | //fmt.Println("========================================================") |
| | |
| | | sTime := tmpTime |
| | | eTime := mTime.Add(time.Second*1).Format("2006-01-02 15:04:05") |
| | | stayTime := 1.0 |
| | | if startTime != "" && point < indexLength{ |
| | | if startTime != "" && point <= indexLength { |
| | | sinTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc) |
| | | passTime := math.Abs(mTime.Sub(sinTime).Seconds()) |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | //fmt.Println("passTime: ", passTime) |
| | | if passTime <= thresholdTime || point == indexLength{ |
| | | startTime = tmpTime |
| | | hitsSources[len(hitsSources)-1]["endTime"] = tmpTime |
| | | if passTime <= thresholdTime { |
| | | if point == indexLength{ |
| | | hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string) |
| | | realStartTime, _ := time.ParseInLocation("2006-01-02 15:04:05", hitStartTime, loc) |
| | | stayTime = math.Abs(mTime.Sub(realStartTime).Seconds()) |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | } |
| | | startTime = "" |
| | | } else { |
| | | startTime = tmpTime |
| | | hitsSources[len(hitsSources)-1]["endTime"] = tmpTime |
| | | continue |
| | | } |
| | | |
| | | } else { |
| | | hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string) |
| | | hitEndTime := hitsSources[len(hitsSources)-1]["endTime"].(string) |
| | |
| | | stayTime = 1 |
| | | } |
| | | hitsSources[len(hitsSources)-1]["stayTime"] = stayTime |
| | | if point == indexLength { |
| | | stayTime = 1 |
| | | } |
| | | startTime = "" |
| | | continue |
| | | //fmt.Println(hitsSources[len(hitsSources)-1]) |
| | | } |
| | | } |
| | | startTime = tmpTime |