sunty
2020-08-26 3ca3fb42eebf23ec31145e8c30a80c37458cba6d
EsClient.go
@@ -507,7 +507,10 @@
      middleHits := topAttentionHits["hits"].(map[string]interface{})
      finalHits := middleHits["hits"].([]interface{})
      startTime := ""
      indexLength := len(finalHits)
      point := 0
      for _, in := range finalHits {
         point = point+1
         tmpHitSource := make(map[string]interface{})
         tmpbuf, ok := in.(map[string]interface{})
         if !ok {
@@ -530,20 +533,23 @@
         sTime := tmpTime
         eTime := tmpTime
         stayTime := 0.0
         if startTime != "" {
         if startTime != "" && point <= indexLength{
            sinTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc)
            passTime := math.Abs(mTime.Sub(sinTime).Seconds())
            //fmt.Println("passTime:   ", passTime)
            if passTime <= thresholdTime {
               startTime = tmpTime
               hitsSources[len(hitsSources)-1]["endTime"] = tmpTime
               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
               }
               continue
            } else {
               hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string)
               realStartTime, _ := time.ParseInLocation("2006-01-02 15:04:05", hitStartTime, loc)
               //fmt.Println("hitStartTime:    ",hitStartTime)
               //fmt.Println("realStartTime:    ",realStartTime)
               //fmt.Println("mTime:    ",mTime)
               stayTime = math.Abs(mTime.Sub(realStartTime).Seconds())
               //fmt.Println("stayTime:    ",stayTime)
               hitsSources[len(hitsSources)-1]["endTime"] = tmpTime
@@ -555,6 +561,8 @@
                  stayTime = stayTime + 1
               }
               hitsSources[len(hitsSources)-1]["stayTime"] = stayTime
               startTime = ""
               continue
               //fmt.Println(hitsSources[len(hitsSources)-1])
            }
         }
@@ -624,8 +632,11 @@
      topAttentionHits := inf.(map[string]interface{})["top_attention_hits"].(map[string]interface{})
      middleHits := topAttentionHits["hits"].(map[string]interface{})
      finalHits := middleHits["hits"].([]interface{})
      indexLength := len(finalHits)
      point := 0
      startTime := ""
      for _, in := range finalHits {
         point = point+1
         tmpHitSource := make(map[string]interface{})
         tmpbuf, ok := in.(map[string]interface{})
         if !ok {
@@ -648,13 +659,19 @@
         sTime := tmpTime
         eTime := tmpTime
         stayTime := 0.0
         if startTime != "" {
         if startTime != "" && point <= indexLength{
            sinTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc)
            passTime := math.Abs(mTime.Sub(sinTime).Seconds())
            //fmt.Println("passTime:   ", passTime)
            if passTime <= thresholdTime {
            if passTime <= thresholdTime || point == indexLength{
               startTime = tmpTime
               hitsSources[len(hitsSources)-1]["endTime"] = tmpTime
               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
               }
               continue
            } else {
               hitStartTime := hitsSources[len(hitsSources)-1]["startTime"].(string)
@@ -673,6 +690,8 @@
                  stayTime = stayTime + 1
               }
               hitsSources[len(hitsSources)-1]["stayTime"] = stayTime
               startTime = ""
               continue
               //fmt.Println(hitsSources[len(hitsSources)-1])
            }
         }