From 4008f7937f49c1f0a20c5e1bfadccd6c847dbd53 Mon Sep 17 00:00:00 2001 From: "shenjian@fangjia.com" Date: Thu, 6 Apr 2023 14:22:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/change_new_to_old_seaweed.py | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/dags/business/business/change_new_to_old_seaweed.py b/dags/business/business/change_new_to_old_seaweed.py index 2396db7..17cf1af 100644 --- a/dags/business/business/change_new_to_old_seaweed.py +++ b/dags/business/business/change_new_to_old_seaweed.py @@ -29,18 +29,27 @@ def do(): global count is_old = False time_now = int(time.mktime(time.strptime(datetime.datetime.now().strftime('%Y-%m-%d'), '%Y-%m-%d'))) - if 'open_date' in x and pd.notna(x['open_date']) and str(x['open_date']) != '': - time_old = int(time.mktime(time.strptime(dateutils.format_date(dateutils.add_months(x['open_date'], years=3), '%Y-%m-%d'), '%Y-%m-%d'))) - if time_old < time_now: - is_old = True - if is_old is False and 'live_date' in x and pd.notna(x['live_date']) and str(x['live_date']) != '': - time_old = int(time.mktime(time.strptime(dateutils.format_date(dateutils.add_months(dateutils.parse_date(x['live_date']), years=3), '%Y-%m-%d'), '%Y-%m-%d'))) - if time_old < time_now: - is_old = True - if is_old is False and 'create_year' in x and pd.notna(x['create_year']) and str(x['create_year']) != '': - time_old = int(time.mktime(time.strptime(dateutils.format_date(dateutils.add_months(dateutils.parse_date(x['create_year'], '%Y'), years=3), '%Y-%m-%d'), '%Y-%m-%d'))) - if time_old < time_now: - is_old = True + try: + if 'open_date' in x and pd.notna(x['open_date']) and str(x['open_date']) != '': + time_old = int(time.mktime(time.strptime(dateutils.format_date(dateutils.add_months(x['open_date'], years=3), '%Y-%m-%d'), '%Y-%m-%d'))) + if time_old < time_now: + is_old = True + except Exception as e: + log.error(e) + try: + if is_old is False and 'live_date' in x and pd.notna(x['live_date']) and str(x['live_date']) != '': + time_old = int(time.mktime(time.strptime(dateutils.format_date(dateutils.add_months(dateutils.parse_date(x['live_date']), years=3), '%Y-%m-%d'), '%Y-%m-%d'))) + if time_old < time_now: + is_old = True + except Exception as e: + log.error(e) + try: + if is_old is False and 'create_year' in x and pd.notna(x['create_year']) and str(x['create_year']) != '': + time_old = int(time.mktime(time.strptime(dateutils.format_date(dateutils.add_months(dateutils.parse_date(x['create_year'], '%Y'), years=3), '%Y-%m-%d'), '%Y-%m-%d'))) + if time_old < time_now: + is_old = True + except Exception as e: + log.error(e) # 查询样本库 names = [x['name']] if type(x['alias']) == list: