From 033f6617f74471a8178c4375f2034504ba3de421 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期三, 03 七月 2019 14:37:11 +0800 Subject: [PATCH] 一些string变为int --- insertdata/insertDataToEs.go | 79 +++++++++++++++++++++++++++++---------- 1 files changed, 59 insertions(+), 20 deletions(-) diff --git a/insertdata/insertDataToEs.go b/insertdata/insertDataToEs.go index c16d36b..d50c5c3 100644 --- a/insertdata/insertDataToEs.go +++ b/insertdata/insertDataToEs.go @@ -30,10 +30,10 @@ SdkName string `json:"sdkName"` Content string `json:"content"` LikeDate string `json:"likeDate"` - Sex int32 `json:"sex"` + Sex string `json:"sex"` Age int32 `json:"age"` AgeDescription string `json:"ageDescription"` - Race int32 `json:"race"` + Race string `json:"race"` SmileLevel int32 `json:"smileLevel"` BeautyLevel int32 `json:"beautyLevel"` FaceFeature string `json:"faceFeature"` @@ -43,9 +43,9 @@ AnalyServerName string `json:"analyServerName"` AnalyServerIp string `json:"analyServerIp"` ClusterId string `json:"clusterId"` - IsAlarm string `json:"isAlarm"` - IsAckAlarm string `json:"isAckAlarm"` - IsCollect string `json:"isCollect"` + IsAlarm int `json:"isAlarm"` + IsAckAlarm int `json:"isAckAlarm"` + IsCollect int `json:"isCollect"` IsDelete int `json:"isDelete"` BaseInfo []Base `json:"baseInfo"` } @@ -82,9 +82,9 @@ PicSmUrl []string `json:"picSmUrl"` PicDate string `json:"picDate"` VideoUrl string `json:"videoUrl"` - IsAlarm string `json:"isAlarm"` - IsAckAlarm string `json:"isAckAlarm"` - IsCollect string `json:"isCollect"` + IsAlarm int `json:"isAlarm"` + IsAckAlarm int `json:"isAckAlarm"` + IsCollect int `json:"isCollect"` IsDelete int `json:"isDelete"` } @@ -131,11 +131,21 @@ } i := protomsg.Image{} err = proto.Unmarshal(bdata, &i) + log.Println("-------------------------------------------鐪嬩笅瀹藉拰楂�", i.Width, i.Height) bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height)) resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String()) if err != nil { log.Println("涓婁紶灏忓浘鍑洪敊") } + sex := "" + if face.ThftRes.Gender == 1 { + sex = "鐢�" + } else { + sex = "濂�" + } + race := getRaceString(face.ThftRes.Race) + ageDescription := getDescription(face.ThftRes.Age) + pervideo := PerVideoPicture{ uuid.NewV4().String(), msg.Cid, @@ -147,10 +157,10 @@ "浜鸿劯", "", time.Now().Format("2006-01-02 15:04:05"), // 鍙娴嬶紝娌℃湁姣斿鏃堕棿 - face.ThftRes.Gender, + sex, face.ThftRes.Age, - "", - face.ThftRes.Race, + ageDescription, + race, face.ThftRes.Smile, face.ThftRes.Beauty, "涓嶆槸姣忎釜浜鸿劯绠楁硶閮芥湁", @@ -160,9 +170,9 @@ localConfig.ServerName, serverIp, "", - "", - "", - "", + 1, + 0, + 0, 0, []Base{}, } @@ -189,10 +199,10 @@ alarm := ChangeToString(yoloResult.AlarmLevel) alarmRules = append(alarmRules, AlarmRule{yoloResult.RuleGroupId, alarm, yoloResult.RuleText}) } - isAlarm := "" + isAlarm := 0 resp := make(map[string]interface{}) if len(alarmRules) > 0 { - isAlarm = "1" + isAlarm = 1 // 瑙e帇缂╁苟涓婁紶鍥剧墖 bdata, err := util.UnCompress(msg.Data) if err != nil { @@ -208,7 +218,7 @@ log.Println("宸叉姤璀﹀苟涓婁紶鏀瑰抚鍥剧墖鍒版湇鍔″櫒") } } else { - isAlarm = "0" + isAlarm = 0 // 涓嶆槸鎶ヨ鏁版嵁涓嶅瓨 return } @@ -242,8 +252,8 @@ time.Now().Format("2006-01-02 15:04:05"), "", isAlarm, - "", - "", + 0, + 0, 0, } requstbody, err := json.Marshal(peraction) @@ -257,7 +267,7 @@ if err != nil { log.Println("寰�ES鎻掑叆鏁版嵁澶辫触", err) } else { - log.Println("__________________________________________寰�ES鎻掑叆鏁版嵁yolo鎴愬姛") + log.Println("__________________________________________寰�ES鎻掑叆yolo鏁版嵁鎴愬姛") } } } @@ -310,3 +320,32 @@ } return alarm } + +//鑾峰彇骞撮緞鎻忚堪 +func getDescription(age int32) string { + ageInfo := "闈掑勾" + if age > 0 && age < 7 { + ageInfo = "绔ュ勾" + } else if age >= 7 && age < 18 { + ageInfo = "灏戝勾" + } else if age >= 18 && age < 40 { + ageInfo = "闈掑勾" + } else if age >= 40 && age < 65 { + ageInfo = "涓勾" + } else if age >= 65 { + ageInfo = "鑰佸勾" + } + return ageInfo +} + +func getRaceString(i int32) string { + race := "" + if i == 1 { + race = "鐧戒汉" + } else if i == 2 { + race = "榛勪汉" + } else { + race = "榛戜汉" + } + return race +} -- Gitblit v1.8.0