dim_name_mapping.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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",
  85. "sort_field": "wenshu_detail2:litigant_info.litigant_id:judge_date"
  86. },
  87. "开庭公告": {
  88. "dim_name": "company_court_open_announcement",
  89. "summary_key": "company_court_open_announcement_del_0_plaintiff,company_court_open_announcement_del_0_defendant",
  90. "sort_field": "defendant_info.litigant_id:start_date,plaintiff_info.litigant_id:start_date"
  91. },
  92. "立案信息": {
  93. "dim_name": "company_court_register",
  94. "summary_key": "company_court_register_del_0_defendant,company_court_register_del_0_plaintiff",
  95. "sort_field": "defendant_info.litigant_id:filing_date,plaintiff_info.litigant_id:filing_date"
  96. },
  97. "法院公告": {
  98. "dim_name": "company_court_announcement",
  99. "summary_key": "company_court_announcement_del_0_plaintiff,company_court_announcement_del_0_litigant",
  100. "sort_field": "defendant_info.litigant_id:publish_date,plaintiff_info.litigant_id:publish_date"
  101. },
  102. "股权冻结": { # todo 没有时间
  103. "dim_name": "company_judicial_assistance",
  104. "summary_key": "", "sort_field": ""
  105. },
  106. "破产重整": {
  107. "dim_name": "",
  108. "summary_key": "", "sort_field": ""
  109. },
  110. "司法拍卖": {
  111. "dim_name": "auction_tracking",
  112. "summary_key": "", "sort_field": "company_info.company_id:start_time"
  113. },
  114. "询价评估": {
  115. "dim_name": "zxr_evaluate,zxr_evaluate_results",
  116. "summary_key": "", "sort_field": "winhc_index_rt_zxr_evaluate_results:keyno:publish_time"
  117. },
  118. "限制出境": {
  119. "dim_name": "restrictions_on_exit",
  120. "summary_key": "", "sort_field": ""
  121. },
  122. "诉前调解": {
  123. "dim_name": "litigation_mediation",
  124. "summary_key": "litigation_mediation_del_0_plaintiff,litigation_mediation_del_0_defendant",
  125. "sort_field": "defendant_info.litigant_id:filing_date,plaintiff_info.litigant_id:filing_date"
  126. },
  127. "破产债权": {
  128. "dim_name": "",
  129. "summary_key": "", "sort_field": ""
  130. },
  131. "行政处罚": {
  132. "dim_name": "company_punishment_info,company_punishment_info_creditchina",
  133. "summary_key": "",
  134. "sort_field": "winhc_index_rt_company_punishment_info:company_id:decision_date,winhc_index_rt_company_punishment_info_creditchina:company_id:decision_date"
  135. },
  136. "经营异常": {
  137. "dim_name": "company_abnormal_info",
  138. "summary_key": "", "sort_field": "put_date"
  139. },
  140. "股权出质": { # todo
  141. "dim_name": "company_equity_info",
  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": "",
  158. "summary_key": "", "sort_field": ""
  159. },
  160. "环保处罚": {
  161. "dim_name": "company_env_punishment",
  162. "summary_key": "", "sort_field": "publish_time"
  163. },
  164. "税收违法": {
  165. "dim_name": "company_tax_contravention",
  166. "summary_key": "", "sort_field": "publish_time"
  167. },
  168. "欠税公告": {
  169. "dim_name": "company_own_tax",
  170. "summary_key": "", "sort_field": "publish_date"
  171. },
  172. "公示催告": {
  173. "dim_name": "company_public_announcement",
  174. "summary_key": "", "sort_field": "publish_date"
  175. },
  176. "严重违法": {
  177. "dim_name": "company_illegal_info",
  178. "summary_key": "", "sort_field": "put_date"
  179. },
  180. "简易注销": {
  181. "dim_name": "company_brief_cancel_announcement",
  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. "股权质押-质押人": {
  193. "dim_name": "",
  194. "summary_key": "", "sort_field": ""
  195. },
  196. "知识产权出质": { # todo 没有发现索引 404
  197. "dim_name": "company_ipr_pledge",
  198. "summary_key": "", "sort_field": ""
  199. },
  200. "注销备案": {
  201. "dim_name": "",
  202. "summary_key": "", "sort_field": ""
  203. },
  204. "招投标": { # todo v9没有该维度
  205. "dim_name": "company_bid_new",
  206. "summary_key": "company_bid_new_del_0_supplier,company_bid_new_del_0_purchaser",
  207. "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"
  208. },
  209. "招聘信息": {
  210. "dim_name": "company_employment",
  211. "summary_key": "", "sort_field": ""
  212. },
  213. "特殊资质": {
  214. "dim_name": "",
  215. "summary_key": "", "sort_field": ""
  216. },
  217. "进出口信用": { # todo 404
  218. "dim_name": "company_customs_credit",
  219. "summary_key": "", "sort_field": ""
  220. },
  221. "行政许可": {
  222. "dim_name": "company_license,company_license_entpub,company_license_creditchina",
  223. "summary_key": "",
  224. "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"
  225. },
  226. "土地公示": {
  227. "dim_name": "company_land_publicity",
  228. "summary_key": "", "sort_field": "publication_date"
  229. },
  230. "购地信息": {
  231. "dim_name": "company_land_announcement",
  232. "summary_key": "", "sort_field": "contract_date"
  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": "",
  248. "summary_key": "", "sort_field": ""
  249. },
  250. "融资信息": {
  251. "dim_name": "company_finance",
  252. "summary_key": "", "sort_field": ""
  253. },
  254. "债券信息": {
  255. "dim_name": "",
  256. "summary_key": "", "sort_field": ""
  257. },
  258. "股权出质-质权人": {
  259. "dim_name": "",
  260. "summary_key": "", "sort_field": ""
  261. },
  262. "产品信息": { # todo 没有时间
  263. "dim_name": "company_app_info",
  264. "summary_key": "", "sort_field": ""
  265. },
  266. "主要客户": {
  267. "dim_name": "",
  268. "summary_key": "", "sort_field": ""
  269. },
  270. "供应商": {
  271. "dim_name": "",
  272. "summary_key": "", "sort_field": ""
  273. },
  274. "抽查检查": {
  275. "dim_name": "company_check_info",
  276. "summary_key": "", "sort_field": "check_date"
  277. },
  278. "产权交易": {
  279. "dim_name": "",
  280. "summary_key": "", "sort_field": ""
  281. },
  282. "双随机抽查": {
  283. "dim_name": "company_double_random_check_info",
  284. "summary_key": "", "sort_field": "check_date"
  285. },
  286. "商标": { # todo
  287. "dim_name": "company_tm",
  288. "summary_key": "company_tm_del_0", "sort_field": "app_date"
  289. },
  290. "专利": {
  291. "dim_name": "company_patent",
  292. "summary_key": "company_patent_del_0", "sort_field": "pub_date"
  293. },
  294. "软件著作权": {
  295. "dim_name": "company_copyright_reg",
  296. "summary_key": "", "sort_field": ""
  297. },
  298. "作品著作权": {
  299. "dim_name": "company_copyright_works",
  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. "应收账款融资": {
  319. "dim_name": "",
  320. "summary_key": "", "sort_field": ""
  321. },
  322. "DCM注册额度": {
  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. "dim_name": "",
  352. "summary_key": "", "sort_field": ""
  353. },
  354. }
  355. _summary_dim_2_name = {}
  356. list = ['行政处罚', '企业年报', '历史变更', '主要成员', '股东信息']
  357. _item_2_class = {}
  358. for i in _map_class:
  359. for j in _map_class[i]:
  360. _item_2_class[j] = i
  361. pass
  362. for i in _winhc_dim_map:
  363. # if i not in list:
  364. # continue
  365. if 'summary_key' in _winhc_dim_map[i] and _winhc_dim_map[i]['summary_key'] != '':
  366. summary_key = _winhc_dim_map[i]['summary_key']
  367. for j in summary_key.split(','):
  368. _summary_dim_2_name[j] = _winhc_dim_map[i].copy()
  369. _summary_dim_2_name[j]['item_name'] = i
  370. _summary_dim_2_name[j]['class'] = _item_2_class[i]
  371. pass
  372. else:
  373. dim_name = _winhc_dim_map[i]['dim_name']
  374. if dim_name is None or dim_name == '':
  375. continue
  376. for j in dim_name.split(','):
  377. _summary_dim_2_name[j + "_del_0"] = _winhc_dim_map[i].copy()
  378. _summary_dim_2_name[j + "_del_0"]['item_name'] = i
  379. _summary_dim_2_name[j + "_del_0"]['class'] = _item_2_class[i]
  380. pass
  381. if 'history_summary_key' in _winhc_dim_map[i] and _winhc_dim_map[i]['history_summary_key'] != '':
  382. history_summary_key = _winhc_dim_map[i]['history_summary_key']
  383. for j in history_summary_key.split(','):
  384. _summary_dim_2_name[j] = _winhc_dim_map[i].copy()
  385. _summary_dim_2_name[j]['item_name'] = '历史' + i
  386. _summary_dim_2_name[j]['class'] = '历史信息'
  387. pass
  388. elif 'history' in _winhc_dim_map[i] and _winhc_dim_map[i]['history']:
  389. dim_name = _winhc_dim_map[i]['dim_name']
  390. if dim_name is None or dim_name == '':
  391. continue
  392. for j in dim_name.split(','):
  393. _summary_dim_2_name[j + "_del_1"] = _winhc_dim_map[i].copy()
  394. _summary_dim_2_name[j + "_del_1"]['item_name'] = '历史' + i
  395. _summary_dim_2_name[j + "_del_1"]['class'] = '历史信息'
  396. pass
  397. pass
  398. _latest_date_map = {
  399. }
  400. for i in _winhc_dim_map:
  401. if _winhc_dim_map[i]['sort_field'] is None or _winhc_dim_map[i]['sort_field'] == '':
  402. continue
  403. sort_field = _winhc_dim_map[i]['sort_field']
  404. dim_name = _winhc_dim_map[i]['dim_name']
  405. # index:company_id_f:sort_f
  406. li = []
  407. for j in sort_field.split(','):
  408. format_str = j
  409. num = j.count(':')
  410. if num == 0:
  411. if dim_name is None or dim_name == '':
  412. raise ValueError("dim_name is null !")
  413. format_str = 'winhc_index_rt_{}:company_id:'.format(dim_name) + j
  414. pass
  415. elif num == 1:
  416. if dim_name is None or dim_name == '':
  417. raise ValueError("dim_name is null !")
  418. format_str = 'winhc_index_rt_{}:'.format(dim_name) + j
  419. pass
  420. elif num == 2:
  421. tmp_str = j.split(":")
  422. if tmp_str[1] == '':
  423. tmp_str[1] = 'company_id'
  424. format_str = ':'.join(tmp_str)
  425. pass
  426. else:
  427. raise ValueError('sort_field: ' + j + ' error, format is index:company_id_f:sort_f')
  428. pass
  429. li.append(format_str)
  430. pass
  431. _latest_date_map[i] = ','.join(li)
  432. pass
  433. def get_summary_map():
  434. return _summary_dim_2_name
  435. def get_latest_date_map():
  436. return _latest_date_map
  437. def key_2_name(key: str):
  438. end_index = len(key)
  439. while True:
  440. if key in _summary_dim_2_name:
  441. return key, _summary_dim_2_name[key], end_index
  442. end_index = key.rfind('_')
  443. key = key[:end_index]
  444. pass
  445. if __name__ == '__main__':
  446. from utils import map_2_json_str
  447. print(map_2_json_str(_latest_date_map))
  448. pass