施設担当者変更実装・指摘修正
This commit is contained in:
parent
df0f2d129f
commit
e29bbe4455
@ -1,19 +0,0 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from src.model.db.base_db_model import BaseDBModel
|
||||
|
||||
|
||||
class GenericKbnMstModel(BaseDBModel):
|
||||
generic_kbn_cd: Optional[str]
|
||||
kbn_cd: Optional[str]
|
||||
kbn_fulll_name_jp: Optional[str]
|
||||
kbn_full_name_en: Optional[str]
|
||||
kbn_name: Optional[str]
|
||||
start_date: Optional[datetime]
|
||||
end_date: Optional[datetime]
|
||||
creator: Optional[str]
|
||||
create_date: Optional[datetime]
|
||||
updater: Optional[str]
|
||||
update_date: Optional[datetime]
|
||||
|
||||
@ -63,6 +63,8 @@ class MasterMainteCSVItem(metaclass=ABCMeta):
|
||||
error_list.extend(self.check_inst_cd_exists())
|
||||
# 担当者種別コード存在チェック
|
||||
error_list.extend(self.check_emp_chg_type_cd_exists())
|
||||
# 領域コード存在チェック
|
||||
error_list.extend(self.check_ta_cd_exists())
|
||||
# MUID存在チェック
|
||||
error_list.extend(self.check_emp_cd_exists())
|
||||
# BuCd存在チェック
|
||||
@ -97,8 +99,11 @@ class MasterMainteCSVItem(metaclass=ABCMeta):
|
||||
def is_exist_inst_cd(self) -> bool:
|
||||
return True if self.mst_inst_repository.fetch_count(self.inst_cd) > 0 else False
|
||||
|
||||
def is_exist_emp_chg_type_cd(self) -> bool:
|
||||
return True if self.generic_kbn_mst_repository.fetch_count(self.emp_chg_type_cd) > 0 else False
|
||||
def is_exist_emp_chg_type_cd(self, start_date) -> bool:
|
||||
return True if self.generic_kbn_mst_repository.fetch_count('emp_chg_type_cd', self.emp_chg_type_cd, start_date) > 0 else False
|
||||
|
||||
def is_exist_ta_cd(self, start_date: str) -> bool:
|
||||
return True if self.generic_kbn_mst_repository.fetch_count('ta_cd', self.ta_cd, start_date) > 0 else False
|
||||
|
||||
def is_exist_bu_cd(self) -> bool:
|
||||
return True if self.bu_master_repository.fetch_count(self.bu_cd) > 0 else False
|
||||
@ -175,6 +180,12 @@ class MasterMainteCSVItem(metaclass=ABCMeta):
|
||||
pass
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def check_ta_cd_exists(self) -> list[str]:
|
||||
"""領域コード存在チェック"""
|
||||
pass
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def check_emp_cd_exists(self) -> list[str]:
|
||||
"""MUID存在チェック"""
|
||||
@ -255,12 +266,12 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem):
|
||||
if len(self.ta_cd) == 0:
|
||||
error_list.append(self.make_require_error_message(
|
||||
self.line_num, constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_TA_CD_COL_NO]))
|
||||
if len(self.emp_cd) == 0:
|
||||
error_list.append(self.make_require_error_message(
|
||||
self.line_num, constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_EMP_CD_COL_NO]))
|
||||
if len(self.emp_chg_type_cd) == 0:
|
||||
error_list.append(self.make_require_error_message(
|
||||
self.line_num, constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_EMP_CHG_TYPE_CD_COL_NO]))
|
||||
if len(self.emp_cd) == 0:
|
||||
error_list.append(self.make_require_error_message(
|
||||
self.line_num, constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_EMP_CD_COL_NO]))
|
||||
if len(self.bu_cd) == 0:
|
||||
error_list.append(self.make_require_error_message(
|
||||
self.line_num, constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_BU_CD_COL_NO]))
|
||||
@ -291,12 +302,19 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem):
|
||||
error_list.append(f'{self.line_num}行目の{constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_EMP_CD_COL_NO]}\
|
||||
は従業員マスタに存在しない もしくは 適用期間外のIDです。')
|
||||
return error_list
|
||||
|
||||
|
||||
def check_emp_chg_type_cd_exists(self) -> list[str]:
|
||||
error_list = []
|
||||
if is_not_empty(self.emp_chg_type_cd) and super().is_exist_emp_chg_type_cd() is False:
|
||||
if is_not_empty(self.emp_chg_type_cd) and super().is_exist_emp_chg_type_cd(self.start_date) is False:
|
||||
error_list.append(f'{self.line_num}行目の{constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_EMP_CHG_TYPE_CD_COL_NO]}\
|
||||
は汎用区分マスタに存在しないコードです。')
|
||||
は汎用区分マスタに存在しない もしくは 適用期間外のコードです。')
|
||||
return error_list
|
||||
|
||||
def check_ta_cd_exists(self) -> list[str]:
|
||||
error_list = []
|
||||
if is_not_empty(self.ta_cd) and super().is_exist_ta_cd(self.start_date) is False:
|
||||
error_list.append(f'{self.line_num}行目の{constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_TA_CD_COL_NO]}\
|
||||
は汎用区分マスタに存在しない もしくは 適用期間外のコードです。')
|
||||
return error_list
|
||||
|
||||
def check_bu_cd_exists(self) -> list[str]:
|
||||
@ -357,7 +375,8 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
|
||||
mst_inst_repository: MstInstRepository,
|
||||
emp_master_repository: EmpMasterRepository,
|
||||
bu_master_repository: BuMasterRepository,
|
||||
emp_chginst_repository: EmpChgInstRepository
|
||||
emp_chginst_repository: EmpChgInstRepository,
|
||||
generic_kbn_mst_repository: GenericKbnMstRepository
|
||||
):
|
||||
super().__init__(
|
||||
csv_row,
|
||||
@ -366,7 +385,8 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
|
||||
mst_inst_repository,
|
||||
emp_master_repository,
|
||||
bu_master_repository,
|
||||
emp_chginst_repository
|
||||
emp_chginst_repository,
|
||||
generic_kbn_mst_repository
|
||||
)
|
||||
self.bu_cd = super().get_csv_value(constants.CSV_CHANGE_BU_CD_COL_NO)
|
||||
self.bu_name = super().get_csv_value(constants.CSV_CHANGE_BU_NAME_COL_NO)
|
||||
@ -376,6 +396,7 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
|
||||
self.inst_name = super().get_csv_value(constants.CSV_CHANGE_INST_NAME_COL_NO)
|
||||
self.ta_cd = super().get_csv_value(constants.CSV_CHANGE_TA_CD_COL_NO)
|
||||
self.explain = super().get_csv_value(constants.CSV_CHANGE_EXPLAIN_COL_NO)
|
||||
self.emp_chg_type_cd = super().get_csv_value(constants.CSV_CHANGE_EMP_CHG_TYPE_CD_COL_NO)
|
||||
self.emp_cd = super().get_csv_value(constants.CSV_CHANGE_EMP_CD_COL_NO)
|
||||
self.emp_full_name = super().get_csv_value(constants.CSV_CHANGE_EMP_FULL_NAME_COL_NO)
|
||||
self.inst_emp_start_date = super().get_csv_value(constants.CSV_CHANGE_INST_EMP_START_DATE_COL_NO)
|
||||
@ -398,6 +419,9 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
|
||||
if len(self.ta_cd) == 0:
|
||||
error_list.append(self.make_require_error_message(
|
||||
self.line_num, constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_TA_CD_COL_NO]))
|
||||
if len(self.emp_chg_type_cd) == 0:
|
||||
error_list.append(self.make_require_error_message(
|
||||
self.line_num, constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_EMP_CHG_TYPE_CD_COL_NO]))
|
||||
if len(self.emp_cd) == 0:
|
||||
error_list.append(self.make_require_error_message(
|
||||
self.line_num, constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_EMP_CD_COL_NO]))
|
||||
@ -466,9 +490,16 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
|
||||
def check_emp_chg_type_cd_exists(self) -> list[str]:
|
||||
error_list = []
|
||||
|
||||
if is_not_empty(self.emp_chg_type_cd) and super().is_exist_emp_chg_type_cd() is False:
|
||||
error_list.append(f'{self.line_num}行目の{constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_EMP_CHG_TYPE_CD_COL_NO]}\
|
||||
は汎用区分マスタに存在しないコードです。')
|
||||
if is_not_empty(self.emp_chg_type_cd) and super().is_exist_emp_chg_type_cd(self.inst_emp_start_date) is False:
|
||||
error_list.append(f'{self.line_num}行目の{constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_EMP_CHG_TYPE_CD_COL_NO]}\
|
||||
は汎用区分マスタに存在しない もしくは 適用期間外のコードです。')
|
||||
return error_list
|
||||
|
||||
def check_ta_cd_exists(self) -> list[str]:
|
||||
error_list = []
|
||||
if is_not_empty(self.ta_cd) and super().is_exist_ta_cd(self.inst_emp_start_date) is False:
|
||||
error_list.append(f'{self.line_num}行目の{constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_TA_CD_COL_NO]}\
|
||||
は汎用区分マスタに存在しない もしくは 適用期間外のコードです。')
|
||||
return error_list
|
||||
|
||||
def check_bu_cd_exists(self) -> list[str]:
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
from src.model.db.base_db_model import BaseDBModel
|
||||
from src.repositories.base_repository import BaseRepository
|
||||
from src.model.db.generic_kbn_mst import GenericKbnMstModel
|
||||
from src.model.db.master_mente_count import MasterMenteCountModel
|
||||
from src.logging.get_logger import get_logger
|
||||
|
||||
@ -14,13 +12,18 @@ class GenericKbnMstRepository(BaseRepository):
|
||||
FROM
|
||||
src05.generic_kbn_mst
|
||||
WHERE
|
||||
generic_kbn_mst.kbn_cd = :kbn_cd\
|
||||
generic_kbn_mst.generic_kbn_cd = :generic_kbn_cd
|
||||
AND
|
||||
generic_kbn_mst.kbn_cd = :kbn_cd
|
||||
AND
|
||||
STR_TO_DATE( :start_date , '%Y%m%d') BETWEEN generic_kbn_mst.start_date AND generic_kbn_mst.end_date\
|
||||
"""
|
||||
|
||||
def fetch_count(self, parameter) -> MasterMenteCountModel:
|
||||
|
||||
def fetch_count(self, generic_kbn_cd, kbn_cd, start_date) -> MasterMenteCountModel:
|
||||
try:
|
||||
query = self.FETCH_SQL
|
||||
result = self._database.execute_select(query, {'kbn_cd': parameter})
|
||||
result = self._database.execute_select(query, {'generic_kbn_cd': generic_kbn_cd, 'kbn_cd': kbn_cd, 'start_date' : start_date})
|
||||
models = [MasterMenteCountModel(**r) for r in result]
|
||||
if len(models) == 0:
|
||||
return 0
|
||||
|
||||
@ -73,7 +73,7 @@ class MasterMainteService(BaseService):
|
||||
raise Exception(f'登録テーブルの選択値が不正です: {csv_upload_form.select_table}')
|
||||
|
||||
(table_name, selected_table_msg) = self.__choose_target_table(csv_upload_form.select_table)
|
||||
|
||||
# TODO
|
||||
csv_items = MasterMainteCSVItems(
|
||||
file,
|
||||
csv_upload_form.select_function,
|
||||
|
||||
@ -119,6 +119,7 @@ CHANGE_INST_CSV_LOGICAL_NAMES = [
|
||||
'施設名',
|
||||
'領域コード',
|
||||
'説明',
|
||||
'担当者種別コード',
|
||||
'MUID',
|
||||
'担当者名',
|
||||
'施設担当_開始日',
|
||||
@ -142,18 +143,20 @@ CSV_CHANGE_INST_NAME_COL_NO = 5
|
||||
CSV_CHANGE_TA_CD_COL_NO = 6
|
||||
# 説明の列No
|
||||
CSV_CHANGE_EXPLAIN_COL_NO = 7
|
||||
# 担当者種別コード
|
||||
CSV_CHANGE_EMP_CHG_TYPE_CD_COL_NO = 8
|
||||
# MUIDの列No
|
||||
CSV_CHANGE_EMP_CD_COL_NO = 8
|
||||
CSV_CHANGE_EMP_CD_COL_NO = 9
|
||||
# 担当者名の列No
|
||||
CSV_CHANGE_EMP_FULL_NAME_COL_NO = 9
|
||||
CSV_CHANGE_EMP_FULL_NAME_COL_NO = 10
|
||||
# 施設担当_開始日の列No
|
||||
CSV_CHANGE_INST_EMP_START_DATE_COL_NO = 10
|
||||
CSV_CHANGE_INST_EMP_START_DATE_COL_NO = 11
|
||||
# 施設担当_終了日の列No
|
||||
CSV_CHANGE_INST_EMP_END_DATE_COL_NO = 11
|
||||
CSV_CHANGE_INST_EMP_END_DATE_COL_NO = 12
|
||||
# 終了日の変更の列No
|
||||
CSV_CHANGE_CHANGE_END_DATE_COL_NO = 12
|
||||
CSV_CHANGE_CHANGE_END_DATE_COL_NO = 13
|
||||
# コメントの列No
|
||||
CSV_CHANGE_COMMENT = 13
|
||||
CSV_CHANGE_COMMENT = 14
|
||||
|
||||
# CSVアップロードテーブル名(マスターメンテ)
|
||||
CSV_REAL_TABLE_NAME = '本番テーブル'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user