sunty
2020-08-23 a88cd5f3c40d32fb48e80873667455f1424ae1cf
EsClient.go
@@ -497,7 +497,7 @@
   if len(buckets) == 0 {
      return nil, nil
   }
   allSource := make([]map[string]interface{},0)
   allSource := make([]map[string]interface{}, 0)
   for _, inf := range buckets {
      //tmpSources := make(map[string]interface{}, 0)
      hitsSources := make([]map[string]interface{}, 0)
@@ -529,15 +529,17 @@
         sTime := tmpTime
         eTime := tmpTime
         stayTime := 0.0
         if startTime != "" {
            sinTime, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc)
            if math.Abs(sinTime.Sub(mTime).Seconds()) <= thresholdTime {
            stayTime = math.Abs(sinTime.Sub(mTime).Seconds())
            if stayTime <= thresholdTime {
               startTime = tmpTime
               hitsSources[len(hitsSources)-1]["endTime"] = tmpTime
               continue
            } else {
               if sinTime.Sub(mTime).Seconds() == 0{
                  sinTime.Add(time.Second*1)
               if sinTime.Sub(mTime).Seconds() == 0 {
                  sinTime.Add(time.Second * 1)
                  sinTime.Format("2006-01-02 15:04:05")
                  hitsSources[len(hitsSources)-1]["endTime"] = sinTime
               }
@@ -559,15 +561,19 @@
         tmpHitSource["startBackGroundPicUrl"] = source["picMaxUrl"].([]interface{})
         tmpHitSource["startFacePicUrl"] = targetInfo["picSmUrl"].(string)
         tmpHitSource["endTime"] = eTime
         tmpHitSource["stayTime"] = stayTime
         tmpHitSource["endTBackGroundPicUrl"] = source["picMaxUrl"].([]interface{})
         tmpHitSource["endTFacePicUrl"] = targetInfo["picSmUrl"].(string)
         if source["picWH"] != nil {
         tmpHitSource["picWH"] = source["picWH"].(map[string]interface{})
         }
         hitsSources = append(hitsSources, tmpHitSource)
      }
      allSource = append(allSource,hitsSources...)
   //   tmpSources["groupKey"] = groupKey
   //   tmpSources["doc_count"] = docCount
   //   tmpSources["hits_sources"] = hitsSources
   //   sources = append(sources, tmpSources)
      allSource = append(allSource, hitsSources...)
      //   tmpSources["groupKey"] = groupKey
      //   tmpSources["doc_count"] = docCount
      //   tmpSources["hits_sources"] = hitsSources
      //   sources = append(sources, tmpSources)
   }
   count := len(allSource)
   fmt.Println(count)
@@ -577,6 +583,42 @@
   return s, nil
}
//解析抓拍库人员结构
func PerSonAnalysis(preData []map[string]interface{}) (sources []map[string]interface{}, err error) {
   loc, err := time.LoadLocation("Asia/Shanghai")
   if err != nil {
      return nil, errors.New("时区设置错误")
   }
   for _, key := range preData {
      source := make(map[string]interface{}, 0)
      info := key
      targetInfo := info["targetInfo"].([]interface{})[0].(map[string]interface{})
      startTime := info["picDate"].(string)
      endTime := info["updateTime"].(string)
      source["personId"] = targetInfo["belongsTargetId"].(string)
      source["cameraId"] = info["cameraId"].(string)
      source["cameraName"] = info["cameraName"].(string)
      source["cameraAddr"] = info["cameraAddr"].(string)
      source["targetScore"] = int(targetInfo["targetScore"].(float64))
      source["personRect"] = targetInfo["targetLocation"].(map[string]interface{})
      source["startTime"] = startTime
      pixMaxUrl := info["picMaxUrl"].([]interface{})
      source["startBackGroundPicUrl"] = pixMaxUrl[0]
      source["endTime"] = endTime
      startT, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, loc)
      endT, _ := time.ParseInLocation("2006-01-02 15:04:05", endTime, loc)
      stayTime := endT.Sub(startT).Seconds()
      source["stayTime"] = stayTime
      source["endBackGroundPicUrl"] = pixMaxUrl[len(pixMaxUrl)-1]
      if info["picWH"] != nil {
         source["picWH"] = info["picWH"].(map[string]interface{})
      }
      sources = append(sources, source)
   }
   return sources, nil
}
func Sourcelist(buf []byte) (sources []map[string]interface{}, err error) {
   var info interface{}
   json.Unmarshal(buf, &info)