From 4a602df833134331ff5f330c45c5c27cf56b9b3e Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期四, 12 九月 2019 15:02:07 +0800 Subject: [PATCH] fix分值莫名除了10 --- insertdata/insertDataToEs.go | 112 +++++++++++++++++++++++++++++-------------------------- 1 files changed, 59 insertions(+), 53 deletions(-) diff --git a/insertdata/insertDataToEs.go b/insertdata/insertDataToEs.go index 07614d8..4b57f9a 100644 --- a/insertdata/insertDataToEs.go +++ b/insertdata/insertDataToEs.go @@ -9,7 +9,7 @@ "net" "ruleprocess/cache" "ruleprocess/logger" - "strings" + "strconv" "time" "basic.com/pubsub/protomsg.git" @@ -205,8 +205,9 @@ if err != nil { logger.Error("涓婁紶灏忓浘鍑洪敊") } - logger.Info("================灏忓浘鍦板潃:", resp["fileUrl"].(string)) + //logger.Info("================灏忓浘鍦板潃:", resp["fileUrl"].(string)) sex := "" + logger.Info(sex) if face.ThftRes.Gender == 1 { sex = "鐢�" } else { @@ -214,31 +215,34 @@ } race := getRaceString(face.ThftRes.Race) ageDescription := getDescription(face.ThftRes.Age) + logger.Info(ageDescription) esDataId := uuid.NewV4().String() linksId := "" if linkId != "" { linksId = linkId } + logger.Info("浜鸿劯鐨刬d:",strconv.FormatUint(face.Id, 10)) + logger.Info("浜鸿劯鐨勫垎鍊硷細",face.Score) pervideo := PerVideoPicture{ esDataId, msg.Cid, camera.Addr, i.Timestamp, - strings.Split(bigPhotoUrl["fileUrl"].(string), "/")[1], + bigPhotoUrl["fileUrl"].(string), msg.Tasklab.Taskid, msg.Tasklab.Taskname, "浜鸿劯", "", alarmRules, time.Now().Format("2006-01-02 15:04:05"), // 鍙娴嬶紝娌℃湁姣斿鏃堕棿 - sex, + strconv.FormatUint(face.Id, 10), //鏆傛敼涓轰汉鑴竔d face.ThftRes.Age, - ageDescription, + fmt.Sprintf("%.2f",face.Score), // 鏆傛敼涓哄垎鍊� race, face.ThftRes.Smile, face.ThftRes.Beauty, base64.StdEncoding.EncodeToString(face.Feature), - []string{strings.Split(resp["fileUrl"].(string), "/")[1]}, + []string{resp["fileUrl"].(string)}, "鏆傛棤闆嗙兢", localConfig.ServerId, localConfig.ServerName, @@ -362,7 +366,7 @@ } else { logger.Info("涓婁紶鐨勫浘鐗囦俊鎭細", resp1) } - url = append(url, strings.Split(resp1["fileUrl"].(string), "/")[1]) + url = append(url, resp1["fileUrl"].(string)) } } } @@ -400,6 +404,7 @@ resp, err = util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) if err != nil { logger.Error("鐢绘鎴栦笂浼犲浘鐗囨湇鍔″櫒鍑洪敊", err) + return } else { logger.Info("涓婁紶鐨勫浘鐗囦俊鎭細", resp) } @@ -420,52 +425,53 @@ logger.Error("鏌ヨ鎽勫儚鏈轰俊鎭け璐�") } serverIp, err := GetLocalIP() + if resp["fileUrl"] != nil { + url = append(url, resp["fileUrl"].(string)) + esDataId := uuid.NewV4().String() + linksId := "" + if linkId != "" { + linksId = linkId + } + peraction := Personaction{ + esDataId, + msg.Cid, + camera.Name, + camera.Addr, + msg.Tasklab.Taskid, + msg.Tasklab.Taskname, + sdkNames, + "", + alarmRules, + localConfig.ServerId, + localConfig.ServerName, + serverIp, + "", + url, + i.Timestamp, + linksId, + "", + isAlarm, + 0, + 0, + 0, + } + requstbody, err := json.Marshal(peraction) - url = append(url, strings.Split(resp["fileUrl"].(string), "/")[1]) - esDataId := uuid.NewV4().String() - linksId := "" - if linkId != "" { - linksId = linkId - } - peraction := Personaction{ - esDataId, - msg.Cid, - camera.Name, - camera.Addr, - msg.Tasklab.Taskid, - msg.Tasklab.Taskname, - sdkNames, - "", - alarmRules, - localConfig.ServerId, - localConfig.ServerName, - serverIp, - "", - url, - i.Timestamp, - linksId, - "", - isAlarm, - 0, - 0, - 0, - } - requstbody, err := json.Marshal(peraction) + if err != nil { + logger.Info("json parse error ", err) + return - if err != nil { - logger.Info("json parse error ", err) - return - - } - resp1, err2 := EsReq("POST", personAction, requstbody) - if err2 != nil { - logger.Error("寰�ES鎻掑叆鏁版嵁澶辫触", err) - } else { - logger.Debug("鎻掑叆es杩斿洖鐨勬暟鎹俊鎭槸锛�", resp1) - // 鍙戝嚭褰曞儚淇″彿 - ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: esDataId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}, Type: 2}) - logger.Warn("__________________________________________寰�ES鎻掑叆yolo鏁版嵁鎴愬姛") - //os.Exit(1) + } + resp1, err2 := EsReq("POST", personAction, requstbody) + if err2 != nil { + logger.Error("寰�ES鎻掑叆鏁版嵁澶辫触", err) + } else { + logger.Debug("鎻掑叆es杩斿洖鐨勬暟鎹俊鎭槸锛�", resp1) + // 鍙戝嚭褰曞儚淇″彿 + ruleserver.AddLxMessage(&protomsg.VideotapeInfo{EsDataId: esDataId, CameraId: msg.Cid, TaskId: msg.Tasklab.Taskid, ImgId: i.Id, SdkIds: []string{}, Type: 2}) + logger.Warn("__________________________________________寰�ES鎻掑叆yolo鏁版嵁鎴愬姛") + //os.Exit(1) + } } } else { logger.Debug("timeLabel鏉′欢閮戒笉绗﹀悎锛�") @@ -516,7 +522,7 @@ localConfig.ServerName, serverIp, "", - []string{strings.Split(resp["fileUrl"].(string), "/")[1]}, + []string{resp["fileUrl"].(string)}, i.Timestamp, "", "", @@ -574,7 +580,7 @@ msg.Cid, camera.Addr, i.Timestamp, - strings.Split(bigPhotoUrl["fileUrl"].(string), "/")[1], + bigPhotoUrl["fileUrl"].(string), msg.Tasklab.Taskid, msg.Tasklab.Taskname, "浜鸿劯", -- Gitblit v1.8.0