Kaynağa Gözat

fix: 统一通过log输出日志

许家凯 1 yıl önce
ebeveyn
işleme
c3a2cb6e9d
3 değiştirilmiş dosya ile 28 ekleme ve 4 silme
  1. 4 2
      JobMain.py
  2. 3 2
      data_clean/task_distributor.py
  3. 21 0
      data_clean/utils/case_utils.py

+ 4 - 2
JobMain.py

@@ -12,6 +12,7 @@ from aio_pika import IncomingMessage
 from environs import Env
 
 from data_clean.task_distributor import task_distribute
+from data_clean.utils import get_log
 from data_clean.utils.async_client import get_aio_kafka_consumer, get_aio_kafka_producer, get_rabbitmq_connection
 from data_clean.utils.asyncio_pool import AsyncPool
 
@@ -25,6 +26,7 @@ source_topic = env.str("source_topic", base_topic)  # "rt_company_dim"
 target_topic = env.str("target_topic", base_topic)  # "rt_company_dim"
 
 max_concurrency = env.int("concurrency", 1)
+log = get_log("JobMain")
 
 
 async def handle(producer, data: dict):
@@ -46,8 +48,8 @@ async def on_message_received(producer, msg: IncomingMessage):
 
 
 async def main_for_rabbitmq():
-    print("start job. Listening queue :", source_topic, "send topic:", target_topic, "max concurrency:",
-          max_concurrency)
+    log.info("start job. Listening queue :", source_topic, "send topic:", target_topic, "max concurrency:",
+             max_concurrency)
 
     pool = AsyncPool(max_concurrency)
 

+ 3 - 2
data_clean/task_distributor.py

@@ -8,11 +8,12 @@ import uuid
 import copy
 from data_clean.dim_handle_registry import get_class_dict
 from data_clean.statistic.data_clean_statistic import success
+from data_clean.utils import get_log
 
 scan_path = os.path.join(os.path.dirname(__file__), 'handle')
 
 file_name_list = [file_name[:-3] for file_name in os.listdir(scan_path) if not file_name.startswith("__")]
-
+log = get_log("task_distribute")
 # class_dict = {}
 for tn in file_name_list:
     tmp = __import__(f"data_clean.handle.{tn}", fromlist=(tn))
@@ -42,7 +43,7 @@ async def task_distribute(data: dict):
 
         else:
             # raise ValueError(f"{key} 维度未实现!")
-            print(f'{key}维度未实现!直接发送...')
+            log.warn(f'{key}维度未实现!直接发送...')
             pass
 
     if len(tmp_data) == 0:

+ 21 - 0
data_clean/utils/case_utils.py

@@ -5,6 +5,7 @@
 # @Software: PyCharm
 import re
 import datetime
+from data_clean.api.es_api import search
 
 _case_no_year_pattern = re.compile("^[((](\\d{4}?)[))].+$")
 
@@ -22,6 +23,26 @@ def case_no_year_datetime(case_no, add_year: int = 0):
     pass
 
 
+async def get_open_court_case_party(case_no: str):
+
+    pass
+
+
+async def get_register_case_party(case_no: str):
+    pass
+
+
+async def get_judgement_document_party(case_no: str):
+    pass
+
+
+async def get_case_party(case_no: str):
+    if not case_no:
+        return None
+
+    pass
+
+
 if __name__ == '__main__':
     year_datetime = case_no_year_datetime("(2102)豫1681 民初535 号", 1)
     print(year_datetime)