feat: 制御対象の処理追加

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2023-04-14 18:21:52 +09:00
parent 8c73f153d6
commit 834bc503dd
6 changed files with 67 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -1,3 +0,0 @@
def exec():
"""メルク施設マスタ作成"""
pass

View File

@ -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()

View File

@ -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):

View File

@ -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