sunty
2020-09-07 0b5dfb70be50bd03d95a7a1248a366661549cfa4
EsClient.go
@@ -476,7 +476,6 @@
   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 {
@@ -530,22 +529,24 @@
         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)
@@ -559,9 +560,10 @@
                  stayTime =  1
               }
               hitsSources[len(hitsSources)-1]["stayTime"] = stayTime
               if point == indexLength {
                  stayTime = 1
               }
               startTime = ""
               continue
               //fmt.Println(hitsSources[len(hitsSources)-1])
            }
         }
         //fmt.Println("========================================================")
@@ -695,21 +697,24 @@
         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)
@@ -723,9 +728,10 @@
                  stayTime =  1
               }
               hitsSources[len(hitsSources)-1]["stayTime"] = stayTime
               if point == indexLength {
                  stayTime = 1
               }
               startTime = ""
               continue
               //fmt.Println(hitsSources[len(hitsSources)-1])
            }
         }
         //fmt.Println("========================================================")
@@ -818,21 +824,24 @@
         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)
@@ -846,9 +855,10 @@
                  stayTime =  1
               }
               hitsSources[len(hitsSources)-1]["stayTime"] = stayTime
               if point == indexLength {
                  stayTime = 1
               }
               startTime = ""
               continue
               //fmt.Println(hitsSources[len(hitsSources)-1])
            }
         }
         startTime = tmpTime