| | |
| | | package insertdata |
| | | package main |
| | | |
| | | import ( |
| | | "encoding/base64" |
| | | "encoding/json" |
| | | "errors" |
| | | "net" |
| | | "ruleprocess/insertdata" |
| | | "strconv" |
| | | "time" |
| | | |
| | |
| | | rules []structure.Result |
| | | } |
| | | |
| | | func InsertToEs(msg structure.ResultMsg) { |
| | | defer func() { |
| | | if err := recover(); err != nil { |
| | | 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.AIOcean.IndexName + "/" + EsInfo.EsIndex.AIOcean.IndexType+"?refresh=true" |
| | | serverIp = localConfig1.AlarmIp |
| | | serverPort = strconv.Itoa(int(localConfig1.AlarmPort)) |
| | | func InsertToEs(msg structure.ResultMsg,weedfsUrl1,videoPersonUrl1,serverIp1,serverPort1 string){ |
| | | weedfsUrl = weedfsUrl1 |
| | | videoPersonUrl = videoPersonUrl1 |
| | | serverIp = serverIp1 |
| | | serverPort = serverPort1 |
| | | for k,results := range msg.RuleResult { |
| | | if results != nil && len(results.([]structure.Result)) > 0{ |
| | | switch k { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 往es中插入人脸类型数据 |
| | | func InsertFace(msg structure.ResultMsg,key string, results interface{}) { |
| | | logger.Info("往es插入抓拍数据") |
| | |
| | | } |
| | | if key == "track" && len(face.Liker) == 1{ |
| | | esid := face.Liker[0].TargetId |
| | | returnMsg, err1 := esutil.AppendTargetInfo(esid, string(requstbody),EsInfo.EsIndex.AIOcean.IndexName,serverIp,serverPort) |
| | | returnMsg, err1 := esutil.AppendTargetInfo(esid, string(requstbody),structure.EsInfo.EsIndex.AIOcean.IndexName,serverIp,serverPort) |
| | | if err1 != nil { |
| | | logger.Error("追加数据出错!---", err1) |
| | | } else { |
| | |
| | | ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: face.Uuid, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, VideoUrl: msg.Push.VideoUrl, ImgId: i.Id, SdkIds: []string{"-1"}, Type: 1}) |
| | | } |
| | | } else { |
| | | resp1, err1 := EsReq("POST", videoPersonUrl, requstbody) |
| | | resp1, err1 := insertdata.EsReq("POST", videoPersonUrl, requstbody) |
| | | if err1 != nil { |
| | | logger.Error("上传ES出错!---", err1) |
| | | } else { |
| | |
| | | logger.Info("json parse error ", err) |
| | | return |
| | | } |
| | | resp1, err2 := EsReq("POST", videoPersonUrl, requstbody) |
| | | resp1, err2 := insertdata.EsReq("POST", videoPersonUrl, requstbody) |
| | | if err2 != nil { |
| | | logger.Error("往ES插入数据失败", err) |
| | | } else { |
| | |
| | | logger.Info("json parse error ", err) |
| | | return |
| | | } |
| | | resp1, err2 := EsReq("POST", videoPersonUrl, requstbody) |
| | | resp1, err2 := insertdata.EsReq("POST", videoPersonUrl, requstbody) |
| | | if err2 != nil { |
| | | logger.Error("往ES插入数据失败", err) |
| | | } else { |