package sci99 import ( "eta/eta_index_lib/models" "github.com/mozillazg/go-pinyin" "strings" ) var IndexCodeMap = make(map[string]string) var IndexMap = make(map[string]*models.BaseFromSci99Index) var ClassifyMap = make(map[string]*models.BaseFromSci99Classify) var PriceTypeIDs = []int{34320, 34318} var requestList = []ListRequestBody{ { Ppname: "天然橡胶原料", PPIDs: "13676", Navid: "593", }, { Ppname: "混合胶", PPIDs: "12973", Navid: "591", }, { Ppname: "标准胶", PPIDs: "12960", Navid: "590", }, { Ppname: "烟片胶", PPIDs: "12985", Navid: "592", }, { Ppname: "天然乳胶", PPIDs: "12947", Navid: "595", }, { Ppname: "丁苯橡胶", PPIDs: "12951", Navid: "596", }, { Ppname: "顺丁橡胶", PPIDs: "12964", Navid: "597", }, { Ppname: "SBS", PPIDs: "12948", Navid: "598", }, { Ppname: "丁腈橡胶", PPIDs: "12945", Navid: "605", }, } func Sci99IndexCodeGenerator(indexName, indexCodeStr, marketSampleName, model string) (indexCode string, needAdd bool) { strResult := "" indexCode, _ = IndexCodeMap[indexName] if indexCode == "" { //首字母 a := pinyin.NewArgs() a.Fallback = func(r rune, a pinyin.Args) []string { return []string{string(r)} } rows := pinyin.Pinyin(indexCodeStr, a) for i := 0; i < len(rows); i++ { //strResult += rows[i][0] if len(rows[i]) != 0 { str := rows[i][0] pi := str[0:1] strResult += pi } } // 处理市场名称 if province, ok := ProvinceMap[marketSampleName]; ok { strResult += province } else { a := pinyin.NewArgs() rows := pinyin.LazyPinyin(marketSampleName, a) for i := 0; i < len(rows); i++ { strResult += rows[i] } } // 去除特殊符号 model = strings.Replace(model, " ", "", -1) model = strings.Replace(model, "-", "", -1) model = strings.Replace(model, "/", "", -1) model = strings.Replace(model, "#", "", -1) model = strings.Replace(model, ":", "", -1) model = strings.Replace(model, "(", "", -1) model = strings.Replace(model, ")", "", -1) // 拼接型号 modelRows := pinyin.Pinyin(model, a) for i := 0; i < len(modelRows); i++ { if len(modelRows[i]) != 0 { str := modelRows[i][0] pi := str[0:1] strResult += pi } } needAdd = true indexCode = strings.Replace(strResult, " ", "", -1) IndexCodeMap[indexName] = indexCode } return } var ProvinceMap = map[string]string{ "上海": "shanghai", "云南": "yunnan", "内蒙古": "innermongolia", "北京": "beijing", "台湾": "taiwan", "吉林": "jilin", "四川": "sichuan", "天津": "tianjin", "宁夏": "ningxia", "安徽": "anhui", "山东": "shandong", "山西": "shanxi", "广东": "guangdong", "广西": "guangxi", "新疆": "xinjiang", "江苏": "jiangsu", "江西": "jiangxi", "河北": "hebei", "河南": "henan", "浙江": "zhejiang", "海南": "hainan", "湖北": "hubei", "湖南": "hunan", "澳门": "macao", "甘肃": "gansu", "福建": "fujian", "西藏": "tibet", "贵州": "guizhou", "辽宁": "liaoning", "重庆": "chongqing", "陕西": "shaanxi", "青海": "qinhai", "香港": "hongkong", "黑龙江": "heilongjiang", }