[BO] 사용하지않는 엑셀다운로드 api, 버튼 삭제
This commit is contained in:
@@ -1,30 +1,11 @@
|
||||
package app.module.admin.usecase.household.tab.bankAutoTransfer.getBankAutoTransferRecords.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.ExcelWriterUtil;
|
||||
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
|
||||
import app.module.admin.usecase.household.tab.bankAutoTransfer.getBankAutoTransferRecords.adapters.web.model.GetAutoTransferRecordsReqVO;
|
||||
import app.module.admin.usecase.household.tab.bankAutoTransfer.getBankAutoTransferRecords.ports.GetBankAutoTransferRecordsPortIn;
|
||||
import app.module.admin.usecase.household.tab.bankAutoTransfer.getBankAutoTransferRecords.ports.application.domain.GetBankAutoTransferExpenseRecords;
|
||||
import app.module.admin.usecase.household.tab.bankAutoTransfer.getBankAutoTransferRecords.ports.application.domain.GetBankAutoTransferIncomeRecords;
|
||||
import app.module.admin.usecase.household.tab.bankAutoTransfer.getBankAutoTransferRecords.ports.application.domain.GetBankAutoTransferRecords;
|
||||
import app.module.admin.usecase.household.tab.bankAutoTransfer.getBankAutoTransferRecords.ports.application.domain.GetBankAutoTransferRecordsCmd;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -33,96 +14,10 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
class GetBankAutoTransferRecordsController {
|
||||
private final GetBankAutoTransferRecordsPortIn portIn;
|
||||
private final GetHouseholdStatusPortIn getHouseholdStatusPortIn;
|
||||
|
||||
@GetMapping(path = "/api/household/bankAutoTransfer")
|
||||
ResponseEntity<GetBankAutoTransferRecords> operate(GetAutoTransferRecordsReqVO reqVO) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(portIn.operate(
|
||||
new GetBankAutoTransferRecordsCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 은행자동이체내역 엑셀 다운로드
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 엑셀 파일 다운로드
|
||||
*/
|
||||
@GetMapping("/api/household/bankAutoTransfer/excel")
|
||||
public ResponseEntity<byte[]> exportBankExcel(GetAutoTransferRecordsReqVO reqVO) {
|
||||
|
||||
String householdNum = "-";
|
||||
String ownerName = "-";
|
||||
GetHouseholdStatus householdInfo = getHouseholdStatusPortIn.operate(new GetHouseholdStatusCmd(reqVO.getHouseholdSeq())).orElse(null);
|
||||
if (householdInfo != null) {
|
||||
householdNum = householdInfo.getHouseholdNum();
|
||||
ownerName = householdInfo.getHouseholdName();
|
||||
}
|
||||
|
||||
GetBankAutoTransferRecords bankRecords =
|
||||
portIn.operate(new GetBankAutoTransferRecordsCmd(
|
||||
reqVO.getHouseholdSeq(), reqVO.getRecordMonth()));
|
||||
|
||||
List<List<String>> rowsIncome = new ArrayList<>();
|
||||
for(GetBankAutoTransferIncomeRecords record : bankRecords.getIncomes()) {
|
||||
rowsIncome.add(List.of(
|
||||
householdNum, // 임가번호
|
||||
ownerName, // 경영주 성명
|
||||
StringUtils.defaultString(record.getCategory()), // 유형
|
||||
StringUtils.defaultString(record.getIncomeCode()), // 수입 부호
|
||||
StringUtils.defaultString(record.getExpenseCode()), // 지출 부호
|
||||
StringUtils.defaultString(record.getCropValue()), // 재배형태 코드
|
||||
StringUtils.defaultString(record.getCategoryText()), // 수입의 종류
|
||||
StringUtils.defaultString(record.getTarget()), // 대상
|
||||
StringUtils.defaultString(record.getSourcePurpose()), // 수입원
|
||||
StringUtils.defaultString(record.getCount()), // 수량
|
||||
StringUtils.defaultString(record.getUnitText()), // 단위
|
||||
StringUtils.defaultString(record.getPrice().toString()))); // 현금(원)
|
||||
}
|
||||
|
||||
// 시트 1: 수입 목록
|
||||
ExcelSheetDto sheet1 = new ExcelSheetDto(
|
||||
"수입",
|
||||
List.of("임가번호", "경영주 성명", "유형", "수입 부호", "지출 부호", "재배형태 코드", "수입의 종류", "대상", "수입원", "수량", "단위", "현금(원)"),
|
||||
rowsIncome,
|
||||
Collections.singleton(11),
|
||||
Map.of(0, IndexedColors.LIGHT_YELLOW)
|
||||
);
|
||||
|
||||
List<List<String>> rowsExpense = new ArrayList<>();
|
||||
for(GetBankAutoTransferExpenseRecords record : bankRecords.getExpenses()) {
|
||||
rowsExpense.add(List.of(
|
||||
householdNum, // 임가번호
|
||||
ownerName, // 경영주 성명
|
||||
StringUtils.defaultString(record.getCategory()), // 유형
|
||||
StringUtils.defaultString(record.getIncomeCode()), // 수입 부호
|
||||
StringUtils.defaultString(record.getExpenseCode()), // 지출 부호
|
||||
StringUtils.defaultString(record.getCategoryText()), // 지출의 종류
|
||||
StringUtils.defaultString(record.getSourcePurpose()), // 용도
|
||||
StringUtils.defaultString(record.getCount()), // 수량
|
||||
StringUtils.defaultString(record.getUnitText()), // 단위
|
||||
StringUtils.defaultString(record.getPrice().toString()))); // 현금(원)
|
||||
}
|
||||
|
||||
// 시트 2: 지출 목록
|
||||
ExcelSheetDto sheet2 = new ExcelSheetDto(
|
||||
"지출",
|
||||
List.of("임가번호", "경영주 성명", "유형", "수입 부호", "지출 부호", "지출의 종류", "용도", "수량", "단위", "현금(원)"),
|
||||
rowsExpense,
|
||||
Collections.singleton(9),
|
||||
Map.of(0, IndexedColors.LIGHT_YELLOW)
|
||||
);
|
||||
|
||||
// 시트 모음
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1, sheet2);
|
||||
|
||||
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||
|
||||
String rawFileName = "04. 은행 자동이체 내역[" + reqVO.getRecordMonth() + "][" + householdNum + "]_" + 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);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,35 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.ExcelWriterUtil;
|
||||
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.adapters.web.model.GetDailyRecordStatusDetailReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.GetDailyRecordStatusDetailPortIn;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.*;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.adapters.web.model.GetDailyRecordsStatusReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatus;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatusCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.GetDailyExpenseRecords;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.GetDailyFarmingRecords;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.GetDailyForestryRecords;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.GetDailyIncomeRecords;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.GetDailyPowerRecords;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.GetDailyRecordStatusCmd;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.GetDailyRecordStatusDetail;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordStatusDetail.ports.application.domain.GetDailyWorkRecords;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetDailyRecordStatusDetailController {
|
||||
private final GetDailyRecordStatusDetailPortIn portIn;
|
||||
private final GetHouseholdStatusPortIn getHouseholdStatusPortIn;
|
||||
|
||||
@GetMapping(path = "/api/household/dailyRecordStatus")
|
||||
ResponseEntity<GetDailyRecordStatusDetail> operate(
|
||||
@@ -53,48 +47,6 @@ class GetDailyRecordStatusDetailController {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(recordView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 상세 현황 엑셀 다운로드
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 엑셀 파일 다운로드
|
||||
*/
|
||||
@GetMapping("/api/household/dailyRecordStatus/excel")
|
||||
public ResponseEntity<byte[]> exportHouseholdExcel(GetDailyRecordStatusDetailReqVO reqVO) {
|
||||
|
||||
String householdNum = "-";
|
||||
String ownerName = "-";
|
||||
GetHouseholdStatus householdInfo = getHouseholdStatusPortIn.operate(new GetHouseholdStatusCmd(reqVO.getHouseholdSeq())).orElse(null);
|
||||
if (householdInfo != null) {
|
||||
householdNum = householdInfo.getHouseholdNum();
|
||||
ownerName = householdInfo.getHouseholdName();
|
||||
}
|
||||
|
||||
GetDailyRecordStatusDetail recordView = portIn.operate(
|
||||
new GetDailyRecordStatusCmd(reqVO.getRecordMonth(), reqVO.getHouseholdSeq())).orElse(null);
|
||||
|
||||
// 시트 : 등록 현황 목록
|
||||
ExcelSheetDto sheet1 = this.getIncomeSheet(recordView, householdNum, ownerName);
|
||||
ExcelSheetDto sheet2 = this.getWorkSheet(recordView, householdNum, ownerName);
|
||||
ExcelSheetDto sheet3 = this.getExpenseSheet(recordView, householdNum, ownerName);
|
||||
ExcelSheetDto sheet4 = this.getPowerSheet(recordView, householdNum, ownerName);
|
||||
ExcelSheetDto sheet5 = this.getForestrySheet(recordView, householdNum, ownerName);
|
||||
ExcelSheetDto sheet6 = this.getFarmingSheet(recordView, householdNum, ownerName);
|
||||
|
||||
// 시트 모음
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1, sheet2, sheet3, sheet4, sheet5, sheet6);
|
||||
|
||||
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||
|
||||
String rawFileName = "03. 일계부 등록 내용[" + reqVO.getRecordMonth() + "][" + householdNum + "]_" + 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수입 엑셀 시트 생성
|
||||
*
|
||||
|
||||
@@ -1,43 +1,25 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.ExcelWriterUtil;
|
||||
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.GetDailyRecordsCountPortIn;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCount;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCountCmd;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.adapters.web.model.GetDailyRecordsStatusReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.adapters.web.model.GetDailyRecordsStatusResVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.GetDailyRecordsStatusPortIn;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatus;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatusCmd;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.adapters.web.model.GetDailyRecordsStatusReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.adapters.web.model.GetDailyRecordsStatusResVO;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetDailyRecordsStatusController {
|
||||
private final GetDailyRecordsStatusPortIn getDailyRecordsStatusPortIn;
|
||||
private final GetDailyRecordsCountPortIn getDailyRecordsCountPortIn;
|
||||
private final GetHouseholdStatusPortIn getHouseholdStatusPortIn;
|
||||
|
||||
@GetMapping(path = "/api/household/dailyRecordsStatus")
|
||||
ResponseEntity<?> operate(GetDailyRecordsStatusReqVO reqVO) {
|
||||
@@ -53,63 +35,4 @@ class GetDailyRecordsStatusController {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new GetDailyRecordsStatusResVO(summary, dailyRecords));
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 등록 현황 엑셀 다운로드
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 엑셀 파일 다운로드
|
||||
*/
|
||||
@GetMapping("/api/household/dailyRecordsStatus/excel")
|
||||
public ResponseEntity<byte[]> exportHouseholdExcel(GetDailyRecordsStatusReqVO reqVO) {
|
||||
|
||||
String householdNum = "-";
|
||||
String ownerName = "-";
|
||||
GetHouseholdStatus householdInfo = getHouseholdStatusPortIn.operate(new GetHouseholdStatusCmd(reqVO.getHouseholdSeq())).orElse(null);
|
||||
if (householdInfo != null) {
|
||||
householdNum = householdInfo.getHouseholdNum();
|
||||
ownerName = householdInfo.getHouseholdName();
|
||||
}
|
||||
|
||||
List<GetDailyRecordsStatus> dailyRecords =
|
||||
getDailyRecordsStatusPortIn.operate(
|
||||
new GetDailyRecordsStatusCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth()));
|
||||
|
||||
List<List<String>> rows = new ArrayList<>();
|
||||
for (GetDailyRecordsStatus record : dailyRecords) {
|
||||
rows.add(List.of(householdNum, ownerName,
|
||||
record.getDayGroup(),
|
||||
record.getAllStatusType().getDesc(),
|
||||
record.getIncomeStatus(),
|
||||
record.getWorkStatus(),
|
||||
record.getExpenseStatus(),
|
||||
record.getPowerStatus(),
|
||||
record.getForestryStatus(),
|
||||
record.getFarmingStatus()));
|
||||
}
|
||||
|
||||
// 시트 1: 등록 현황 목록
|
||||
ExcelSheetDto sheet1 = new ExcelSheetDto(
|
||||
"일계부 등록 현황",
|
||||
List.of("임가번호", "경영주 성명", "입력 날짜", "완료상태", "수입", "노동투입", "지출", "동력사용시간", "임업 자가소비량", "농업 자가소비량"),
|
||||
rows,
|
||||
null,
|
||||
Map.of(
|
||||
0, IndexedColors.LIGHT_YELLOW
|
||||
)
|
||||
);
|
||||
|
||||
// 시트 모음
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1);
|
||||
|
||||
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||
|
||||
String rawFileName = "02. 일계부 등록 현황[" + reqVO.getRecordMonth() + "][" + householdNum + "]_" + 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);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,11 @@
|
||||
package app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.util.ExcelWriterUtil;
|
||||
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
|
||||
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.adapters.web.model.GetForestProductsStatusReqVO;
|
||||
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.GetForestProductsStatusPortIn;
|
||||
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatus;
|
||||
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusCmd;
|
||||
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusResult;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -32,93 +15,10 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
class GetForestProductsStatusController {
|
||||
|
||||
private final GetForestProductsStatusPortIn portIn;
|
||||
private final GetHouseholdStatusPortIn getHouseholdStatusPortIn;
|
||||
|
||||
@GetMapping(path = "/api/household/forestProducts")
|
||||
ResponseEntity<GetForestProductsStatusResult> operate(GetForestProductsStatusReqVO reqVO) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(portIn.operate(
|
||||
new GetForestProductsStatusCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 임산물현황 엑셀 다운로드
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 엑셀 파일 다운로드
|
||||
*/
|
||||
@GetMapping("/api/household/forestProduct/excel")
|
||||
public ResponseEntity<byte[]> exportForestExcel(GetForestProductsStatusReqVO reqVO) {
|
||||
|
||||
String householdNum = "-";
|
||||
String ownerName = "-";
|
||||
GetHouseholdStatus householdInfo = getHouseholdStatusPortIn
|
||||
.operate(new GetHouseholdStatusCmd(reqVO.getHouseholdSeq())).orElse(null);
|
||||
if (householdInfo != null) {
|
||||
householdNum = householdInfo.getHouseholdNum();
|
||||
ownerName = householdInfo.getHouseholdName();
|
||||
}
|
||||
|
||||
GetForestProductsStatusResult forestRecords =
|
||||
portIn.operate(
|
||||
new GetForestProductsStatusCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth()));
|
||||
|
||||
List<List<String>> rows = new ArrayList<>();
|
||||
for (GetForestProductsStatus record : forestRecords.getForestProducts()) {
|
||||
rows.add(List.of(
|
||||
householdNum,
|
||||
ownerName,
|
||||
StringUtils.defaultString(record.getStreetNum()),
|
||||
StringUtils.defaultString(record.getLandType()),
|
||||
StringUtils.defaultString(record.getTown()),
|
||||
StringUtils.defaultString(record.getAvailableArea()),
|
||||
StringUtils.defaultString(record.getCropName()),
|
||||
StringUtils.defaultString(record.getCropeCode()),
|
||||
StringUtils.defaultString(record.getLandArea()),
|
||||
StringUtils.defaultString(record.getMainYield()),
|
||||
StringUtils.defaultString(record.getMainYieldUnitText()),
|
||||
StringUtils.defaultString(record.getMainSaleAmount()),
|
||||
StringUtils.defaultString(record.getMainSaleAmountUnitText()),
|
||||
StringUtils.defaultString(record.getSubYield()),
|
||||
StringUtils.defaultString(record.getSubYieldUnitText()),
|
||||
StringUtils.defaultString(record.getSubSaleAmount()),
|
||||
StringUtils.defaultString(record.getSubSaleAmountUnitText())
|
||||
));
|
||||
}
|
||||
|
||||
// 시트 1: 임산물 현황 목록
|
||||
ExcelSheetDto sheet1 = new ExcelSheetDto("임산물 현황",
|
||||
List.of(
|
||||
"임가번호",
|
||||
"경영주 성명",
|
||||
"지번",
|
||||
"지목",
|
||||
"읍면동",
|
||||
"가능면적(평)",
|
||||
"재배 작물명",
|
||||
"작물 부호",
|
||||
"면적",
|
||||
"주생산물 수확량",
|
||||
"단위",
|
||||
"주생산물 판매량",
|
||||
"단위",
|
||||
"부생산물 수확량",
|
||||
"단위",
|
||||
"부생산물 판매량",
|
||||
"단위"),
|
||||
rows,
|
||||
null,
|
||||
Map.of(0, IndexedColors.LIGHT_YELLOW));
|
||||
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1);
|
||||
|
||||
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||
|
||||
String rawFileName = "05. 임산물 현황[" + reqVO.getRecordMonth() + "][" + householdNum + "]_" + 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);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,12 @@
|
||||
package app.module.admin.usecase.household.tab.householdVisit.getHouseholdVisitInfos.adapters.web;
|
||||
|
||||
import app.module.admin.config.application.enums.ManagementType;
|
||||
import app.module.admin.config.application.util.ExcelWriterUtil;
|
||||
import app.module.admin.config.application.util.model.ExcelSheetDto;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
|
||||
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.adapters.web.model.GetForestProductsStatusReqVO;
|
||||
import app.module.admin.usecase.household.tab.householdVisit.getHouseholdVisitInfos.adapters.web.model.GetHouseholdVisitInfosReqVO;
|
||||
import app.module.admin.usecase.household.tab.householdVisit.getHouseholdVisitInfos.ports.GetHouseholdVisitInfosPortIn;
|
||||
import app.module.admin.usecase.household.tab.householdVisit.getHouseholdVisitInfos.ports.application.domain.GetHouseholdVisitInfos;
|
||||
import app.module.admin.usecase.household.tab.householdVisit.getHouseholdVisitInfos.ports.application.domain.GetHouseholdVisitInfosCmd;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -34,76 +16,10 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
class GetHouseholdVisitInfosController {
|
||||
|
||||
private final GetHouseholdVisitInfosPortIn portIn;
|
||||
private final GetHouseholdStatusPortIn getHouseholdStatusPortIn;
|
||||
|
||||
@GetMapping(path = "/api/household/visitInfos")
|
||||
ResponseEntity<List<GetHouseholdVisitInfos>> operate(GetHouseholdVisitInfosReqVO reqVO) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(portIn.operate(
|
||||
new GetHouseholdVisitInfosCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 임가방문정보 엑셀 다운로드
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 엑셀 파일 다운로드
|
||||
*/
|
||||
@GetMapping("/api/household/visitInfos/excel")
|
||||
public ResponseEntity<byte[]> exportVisitExcel(GetForestProductsStatusReqVO reqVO) {
|
||||
|
||||
String householdNum = "-";
|
||||
String ownerName = "-";
|
||||
GetHouseholdStatus householdInfo = getHouseholdStatusPortIn
|
||||
.operate(new GetHouseholdStatusCmd(reqVO.getHouseholdSeq())).orElse(null);
|
||||
if (householdInfo != null) {
|
||||
householdNum = householdInfo.getHouseholdNum();
|
||||
ownerName = householdInfo.getHouseholdName();
|
||||
}
|
||||
|
||||
List<GetHouseholdVisitInfos> visitInfos = portIn.operate(
|
||||
new GetHouseholdVisitInfosCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth()));
|
||||
|
||||
List<List<String>> rows = new ArrayList<>();
|
||||
for (GetHouseholdVisitInfos record : visitInfos) {
|
||||
rows.add(List.of(
|
||||
householdNum,
|
||||
ownerName,
|
||||
record.getVisitDate(),
|
||||
Optional.ofNullable(ManagementType.from(record.getManagementType()))
|
||||
.map(ManagementType::getDesc).orElse(""),
|
||||
record.getContent(),
|
||||
record.getUpdatedBy() + " (" + record.getUpdatedAt() + ")",
|
||||
record.getIsGiftSent() ? "전달 완료" : "-"
|
||||
));
|
||||
}
|
||||
|
||||
// 시트 1: 임가방문정보 목록
|
||||
ExcelSheetDto sheet1 = new ExcelSheetDto("임가방문정보",
|
||||
List.of(
|
||||
"임가번호",
|
||||
"경영주 성명",
|
||||
"방문일",
|
||||
"관리분야",
|
||||
"내용",
|
||||
"최종 작성자",
|
||||
"답례품 전달"),
|
||||
rows,
|
||||
Collections.singleton(11),
|
||||
Map.of(
|
||||
0, IndexedColors.LIGHT_YELLOW,
|
||||
2, IndexedColors.LIGHT_TURQUOISE
|
||||
));
|
||||
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1);
|
||||
|
||||
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||
|
||||
String rawFileName = "06. 임가방문정보[" + reqVO.getRecordMonth() + "][" + householdNum + "]_" + 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);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
package app.module.admin.usecase.researcher.adpaters.web;
|
||||
|
||||
import app.module.admin.config.application.enums.UsageType;
|
||||
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.adpaters.web.model.HouseholdSearchReqVO;
|
||||
import app.module.admin.usecase.researcher.adpaters.web.model.MappingHouseholdListReqVO;
|
||||
import app.module.admin.usecase.researcher.adpaters.web.model.ResearchersDetailReqVO;
|
||||
import app.module.admin.usecase.researcher.adpaters.web.model.ResearchersListReqVO;
|
||||
import app.module.admin.usecase.researcher.adpaters.web.model.ResearchersVisitDetailReqVO;
|
||||
import app.module.admin.usecase.researcher.ports.ResearcherPortIn;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -25,10 +25,14 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -123,121 +127,4 @@ class ResearcherApiController {
|
||||
.body(excel);
|
||||
}
|
||||
|
||||
@GetMapping(path = "/mappingHouseholdList/excel")
|
||||
ResponseEntity<byte[]> exportMappingHouseholdsExcel(@ModelAttribute ResearchersDetailReqVO reqVO) {
|
||||
|
||||
Page<ResearchersMappingHouseholdDto> mappingHouseholds =
|
||||
researcherPortIn.mappingHouseholdList(reqVO);
|
||||
|
||||
List<List<String>> rows = new ArrayList<>();
|
||||
for(ResearchersMappingHouseholdDto item : mappingHouseholds.getContent()) {
|
||||
rows.add(List.of(
|
||||
StringUtils.defaultString(item.getHouseholdNum()),
|
||||
StringUtils.defaultString(item.getOwnerName()),
|
||||
StringUtils.defaultString(item.getOwnerAge().toString()),
|
||||
StringUtils.defaultString(item.getPhone()),
|
||||
StringUtils.defaultString(item.getRegionMainCodeName()),
|
||||
StringUtils.defaultString(item.getRegionSubCodeName()),
|
||||
StringUtils.defaultString(item.getRegionDetailCodeName()),
|
||||
StringUtils.defaultString(item.getAddress()),
|
||||
StringUtils.defaultString(item.getIndustryLargeCodeName()),
|
||||
StringUtils.defaultString(item.getIndustryMiddleCodeName()),
|
||||
StringUtils.defaultString(item.getIndustrySubMiddle()),
|
||||
StringUtils.defaultString(item.getIndustryDetail()),
|
||||
StringUtils.defaultString(item.getResearcherName()),
|
||||
StringUtils.defaultString(item.getResearcherPhone()),
|
||||
item.getUsageType() != null ? UsageType.valueOf(item.getUsageType()).getDesc() : "",
|
||||
StringUtils.defaultString(item.getPanelFlag())
|
||||
));
|
||||
}
|
||||
|
||||
// 시트 1: 임가 목록
|
||||
ExcelSheetDto sheet1 = new ExcelSheetDto(
|
||||
"임가 목록",
|
||||
List.of(
|
||||
"임가번호",
|
||||
"경영주 성명",
|
||||
"연령",
|
||||
"연락처",
|
||||
"실사",
|
||||
"지역",
|
||||
"세부지역",
|
||||
"전체 주소",
|
||||
"업종_대분류",
|
||||
"업종_중분류1",
|
||||
"업종_중분류2",
|
||||
"규모/세부품목",
|
||||
"조사원",
|
||||
"조사원 연락처",
|
||||
"이용 구분",
|
||||
"유지여부"),
|
||||
rows,
|
||||
null,
|
||||
Map.of(0, IndexedColors.LIGHT_YELLOW)
|
||||
);
|
||||
|
||||
// 시트 모음
|
||||
List<ExcelSheetDto> sheets = List.of(sheet1);
|
||||
|
||||
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
|
||||
|
||||
String rawFileName = "08. 담당 임가 목록" + "_" + 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);
|
||||
}
|
||||
|
||||
@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 = "임가방문정보_" + 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