feat: SQL修正、単体試験書レビュー時の指摘の対応

This commit is contained in:
高木要 2023-05-25 16:22:05 +09:00
parent 7da4be471c
commit 5d16bceec9

View File

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