---
panlei
2019-07-09 9126bb1f11799ace90ed8de69cec15188b162eb4
insertdata/insertDataToEs.go
@@ -4,6 +4,7 @@
   "encoding/json"
   "errors"
   "fmt"
   "io/ioutil"
   "net"
   "ruleprocess/cache"
   "ruleprocess/logger"
@@ -15,9 +16,21 @@
   "github.com/satori/go.uuid"
   "ruleprocess/ruleserver"
   "ruleprocess/util"
   "github.com/go-yaml/yaml"
)
var weedfsUrl string
type conf struct {
   PhotoUrl string
}
func init() {
   logger.Info("_________________________________________老子想看你执行了没")
   data, _ := ioutil.ReadFile("conf.yml")
   c := conf{}
   //把yaml形式的字符串解析成struct类型
   yaml.Unmarshal(data, &c)
   weedfsUrl = c.PhotoUrl
}
var weedfsUrl = "http://192.168.1.182:6333/submit"
// 人脸的数据结构
type PerVideoPicture struct {
   Id              string   `json:"id"`
@@ -84,6 +97,7 @@
func InsertToEs(msg ruleserver.ResultMsg) {
   // 直接从规则的标签数据里拿符合规则的人脸结果
   logger.Info("------------------------------------从配置文件读取的值:",weedfsUrl)
   if msg.RuleResult["face"] != nil && len(msg.RuleResult["face"].([]ruleserver.Arg)) > 0 {
      logger.Info("往ES插人脸数据")
      for _, face := range msg.RuleResult["face"].([]ruleserver.Arg) {
@@ -117,12 +131,13 @@
            }
            i := protomsg.Image{}
            err = proto.Unmarshal(bdata, &i)
            logger.Info("-------------------------------------------看下宽和高", i.Width, i.Height)
            //logger.Info("-------------------------------------------看下宽和高", i.Width, i.Height)
            bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height))
            resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String())
            if err != nil {
               logger.Error("上传小图出错")
            }
            logger.Info("================小图地址:",resp["fileUrl"].(string))
            sex := ""
            if face.ThftRes.Gender == 1 {
               sex = "男"
@@ -149,7 +164,7 @@
               race,
               face.ThftRes.Smile,
               face.ThftRes.Beauty,
               "",
               string(face.Feature),
               []string{strings.Split(resp["fileUrl"].(string), "/")[1]},
               "暂无集群",
               localConfig.ServerId,
@@ -190,12 +205,13 @@
            }
            i := protomsg.Image{}
            err = proto.Unmarshal(bdata, &i)
            logger.Info("-------------------------------------------看下宽和高", i.Width, i.Height)
            //logger.Info("-------------------------------------------看下宽和高", i.Width, i.Height)
            bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height))
            resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String())
            if err != nil {
               logger.Error("上传小图出错")
            }
            logger.Info("================小图地址:",resp["fileUrl"].(string))
            sex := ""
            if face.ThftRes.Gender == 1 {
               sex = "男"