|
@@ -3,9 +3,15 @@
|
|
|
# @Author : XuJiakai
|
|
|
# @File : case_utils
|
|
|
# @Software: PyCharm
|
|
|
-import re
|
|
|
+import asyncio
|
|
|
import datetime
|
|
|
+import json
|
|
|
+import re
|
|
|
+
|
|
|
from data_clean.api.es_api import search
|
|
|
+from data_clean.api.hbase_api import get as hbase_get
|
|
|
+from data_clean.utils.json_utils import json_path, del_key
|
|
|
+from data_clean.utils.party_name_verify_utils import person_name_list_verify
|
|
|
|
|
|
_case_no_year_pattern = re.compile("^[((](\\d{4}?)[))].+$")
|
|
|
|
|
@@ -23,27 +29,158 @@ def case_no_year_datetime(case_no, add_year: int = 0):
|
|
|
pass
|
|
|
|
|
|
|
|
|
-async def get_open_court_case_party(case_no: str):
|
|
|
+async def _general_query_case_party(case_no: str, index: str, doc_type: str = '_doc', case_no_key: str = 'case_no',
|
|
|
+ hbase_table_name: str = None):
|
|
|
+ if not case_no:
|
|
|
+ return None
|
|
|
+ result = await search(index=index, doc_type=doc_type, body={
|
|
|
+ "query": {
|
|
|
+ "bool": {
|
|
|
+ "must": [
|
|
|
+ {
|
|
|
+ "term": {
|
|
|
+ case_no_key: {
|
|
|
+ "value": case_no
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ "terms": {
|
|
|
+ "deleted": [
|
|
|
+ "0",
|
|
|
+ "1"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ result = result['hits']
|
|
|
+ total = result['total']
|
|
|
+ if total != 1:
|
|
|
+ return None
|
|
|
+ pass
|
|
|
+
|
|
|
+ record = result['hits'][0]
|
|
|
+ plaintiff_info = json_path(record, '$._source.plaintiff_info')
|
|
|
+ defendant_info = json_path(record, '$._source.defendant_info')
|
|
|
+ litigant_info = json_path(record, '$._source.litigant_info')
|
|
|
+ if not litigant_info:
|
|
|
+ if hbase_table_name:
|
|
|
+ rowkey = json_path(record, '$._id')
|
|
|
+ re = await hbase_get(hbase_table_name, rowkey)
|
|
|
+ if 'LITIGANT_INFO' in re:
|
|
|
+ li_str = re['LITIGANT_INFO']
|
|
|
+ litigant_info = json.loads(li_str)
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ litigant_info = []
|
|
|
+ if plaintiff_info:
|
|
|
+ litigant_info = litigant_info + plaintiff_info
|
|
|
+ if defendant_info:
|
|
|
+ litigant_info = litigant_info + defendant_info
|
|
|
+
|
|
|
+ names = [i['name'] for i in litigant_info]
|
|
|
+ flag, error_name = person_name_list_verify(names)
|
|
|
+ if not flag:
|
|
|
+ return None
|
|
|
+ pass
|
|
|
+
|
|
|
+ if plaintiff_info is None or defendant_info is None or litigant_info is None or len(plaintiff_info) == 0 or len(
|
|
|
+ defendant_info) == 0 or len(litigant_info) == 0:
|
|
|
+ return None
|
|
|
+
|
|
|
+ for i in plaintiff_info:
|
|
|
+ del_key(i, 'lawyer_info')
|
|
|
+ del_key(i, 'judge_tendency')
|
|
|
+ for i in defendant_info:
|
|
|
+ del_key(i, 'lawyer_info')
|
|
|
+ del_key(i, 'judge_tendency')
|
|
|
+ for i in litigant_info:
|
|
|
+ del_key(i, 'lawyer_info')
|
|
|
+ del_key(i, 'judge_tendency')
|
|
|
+
|
|
|
+ return {
|
|
|
+ "plaintiff_info": plaintiff_info,
|
|
|
+ "defendant_info": defendant_info,
|
|
|
+ "litigant_info": litigant_info,
|
|
|
+ "plaintiff": ','.join([i['name'] for i in plaintiff_info]),
|
|
|
+ "defendant": ','.join([i['name'] for i in defendant_info]),
|
|
|
+ "litigant": ','.join([i['name'] for i in litigant_info]),
|
|
|
+ }
|
|
|
+ pass
|
|
|
|
|
|
+
|
|
|
+async def get_open_court_case_party(case_no: str):
|
|
|
+ return await _general_query_case_party(case_no, "winhc_index_rt_company_court_open_announcement",
|
|
|
+ hbase_table_name="NG_RT_COMPANY_COURT_OPEN_ANNOUNCEMENT")
|
|
|
pass
|
|
|
|
|
|
|
|
|
async def get_register_case_party(case_no: str):
|
|
|
+ return await _general_query_case_party(case_no, "winhc_index_rt_company_court_register")
|
|
|
pass
|
|
|
|
|
|
|
|
|
async def get_judgement_document_party(case_no: str):
|
|
|
+ return await _general_query_case_party(case_no, "old.wenshu_detail2", doc_type='wenshu_detail_type',
|
|
|
+ case_no_key='case_no.keyword')
|
|
|
pass
|
|
|
|
|
|
|
|
|
-async def get_case_party(case_no: str):
|
|
|
+async def get_case_party(case_no: str, source: str = None):
|
|
|
if not case_no:
|
|
|
return None
|
|
|
|
|
|
+ if source == 'case_register':
|
|
|
+ result = await get_open_court_case_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+ result = await get_judgement_document_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+ elif source == 'open_court':
|
|
|
+ result = await get_register_case_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+ result = await get_judgement_document_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+ elif source == 'judgement_doc':
|
|
|
+ result = await get_register_case_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+ result = await get_open_court_case_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+ else:
|
|
|
+ result = await get_register_case_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+ result = await get_open_court_case_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+ result = await get_judgement_document_party(case_no)
|
|
|
+ if result:
|
|
|
+ return result
|
|
|
+
|
|
|
+ return None
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+async def test():
|
|
|
+ from base_utils import to_string
|
|
|
+ # print(await get_case_party("(2021)粤05民初2014号"))
|
|
|
+ # print(await get_case_party("(2020)冀0181民初1940号"))
|
|
|
+ # print(await get_case_party("(2020)冀0181民初2477号"))
|
|
|
+ # print(to_string(await get_case_party("(2020)冀09民终5209号"), is_format=False))
|
|
|
+ print(to_string(await get_case_party("(2020)苏0481民初1925号", source='open_court')))
|
|
|
+ # print(await get_register_case_party("(2017)津0119民初2784号"))
|
|
|
+ # print(await get_open_court_case_party("(2017)津0119民初2784号"))
|
|
|
+ # print(await get_judgement_document_party("(2017)津0119民初2784号"))
|
|
|
pass
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
- year_datetime = case_no_year_datetime("(2102)豫1681 民初535 号", 1)
|
|
|
- print(year_datetime)
|
|
|
+ asyncio.run(test())
|
|
|
pass
|