panlei
2019-07-15 ca177f11067d4886e615a2179e943ed6acc687b4
把es插入路径换成配置文件里的
2个文件已修改
149 ■■■■ 已修改文件
config/conf.yml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
insertdata/insertDataToEs.go 145 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/conf.yml
@@ -1 +1,3 @@
photoUrl: "http://192.168.1.182:6333/submit"
photoUrl: "http://192.168.1.182:6333/submit"
videopersons: "http://192.168.1.182:9200/videopersons/perVideoPicture"
personaction: "http://192.168.1.182:9200/personaction/perVideoAction"
insertdata/insertDataToEs.go
@@ -19,10 +19,12 @@
    "ruleprocess/util"
)
var weedfsUrl string
var weedfsUrl,videoPersonUrl,personAction string
type conf struct {
    PhotoUrl string `yaml:"photoUrl"`
    PhotoUrl     string `yaml:"photoUrl"`
    Videopersons string `yaml:"videopersons"`
    Personaction string `yaml:"personaction"`
}
func init() {
@@ -35,6 +37,8 @@
    //把yaml形式的字符串解析成struct类型
    yaml.Unmarshal(data, &c)
    weedfsUrl = c.PhotoUrl
    videoPersonUrl = c.Videopersons
    personAction = c.Personaction
}
// 人脸的数据结构
@@ -202,7 +206,7 @@
                logger.Info("json parse error ", err)
                return
            }
            err1 := EsReq("POST", "http://192.168.1.182:9200/videopersons/perVideoPicture", requstbody)
            err1 := EsReq("POST", videoPersonUrl, requstbody)
            if err1 != nil {
                logger.Error("上传ES出错!---", err1)
            }
@@ -211,73 +215,73 @@
}
func ChangeStatusFace(msg ruleserver.ResultMsg) {
    logger.Info("往ES插入人脸非报警但是状态转换数据")
        // 上传大图
        // 解压缩并上传图片
        bdata, err := util.UnCompress(msg.Data)
        if err != nil {
            panic("解压缩图片时出现错误")
        }
        i := protomsg.Image{}
        err = proto.Unmarshal(bdata, &i)
        bigPhotoUrl := make(map[string]interface{})
        bigPhotoUrl, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String())
        logger.Debug("========大图路径:", bigPhotoUrl)
        // 人脸检测,没有相似的底库人员
        localConfig, err := cache.GetServerInfo()
        if err != nil {
            logger.Error("查询本机信息失败!")
        }
        serverIp, err := GetLocalIP()
        // 查询cameraName
        camera, err := cache.GetCameraById(msg.Cid)
        if err != nil {
            logger.Error("查询摄像机信息失败")
        }
    // 上传大图
    // 解压缩并上传图片
    bdata, err := util.UnCompress(msg.Data)
    if err != nil {
        panic("解压缩图片时出现错误")
    }
    i := protomsg.Image{}
    err = proto.Unmarshal(bdata, &i)
    bigPhotoUrl := make(map[string]interface{})
    bigPhotoUrl, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String())
    logger.Debug("========大图路径:", bigPhotoUrl)
    // 人脸检测,没有相似的底库人员
    localConfig, err := cache.GetServerInfo()
    if err != nil {
        logger.Error("查询本机信息失败!")
    }
    serverIp, err := GetLocalIP()
    // 查询cameraName
    camera, err := cache.GetCameraById(msg.Cid)
    if err != nil {
        logger.Error("查询摄像机信息失败")
    }
        pervideo := PerVideoPicture{
            uuid.NewV4().String(),
            msg.Cid,
            camera.Addr,
            i.Timestamp,
            strings.Split(bigPhotoUrl["fileUrl"].(string), "/")[1],
            msg.Tasklab.Taskid,
            msg.Tasklab.Taskname,
            "人脸",
            "状态转换数据,非报警数据",
            time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间
            "",
            0,
            "",
            "",
            0,
            0,
            "",
            []string{""},
            "暂无集群",
            localConfig.ServerId,
            localConfig.ServerName,
            serverIp,
            "",
            0,
            1,
            0,
            0,
            0,
            []*protomsg.Baseinfo{},
        }
        requstbody, err := json.Marshal(pervideo)
    pervideo := PerVideoPicture{
        uuid.NewV4().String(),
        msg.Cid,
        camera.Addr,
        i.Timestamp,
        strings.Split(bigPhotoUrl["fileUrl"].(string), "/")[1],
        msg.Tasklab.Taskid,
        msg.Tasklab.Taskname,
        "人脸",
        "状态转换数据,非报警数据",
        time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间
        "",
        0,
        "",
        "",
        0,
        0,
        "",
        []string{""},
        "暂无集群",
        localConfig.ServerId,
        localConfig.ServerName,
        serverIp,
        "",
        0,
        1,
        0,
        0,
        0,
        []*protomsg.Baseinfo{},
    }
    requstbody, err := json.Marshal(pervideo)
        if err != nil {
            logger.Info("json parse error ", err)
            return
        }
        err1 := EsReq("POST", "http://192.168.1.182:9200/videopersons/perVideoPicture", requstbody)
        if err1 != nil {
            logger.Error("上传ES出错!---", err1)
        }
        //if msg.RuleResult["cacheData"] != nil {
        //    InsertFace(msg.RuleResult["cacheData"].(ruleserver.ResultMsg))
        //}
    if err != nil {
        logger.Info("json parse error ", err)
        return
    }
    err1 := EsReq("POST", videoPersonUrl, requstbody)
    if err1 != nil {
        logger.Error("上传ES出错!---", err1)
    }
    //if msg.RuleResult["cacheData"] != nil {
    //    InsertFace(msg.RuleResult["cacheData"].(ruleserver.ResultMsg))
    //}
}
// 往es中插入yolo数据
@@ -355,7 +359,7 @@
            return
        }
        err = EsReq("POST", "http://192.168.1.182:9200/personaction/perVideoAction", requstbody)
        err = EsReq("POST", personAction, requstbody)
        if err != nil {
            logger.Error("往ES插入数据失败", err)
        } else {
@@ -425,7 +429,7 @@
        return
    }
    err = EsReq("POST", "http://192.168.1.182:9200/personaction/perVideoAction", requstbody)
    err = EsReq("POST", personAction, requstbody)
    if err != nil {
        logger.Error("往ES插入数据失败", err)
    } else {
@@ -433,6 +437,7 @@
        //os.Exit(1)
    }
}
// 获取本机ip
func GetLocalIP() (ipv4 string, err error) {
    var (