sci99.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. package sci99
  2. import (
  3. "eta/eta_index_lib/models"
  4. "github.com/mozillazg/go-pinyin"
  5. "strings"
  6. )
  7. var IndexCodeMap = make(map[string]string)
  8. var IndexMap = make(map[string]*models.BaseFromSci99Index)
  9. var ClassifyMap = make(map[string]*models.BaseFromSci99Classify)
  10. var PriceTypeIDs = []int{34320, 34318}
  11. var requestList = []ListRequestBody{
  12. {
  13. Ppname: "天然橡胶原料",
  14. PPIDs: "13676",
  15. Navid: "593",
  16. }, {
  17. Ppname: "混合胶",
  18. PPIDs: "12973",
  19. Navid: "591",
  20. }, {
  21. Ppname: "标准胶",
  22. PPIDs: "12960",
  23. Navid: "590",
  24. }, {
  25. Ppname: "烟片胶",
  26. PPIDs: "12985",
  27. Navid: "592",
  28. }, {
  29. Ppname: "天然乳胶",
  30. PPIDs: "12947",
  31. Navid: "595",
  32. }, {
  33. Ppname: "丁苯橡胶",
  34. PPIDs: "12951",
  35. Navid: "596",
  36. }, {
  37. Ppname: "顺丁橡胶",
  38. PPIDs: "12964",
  39. Navid: "597",
  40. }, {
  41. Ppname: "SBS",
  42. PPIDs: "12948",
  43. Navid: "598",
  44. }, {
  45. Ppname: "丁腈橡胶",
  46. PPIDs: "12945",
  47. Navid: "605",
  48. },
  49. }
  50. func Sci99IndexCodeGenerator(indexName, indexCodeStr, marketSampleName, model string) (indexCode string, needAdd bool) {
  51. strResult := ""
  52. indexCode, _ = IndexCodeMap[indexName]
  53. if indexCode == "" {
  54. //首字母
  55. a := pinyin.NewArgs()
  56. a.Fallback = func(r rune, a pinyin.Args) []string {
  57. return []string{string(r)}
  58. }
  59. rows := pinyin.Pinyin(indexCodeStr, a)
  60. for i := 0; i < len(rows); i++ {
  61. //strResult += rows[i][0]
  62. if len(rows[i]) != 0 {
  63. str := rows[i][0]
  64. pi := str[0:1]
  65. strResult += pi
  66. }
  67. }
  68. // 处理市场名称
  69. if province, ok := ProvinceMap[marketSampleName]; ok {
  70. strResult += province
  71. } else {
  72. a := pinyin.NewArgs()
  73. rows := pinyin.LazyPinyin(marketSampleName, a)
  74. for i := 0; i < len(rows); i++ {
  75. strResult += rows[i]
  76. }
  77. }
  78. // 去除特殊符号
  79. model = strings.Replace(model, " ", "", -1)
  80. model = strings.Replace(model, "-", "", -1)
  81. model = strings.Replace(model, "/", "", -1)
  82. model = strings.Replace(model, "#", "", -1)
  83. model = strings.Replace(model, ":", "", -1)
  84. model = strings.Replace(model, "(", "", -1)
  85. model = strings.Replace(model, ")", "", -1)
  86. // 拼接型号
  87. modelRows := pinyin.Pinyin(model, a)
  88. for i := 0; i < len(modelRows); i++ {
  89. if len(modelRows[i]) != 0 {
  90. str := modelRows[i][0]
  91. pi := str[0:1]
  92. strResult += pi
  93. }
  94. }
  95. needAdd = true
  96. indexCode = strings.Replace(strResult, " ", "", -1)
  97. IndexCodeMap[indexName] = indexCode
  98. }
  99. return
  100. }
  101. var ProvinceMap = map[string]string{
  102. "上海": "shanghai",
  103. "云南": "yunnan",
  104. "内蒙古": "innermongolia",
  105. "北京": "beijing",
  106. "台湾": "taiwan",
  107. "吉林": "jilin",
  108. "四川": "sichuan",
  109. "天津": "tianjin",
  110. "宁夏": "ningxia",
  111. "安徽": "anhui",
  112. "山东": "shandong",
  113. "山西": "shanxi",
  114. "广东": "guangdong",
  115. "广西": "guangxi",
  116. "新疆": "xinjiang",
  117. "江苏": "jiangsu",
  118. "江西": "jiangxi",
  119. "河北": "hebei",
  120. "河南": "henan",
  121. "浙江": "zhejiang",
  122. "海南": "hainan",
  123. "湖北": "hubei",
  124. "湖南": "hunan",
  125. "澳门": "macao",
  126. "甘肃": "gansu",
  127. "福建": "fujian",
  128. "西藏": "tibet",
  129. "贵州": "guizhou",
  130. "辽宁": "liaoning",
  131. "重庆": "chongqing",
  132. "陕西": "shaanxi",
  133. "青海": "qinhai",
  134. "香港": "hongkong",
  135. "黑龙江": "heilongjiang",
  136. }