panlei
2019-11-18 4af2c7cf0abc5cc9c5aec3cdff78b1c93d9c6ff0
es数据
3个文件已修改
173 ■■■■ 已修改文件
insertdata/insertDataToEs.go 156 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruleserver/readyDataForRule.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
structure/rule.go 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
insertdata/insertDataToEs.go
@@ -42,23 +42,20 @@
    CameraAddr      string                `json:"cameraAddr"`
    CameraName      string                `json:"cameraName"`
    PicDate         string                `json:"picDate"`
    PicMaxUrl       string                `json:"picMaxUrl"`
    PicMaxUrl       []string              `json:"picMaxUrl"`
    TaskId          string                `json:"taskId"`
    TaskName        string                `json:"taskName"`
    SdkName         string                `json:"sdkName"`
    Content         string                `json:"content"`
    AlarmRules      []AlarmRule           `json:"alarmRules"`
    LikeDate        string                `json:"likeDate"`
    ShowLable       string                `json:"showLable"`
    OtherLable      string                `json:"otherLable"`
    FaceFeature     string                `json:"faceFeature"`
    PicSmUrl        []string              `json:"picSmUrl"`
    ShowLables      string                `json:"showLables"`
    OtherLables     string                `json:"otherLables"`
    VideoUrl        string                `json:"videoUrl"`
    AnalyServerId   string                `json:"analyServerId"`
    AnalyServerName string                `json:"analyServerName"`
    AnalyServerIp   string                `json:"analyServerIp"`
    ClusterId       string                `json:"clusterId"`
    DetectScore     float64               `json:"detectScore"`
    IsAlarm         int                   `json:"isAlarm"`
    IsAckAlarm      int                   `json:"isAckAlarm"`
    IsCollect       int                   `json:"isCollect"`
@@ -75,22 +72,20 @@
    CameraAddr      string                `json:"cameraAddr"`
    CameraName      string                `json:"cameraName"`
    PicDate         string                `json:"picDate"`
    PicMaxUrl       string                `json:"picMaxUrl"`
    PicMaxUrl       []string              `json:"picMaxUrl"`
    TaskId          string                `json:"taskId"`
    TaskName        string                `json:"taskName"`
    SdkName         string                `json:"sdkName"`
    Content         string                `json:"content"`
    AlarmRules      []AlarmRule           `json:"alarmRules"`
    LikeDate        string                `json:"likeDate"`
    Lable           string                `json:"lable"`
    FaceFeature     string                `json:"faceFeature"`
    PicSmUrl        []string              `json:"picSmUrl"`
    ShowLables      string                `json:"showLables"`
    OtherLables     string                `json:"otherLables"`
    VideoUrl        string                `json:"videoUrl"`
    AnalyServerId   string                `json:"analyServerId"`
    AnalyServerName string                `json:"analyServerName"`
    AnalyServerIp   string                `json:"analyServerIp"`
    ClusterId       string                `json:"clusterId"`
    DetectScore     float64               `json:"detectScore"`
    IsAlarm         int                   `json:"isAlarm"`
    IsAckAlarm      int                   `json:"isAckAlarm"`
    IsCollect       int                   `json:"isCollect"`
