feat: レビュー指摘対応
This commit is contained in:
parent
bb00b9d9d4
commit
f1641b2739
@ -1,14 +0,0 @@
|
||||
from src.batch.datachange import emp_chg_inst_lau
|
||||
from src.batch.datachange import create_inst_merge_for_laundering
|
||||
from src.logging.get_logger import get_logger
|
||||
|
||||
logger = get_logger('実績洗替')
|
||||
|
||||
|
||||
def batch_process():
|
||||
"""実績洗替処理"""
|
||||
logger.info('Start Jisseki Araigae Batch PGM.')
|
||||
# 洗替用マスタ作成
|
||||
create_inst_merge_for_laundering.batch_process()
|
||||
# 施設担当者洗替
|
||||
emp_chg_inst_lau.batch_process()
|
||||
@ -5,7 +5,7 @@ from src.logging.get_logger import get_logger
|
||||
logger = get_logger('洗替用マスタ作成')
|
||||
|
||||
|
||||
def batch_process():
|
||||
def exec():
|
||||
db = Database.get_instance()
|
||||
|
||||
try:
|
||||
@ -17,7 +17,7 @@ def batch_process():
|
||||
logger.debug('処理終了')
|
||||
except Exception as e:
|
||||
raise BatchOperationException(e)
|
||||
finally:
|
||||
finally:
|
||||
db.disconnect()
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
from src.batch.common.batch_context import BatchContext
|
||||
from src.batch.laundering import emp_chg_inst_laundering
|
||||
from src.batch.laundering import create_inst_merge_for_laundering, emp_chg_inst_laundering, ult_ident_presc_laundering
|
||||
from src.logging.get_logger import get_logger
|
||||
|
||||
batch_context = BatchContext.get_instance()
|
||||
@ -14,9 +14,12 @@ def exec():
|
||||
if batch_context.is_not_business_day:
|
||||
logger.info('営業日ではないため、実績洗替処理をスキップします。')
|
||||
return
|
||||
|
||||
# 洗替用マスタ作成
|
||||
create_inst_merge_for_laundering.exec()
|
||||
# 施設担当者洗替
|
||||
emp_chg_inst_laundering.exec()
|
||||
# 納入先処方元マスタ洗替
|
||||
ult_ident_presc_laundering.exec()
|
||||
|
||||
# # 並列処理のテスト用コード
|
||||
# import time
|
||||
|
||||
@ -16,19 +16,14 @@ def exec():
|
||||
logger.debug('納入先処方元マスタの洗替処理開始')
|
||||
# ult_ident_presc_lauをTruncate
|
||||
_truncate_ult_ident_presc_lau(db)
|
||||
# トランザクション開始
|
||||
db.begin()
|
||||
# ult_ident_presc から、ult_ident_presc_lauへInsert
|
||||
_insert_into_ult_ident_presc_lau_from_ult_ident_presc(db)
|
||||
# v_inst_merge_tから、ult_ident_presc_lauをUpdate
|
||||
_update_ult_ident_presc_lau_from_v_inst_merge_t(db)
|
||||
# inst_merge_tから、ult_ident_presc_lauをUpdate
|
||||
_update_ult_ident_presc_lau_from_inst_merge_t(db)
|
||||
# コミット
|
||||
db.commit()
|
||||
logger.debug('納入先処方元マスタの洗替処理製造終了')
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
raise BatchOperationException(e)
|
||||
finally:
|
||||
db.disconnect()
|
||||
@ -36,7 +31,7 @@ def exec():
|
||||
|
||||
def _truncate_ult_ident_presc_lau(db: Database):
|
||||
try:
|
||||
db.execute("TRUNCATE TABLE ult_ident_presc_lau")
|
||||
db.execute("TRUNCATE TABLE src05.ult_ident_presc_lau")
|
||||
except Exception as e:
|
||||
logger.debug("納入先処方元マスタ(洗替後)の全件削除に失敗")
|
||||
raise e
|
||||
@ -48,7 +43,7 @@ def _truncate_ult_ident_presc_lau(db: Database):
|
||||
def _insert_into_ult_ident_presc_lau_from_ult_ident_presc(db: Database):
|
||||
try:
|
||||
elapsed_time = ElapsedTime()
|
||||
sql = "INSERT INTO ult_ident_presc_lau SELECT *, null FROM ult_ident_presc"
|
||||
sql = "INSERT INTO src05.ult_ident_presc_lau SELECT *, NULL FROM src05.ult_ident_presc"
|
||||
res = db.execute(sql)
|
||||
logging_sql(logger, sql)
|
||||
logger.info(f'処方元マスタから処方元マスタ(洗替後)に全件コピーに成功, {res.rowcount} 行更新 ({elapsed_time.of})')
|
||||
Loading…
x
Reference in New Issue
Block a user