forked from golang/hotime
对政策匹配进行优化
This commit is contained in:
parent
c1b013c926
commit
db0724f09b
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user