엑셀 다운로드 일계부 등록 데이터 완료

This commit is contained in:
주수현
2025-07-14 12:20:53 +09:00
parent b7845f14d7
commit 8f626812de
15 changed files with 670 additions and 36 deletions

View File

@@ -27,8 +27,27 @@ class GetHouseholdsExcelDao implements GetHouseholdsExcelPortOut {
}
@Override
public List<GetForestProducts> forestProducts(GetHouseholdsExcelCmd cmd) { return mapper.forestProducts(cmd); }
public List<GetForestProducts> forestProducts(GetHouseholdsExcelCmd cmd) { return mapper.forestProductsExcel(cmd); }
@Override
public List<GetBankAutoTransfers> bankAutoTransfers(GetHouseholdsExcelCmd cmd) { return mapper.bankAutoTransfers(cmd); }
}
public List<GetBankAutoTransfers> bankAutoTransfers(GetHouseholdsExcelCmd cmd) { return mapper.bankAutoTransfersExcel(cmd); }
@Override
public List<GetCarryOvers> carryOvers(GetHouseholdsExcelCmd cmd) { return mapper.carryOversExcel(cmd); }
@Override
public List<GetDailyIncomeExpense> dailyIncomeExpenses(GetHouseholdsExcelCmd cmd) { return mapper.dailyIncomeExpensesExcel(cmd); }
@Override
public List<GetDailyWork> dailyWorks(GetHouseholdsExcelCmd cmd) { return mapper.dailyWorksExcel(cmd); }
@Override
public List<GetDailyPower> dailyPowers(GetHouseholdsExcelCmd cmd) { return mapper.dailyPowersExcel(cmd); }
@Override
public List<GetDailyForestry> dailyForestry(GetHouseholdsExcelCmd cmd) { return mapper.dailyForestryExcel(cmd); }
@Override
public List<GetDailyFarming> dailyFarmings(GetHouseholdsExcelCmd cmd) { return mapper.dailyFarmingsExcel(cmd); }
}

View File

@@ -10,6 +10,12 @@ public interface GetHouseholdsExcelMapper {
List<GetHouseholds> households(GetHouseholdsExcelCmd cmd);
List<GetDailyRecords> dailyRecords(GetHouseholdsExcelCmd cmd);
List<GetVisitInfos> visitInfos(GetHouseholdsExcelCmd cmd);
List<GetForestProducts> forestProducts(GetHouseholdsExcelCmd cmd);
List<GetBankAutoTransfers> bankAutoTransfers(GetHouseholdsExcelCmd cmd);
List<GetForestProducts> forestProductsExcel(GetHouseholdsExcelCmd cmd);
List<GetBankAutoTransfers> bankAutoTransfersExcel(GetHouseholdsExcelCmd cmd);
List<GetCarryOvers> carryOversExcel(GetHouseholdsExcelCmd cmd);
List<GetDailyIncomeExpense> dailyIncomeExpensesExcel(GetHouseholdsExcelCmd cmd);
List<GetDailyWork> dailyWorksExcel(GetHouseholdsExcelCmd cmd);
List<GetDailyPower> dailyPowersExcel(GetHouseholdsExcelCmd cmd);
List<GetDailyForestry> dailyForestryExcel(GetHouseholdsExcelCmd cmd);
List<GetDailyFarming> dailyFarmingsExcel(GetHouseholdsExcelCmd cmd);
}

View File

