From a7bc502f364cf2ea95e5882a00acb7e9208d8baf Mon Sep 17 00:00:00 2001 From: "nik.n" Date: Mon, 15 Apr 2024 08:56:26 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=AD=E9=80=94=E3=83=97=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/model/internal/master_mainte_csv.py | 12 ++++++++++++ .../src/repositories/emp_chg_inst_repository.py | 2 ++ ecs/jskult-webapp/src/system_var/constants.py | 15 +++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py index e288ce3a..619e736e 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py @@ -57,6 +57,8 @@ 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()) # MUID存在チェック error_list.extend(self.check_emp_cd_exists()) # BuCd存在チェック @@ -160,6 +162,12 @@ class MasterMainteCSVItem(metaclass=ABCMeta): pass ... + @abstractmethod + def check_emp_chg_type_cd_exists(self) -> list[str]: + """担当者種別コード存在チェック""" + pass + ... + @abstractmethod def check_emp_cd_exists(self) -> list[str]: """MUID存在チェック""" @@ -219,6 +227,7 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem): self.inst_cd = super().get_csv_value(constants.CSV_NEW_INST_CD_COL_NO) self.inst_name = super().get_csv_value(constants.CSV_NEW_INST_NAME_COL_NO) self.ta_cd = super().get_csv_value(constants.CSV_NEW_TA_CD_COL_NO) + self.emp_chg_type_cd = super().get_csv_value(constants.CSV_NEW_EMP_CHG_TYPE_CD_COL_NO) self.emp_cd = super().get_csv_value(constants.CSV_NEW_EMP_CD_COL_NO) self.emp_name_family = super().get_csv_value(constants.CSV_NEW_EMP_NAME_FAMILY_COL_NO) self.emp_name_first = super().get_csv_value(constants.CSV_NEW_EMP_NAME_FIRST_COL_NO) @@ -240,6 +249,9 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem): 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.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])) diff --git a/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py b/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py index d91be694..07dcf34c 100644 --- a/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py +++ b/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py @@ -28,6 +28,7 @@ class EmpChgInstRepository(BaseRepository): ( inst_cd, ta_cd, + emp_chg_type_cd, emp_cd, bu_cd, start_date, @@ -42,6 +43,7 @@ class EmpChgInstRepository(BaseRepository): VALUES ( :inst_cd, :ta_cd, + :emp_chg_type_cd, :emp_cd, :bu_cd, :start_date, diff --git a/ecs/jskult-webapp/src/system_var/constants.py b/ecs/jskult-webapp/src/system_var/constants.py index 3756facb..f592f370 100644 --- a/ecs/jskult-webapp/src/system_var/constants.py +++ b/ecs/jskult-webapp/src/system_var/constants.py @@ -80,6 +80,7 @@ NEW_INST_EMP_CSV_LOGICAL_NAMES = [ '施設コード', '施設名', '領域コード', + '担当者種別コード', 'MUID', '担当者名(姓)', '担当者名(名)', @@ -93,18 +94,20 @@ CSV_NEW_INST_CD_COL_NO = 0 CSV_NEW_INST_NAME_COL_NO = 1 # 領域コードの列No CSV_NEW_TA_CD_COL_NO = 2 +# 担当者種別コードの列No +CSV_NEW_EMP_CHG_TYPE_CD_COL_NO = 3 # MUIDの列No -CSV_NEW_EMP_CD_COL_NO = 3 +CSV_NEW_EMP_CD_COL_NO = 4 # 担当者名(姓)の列No -CSV_NEW_EMP_NAME_FAMILY_COL_NO = 4 +CSV_NEW_EMP_NAME_FAMILY_COL_NO = 5 # 担当者名(名)の列No -CSV_NEW_EMP_NAME_FIRST_COL_NO = 5 +CSV_NEW_EMP_NAME_FIRST_COL_NO = 6 # ビジネスユニットコードの列No -CSV_NEW_BU_CD_COL_NO = 6 +CSV_NEW_BU_CD_COL_NO = 7 # 適用開始日の列No -CSV_NEW_START_DATE = 7 +CSV_NEW_START_DATE = 8 # 適用終了日の列No -CSV_NEW_END_DATE = 8 +CSV_NEW_END_DATE = 9 # 施設担当者変更登録CSV(マスターメンテ) CHANGE_INST_CSV_LOGICAL_NAMES = [ From 9576dc054a085c4c072ad2b58dd1023c8717641f Mon Sep 17 00:00:00 2001 From: "nik.n" Date: Tue, 16 Apr 2024 16:57:35 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=E4=B8=AD=E9=80=94=E3=83=97=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/model/db/generic_kbn_mst.py | 19 +++++++++ .../src/model/internal/master_mainte_csv.py | 42 +++++++++++++++---- .../generic_kbn_mst_repository.py | 29 +++++++++++++ .../src/services/master_mainte_service.py | 7 +++- 4 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 ecs/jskult-webapp/src/model/db/generic_kbn_mst.py create mode 100644 ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py diff --git a/ecs/jskult-webapp/src/model/db/generic_kbn_mst.py b/ecs/jskult-webapp/src/model/db/generic_kbn_mst.py new file mode 100644 index 00000000..ee189cd6 --- /dev/null +++ b/ecs/jskult-webapp/src/model/db/generic_kbn_mst.py @@ -0,0 +1,19 @@ +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] + diff --git a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py index 619e736e..9910aa3b 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py @@ -10,6 +10,7 @@ from src.repositories.mst_inst_repository import MstInstRepository from src.repositories.bu_master_cd_repository import BuMasterRepository from src.repositories.emp_master_repository import EmpMasterRepository from src.repositories.emp_chg_inst_repository import EmpChgInstRepository +from src.repositories.generic_kbn_mst_repository import GenericKbnMstRepository from src.logging.get_logger import get_logger logger = get_logger('マスターメンテ') @@ -24,6 +25,7 @@ class MasterMainteCSVItem(metaclass=ABCMeta): emp_master_repository: EmpMasterRepository bu_master_repository: BuMasterRepository emp_chginst_repository: EmpChgInstRepository + generic_kbn_mst_repository: GenericKbnMstRepository def __init__( self, @@ -33,7 +35,8 @@ class MasterMainteCSVItem(metaclass=ABCMeta): 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 ): self.csv_row = csv_row self.table_name = table_name @@ -42,6 +45,7 @@ class MasterMainteCSVItem(metaclass=ABCMeta): self.emp_master_repository = emp_master_repository self.bu_master_repository = bu_master_repository self.emp_chginst_repository = emp_chginst_repository + self.generic_kbn_mst_repository = generic_kbn_mst_repository def validate(self) -> list[str]: """ @@ -213,7 +217,8 @@ class MasterMainteNewInstEmpCSVItem(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, @@ -222,7 +227,8 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem): mst_inst_repository, emp_master_repository, bu_master_repository, - emp_chginst_repository + emp_chginst_repository, + generic_kbn_mst_repository ) self.inst_cd = super().get_csv_value(constants.CSV_NEW_INST_CD_COL_NO) self.inst_name = super().get_csv_value(constants.CSV_NEW_INST_NAME_COL_NO) @@ -282,6 +288,14 @@ 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 = [] + # TODO + # 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 def check_bu_cd_exists(self) -> list[str]: error_list = [] @@ -446,6 +460,12 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem): error_list.append(f'{self.line_num}行目の{constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_EMP_CD_COL_NO]}\ は従業員マスタに存在しない もしくは 適用期間外のIDです。') return error_list + + def check_emp_chg_type_cd_exists(self) -> list[str]: + error_list = [] + + # TODO if super().is + return error_list def check_bu_cd_exists(self) -> list[str]: error_list = [] @@ -537,7 +557,8 @@ class MasterMainteCSVItems: 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 ) -> None: reader = csv.reader(file) csv_rows = [] @@ -552,7 +573,9 @@ class MasterMainteCSVItems: mst_inst_repository, emp_master_repository, bu_master_repository, - emp_chginst_repository)) + emp_chginst_repository, + generic_kbn_mst_repository + )) self.lines = csv_rows def __select_function(self, @@ -563,7 +586,8 @@ class MasterMainteCSVItems: mst_inst_repository: MstInstRepository, emp_master_repository: EmpMasterRepository, bu_master_repository: BuMasterRepository, - emp_chginst_repository: EmpChgInstRepository) -> MasterMainteCSVItem: + emp_chginst_repository: EmpChgInstRepository, + generic_kbn_mst_repository: GenericKbnMstRepository) -> MasterMainteCSVItem: if function_type == 'new': return MasterMainteNewInstEmpCSVItem( row, @@ -572,7 +596,8 @@ class MasterMainteCSVItems: mst_inst_repository, emp_master_repository, bu_master_repository, - emp_chginst_repository) + emp_chginst_repository, + generic_kbn_mst_repository) elif function_type == 'change': return MasterMainteChangeInstEmpCSVItem( row, @@ -581,4 +606,5 @@ class MasterMainteCSVItems: mst_inst_repository, emp_master_repository, bu_master_repository, - emp_chginst_repository) + emp_chginst_repository, + generic_kbn_mst_repository) diff --git a/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py b/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py new file mode 100644 index 00000000..278d864a --- /dev/null +++ b/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py @@ -0,0 +1,29 @@ +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.logging.get_logger import get_logger + +logger = get_logger('汎用区分マスタ') + +class GenericKbnMstRepository(BaseRepository): + + FETCH_SQL = """\ + SELECT + * + FROM + src05.generic_kbn_mst + WHERE + generic_kbn_mst.kbn_cd = :kbn_cd\ + """ + + def fetch_all(self, parameter) -> list[BaseDBModel]: + try: + query = self.FETCH_SQL + result = self._database.execute_select(query, parameter) + models = [GenericKbnMstModel(**r) for r in result] + if len(models) == 0: + return None + return models[0] + except Exception as e: + logger.error(f"DB Error : Exception={e}") + raise e \ No newline at end of file diff --git a/ecs/jskult-webapp/src/services/master_mainte_service.py b/ecs/jskult-webapp/src/services/master_mainte_service.py index f3bbdb1a..d7e85638 100644 --- a/ecs/jskult-webapp/src/services/master_mainte_service.py +++ b/ecs/jskult-webapp/src/services/master_mainte_service.py @@ -19,6 +19,7 @@ from src.repositories.mst_inst_repository import MstInstRepository from src.repositories.bu_master_cd_repository import BuMasterRepository from src.repositories.emp_master_repository import EmpMasterRepository from src.repositories.emp_chg_inst_repository import EmpChgInstRepository +from src.repositories.generic_kbn_mst_repository import GenericKbnMstRepository from src.model.internal.master_mainte_csv import MasterMainteCSVItems from src.model.internal.master_mainte_emp_chg_inst_function import NewEmpChgInstFunction from src.model.internal.master_mainte_emp_chg_inst_function import ChangeEmpChgInstFunction @@ -38,6 +39,7 @@ class MasterMainteService(BaseService): 'emp_master_repository': EmpMasterRepository, 'bu_master_repository': BuMasterRepository, 'emp_chginst_repository': EmpChgInstRepository, + 'generic_kbn_mst_repository': GenericKbnMstRepository, } CLIENTS = { @@ -48,6 +50,7 @@ class MasterMainteService(BaseService): emp_master_repository: EmpMasterRepository bu_master_repository: BuMasterRepository emp_chginst_repository: EmpChgInstRepository + generic_kbn_mst_repository: GenericKbnMstRepository s3_client: S3Client def __init__(self, repositories: dict[str, BaseRepository], clients: dict[str, AWSAPIClient]) -> None: @@ -56,6 +59,7 @@ class MasterMainteService(BaseService): self.emp_master_repository = repositories['emp_master_repository'] self.bu_master_repository = repositories['bu_master_repository'] self.emp_chginst_repository = repositories['emp_chginst_repository'] + self.generic_kbn_mst_repository = repositories['generic_kbn_mst_repository'] self.s3_client = clients['s3_client'] def prepare_mainte_csv_up_view(self, @@ -77,7 +81,8 @@ class MasterMainteService(BaseService): self.mst_inst_repository, self.emp_master_repository, self.bu_master_repository, - self.emp_chginst_repository + self.emp_chginst_repository, + self.generic_kbn_mst_repository ) error_message_list = [] From df0f2d129f6f893894c96919d3bf064a7330e37b Mon Sep 17 00:00:00 2001 From: "nik.n" Date: Wed, 17 Apr 2024 10:23:33 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=E6=8B=85=E5=BD=93=E8=80=85=E7=A8=AE?= =?UTF-8?q?=E5=88=A5=E3=82=B3=E3=83=BC=E3=83=89CSV=E3=82=A2=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/model/internal/master_mainte_csv.py | 14 +++++++++----- .../master_mainte_emp_chg_inst_function.py | 1 + .../src/repositories/emp_chg_inst_repository.py | 3 ++- .../repositories/generic_kbn_mst_repository.py | 15 ++++++++------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py index 9910aa3b..3f1d5c42 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py @@ -96,6 +96,9 @@ 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_bu_cd(self) -> bool: 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]: error_list = [] - # TODO - # 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() 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_bu_cd_exists(self) -> list[str]: @@ -464,7 +466,9 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem): def check_emp_chg_type_cd_exists(self) -> list[str]: 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 def check_bu_cd_exists(self) -> list[str]: diff --git a/ecs/jskult-webapp/src/model/internal/master_mainte_emp_chg_inst_function.py b/ecs/jskult-webapp/src/model/internal/master_mainte_emp_chg_inst_function.py index 18a5cb0c..0ce3d2c8 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_emp_chg_inst_function.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_emp_chg_inst_function.py @@ -46,6 +46,7 @@ class MasterMainteEmpChgInstFunction(metaclass=ABCMeta): self.emp_chginst_repository.insert_emp_chg_inst( data['施設コード'], data['領域コード'], + data['担当者種別コード'], data['MUID'], data['ビジネスユニットコード'], start_date, diff --git a/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py b/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py index 07dcf34c..7df22275 100644 --- a/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py +++ b/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py @@ -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): try: query = self.INSERT_SQL.format(table_name=table_name) self._database.execute(query, { 'inst_cd': inst_cd, 'ta_cd': ta_cd, + 'emp_chg_type_cd': emp_chg_type_cd, 'emp_cd': emp_cd, 'bu_cd': bu_cd, 'start_date': start_date, diff --git a/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py b/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py index 278d864a..36d59fbd 100644 --- a/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py +++ b/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py @@ -1,6 +1,7 @@ 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 logger = get_logger('汎用区分マスタ') @@ -9,21 +10,21 @@ class GenericKbnMstRepository(BaseRepository): FETCH_SQL = """\ SELECT - * + COUNT(*) AS count FROM src05.generic_kbn_mst WHERE generic_kbn_mst.kbn_cd = :kbn_cd\ """ - def fetch_all(self, parameter) -> list[BaseDBModel]: + def fetch_count(self, parameter) -> MasterMenteCountModel: try: query = self.FETCH_SQL - result = self._database.execute_select(query, parameter) - models = [GenericKbnMstModel(**r) for r in result] + result = self._database.execute_select(query, {'kbn_cd': parameter}) + models = [MasterMenteCountModel(**r) for r in result] if len(models) == 0: - return None - return models[0] + return 0 + return models[0].count except Exception as e: - logger.error(f"DB Error : Exception={e}") + logger.error(f"DB Error : Exception={e.args}") raise e \ No newline at end of file From e29bbe445506c90090c86bf7bd6b452299098791 Mon Sep 17 00:00:00 2001 From: "nik.n" Date: Wed, 17 Apr 2024 18:45:07 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E6=96=BD=E8=A8=AD=E6=8B=85=E5=BD=93?= =?UTF-8?q?=E8=80=85=E5=A4=89=E6=9B=B4=E5=AE=9F=E8=A3=85=E3=83=BB=E6=8C=87?= =?UTF-8?q?=E6=91=98=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/model/db/generic_kbn_mst.py | 19 ------- .../src/model/internal/master_mainte_csv.py | 57 ++++++++++++++----- .../generic_kbn_mst_repository.py | 13 +++-- .../src/services/master_mainte_service.py | 2 +- ecs/jskult-webapp/src/system_var/constants.py | 15 +++-- 5 files changed, 62 insertions(+), 44 deletions(-) delete mode 100644 ecs/jskult-webapp/src/model/db/generic_kbn_mst.py diff --git a/ecs/jskult-webapp/src/model/db/generic_kbn_mst.py b/ecs/jskult-webapp/src/model/db/generic_kbn_mst.py deleted file mode 100644 index ee189cd6..00000000 --- a/ecs/jskult-webapp/src/model/db/generic_kbn_mst.py +++ /dev/null @@ -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] - diff --git a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py index 3f1d5c42..be740eb7 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py @@ -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]: diff --git a/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py b/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py index 36d59fbd..18995972 100644 --- a/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py +++ b/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py @@ -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 diff --git a/ecs/jskult-webapp/src/services/master_mainte_service.py b/ecs/jskult-webapp/src/services/master_mainte_service.py index d7e85638..168f1075 100644 --- a/ecs/jskult-webapp/src/services/master_mainte_service.py +++ b/ecs/jskult-webapp/src/services/master_mainte_service.py @@ -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, diff --git a/ecs/jskult-webapp/src/system_var/constants.py b/ecs/jskult-webapp/src/system_var/constants.py index f592f370..5bd8a878 100644 --- a/ecs/jskult-webapp/src/system_var/constants.py +++ b/ecs/jskult-webapp/src/system_var/constants.py @@ -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 = '本番テーブル' From b878ded447ee5492524e45f6e04b01f9f8efef02 Mon Sep 17 00:00:00 2001 From: "nik.n" Date: Thu, 18 Apr 2024 10:27:08 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E6=8C=87=E6=91=98=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecs/jskult-webapp/src/model/internal/master_mainte_csv.py | 2 +- .../model/internal/master_mainte_emp_chg_inst_function.py | 4 +++- .../src/repositories/emp_chg_inst_repository.py | 6 ++++-- .../src/repositories/generic_kbn_mst_repository.py | 2 +- ecs/jskult-webapp/src/services/master_mainte_service.py | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py index be740eb7..fe4e328d 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py @@ -99,7 +99,7 @@ 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, start_date) -> bool: + 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 def is_exist_ta_cd(self, start_date: str) -> bool: diff --git a/ecs/jskult-webapp/src/model/internal/master_mainte_emp_chg_inst_function.py b/ecs/jskult-webapp/src/model/internal/master_mainte_emp_chg_inst_function.py index 0ce3d2c8..1c79b75e 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_emp_chg_inst_function.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_emp_chg_inst_function.py @@ -29,8 +29,8 @@ class MasterMainteEmpChgInstFunction(metaclass=ABCMeta): def save(self): error_list = [] try: - self.emp_chginst_repository.to_jst() self.emp_chginst_repository.begin() + self.emp_chginst_repository.to_jst() (result_message, error_list) = self.write_emp_chg_inst_table() if len(error_list) > 0: self.emp_chginst_repository.rollback() @@ -149,6 +149,7 @@ class ChangeEmpChgInstFunction(MasterMainteEmpChgInstFunction): self.emp_chginst_repository.end_emp_chg_inst( data['施設コード'], data['領域コード'], + data['担当者種別コード'], data['施設担当_開始日'], data['終了日の変更'], self.user_name, @@ -159,6 +160,7 @@ class ChangeEmpChgInstFunction(MasterMainteEmpChgInstFunction): data['施設コード'], data['領域コード'], data['施設担当_開始日'], + data['担当者種別コード'], data['MUID'], self.user_name, self.table_name) diff --git a/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py b/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py index 7df22275..6019b48c 100644 --- a/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py +++ b/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py @@ -89,13 +89,14 @@ class EmpChgInstRepository(BaseRepository): and start_date = :start_date """ - def end_emp_chg_inst(self, inst_cd, ta_cd, start_date, + def end_emp_chg_inst(self, inst_cd, ta_cd, emp_chg_type_cd, start_date, end_date, update_user_name, table_name): try: query = self.UPDATE_END_DATE_SQL.format(table_name=table_name) self._database.execute(query, { 'inst_cd': inst_cd, 'ta_cd': ta_cd, + 'emp_chg_type_cd': emp_chg_type_cd, 'start_date': start_date, 'end_date': end_date, 'update_user_name': update_user_name @@ -117,12 +118,13 @@ class EmpChgInstRepository(BaseRepository): and start_date = :start_date """ - def modify_emp_chg_inst(self, inst_cd, ta_cd, start_date, emp_cd, update_user_name, table_name): + def modify_emp_chg_inst(self, inst_cd, ta_cd, start_date, emp_chg_type_cd, emp_cd, update_user_name, table_name): try: query = self.UPDATE_EMP_CD_SQL.format(table_name=table_name) self._database.execute(query, { 'inst_cd': inst_cd, 'ta_cd': ta_cd, + 'emp_chg_type_cd': emp_chg_type_cd, 'start_date': start_date, 'emp_cd': emp_cd, 'update_user_name': update_user_name diff --git a/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py b/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py index 18995972..e2d210c4 100644 --- a/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py +++ b/ecs/jskult-webapp/src/repositories/generic_kbn_mst_repository.py @@ -20,7 +20,7 @@ class GenericKbnMstRepository(BaseRepository): """ - def fetch_count(self, generic_kbn_cd, kbn_cd, start_date) -> MasterMenteCountModel: + def fetch_count(self, generic_kbn_cd: str, kbn_cd: str, start_date: str) -> MasterMenteCountModel: try: query = self.FETCH_SQL result = self._database.execute_select(query, {'generic_kbn_cd': generic_kbn_cd, 'kbn_cd': kbn_cd, 'start_date' : start_date}) diff --git a/ecs/jskult-webapp/src/services/master_mainte_service.py b/ecs/jskult-webapp/src/services/master_mainte_service.py index 168f1075..6f612a87 100644 --- a/ecs/jskult-webapp/src/services/master_mainte_service.py +++ b/ecs/jskult-webapp/src/services/master_mainte_service.py @@ -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, @@ -153,8 +153,8 @@ class MasterMainteService(BaseService): def copy_data_real_to_dummy(self) -> TableOverrideViewModel: try: - self.emp_chginst_repository.to_jst() self.emp_chginst_repository.begin() + self.emp_chginst_repository.to_jst() self.emp_chginst_repository.delete_dummy_table() self.emp_chginst_repository.copy_real_to_dummy() self.emp_chginst_repository.commit()