[Bo] 일계부 등록 내용 엑셀 다운로드(수입, 지출 외의 건)

This commit is contained in:
김현주
2025-07-03 14:34:55 +09:00
parent d904ff1baa
commit 1c2ea218ec
8 changed files with 314 additions and 48 deletions

View File

@@ -7,10 +7,7 @@ import app.module.admin.usecase.household.getHouseholdStatus.ports.application.d
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.GetDailyExpenseRecords;
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.GetDailyRecordStatusDetail;
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.*;
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;
@@ -67,16 +64,19 @@ class GetDailyRecordStatusDetailController {
ownerName = householdInfo.getHouseholdName();
}
GetDailyRecordStatusDetail recordView =
portIn.operate(new GetDailyRecordStatusCmd(reqVO.getRecordMonth(), reqVO.getHouseholdSeq())).orElse(null);
GetDailyRecordStatusDetail recordView = portIn.operate(
new GetDailyRecordStatusCmd(reqVO.getRecordMonth(), reqVO.getHouseholdSeq())).orElse(null);
// 시트 1: 등록 현황 목록
// 시트 : 등록 현황 목록
ExcelSheetDto sheet1 = this.getIncomeSheet(recordView, householdNum, ownerName);
ExcelSheetDto sheet2 = this.getExpenseSheet(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);
List<ExcelSheetDto> sheets = List.of(sheet1, sheet2, sheet3, sheet4, sheet5, sheet6);
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
@@ -89,6 +89,14 @@ class GetDailyRecordStatusDetailController {
.body(excel);
}
/**
* 수입 엑셀 시트 생성
*
* @param recordView 조회 데이터
* @param householdNum 임가번호
* @param ownerName 경영주 이름
* @return 엑셀 시트
*/
private ExcelSheetDto getIncomeSheet(GetDailyRecordStatusDetail recordView, String householdNum, String ownerName) {
List<List<String>> rows = new ArrayList<>();
if (recordView != null && !recordView.getIncomes().isEmpty()) {
@@ -104,7 +112,7 @@ class GetDailyRecordStatusDetailController {
row.add(StringUtils.defaultString(record.getIncomeKind()));
row.add(StringUtils.defaultString(record.getIncomeKindMark()));
row.add(StringUtils.defaultString(record.getSourcePurpose()));
row.add(record.getQuantity() != null ? StringUtils.defaultString(record.getQuantity().toString()) : "");
row.add(StringUtils.defaultString(record.getQuantity()));
row.add(StringUtils.defaultString(record.getUnitText()));
row.add(StringUtils.defaultString(record.getPrice()));
row.add(StringUtils.defaultString(record.getEstimatedValue()));
@@ -126,6 +134,67 @@ class GetDailyRecordStatusDetailController {
);
}
/**
* 임업노동 엑셀 시트 생성
*
* @param recordView 조회 데이터
* @param householdNum 임가번호
* @param ownerName 경영주 이름
* @return 엑셀 시트
*/
private ExcelSheetDto getWorkSheet(GetDailyRecordStatusDetail recordView, String householdNum, String ownerName) {
List<List<String>> rows = new ArrayList<>();
if (recordView != null && !recordView.getWorks().isEmpty()) {
for (GetDailyWorkRecords record : recordView.getWorks()) {
List<String> row = new ArrayList<>(List.of(householdNum, ownerName,
record.getStartDay(),
record.getEndDay(),
StringUtils.defaultString(record.getItemName()),
StringUtils.defaultString(record.getItemMark()),
StringUtils.defaultString(record.getWorkName()),
StringUtils.defaultString(record.getWorkMark())));
row.add(StringUtils.defaultString(record.getWorkLandArea()));
row.add(StringUtils.defaultString(record.getAreaUnitText()));
row.add(StringUtils.defaultString(record.getHarvestQuantity()));
row.add(StringUtils.defaultString(record.getHarvestUnitText()));
row.add(StringUtils.defaultString(record.getOwnerTime()));
row.add(StringUtils.defaultString(record.getSpouseTime()));
row.add(StringUtils.defaultString(record.getFamilyMHours()));
row.add(StringUtils.defaultString(record.getFamilyFHours()));
row.add(StringUtils.defaultString(record.getHiredMHours()));
row.add(StringUtils.defaultString(record.getHiredFHours()));
row.add(StringUtils.defaultString(record.getSharedMHours()));
row.add(StringUtils.defaultString(record.getSharedFHours()));
row.add(StringUtils.defaultString(record.getVolunteerMHours()));
row.add(StringUtils.defaultString(record.getVolunteerFHours()));
rows.add(row);
}
}
return new ExcelSheetDto(
"임업노동 투입",
List.of("임가번호", "경영주 성명", "날", "짜", "품목명", "품목부호", "작업명", "작업 부호", "작업면적", "단위", "수확량", "단위",
"경영주", "배우자", "가족노동-남", "가족노동-여", "고용노동-남", "고용노동-여", "품앗이-남", "품앗이-여", "일손돕기-남", "일손돕기-여"),
rows,
Set.of(8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21),
Map.of(
0, IndexedColors.LIGHT_YELLOW,
2, IndexedColors.LIGHT_TURQUOISE,
3, IndexedColors.LIGHT_TURQUOISE
)
);
}
/**
* 지출 엑셀 시트 생성
*
* @param recordView 조회 데이터
* @param householdNum 임가번호
* @param ownerName 경영주 이름
* @return 엑셀 시트
*/
private ExcelSheetDto getExpenseSheet(GetDailyRecordStatusDetail recordView, String householdNum, String ownerName) {
List<List<String>> rows = new ArrayList<>();
if (recordView != null && !recordView.getExpenses().isEmpty()) {
@@ -140,7 +209,7 @@ class GetDailyRecordStatusDetailController {
row.add(StringUtils.defaultString(record.getExpenseKind()));
row.add(StringUtils.defaultString(record.getExpenseKindMark()));
row.add(StringUtils.defaultString(record.getSourcePurpose()));
row.add(record.getQuantity() != null ? StringUtils.defaultString(record.getQuantity().toString()) : "");
row.add(StringUtils.defaultString(record.getQuantity()));
row.add(StringUtils.defaultString(record.getUnitText()));
row.add(StringUtils.defaultString(record.getPrice()));
row.add(StringUtils.defaultString(record.getEstimatedValue()));
@@ -161,4 +230,115 @@ class GetDailyRecordStatusDetailController {
)
);
}
/**
* 동력 사용시간 엑셀 시트 생성
*
* @param recordView 조회 데이터
* @param householdNum 임가번호
* @param ownerName 경영주 이름
* @return 엑셀 시트
*/
private ExcelSheetDto getPowerSheet(GetDailyRecordStatusDetail recordView, String householdNum, String ownerName) {
List<List<String>> rows = new ArrayList<>();
if (recordView != null && !recordView.getPowers().isEmpty()) {
for (GetDailyPowerRecords record : recordView.getPowers()) {
rows.add(List.of(householdNum, ownerName,
record.getStartDay(),
record.getEndDay(),
StringUtils.defaultString(record.getEquipmentName()),
StringUtils.defaultString(record.getEquipmentMark()),
StringUtils.defaultString(record.getOwnedHours()),
StringUtils.defaultString(record.getLeasedHours())));
}
}
return new ExcelSheetDto(
"동력사용시간",
List.of("임가번호", "경영주 성명", "날", "짜", "명칭", "명칭 부호", "자가 사용시간", "임차 사용시간"),
rows,
Set.of(6, 7),
Map.of(
0, IndexedColors.LIGHT_YELLOW,
2, IndexedColors.LIGHT_TURQUOISE,
3, IndexedColors.LIGHT_TURQUOISE
)
);
}
/**
* 임업 자가소비량 엑셀 시트 생성
*
* @param recordView 조회 데이터
* @param householdNum 임가번호
* @param ownerName 경영주 이름
* @return 엑셀 시트
*/
private ExcelSheetDto getForestrySheet(GetDailyRecordStatusDetail recordView, String householdNum, String ownerName) {
List<List<String>> rows = new ArrayList<>();
if (recordView != null && !recordView.getForestries().isEmpty()) {
for (GetDailyForestryRecords record : recordView.getForestries()) {
rows.add(List.of(householdNum, ownerName,
record.getStartDay(),
record.getEndDay(),
StringUtils.defaultString(record.getIncomeMark()),
StringUtils.defaultString(record.getExpenseMark()),
StringUtils.defaultString(record.getProductName()),
StringUtils.defaultString(record.getUsage()),
StringUtils.defaultString(record.getQuantity()),
StringUtils.defaultString(record.getUnitText()),
StringUtils.defaultString(record.getEstimatedValue())));
}
}
return new ExcelSheetDto(
"임업_자가소비량",
List.of("임가번호", "경영주 성명", "날", "짜", "수입 부호", "지출 부호", "생산물", "용도", "수량", "단위", "현물(평가액)"),
rows,
Set.of(8, 10),
Map.of(
0, IndexedColors.LIGHT_YELLOW,
2, IndexedColors.LIGHT_TURQUOISE,
3, IndexedColors.LIGHT_TURQUOISE
)
);
}
/**
* 농업 자가소비량 엑셀 시트 생성
*
* @param recordView 조회 데이터
* @param householdNum 임가번호
* @param ownerName 경영주 이름
* @return 엑셀 시트
*/
private ExcelSheetDto getFarmingSheet(GetDailyRecordStatusDetail recordView, String householdNum, String ownerName) {
List<List<String>> rows = new ArrayList<>();
if (recordView != null && !recordView.getFarmings().isEmpty()) {
for (GetDailyFarmingRecords record : recordView.getFarmings()) {
rows.add(List.of(householdNum, ownerName,
record.getStartDay(),
record.getEndDay(),
StringUtils.defaultString(record.getIncomeMark()),
StringUtils.defaultString(record.getExpenseMark()),
StringUtils.defaultString(record.getProductName()),
StringUtils.defaultString(record.getUsage()),
StringUtils.defaultString(record.getQuantity()),
StringUtils.defaultString(record.getUnitText()),
StringUtils.defaultString(record.getEstimatedValue())));
}
}
return new ExcelSheetDto(
"농업_자가소비량",
List.of("임가번호", "경영주 성명", "날", "짜", "수입 부호", "지출 부호", "생산물", "용도", "수량", "단위", "현물(평가액)"),
rows,
Set.of(8, 10),
Map.of(
0, IndexedColors.LIGHT_YELLOW,
2, IndexedColors.LIGHT_TURQUOISE,
3, IndexedColors.LIGHT_TURQUOISE
)
);
}
}

View File

@@ -8,15 +8,17 @@ import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyFarmingRecords {
private Long id;
private String incomeMark;
private String expenseMark;
private String productName;
private String usage;
private BigDecimal quantity;
private String quantity;
private String unitText;
private String estimatedValue;
private String updatedBy;
private String updatedAt;
private String startDay;
private String endDay;
}

View File

@@ -8,16 +8,18 @@ import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyForestryRecords {
private Long id;
private String incomeMark;
private String expenseMark;
private String productName;
private String usage;
private BigDecimal quantity;
private String quantity;
private String unitCode;
private String unitText;
private String estimatedValue;
private String updatedBy;
private String updatedAt;
private String startDay;
private String endDay;
}

View File

@@ -21,7 +21,7 @@ public class GetDailyIncomeRecords {
private String incomeKind;
private String incomeKindMark;
private String sourcePurpose;
private BigDecimal quantity;
private String quantity;
private String unitCode;
private String unitText;
private String price;

View File

@@ -8,13 +8,14 @@ import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyPowerRecords {
private Long id;
private String equipmentName;
private BigDecimal ownedHours;
private BigDecimal leasedHours;
private String equipmentMark;
private String ownedHours;
private String leasedHours;
private String updatedBy;
private String updatedAt;
private String startDay;
private String endDay;
}

View File

@@ -22,4 +22,12 @@ public class GetDailyRecordStatusCmd {
private Long recordSeq;
private Long householdSeq;
private String recordMonth;
/**
* 월 검색 여부
* @return true=월 검색, false=단일 검색
*/
public boolean isSearchMonth() {
return recordMonth != null && householdSeq != null;
}
}

View File

@@ -7,12 +7,12 @@ import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyWorkRecords {
private Long id;
private String itemName;
private String itemMark;
private String workName;
private String workMark;
private String workLandArea;
private String areaUnitText;
private String harvestQuantity;
@@ -29,4 +29,6 @@ public class GetDailyWorkRecords {
private String volunteerFHours;
private String updatedBy;
private String updatedAt;
private String startDay;
private String endDay;
}