Merge pull request #384 feature-NEWDWH2021-1507 into develop-emp-chg-inst

This commit is contained in:
下田雅人 2024-04-23 13:06:41 +09:00
commit 5b47804c3f
2 changed files with 38 additions and 9 deletions

View File

@ -61,10 +61,10 @@ class MasterMainteCSVItem(metaclass=ABCMeta):
error_list.extend(self.check_require())
# 施設コード存在チェック
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())
# 担当者種別コード存在チェック
error_list.extend(self.check_emp_chg_type_cd_exists())
# MUID存在チェック
error_list.extend(self.check_emp_cd_exists())
# BuCd存在チェック
@ -87,7 +87,7 @@ class MasterMainteCSVItem(metaclass=ABCMeta):
return error_list
def emp_chg_inst_count(self, start_date: str):
return self.emp_chginst_repository.fetch_count(self.inst_cd, self.ta_cd, start_date, self.table_name)
return self.emp_chginst_repository.fetch_count(self.inst_cd, self.ta_cd, self.emp_chg_type_cd, start_date, self.table_name)
def is_exist_emp_cd(self, start_date: str) -> bool:
if start_date is None or len(start_date) == 0:
@ -100,10 +100,18 @@ class MasterMainteCSVItem(metaclass=ABCMeta):
return True if self.mst_inst_repository.fetch_count(self.inst_cd) > 0 else False
def is_exist_emp_chg_type_cd(self, start_date: str) -> 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
if start_date is None or len(start_date) == 0:
return False
if self.generic_kbn_mst_repository.fetch_count('emp_chg_type_cd', self.emp_chg_type_cd, start_date) > 0:
return True
return 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
if start_date is None or len(start_date) == 0:
return False
if self.generic_kbn_mst_repository.fetch_count('ta_cd', self.ta_cd, start_date) > 0:
return True
return False
def is_exist_bu_cd(self) -> bool:
return True if self.bu_master_repository.fetch_count(self.bu_cd) > 0 else False
@ -305,6 +313,9 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem):
def check_emp_chg_type_cd_exists(self) -> list[str]:
error_list = []
if not self.start_date or not self.emp_chg_type_cd:
return error_list
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]}\
は汎用区分マスタに存在しない もしくは 適用期間外のコードです')
@ -312,6 +323,9 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem):
def check_ta_cd_exists(self) -> list[str]:
error_list = []
if not self.start_date or not self.ta_cd:
return 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]}\
は汎用区分マスタに存在しない もしくは 適用期間外のコードです')
@ -440,6 +454,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.inst_emp_start_date) == 0:
error_list.append(self.make_require_error_message(
self.line_num,
@ -455,6 +472,10 @@ 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]))
@ -490,6 +511,9 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
def check_emp_chg_type_cd_exists(self) -> list[str]:
error_list = []
if not self.inst_emp_start_date or not self.emp_chg_type_cd:
return error_list
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]}\
は汎用区分マスタに存在しない もしくは 適用期間外のコードです')
@ -497,6 +521,10 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
def check_ta_cd_exists(self) -> list[str]:
error_list = []
if not self.inst_emp_start_date or not self.ta_cd:
return 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]}\
は汎用区分マスタに存在しない もしくは 適用期間外のコードです')
@ -551,10 +579,10 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
error_list = []
emp_chg_inst_count = super().emp_chg_inst_count(self.inst_emp_start_date)
if self.comment == '追加' and emp_chg_inst_count > 0:
error_list.append(f'{self.line_num}行目の施設コード、領域コード、施設担当_開始日がすべて同一のデータが既に登録されています。')
error_list.append(f'{self.line_num}行目の施設コード、領域コード、担当者種別コード、施設担当_開始日がすべて同一のデータが既に登録されています。')
elif (self.comment == '終了' or self.comment == '担当者修正') and emp_chg_inst_count == 0:
error_list.append(f'{self.line_num}行目の施設コード、領域コード、施設担当_開始日がすべて同一のデータが存在しないため更新できません。')
error_list.append(f'{self.line_num}行目の施設コード、領域コード、担当者種別コード、施設担当_開始日がすべて同一のデータが存在しないため更新できません。')
return error_list

View File

@ -141,14 +141,15 @@ class EmpChgInstRepository(BaseRepository):
WHERE
inst_cd = :inst_cd
AND ta_cd = :ta_cd
AND emp_chg_type_cd = :emp_chg_type_cd
AND start_date = :start_date
"""
def fetch_count(self, inst_cd, ta_cd, start_date, table_name) -> MasterMenteCountModel:
def fetch_count(self, inst_cd, ta_cd, emp_chg_type_cd, start_date, table_name) -> MasterMenteCountModel:
try:
query = self.FETCH_COUNT_SQL.format(table_name=table_name)
result = self._database.execute_select(query, {'inst_cd': inst_cd, 'ta_cd': ta_cd,
'start_date': start_date})
'emp_chg_type_cd': emp_chg_type_cd,'start_date': start_date})
models = [MasterMenteCountModel(**r) for r in result]
if len(models) == 0:
return 0