From 0e669ac6b266466fec8472d02b3ce87134de82a7 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期二, 23 七月 2019 18:52:25 +0800 Subject: [PATCH] 容错5改为3 --- insertdata/insertDataToEs.go | 112 +++++++++++++++++++++++++++++++++----------------------- 1 files changed, 66 insertions(+), 46 deletions(-) diff --git a/insertdata/insertDataToEs.go b/insertdata/insertDataToEs.go index 5384eef..28ccb80 100644 --- a/insertdata/insertDataToEs.go +++ b/insertdata/insertDataToEs.go @@ -19,12 +19,15 @@ "ruleprocess/util" ) -var weedfsUrl,videoPersonUrl,personAction string +var weedfsUrl, videoPersonUrl, personAction string type conf struct { - PhotoUrl string `yaml:"photoUrl"` - Videopersons string `yaml:"videopersons"` - Personaction string `yaml:"personaction"` + PhotoUrl string `yaml:"photoUrl"` + VideoPersons string `yaml:"videoPersons"` + PersonAction string `yaml:"personAction"` + ServerIp string `yaml:"serverIp"` + ServerPort string `yaml:"serverPort"` + DbTablePersons string `yaml:"dbTablePersons"` } func init() { @@ -37,41 +40,41 @@ //鎶妝aml褰㈠紡鐨勫瓧绗︿覆瑙f瀽鎴恠truct绫诲瀷 yaml.Unmarshal(data, &c) weedfsUrl = c.PhotoUrl - videoPersonUrl = c.Videopersons - personAction = c.Personaction + videoPersonUrl = c.VideoPersons + personAction = c.PersonAction } // 浜鸿劯鐨勬暟鎹粨鏋� type PerVideoPicture struct { - Id string `json:"id"` - CameraId string `json:"cameraId"` - CameraAddr string `json:"cameraAddr"` - PicDate string `json:"picDate"` - PicMaxUrl string `json:"picMaxUrl"` - TaskId string `json:"taskId"` - TaskName string `json:"taskName"` - SdkName string `json:"sdkName"` - Content string `json:"content"` - LikeDate string `json:"likeDate"` - Sex string `json:"sex"` - Age int32 `json:"age"` - AgeDescription string `json:"ageDescription"` - Race string `json:"race"` - SmileLevel int32 `json:"smileLevel"` - BeautyLevel int32 `json:"beautyLevel"` - FaceFeature string `json:"faceFeature"` - PicSmUrl []string `json:"picSmUrl"` - 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"` - IsDelete int `json:"isDelete"` - BaseInfo []*ruleserver.BaseInfo`json:"baseInfo"` + Id string `json:"id"` + CameraId string `json:"cameraId"` + CameraAddr string `json:"cameraAddr"` + PicDate string `json:"picDate"` + PicMaxUrl string `json:"picMaxUrl"` + TaskId string `json:"taskId"` + TaskName string `json:"taskName"` + SdkName string `json:"sdkName"` + Content string `json:"content"` + LikeDate string `json:"likeDate"` + Sex string `json:"sex"` + Age int32 `json:"age"` + AgeDescription string `json:"ageDescription"` + Race string `json:"race"` + SmileLevel int32 `json:"smileLevel"` + BeautyLevel int32 `json:"beautyLevel"` + FaceFeature string `json:"faceFeature"` + PicSmUrl []string `json:"picSmUrl"` + 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"` + IsDelete int `json:"isDelete"` + BaseInfo []*ruleserver.BaseInfo `json:"baseInfo"` } // yolo琛屼负鐨勬暟鎹粨鏋� @@ -206,9 +209,13 @@ logger.Info("json parse error ", err) return } - err1 := EsReq("POST", videoPersonUrl, requstbody) + resp1, err1 := EsReq("POST", videoPersonUrl, requstbody) if err1 != nil { logger.Error("涓婁紶ES鍑洪敊锛�---", err1) + } else { + logger.Info("鎻掑叆es杩斿洖鐨勪俊鎭細", resp1) + // 鍙戝嚭褰曞儚淇″彿 + ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: resp1["_id"].(string), CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}}) } } } @@ -275,9 +282,14 @@ logger.Info("json parse error ", err) return } - err1 := EsReq("POST", videoPersonUrl, requstbody) + resp1, err1 := EsReq("POST", videoPersonUrl, requstbody) + if err1 != nil { logger.Error("涓婁紶ES鍑洪敊锛�---", err1) + } else { + logger.Info("鎻掑叆es杩斿洖鐨勪俊鎭細", resp1) + // 鍙戝嚭褰曞儚淇″彿 + ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: resp1["_id"].(string), CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}}) } //if msg.RuleResult["cacheData"] != nil { // InsertFace(msg.RuleResult["cacheData"].(ruleserver.ResultMsg)) @@ -307,7 +319,7 @@ if len(alarmRules) > 0 { isAlarm = 1 //resp, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) - resp, err = util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result),weedfsUrl) + resp, err = util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) if err != nil { logger.Error("鐢绘鎴栦笂浼犲浘鐗囨湇鍔″櫒鍑洪敊", err) } else { @@ -330,6 +342,11 @@ logger.Error("鏌ヨ鎽勫儚鏈轰俊鎭け璐�") } serverIp, err := GetLocalIP() + if msg.RuleResult["cacheData"] != nil { + InsertYolo(msg.RuleResult["cacheData"].(ruleserver.ResultMsg)) + // 鎶婄紦瀛樼殑鏁版嵁涓婁紶鍚庡緱鍒板湴鍧�瀛樿繘鍘� + + } peraction := Personaction{ uuid.NewV4().String(), msg.Cid, @@ -359,15 +376,15 @@ return } - err = EsReq("POST", personAction, requstbody) - if err != nil { + resp1, err2 := EsReq("POST", personAction, requstbody) + if err2 != nil { logger.Error("寰�ES鎻掑叆鏁版嵁澶辫触", err) } else { + logger.Debug("鎻掑叆es杩斿洖鐨勬暟鎹俊鎭槸锛�", resp1) + // 鍙戝嚭褰曞儚淇″彿 + ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: resp1["_id"].(string), CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}}) logger.Warn("__________________________________________寰�ES鎻掑叆yolo鏁版嵁鎴愬姛") //os.Exit(1) - } - if msg.RuleResult["cacheData"] != nil { - InsertYolo(msg.RuleResult["cacheData"].(ruleserver.ResultMsg)) } } } @@ -382,7 +399,7 @@ i := protomsg.Image{} err = proto.Unmarshal(bdata, &i) //resp, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) - resp, err := util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result),weedfsUrl) + resp, err := util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) if err != nil { logger.Error("鐢绘鎴栦笂浼犲浘鐗囨湇鍔″櫒鍑洪敊", err) } else { @@ -429,10 +446,13 @@ return } - err = EsReq("POST", personAction, requstbody) - if err != nil { + resp1, err1 := EsReq("POST", personAction, requstbody) + if err1 != nil { logger.Error("寰�ES鎻掑叆鏁版嵁澶辫触", err) } else { + logger.Info("鎻掑叆es杩斿洖鐨勪俊鎭細", resp1) + // 鍙戝嚭褰曞儚淇″彿 + ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: resp1["_id"].(string), CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}}) logger.Warn("__________________________________________寰�ES鎻掑叆yolo鏁版嵁鎴愬姛") //os.Exit(1) } -- Gitblit v1.8.0