From 834bc503dd9e8b019eb78f6ad765b666d23e418e Mon Sep 17 00:00:00 2001 From: "shimoda.m@nds-tyo.co.jp" Date: Fri, 14 Apr 2023 18:21:52 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=B6=E5=BE=A1=E5=AF=BE=E8=B1=A1?= =?UTF-8?q?=E3=81=AE=E5=87=A6=E7=90=86=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/laundering/create_dcf_inst_merge.py | 15 ++++++++++ .../src/batch/laundering/create_mst_inst.py | 21 ++++++++++++++ .../src/batch/laundering/mst_inst_create.py | 3 -- .../src/batch/laundering/sales_laundering.py | 10 ++++++- .../src/batch/ultmarc/ultmarc_process.py | 5 ++-- ecs/jskult-batch-daily/src/jobctrl_daily.py | 29 ++++++++++++------- 6 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 ecs/jskult-batch-daily/src/batch/laundering/create_dcf_inst_merge.py create mode 100644 ecs/jskult-batch-daily/src/batch/laundering/create_mst_inst.py delete mode 100644 ecs/jskult-batch-daily/src/batch/laundering/mst_inst_create.py diff --git a/ecs/jskult-batch-daily/src/batch/laundering/create_dcf_inst_merge.py b/ecs/jskult-batch-daily/src/batch/laundering/create_dcf_inst_merge.py new file mode 100644 index 00000000..974aa329 --- /dev/null +++ b/ecs/jskult-batch-daily/src/batch/laundering/create_dcf_inst_merge.py @@ -0,0 +1,15 @@ +from src.batch.common.batch_context import BatchContext +from src.logging.get_logger import get_logger + +batch_context = BatchContext.get_instance() +logger = get_logger('DCF施設統合マスタ作成') + + +def exec(): + """DCF施設統合マスタ作成""" + + # アルトマーク取込が行われていない場合は処理をスキップする + if not batch_context.is_ultmarc_imported: + logger.info('アルトマーク取込が行われていないため、DCF施設統合マスタ作成処理をスキップします。') + + pass diff --git a/ecs/jskult-batch-daily/src/batch/laundering/create_mst_inst.py b/ecs/jskult-batch-daily/src/batch/laundering/create_mst_inst.py new file mode 100644 index 00000000..832e430d --- /dev/null +++ b/ecs/jskult-batch-daily/src/batch/laundering/create_mst_inst.py @@ -0,0 +1,21 @@ +from src.batch.common.batch_context import BatchContext +from src.logging.get_logger import get_logger + +batch_context = BatchContext.get_instance() +logger = get_logger('メルク施設統合マスタ') + + +def exec(): + """メルク施設統合マスタ""" + + # 営業日ではない場合、処理をスキップする + if batch_context.is_not_business_day: + logger.info('営業日ではないため、メルク施設統合マスタ作成処理をスキップします。') + return + + # アルトマーク取込が行われていない場合は処理をスキップする + if not batch_context.is_ultmarc_imported: + logger.info('アルトマーク取込が行われていないため、メルク施設統合マスタ作成処理をスキップします。') + return + + pass diff --git a/ecs/jskult-batch-daily/src/batch/laundering/mst_inst_create.py b/ecs/jskult-batch-daily/src/batch/laundering/mst_inst_create.py deleted file mode 100644 index a2e52df4..00000000 --- a/ecs/jskult-batch-daily/src/batch/laundering/mst_inst_create.py +++ /dev/null @@ -1,3 +0,0 @@ -def exec(): - """メルク施設マスタ作成""" - pass diff --git a/ecs/jskult-batch-daily/src/batch/laundering/sales_laundering.py b/ecs/jskult-batch-daily/src/batch/laundering/sales_laundering.py index c1884b7d..962b3e12 100644 --- a/ecs/jskult-batch-daily/src/batch/laundering/sales_laundering.py +++ b/ecs/jskult-batch-daily/src/batch/laundering/sales_laundering.py @@ -1,11 +1,19 @@ +from src.batch.common.batch_context import BatchContext from src.batch.laundering import emp_chg_inst_laundering from src.logging.get_logger import get_logger +batch_context = BatchContext.get_instance() + logger = get_logger('実績洗替') def exec(): """実績洗替処理""" - logger.info('Start Jisseki Araigae Batch PGM.') + + # 非営業日の場合実績洗替処理は実行しない + if batch_context.is_not_business_day: + logger.info('非営業日のため、実績洗替処理をスキップします。') + return + # 施設担当者洗替 emp_chg_inst_laundering.exec() diff --git a/ecs/jskult-batch-daily/src/batch/ultmarc/ultmarc_process.py b/ecs/jskult-batch-daily/src/batch/ultmarc/ultmarc_process.py index 4c331b56..8ddae44a 100644 --- a/ecs/jskult-batch-daily/src/batch/ultmarc/ultmarc_process.py +++ b/ecs/jskult-batch-daily/src/batch/ultmarc/ultmarc_process.py @@ -66,9 +66,10 @@ def exec_import(): def exec_export(): - # 取り込み日に限らず、毎日実行する """V実消化用施設・薬局薬店データ作成処理""" - pass + if not batch_context.is_ultmarc_imported: + logger.info('アルトマーク取込が行われていないため、V実消化用施設・薬局薬店データ作成処理をスキップします。') + return def _import_to_ultmarc_table(dat_file: DatFile): diff --git a/ecs/jskult-batch-daily/src/jobctrl_daily.py b/ecs/jskult-batch-daily/src/jobctrl_daily.py index 94e8a835..0b865b9b 100644 --- a/ecs/jskult-batch-daily/src/jobctrl_daily.py +++ b/ecs/jskult-batch-daily/src/jobctrl_daily.py @@ -6,7 +6,8 @@ from src.batch.batch_functions import ( update_batch_processing_flag_in_processing) from src.batch.common.batch_context import BatchContext from src.batch.common.calendar_file import CalendarFile -from src.batch.laundering import sales_laundering +from src.batch.laundering import (create_dcf_inst_merge, create_mst_inst, + sales_laundering) from src.batch.ultmarc import ultmarc_process from src.error.exceptions import BatchOperationException from src.logging.get_logger import get_logger @@ -20,7 +21,7 @@ batch_context = BatchContext.get_instance() def exec(): try: - logger.info('日次ジョブ:開始') + logger.info('日次バッチ:開始') try: # 日次バッチ処置中フラグ、dump処理状態区分、処理日を取得 batch_processing_flag, dump_status_kbn, syor_date = get_batch_statuses() @@ -36,7 +37,7 @@ def exec(): # dump取得が正常終了していない場合、後続の処理は行わない if dump_status_kbn not in [constants.DUMP_STATUS_KBN_COMPLETE, constants.DUMP_STATUS_KBN_DUMP_SKIP]: logger.error('dump取得が正常終了していないため、日次バッチ処理を終了します。') - return constants.BATCH_EXIT_CODE_SUCCESS # TODO: エラーで返せば、StepFunctionsでリトライしてくれるので、どう返すかは要検討 + return constants.BATCH_EXIT_CODE_SUCCESS logger.info(f'処理日={syor_date}') # バッチ共通設定に処理日を追加 @@ -45,7 +46,7 @@ def exec(): # 稼働日かかどうかを、非営業日ファイルをダウンロードして判定 holiday_list_file_path = ConfigBucket().download_holiday_list() holiday_calendar = CalendarFile(holiday_list_file_path) - batch_context.is_not_business_day = not holiday_calendar.compare_date(syor_date) + batch_context.is_not_business_day = holiday_calendar.compare_date(syor_date) # バッチ処理中に更新 try: @@ -54,7 +55,6 @@ def exec(): logger.exception(f'処理フラグ更新(未処理→処理中) エラー(異常終了){e}') return constants.BATCH_EXIT_CODE_SUCCESS - logger.info('日次処理(アルトマーク)') try: logger.info('アルトマーク取込:起動') ultmarc_process.exec_import() @@ -79,18 +79,16 @@ def exec(): logger.exception(f'V実消化取込処理エラー(異常終了){e}') return constants.BATCH_EXIT_CODE_SUCCESS - # 非稼働日や、月火水に限らず、必ず実施 - logger.info('メルク施設マスタ作成') try: logger.info('メルク施設マスタ作成:起動') + create_mst_inst.exec() logger.info('メルク施設マスタ作成:終了') except BatchOperationException as e: logger.exception(f'メルク施設マスタ作成 エラー(異常終了){e}') return constants.BATCH_EXIT_CODE_SUCCESS - logger.info('日次処理(実績更新)') try: - # ここで、生物由来ロット分解と並行処理 + # TODO: ここで、生物由来ロット分解と並行処理 logger.info('実績更新:起動') sales_laundering.exec() logger.info('生物由来ロット分解:起動') @@ -100,6 +98,16 @@ def exec(): logger.exception(f'実績更新処理エラー(異常終了){e}') return constants.BATCH_EXIT_CODE_SUCCESS + # TODO: ここで並行処理合流 + + try: + logger.info('DCF施設統合マスタ作成:起動') + create_dcf_inst_merge.exec() + logger.info('DCF施設統合マスタ作成:終了') + except BatchOperationException as e: + logger.exception(f'DCF施設統合マスタ作成エラー(異常終了){e}') + return constants.BATCH_EXIT_CODE_SUCCESS + # バッチ処理完了とし、処理日、バッチ処置中フラグ、dump取得状態区分を更新 try: update_batch_process_complete() @@ -108,8 +116,9 @@ def exec(): return constants.BATCH_EXIT_CODE_SUCCESS # 正常終了を保守ユーザーに通知 - logger.info('[NOTICE]日次ジョブ:終了(正常終了)') + logger.info('[NOTICE]日次バッチ:終了(正常終了)') return constants.BATCH_EXIT_CODE_SUCCESS + except Exception as e: logger.exception(f'日次バッチ処理中に想定外のエラーが発生しました {e}') raise e