From 5d16bceec95f4bd064d18246f55fc32dd5736e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E6=9C=A8=E8=A6=81?= Date: Thu, 25 May 2023 16:22:05 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20SQL=E4=BF=AE=E6=AD=A3=E3=80=81=E5=8D=98?= =?UTF-8?q?=E4=BD=93=E8=A9=A6=E9=A8=93=E6=9B=B8=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E6=99=82=E3=81=AE=E6=8C=87=E6=91=98=E3=81=AE=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integrate_dcf_inst_merge.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ecs/jskult-batch-daily/src/batch/dcf_inst_merge/integrate_dcf_inst_merge.py b/ecs/jskult-batch-daily/src/batch/dcf_inst_merge/integrate_dcf_inst_merge.py index ffb2ba06..6e9bf5e4 100644 --- a/ecs/jskult-batch-daily/src/batch/dcf_inst_merge/integrate_dcf_inst_merge.py +++ b/ecs/jskult-batch-daily/src/batch/dcf_inst_merge/integrate_dcf_inst_merge.py @@ -90,12 +90,15 @@ def _add_ult_ident_presc(db: Database, enabled_dst_inst_merge_records: list[dict continue # 重複予定データが存在しない、且つ、適用終了日 ≧ 適用開始日の場合 if not is_exists_duplicate_key: - # 適用終了日を、DCF施設統合マスタの適用月度の前月末日で更新 last_end_date = tekiyo_month_first_day - timedelta(days=1) - _update_ult_ident_presc_end_date(db, _date_time_to_str(last_end_date), ult_ident_presc_row) + # 適用開始日 > DCF施設統合マスタの適用月度の前月末日の場合 if start_date > last_end_date: + # 対象レコードを物理削除する _delete_ult_ident_presc(db, ult_ident_presc_row['start_date'], ult_ident_presc_row, '適用終了日更新後 開始日>終了日のため物理削除') + continue + # 適用終了日を、DCF施設統合マスタの適用月度の前月末日で更新 + _update_ult_ident_presc_end_date(db, _date_time_to_str(last_end_date), ult_ident_presc_row) logger.info('納入先処方元マスタの登録 終了') @@ -195,7 +198,7 @@ def _update_emp_chg_inst_end_date(db: Database, dcf_inst_cd: str, last_end_date: src05.emp_chg_inst SET end_date = :end_date, updater = CURRENT_USER(), - update_date= SYSDATE() + update_date = SYSDATE() WHERE inst_cd = :dcf_inst_cd AND ta_cd = :ta_cd @@ -310,9 +313,9 @@ def _select_dct_inst_merge(db: Database, muko_flg: int) -> list[dict]: def _update_dcf_inst_merge(db: Database, muko_flg: int) -> int: # dcf_inst_mergeをUPDATE # muko_flgの値によって、SQLのWHERE条件とSET句を変更 - try: + try: elapsed_time = ElapsedTime() - log_message = '更新しました' if muko_flg == 0 else '無効データに戻しました' + log_message = '更新しました' if muko_flg == 0 else '無効データに戻しました' sql = """ UPDATE src05.dcf_inst_merge AS updim @@ -330,7 +333,7 @@ def _update_dcf_inst_merge(db: Database, muko_flg: int) -> int: ON dim.tekiyo_month = DATE_FORMAT(ht.syor_date, '%Y%m') WHERE dim.muko_flg = :muko_flg - AND dim.enabled_flg='Y' + AND dim.enabled_flg ='Y' AND dim.dcf_inst_cd_new IS {not_null}NULL ) AS bf_dim SET @@ -397,7 +400,7 @@ def _update_ult_ident_presc_end_date(db: Database, last_end_date: str, ult_ident src05.ult_ident_presc SET end_date = :end_date, updater = CURRENT_USER(), - update_date= SYSDATE() + update_date = SYSDATE() WHERE ta_cd = :ta_cd AND ult_ident_cd = :ult_ident_cd @@ -519,7 +522,7 @@ def _select_ult_ident_presc(db: Database, dcf_inst_cd: str, dup_opp_cd: str) -> SELECT COUNT(uipopp.ta_cd) FROM - ult_ident_presc AS uipopp + src05.ult_ident_presc AS uipopp WHERE uipopp.presc_cd = :dup_opp_cd ) AS opp_count