feat: 日付テーブルに関する共通処理実装完了。処理に組み込み。
This commit is contained in:
parent
fbd3bdb590
commit
09307c0142
@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
from src.aws.s3 import (JskIOBucket, TransferResultOutputBucket, UltmarcBucket,
|
from src.aws.s3 import (JskIOBucket, TransferResultOutputBucket, UltmarcBucket,
|
||||||
UltmarcImportBucket)
|
UltmarcImportBucket)
|
||||||
from src.batch.batch_functions import (
|
|
||||||
get_batch_statuses, update_batch_processing_flag_in_processing)
|
|
||||||
from src.error.exceptions import BatchOperationException
|
from src.error.exceptions import BatchOperationException
|
||||||
from src.logging.get_logger import get_logger
|
from src.logging.get_logger import get_logger
|
||||||
|
from src.manager.jskult_hdke_tbl_manager import JskultHdkeTblManager
|
||||||
from src.system_var import constants
|
from src.system_var import constants
|
||||||
|
|
||||||
logger = get_logger('実消化&アルトマークデータ転送')
|
logger = get_logger('実消化&アルトマークデータ転送')
|
||||||
@ -19,30 +18,23 @@ def exec():
|
|||||||
# 転送データリストを初期化する。
|
# 転送データリストを初期化する。
|
||||||
transfer_file_lists = {"transfer_list": []}
|
transfer_file_lists = {"transfer_list": []}
|
||||||
|
|
||||||
|
hdke_tbl_manager = JskultHdkeTblManager()
|
||||||
# ② 日付テーブルのステータスを確認する
|
# ② 日付テーブルのステータスを確認する
|
||||||
try:
|
try:
|
||||||
# 日次バッチ処置中フラグ、dump処理状態区分、処理日を取得
|
if not hdke_tbl_manager.can_run_process():
|
||||||
batch_processing_flag, dump_status_kbn, syor_date = get_batch_statuses()
|
logger.error('日次バッチ処理中またはdump取得が正常終了していないため、データ転送処理を終了します。')
|
||||||
|
return constants.BATCH_EXIT_CODE_SUCCESS
|
||||||
|
# 処理日を取得
|
||||||
|
_, _, syor_date = hdke_tbl_manager.get_batch_statuses()
|
||||||
except BatchOperationException as e:
|
except BatchOperationException as e:
|
||||||
logger.exception(f'日付テーブル取得(異常終了){e}')
|
logger.exception(f'日付テーブル取得(異常終了){e}')
|
||||||
return constants.BATCH_EXIT_CODE_SUCCESS
|
return constants.BATCH_EXIT_CODE_SUCCESS
|
||||||
|
|
||||||
# 日次バッチ処理中の場合、後続の処理は行わない
|
|
||||||
if batch_processing_flag == constants.BATCH_ACTF_BATCH_IN_PROCESSING:
|
|
||||||
logger.error('日次バッチ処理中のため、日次バッチ処理を終了します。')
|
|
||||||
return constants.BATCH_EXIT_CODE_SUCCESS
|
|
||||||
|
|
||||||
# dump取得が正常終了していない場合、後続の処理は行わない
|
|
||||||
if dump_status_kbn != constants.DUMP_STATUS_KBN_COMPLETE:
|
|
||||||
logger.error('dump取得が正常終了していないため、日次バッチ処理を終了します。')
|
|
||||||
return constants.BATCH_EXIT_CODE_SUCCESS
|
|
||||||
|
|
||||||
logger.info(f'処理日={syor_date}')
|
logger.info(f'処理日={syor_date}')
|
||||||
|
|
||||||
logger.info('I-2 日次バッチ処理中フラグ更新')
|
logger.info('I-2 日次バッチ処理中フラグ更新')
|
||||||
# バッチ処理中に更新
|
# バッチ処理中に更新
|
||||||
try:
|
try:
|
||||||
update_batch_processing_flag_in_processing()
|
hdke_tbl_manager.update_batch_process_start()
|
||||||
except BatchOperationException as e:
|
except BatchOperationException as e:
|
||||||
logger.exception(f'処理フラグ更新(未処理→処理中) エラー(異常終了){e}')
|
logger.exception(f'処理フラグ更新(未処理→処理中) エラー(異常終了){e}')
|
||||||
return constants.BATCH_EXIT_CODE_SUCCESS
|
return constants.BATCH_EXIT_CODE_SUCCESS
|
||||||
|
|||||||
@ -12,16 +12,13 @@ class JskultHdkeTblManager:
|
|||||||
self._db = Database.get_instance()
|
self._db = Database.get_instance()
|
||||||
|
|
||||||
def get_batch_statuses(self) -> tuple[str, str, str]:
|
def get_batch_statuses(self) -> tuple[str, str, str]:
|
||||||
"""日付テーブルから、以下を取得して返す。
|
"""日次バッチ処理中フラグ、dump取得状況区分、処理日を取得する
|
||||||
- 日次バッチ処理中フラグ
|
|
||||||
- dump取得状況区分
|
|
||||||
- 処理日(YYYY/MM/DD)
|
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
BatchOperationException: 日付テーブルが取得できないとき、何らかのエラーが発生したとき
|
BatchOperationException: DB操作の何らかのエラー
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
tuple[str, str]: [0]日次バッチ処理中フラグ、dump取得状況区分
|
tuple[str, str, str]: [0]日次バッチ処理中フラグ、[1]dump取得状況区分、[2]処理日
|
||||||
"""
|
"""
|
||||||
sql = 'SELECT bch_actf, dump_sts_kbn, src07.get_syor_date() AS syor_date FROM src07.hdke_tbl'
|
sql = 'SELECT bch_actf, dump_sts_kbn, src07.get_syor_date() AS syor_date FROM src07.hdke_tbl'
|
||||||
try:
|
try:
|
||||||
@ -51,6 +48,7 @@ class JskultHdkeTblManager:
|
|||||||
Raises:
|
Raises:
|
||||||
BatchOperationException: DB操作の何らかのエラー
|
BatchOperationException: DB操作の何らかのエラー
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sql = """\
|
sql = """\
|
||||||
UPDATE src07.hdke_tbl
|
UPDATE src07.hdke_tbl
|
||||||
SET
|
SET
|
||||||
@ -70,12 +68,13 @@ class JskultHdkeTblManager:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def update_batch_process_complete(self):
|
def update_batch_process_complete(self) -> None:
|
||||||
"""バッチ処理を完了とし、処理日、バッチ処理中フラグ、dump処理状態区分を更新する
|
"""バッチ正常終了処理時の更新処理
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
BatchOperationException: DB操作の何らかのエラー
|
BatchOperationException: DB操作の何らかのエラー
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sql = """\
|
sql = """\
|
||||||
UPDATE src07.hdke_tbl
|
UPDATE src07.hdke_tbl
|
||||||
SET
|
SET
|
||||||
@ -97,5 +96,27 @@ class JskultHdkeTblManager:
|
|||||||
finally:
|
finally:
|
||||||
self._db.disconnect()
|
self._db.disconnect()
|
||||||
|
|
||||||
def can_run_process(self):
|
def can_run_process(self) -> bool:
|
||||||
pass
|
"""バッチ処理を起動してよいかを判定する
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
BatchOperationException: DB操作の何らかのエラー
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: バッチ処理を実行して良い場合はTrue
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# 日次バッチ処置中フラグ、dump処理状態区分を取得
|
||||||
|
batch_processing_flag, dump_status_kbn, _ = self.get_batch_statuses()
|
||||||
|
except DBException as e:
|
||||||
|
raise BatchOperationException(e)
|
||||||
|
finally:
|
||||||
|
self._db.disconnect()
|
||||||
|
# 日次バッチ処理中の場合、後続の処理は行わない
|
||||||
|
if batch_processing_flag == constants.BATCH_ACTF_BATCH_IN_PROCESSING:
|
||||||
|
return False
|
||||||
|
# dump取得が正常終了していない場合、後続の処理は行わない
|
||||||
|
if dump_status_kbn != constants.DUMP_STATUS_KBN_COMPLETE:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user