[BO] 임가현황, 조사원현황 엑셀 다운로드 작업
This commit is contained in:
@@ -72,8 +72,8 @@ class GetHouseholdVisitInfosController {
|
||||
Optional.ofNullable(ManagementType.from(record.getManagementType()))
|
||||
.map(ManagementType::getDesc).orElse(""),
|
||||
record.getContent(),
|
||||
record.getUpdatedBy() + " (" + record.getUpdatedAt() + ")",
|
||||
record.getIsGiftSent() ? "전달" : "미전달"
|
||||
record.getUpdatedBy() + " (" + record.getUpdatedAt() + ")",
|
||||
record.getIsGiftSent() ? "전달 완료" : "-"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -89,7 +89,10 @@ class GetHouseholdVisitInfosController {
|
||||
"답례품 전달"),
|
||||
rows,
|
||||
Collections.singleton(11),
|
||||
Map.of(0, IndexedColors.LIGHT_YELLOW));
|
||||
Map.of(
|
||||
0, IndexedColors.LIGHT_YELLOW,
|
||||
2, IndexedColors.LIGHT_TURQUOISE
|
||||
));
|
||||
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1);
|
||||
|
||||
|
||||
@@ -15,5 +15,6 @@ public class ResearchersHouseholdVisitDto {
|
||||
private ManagementType managementType;
|
||||
private String content;
|
||||
private String isGiftSentFlag;
|
||||
private LocalDateTime createdAt;
|
||||
private String updatedAt;
|
||||
private String updatedBy;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import app.module.admin.config.application.util.AdminUtil;
|
||||
import app.module.admin.config.application.util.ExcelWriterUtil;
|
||||
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
||||
import app.module.admin.usecase.researcher.adpaters.persistence.model.ResearchersDto;
|
||||
import app.module.admin.usecase.researcher.adpaters.persistence.model.ResearchersHouseholdVisitDto;
|
||||
import app.module.admin.usecase.researcher.adpaters.persistence.model.ResearchersMappingHouseholdDto;
|
||||
import app.module.admin.usecase.researcher.adpaters.web.model.*;
|
||||
import app.module.admin.usecase.researcher.ports.ResearcherPortIn;
|
||||
@@ -122,7 +123,7 @@ class ResearcherApiController {
|
||||
}
|
||||
|
||||
@GetMapping(path = "/mappingHouseholdList/excel")
|
||||
ResponseEntity<?> exportMappingHouseholdsExcel(@ModelAttribute ResearchersDetailReqVO reqVO) {
|
||||
ResponseEntity<byte[]> exportMappingHouseholdsExcel(@ModelAttribute ResearchersDetailReqVO reqVO) {
|
||||
|
||||
Page<ResearchersMappingHouseholdDto> mappingHouseholds =
|
||||
researcherPortIn.mappingHouseholdList(reqVO);
|
||||
@@ -188,4 +189,54 @@ class ResearcherApiController {
|
||||
.body(excel);
|
||||
}
|
||||
|
||||
@GetMapping(path = "/visitHousehold/list/excel")
|
||||
ResponseEntity<byte[]> exportVisitHouseholdExcel(@ModelAttribute ResearchersDetailReqVO reqVO) {
|
||||
|
||||
List<ResearchersHouseholdVisitDto> visitInfos = researcherPortIn.visitHouseholdList(reqVO);
|
||||
|
||||
List<List<String>> rows = new ArrayList<>();
|
||||
for(ResearchersHouseholdVisitDto item : visitInfos) {
|
||||
rows.add(List.of(
|
||||
StringUtils.defaultString(item.getHouseholdNum()),
|
||||
StringUtils.defaultString(item.getOwnerName()),
|
||||
StringUtils.defaultString(item.getVisitDate()),
|
||||
item.getManagementType() != null ? item.getManagementType().getDesc() : "",
|
||||
StringUtils.defaultString(item.getContent()),
|
||||
item.getUpdatedBy() + " (" + item.getUpdatedAt() + ")",
|
||||
StringUtils.defaultString(item.getIsGiftSentFlag())
|
||||
));
|
||||
}
|
||||
|
||||
// 시트 1: 임가방문정보
|
||||
ExcelSheetDto sheet1 = new ExcelSheetDto(
|
||||
"임가방문정보",
|
||||
List.of(
|
||||
"임가번호",
|
||||
"경영주 성명",
|
||||
"방문일",
|
||||
"관리분야",
|
||||
"내용",
|
||||
"최종 작성자",
|
||||
"답례품 전달"),
|
||||
rows,
|
||||
null,
|
||||
Map.of(
|
||||
0, IndexedColors.LIGHT_YELLOW,
|
||||
2, IndexedColors.LIGHT_TURQUOISE
|
||||
));
|
||||
|
||||
// 시트 모음
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1);
|
||||
|
||||
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||
|
||||
String rawFileName = "06. 임가방문정보" + "_" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
||||
String encodedFileName = URLEncoder.encode(rawFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encodedFileName)
|
||||
.body(excel);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user