担当者種別コードCSVアップロード実装
This commit is contained in:
parent
9576dc054a
commit
df0f2d129f
@ -97,6 +97,9 @@ class MasterMainteCSVItem(metaclass=ABCMeta):
|
|||||||
def is_exist_inst_cd(self) -> bool:
|
def is_exist_inst_cd(self) -> bool:
|
||||||
return True if self.mst_inst_repository.fetch_count(self.inst_cd) > 0 else False
|
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_bu_cd(self) -> bool:
|
def is_exist_bu_cd(self) -> bool:
|
||||||
return True if self.bu_master_repository.fetch_count(self.bu_cd) > 0 else False
|
return True if self.bu_master_repository.fetch_count(self.bu_cd) > 0 else False
|
||||||
|
|
||||||
@ -291,10 +294,9 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem):
|
|||||||
|
|
||||||
def check_emp_chg_type_cd_exists(self) -> list[str]:
|
def check_emp_chg_type_cd_exists(self) -> list[str]:
|
||||||
error_list = []
|
error_list = []
|
||||||
# TODO
|
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() 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]}\
|
||||||
# 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
|
return error_list
|
||||||
|
|
||||||
def check_bu_cd_exists(self) -> list[str]:
|
def check_bu_cd_exists(self) -> list[str]:
|
||||||
@ -464,7 +466,9 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem):
|
|||||||
def check_emp_chg_type_cd_exists(self) -> list[str]:
|
def check_emp_chg_type_cd_exists(self) -> list[str]:
|
||||||
error_list = []
|
error_list = []
|
||||||
|
|
||||||
# TODO if super().is
|
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]}\
|
||||||
|
は汎用区分マスタに存在しないコードです。')
|
||||||
return error_list
|
return error_list
|
||||||
|
|
||||||
def check_bu_cd_exists(self) -> list[str]:
|
def check_bu_cd_exists(self) -> list[str]:
|
||||||
|
|||||||
@ -46,6 +46,7 @@ class MasterMainteEmpChgInstFunction(metaclass=ABCMeta):
|
|||||||
self.emp_chginst_repository.insert_emp_chg_inst(
|
self.emp_chginst_repository.insert_emp_chg_inst(
|
||||||
data['施設コード'],
|
data['施設コード'],
|
||||||
data['領域コード'],
|
data['領域コード'],
|
||||||
|
data['担当者種別コード'],
|
||||||
data['MUID'],
|
data['MUID'],
|
||||||
data['ビジネスユニットコード'],
|
data['ビジネスユニットコード'],
|
||||||
start_date,
|
start_date,
|
||||||
|
|||||||
@ -57,13 +57,14 @@ class EmpChgInstRepository(BaseRepository):
|
|||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def insert_emp_chg_inst(self, inst_cd, ta_cd, emp_cd, bu_cd, start_date,
|
def insert_emp_chg_inst(self, inst_cd, ta_cd, emp_chg_type_cd, emp_cd, bu_cd, start_date,
|
||||||
end_date, create_user_name, table_name):
|
end_date, create_user_name, table_name):
|
||||||
try:
|
try:
|
||||||
query = self.INSERT_SQL.format(table_name=table_name)
|
query = self.INSERT_SQL.format(table_name=table_name)
|
||||||
self._database.execute(query, {
|
self._database.execute(query, {
|
||||||
'inst_cd': inst_cd,
|
'inst_cd': inst_cd,
|
||||||
'ta_cd': ta_cd,
|
'ta_cd': ta_cd,
|
||||||
|
'emp_chg_type_cd': emp_chg_type_cd,
|
||||||
'emp_cd': emp_cd,
|
'emp_cd': emp_cd,
|
||||||
'bu_cd': bu_cd,
|
'bu_cd': bu_cd,
|
||||||
'start_date': start_date,
|
'start_date': start_date,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from src.model.db.base_db_model import BaseDBModel
|
from src.model.db.base_db_model import BaseDBModel
|
||||||
from src.repositories.base_repository import BaseRepository
|
from src.repositories.base_repository import BaseRepository
|
||||||
from src.model.db.generic_kbn_mst import GenericKbnMstModel
|
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
|
from src.logging.get_logger import get_logger
|
||||||
|
|
||||||
logger = get_logger('汎用区分マスタ')
|
logger = get_logger('汎用区分マスタ')
|
||||||
@ -9,21 +10,21 @@ class GenericKbnMstRepository(BaseRepository):
|
|||||||
|
|
||||||
FETCH_SQL = """\
|
FETCH_SQL = """\
|
||||||
SELECT
|
SELECT
|
||||||
*
|
COUNT(*) AS count
|
||||||
FROM
|
FROM
|
||||||
src05.generic_kbn_mst
|
src05.generic_kbn_mst
|
||||||
WHERE
|
WHERE
|
||||||
generic_kbn_mst.kbn_cd = :kbn_cd\
|
generic_kbn_mst.kbn_cd = :kbn_cd\
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def fetch_all(self, parameter) -> list[BaseDBModel]:
|
def fetch_count(self, parameter) -> MasterMenteCountModel:
|
||||||
try:
|
try:
|
||||||
query = self.FETCH_SQL
|
query = self.FETCH_SQL
|
||||||
result = self._database.execute_select(query, parameter)
|
result = self._database.execute_select(query, {'kbn_cd': parameter})
|
||||||
models = [GenericKbnMstModel(**r) for r in result]
|
models = [MasterMenteCountModel(**r) for r in result]
|
||||||
if len(models) == 0:
|
if len(models) == 0:
|
||||||
return None
|
return 0
|
||||||
return models[0]
|
return models[0].count
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"DB Error : Exception={e}")
|
logger.error(f"DB Error : Exception={e.args}")
|
||||||
raise e
|
raise e
|
||||||
Loading…
x
Reference in New Issue
Block a user