panlei
2019-09-12 fb1b6c4f3eac63ad04f48be4a1e88a372799e95f
insertdata/insertDataToEs.go
@@ -9,6 +9,7 @@
   "net"
   "ruleprocess/cache"
   "ruleprocess/logger"
   "strconv"
   "time"
   "basic.com/pubsub/protomsg.git"
@@ -206,6 +207,7 @@
            }
            //logger.Info("================小图地址:", resp["fileUrl"].(string))
            sex := ""
            logger.Info(sex)
            if face.ThftRes.Gender == 1 {
               sex = "男"
            } else {
@@ -213,11 +215,14 @@
            }
            race := getRaceString(face.ThftRes.Race)
            ageDescription := getDescription(face.ThftRes.Age)
            logger.Info(ageDescription)
            esDataId := uuid.NewV4().String()
            linksId := ""
            if linkId != "" {
               linksId = linkId
            }
            logger.Info("人脸的id:",strconv.FormatUint(face.Id, 10))
            logger.Info("人脸的分值:",face.Score)
            pervideo := PerVideoPicture{
               esDataId,
               msg.Cid,
@@ -230,9 +235,9 @@
               "",
               alarmRules,
               time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间
               sex,
               strconv.FormatUint(face.Id, 10),            //暂改为人脸id
               face.ThftRes.Age,
               ageDescription,
               strconv.FormatFloat(face.Score, 'E', -1, 64), // 暂改为分值
               race,
               face.ThftRes.Smile,
               face.ThftRes.Beauty,
@@ -420,52 +425,53 @@
            logger.Error("查询摄像机信息失败")
         }
         serverIp, err := GetLocalIP()
         if resp["fileUrl"] != nil {
            url = append(url, resp["fileUrl"].(string))
            esDataId := uuid.NewV4().String()
            linksId := ""
            if linkId != "" {
               linksId = linkId
            }
            peraction := Personaction{
               esDataId,
               msg.Cid,
               camera.Name,
               camera.Addr,
               msg.Tasklab.Taskid,
               msg.Tasklab.Taskname,
               sdkNames,
               "",
               alarmRules,
               localConfig.ServerId,
               localConfig.ServerName,
               serverIp,
               "",
               url,
               i.Timestamp,
               linksId,
               "",
               isAlarm,
               0,
               0,
               0,
            }
            requstbody, err := json.Marshal(peraction)
         url = append(url, resp["fileUrl"].(string))
         esDataId := uuid.NewV4().String()
         linksId := ""
         if linkId != "" {
            linksId = linkId
         }
         peraction := Personaction{
            esDataId,
            msg.Cid,
            camera.Name,
            camera.Addr,
            msg.Tasklab.Taskid,
            msg.Tasklab.Taskname,
            sdkNames,
            "",
            alarmRules,
            localConfig.ServerId,
            localConfig.ServerName,
            serverIp,
            "",
            url,
            i.Timestamp,
            linksId,
            "",
            isAlarm,
            0,
            0,
            0,
         }
         requstbody, err := json.Marshal(peraction)
            if err != nil {
               logger.Info("json parse error ", err)
               return
         if err != nil {
            logger.Info("json parse error ", err)
            return
         }
         resp1, err2 := EsReq("POST", personAction, requstbody)
         if err2 != nil {
            logger.Error("往ES插入数据失败", err)
         } else {
            logger.Debug("插入es返回的数据信息是:", resp1)
            // 发出录像信号
            ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: esDataId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}, Type: 2})
            logger.Warn("__________________________________________往ES插入yolo数据成功")
            //os.Exit(1)
            }
            resp1, err2 := EsReq("POST", personAction, requstbody)
            if err2 != nil {
               logger.Error("往ES插入数据失败", err)
            } else {
               logger.Debug("插入es返回的数据信息是:", resp1)
               // 发出录像信号
               ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: esDataId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}, Type: 2})
               logger.Warn("__________________________________________往ES插入yolo数据成功")
               //os.Exit(1)
            }
         }
      } else {
         logger.Debug("timeLabel条件都不符合!")