对政策匹配进行优化

This commit is contained in:
hoteas 2022-05-09 15:07:01 +08:00
parent b48ad793da
commit c1b013c926
8 changed files with 768 additions and 47 deletions

View File

@ -10,6 +10,10 @@ import (
var CompanyCtr = Ctr{
"search": func(that *Context) {
if that.Session("user_id").Data == nil {
that.Display(2, "没有登录")
return
}
keywords := that.Req.FormValue("keywords")
if keywords == "" {
keywords = that.Req.FormValue("company_name")
@ -37,4 +41,79 @@ var CompanyCtr = Ctr{
that.Display(0, res.GetMap("data").GetSlice("list"))
},
"search_info": func(that *Context) {
if that.Session("user_id").Data == nil {
that.Display(2, "没有登录")
return
}
name := that.Req.FormValue("name")
if len(name) < 2 {
that.Display(3, "找不到企业")
return
}
res, err := aliyun.Company.GetCompanyBaseInfo(name)
if err != nil {
fmt.Println(err)
that.Display(4, "查询失败")
return
}
if res.GetBool("status") != true {
fmt.Println(err)
that.Display(4, "查询失败")
return
}
that.Display(0, res.GetMap("data"))
},
"info": func(that *Context) {
if that.Session("user_id").Data == nil {
that.Display(2, "没有登录")
return
}
id := ObjToInt(that.Req.FormValue("id"))
if id == 0 {
that.Display(3, "请求参数异常")
return
}
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").Data})
if user == nil {
that.Display(4, "找不到用户")
return
}
res := that.Db.Get("company", "*", Map{"id": user.GetCeilInt("company_id")})
if res == nil {
that.Display(4, "找不到企业")
return
}
//先不做限制
//if res.GetCeilInt("salesman_id")!=that.Session("salesman_id").ToCeilInt(){
// that.Display(4,"不是你的企业")
// return
//}
//res["technology_center_flag"] = ObjToSlice(res["technology_center_flag"])
//res["engineering_center_flag"] = ObjToSlice(res["engineering_center_flag"])
//res["engineering_laboratory_flag"] = ObjToSlice(res["engineering_laboratory_flag"])
//res["key_laboratory_flag"] = ObjToSlice(res["key_laboratory_flag"])
//res["industrial_design_center_flag"] = ObjToSlice(res["industrial_design_center_flag"])
//
//res["high_level_talents_flag1"] = ObjToSlice(res["high_level_talents_flag1"])
//
//res["tags"] = ObjToSlice(res["tags"])
res["technology_center_flag"] = strToArray(res.GetString("technology_center_flag"))
res["engineering_center_flag"] = strToArray(res.GetString("engineering_center_flag"))
res["engineering_laboratory_flag"] = strToArray(res.GetString("engineering_laboratory_flag"))
res["key_laboratory_flag"] = strToArray(res.GetString("key_laboratory_flag"))
res["industrial_design_center_flag"] = strToArray(res.GetString("industrial_design_center_flag"))
res["high_level_talents_flag1"] = strToArray(res.GetString("high_level_talents_flag1"))
res["tags"] = strToArray(res.GetString("tags"))
that.Display(0, res)
},
}

View File

@ -108,27 +108,30 @@ var DeclareCtr = Ctr{
delete(company, "create_time")
delete(company, "modify_time")
data := Map{}
for k, _ := range company {
if k == "high_level_talents_flag1" && that.Req.FormValue("highLevel_talents_flag") != "" {
that.Req.Form[k] = that.Req.Form["highLevel_talents_flag"]
}
if that.Req.Form[k] != nil {
if k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" {
if k == "tags" || k == "high_level_talents_flag1" || k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" {
data[k] = ObjToStr(that.Req.Form[k])
} else {
data[k] = that.Req.FormValue(k)
}
}
}
//如果企业名称相同则允许变更企业信息
if companyName == company.GetString("name") {
that.Db.Update("company", company, Map{"user_id": that.Session("user_id").Data})
that.Db.Update("company", data, Map{"user_id": that.Session("user_id").Data})
}
if companyName != company.GetString("name") {
//扫码绑定后,第一次使用匹配功能,自动进行认证,并更新企业信息
if user.GetCeilInt("certification_flag") == 0 && user.GetCeilInt64("salesman_id") != 0 {
that.Db.Update("user", Map{"certification_flag": 1}, Map{"id": user.GetCeilInt("id")})
company["name"] = companyName
that.Db.Update("company", company, Map{"user_id": that.Session("user_id").Data})
that.Db.Update("company", data, Map{"user_id": that.Session("user_id").Data})
}
//其余情况,不存储数据
}
@ -200,6 +203,7 @@ var DeclareCtr = Ctr{
}
}
if len(flags) > 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 {
@ -210,6 +214,7 @@ var DeclareCtr = Ctr{
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["engineering_center_flag_count"] = 1
}
}
//是否是有效期内的工程实验室称号:0-否,1-市级,2-省级,3-国家级
flags = that.Req.Form["engineering_laboratory_flag"]
@ -223,6 +228,7 @@ var DeclareCtr = Ctr{
}
}
if len(flags) > 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 {
@ -233,7 +239,7 @@ var DeclareCtr = Ctr{
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["engineering_laboratory_flag_count"] = 1
}
}
//是否是有效期内的重点实验室称号:0-否,1-市级,2-省级,3-国家级
flags = that.Req.Form["key_laboratory_flag"]
flagslice = Slice{}
@ -246,6 +252,7 @@ var DeclareCtr = Ctr{
}
}
if len(flags) > 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 {
@ -254,6 +261,7 @@ var DeclareCtr = Ctr{
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["key_laboratory_flag_count"] = 1
}
}
//是否是有效期内的工业设计中心称号:0-否,1-市级,2-省级,3-国家级
flags = that.Req.Form["industrial_design_center_flag"]
@ -267,6 +275,7 @@ var DeclareCtr = Ctr{
}
}
if len(flags) > 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 {
@ -275,6 +284,7 @@ var DeclareCtr = Ctr{
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["industrial_design_center_flag_count"] = 1
}
}
//上年度有无研发投入:0-否,1-是
if ObjToInt(that.Req.FormValue("research_input_flag")) > 0 {
@ -327,15 +337,55 @@ var DeclareCtr = Ctr{
}
}
//高层次人才情况:0-否,1-3个及以上博士-1,2-1个及以上博士-2,3-知名企业中高管1个及以上
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_flag": ObjToInt(that.Req.FormValue("high_level_talents_flag"))}})
//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": ObjToInt(that.Req.FormValue("high_level_talents_flag1"))}})
//for _, v1 := range dtag {
//
// if declares[v1.GetCeilInt64("declare_id")] == nil {
// declares[v1.GetCeilInt64("declare_id")] = v1
// }
// declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
// declares[v1.GetCeilInt64("declare_id")]["high_level_talents_flag1_count"] = 1
//}
//
//
//flags := that.Req.Form["engineering_center_flag"]
//flagslice := Slice{}
//if flags != nil {
// for _, v := range flags {
// if v == "0" {
// continue
// }
// flagslice = append(flagslice, v)
// }
//
//}
//高层次人才情况:0-否,1-3个及以上博士-1,2-1个及以上博士-2,3-知名企业中高管1个及以上
flags = that.Req.Form["high_level_talents_flag1"]
flagslice = Slice{}
if flags != nil {
for _, v := range flags {
if v == "0" {
continue
}
flagslice = append(flagslice, v)
}
}
if len(flags) > 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}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["high_level_talents_flag_count"] = 1
declares[v1.GetCeilInt64("declare_id")]["high_level_talents_flag1"] = 1
}
}
//企业股东或成员是否有国内外高校或科研院在编、全职人员:0-否,1-是
if ObjToInt(that.Req.FormValue("shareholders_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "shareholders_flag": ObjToInt(that.Req.FormValue("shareholders_flag"))}})
@ -423,6 +473,485 @@ var DeclareCtr = Ctr{
that.Display(0, res)
},
//政策匹配
"match_v2": func(that *Context) {
if that.Session("user_id").Data == nil {
that.Display(2, "没有登录")
return
}
user := that.Db.Get("user", "*", Map{"id": that.Session("user_id").Data})
if user == nil {
that.Display(4, "找不到用户")
return
}
//消除company没有创建的影响
if user.GetCeilInt("company_id") == 0 {
companyId := that.Db.Insert("company", Map{
"user_id": user["id"],
"create_time[#]": "now()",
"modify_time[#]": "now()",
"del_flag": 0,
})
user["company_id"] = companyId
that.Db.Update("user", Map{"company_id": companyId}, Map{"id": user.GetCeilInt("id")})
}
companyName := that.Req.FormValue("company_name")
if companyName == "" {
that.Display(3, "参数错误")
return
}
qu := that.Req.FormValue("register_address")
qus := strings.Split(qu, "/")
for _, v := range qus {
if v != "" {
qu = v
}
}
if !strings.Contains(qu, "区") && !strings.Contains(qu, "县") {
qu = "没有此项数据随意填充的"
}
company := that.Db.Get("company", "*", Map{"id": user.GetCeilInt("company_id")})
//消除company没有创建的影响
if company == nil {
companyId := that.Db.Insert("company", Map{
"user_id": user["id"],
"create_time[#]": "now()",
"modify_time[#]": "now()",
"provider_id": user["provider_id"],
"salesman_id": user["salesman_id"],
"del_flag": 0,
})
user["company_id"] = companyId
that.Db.Update("user", Map{"company_id": companyId}, Map{"id": user.GetCeilInt("id")})
company = that.Db.Get("company", "*", Map{"id": user.GetCeilInt("company_id")})
}
delete(company, "id")
delete(company, "salesman_id")
delete(company, "provider_id")
delete(company, "user_id")
delete(company, "del_flag")
delete(company, "state")
delete(company, "create_time")
delete(company, "modify_time")
data := Map{}
for k, _ := range company {
if k == "high_level_talents_flag1" && that.Req.FormValue("highLevel_talents_flag") != "" {
that.Req.Form[k] = that.Req.Form["highLevel_talents_flag"]
}
if that.Req.Form[k] != nil {
if k == "tags" || k == "high_level_talents_flag1" || k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" {
//data[k] = ObjToStr(that.Req.Form[k])
data[k] = arrayToStr(ObjToSlice(that.Req.Form[k]))
} else {
data[k] = that.Req.FormValue(k)
}
}
}
//如果企业名称相同则允许变更企业信息
if companyName == company.GetString("name") || company.GetString("name") == "" {
that.Db.Update("company", data, Map{"user_id": that.Session("user_id").Data})
}
if companyName != company.GetString("name") {
//扫码绑定后,第一次使用匹配功能,自动进行认证,并更新企业信息
if (user.GetCeilInt("certification_flag") == 0 || company.GetString("name") == "") && user.GetCeilInt64("salesman_id") != 0 {
that.Db.Update("user", Map{"certification_flag": 1}, Map{"id": user.GetCeilInt("id")})
company["name"] = companyName
that.Db.Update("company", data, Map{"user_id": that.Session("user_id").Data})
}
//其余情况,不存储数据
}
tags := that.Req.Form["tags"]
declares := map[int64]Map{}
//标签分析
if tags != nil {
for _, v := range tags {
dtag := that.Db.Select("declare_tag", Map{"[><]declare": "declare_tag.declare_id=declare.id"}, "declare_tag.declare_id", Map{"AND": Map{"OR": Map{"declare.policy_level": Slice{"省", "市"}, "declare.dispatch_department[~]": qu}, "declare_tag.tag_id": v}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["tag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("tag_count") + 1
}
}
}
//企业规模分析
dtag := that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "company_scale[<=]": ObjToInt(that.Req.FormValue("company_scale"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["company_scale_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("company_scale_count") + 1
}
//是否是有效期内的科技型中小企业称号:0-否,1-是
if ObjToInt(that.Req.FormValue("smes_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "smes_flag": ObjToInt(that.Req.FormValue("smes_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["smes_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("smes_flag_count") + 1
}
}
//是否是有效期内的高新区技术企业称号:0-否,1-是
if ObjToInt(that.Req.FormValue("htzte_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "htzte_flag": ObjToInt(that.Req.FormValue("htzte_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["htzte_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("htzte_flag_count") + 1
}
}
//是否是有效期内的工程中心称号:0-否,1-市级,2-省级,3-国家级
flags := that.Req.Form["engineering_center_flag"]
flagslice := Slice{}
if flags != nil {
for _, v := range flags {
if v == "0" {
continue
}
flagslice = append(flagslice, v)
}
}
if len(flags) > 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 {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["engineering_center_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("engineering_center_flag_count") + 1
}
}
//是否是有效期内的工程实验室称号:0-否,1-市级,2-省级,3-国家级
flags = that.Req.Form["engineering_laboratory_flag"]
flagslice = Slice{}
if flags != nil {
for _, v := range flags {
if v == "0" {
continue
}
flagslice = append(flagslice, v)
}
}
if len(flags) > 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 {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["engineering_laboratory_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("engineering_laboratory_flag_count") + 1
}
}
//是否是有效期内的重点实验室称号:0-否,1-市级,2-省级,3-国家级
flags = that.Req.Form["key_laboratory_flag"]
flagslice = Slice{}
if flags != nil {
for _, v := range flags {
if v == "0" {
continue
}
flagslice = append(flagslice, v)
}
}
if len(flags) > 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 {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["key_laboratory_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("key_laboratory_flag_count") + 1
}
}
//是否是有效期内的工业设计中心称号:0-否,1-市级,2-省级,3-国家级
flags = that.Req.Form["industrial_design_center_flag"]
flagslice = Slice{}
if flags != nil {
for _, v := range flags {
if v == "0" {
continue
}
flagslice = append(flagslice, v)
}
}
if len(flags) > 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 {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["industrial_design_center_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("industrial_design_center_flag_count") + 1
}
}
//上年度有无研发投入:0-否,1-是
if ObjToInt(that.Req.FormValue("research_input_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"del_flag": 0, "research_input_flag": ObjToInt(that.Req.FormValue("research_input_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["research_input_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("research_input_flag_count") + 1
}
}
//有无授权发明专利:0-否,1-是
if ObjToInt(that.Req.FormValue("invention_patent_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "invention_patent_flag": ObjToInt(that.Req.FormValue("invention_patent_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["invention_patent_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("invention_patent_flag_count") + 1
}
}
//有无国际科技合作:0-否,1-是
if ObjToInt(that.Req.FormValue("international_cooperation_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "international_cooperation_flag": ObjToInt(that.Req.FormValue("international_cooperation_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["international_cooperation_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("international_cooperation_flag_count") + 1
}
}
//上年度有无固定资产投入:0-否,1-是
if ObjToInt(that.Req.FormValue("investment_fixed_assets_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "investment_fixed_assets_flag": ObjToInt(that.Req.FormValue("investment_fixed_assets_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["investment_fixed_assets_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("investment_fixed_assets_flag_count") + 1
}
}
//高层次人才情况:0-否,1-3个及以上博士-1,2-1个及以上博士-2,3-知名企业中高管1个及以上
//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": ObjToInt(that.Req.FormValue("high_level_talents_flag1"))}})
//for _, v1 := range dtag {
//
// if declares[v1.GetCeilInt64("declare_id")] == nil {
// declares[v1.GetCeilInt64("declare_id")] = v1
// }
// declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
// declares[v1.GetCeilInt64("declare_id")]["high_level_talents_flag1_count"] = 1
//}
//
//
//flags := that.Req.Form["engineering_center_flag"]
//flagslice := Slice{}
//if flags != nil {
// for _, v := range flags {
// if v == "0" {
// continue
// }
// flagslice = append(flagslice, v)
// }
//
//}
//高层次人才情况:0-否,1-3个及以上博士-1,2-1个及以上博士-2,3-知名企业中高管1个及以上
flags = that.Req.Form["high_level_talents_flag1"]
flagslice = Slice{}
if flags != nil {
for _, v := range flags {
if v == "0" {
continue
}
flagslice = append(flagslice, v)
}
}
if len(flags) > 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}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["high_level_talents_flag1_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("high_level_talents_flag1_count") + 1
}
}
//企业股东或成员是否有国内外高校或科研院在编、全职人员:0-否,1-是
if ObjToInt(that.Req.FormValue("shareholders_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "shareholders_flag": ObjToInt(that.Req.FormValue("shareholders_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["shareholders_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("shareholders_flag_count") + 1
}
}
//企业有无从外地引进博士学历人才:0-否,1-是
if ObjToInt(that.Req.FormValue("nonlocal_dr_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "nonlocal_dr_flag": ObjToInt(that.Req.FormValue("nonlocal_dr_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["nonlocal_dr_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("nonlocal_dr_flag_count") + 1
}
}
//上年度是否有贷款/融资或未来有贷款/融资计划:0-否,1-是
if ObjToInt(that.Req.FormValue("loan_flag")) > 0 {
dtag = that.Db.Select("declare", "id AS declare_id", Map{"AND": Map{"OR": Map{"policy_level": Slice{"省", "市"}, "dispatch_department[~]": qu}, "del_flag": 0, "loan_flag": ObjToInt(that.Req.FormValue("loan_flag"))}})
for _, v1 := range dtag {
if declares[v1.GetCeilInt64("declare_id")] == nil {
declares[v1.GetCeilInt64("declare_id")] = v1
}
declares[v1.GetCeilInt64("declare_id")]["count"] = declares[v1.GetCeilInt64("declare_id")].GetCeilInt64("count") + 1
declares[v1.GetCeilInt64("declare_id")]["loan_flag_count"] = declares[v1.GetCeilInt64("declare_id")].GetInt64("loan_flag_count") + 1
}
}
px := paixuArr{}
for _, v := range declares {
px = append(px, v)
}
//获取到排序后的数据
sort.Sort(px)
var res []Map
//总参数量除了tag标签
columns := []string{
"loan_flag", "nonlocal_dr_flag", "shareholders_flag", "high_level_talents_flag1",
"investment_fixed_assets_flag", "international_cooperation_flag", "invention_patent_flag",
"research_input_flag", "industrial_design_center_flag", "key_laboratory_flag",
"engineering_laboratory_flag", "engineering_center_flag", "htzte_flag",
"smes_flag", "company_scale"}
RecommendValue := 0
RecommendDeclare := Map{}
for _, v := range px {
id := v.GetCeilInt("declare_id")
article := that.Db.Get("article", "id,title,description,department_id,click_num+click_num_base AS click_num,"+
"favorite_num_base+favorite_num AS favorite_num,dispatch_num,dispatch_name,prepare_date,release_time,expire_date,area_id,status,declare_id,declare_id,declare_id", Map{"declare_id": id})
declare := that.Db.Get("declare", "*", Map{"id": id})
//查询是否已关注
if that.Session("user_id").Data != nil {
favorite := that.Db.Get("favorite", "user_id,declare_id", Map{"AND": Map{"declare_id": id, "user_id": that.Session("user_id").ToCeilInt(), "del_flag": 0}})
declare["favorite"] = favorite
}
matchingDegree := 0
for _, v1 := range columns {
if declare.GetCeilInt(v1) != 0 && v.GetCeilInt(v1+"_count") != 0 {
matchingDegree++
}
}
if RecommendValue < matchingDegree {
RecommendValue = matchingDegree
RecommendDeclare = declare
}
matchingDegreePercent := ObjToFloat64(matchingDegree) / ObjToFloat64(len(columns))
if matchingDegreePercent < 0.5 {
matchingDegreePercent = 0.5 + matchingDegreePercent
}
declare["matching_degree"] = matchingDegreePercent
article["declare"] = declare
res = append(res, article)
}
minMoney := float64(0)
maxMoney := float64(0)
for _, v := range res {
if v.GetMap("declare") != nil {
if v.GetMap("declare").GetFloat64("money_scope_min") < minMoney {
minMoney = v.GetMap("declare").GetFloat64("money_scope_min")
}
if v.GetMap("declare").GetFloat64("money_scope_max") > maxMoney {
maxMoney = v.GetMap("declare").GetFloat64("money_scope_max")
}
}
}
seData := Map{
"user_id": that.Session("user_id").Data,
"search_company_name": companyName,
"policy_match_count": len(res),
"json_data": ObjToStr(company),
"create_time[#]": "now()",
"modify_time[#]": "now()",
"del_flag": 0,
}
if maxMoney != minMoney {
seData["money_scope"] = ObjToStr(ObjToInt(minMoney)) + "-" + ObjToStr(ObjToInt(maxMoney)) + ""
} else if maxMoney == 0 {
seData["money_scope"] = ""
} else {
seData["money_scope"] = ObjToStr(ObjToInt(maxMoney)) + ""
}
//匹配记录存储
that.Db.Insert("search_record", seData)
re := Map{"recomend": RecommendDeclare, "count": len(res), "data": res}
//company,e:=aliyun.Company.GetCompanyBaseInfo(companyName)
//if e==nil{
// re["company"]=
//}
that.Display(0, re)
},
//用户微信公众号或者小程序登录
"search": func(that *Context) {

View File

@ -4,6 +4,7 @@ import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"errors"
"strings"
"time"
"unicode/utf8"
)
@ -46,6 +47,29 @@ func getCode() string {
return res
}
func strToArray(str string) Slice {
s := Slice{}
olds := strings.Split(str, ",")
for _, v := range olds {
if v != "" {
s = append(s, v)
}
}
return s
}
func arrayToStr(ars Slice) string {
s := ","
if ars == nil {
return s
}
for k, _ := range ars {
s = s + ars.GetString(k) + ","
}
return s
}
//认证公共方案
func auth(that *Context, phone, companyName, userName string) error {

View File

@ -110,6 +110,21 @@ var Wechath5 = Ctr{
}
delete(user, "password")
company := that.Db.Get("company", "id,name", Map{"id": user.GetCeilInt("company_id")})
//消除company没有创建的影响
if company == nil {
companyId := that.Db.Insert("company", Map{
"user_id": user["id"],
"provider_id": user["provider_id"],
"salesman_id": user["salesman_id"],
"create_time[#]": "now()",
"modify_time[#]": "now()",
"del_flag": 0,
})
user["company_id"] = companyId
that.Db.Update("user", Map{"company_id": companyId}, Map{"id": user.GetCeilInt("id")})
company = that.Db.Get("company", "*", Map{"id": user.GetCeilInt("company_id")})
}
salesman := that.Db.Get("salesman", "id,name", Map{"id": user.GetCeilInt("salesman_id")})
provider := that.Db.Get("provider", "id,name", Map{"id": user.GetCeilInt("provider_id")})

View File

@ -25,7 +25,7 @@
"db": {
"mysql": {
"host": "192.168.2.50",
"name": "zct_v2",
"name": "zct_v2_v2",
"password": "kct@2021",
"port": "3306",
"prefix": "",

View File

@ -30,11 +30,13 @@ var CompanyCtr = Ctr{
// return
//}
res["technology_center_flag"] = ObjToSlice(res["technology_center_flag"])
res["engineering_center_flag"] = ObjToSlice(res["engineering_center_flag"])
res["engineering_laboratory_flag"] = ObjToSlice(res["engineering_laboratory_flag"])
res["key_laboratory_flag"] = ObjToSlice(res["key_laboratory_flag"])
res["industrial_design_center_flag"] = ObjToSlice(res["industrial_design_center_flag"])
res["technology_center_flag"] = strToArray(res.GetString("technology_center_flag"))
res["engineering_center_flag"] = strToArray(res.GetString("engineering_center_flag"))
res["engineering_laboratory_flag"] = strToArray(res.GetString("engineering_laboratory_flag"))
res["key_laboratory_flag"] = strToArray(res.GetString("key_laboratory_flag"))
res["industrial_design_center_flag"] = strToArray(res.GetString("industrial_design_center_flag"))
res["high_level_talents_flag1"] = strToArray(res.GetString("high_level_talents_flag1"))
res["tags"] = strToArray(res.GetString("tags"))
that.Display(0, res)
},
@ -63,8 +65,8 @@ var CompanyCtr = Ctr{
data := Map{}
for k, _ := range company {
if that.Req.Form[k] != nil {
if k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" {
data[k] = ObjToStr(that.Req.Form[k])
if k == "tags" || k == "high_level_talents_flag1" || k == "technology_center_flag" || k == "engineering_center_flag" || k == "engineering_laboratory_flag" || k == "key_laboratory_flag" || k == "industrial_design_center_flag" {
data[k] = arrayToStr(ObjToSlice(that.Req.Form[k]))
} else {
data[k] = that.Req.FormValue(k)
}

View File

@ -3,6 +3,7 @@ package provider
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"strings"
"time"
"unicode/utf8"
)
@ -20,6 +21,29 @@ var Project = Proj{
"wechat": Wechat,
}
func strToArray(str string) Slice {
s := Slice{}
olds := strings.Split(str, ",")
for _, v := range olds {
if v != "" {
s = append(s, v)
}
}
return s
}
func arrayToStr(ars Slice) string {
s := ","
if ars == nil {
return s
}
for k, _ := range ars {
s = s + ars.GetString(k) + ","
}
return s
}
//生成随机码的6位md5
func getSn() string {
x := Rand(8)

View File

@ -3,10 +3,50 @@
<head>
<meta charset="UTF-8">
<title>微信登录</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script type="text/javascript" src="js/hotime.js"></script>
<script type="text/javascript" src="js/qrcode.min.js"></script>
<style>
body{margin:0;}
.box{width:100%;height: 100vh;display:flex;align-items:center;justify-content: center;position: relative;}
.logo{position: absolute;top:7px;left: 17px;z-index: 2;width: 62px;height:22px;}
.logo img{width:100%;background-size: contain;}
.bg-img{position: absolute;top:0;left:0;width:100%;background-size: contain;}
.title{font-size: 14px;font-weight: bold;color: #FFF;letter-spacing: 6px;margin-bottom:50px;text-align: center;}
#qrcode{width:117px; height:117px; margin:23px auto 40px;}
.content{background: #D0ECF9;border: 1px solid rgba(255, 255, 255, 0.6);box-shadow: 0px 4px 12px rgba(25, 105, 146, 0.24);border-radius: 8px;padding:34px 0;font-size: 18px;color: #0674AE;margin:0 auto;width:65%;text-align: center;}
.footer{position: fixed;bottom:14px;width: 100%;font-size: 12px;
color: rgba(0, 0, 0, 0.7);text-align: center;line-height: 16px;}
</style>
</head>
<body>
<div class="box">
<div class="logo">
<img src="./img/logo_2@2x.png" alt="">
</div>
<img class="bg-img" src="./img/bg_up@2x.png">
<div style="flex:1;">
<div class="title">
欢迎使用政策狩猎精灵
</div>
<div class="content">
<div>初次使用需要绑定您的信息</div>
<div>请打开微信扫描下方二维码</div>
<div id="qrcode"></div>
</div>
</div>
<div class="footer">
<div>成都市创新创业服务平台</div>
<div>国家级双创示范平台</div>
</div>
</div>
<script>
var qrcode = new QRCode(document.getElementById("qrcode"), {
width: 117,
height: 117
})
function run() {
var data={"timestamp": window.H.getParam("timestamp"),"sn":window.H.getParam("sn")}
// if(data.code==null){
@ -14,9 +54,16 @@
// return
// }
window.H.post("app/upan/login", data, function (res) {
//定时器3s刷新登录
window.H.post("/app/upan/login", data, function (res) {
if (res.status != 0) {
alert(res.result.msg)
//展示二维码链接扫码到一个页面传参timestamp&sn页面内容app/upan/createtimestamp&sn&phone&company_name&code,成功后跳转到首页
let url = 'https://'+location.host+'/#/qrcode?timestamp='+ window.H.getParam("timestamp")+"&sn="+ encodeURIComponent(window.H.getParam("sn"))
qrcode.makeCode(url)
setTimeout(function(){
run()
},3000)
return
}
// let res = { "result": { "acttoken": "56_ogEfWa4mglG-Ilf2kD50FfekZWimJXUouZ4gMKmkVP2CwcLwv2lHO35LOn5NSLOQ-yEAZcIs3FvgIBhk2uF9CA", "appid": "wx4d97696b9ecb49fc", "avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLNj0yKXe77H8C60ic2lUFIx5hkibf0FluNCRfTkiazrBfuqclqRhm4nDug9Hx3nsXQhtzNdfchAvJTQ/132", "nickname": "候鸟半夏", "openid": "oPoZT6juCkF6fvnMHrCFI6SK_vK8", "retoken": "56_tjuJPobvbLVvOPtqPRZjTzQHR7i3Vmx_aGXOy9j0WsNTFS_JRnb4ArmUGhWtq6e7eCpUnPNKulIQ44CPiBnYEA", "unionid": "ofKK36PEkbIt0xMMUgch4H-bVaFI" }, "status": 0 }
@ -24,6 +71,7 @@
})
}
run()