From f830c55160796d83b151bfa2d24507c5c629099f Mon Sep 17 00:00:00 2001 From: "shimoda.m@nds-tyo.co.jp" Date: Tue, 23 Apr 2024 17:17:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E6=96=B0=E8=A6=8F=E6=96=BD=E8=A8=AD?= =?UTF-8?q?=E7=99=BB=E9=8C=B2=E3=81=AE=E9=87=8D=E8=A4=87=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E7=99=BA=E7=94=9F=E6=99=82=E3=81=AB=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=82=8B=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AB=E6=8B=85=E5=BD=93=E8=80=85=E7=A8=AE=E5=88=A5?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=8C=E5=90=AB=E3=81=BE=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/model/internal/master_mainte_csv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 70ad315a..6b5b7754 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py @@ -98,7 +98,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: str) -> bool: if start_date is None or len(start_date) == 0: return False @@ -325,7 +325,7 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem): 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]}\ は汎用区分マスタに存在しない もしくは 適用期間外のコードです。') @@ -363,7 +363,7 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem): def check_data_exists(self) -> list[str]: error_list = [] if super().emp_chg_inst_count(self.start_date) > 0: - error_list.append(f'{self.line_num}行目の施設コード、領域コード、適用開始日がすべて同一のデータが既に登録されています。') + error_list.append(f'{self.line_num}行目の施設コード、領域コード、担当者種別コード、適用開始日がすべて同一のデータが既に登録されています。') return error_list @@ -507,7 +507,7 @@ 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 = [] @@ -518,7 +518,7 @@ class MasterMainteChangeInstEmpCSVItem(MasterMainteCSVItem): 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 = [] From 6208fb1ac317511611c7433e7cb4fc953fd2be5f Mon Sep 17 00:00:00 2001 From: "shimoda.m@nds-tyo.co.jp" Date: Tue, 23 Apr 2024 18:24:24 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E6=8C=87=E6=91=98=E4=BF=AE=E6=AD=A3=E3=80=82=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=82=BF=E5=AD=98=E5=9C=A8=E3=83=81=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=81=AB=E3=80=81=E9=A0=85=E7=9B=AE=E8=AB=96?= =?UTF-8?q?=E7=90=86=E5=90=8D=E3=81=AE=E5=AE=9A=E6=95=B0=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/model/internal/master_mainte_csv.py | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 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 6b5b7754..a6146731 100644 --- a/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py +++ b/ecs/jskult-webapp/src/model/internal/master_mainte_csv.py @@ -1,17 +1,17 @@ import csv import json - -from io import TextIOWrapper -from datetime import datetime from abc import ABCMeta, abstractmethod +from datetime import datetime +from io import TextIOWrapper + +from src.logging.get_logger import get_logger +from src.repositories.bu_master_cd_repository import BuMasterRepository +from src.repositories.emp_chg_inst_repository import EmpChgInstRepository +from src.repositories.emp_master_repository import EmpMasterRepository +from src.repositories.generic_kbn_mst_repository import GenericKbnMstRepository +from src.repositories.mst_inst_repository import MstInstRepository from src.system_var import constants from src.util.string_util import is_not_empty -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('マスターメンテ') @@ -119,6 +119,16 @@ class MasterMainteCSVItem(metaclass=ABCMeta): def make_require_error_message(self, line_num: str, col_name: str) -> str: return f'{line_num}行目の{col_name}が入力されておりません。' + def make_data_exist_error_message(self, line_num: str, primary_key_col_names: list[str]) -> str: + return self.__make_check_data_exists_error_message(line_num, primary_key_col_names, 'がすべて同一のデータが既に登録されています。') + + def make_data_not_exist_error_message(self, line_num: str, primary_key_col_names: list[str]) -> str: + return self.__make_check_data_exists_error_message(line_num, primary_key_col_names, 'がすべて同一のデータが存在しないため更新できません。') + + def __make_check_data_exists_error_message(self, line_num: str, primary_key_col_names: list[str], suffix_message: str) -> str: + primary_key_logical_names = '、'.join(primary_key_col_names) + return f'{line_num}行目の{primary_key_logical_names}{suffix_message}' + def __parse_str_to_date(self, check_date: str) -> tuple[bool, datetime]: try: check_date_time: datetime = datetime.strptime(check_date, '%Y%m%d') @@ -363,7 +373,15 @@ class MasterMainteNewInstEmpCSVItem(MasterMainteCSVItem): def check_data_exists(self) -> list[str]: error_list = [] if super().emp_chg_inst_count(self.start_date) > 0: - error_list.append(f'{self.line_num}行目の施設コード、領域コード、担当者種別コード、適用開始日がすべて同一のデータが既に登録されています。') + error_list.append(super().make_data_exist_error_message( + self.line_num, + primary_key_col_names=[ + constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_INST_CD_COL_NO], + constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_TA_CD_COL_NO], + constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_EMP_CHG_TYPE_CD_COL_NO], + constants.NEW_INST_EMP_CSV_LOGICAL_NAMES[constants.CSV_NEW_START_DATE] + ] + )) return error_list @@ -579,10 +597,26 @@ 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(super().make_data_exist_error_message( + self.line_num, + primary_key_col_names=[ + constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_INST_CD_COL_NO], + constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_TA_CD_COL_NO], + constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_EMP_CHG_TYPE_CD_COL_NO], + constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_INST_EMP_START_DATE_COL_NO] + ] + )) elif (self.comment == '終了' or self.comment == '担当者修正') and emp_chg_inst_count == 0: - error_list.append(f'{self.line_num}行目の施設コード、領域コード、担当者種別コード、施設担当_開始日がすべて同一のデータが存在しないため更新できません。') + error_list.append(super().make_data_not_exist_error_message( + self.line_num, + primary_key_col_names=[ + constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_INST_CD_COL_NO], + constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_TA_CD_COL_NO], + constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_EMP_CHG_TYPE_CD_COL_NO], + constants.CHANGE_INST_CSV_LOGICAL_NAMES[constants.CSV_CHANGE_INST_EMP_START_DATE_COL_NO] + ] + )) return error_list