feat: 単体試験不具合対応

This commit is contained in:
高木要 2023-07-21 15:08:11 +09:00
parent a4d38e7395
commit 68339d28a0
6 changed files with 26 additions and 21 deletions

View File

@ -296,7 +296,7 @@ async def inst_emp_csv_download(
update_date_from=csv_download_form.update_date_from,
update_date_to=csv_download_form.update_date_to,
select_table=csv_download_form.select_table,
data_count=search_result_df.size,
data_count=search_result_df.shape[0],
download_file_url=download_file_url,
file_name=constants.MENTE_CSV_DOWNLOAD_FILE_NAME,
result_msg=result_msg
@ -310,6 +310,7 @@ async def inst_emp_csv_download(
]
)
set_session(session)
templates_response = templates.TemplateResponse(
'instEmpCsvDL.html',
{

View File

@ -121,22 +121,22 @@ class MasterMainteCsvDlModel(RequestBaseModel):
adapt_create_date_from = ''
adapt_create_date_to = ''
if is_not_empty(ctrl_create_date_from):
adapt_create_date_from = ctrl_create_date_from.replace('/', '')
adapt_create_date_from = ctrl_create_date_from.replace('/', '-') + ' 00:00:00'
else:
ctrl_create_date_from = ''
if is_not_empty(ctrl_create_date_to):
adapt_create_date_to = ctrl_create_date_to.replace('/', '')
adapt_create_date_to = ctrl_create_date_to.replace('/', '-') + ' 23:59:59'
else:
ctrl_create_date_to = ''
adapt_update_date_from = ''
adapt_update_date_to = ''
if is_not_empty(ctrl_update_date_from):
adapt_update_date_from = ctrl_update_date_from.replace('/', '')
adapt_update_date_from = ctrl_update_date_from.replace('/', '-') + ' 00:00:00'
else:
ctrl_update_date_from = ''
if is_not_empty(ctrl_update_date_to):
adapt_update_date_to = ctrl_update_date_to.replace('/', '')
adapt_update_date_to = ctrl_update_date_to.replace('/', '-') + ' 23:59:59'
else:
ctrl_update_date_to = ''

View File

@ -15,10 +15,7 @@ class InstEmpCsvUploadViewModel(BaseModel):
csv_upload_list: Optional[list[dict]]
json_upload_data: Optional[str]
result_message_list: Optional[list[str]]
dialog_msg: Optional[str]
def select_function_message(self):
return '新規施設登録' if self.select_function == 'new' else '施設担当者変更'
select_function_message: Optional[str]
def select_table_message(self):
return self.__dummy_table() if self.select_table == 'dummy' else self.__real_table()

View File

@ -192,7 +192,7 @@ class EmpChgInstRepository(BaseRepository):
query = self.FETCH_SQL.format(table_name=table_name, where_clause=where_clause)
logger.debug(f'SQL: {query}')
df = self._to_data_frame(query, parameter)
logger.debug(f'count= {len(df.index)}')
logger.debug(f'count= {df.shape[0]}')
return df
except Exception as e:
logger.exception(f"DB Error : Exception={e.args}")
@ -263,13 +263,13 @@ class EmpChgInstRepository(BaseRepository):
condition.LE,
'adapt_create_date_to'))
# データ作成FROMが入力されていた場合
# データ更新FROMが入力されていた場合
if is_not_empty(parameter.adapt_update_date_from):
where_clauses.append(SQLCondition('eci.update_date',
condition.GE,
'adapt_update_date_from'))
# データ作成TOが入力されていた場合
# データ更新TOが入力されていた場合
if is_not_empty(parameter.adapt_update_date_to):
where_clauses.append(SQLCondition('eci.update_date',
condition.LE,

View File

@ -67,7 +67,7 @@ class MasterMainteService(BaseService):
if csv_upload_form.select_table != 'dummy' and csv_upload_form.select_table != 'real':
raise Exception(f'登録テーブルの選択値が不正です: {csv_upload_form.select_table}')
(table_name, _) = self.__choose_target_table(csv_upload_form.select_table)
(table_name, selected_table_msg) = self.__choose_target_table(csv_upload_form.select_table)
csv_items = MasterMainteCSVItems(
file,
@ -101,7 +101,10 @@ class MasterMainteService(BaseService):
select_table=csv_upload_form.select_table,
csv_upload_list=csv_upload_list,
json_upload_data=json_upload_data,
csv_file_name=csv_file_name
csv_file_name=csv_file_name,
select_function_message=self.__make_dialog_confirm_message(
csv_upload_form.select_function,
selected_table_msg)
)
return mainte_csv_up
@ -190,12 +193,12 @@ class MasterMainteService(BaseService):
header_df = pd.DataFrame([header_data], index=None)
output_df = pd.concat([header_df, data_frame])
# ヘッダー行としてではなく、1レコードとして出力する
output_df.to_csv(output_file_path, index=False, header=False)
output_df.to_csv(output_file_path, encoding="utf-8_sig", index=False, header=False)
return output_file_path
def upload_emp_chg_inst_data_file(self, df: pd.DataFrame, user_id: str, select_table: str) -> tuple[str, str]:
if df.size == 0:
if df.shape[0] == 0:
return '該当データが存在しないためCSVファイルを出力しませんでした', ''
# ファイル名に使用するタイムスタンプを初期化しておく
@ -221,9 +224,9 @@ class MasterMainteService(BaseService):
detail={'error': 'aws_error', 'message': e.args}
)
if select_table == 'dummy':
result_msg = f'ダミーテーブルのデータ{df.size}件をCSVファイルに出力しました'
result_msg = f'ダミーテーブルのデータ{df.shape[0]}件をCSVファイルに出力しました'
else:
result_msg = f'本番テーブルのデータ{df.size}件をCSVファイルに出力しました'
result_msg = f'本番テーブルのデータ{df.shape[0]}件をCSVファイルに出力しました'
return result_msg, download_file_url
@ -250,5 +253,9 @@ class MasterMainteService(BaseService):
raise Exception(f'登録テーブルの選択値が不正です: {select_table}')
return (table_name, selected_table_msg)
def __make_dialog_confirm_message(self, select_function: str, selected_table_msg: str) -> str:
select_function_msg = '新規施設登録' if select_function == 'new' else '施設担当者変更'
return f'{selected_table_msg}{select_function_msg}を行いますか?'
def delete_local_file(self, local_file_path: str):
os.remove(local_file_path)

View File

@ -13,7 +13,7 @@
}
function Form_Submit_Disp_Dialog(){
var msg = '{{ mainte_csv_up.select_function_message() }}';
var msg = '{{ mainte_csv_up.select_function_message }}';
if (confirmDialog(msg)) {
document.getElementById("loading").style.display = "block";
document.getElementById("ulMsg").style.display = "none";
@ -29,7 +29,7 @@
<h1>
<table class="headerTable">
<tr>
<td class="headerTdLeft"><h1>施設担当者データCSVアップロ</h1></td>
<td class="headerTdLeft"><h1>施設担当者データCSVアップロ</h1></td>
<td class="headerTdRight">
{% if mainte_csv_up.is_verified and mainte_csv_up.is_error_message_list_empty() %}
<input type="button" class="header_buttonSize" onclick="location.href='/masterMainte/instEmpCsvUL' " value="戻る">
@ -100,7 +100,7 @@
<!-- 選択フォーム3行目 -->
<tr>
<!-- 登録Excel -->
<td class="inputLabelTd">登録Excel</td>
<td class="inputLabelTd">登録CSV</td>
<td class="input_tb" colspan="2">
{% if mainte_csv_up.is_verified and mainte_csv_up.is_error_message_list_empty() %}
{{mainte_csv_up.csv_file_name}}