Pārlūkot izejas kodu

feat: 添加时间格式校验的异常

许家凯 1 gadu atpakaļ
vecāks
revīzija
5f93ef4210

+ 1 - 1
.drone.yml

@@ -11,7 +11,7 @@ steps:
       registry_mirrors: 9s9ylon1.mirror.aliyuncs.com
       registry: registry-vpc.cn-shanghai.aliyuncs.com
       skip_tls_verify: true
-      enable_cache: false
+      enable_cache: true
       cache_repo: 192.168.1.7:5000/winhc-spider/data-clean
       username:
         from_secret: username

+ 1 - 1
JobMain.py

@@ -30,7 +30,7 @@ max_concurrency = env.int("concurrency", 1)
 async def handle(producer, data: dict):
     result = await task_distribute(data)
 
-    print("send : ", result)
+    # print("send : ", result)
 
     if result is not None:
         await producer.send_and_wait(target_topic, json.dumps(result).encode())

+ 0 - 1
README.md

@@ -1 +0,0 @@
-b

+ 0 - 2
data_clean/handle/company_court_open_announcement.py

@@ -55,10 +55,8 @@ async def party_intersect(row_data: dict) -> dict:
 async def open_ann_date(row_data: dict) -> dict:
     # 过滤开庭时间早于建国时间问题
     if 'start_date' in row_data:
-
         if not row_data['start_date']:
             raise RulerValidationException("ccoa_002", "开庭时间为空")
-            pass
 
         this_date = str_2_date_time(row_data['start_date'])
         if this_date < establish_state_time:

+ 7 - 1
data_clean/utils/date_utils.py

@@ -6,6 +6,8 @@
 
 from datetime import datetime
 
+from data_clean.exception.ruler_validation_exception import RulerValidationException
+
 establish_state_time = datetime(year=1949, month=10, day=1)
 
 
@@ -15,7 +17,11 @@ def get_update_time():
 
 
 def str_2_date_time(date_str, format="%Y-%m-%d %H:%M:%S"):
-    return datetime.strptime(date_str, format)
+    try:
+        return datetime.strptime(date_str, format)
+    except Exception as ex:
+        raise RulerValidationException("%s,时间解析异常,%s" % (date_str, str(ex)))
+        pass
     pass