dim_name_mapping.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. # -*- coding: utf-8 -*-
  2. # @Time : 2022/11/29 15:50
  3. # @Author : XuJiakai
  4. # @File : dim_name_mapping
  5. # @Software: PyCharm
  6. _map_class = {
  7. "基本信息": ['股东信息', '主要成员', '对外投资', '总公司', '分支机构', '历史变更', '企业年报', ],
  8. "法律风险": ['司法案件', '失信信息', '被执行人', '限制消费', '终本案件', '送达公告', '裁判文书', '开庭公告', '立案信息', '法院公告', '股权冻结', '破产重整', '司法拍卖',
  9. '询价评估', '限制出境', '诉前调解', '破产债权', ],
  10. "经营风险": ['行政处罚', '经营异常', '股权出质', '减资记录', '土地转让-出让人', '土地抵押-抵押人', '动产抵押', '环保处罚', '税收违法', '欠税公告', '公示催告', '严重违法',
  11. '简易注销', '解散清算', '股权质押', '股权质押-质押人', '知识产权出质', '注销备案'],
  12. "经营信息": ['招投标', '招聘信息', '特殊资质', '进出口信用', '行政许可', '土地公示', '购地信息', '土地转让-受让人', '土地抵押-抵押权人', '信用评级', '税务信用', '融资信息',
  13. '债券信息', '股权出质-质权人', '产品信息', '主要客户', '供应商', '抽查检查', '产权交易', '双随机抽查'],
  14. "知识产权": ['商标', '专利', '软件著作权', '作品著作权', '网站域名', ],
  15. "建筑信息": ['建筑资质', '建筑人员', '建筑项目', ],
  16. "融资信息": ['应收账款融资', 'DCM注册额度', '债券融资', '境外债券融资', '银行借款', '授信额度', '租赁融资', '信托融资', '其他融资', ],
  17. }
  18. _history_item_key = ['经营异常', '严重违法', '被执行人', '失信信息', '终本案件', '限制高消费', '法院公告', '行政处罚', '动产抵押', '土地抵押', '开庭公告',
  19. '股权出质-质权人', '股权出质', '股权冻结', ]
  20. _winhc_dim_map = {
  21. "股东信息": {
  22. "dim_name": "company_holder",
  23. "summary_key": "",
  24. "history_summary_key": "",
  25. "history": True,
  26. "sort_field": None
  27. },
  28. "主要成员": {
  29. "dim_name": "company_staff",
  30. "history": True,
  31. "sort_field": None
  32. },
  33. "对外投资": {
  34. "dim_name": "",
  35. "summary_key": "company_holder_del_0_invest",
  36. "history_summary_key": "company_holder_del_1_invest",
  37. "sort_field": ""
  38. },
  39. # "总公司": {
  40. # "dim_name": "",
  41. # "sort_field": None
  42. # },
  43. "分支机构": {
  44. "dim_name": "",
  45. "summary_key": "company_branch_del_0",
  46. "history_summary_key": "company_branch_del_1",
  47. "sort_field": ""
  48. },
  49. "历史变更": {
  50. "dim_name": "company_change",
  51. "summary_key": "",
  52. "sort_field": "change_time"
  53. },
  54. "企业年报": {
  55. "dim_name": "company_annual_report",
  56. "summary_key": "", "sort_field": ""
  57. },
  58. "司法案件": { # todo
  59. "dim_name": "",
  60. "summary_key": "", "sort_field": ""
  61. },
  62. "失信信息": {
  63. "dim_name": "company_dishonest_info",
  64. "summary_key": "", "sort_field": "keyno:pub_date"
  65. },
  66. "被执行人": {
  67. "dim_name": "company_zxr",
  68. "summary_key": "", "sort_field": "keyno:case_create_time"
  69. },
  70. "限制消费": {
  71. "dim_name": "company_zxr_restrict",
  72. "summary_key": "", "sort_field": "publish_date"
  73. },
  74. "终本案件": {
  75. "dim_name": "company_zxr_final_case",
  76. "summary_key": "", "sort_field": "keyno:case_create_time"
  77. },
  78. "送达公告": { # todo
  79. "dim_name": "company_send_announcement",
  80. "summary_key": "", "sort_field": "plaintiff_info.litigant_id:start_date,defendant_info.litigant_id:start_date"
  81. },
  82. "裁判文书": { # fixme 需要跨集群查询
  83. "dim_name": "wenshu_detail_v2",
  84. "summary_key": "wenshu_detail_v2_del_0_defendant,wenshu_detail_v2_del_0_plaintiff", "sort_field": "wenshu_detail2:litigant_info.litigant_id:judge_date"
  85. },
  86. "开庭公告": {
  87. "dim_name": "company_court_open_announcement",
  88. "summary_key": "company_court_open_announcement_del_0_plaintiff,company_court_open_announcement_del_0_defendant", "sort_field": "defendant_info.litigant_id:start_date,plaintiff_info.litigant_id:start_date"
  89. },
  90. "立案信息": {
  91. "dim_name": "company_court_register",
  92. "summary_key": "company_court_register_del_0_defendant,company_court_register_del_0_plaintiff", "sort_field": "defendant_info.litigant_id:filing_date,plaintiff_info.litigant_id:filing_date"
  93. },
  94. "法院公告": {
  95. "dim_name": "company_court_announcement",
  96. "summary_key": "company_court_announcement_del_0_plaintiff,company_court_announcement_del_0_litigant",
  97. "sort_field": "defendant_info.litigant_id:publish_date,plaintiff_info.litigant_id:publish_date"
  98. },
  99. "股权冻结": { # todo 没有时间
  100. "dim_name": "company_judicial_assistance",
  101. "summary_key": "", "sort_field": ""
  102. },
  103. "破产重整": {
  104. "dim_name": "",
  105. "summary_key": "", "sort_field": ""
  106. },
  107. "司法拍卖": {
  108. "dim_name": "auction_tracking",
  109. "summary_key": "", "sort_field": "company_info.company_id:start_time"
  110. },
  111. "询价评估": {
  112. "dim_name": "zxr_evaluate,zxr_evaluate_results",
  113. "summary_key": "", "sort_field": "winhc_index_rt_zxr_evaluate_results:keyno:publish_time"
  114. },
  115. "限制出境": {
  116. "dim_name": "restrictions_on_exit",
  117. "summary_key": "", "sort_field": ""
  118. },
  119. "诉前调解": {
  120. "dim_name": "litigation_mediation",
  121. "summary_key": "litigation_mediation_del_0_plaintiff,litigation_mediation_del_0_defendant", "sort_field": "defendant_info.litigant_id:filing_date,plaintiff_info.litigant_id:filing_date"
  122. },
  123. "破产债权": {
  124. "dim_name": "",
  125. "summary_key": "", "sort_field": ""
  126. },
  127. "行政处罚": {
  128. "dim_name": "company_punishment_info,company_punishment_info_creditchina",
  129. "summary_key": "",
  130. "sort_field": "winhc_index_rt_company_punishment_info:company_id:decision_date,winhc_index_rt_company_punishment_info_creditchina:company_id:decision_date"
  131. },
  132. "经营异常": {
  133. "dim_name": "company_abnormal_info",
  134. "summary_key": "", "sort_field": "put_date"
  135. },
  136. "股权出质": { # todo
  137. "dim_name": "company_equity_info",
  138. "summary_key": "", "sort_field": ""
  139. },
  140. "减资记录": {
  141. "dim_name": "",
  142. "summary_key": "", "sort_field": ""
  143. },
  144. "土地转让-出让人": {
  145. "dim_name": "",
  146. "summary_key": "", "sort_field": ""
  147. },
  148. "土地抵押-抵押人": {
  149. "dim_name": "",
  150. "summary_key": "", "sort_field": ""
  151. },
  152. "动产抵押": {
  153. "dim_name": "",
  154. "summary_key": "", "sort_field": ""
  155. },
  156. "环保处罚": {
  157. "dim_name": "company_env_punishment",
  158. "summary_key": "", "sort_field": "publish_time"
  159. },
  160. "税收违法": {
  161. "dim_name": "company_tax_contravention",
  162. "summary_key": "", "sort_field": "publish_time"
  163. },
  164. "欠税公告": {
  165. "dim_name": "company_own_tax",
  166. "summary_key": "", "sort_field": "publish_date"
  167. },
  168. "公示催告": {
  169. "dim_name": "company_public_announcement",
  170. "summary_key": "", "sort_field": "publish_date"
  171. },
  172. "严重违法": {
  173. "dim_name": "company_illegal_info",
  174. "summary_key": "", "sort_field": "put_date"
  175. },
  176. "简易注销": {
  177. "dim_name": "company_brief_cancel_announcement",
  178. "summary_key": "", "sort_field": ""
  179. },
  180. "解散清算": {
  181. "dim_name": "",
  182. "summary_key": "", "sort_field": ""
  183. },
  184. "股权质押": {
  185. "dim_name": "",
  186. "summary_key": "", "sort_field": ""
  187. },
  188. "股权质押-质押人": {
  189. "dim_name": "",
  190. "summary_key": "", "sort_field": ""
  191. },
  192. "知识产权出质": { # todo 没有发现索引 404
  193. "dim_name": "company_ipr_pledge",
  194. "summary_key": "", "sort_field": ""
  195. },
  196. "注销备案": {
  197. "dim_name": "",
  198. "summary_key": "", "sort_field": ""
  199. },
  200. "招投标": { # todo v9没有该维度
  201. "dim_name": "company_bid_new",
  202. "summary_key": "company_bid_new_del_0_supplier,company_bid_new_del_0_purchaser",
  203. "sort_field": "winhc_index_rt_company_bid_new:proxy.keyno:publish_time,winhc_index_rt_company_bid_new:purchaser_info.keyno:publish_time,winhc_index_rt_company_bid_new:supplier_info.keyno:publish_time"
  204. },
  205. "招聘信息": {
  206. "dim_name": "company_employment",
  207. "summary_key": "", "sort_field": ""
  208. },
  209. "特殊资质": {
  210. "dim_name": "",
  211. "summary_key": "", "sort_field": ""
  212. },
  213. "进出口信用": { # todo 404
  214. "dim_name": "company_customs_credit",
  215. "summary_key": "", "sort_field": ""
  216. },
  217. "行政许可": {
  218. "dim_name": "company_license,company_license_entpub,company_license_creditchina",
  219. "summary_key": "",
  220. "sort_field": "winhc_index_rt_company_license:company_id:start_date,winhc_index_rt_company_license_entpub:company_id:start_date,winhc_index_rt_company_license_creditchina:company_id:decision_date"
  221. },
  222. "土地公示": {
  223. "dim_name": "company_land_publicity",
  224. "summary_key": "", "sort_field": "publication_date"
  225. },
  226. "购地信息": {
  227. "dim_name": "company_land_announcement",
  228. "summary_key": "", "sort_field": "contract_date"
  229. },
  230. "土地转让-受让人": {
  231. "dim_name": "",
  232. "summary_key": "", "sort_field": ""
  233. },
  234. "土地抵押-抵押权人": {
  235. "dim_name": "",
  236. "summary_key": "", "sort_field": ""
  237. },
  238. "信用评级": {
  239. "dim_name": "",
  240. "summary_key": "", "sort_field": ""
  241. },
  242. "税务信用": {
  243. "dim_name": "",
  244. "summary_key": "", "sort_field": ""
  245. },
  246. "融资信息": {
  247. "dim_name": "company_finance",
  248. "summary_key": "", "sort_field": ""
  249. },
  250. "债券信息": {
  251. "dim_name": "",
  252. "summary_key": "", "sort_field": ""
  253. },
  254. "股权出质-质权人": {
  255. "dim_name": "",
  256. "summary_key": "", "sort_field": ""
  257. },
  258. "产品信息": {
  259. "dim_name": "company_app_info",
  260. "summary_key": "", "sort_field": ""
  261. },
  262. "主要客户": {
  263. "dim_name": "",
  264. "summary_key": "", "sort_field": ""
  265. },
  266. "供应商": {
  267. "dim_name": "",
  268. "summary_key": "", "sort_field": ""
  269. },
  270. "抽查检查": {
  271. "dim_name": "company_check_info",
  272. "summary_key": "", "sort_field": "check_date"
  273. },
  274. "产权交易": {
  275. "dim_name": "",
  276. "summary_key": "", "sort_field": ""
  277. },
  278. "双随机抽查": {
  279. "dim_name": "company_double_random_check_info",
  280. "summary_key": "", "sort_field": "check_date"
  281. },
  282. "商标": { # todo
  283. "dim_name": "company_tm",
  284. "summary_key": "", "sort_field": ""
  285. },
  286. "专利": {
  287. "dim_name": "company_patent",
  288. "summary_key": "", "sort_field": ""
  289. },
  290. "软件著作权": {
  291. "dim_name": "company_copyright_reg",
  292. "summary_key": "", "sort_field": ""
  293. },
  294. "作品著作权": {
  295. "dim_name": "company_copyright_works",
  296. "summary_key": "", "sort_field": ""
  297. },
  298. "网站域名": {
  299. "dim_name": "",
  300. "summary_key": "", "sort_field": ""
  301. },
  302. "建筑资质": {
  303. "dim_name": "",
  304. "summary_key": "", "sort_field": ""
  305. },
  306. "建筑人员": {
  307. "dim_name": "",
  308. "summary_key": "", "sort_field": ""
  309. },
  310. "建筑项目": {
  311. "dim_name": "",
  312. "summary_key": "", "sort_field": ""
  313. },
  314. "应收账款融资": {
  315. "dim_name": "",
  316. "summary_key": "", "sort_field": ""
  317. },
  318. "DCM注册额度": {
  319. "dim_name": "",
  320. "summary_key": "", "sort_field": ""
  321. },
  322. "债券融资": {
  323. "dim_name": "",
  324. "summary_key": "", "sort_field": ""
  325. },
  326. "境外债券融资": {
  327. "dim_name": "",
  328. "summary_key": "", "sort_field": ""
  329. },
  330. "银行借款": {
  331. "dim_name": "",
  332. "summary_key": "", "sort_field": ""
  333. },
  334. "授信额度": {
  335. "dim_name": "",
  336. "summary_key": "", "sort_field": ""
  337. },
  338. "租赁融资": {
  339. "dim_name": "",
  340. "summary_key": "", "sort_field": ""
  341. },
  342. "信托融资": {
  343. "dim_name": "",
  344. "summary_key": "", "sort_field": ""
  345. },
  346. "其他融资": {
  347. "dim_name": "",
  348. "summary_key": "", "sort_field": ""
  349. },
  350. }
  351. _summary_dim_2_name = {}
  352. list = ['行政处罚', '企业年报', '历史变更', '主要成员', '股东信息']
  353. _item_2_class = {}
  354. for i in _map_class:
  355. for j in _map_class[i]:
  356. _item_2_class[j] = i
  357. pass
  358. for i in _winhc_dim_map:
  359. # if i not in list:
  360. # continue
  361. if 'summary_key' in _winhc_dim_map[i] and _winhc_dim_map[i]['summary_key'] != '':
  362. summary_key = _winhc_dim_map[i]['summary_key']
  363. for j in summary_key.split(','):
  364. _summary_dim_2_name[j] = _winhc_dim_map[i].copy()
  365. _summary_dim_2_name[j]['item_name'] = i
  366. _summary_dim_2_name[j]['class'] = _item_2_class[i]
  367. pass
  368. else:
  369. dim_name = _winhc_dim_map[i]['dim_name']
  370. if dim_name is None or dim_name == '':
  371. continue
  372. for j in dim_name.split(','):
  373. _summary_dim_2_name[j + "_del_0"] = _winhc_dim_map[i].copy()
  374. _summary_dim_2_name[j + "_del_0"]['item_name'] = i
  375. _summary_dim_2_name[j + "_del_0"]['class'] = _item_2_class[i]
  376. pass
  377. if 'history_summary_key' in _winhc_dim_map[i] and _winhc_dim_map[i]['history_summary_key'] != '':
  378. history_summary_key = _winhc_dim_map[i]['history_summary_key']
  379. for j in history_summary_key.split(','):
  380. _summary_dim_2_name[j] = _winhc_dim_map[i].copy()
  381. _summary_dim_2_name[j]['item_name'] = '历史' + i
  382. _summary_dim_2_name[j]['class'] = '历史信息'
  383. pass
  384. elif 'history' in _winhc_dim_map[i] and _winhc_dim_map[i]['history']:
  385. dim_name = _winhc_dim_map[i]['dim_name']
  386. if dim_name is None or dim_name == '':
  387. continue
  388. for j in dim_name.split(','):
  389. _summary_dim_2_name[j + "_del_1"] = _winhc_dim_map[i].copy()
  390. _summary_dim_2_name[j + "_del_1"]['item_name'] = '历史' + i
  391. _summary_dim_2_name[j + "_del_1"]['class'] = '历史信息'
  392. pass
  393. pass
  394. _latest_date_map = {
  395. }
  396. for i in _winhc_dim_map:
  397. if _winhc_dim_map[i]['sort_field'] is None or _winhc_dim_map[i]['sort_field'] == '':
  398. continue
  399. sort_field = _winhc_dim_map[i]['sort_field']
  400. dim_name = _winhc_dim_map[i]['dim_name']
  401. # index:company_id_f:sort_f
  402. li = []
  403. for j in sort_field.split(','):
  404. format_str = j
  405. num = j.count(':')
  406. if num == 0:
  407. if dim_name is None or dim_name == '':
  408. raise ValueError("dim_name is null !")
  409. format_str = 'winhc_index_rt_{}:company_id:'.format(dim_name) + j
  410. pass
  411. elif num == 1:
  412. if dim_name is None or dim_name == '':
  413. raise ValueError("dim_name is null !")
  414. format_str = 'winhc_index_rt_{}:'.format(dim_name) + j
  415. pass
  416. elif num == 2:
  417. tmp_str = j.split(":")
  418. if tmp_str[1] == '':
  419. tmp_str[1] = 'company_id'
  420. format_str = ':'.join(tmp_str)
  421. pass
  422. else:
  423. raise ValueError('sort_field: ' + j + ' error, format is index:company_id_f:sort_f')
  424. pass
  425. li.append(format_str)
  426. pass
  427. _latest_date_map[i] = ','.join(li)
  428. pass
  429. def get_summary_map():
  430. return _summary_dim_2_name
  431. def get_latest_date_map():
  432. return _latest_date_map
  433. def key_2_name(key: str):
  434. end_index = len(key)
  435. while True:
  436. if key in _summary_dim_2_name:
  437. return key, _summary_dim_2_name[key], end_index
  438. end_index = key.rfind('_')
  439. key = key[:end_index]
  440. pass
  441. if __name__ == '__main__':
  442. from utils import map_2_json_str
  443. print(map_2_json_str(_latest_date_map))
  444. pass