panlei
2019-09-29 0d08415bcbc5d1b260861365f26b0532771da2c5
insertdata/insertDataToEs.go
@@ -1,13 +1,12 @@
package insertdata
import (
   "basic.com/valib/logger.git"
   "encoding/base64"
   "encoding/json"
   "errors"
   "fmt"
   "net"
   "ruleprocess/cache"
   "ruleprocess/logger"
   "strconv"
   "time"
@@ -29,11 +28,11 @@
   DbTablePersons string `yaml:"dbTablePersons"`
}
func InitInsertEs() {
   weedfsUrl = "http://"+WeedFs.Ip+":"+strconv.Itoa(WeedFs.UploadPort)+"/submit"
   videoPersonUrl = "http://"+EsInfo.Masterip+":"+EsInfo.Httpport+"/"+EsInfo.EsIndex.VideoPersons.IndexName+"/"+EsInfo.EsIndex.VideoPersons.IndexType
   personAction = "http://"+EsInfo.Masterip+":"+EsInfo.Httpport+"/"+EsInfo.EsIndex.Personaction.IndexName+"/"+EsInfo.EsIndex.Personaction.IndexType
}
//func InitInsertEs() {
//   weedfsUrl = "http://"+WeedFs.Ip+":"+strconv.Itoa(WeedFs.UploadPort)+"/submit"
//   videoPersonUrl = "http://"+EsInfo.Masterip+":"+EsInfo.Httpport+"/"+EsInfo.EsIndex.VideoPersons.IndexName+"/"+EsInfo.EsIndex.VideoPersons.IndexType
//   personAction = "http://"+EsInfo.Masterip+":"+EsInfo.Httpport+"/"+EsInfo.EsIndex.Personaction.IndexName+"/"+EsInfo.EsIndex.Personaction.IndexType
//}
// 人脸的数据结构
type PerVideoPicture struct {
@@ -140,6 +139,13 @@
         logger.Error("es模块儿的异常捕获:",err)
      }
   }()
   localConfig1, err := cache.GetServerInfo()
   if err != nil {
      panic("配置文件不合法")
   }
   weedfsUrl = "http://"+localConfig1.WebPicIp+":"+strconv.Itoa(int(localConfig1.WebPicPort))+"/submit"
   videoPersonUrl = "http://"+localConfig1.AlarmIp+":"+strconv.Itoa(int(localConfig1.AlarmPort))+"/"+EsInfo.EsIndex.VideoPersons.IndexName+"/"+EsInfo.EsIndex.VideoPersons.IndexType
   personAction = "http://"+localConfig1.AlarmIp+":"+strconv.Itoa(int(localConfig1.AlarmPort))+"/"+EsInfo.EsIndex.Personaction.IndexName+"/"+EsInfo.EsIndex.Personaction.IndexType
   InsertFace(msg, "")
   // 如果标签中含有持续时间首次报警的timeLabel的话则不需要过人体追踪,不然就没的插入了
   fk := ruleserver.TrackOrNot(msg.RuleResult)
@@ -185,7 +191,7 @@
            err = proto.Unmarshal(bdata, &i)
            if imgMaxUrl == "" {
               bigPhotoUrl := make(map[string]interface{})
               bigPhotoUrl, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String())
               bigPhotoUrl, err = util.DrawPolygonOnImageForFace(msg.Cid, i, msg.RuleResult["face"].([]ruleserver.FaceResult), weedfsUrl)
               logger.Debug("========大图路径:", bigPhotoUrl)
               imgMaxUrl = bigPhotoUrl["fileUrl"].(string)
               picTime = i.Timestamp
@@ -222,8 +228,8 @@
            if linkId != "" {
               linksId = linkId
            }
            logger.Info("人脸的id:",strconv.FormatUint(face.Id, 10))
            logger.Info("人脸的分值:",face.Score)
            //logger.Info("人脸的id:",strconv.FormatUint(face.Id, 10))
            //logger.Info("人脸的分值:",face.Score)
            pervideo := PerVideoPicture{
               esDataId,
               msg.Cid,
@@ -236,9 +242,9 @@
               "",
               alarmRules,
               time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间
               strconv.FormatUint(face.Id, 10),            //暂改为人脸id strconv.FormatUint(face.Id, 10)
               sex,            //暂改为人脸id strconv.FormatUint(face.Id, 10)
               face.ThftRes.Age,
               fmt.Sprintf("%.2f",face.Score), // 暂改为分值fmt.Sprintf("%.2f",face.Score)
               ageDescription, // 暂改为分值fmt.Sprintf("%.2f",face.Score)
               race,
               face.ThftRes.Smile,
               face.ThftRes.Beauty,
@@ -361,7 +367,7 @@
                     }
                     i := protomsg.Image{}
                     err = proto.Unmarshal(bdata, &i)
                     resp1, err1 := util.DrawPolygonOnImage(msg1.Cid, i, msg1.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl)
                     resp1, err1 := util.DrawPolygonOnImageForYolo(msg1.Cid, i, msg1.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl)
                     if err1 != nil {
                        logger.Error("缓存数据画框或上传图片服务器出错", err)
                     } else {
@@ -404,7 +410,7 @@
         if len(alarmRules) > 0 {
            isAlarm = 1
            //resp, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String())
            resp, err = util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl)
            resp, err = util.DrawPolygonOnImageForYolo(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl)
            if err != nil {
               logger.Error("画框或上传图片服务器出错", err)
               return