@@ -102,6 +97,8 @@
type Target struct {
    TargetId       string  `json:"targetId"`
    TargetScore    float64 `json:"targetScore"`
    FaceFeature    string  `json:"faceFeature"`
    PicSmUrl       string  `json:"picSmUrl"`
    TargetLocation Points  `json:"targetLocation"`
}
@@ -116,31 +113,31 @@
}
//  yolo行为的数据结构
type Personaction struct {
    Id              string      `json:"id"`
    CameraId        string      `json:"cameraId"`
    CameraName      string      `json:"cameraName"`
    CameraAddr      string      `json:"cameraAddr"`
    TaskId          string      `json:"taskId"`
    TaskName        string      `json:"taskName"`
    SdkName         string      `json:"sdkName"`
    Content         string      `json:"content"`
    AlarmRules      []AlarmRule `json:"alarmRules"`
    AnalyServerId   string      `json:"analyServerId"`
    AnalyServerName string      `json:"analyServerName"`
    AnalyServerIp   string      `json:"analyServerIp"`
    ClusterId       string      `json:"clusterId"`
    PicSmUrl        []string    `json:"picSmUrl"`
    PicDate         string      `json:"picDate"`
    VideoUrl        string      `json:"videoUrl"`
    IsAlarm         int         `json:"isAlarm"`
    IsAckAlarm      int         `json:"isAckAlarm"`
    IsCollect       int         `json:"isCollect"`
    IsDelete        int         `json:"isDelete"`
    TargetInfo      []Target    `json:"targetInfo"`
    LinkTag         string      `json:"linkTag"`
    LinkTagInfo     []*LinkInfo `json:"linkTagInfo"`
}
//type Personaction struct {
//    Id              string      `json:"id"`
//    CameraId        string      `json:"cameraId"`
//    CameraName      string      `json:"cameraName"`
//    CameraAddr      string      `json:"cameraAddr"`
//    TaskId          string      `json:"taskId"`
//    TaskName        string      `json:"taskName"`
//    SdkName         string      `json:"sdkName"`
//    Content         string      `json:"content"`
//    AlarmRules      []AlarmRule `json:"alarmRules"`
//    AnalyServerId   string      `json:"analyServerId"`
//    AnalyServerName string      `json:"analyServerName"`
//    AnalyServerIp   string      `json:"analyServerIp"`
//    ClusterId       string      `json:"clusterId"`
//    PicSmUrl        []string    `json:"picSmUrl"`
//    PicDate         string      `json:"picDate"`
//    VideoUrl        string      `json:"videoUrl"`
//    IsAlarm         int         `json:"isAlarm"`
//    IsAckAlarm      int         `json:"isAckAlarm"`
//    IsCollect       int         `json:"isCollect"`
//    IsDelete        int         `json:"isDelete"`
//    TargetInfo      []Target    `json:"targetInfo"`
//    LinkTag         string      `json:"linkTag"`
//    LinkTagInfo     []*LinkInfo `json:"linkTagInfo"`
//}
type AlarmRule struct {
    GroupId      string `json:"groupId"`
@@ -184,7 +181,7 @@
                faces = PutFace(faces, results.([]structure.Result))
                //logger.Info("整理后的数据:",faces)
                if faces != nil {
                    var imgMaxUrl string = ""
                    var imgMaxUrl []string = []string{}
                    var picTime string = ""
                    for _, face := range faces {
                        // 上传大图
@@ -207,19 +204,20 @@
                            logger.Error("上传小图出错")
                        }
                        // 上传大图
                        if imgMaxUrl == "" {
                        if len(imgMaxUrl) == 0 {
                            bigPhotoUrl := make(map[string]interface{})
                            bigPhotoUrl, err = util.DrawPolygonOnImageForFace(msg.Cid, i, msg.RuleResult["face"].([]structure.Result), weedfsUrl)
                            logger.Debug("========大图路径:", bigPhotoUrl)
                            imgMaxUrl = bigPhotoUrl["fileUrl"].(string)
                            imgMaxUrl = append(imgMaxUrl,bigPhotoUrl["fileUrl"].(string))
                            picTime = i.Timestamp
                        }
                        lable,lableAttach := Feature2Jsonstr(*face)
                        var target = new(Target)
                        target.TargetId = face.Id
                        target.TargetScore = face.Score
                        target.FaceFeature = base64.StdEncoding.EncodeToString(face.Feature)
                        target.PicSmUrl = resp["fileUrl"].(string)
                        target.TargetLocation = Points{TopLeft: Point{face.Location.X, face.Location.Y}, BottomRight: Point{face.Location.X + face.Location.Width, face.Location.Y + face.Location.Height}}
                        //logger.Info("人脸的id:",strconv.FormatUint(face.Id, 10))
                        var targetInfos []Target
                        targetInfos = append(targetInfos, *target)
                        pervideo := PerVideoPicture{
@@ -237,14 +235,11 @@
                            time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间
                            lable,
                            lableAttach,
                            base64.StdEncoding.EncodeToString(face.Feature),
                            []string{resp["fileUrl"].(string)},
                            "",
                            msg.Push.ServerId,
                            msg.Push.ServerName,
                            msg.Push.LocalIp,
                            "",
                            face.Score,
                            1,
                            0,
                            0,
@@ -298,7 +293,7 @@
                for _, liker := range arg.Liker {
                    flag1 := true
                    for _, liker1 := range face.Liker {
                        if liker.PersonId == liker1.PersonId {
                        if liker.TargetId == liker1.TargetId {
                            flag1 = false
                        }
                    }
@@ -432,27 +427,31 @@
            if resp["fileUrl"] != nil {
                url = append(url, resp["fileUrl"].(string))
                //esDataId := uuid.NewV4().String()
                peraction := Personaction{
                peraction := PerVideoPicture{
                    msg.Push.PushId,
                    msg.Cid,
                    msg.Push.Cam.Name,
                    msg.Push.Cam.Addr,
                    msg.Push.Cam.Name ,
                    time.Now().Format("2006-01-02 15:04:05"),
                    url,
                    msg.Tasklab.Taskid,
                    msg.Tasklab.Taskname,
                    sdkNames,
                    time.Now().Format("2006-01-02 15:04:05"),
                    alarmRules,
                    i.Timestamp,
                    "",
                    "",
                    "",
                    msg.Push.ServerId,
                    msg.Push.ServerName,
                    msg.Push.LocalIp,
                    "",
                    url,
                    i.Timestamp,
                    "",
                    isAlarm,
                    0,
                    0,
                    0,
                    nil,
                    targetInfos,
                    linkTag,
                    linkTagInfos,
@@ -506,13 +505,7 @@
            }
            if insertFlag {
                logger.Info("报警目标个数:", alarmNum)
                //var target = new(Target)
                //target.TargetId = strconv.FormatUint(tar.Id, 10)
                //target.TargetScore = tar.Score
                //target.TargetLocation = Points{TopLeft: Point{tar.Location.X, tar.Location.Y}, BottomRight: Point{tar.Location.X + tar.Location.Width, tar.Location.Y + tar.Location.Height}}
                //logger.Info("人脸的id:",strconv.FormatUint(face.Id, 10))
                //var targetInfos []Target
                //targetInfos = append(targetInfos, *target)
                // 获取目标缓存图片
                url := []string{}
                //InsertYolo(msg.RuleResult["cacheData"].(ruleserver.ResultMsg))
@@ -570,33 +563,56 @@
                    // 不是报警数据不存
                    return
                }
                // 整合目标
                var targetInfos []Target
                for _, target := range yoloResult.AlarmObj {
                    // 去重添加
                    var flag = true
                    for _, selectTarget := range targetInfos {
                        if target.Id == selectTarget.TargetId {
                            flag = false
                            break
                        }
                    }
                    if flag {
                        var target1 = new(Target)
                        target1.TargetId = target.Id
                        target1.TargetScore = target.Score
                        target1.TargetLocation = Points{TopLeft: Point{target.Location.X, target.Location.Y}, BottomRight: Point{target.Location.X + target.Location.Width, target.Location.Y + target.Location.Height}}
                        targetInfos = append(targetInfos, *target1)
                    }
                }
                if resp["fileUrl"] != nil {
                    url = append(url, resp["fileUrl"].(string))
                    if len(url) == 1 {
                        return
                    }
                    //esDataId := uuid.NewV4().String()
                    peraction := Personaction{
                    peraction := PerVideoPicture{
                        msg.Push.PushId,
                        msg.Cid,
                        msg.Push.Cam.Name,
                        msg.Push.Cam.Addr,
                        msg.Push.Cam.Name,
                        i.Timestamp,
                        url,
                        msg.Tasklab.Taskid,
                        msg.Tasklab.Taskname,
                        sdkNames,
                        time.Now().Format("2006-01-02 15:04:05"),
                        "",
                        alarmRules,
                        time.Now().Format("2006-01-02 15:04:05"),
                        "",
                        "",
                        "",
                        msg.Push.ServerId,
                        msg.Push.ServerName,
                        msg.Push.LocalIp,
                        "",
                        url,
                        i.Timestamp,
                        "",
                        isAlarm,
                        0,
                        0,
                        0,
                        nil,
                        nil,
                        linkTag,
                        linkTagInfos,
@@ -748,15 +764,15 @@
            }
            race := getRaceString(obj.ThftRes.Race)
            ageDescription := getDescription(obj.ThftRes.Age)
            lable = sex+" / "+ageDescription+" / "+race+" / "
            lableAttach = strconv.Itoa(int(obj.ThftRes.Age))+"岁"+" / "+"微笑值:"+strconv.Itoa(int(obj.ThftRes.Smile))+" / "+"颜值:"+strconv.Itoa(int(obj.ThftRes.Beauty))
            lable = sex+"/"+ageDescription+"/"+race+"/"
            lableAttach = strconv.Itoa(int(obj.ThftRes.Age))+"岁"+"/"+"微笑值:"+strconv.Itoa(int(obj.ThftRes.Smile))+"/"+"颜值:"+strconv.Itoa(int(obj.ThftRes.Beauty))
        case "plate":
           // 车牌运动方向,0 unknown, 1 left, 2 right, 3 up, 4 down
            lable = obj.Car.License+" / "+cache.GetDic("nColor"+strconv.Itoa(int(obj.Car.NColor)))+"车牌"+" / "+
                cache.GetDic("nCarColor"+strconv.Itoa(int(obj.Car.NCarColor)))+"车辆"+" / "+ cache.GetDic("nCarLogo"+strconv.Itoa(int(obj.Car.NCarLogo)))+" / "+cache.GetDic("nCarLogo"+strconv.Itoa(int(obj.Car.NCarType)))
            lableAttach = cache.GetDic("nDirection"+strconv.Itoa(int(obj.Car.NDirection)))+" / "+"车牌置信度:"+strconv.Itoa(int(obj.Car.NConfidence))+" / "+
                "车牌亮度:"+strconv.Itoa(int(obj.Car.NBright))+" / "+"车的亮度:"+strconv.Itoa(int(obj.Car.NCarBright))+" / "+"识别时间:"+strconv.Itoa(int(obj.Car.NTime))
            lable = obj.Car.License+"/"+cache.GetDic("nColor"+strconv.Itoa(int(obj.Car.NColor)))+"车牌"+"/"+
                cache.GetDic("nCarColor"+strconv.Itoa(int(obj.Car.NCarColor)))+"车辆"+"/"+ cache.GetDic("nCarLogo"+strconv.Itoa(int(obj.Car.NCarLogo)))+"/"+cache.GetDic("nCarLogo"+strconv.Itoa(int(obj.Car.NCarType)))
            lableAttach = cache.GetDic("nDirection"+strconv.Itoa(int(obj.Car.NDirection)))+"/"+"车牌置信度:"+strconv.Itoa(int(obj.Car.NConfidence))+"/"+
                "车牌亮度:"+strconv.Itoa(int(obj.Car.NBright))+"/"+"车的亮度:"+strconv.Itoa(int(obj.Car.NCarBright))+"/"+"识别时间:"+strconv.Itoa(int(obj.Car.NTime))
    }
    return lable,lableAttach
}
@@ -865,7 +881,7 @@
                    msg.Push.Cam.Addr,
                    msg.Push.Cam.Name,
                    i.Timestamp,
                    "",
                    []string{resp["fileUrl"].(string)},
                    msg.Tasklab.Taskid,
                    msg.Tasklab.Taskname,
                    "人脸",
@@ -874,13 +890,11 @@
                    time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间
                    "",
                    "",
                    []string{resp["fileUrl"].(string)},
                    "",
                    msg.Push.ServerId,
                    msg.Push.ServerName,
                    msg.Push.LocalIp,
                    "",
                    0,
                    isAlarm,
                    0,
                    0,
ruleserver/readyDataForRule.go
@@ -158,7 +158,7 @@
                logger.Error("根据id查询底库信息出错!", err, "--返回值长度为:", len(table))
            }
            logger.Debug("看看这个base的对比值是多少:", Decimal(m[baseinfo.Id].CompareScore))
            base := structure.BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id].CompareScore), PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved}
            base := structure.BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id].CompareScore), TargetId: baseinfo.Id, TargetName: baseinfo.PersonName, TargetPicUrl: baseinfo.PersonPicUrl, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved,DbLabel: baseinfo.PhoneNum+baseinfo.Sex+baseinfo.IdCard,}
            //os.Exit(1)
            arg.Liker = append(arg.Liker, &base)
        }