@@ -18,6 +18,8 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import app.module.core.config.application.util.DailyUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -36,6 +38,7 @@ import org.springframework.web.bind.annotation.RestController;
class GetHouseholdsExcelController {
private final GetHouseholdsStatusPortIn getHouseholdsStatusPortIn;
private final GetHouseholdsExcelPortIn getHouseholdsExcelPortIn;
private final DailyUtil dailyUtil;
/**
* 엑셀 다운로드 응답용 데이터 클래스.
@@ -94,12 +97,24 @@ class GetHouseholdsExcelController {
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth()))
);
case DAILY_RECORD -> // 일계부 등록 데이터
// TODO : 추가하기
dailyRegisterExcel(
getHouseholdsExcelPortIn.forestProducts(
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth())),
getHouseholdsExcelPortIn.bankAutoTransfers(
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth())),
getHouseholdsExcelPortIn.carryOvers(
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth())),
getHouseholdsExcelPortIn.dailyIncomeExpenses(
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth())),
getHouseholdsExcelPortIn.dailyWorks(
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth())),
getHouseholdsExcelPortIn.dailyPowers(
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth())),
getHouseholdsExcelPortIn.dailyForestry(
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth())),
getHouseholdsExcelPortIn.dailyFarmings(
new GetHouseholdsExcelCmd(householdSeqList, reqVO.getRecordMonth()))
);
default -> null;
};
@@ -308,7 +323,16 @@ class GetHouseholdsExcelController {
/**
* 엑셀 다운로드 템플릿 - 일계부 등록 데이터
* */
private ExcelResult dailyRegisterExcel(List<GetForestProducts> forestItems,List<GetBankAutoTransfers> bankAutoTransferItems) {
private ExcelResult dailyRegisterExcel(
List<GetForestProducts> forestItems,
List<GetBankAutoTransfers> bankAutoTransferItems,
List<GetCarryOvers> carryOverItems,
List<GetDailyIncomeExpense> dailyIncomeExpenseItems ,
List<GetDailyWork> dailyWorkItems,
List<GetDailyPower> dailyPowerItems,
List<GetDailyForestry> dailyForestryItems,
List<GetDailyFarming> dailyFarmingItems ){
// 시트 1: 임산물 현황
List<List<String>> rows = new ArrayList<>();
for(GetForestProducts item : forestItems) {
@@ -320,7 +344,7 @@ class GetHouseholdsExcelController {
StringUtils.defaultString(item.getTown()),
StringUtils.defaultString(item.getAvailableArea()),
StringUtils.defaultString(item.getCropName()),
StringUtils.defaultString(item.getCropCodeName()),
StringUtils.defaultString(item.getCropCode()),
StringUtils.defaultString(item.getLandArea()),
StringUtils.defaultString(item.getMainYield()),
StringUtils.defaultString(item.getMainYieldUnitCodeName()),
@@ -359,7 +383,7 @@ class GetHouseholdsExcelController {
Map.of(0, IndexedColors.LIGHT_YELLOW));
// 시트 2: 자동이체_수입(지출) 현황
rows.clear();
rows = new ArrayList<>();
for(GetBankAutoTransfers item : bankAutoTransferItems) {
rows.add(List.of(
StringUtils.defaultString(item.getHouseholdNum()),
@@ -367,12 +391,12 @@ class GetHouseholdsExcelController {
StringUtils.defaultString(item.getTransferTypeName()),
StringUtils.defaultString(item.getIncomeCode()),
StringUtils.defaultString(item.getExpenseCode()),
StringUtils.defaultString(item.getCropCodeName()),
StringUtils.defaultString(item.getCropCode()),
StringUtils.defaultString(item.getTransferCategoryCodeName()),
StringUtils.defaultString(item.getSourcePurpose()),
StringUtils.defaultString(item.getCount()),
StringUtils.defaultString(item.getUnitCodeName()),
StringUtils.defaultString(item.getPrice())
StringUtils.defaultString(dailyUtil.getStringComma(item.getPrice()))
));
}
@@ -395,7 +419,229 @@ class GetHouseholdsExcelController {
null,
Map.of(0, IndexedColors.LIGHT_YELLOW));
List<ExcelSheetDto> sheets = List.of(sheet1,sheet2);
// 시트 3: 월초 이월금
rows = new ArrayList<>();
for(GetCarryOvers item : carryOverItems) {
rows.add(List.of(
StringUtils.defaultString(item.getHouseholdNum()),
StringUtils.defaultString(item.getOwnerName()),
StringUtils.defaultString(dailyUtil.getStringComma(item.getCarryOver()))
));
}
ExcelSheetDto sheet3 = new ExcelSheetDto("월초이월금",
List.of(
"임가번호",
"경영주 성명",
"월초이월금"
),
rows,
null,
Map.of(0, IndexedColors.LIGHT_YELLOW));
// 시트 4: 수입(지출)
rows = new ArrayList<>();
for(GetDailyIncomeExpense item : dailyIncomeExpenseItems) {
rows.add(List.of(
StringUtils.defaultString(item.getHouseholdNum()),
StringUtils.defaultString(item.getOwnerName()),
StringUtils.defaultString(item.getStartDay()),
StringUtils.defaultString(item.getEndDay()),
StringUtils.defaultString(item.getCategory()),
StringUtils.defaultString(item.getIncomeMark()),
StringUtils.defaultString(item.getExpenseMark()),
StringUtils.defaultString(item.getCropCode()),
StringUtils.defaultString(item.getKind()),
StringUtils.defaultString(item.getSourcePurpose()),
StringUtils.defaultString(item.getQuantity()),
StringUtils.defaultString(item.getUnitCodeName()),
StringUtils.defaultString(dailyUtil.getStringComma(item.getPrice())),
StringUtils.defaultString(dailyUtil.getStringComma(item.getEstimatedValue()))
));
}
ExcelSheetDto sheet4 = new ExcelSheetDto("수입(지출)",
List.of(
"임가번호",
"경영주 성명",
"날",
"짜",
"유형",
"수입 부호",
"지출 부호",
"재배형태 코드",
"수입(지출)의 종류",
"수입원(용도)",
"수량",
"단위",
"현금(원)",
"현물(평가액)"
),
rows,
null,
Map.of(0, IndexedColors.LIGHT_YELLOW));
// 시트 5: 임업노동 투입내역
rows = new ArrayList<>();
for(GetDailyWork item : dailyWorkItems) {
rows.add(List.of(
StringUtils.defaultString(item.getHouseholdNum()),
StringUtils.defaultString(item.getOwnerName()),
StringUtils.defaultString(item.getStartDay()),
StringUtils.defaultString(item.getEndDay()),
StringUtils.defaultString(item.getItemName()),
StringUtils.defaultString(item.getItemMark()),
StringUtils.defaultString(item.getWorkName()),
StringUtils.defaultString(item.getWorkMark()),
StringUtils.defaultString(item.getWorkLandArea()),
StringUtils.defaultString(item.getAreaUnitName()),
StringUtils.defaultString(item.getHarvestQuantity()),
StringUtils.defaultString(item.getHarvestUnitName()),
StringUtils.defaultString(item.getOwnerTime()),
StringUtils.defaultString(item.getSpouseTime()),
StringUtils.defaultString(item.getFamilyMHours()),
StringUtils.defaultString(item.getFamilyFHours()),
StringUtils.defaultString(item.getHiredMHours()),
StringUtils.defaultString(item.getHiredFHours()),
StringUtils.defaultString(item.getSharedMHours()),
StringUtils.defaultString(item.getSharedFHours()),
StringUtils.defaultString(item.getVolunteerMHours()),
StringUtils.defaultString(item.getVolunteerMHours())
));
}
ExcelSheetDto sheet5 = new ExcelSheetDto("임업노동 투입내역",
List.of(
"임가번호",
"경영주 성명",
"날",
"짜",
"품목명",
"품목 부호",
"작업명",
"작업 부호",
"작업면적",
"단위",
"수확량",
"단위",
"경영주",
"배우자",
"가족노동 남",
"가족노동 여",
"고용노동 남",
"고용노동 여",
"품앗이 남",
"품앗이 여",
"일손돕기 남",
"일손돕기 여"
),
rows,
null,
Map.of(0, IndexedColors.LIGHT_YELLOW));
// 시트 6: 동력사용시간
rows = new ArrayList<>();
for(GetDailyPower item : dailyPowerItems) {
rows.add(List.of(
StringUtils.defaultString(item.getHouseholdNum()),
StringUtils.defaultString(item.getOwnerName()),
StringUtils.defaultString(item.getStartDay()),
StringUtils.defaultString(item.getEndDay()),
StringUtils.defaultString(item.getEquipmentName()),
StringUtils.defaultString(item.getEquipmentMark()),
StringUtils.defaultString(item.getOwnedHours()),
StringUtils.defaultString(item.getLeasedHours())
));
}
ExcelSheetDto sheet6 = new ExcelSheetDto("동력사용시간",
List.of(
"임가번호",
"경영주 성명",
"날",
"짜",
"명칭",
"부호",
"자가시간",
"임차시간"
),
rows,
null,
Map.of(0, IndexedColors.LIGHT_YELLOW));
// 시트 7: 자가임업생산물 중 자가소비량
rows = new ArrayList<>();
for(GetDailyForestry item : dailyForestryItems) {
rows.add(List.of(
StringUtils.defaultString(item.getHouseholdNum()),
StringUtils.defaultString(item.getOwnerName()),
StringUtils.defaultString(item.getWeekOfMonth()),
StringUtils.defaultString(item.getIncomeMark()),
StringUtils.defaultString(item.getExpenseMark()),
StringUtils.defaultString(item.getProductName()),
StringUtils.defaultString(item.getUsage()),
StringUtils.defaultString(item.getQuantity()),
StringUtils.defaultString(item.getUnitName()),
StringUtils.defaultString(dailyUtil.getStringComma(item.getEstimatedValue()))
));
}
ExcelSheetDto sheet7 = new ExcelSheetDto(" 자가임업생산물 중 자가소비량",
List.of(
"임가번호",
"경영주 성명",
"차수",
"수입 부호",
"지출 부호",
"생산물",
"용도",
"수량",
"단위",
"현물평가액"
),
rows,
null,
Map.of(0, IndexedColors.LIGHT_YELLOW));
// 시트 8: 자가농업생산물 중 자가소비량
rows = new ArrayList<>();
for(GetDailyFarming item : dailyFarmingItems) {
rows.add(List.of(
StringUtils.defaultString(item.getHouseholdNum()),
StringUtils.defaultString(item.getOwnerName()),
StringUtils.defaultString(item.getStartDay()),
StringUtils.defaultString(item.getEndDay()),
StringUtils.defaultString(item.getIncomeMark()),
StringUtils.defaultString(item.getExpenseMark()),
StringUtils.defaultString(item.getProductName()),
StringUtils.defaultString(item.getUsage()),
StringUtils.defaultString(item.getQuantity()),
StringUtils.defaultString(item.getUnitName()),
StringUtils.defaultString(dailyUtil.getStringComma(item.getEstimatedValue()))
));
}
ExcelSheetDto sheet8 = new ExcelSheetDto("자가농업생산물 중 자가소비량",
List.of(
"임가번호",
"경영주 성명",
"날",
"짜",
"수입 부호",
"지출 부호",
"생산물",
"용도",
"수량",
"단위",
"현물평가액"
),
rows,
null,
Map.of(0, IndexedColors.LIGHT_YELLOW));
List<ExcelSheetDto> sheets = List.of(sheet1,sheet2,sheet3,sheet4,sheet5,sheet6,sheet7,sheet8);
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
String rawFileName = "일계부등록데이터_" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";

View File

@@ -16,15 +16,15 @@ public interface GetHouseholdsExcelPortIn {
// 자동이체_수입(지출)
List<GetBankAutoTransfers> bankAutoTransfers(GetHouseholdsExcelCmd cmd);
// 월초이월금
List<GetCarryOvers> carryOvers(GetHouseholdsExcelCmd cmd);
// 수입(지출)
// 임엄노동투입내력
List<GetDailyIncomeExpense> dailyIncomeExpenses(GetHouseholdsExcelCmd cmd);
// 임엄노동투입내역
List<GetDailyWork> dailyWorks(GetHouseholdsExcelCmd cmd);
// 동력사용시간
List<GetDailyPower> dailyPowers(GetHouseholdsExcelCmd cmd);
// 자가임업생산물 중 자가소비량
List<GetDailyForestry> dailyForestry(GetHouseholdsExcelCmd cmd);
// 자가농업생산물 중 자가소비량
List<GetDailyFarming> dailyFarmings(GetHouseholdsExcelCmd cmd);
}

View File

@@ -10,4 +10,10 @@ public interface GetHouseholdsExcelPortOut {
List<GetVisitInfos> visitInfos(GetHouseholdsExcelCmd cmd);
List<GetForestProducts> forestProducts(GetHouseholdsExcelCmd cmd);
List<GetBankAutoTransfers> bankAutoTransfers(GetHouseholdsExcelCmd cmd);
List<GetCarryOvers> carryOvers(GetHouseholdsExcelCmd cmd);
List<GetDailyIncomeExpense> dailyIncomeExpenses(GetHouseholdsExcelCmd cmd);
List<GetDailyWork> dailyWorks(GetHouseholdsExcelCmd cmd);
List<GetDailyPower> dailyPowers(GetHouseholdsExcelCmd cmd);
List<GetDailyForestry> dailyForestry(GetHouseholdsExcelCmd cmd);
List<GetDailyFarming> dailyFarmings(GetHouseholdsExcelCmd cmd);
}

View File

@@ -32,4 +32,23 @@ class GetHouseholdsExcelService implements GetHouseholdsExcelPortIn {
@Override
public List<GetBankAutoTransfers> bankAutoTransfers(GetHouseholdsExcelCmd cmd) { return portOut.bankAutoTransfers(cmd); }
@Override
public List<GetCarryOvers> carryOvers(GetHouseholdsExcelCmd cmd) { return portOut.carryOvers(cmd); }
@Override
public List<GetDailyIncomeExpense> dailyIncomeExpenses(GetHouseholdsExcelCmd cmd) { return portOut.dailyIncomeExpenses(cmd); }
@Override
public List<GetDailyWork> dailyWorks(GetHouseholdsExcelCmd cmd) { return portOut.dailyWorks(cmd); }
@Override
public List<GetDailyPower> dailyPowers(GetHouseholdsExcelCmd cmd) { return portOut.dailyPowers(cmd); }
@Override
public List<GetDailyForestry> dailyForestry(GetHouseholdsExcelCmd cmd) { return portOut.dailyForestry(cmd); }
@Override
public List<GetDailyFarming> dailyFarmings(GetHouseholdsExcelCmd cmd) { return portOut.dailyFarmings(cmd); }
}

View File

@@ -15,7 +15,7 @@ public class GetBankAutoTransfers {
private String transferTypeName;
private String incomeCode;
private String expenseCode;
private String cropCodeName;
private String cropCode;
private String transferCategoryCodeName;
private String sourcePurpose;
private String count;

View File

@@ -0,0 +1,16 @@
package app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetCarryOvers {
private String householdNum;
private String ownerName;
private String carryOver;
}

View File

@@ -0,0 +1,24 @@
package app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyFarming {
private String householdNum;
private String ownerName;
private String startDay;
private String endDay;
private String incomeMark;
private String expenseMark;
private String productName;
private String usage;
private String quantity;
private String unitName;
private String estimatedValue;
}

View File

@@ -0,0 +1,23 @@
package app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyForestry {
private String householdNum;
private String ownerName;
private String weekOfMonth;
private String incomeMark;
private String expenseMark;
private String productName;
private String usage;
private String quantity;
private String unitName;
private String estimatedValue;
}

View File

@@ -0,0 +1,27 @@
package app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyIncomeExpense {
private String householdNum;
private String ownerName;
private String startDay;
private String endDay;
private String category;
private String incomeMark;
private String expenseMark;
private String cropCode;
private String kind;
private String sourcePurpose;
private String quantity;
private String unitCodeName;
private String price;
private String estimatedValue;
}

View File

@@ -0,0 +1,21 @@
package app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyPower {
private String householdNum;
private String ownerName;
private String startDay;
private String endDay;
private String equipmentName;
private String equipmentMark;
private String ownedHours;
private String leasedHours;
}

View File

@@ -0,0 +1,35 @@
package app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyWork {
private String householdNum;
private String ownerName;
private String startDay;
private String endDay;
private String itemName;
private String itemMark;
private String workName;
private String workMark;
private String workLandArea;
private String areaUnitName;
private String harvestQuantity;
private String harvestUnitName;
private String ownerTime;
private String spouseTime;
private String familyMHours;
private String familyFHours;
private String hiredMHours;
private String hiredFHours;
private String sharedMHours;
private String sharedFHours;
private String volunteerMHours;
private String volunteerFHours;
}

View File

@@ -17,7 +17,7 @@ public class GetForestProducts {
private String town;
private String availableArea;
private String cropName;
private String cropCodeName;
private String cropCode;
private String landArea;
private String mainYield;
private String mainYieldUnitCodeName;