[BO] 임가현황, 조사원현황 엑셀 다운로드 작업
This commit is contained in:
@@ -73,7 +73,7 @@ class GetHouseholdVisitInfosController {
|
|||||||
.map(ManagementType::getDesc).orElse(""),
|
.map(ManagementType::getDesc).orElse(""),
|
||||||
record.getContent(),
|
record.getContent(),
|
||||||
record.getUpdatedBy() + " (" + record.getUpdatedAt() + ")",
|
record.getUpdatedBy() + " (" + record.getUpdatedAt() + ")",
|
||||||
record.getIsGiftSent() ? "전달" : "미전달"
|
record.getIsGiftSent() ? "전달 완료" : "-"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,10 @@ class GetHouseholdVisitInfosController {
|
|||||||
"답례품 전달"),
|
"답례품 전달"),
|
||||||
rows,
|
rows,
|
||||||
Collections.singleton(11),
|
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);
|
List<ExcelSheetDto> sheets = List.of(sheet1);
|
||||||
|
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ public class ResearchersHouseholdVisitDto {
|
|||||||
private ManagementType managementType;
|
private ManagementType managementType;
|
||||||
private String content;
|
private String content;
|
||||||
private String isGiftSentFlag;
|
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.ExcelWriterUtil;
|
||||||
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
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.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.persistence.model.ResearchersMappingHouseholdDto;
|
||||||
import app.module.admin.usecase.researcher.adpaters.web.model.*;
|
import app.module.admin.usecase.researcher.adpaters.web.model.*;
|
||||||
import app.module.admin.usecase.researcher.ports.ResearcherPortIn;
|
import app.module.admin.usecase.researcher.ports.ResearcherPortIn;
|
||||||
@@ -122,7 +123,7 @@ class ResearcherApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/mappingHouseholdList/excel")
|
@GetMapping(path = "/mappingHouseholdList/excel")
|
||||||
ResponseEntity<?> exportMappingHouseholdsExcel(@ModelAttribute ResearchersDetailReqVO reqVO) {
|
ResponseEntity<byte[]> exportMappingHouseholdsExcel(@ModelAttribute ResearchersDetailReqVO reqVO) {
|
||||||
|
|
||||||
Page<ResearchersMappingHouseholdDto> mappingHouseholds =
|
Page<ResearchersMappingHouseholdDto> mappingHouseholds =
|
||||||
researcherPortIn.mappingHouseholdList(reqVO);
|
researcherPortIn.mappingHouseholdList(reqVO);
|
||||||
@@ -188,4 +189,54 @@ class ResearcherApiController {
|
|||||||
.body(excel);
|
.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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,8 @@
|
|||||||
rhv.content,
|
rhv.content,
|
||||||
rhv.management_type,
|
rhv.management_type,
|
||||||
case rhv.is_gift_sent when true then '전달완료' when false then '-' end is_gift_sent_flag,
|
case rhv.is_gift_sent when true then '전달완료' when false then '-' end is_gift_sent_flag,
|
||||||
rhv.created_at
|
TO_CHAR(rhv.updated_at, 'YYYY-MM-DD HH24:MI') AS updated_at,
|
||||||
|
rhv.updated_by
|
||||||
from household_visit rhv
|
from household_visit rhv
|
||||||
join household h on rhv.household_seq = h.seq
|
join household h on rhv.household_seq = h.seq
|
||||||
join researcher_has_household rhh on rhh.household_seq = h.seq and rhh.is_deleted = false
|
join researcher_has_household rhh on rhh.household_seq = h.seq and rhh.is_deleted = false
|
||||||
|
|||||||
@@ -330,7 +330,7 @@
|
|||||||
<td>${ct.visitDate}</td>
|
<td>${ct.visitDate}</td>
|
||||||
<td>${ct.managementType}</td>
|
<td>${ct.managementType}</td>
|
||||||
<td>${ct.content}</td>
|
<td>${ct.content}</td>
|
||||||
<td>${ct.createdAt}</td>
|
<td>${ct.updatedAt}</td>
|
||||||
<td>${ct.isGiftSentFlag}</td>
|
<td>${ct.isGiftSentFlag}</td>
|
||||||
</tr>
|
</tr>
|
||||||
`
|
`
|
||||||
@@ -362,7 +362,7 @@
|
|||||||
if (selectedTab.dataset.tabValue === 'tab1') {
|
if (selectedTab.dataset.tabValue === 'tab1') {
|
||||||
url = '/api/researcher/mappingHouseholdList/excel';
|
url = '/api/researcher/mappingHouseholdList/excel';
|
||||||
} else if (selectedTab.dataset.tabValue === 'tab2') {
|
} else if (selectedTab.dataset.tabValue === 'tab2') {
|
||||||
url = ''; // 임가방문정보
|
url = '/api/researcher/visitHousehold/list/excel';
|
||||||
}
|
}
|
||||||
|
|
||||||
const f = document.householdReqForm;
|
const f = document.householdReqForm;
|
||||||
|
|||||||
Reference in New Issue
Block a user