@@ -246,7 +246,7 @@
            // 这步要备齐表达式里所需要的所有参数
            a.TargetNum++
            uuid := uuid.NewV4().String()
            arg1 := structure.Arg{obj.Id,uuid,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), a.AreaJson,obj.IsYolo, obj.Rects, obj.Car,obj.Feature, obj.ThftRes, []*structure.BaseInfo{},"",structure.ResultMsg{}}
            arg1 := structure.Arg{obj.Id,uuid,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), a.AreaJson,obj.Type, obj.Rects, obj.Car,obj.Feature, obj.ThftRes, []*structure.BaseInfo{},"",structure.ResultMsg{}}
            //logger.Println("放进去的arg:-------", arg1)
            a.Args = append(a.Args, &arg1)
            a.FilterData = append(a.FilterData, &arg1)
structure/rule.go
@@ -121,12 +121,13 @@
    TableName    string  `json:"tableName"`
    BwType       string  `json:"bwType"`
    CompareScore float64 `json:"compareScore"`
    PersonId     string  `json:"personId"`
    PersonName   string  `json:"personName"`
    PersonPicUrl string  `json:"personPicUrl"`
    PhoneNum     string  `json:"phoneNum"`
    Sex          string  `json:"sex"`
    IdCard       string  `json:"idCard"`
    TargetId     string  `json:"targetId"`
    TargetName   string  `json:"targetName"`
    TargetPicUrl string  `json:"targetPicUrl"`
    MonitorLevel string  `json:"monitorLevel"`
    Content      string  `json:"content"`
    DbLabel         string     `json:"dbLabel"`
    //PhoneNum     string  `json:"phoneNum"`
    //Sex          string  `json:"sex"`
    //IdCard       string  `json:"idCard"`
}