diff --git a/example/app/company.go b/example/app/company.go index 5c4cf4b..a1014c1 100644 --- a/example/app/company.go +++ b/example/app/company.go @@ -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) + }, } diff --git a/example/app/declare.go b/example/app/declare.go index 0ef9f83..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) { @@ -108,38 +110,14 @@ var DeclareCtr = Ctr{ delete(company, "create_time") delete(company, "modify_time") 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]) - // } else { - // data[k] = that.Req.FormValue(k) - // } - // - // } - //} for k, _ := range company { - // 前端传传值不规范 - if k == "high_level_talents_flag" { + 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 if k == "tags" || k == "high_level_talents_flag" { - keyObj := that.Req.Form[k] - if keyObj != nil && ObjToStr(keyObj) != "" { - tagsStr := "" - for k2, v2 := range keyObj { - if k == "tags" && k2 < len(keyObj)-1 { - tagsStr = tagsStr + v2 + "," - } else { - tagsStr += v2 - } - } - data[k] = tagsStr - } } else { data[k] = that.Req.FormValue(k) } @@ -148,14 +126,14 @@ var DeclareCtr = Ctr{ //如果企业名称相同则允许变更企业信息 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}) } //其余情况,不存储数据 } @@ -227,15 +205,17 @@ var DeclareCtr = Ctr{ } } - 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}}) + 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 { + for _, v1 := range dtag { - if declares[v1.GetCeilInt64("declare_id")] == nil { - declares[v1.GetCeilInt64("declare_id")] = v1 + 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 } - 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-国家级 @@ -250,17 +230,18 @@ var DeclareCtr = Ctr{ } } - 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}}) + 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 { + for _, v1 := range dtag { - if declares[v1.GetCeilInt64("declare_id")] == nil { - declares[v1.GetCeilInt64("declare_id")] = v1 + 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 } - 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{} @@ -273,13 +254,15 @@ var DeclareCtr = Ctr{ } } - 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 + 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 } - 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-国家级 @@ -294,13 +277,15 @@ var DeclareCtr = Ctr{ } } - 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 + 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 } - 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-是 @@ -354,15 +339,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"))}}) - for _, v1 := range dtag { - - if declares[v1.GetCeilInt64("declare_id")] == nil { - declares[v1.GetCeilInt64("declare_id")] = v1 + //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) } - 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 + } + 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"))}}) @@ -450,6 +475,492 @@ 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(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(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) { diff --git a/example/app/init.go b/example/app/init.go index a03dbc6..5be176e 100644 --- a/example/app/init.go +++ b/example/app/init.go @@ -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 { diff --git a/example/app/wechath5.go b/example/app/wechath5.go index 98805ab..f65bba1 100644 --- a/example/app/wechath5.go +++ b/example/app/wechath5.go @@ -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")}) diff --git a/example/config/config.json b/example/config/config.json index f45e0c3..07959f5 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -25,7 +25,7 @@ "db": { "mysql": { "host": "192.168.2.50", - "name": "zct_v2", + "name": "zct_v2_v2", "password": "kct@2021", "port": "3306", "prefix": "", diff --git a/example/provider/company.go b/example/provider/company.go index 03c6d5f..98443c5 100644 --- a/example/provider/company.go +++ b/example/provider/company.go @@ -3,8 +3,6 @@ package provider import ( . "code.hoteas.com/golang/hotime" . "code.hoteas.com/golang/hotime/common" - "code.hoteas.com/golang/hotime/dri/aliyun" - "fmt" ) var CompanyCtr = Ctr{ @@ -32,12 +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["high_level_talents_flag"] = ObjToSlice(res["high_level_talents_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) }, @@ -64,81 +63,20 @@ var CompanyCtr = Ctr{ delete(company, "create_time") delete(company, "modify_time") 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]) - // } else { - // data[k] = that.Req.FormValue(k) - // } - // - // } - //} for k, _ := range company { - // 前端传传值不规范 - if k == "high_level_talents_flag" { - that.Req.Form[k] = that.Req.Form["highLevel_talents_flag"] - } - if k == "attendee" { - continue - } 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]) - } else if k == "tags" || k == "high_level_talents_flag" { - keyObj := that.Req.Form[k] - if keyObj != nil && ObjToStr(keyObj) != "" { - tagsStr := "" - for k2, v2 := range keyObj { - if k == "tags" && k2 < len(keyObj)-1 { - tagsStr = tagsStr + v2 + "," - } else { - tagsStr += v2 - } - } - data[k] = tagsStr - } + 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 { - fmt.Println(that.Req.FormValue(k)) - if that.Req.FormValue(k) != "" { - data[k] = that.Req.FormValue(k) - } + data[k] = that.Req.FormValue(k) } + } } - data["modify_time[#]"] = "NOW()" - that.Db.Update("company", data, Map{"id": id}) + that.Db.Update("company", company, Map{"id": id}) that.Display(0, "更新成功") }, - "search": func(that *Context) { - keywords := that.Req.FormValue("keywords") - if keywords == "" { - keywords = that.Req.FormValue("company_name") - } - if keywords == "" { - keywords = that.Req.FormValue("name") - } - - if len(keywords) < 2 { - that.Display(0, Slice{}) - return - } - - res, err := aliyun.Company.GetCompanyList(keywords) - if err != nil { - fmt.Println(err) - that.Display(0, Slice{}) - return - } - if res.GetCeilInt64("status") != 200 { - fmt.Println(err) - that.Display(0, Slice{}) - return - } - - that.Display(0, res.GetMap("data").GetSlice("list")) - }, } diff --git a/example/provider/init.go b/example/provider/init.go index d735eae..67bc9ea 100644 --- a/example/provider/init.go +++ b/example/provider/init.go @@ -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) diff --git a/example/tpt/pc.html b/example/tpt/pc.html index e4cd5a2..ea60dfc 100644 --- a/example/tpt/pc.html +++ b/example/tpt/pc.html @@ -3,20 +3,67 @@ 微信登录 + + + + + +
+ + +
+
+ 欢迎使用政策狩猎精灵 +
+
+
初次使用需要绑定您的信息
+
请打开微信扫描下方二维码
+
+
+
+ +