utils.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. package main
  2. import (
  3. "log"
  4. "regexp"
  5. "strings"
  6. )
  7. // getProject 根据标讯ID获取项目信息
  8. func getProject(id string) map[string]interface{} {
  9. where := map[string]interface{}{
  10. "ids": id,
  11. }
  12. p, _ := MgoP.FindOne("projectset_20230904", where)
  13. project := *p
  14. return project
  15. }
  16. // getCodeByCompanyType 根据企业类型,返回经营主体代码
  17. func getCodeByCompanyType(cleanText string, codeMap map[string]string) (code string) {
  18. if code == "" {
  19. //一人有限责任公司
  20. if strings.Contains(cleanText, "一人有限责任公司分公司") {
  21. cleanText = "一人有限责任公司分公司"
  22. } else if strings.Contains(cleanText, "一人有限责任公司") {
  23. cleanText = "一人有限责任公司"
  24. } else if cleanText == "有限责任(公司)" {
  25. cleanText = "有限责任公司"
  26. } else if cleanText == "上市股份有限公司分公司" {
  27. cleanText = "股份有限公司分公司(上市)"
  28. } else if cleanText == "上市股份有限公司分公司(非上市)" {
  29. cleanText = "股份有限公司分公司(非上市)"
  30. } else if !strings.Contains(cleanText, "非个人") && !strings.Contains(cleanText, "非个体") {
  31. if strings.Contains(cleanText, "个人") || strings.Contains(cleanText, "个体") || strings.Contains(cleanText, "户体商工个") {
  32. cleanText = "个体工商户"
  33. }
  34. } else if strings.Contains(cleanText, "中外合作") { // 中外合作企业 - 有限责任公司(中外合作)
  35. if strings.Contains(cleanText, "非公司外商投资企业(中外合作)") {
  36. cleanText = "非公司外商投资企业(中外合作)"
  37. } else {
  38. cleanText = "有限责任公司(中外合作)"
  39. }
  40. } else if strings.Contains(cleanText, "有限责任公司(中外合资)") { //有限责任公司(中外合资)
  41. cleanText = "有限责任公司(中外合资)"
  42. } else if strings.Contains(cleanText, "外商投资企业分支机构") { //非公司外商投资企业分支机构;外商投资企业分支机构
  43. if strings.Contains(cleanText, "非公司") {
  44. cleanText = "非公司外商投资企业分支机构"
  45. } else {
  46. cleanText = "外商投资企业分支机构"
  47. }
  48. } else if strings.Contains(cleanText, "其他") {
  49. //有限责任公司(港、澳、台)
  50. if strings.Contains(cleanText, "港、澳、台") {
  51. if strings.Contains(cleanText, "有限责任公司") {
  52. cleanText = "有限责任公司(港、澳、台)"
  53. } else if strings.Contains(cleanText, "非公司") {
  54. code = "6300"
  55. cleanText = "非公司"
  56. }
  57. }
  58. } else if strings.Contains(cleanText, "有限责任公司(台港澳与境内合作)") {
  59. cleanText = "有限责任公司(台港澳与境内合作)"
  60. } else if strings.Contains(cleanText, "有限责任公司(台港澳与境内合资)") {
  61. cleanText = "有限责任公司(台港澳与境内合资)"
  62. } else if strings.Contains(cleanText, "有限责任公司(台港澳与外国投资者合资)") {
  63. cleanText = "有限责任公司(台港澳与外国投资者合资)"
  64. } else if strings.Contains(cleanText, "有限责任公司(台港澳合资)") || (strings.Contains(cleanText, "台、港、澳资") && strings.Contains(cleanText, "有限责任公司")) {
  65. cleanText = "有限责任公司(台港澳合资)"
  66. } else if strings.Contains(cleanText, "有限责任公司(台港澳法人独资)") {
  67. cleanText = "有限责任公司(港澳台法人独资)"
  68. } else if strings.Contains(cleanText, "有限责任公司(台港澳自然人独资)") {
  69. cleanText = "有限责任公司(港澳台自然人独资)"
  70. } else if strings.Contains(cleanText, "有限责任公司(外商合资)") {
  71. cleanText = "有限责任公司(外商合资)"
  72. } else if strings.Contains(cleanText, "有限责任公司(外商投资") {
  73. cleanText = "有限责任公司(外商投资、非独资)"
  74. } else if strings.Contains(cleanText, "有限责任公司(外国法人独资)") {
  75. cleanText = "有限责任公司(外国法人独资)"
  76. } else if strings.Contains(cleanText, "外国非法人经济组织独资") {
  77. cleanText = "外国非法人经济组织独资"
  78. } else if strings.Contains(cleanText, "有限责任公司(外国自然人独资)") || strings.Contains(cleanText, "有限责任公司(外自然人独资)") {
  79. cleanText = "有限责任公司(外国自然人独资)"
  80. } else if strings.Contains(cleanText, "有限责任公司(法人独资)(外商投资企业投资)") {
  81. cleanText = "有限责任公司分公司(外商投资企业法人独资)"
  82. } else if strings.Contains(cleanText, "有限责任公司(港、澳、台)") || strings.Contains(cleanText, "有限责任公司(港澳台合资)") {
  83. cleanText = "有限责任公司(台港澳合资)"
  84. } else if strings.Contains(cleanText, "有限责任公司") || strings.Contains(cleanText, "港澳台与境内合作") {
  85. cleanText = "有限责任公司(台港澳与境内合作)"
  86. } else if strings.Contains(cleanText, "港澳台与境内合资") && strings.Contains(cleanText, "有限责任公司") {
  87. cleanText = "有限责任公司(台港澳与境内合资)"
  88. } else
  89. // 这个需要和贾老师确认
  90. if strings.Contains(cleanText, "有限责任公司(法人独资") && strings.Contains(cleanText, "私营") {
  91. cleanText = "有限责任公司(非自然人投资或控股的法人独资)"
  92. } else if strings.Contains(cleanText, "港澳台与外国投资者合资") && strings.Contains(cleanText, "有限责任公司") {
  93. cleanText = "有限责任公司(台港澳与外国投资者合资)"
  94. } else if strings.Contains(cleanText, "港澳台法人独资") && strings.Contains(cleanText, "有限责任公司") {
  95. cleanText = "有限责任公司(港澳台法人独资)"
  96. } else if strings.Contains(cleanText, "港澳台自然人独资") && strings.Contains(cleanText, "有限责任公司") {
  97. cleanText = "有限责任公司(港澳台自然人独资)"
  98. } else if strings.Contains(cleanText, "有限责任公司(港澳台非法人经济组织独资)") {
  99. cleanText = "有限责任公司(台港澳非法人经济组织独资)"
  100. } else if strings.Contains(cleanText, "港澳台投资、非独资") && strings.Contains(cleanText, "有限责任公司") {
  101. cleanText = "有限责任公司(港澳台投资、非独资)"
  102. } else if strings.Contains(cleanText, "港澳台合资") && strings.Contains(cleanText, "未上市") {
  103. if strings.Contains(cleanText, "股份有限公司") {
  104. code = "6230"
  105. }
  106. } else if strings.Contains(cleanText, "集体所有制") {
  107. cleanText = "集体所有制"
  108. } else if strings.Contains(cleanText, "国有独资") {
  109. if strings.Contains(cleanText, "有限责公司分公司") {
  110. cleanText = "有限责任公司分公司(国有独资)"
  111. } else if strings.Contains(cleanText, "有限责公司") {
  112. cleanText = "有限责任公司(国有独资)"
  113. }
  114. } else
  115. //台、港、澳
  116. if strings.Contains(cleanText, "台、港、澳") {
  117. if strings.Contains(cleanText, "台、港、澳分公司") || strings.Contains(cleanText, "台、港、澳投资企业分公司") || strings.Contains(cleanText, "台、港、澳投资公司分公司") {
  118. code = "6810"
  119. }
  120. if strings.Contains(cleanText, "台、港、澳办事处") {
  121. code = "6830"
  122. }
  123. if strings.Contains(cleanText, "台、港、澳投资企业") {
  124. code = "6000"
  125. }
  126. if strings.Contains(cleanText, "台、港、澳投资企业其他") {
  127. code = "6190"
  128. }
  129. } else if cleanText == "股份有限公司分支机构(台港澳与境内合资)" {
  130. code = "6220"
  131. } else if strings.Contains(cleanText, "台港澳投资企业办事处") {
  132. code = "6830"
  133. } else if strings.Contains(cleanText, "台港澳投资有限合伙企业") {
  134. code = "6400"
  135. } else if strings.Contains(cleanText, "台港澳投资普通合伙企业分支机构") {
  136. code = "6840"
  137. } else if strings.Contains(cleanText, "台港澳投资特殊普通合伙企业分支机构") {
  138. code = "6420"
  139. } else if strings.Contains(cleanText, "台港澳股份有限公司") {
  140. code = "6200"
  141. } else if strings.Contains(cleanText, "台港澳非公司") {
  142. code = "6300"
  143. } else if cleanText == "国外投资" {
  144. code = "5000"
  145. } else if strings.Contains(cleanText, "国有事业单位营业") {
  146. cleanText = "国有事业单位营业"
  147. } else if strings.Contains(cleanText, "国有控股") {
  148. if strings.Contains(cleanText, "非上市") {
  149. if strings.Contains(cleanText, "股份有限公司分公司") {
  150. code = "1223"
  151. }
  152. } else if strings.Contains(cleanText, "上市") {
  153. if strings.Contains(cleanText, "股份有限公司分公司") {
  154. code = "2213"
  155. cleanText = "股份有限公司分公司(上市、国有控股)"
  156. }
  157. } else if strings.Contains(cleanText, "股份有限公司分公司") {
  158. code = "2223"
  159. } else if strings.Contains(cleanText, "有限责任公司分公司") {
  160. code = "2140"
  161. } else if strings.Contains(cleanText, "有限责任公司") {
  162. code = "1140"
  163. }
  164. } else if strings.Contains(cleanText, "国有") {
  165. if strings.Contains(cleanText, "经营单位") && strings.Contains(cleanText, "非法人") {
  166. code = "4410"
  167. cleanText = "国有经营单位(非法人)"
  168. } else if strings.Contains(cleanText, "国有联营") {
  169. code = "4600"
  170. }
  171. } else
  172. //合伙企业
  173. if strings.Contains(cleanText, "合伙企业") {
  174. if strings.Contains(cleanText, "特殊普通合伙") {
  175. code = "4532"
  176. } else if strings.Contains(cleanText, "普通合伙") {
  177. code = "4530"
  178. } else if strings.Contains(cleanText, "有限合伙") {
  179. code = "4533"
  180. } else if strings.Contains(cleanText, "合伙企业分支机构") {
  181. code = "4550"
  182. }
  183. } else if strings.Contains(cleanText, "合伙私营企业") {
  184. code = "4530"
  185. } else if cleanText == "内资企业法人联营" {
  186. cleanText = "联营"
  187. } else
  188. //农民专业合作社分支机构
  189. if strings.Contains(cleanText, "合作社") {
  190. if strings.Contains(cleanText, "农民专业合作社分支机构") {
  191. cleanText = "农民专业合作社分支机构"
  192. } else if strings.Contains(cleanText, "农民专业合作社") {
  193. cleanText = "农民专业合作社"
  194. } else if strings.Contains(cleanText, "合作社分支机构") {
  195. cleanText = "农民专业合作社分支机构"
  196. } else {
  197. cleanText = "农民专业合作社"
  198. }
  199. } else if strings.Contains(cleanText, "非公司") {
  200. if strings.Contains(cleanText, "港、澳、台投资企业分支机构") {
  201. cleanText = "非公司台、港、澳投资企业分支机构"
  202. code = "6820"
  203. } else if strings.Contains(cleanText, "港、澳、台企业(港澳台合资)") {
  204. cleanText = "非公司台、港、澳企业(台港澳与境内合作)"
  205. code = "6310"
  206. } else if strings.Contains(cleanText, "非公司外商投资企业") && strings.Contains(cleanText, "其他") {
  207. code = "5390"
  208. }
  209. } else if strings.Contains(cleanText, "股份有限公司(上市公司)") {
  210. cleanText = "股份有限公司(上市)"
  211. code = "1210"
  212. } else if strings.Contains(cleanText, "股份有限公司(中外合资、上市)") {
  213. cleanText = "股份有限公司(中外合资、上市)"
  214. code = "5220"
  215. } else if strings.Contains(cleanText, "股份有限公司(中外合资、未上市)") || strings.Contains(cleanText, "股份有限公司(中外合资,未上市)") {
  216. cleanText = "股份有限公司(中外合资、未上市)"
  217. code = "5210"
  218. } else if cleanText == "股份有限公司(其他)" {
  219. code = "5290"
  220. } else if strings.Contains(cleanText, "股份有限公司(其他台港澳股份有限公司)") {
  221. code = "6290"
  222. } else if cleanText == "股份有限公司(台、港、澳资)" {
  223. code = "6270"
  224. } else if strings.Contains(cleanText, "股份有限公司(台港澳与境内合资、上市)") || strings.Contains(cleanText, "股份有限公司(台港澳与境内合资,上市)") {
  225. cleanText = "股份有限公司(台港澳与境内合资、上市)"
  226. code = "6220"
  227. } else if strings.Contains(cleanText, "股份有限公司(台港澳与境内合资、未上市)") {
  228. cleanText = "股份有限公司(台港澳与境内合资、未上市)"
  229. code = "6210"
  230. } else if strings.Contains(cleanText, "股份有限公司(台港澳与外国投资者合资、未上市)") {
  231. cleanText = "股份有限公司(台港澳与外国投资者合资、未上市)"
  232. code = "6250"
  233. } else if strings.Contains(cleanText, "股份有限公司(台港澳合资、上市)") {
  234. cleanText = "股份有限公司(台港澳合资、上市)"
  235. code = "6240"
  236. } else if strings.Contains(cleanText, "股份有限公司(台港澳合资、未上市)") {
  237. cleanText = "股份有限公司(台港澳合资、未上市)"
  238. code = "6230"
  239. } else if cleanText == "股份有限公司(港、澳、台)" {
  240. code = "6200"
  241. } else {
  242. }
  243. // 判断是不是日期(如 2008/10/31)
  244. if matched, _ := regexp.MatchString(`^\d{4}/\d{1,2}/\d{1,2}$`, cleanText); matched {
  245. log.Printf("跳过日期行: %s", cleanText)
  246. return
  247. }
  248. // 如果包含“年”/“月”/“日”等,也跳过(不提取数字)
  249. if strings.Contains(cleanText, "年") || strings.Contains(cleanText, "月") || strings.Contains(cleanText, "日") {
  250. log.Printf("跳过含日期描述的行: %s", cleanText)
  251. return
  252. }
  253. cleanText = strings.TrimSpace(cleanText)
  254. cleanText = strings.ReplaceAll(cleanText, "(", "(")
  255. cleanText = strings.ReplaceAll(cleanText, ")", ")")
  256. if code == "" {
  257. if c, ok := codeMap[cleanText]; ok {
  258. code = c
  259. }
  260. }
  261. }
  262. return code
  263. }