엑셀 업로드 오류 분기처리
This commit is contained in:
@@ -21,6 +21,14 @@ class ExcelSaveAdminController {
|
||||
|
||||
@PostMapping("/api/settings/admin/excelUpload")
|
||||
ResponseEntity<?> excelUploadSaveAdmin(@RequestParam("file") MultipartFile file ) throws IOException {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(excelSaveAdminPortIn.operate(file));
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(excelSaveAdminPortIn.operate(file));
|
||||
} catch (IOException e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("엑셀 파일 처리 중 오류가 발생했습니다: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body("잘못된 데이터 형식입니다: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,16 +188,16 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
|
||||
private String getUiCode(Cell cell,List<UICodeElement> uiCodeElementList,String codeId){
|
||||
if (cell == null) return "";
|
||||
try {
|
||||
String cellValue = cell.getStringCellValue().trim();
|
||||
String[] cellValueParts = cellValue.split("\\.");
|
||||
String cellValue = cell.getStringCellValue().trim();
|
||||
String[] cellValueParts = cellValue.split("\\.");
|
||||
|
||||
return uiCodeElementList.stream().filter(code -> {
|
||||
if(cellValueParts.length == 1 ) return code.getCodeText().equals(codeId+"."+cellValueParts[0]) || code.getCodeText().equals(cellValueParts[0]) ;
|
||||
if(cellValueParts.length == 2 ) return code.getId().equals(codeId+"."+cellValueParts[0]) || code.getCodeText().equals(cellValueParts[1]) ;
|
||||
return Boolean.parseBoolean(null);
|
||||
} )
|
||||
.findFirst()
|
||||
.map(UICodeElement::getId).orElse("");
|
||||
return uiCodeElementList.stream().filter(code -> {
|
||||
if(cellValueParts.length == 1 ) return code.getCodeText().equals(codeId+"."+cellValueParts[0]) || code.getCodeText().equals(cellValueParts[0]) ;
|
||||
if(cellValueParts.length == 2 ) return code.getId().equals(codeId+"."+cellValueParts[0]) || code.getCodeText().equals(cellValueParts[1]) ;
|
||||
return Boolean.parseBoolean(null);
|
||||
} )
|
||||
.findFirst()
|
||||
.map(UICodeElement::getId).orElse("");
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
|
||||
|
||||
ExcelUploadContactVO contactVO = new ExcelUploadContactVO();
|
||||
|
||||
if(contact[2].length() == 4) {
|
||||
if(contact.length == 3 && contact[2].length() == 4) {
|
||||
if (contact[0].equals("010") || contact[0].equals("011")) {
|
||||
contactVO.setPhone(getCellValue(cell));
|
||||
contactVO.setPhoneLast(contact[2]);
|
||||
|
||||
@@ -19,7 +19,14 @@ class ExcelUploadCreateHouseholdController {
|
||||
|
||||
@PostMapping(path = "/api/household/excelUpload")
|
||||
ResponseEntity<?> operate(@RequestParam("file") MultipartFile file ) throws IOException {
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(excelUploadCreateHouseholdPortIn.operate(file));
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(excelUploadCreateHouseholdPortIn.operate(file));
|
||||
} catch (IOException e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("엑셀 파일 처리 중 오류가 발생했습니다: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body("잘못된 데이터 형식입니다: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,11 @@
|
||||
// }
|
||||
|
||||
function showAdminExcelUploadModal() {
|
||||
const modal = document.querySelector(".modal02");
|
||||
const modal = document.querySelector(".modal-admin-excel");
|
||||
const fileInput = document.getElementById("file");
|
||||
if (fileInput) {
|
||||
fileInput.value = '';
|
||||
}
|
||||
modal.ui.open();
|
||||
|
||||
}
|
||||
@@ -248,17 +252,22 @@
|
||||
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
|
||||
},
|
||||
statusCode: {
|
||||
422: (res) => {
|
||||
const resJson = res.responseJSON;
|
||||
$(input).parent().find('.invalid-feedback').text(resJson.message);
|
||||
$(input).addClass('is-invalid');
|
||||
400:() => {
|
||||
ajaxUtil._hideWaiting();
|
||||
alert("잘못된 엑셀파일입니다.");
|
||||
document.querySelector(".modal-admin-excel").ui.close();
|
||||
},
|
||||
500: () => {
|
||||
ajaxUtil._hideWaiting();
|
||||
alert("엑셀 업로드에 실패하였습니다.");
|
||||
document.querySelector(".modal-admin-excel").ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
document.querySelector(".modal02").ui.close();
|
||||
document.querySelector(".modal-admin-excel").ui.close();
|
||||
};
|
||||
</script>
|
||||
</section>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<div class="layer-wrap" th:fragment="modalFragment">
|
||||
<div class="component-modal modal02" id="test" data-props-dimm-click="true" data-state="close">
|
||||
<div class="component-modal modal01 modal-admin-excel" id="test" data-props-dimm-click="true" data-state="close">
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
<div class="modal-container type-small">
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
// 임가방문정보 모달창 띄우기
|
||||
const showExcelHouseholdModal = () => {
|
||||
document.querySelector(".modal-excel-household").ui.open();
|
||||
const fileInput = document.getElementById("householdFile");
|
||||
if (fileInput) {
|
||||
fileInput.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
// 임가방문정보 등록
|
||||
@@ -72,15 +76,19 @@
|
||||
},
|
||||
success(res) {
|
||||
ajaxUtil._hideWaiting(); // 로딩바 hide
|
||||
|
||||
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
|
||||
document.querySelector(".modal-excel-household").ui.close();
|
||||
},
|
||||
statusCode: {
|
||||
422: (res) => {
|
||||
const resJson = res.responseJSON;
|
||||
$(input).parent().find('.invalid-feedback').text(resJson.message);
|
||||
$(input).addClass('is-invalid');
|
||||
400: () => {
|
||||
ajaxUtil._hideWaiting();
|
||||
alert("잘못된 엑셀파일입니다.");
|
||||
document.querySelector(".modal-excel-household").ui.close();
|
||||
},
|
||||
500: () => {
|
||||
ajaxUtil._hideWaiting();
|
||||
alert("엑셀 업로드에 실패하였습니다.");
|
||||
document.querySelector(".modal-excel-household").ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user