panlei
2019-07-09 9bb6f2ddbdcc3c06799dd7beb2e19861f982d9d4
insertdata/insertDataToEs.go
@@ -1,12 +1,13 @@
package insertdata
import (
   "ruleprocess/logger"
   "encoding/json"
   "errors"
   "fmt"
   "io/ioutil"
   "net"
   "ruleprocess/cache"
   "ruleprocess/logger"
   "strings"
   "time"
@@ -15,9 +16,30 @@
   "github.com/satori/go.uuid"
   "ruleprocess/ruleserver"
   "ruleprocess/util"
   "github.com/go-yaml/yaml"
)
var weedfsUrl string
type conf struct {
   PhotoUrl string `yaml:"photoUrl"`
}
func init() {
   logger.Info("_________________________________________老子想看你执行了没")
   fmt.Println("_________________________________________老子想看你执行了没")
   data, err := ioutil.ReadFile("./config/conf.yml")
   if err != nil {
      fmt.Println("读取配置文件出错--",err)
      logger.Error("读取配置文件出错--",err)
   }
   fmt.Println("从配置文件中读取的值为:",string(data))
   c := conf{}
   //把yaml形式的字符串解析成struct类型
   yaml.Unmarshal(data, &c)
   fmt.Println("c.PhotoUrl的值为:",c.PhotoUrl)
   weedfsUrl = c.PhotoUrl
   fmt.Println("weedfsUrl的值为:",weedfsUrl)
   logger.Info("weedfsUrl的值为:",weedfsUrl)
}
var weedfsUrl = "http://192.168.1.182:6333/submit"
// 人脸的数据结构
type PerVideoPicture struct {
   Id              string   `json:"id"`
@@ -84,6 +106,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) {
@@ -150,7 +173,7 @@
               race,
               face.ThftRes.Smile,
               face.ThftRes.Beauty,
               "",
               string(face.Feature),
               []string{strings.Split(resp["fileUrl"].(string), "/")[1]},
               "暂无集群",
               localConfig.ServerId,