package app import ( . "code.hoteas.com/golang/hotime" . "code.hoteas.com/golang/hotime/common" "sort" "strings" ) type paixuArr []Map 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) { x[i], x[j] = x[j], x[i] } var DeclareCtr = Ctr{ "info": func(that *Context) { id := ObjToInt(that.Req.FormValue("id")) if id == 0 { that.Display(3, "请求参数异常") return } res := that.Db.Get("declare", "*", Map{"id": id}) if res == nil { that.Display(4, "找不到通知公告") return } res["click_num"] = res.GetCeilInt64("click_num") + res.GetCeilInt64("click_num_base") + 1 delete(res, "click_num_base") res["favorite_num"] = res.GetCeilInt64("favorite_num") + res.GetCeilInt64("favorite_num_base") delete(res, "favorite_num_base") article := that.Db.Get("article", "*", Map{"id": res.GetCeilInt64("article_id")}) if article != nil { article["click_num"] = article.GetCeilInt64("click_num") + article.GetCeilInt64("click_num_base") + 1 delete(article, "click_num_base") article["favorite_num"] = article.GetCeilInt64("favorite_num") + article.GetCeilInt64("favorite_num_base") delete(article, "favorite_num_base") } res["article"] = article //浏览量加1 that.Db.Update("declare", Map{"click_num[#]": "click_num+1"}, Map{"id": id}) //浏览量加1 that.Db.Update("article", Map{"click_num[#]": "click_num+1"}, Map{"id": res.GetCeilInt64("article_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}}) res["favorite"] = favorite } that.Display(0, res) }, //政策匹配 "match": 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 } 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{"user_id": that.Session("user_id").Data}) 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]) } else { data[k] = that.Req.FormValue(k) } } } //如果企业名称相同则允许变更企业信息 if companyName == 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 && 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"] = 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"] = 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"] = 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"] = 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(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 { 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"] = 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(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 { 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"] = 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(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 { 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"] = 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(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 { 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"] = 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"] = 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"] = 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"] = 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"] = 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(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}}) 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"] = 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"] = 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"] = 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"] = 1 } } px := paixuArr{} for _, v := range declares { px = append(px, v) } //获取到排序后的数据 sort.Sort(px) var res []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}) article["declare"] = that.Db.Get("declare", "money_scope_min,money_scope_max,status", Map{"id": id}) 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) 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 } 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") || user.GetCeilInt("certification_flag") == 0 { //扫码绑定后,第一次使用匹配功能,自动进行认证,并更新企业信息 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(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 { 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(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 { 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(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 { 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(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 { 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(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}}) 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) res := paixuArr{} //总参数量,除了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 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++ } } if RecommendValue < matchingDegree { RecommendValue = matchingDegree RecommendDeclare = declare } matchingDegreePercent := ObjToFloat64(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 { 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) { page := ObjToInt(that.Req.FormValue("page")) pageSize := ObjToInt(that.Req.FormValue("pageSize")) if page < 1 { page = 1 } if pageSize <= 0 { pageSize = 20 } data := Map{"del_flag": 0, "declare_id[!]": nil} keywords := that.Req.FormValue("keywords") if keywords != "" { data["OR"] = Map{"title[~]": keywords, "description[~]": keywords, "content[~]": keywords} } startTime := that.Req.FormValue("starttime") finishTime := that.Req.FormValue("finishtime") if startTime != "" { data["release_date[>=]"] = startTime } if finishTime != "" { data["release_date[<=]"] = finishTime } dispatchName := that.Req.FormValue("dispatch_name") if dispatchName != "" { data["dispatch_name"] = dispatchName } if len(data) > 1 { data = Map{"AND": data, "ORDER": "release_time DESC"} } count := that.Db.Count("article", data) res := that.Db.Page(page, pageSize).PageSelect("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,dispatch_name,policy_level", data) for _, v := range res { //if v.GetCeilInt("declare_id")>0{ // v["declare"]=that.Db.Get("declare","id,tag",Map{"id":v.GetCeilInt("declare_id")}) //} //if v.GetCeilInt("declare_id")>0{ // v["declare"]=that.Db.Get("declare","tag",Map{"id":v.GetCeilInt("declare_id")}) //} if v.GetCeilInt("declare_id") > 0 { v["declare"] = that.Db.Get("declare", "money_scope_min,money_scope_max,status", Map{"id": v.GetCeilInt("declare_id")}) } } that.Display(0, Map{"total": count, "data": res}) }, }