12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package init
- import (
- util "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/mysql"
- "bp.jydev.jianyu360.cn/BaseService/jyCodeService/rpc/codeservice/codeservice"
- "fmt"
- "log"
- )
- var PushMapping = &codeservice.TypeStruct{}
- const (
- CODEAREA = "code_area"
- CODEBIDSCOPE = "code_bidscope"
- CODEBIDTOPSUBTYPE = "code_bidtopsubtype"
- CODEBUYERCLASS = "code_buyerclass"
- )
- func Init(Mysql *mysql.Mysql) {
- //信息类型
- infotype := Mysql.SelectBySql(fmt.Sprintf("select level,code,name from %s where level=2", CODEBIDTOPSUBTYPE))
- Subtype := map[string]string{}
- if infotype != nil && len(*infotype) > 0 {
- for _, v := range *infotype {
- code := util.ObjToString(v["code"])
- name := util.ObjToString(v["name"])
- Subtype[name] = code
- }
- if len(Subtype) == 0 {
- log.Fatalln("PushMapping Subtype Init Error")
- }
- PushMapping.Subtype = Subtype
- }
- //采购单位行业
- Buyerclass := map[string]string{}
- buyerclass := Mysql.SelectBySql(fmt.Sprintf("select code,name from %s where level=1", CODEBUYERCLASS))
- if buyerclass != nil && len(*buyerclass) > 0 {
- for _, v := range *buyerclass {
- code := util.ObjToString(v["code"])
- name := util.ObjToString(v["name"])
- Buyerclass[name] = code
- }
- if len(Buyerclass) == 0 {
- log.Fatalln("PushMapping Buyerclass Init Error")
- }
- PushMapping.Buyerclass = Buyerclass
- }
- //公告类型处理
- Subscopeclass := map[string]string{}
- subscopeclass := Mysql.SelectBySql(fmt.Sprintf("select a.code, CONCAT(b.name,'_',a.name) as name from %s a LEFT JOIN %s b on a.pcode=b.code where a.level=2", CODEBIDSCOPE, CODEBIDSCOPE))
- if subscopeclass != nil && len(*subscopeclass) > 0 {
- for _, v := range *subscopeclass {
- code := util.ObjToString(v["code"])
- name := util.ObjToString(v["name"])
- Subscopeclass[name] = code
- }
- if len(Subscopeclass) == 0 {
- log.Fatalln("PushMapping subscopeclass Init Error")
- }
- PushMapping.Subscopeclass = Subscopeclass
- }
- //省份处理
- Area := map[string]string{}
- City := map[string]string{}
- province := Mysql.SelectBySql(fmt.Sprintf("select code,area,city from %s where (district is null or district='')", CODEAREA))
- if province != nil && len(*province) > 0 {
- for _, v := range *province {
- code := util.ObjToString(v["code"])
- city := util.ObjToString(v["city"])
- area := util.ObjToString(v["area"])
- if city == "" {
- Area[area] = code
- } else {
- City[city] = code
- }
- }
- if len(Area) == 0 {
- log.Fatalln("PushMapping Area Init Error")
- }
- if len(City) == 0 {
- log.Fatalln("PushMapping City Init Error")
- }
- PushMapping.Area = Area
- PushMapping.City = City
- }
- }
|