서버 수정
This commit is contained in:
@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -42,6 +43,7 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
|
||||
@Transactional
|
||||
public ExcelUploadResultVO operate(MultipartFile file) throws IOException {
|
||||
// 엑셀 파일 읽기
|
||||
|
||||
Workbook workbook = WorkbookFactory.create(file.getInputStream());
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
Integer success = 0;
|
||||
@@ -52,6 +54,7 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
|
||||
List<UICodeElement> IndustryLargeCodeList = uiCodeListMapper.findByParentId("code.industry.large");
|
||||
List<UICodeElement> IndustryMiddleCodeList = uiCodeListMapper.findByParentId("code.industry.middle");
|
||||
|
||||
List<String> errorList = new ArrayList<>();
|
||||
// 첫 번째 행은 헤더로 간주하고 스킵
|
||||
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
@@ -60,9 +63,9 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
|
||||
CheckHouseholdNum checkHouseholdNum = checkHouseholdNumMapper.checkHouseholdNum(new CheckHouseholdNumCmd(getCellValue(row.getCell(0)))).orElse(null);
|
||||
ExcelUploadContactVO contactVO = getDivisionContact(row.getCell(3));
|
||||
|
||||
|
||||
// 데이터 누락 warn
|
||||
if(!checkHouseholdNum.getIsDuplicated() && contactVO != null) {
|
||||
|
||||
int flag = 0;
|
||||
ExcelCreateHouseholdVO household = new ExcelCreateHouseholdVO();
|
||||
household.setHouseholdNum(getCellValue(row.getCell(0))); // 임가번호
|
||||
household.setOwnerName(getCellValue(row.getCell(1))); // 경영주명
|
||||
@@ -80,7 +83,7 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
|
||||
household.setIndustryDetail(getCellValue(row.getCell(11))); // 규모 / 세부품목
|
||||
household.setResearcherSeq(getResearcherSeq(row.getCell(12))); // 조사원
|
||||
household.setIsPanel(getIsPanel(row.getCell(13))); // 유지여부
|
||||
|
||||
household.setMemo(getCellValue(row.getCell(14))); // 비고
|
||||
|
||||
CreateHouseholdOutCmd cmd = new CreateHouseholdOutCmd(
|
||||
null,
|
||||
@@ -100,11 +103,17 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
|
||||
household.getIndustryDetail(),
|
||||
household.getResearcherSeq(),
|
||||
household.getIsPanel(),
|
||||
null,
|
||||
household.getMemo(),
|
||||
List.of("ROLE_GENERAL")
|
||||
);
|
||||
|
||||
success += createHouseholdMapper.createHousehold(AuditUtil.create(cmd));
|
||||
flag = createHouseholdMapper.createHousehold(AuditUtil.create(cmd));
|
||||
|
||||
success += flag;
|
||||
|
||||
if(flag == 0){
|
||||
errorList.add(household.getHouseholdNum());
|
||||
}
|
||||
|
||||
if(cmd.getRoleIds() != null && !cmd.getRoleIds().isEmpty()) {
|
||||
createHouseholdMapper.createHouseholdHasRole(AuditUtil.create(new CreateHouseholdHasRoleCmd(cmd.getSeq(), cmd.getRoleIds())));
|
||||
@@ -116,7 +125,7 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
|
||||
}
|
||||
}
|
||||
workbook.close();
|
||||
return new ExcelUploadResultVO(sheet.getLastRowNum()-1 , success);
|
||||
return new ExcelUploadResultVO(sheet.getLastRowNum()-1 , success, errorList);
|
||||
}
|
||||
|
||||
// 셀 값을 문자열로 변환
|
||||
|
||||
@@ -24,4 +24,5 @@ public class ExcelCreateHouseholdVO {
|
||||
private String industryDetail;
|
||||
private Long researcherSeq;
|
||||
private Boolean isPanel;
|
||||
private String memo;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class ExcelUploadResultVO {
|
||||
private Integer total;
|
||||
private Integer success;
|
||||
private List<String> errorList;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ server:
|
||||
mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript
|
||||
# 압축 적용 최소 응답 크기(바이트)
|
||||
min-response-size: 2048
|
||||
servlet:
|
||||
session:
|
||||
cookie:
|
||||
name: ADMIN_SESSION
|
||||
|
||||
# ==============================================
|
||||
# 관리자 관련 설정
|
||||
|
||||
@@ -91,4 +91,12 @@ logging:
|
||||
hibernate:
|
||||
orm:
|
||||
jdbc:
|
||||
bind: trace # Hibernate SQL 파라미터 바인딩 로깅
|
||||
bind: trace # Hibernate SQL 파라미터 바인딩 로깅
|
||||
# ==============================================
|
||||
# 서버 압축 설정
|
||||
# ==============================================
|
||||
server:
|
||||
servlet:
|
||||
session:
|
||||
cookie:
|
||||
name: FRONT_SESSION
|
||||
Reference in New Issue
Block a user