From db0724f09b259f4028298e5586fe7baf9f170fa4 Mon Sep 17 00:00:00 2001 From: hoteas <等> Date: Mon, 9 May 2022 19:19:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=94=BF=E7=AD=96=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/app/declare.go | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/example/app/declare.go b/example/app/declare.go index 4e9d677..1926f94 100644 --- a/example/app/declare.go +++ b/example/app/declare.go @@ -13,7 +13,9 @@ func (x paixuArr) Len() int { return len(x) } func (x paixuArr) Less(i, j int) bool { - + if x[i].GetMap("declare") != nil { + return x[i].GetMap("declare").GetFloat64("matching_degree") > x[j].GetMap("declare").GetFloat64("matching_degree") + } return x[i].GetCeilInt64("count") > x[j].GetCeilInt64("count") } func (x paixuArr) Swap(i, j int) { @@ -203,7 +205,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "engineering_center_flag": flagslice}}) for _, v1 := range dtag { @@ -228,7 +230,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "engineering_laboratory_flag": flagslice}}) for _, v1 := range dtag { @@ -252,7 +254,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "key_laboratory_flag": flagslice}}) for _, v1 := range dtag { if declares[v1.GetCeilInt64("declare_id")] == nil { @@ -275,7 +277,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "industrial_design_center_flag": flagslice}}) for _, v1 := range dtag { if declares[v1.GetCeilInt64("declare_id")] == nil { @@ -371,7 +373,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "high_level_talents_flag1": flagslice}}) @@ -639,7 +641,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "engineering_center_flag": flagslice}}) for _, v1 := range dtag { @@ -664,7 +666,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "engineering_laboratory_flag": flagslice}}) for _, v1 := range dtag { @@ -688,7 +690,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "key_laboratory_flag": flagslice}}) for _, v1 := range dtag { if declares[v1.GetCeilInt64("declare_id")] == nil { @@ -711,7 +713,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "industrial_design_center_flag": flagslice}}) for _, v1 := range dtag { if declares[v1.GetCeilInt64("declare_id")] == nil { @@ -807,7 +809,7 @@ var DeclareCtr = Ctr{ } } - if len(flags) > 0 { + if len(flagslice) > 0 { dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "high_level_talents_flag1": flagslice}}) @@ -865,7 +867,7 @@ var DeclareCtr = Ctr{ } //获取到排序后的数据 sort.Sort(px) - var res []Map + res := paixuArr{} //总参数量,除了tag标签 columns := []string{ "loan_flag", "nonlocal_dr_flag", "shareholders_flag", "high_level_talents_flag1", @@ -887,8 +889,11 @@ var DeclareCtr = Ctr{ declare["favorite"] = favorite } matchingDegree := 0 + matchingDegreeCount := 0 for _, v1 := range columns { - + if declare.GetCeilInt(v1) != 0 { + matchingDegreeCount = matchingDegreeCount + 1 + } if declare.GetCeilInt(v1) != 0 && v.GetCeilInt(v1+"_count") != 0 { matchingDegree++ } @@ -899,17 +904,21 @@ var DeclareCtr = Ctr{ RecommendDeclare = declare } - matchingDegreePercent := ObjToFloat64(matchingDegree) / ObjToFloat64(len(columns)) + matchingDegreePercent := ObjToFloat64(matchingDegree) / ObjToFloat64(matchingDegreeCount) if matchingDegreePercent < 0.5 { matchingDegreePercent = 0.5 + matchingDegreePercent } + if matchingDegreePercent == 1 { + matchingDegreePercent = 0.95 + } declare["matching_degree"] = matchingDegreePercent article["declare"] = declare res = append(res, article) } + sort.Sort(res) minMoney := float64(0) maxMoney := float64(0) for _, v := range res {