SQL検索に担当者種別コード検索条件追加
This commit is contained in:
parent
35993730d6
commit
18f215f4f6
@ -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:
|
||||
@ -454,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,
|
||||
@ -469,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]))
|
||||
@ -572,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
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ class EmpChgInstRepository(BaseRepository):
|
||||
except Exception as e:
|
||||
logger.exception(f'DB Error : Exception={e.args}')
|
||||
raise e
|
||||
|
||||
# TODO
|
||||
FETCH_COUNT_SQL = """\
|
||||
SELECT
|
||||
COUNT(*) AS count
|
||||
@ -142,13 +142,14 @@ class EmpChgInstRepository(BaseRepository):
|
||||
inst_cd = :inst_cd
|
||||
AND ta_cd = :ta_cd
|
||||
AND start_date = :start_date
|
||||
AND emp_chg_type_cd = :emp_chg_type_cd
|
||||
"""
|
||||
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user