diff --git a/README.md b/README.md index d86001dd..906ebb3e 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,53 @@ spring: username: ENC(...) password: ENC(...) ``` +작성_1 : pom.xml에 의존성추가 +```pom + +com.github.ulisesbocchio +jasypt-spring-boot-starter +3.0.5 + +``` +작성_2 : 클래스 생성 후 실행 +```java +import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; + +public class EncryptTest { + public static void main(String[] args) { + StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); + encryptor.setPassword("내Jasypt비번"); // jasypt.encryptor.password 값과 동일 + encryptor.setAlgorithm("PBEWITHHMACSHA512ANDAES_256"); // 설정에 맞춤 + + String plainText = "dbUserPassword"; // 평문 + String encrypted = encryptor.encrypt(plainText); + + System.out.println("ENC(" + encrypted + ")"); + } +} +``` +작성_3 : 암호화 문자열 생성 +```scss +ENC(mF3Z0fgCagFruOk/F2Z2PYzXhwGedE1secfYDgci+ke9z8xFEZ/GWbgXA4XeSq5D...) +``` +작성_4 : 복호화 +```java +import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; + +public class DecryptTest { +public static void main(String[] args) { +StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); +encryptor.setPassword("내Jasypt비번"); +encryptor.setAlgorithm("PBEWITHHMACSHA512ANDAES_256"); + + String encrypted = "mF3Z0fgCagFruOk/..."; // ENC(...) 안쪽 + String decrypted = encryptor.decrypt(encrypted); + + System.out.println("복호화 결과 = " + decrypted); + } +} +``` --- ## 🗃️ DB 구성 diff --git a/admin/src/main/java/app/module/admin/BulkUrlShortener.java b/admin/src/main/java/app/module/admin/BulkUrlShortener.java new file mode 100644 index 00000000..be2e36b1 --- /dev/null +++ b/admin/src/main/java/app/module/admin/BulkUrlShortener.java @@ -0,0 +1,95 @@ +package app.module.admin; + +import java.io.IOException; +import java.io.PrintWriter; +import java.net.URLEncoder; +import java.net.http.*; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.*; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class BulkUrlShortener { + + private static final String ISGD_API = "https://is.gd/create.php?format=json&url="; + private static final ObjectMapper MAPPER = new ObjectMapper(); + private static final HttpClient CLIENT = HttpClient.newBuilder() + .connectTimeout(Duration.ofSeconds(10)) + .build(); + + public static void main(String[] args) throws Exception { + + // 🔹 단축할 URL 목록 (여기만 교체!) + // 🔹 대상 SID 목록 + List sidList = Arrays.asList( + 80303, 80308, 80309, 80310, 80312, 80313, 80314, + 80316, 80317, 80318, 80319, 80322, 80323, 80324, 80325, + 80327, 80328, 80329, 80330, 80331, 80332, 80333, 80334, + 80336, 80337, 80338, 80339, 80340, 80343, 80344, 80346, + 80347, 80348, 80349, 80350, 80351, 80352 + ); + + List urls = new ArrayList<>(); + for (Integer sid : sidList) { + urls.add("https://kon.kric.com/project/2509018_B/INDEX.asp?SID=" + sid); + } +// for (int i = 80001; i <= 81575; i++) { +// urls.add("https://kon.kric.com/project/2509018_B/INDEX.asp?SID=" + i); +// } + + Map results = new LinkedHashMap<>(); + int delayMillis = 400; // 0.4초 간격 (안전한 호출 속도) + int success = 0; + + System.out.println("총 " + urls.size() + "개의 URL 단축을 시작합니다...\n"); + + for (int i = 0; i < urls.size(); i++) { + String longUrl = urls.get(i); + try { + String shortUrl = shorten(longUrl); + results.put(longUrl, shortUrl); + success++; + System.out.printf("[%4d/%4d] %s -> %s%n", success, urls.size(), longUrl, shortUrl); + } catch (Exception e) { + results.put(longUrl, "ERROR"); + System.err.printf("[ERROR] %s : %s%n", longUrl, e.getMessage()); + } + Thread.sleep(delayMillis); + } + + System.out.println("\n✅ 작업 완료: " + success + "개 단축 완료"); + saveCsv(results); + } + + public static String shorten(String longUrl) throws IOException, InterruptedException { + String encoded = URLEncoder.encode(longUrl, StandardCharsets.UTF_8); + String apiUrl = ISGD_API + encoded; + + HttpRequest req = HttpRequest.newBuilder() + .uri(URI.create(apiUrl)) + .timeout(Duration.ofSeconds(10)) + .header("User-Agent", "Java-Bulk-Shortener/1.0") + .GET() + .build(); + + HttpResponse resp = CLIENT.send(req, HttpResponse.BodyHandlers.ofString()); + if (resp.statusCode() != 200) throw new IOException("HTTP " + resp.statusCode()); + + Map map = MAPPER.readValue(resp.body(), Map.class); + if (map.get("shorturl") == null) throw new IOException("API error: " + map); + return map.get("shorturl").toString(); + } + + private static void saveCsv(Map results) throws IOException { + try (PrintWriter pw = new PrintWriter("short_urls.csv", StandardCharsets.UTF_8)) { + pw.println("original_url,short_url"); + for (var e : results.entrySet()) { + pw.printf("\"%s\",\"%s\"%n", e.getKey(), e.getValue()); + } + } + System.out.println("결과가 short_urls.csv 로 저장되었습니다 ✅"); + } +} + + diff --git a/admin/src/main/java/app/module/admin/usecase/household/checkHouseholdNum/ports/application/domain/CheckHouseholdNum.java b/admin/src/main/java/app/module/admin/usecase/household/checkHouseholdNum/ports/application/domain/CheckHouseholdNum.java index 99b4996d..2b6f87c0 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/checkHouseholdNum/ports/application/domain/CheckHouseholdNum.java +++ b/admin/src/main/java/app/module/admin/usecase/household/checkHouseholdNum/ports/application/domain/CheckHouseholdNum.java @@ -10,5 +10,6 @@ import lombok.Setter; @AllArgsConstructor @EqualsAndHashCode public class CheckHouseholdNum { - private Boolean isDuplicated; // 사용여부 + private Boolean isDuplicated; // 사용여부 + private Long householdSeq; // 가구일련번호 } diff --git a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/adapters/persistence/ExcelUploadCreateHouseholdDao.java b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/adapters/persistence/ExcelUploadCreateHouseholdDao.java index f933a7e3..178cdd28 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/adapters/persistence/ExcelUploadCreateHouseholdDao.java +++ b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/adapters/persistence/ExcelUploadCreateHouseholdDao.java @@ -1,5 +1,6 @@ package app.module.admin.usecase.household.excelUploadCreateHousehold.adapters.persistence; +import app.module.admin.config.application.enums.MonthlyInputStatusType; import app.module.admin.config.application.util.AdminUtil; import app.module.admin.usecase.household.checkHouseholdNum.adapters.persistence.CheckHouseholdNumMapper; import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum; @@ -12,12 +13,57 @@ import app.module.admin.usecase.household.excelUploadCreateHousehold.adapters.we import app.module.admin.usecase.household.excelUploadCreateHousehold.adapters.web.model.ExcelUploadContactVO; import app.module.admin.usecase.household.excelUploadCreateHousehold.adapters.web.model.ExcelUploadResultVO; import app.module.admin.usecase.household.excelUploadCreateHousehold.ports.ExcelUploadCreateHouseholdPortOut; +import app.module.admin.usecase.household.monthlyInputStatus.updateMonthlyInputStatus.adapters.persistence.UpdateMonthlyInputStatusMapper; +import app.module.admin.usecase.household.monthlyInputStatus.updateMonthlyInputStatus.ports.application.domain.SaveExcelUploadLogCmd; +import app.module.admin.usecase.household.monthlyInputStatus.updateMonthlyInputStatus.ports.application.domain.UpdateForestProductStatusCmd; +import app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferExpense.adapters.persistence.SaveBankAutoTransferExpenseMapper; +import app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferExpense.ports.application.domain.SaveBankAutoTransferExpenseOutCmd; +import app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferExpense.ports.application.domain.SaveBankAutoTransferExpenseOutExcelCmd; +import app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferIncome.adapters.persistence.SaveBankAutoTransferIncomeMapper; +import app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferIncome.ports.application.domain.SaveBankAutoTransferIncomeOutCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.SaveDailyExpenseMapper; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.SaveDailyExpenseCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.SaveDailyExpenseExcelCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.SaveDailyFarmingMapper; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.SaveDailyFarmingCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.adapters.persistence.SaveDailyForestryMapper; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.ports.application.domain.SaveDailyForestryCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.ports.application.domain.SaveDailyForestryExcelCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.persistence.SaveDailyIncomeMapper; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.ports.application.domain.SaveDailyIncomeCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.ports.application.domain.SaveDailyIncomeExcelCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.adapters.persistence.SaveDailyPowerMapper; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.ports.application.domain.SaveDailyPowerCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.ports.application.domain.SaveDailyPowerExcelCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.adapters.persistence.SaveDailyWorkMapper; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.ports.application.domain.SaveDailyWorkCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.ports.application.domain.SaveDailyWorkExcelCmd; +import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.adapters.persistence.GetForestProductsStatusMapper; +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.GetMonthlyForestProductsStatus; +import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.persistence.SaveForestProductMapper; +import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model.SaveForestProductReqVO; +import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.validator.SaveForestProductValidator; +import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd; +import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductExcelCmd; import app.module.admin.usecase.researcher.adpaters.persistence.ResearcherMapper; +import app.module.core.config.application.enums.DailyInputType; import app.module.core.config.application.logging.SafeLogger; import app.module.core.config.application.util.AuditUtil; +import app.module.core.config.application.util.CommonUtil; +import app.module.core.config.constants.DailyRecordConstants; +import app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto; +import app.module.core.usecase.daily.record.adapters.persistence.DailyRecordMapper; +import app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto; +import app.module.core.usecase.daily.record.ports.application.domain.CreateDailyRecordCmd; +import app.module.core.usecase.daily.record.ports.application.domain.CreateDailyRecordExcelCmd; +import app.module.core.usecase.daily.record.ports.application.domain.UpdateDailyRecordStatusCmd; import app.module.core.usecase.uicode.list.adapters.persistence.UICodeListMapper; import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement; +import app.module.core.usecase.uicode.view.adapters.persistence.UICodeViewMapper; +import app.module.core.usecase.uicode.view.ports.application.domain.UICodeView; import lombok.RequiredArgsConstructor; +import org.apache.commons.collections4.bag.SynchronizedSortedBag; import org.apache.poi.ss.usermodel.*; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -27,8 +73,15 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +import static app.module.core.config.application.enums.DailyStatus.WAITING; +import static app.module.core.config.application.enums.DailyTargetStatus.TARGET; +import static app.module.core.config.application.enums.DailyTargetStatus.TODAY_NONE; +import static java.util.Map.entry; @Repository @RequiredArgsConstructor @@ -43,6 +96,21 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut private final UICodeListMapper uiCodeListMapper; private final BCryptPasswordEncoder passwordEncoder; private final ResearcherMapper researcherMapper; + private final SaveForestProductMapper saveForestProductMapper; + private final UICodeViewMapper uiCodeMapper; + private final GetForestProductsStatusMapper monthlyInputstatusMapper; + private final SaveBankAutoTransferExpenseMapper saveBankAutoTransferExpenseMapper; + private final SaveBankAutoTransferIncomeMapper saveBankAutoTransferIncomeMapper; + private final DailyRecordMapper dailyRecordMapper; + private final SaveDailyIncomeMapper dailyIncomeMapper; + private final SaveDailyExpenseMapper dailyExpenseMapper; + private final SaveDailyWorkMapper dailyWorkMapper; + private final SaveDailyPowerMapper dailyPowerMapper; + private final SaveDailyForestryMapper dailyForestryMapper; + private final SaveDailyFarmingMapper dailyFarmingMapper; + private final UpdateMonthlyInputStatusMapper updateMonthlyInputStatusMapper; + + private final SaveForestProductValidator validator; @Override @Transactional @@ -152,6 +220,694 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut return new ExcelUploadResultVO(sheet.getLastRowNum() , success, errorList); } + @Override + public ExcelUploadResultVO dailyExcelUpload(MultipartFile file) throws IOException { + // 엑셀 파일 읽기 + Workbook workbook = WorkbookFactory.create(file.getInputStream()); + + int success = 0; + int totalRows = 0; // 전체 시트의 행 개수 합산 + String loginUser = CommonUtil.getLoginUsername(); + String originalFileName = file.getOriginalFilename(); + + List errorList = new ArrayList<>(); + int flag = 0; + String month = null; + String householdNum = null; + int sheetNum = 0; + int sheetRow = 0; + int erroeCnt = 0; + + // === 여러 시트 순회 === + //(공통) 단위코드 가져오기 - 코드를 조회하여 map에 매핑 + Map unitCodeMap = getAllCodeMaps("code.record.unit"); + //(공통) 재배형태코드 가져오기 - 코드를 조회하여 map에 매핑 + Map cropCodeMap = getAllCodeMaps("code.record.crop"); + //(공통) 수입의종류 가져오기 - 코드를 조회하여 map에 매핑 + Map bankInMap = getAllCodeTextMaps("code.bank.input"); + //(공통) 지출의종류 가져오기 - 코드를 조회하여 map에 매핑 + Map bankOutMap = getAllCodeTextMaps("code.bank.output"); + //(공통) 생산물 가져오기 - 코드를 조회하여 map에 매핑 + Map farmingMap = getAllCodeTextMaps("code.record.farming"); + //(공통) 작업면적 가져오기 - 코드를 조회하여 map에 매핑 + Map areaMap = getAllCodeTextMaps("code.record.area"); + //(공통) 일계부 작성일자 그룹 가져오기 - 시작일자를 조회하여 map에 매핑 + Map dayGroupMap = getDayGroupMap(); + + try{ + for (int s = 1; s < workbook.getNumberOfSheets(); s++) { + Sheet sheet = workbook.getSheetAt(s); + +// if (s != 2){ +// continue; +// } + if (s == 3){ + continue; + } + sheetNum = s; + // 전체 row 수 합산 (헤더 제외) + totalRows += sheet.getLastRowNum(); + + // 첫 번째 행은 헤더로 간주하고 스킵 + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + Row row = sheet.getRow(i); + if (row == null) continue; + + sheetRow = i+1; + + householdNum = getCellValue(row.getCell(5)).toString(); + month = getCellValue(row.getCell(2)); + + // 등록되어있는 임가번호인지 조회 + CheckHouseholdNum checkHouseholdNum = checkHouseholdNumMapper.checkHouseholdNum( + new CheckHouseholdNumCmd(getCellValue(row.getCell(5)).toString()) + ).orElse(null); + + if (checkHouseholdNum != null) { + //1.임산물 현황 등록 + if (s == 1) { + try { + + // 🔸 (1) 엑셀 컬럼별 기대 타입 정의 + Map requiredTypes = Map.ofEntries( + entry(2, CellType.NUMERIC), // 조사월 + entry(11, CellType.NUMERIC), // 가능면적 + entry(14, CellType.NUMERIC), // 면적 + entry(15, CellType.NUMERIC), // 주생산물 수확량 + entry(16, CellType.STRING), // 주생산물 단위 + entry(17, CellType.NUMERIC), // 주생산물 판매량 + entry(18, CellType.STRING), // 단위.1 + entry(19, CellType.NUMERIC), // 부생산물 수확량 + entry(20, CellType.STRING), // 단위.2 + entry(21, CellType.NUMERIC), // 부생산물 판매량 + entry(22, CellType.STRING) // 단위.3 + ); + + // 🔸 (2) 검증 수행 + for (Map.Entry entry : requiredTypes.entrySet()) { + int colIdx = entry.getKey(); + CellType expected = entry.getValue(); + validateCellType(row.getCell(colIdx), expected, + sheetNum + "번 Sheet의 " + (i + 1) + "행 " + colIdx + "열"); + } + + // 월별 입력 상태 ID 셋팅 + GetForestProductsStatusCmd cmd = new GetForestProductsStatusCmd(checkHouseholdNum.getHouseholdSeq(), month); + GetMonthlyForestProductsStatus monthlyStatus = monthlyInputstatusMapper.getMonthlyStatus(cmd); + + //코드값 매핑 + AbstractMap.SimpleEntry mainYieldUnit = resolveUnit(unitCodeMap, getCellValue(row.getCell(16)), "code.record.unit"); + AbstractMap.SimpleEntry mainSaleUnit = resolveUnit(unitCodeMap, getCellValue(row.getCell(18)), "code.record.unit"); + AbstractMap.SimpleEntry subYieldUnit = resolveUnit(unitCodeMap, getCellValue(row.getCell(20)), "code.record.unit"); + AbstractMap.SimpleEntry subSaleUnit = resolveUnit(unitCodeMap, getCellValue(row.getCell(22)), "code.record.unit"); + + // 임산물 현황 값 셋팅 + SaveForestProductExcelCmd forestProductCmd = new SaveForestProductExcelCmd( + null, + checkHouseholdNum.getHouseholdSeq(), //household_seq-임가일련번호 + monthlyStatus.getId(), //monthly_input_status_id-월별 입력 상태 ID + getCellValue(row.getCell(2)), //month-조사월 + getCellValue(row.getCell(8)), //street_num-지번 + getCellValue(row.getCell(9)), //land_type-지목 + getCellValue(row.getCell(10)), //town-읍면동 + getCellValue(row.getCell(12)), //crop_name-재배 작물명 + getCellValue(row.getCell(13)), //crop_code-재배 작물코드 + getCellValue(row.getCell(14)), //land_area-면적 + getCellValue(row.getCell(11)), //available_area-가능면적(평) + getCellValue(row.getCell(15)), //main_yield-주생산물 수확량 + mainYieldUnit.getKey(), //main_yield_unit_code-단위 + mainYieldUnit.getValue(), //main_yield_unit-주생산물 수확량 직접입력 단위 + getCellValue(row.getCell(17)), //main_sale_amount-주생산물 판매량 + mainSaleUnit.getKey(), //main_sale_unit_code-단위.1 + mainSaleUnit.getValue(), //main_sale_unit-주생산물 판매량 직접입력 단위 + getCellValue(row.getCell(19)), //sub_yield-부생산물 수확량 + subYieldUnit.getKey(), //sub_yield_unit_code-단위.2 + subYieldUnit.getValue(), //sub_yield_unit-부생산물 수확량 직접입력 단위 + getCellValue(row.getCell(21)), //sub_sale-부생산물 판매량 + subSaleUnit.getKey(), //sub_sale_unit_code-단위.3 + subSaleUnit.getValue() //sub_sale_unit_code-부생산물 판매량 직접입력 단위 + ); + + // 임산물 현황(forest_product) 테이블 등록 + saveForestProductMapper.createForestProductExcel(AuditUtil.create(forestProductCmd)); + + // 임산물 현황(forest_product) 테이블 업데이트 + updateMonthlyInputStatusMapper.updateForestProductStatus(AuditUtil.update( + new UpdateForestProductStatusCmd( + monthlyStatus.getId(), + MonthlyInputStatusType.REGISTERED.name()))); + } catch (Exception e) { + // ❗ 예외 발생 시 insert 메소드 호출 + try { + saveExcelUploadLog( updateMonthlyInputStatusMapper, originalFileName, getCellValue(row.getCell(2)), + sheetNum + "번 Sheet(1.임산물 현황 등록)의 " + sheetRow + "번ROW에서 에러 발생", loginUser, e + ); + erroeCnt++; + } catch (Exception logEx) { + // 로그 기록 중 예외가 나더라도 전체 멈추지 않게 처리 + logEx.printStackTrace(); + } + } + } + + //2.자동이체_수입(지출) + if (s == 2) { + try { + // 월별 입력 상태 ID 셋팅 + GetForestProductsStatusCmd cmd = new GetForestProductsStatusCmd(checkHouseholdNum.getHouseholdSeq(), month); + GetMonthlyForestProductsStatus monthlyStatus = monthlyInputstatusMapper.getMonthlyStatus(cmd); + + //코드값 매핑 + AbstractMap.SimpleEntry unitCode = resolveUnit(unitCodeMap, getCellValue(row.getCell(15)), "code.record.unit"); + + // 이체유형 수입 + if ("1".equals(getCellValue(row.getCell(7)).toString())) { + AbstractMap.SimpleEntry bankCode = resolveUnit2(bankInMap, getCellValue(row.getCell(12)), "code.bank.input"); + + // 직접입력일 경우 대상과 수입(지출)의 종류를 합침 + String tmpTransferCategory = ""; + if(bankCode.getKey().equals("code.bank.input.self")){ + tmpTransferCategory = getCellValue(row.getCell(11))+bankCode.getValue(); + } + + SaveBankAutoTransferIncomeOutCmd incomeOutCmd = new SaveBankAutoTransferIncomeOutCmd( + null, + checkHouseholdNum.getHouseholdSeq(), //household_idx-임가일련번호 + month, //month-조사시행 월 + cropCodeMap.get(getCellValue(row.getCell(10))), //crop_code-재배형태코드 + getCellValue(row.getCell(8)), //income_code-수입부호 + getCellValue(row.getCell(9)), //expense_code-지출부호 + bankCode.getKey(), //transfer_category_code-수입(지출)의 종류 + tmpTransferCategory, //transfer_category--수입(지출)의 종류 직접입력 + getCellValue(row.getCell(13)), //source_purpose-수입원(용도) + getCellValue(row.getCell(14)), // count-수량 + unitCode.getKey(), // unit_code-단위 + unitCode.getValue(), // unit-unit_code 직접입력 + Long.parseLong(getCellValue(row.getCell(16)).replaceAll(",", "")), // price-현금(원) + "code.bank.input", // 수입 type code + "1", // 수입 유형 1 고정 + monthlyStatus.getId() != null ? monthlyStatus.getId() : null, + null + ); + // 은행자동이체(수입) 등록 + saveBankAutoTransferIncomeMapper.createBankAutoTransferIncome(AuditUtil.create(incomeOutCmd)); + + // 은행자동이체(수입) 업데이트 + updateMonthlyInputStatusMapper.updateBankInputStatus(AuditUtil.update( + new UpdateForestProductStatusCmd( + monthlyStatus.getId(), + MonthlyInputStatusType.REGISTERED.name()))); + + // 이체유형 지출 + } else { + AbstractMap.SimpleEntry bankCode = resolveUnit2(bankOutMap, getCellValue(row.getCell(12)), "code.bank.output"); + // 직접입력일 경우 대상과 수입(지출)의 종류를 합침 + String tmpTransferCategory = ""; + if(bankCode.getKey().equals("code.bank.output.self")){ + tmpTransferCategory = getCellValue(row.getCell(11))+bankCode.getValue(); + } + + SaveBankAutoTransferExpenseOutExcelCmd expenseInCmd = new SaveBankAutoTransferExpenseOutExcelCmd( + null, + checkHouseholdNum.getHouseholdSeq(), //household_idx-임가일련번호 + month, //month-조사시행 월 + getCellValue(row.getCell(9)), //expense_code-지출부호 + bankCode.getKey(), //transfer_category_code-수입(지출)의 종류 + tmpTransferCategory, //inCmd.getTransferCategory(), + getCellValue(row.getCell(13)), //source_purpose-수입원(용도) + getCellValue(row.getCell(14)), // count-수량 + unitCode.getKey(), // unit_code-단위 + unitCode.getValue(), // unit-unit_code 직접입력 + Long.parseLong(getCellValue(row.getCell(16)).replaceAll(",", "")), // price-현금(원) + "code.bank.output", // 지출 type code + "2", // 지출 유형 2 고정 + monthlyStatus.getId() != null ? monthlyStatus.getId() : null, + null, + cropCodeMap.get(getCellValue(row.getCell(10))) //crop_code-재배형태코드 + ); + // 은행자동이체(지출) 등록 + saveBankAutoTransferExpenseMapper.createBankAutoTransferExpenseExcel(AuditUtil.create(expenseInCmd)); + + // 은행자동이체(지출) 업데이트 + updateMonthlyInputStatusMapper.updateBankOutputStatus(AuditUtil.update( + new UpdateForestProductStatusCmd( + monthlyStatus.getId(), + MonthlyInputStatusType.REGISTERED.name()))); + } + } catch (Exception e) { + // ❗ 예외 발생 시 insert 메소드 호출 + try { + saveExcelUploadLog( updateMonthlyInputStatusMapper, originalFileName, getCellValue(row.getCell(2)), + sheetNum + "번 Sheet(2.자동이체_수입(지출))의 " + sheetRow + "번ROW에서 에러 발생", loginUser, e + ); + erroeCnt++; + } catch (Exception logEx) { + // 로그 기록 중 예외가 나더라도 전체 멈추지 않게 처리 + logEx.printStackTrace(); + } + } + } + + //4.수입(지출) + if (s == 4) { + try { + // 🔸 (1) 엑셀 컬럼별 기대 타입 정의 + Map requiredTypes = Map.ofEntries( + entry(7, CellType.NUMERIC), // 날 + entry(8, CellType.NUMERIC), // 짜 + entry(9, CellType.NUMERIC), // 유형 + entry(15, CellType.NUMERIC), // 수량 + entry(16, CellType.STRING), // 단위 + entry(17, CellType.NUMERIC), // 현금(원) + entry(18, CellType.NUMERIC) // 현물(평가액) + ); + + // 🔸 (2) 검증 수행 + for (Map.Entry entry : requiredTypes.entrySet()) { + int colIdx = entry.getKey(); + CellType expected = entry.getValue(); + validateCellType(row.getCell(colIdx), expected, + sheetNum + "번 Sheet의 " + (i + 1) + "행 " + colIdx + "열"); + } + + //'날' null check + requireCellValue(row.getCell(7), 7, sheetRow); + + //daily_record(일계부 일별 작성상태) 등록 + Long dailyRecordSeq = createDailyRecordFromExcel(month, checkHouseholdNum.getHouseholdSeq(), getCellValue(row.getCell(7)), getCellValue(row.getCell(8))); + + //코드값 매핑 + AbstractMap.SimpleEntry unitCode = resolveUnit(unitCodeMap, getCellValue(row.getCell(16)), "code.record.unit"); + + //수입인 경우 + if ("1".equals(getCellValue(row.getCell(9)).toString())) { + String value11 = getCellValue(row.getCell(11)); + boolean credit = DailyRecordConstants.INCOME_EXPENSE_MARK.equals(value11); + + SaveDailyIncomeExcelCmd dailyIncomeCmd = new SaveDailyIncomeExcelCmd( + null, + dailyRecordSeq, + DailyInputType.OCR, + DailyRecordConstants.INCOME_CATEGORY, + getCellValue(row.getCell(11)), + credit, + cropCodeMap.get(getCellValue(row.getCell(12))), + getCellValue(row.getCell(13)), + getCellValue(row.getCell(14)), + toNumberOrNull(getCellValue(row.getCell(15)), Double.class), + unitCode.getKey(), + unitCode.getValue(), + toNumberOrNull(getCellValue(row.getCell(17)), Long.class), + toNumberOrNull(getCellValue(row.getCell(18)), Long.class), + getCellValue(row.getCell(10))); + //수입내역 등록 + dailyIncomeMapper.createDailyIncomeExcel(AuditUtil.create(dailyIncomeCmd)); + + //daily_record 테이블 업데이트 + UpdateDailyRecordStatusCmd command = AuditUtil.update( + new UpdateDailyRecordStatusCmd( + null, + Integer.parseInt(String.valueOf(dailyRecordSeq)), + null, + "DONE", + "INCOME", + "TARGET" + ) + ); + dailyRecordMapper.updateDailyRecordStatusExcel(command); + //지출인 경우 + } else { + String value10 = getCellValue(row.getCell(10)); + boolean credit = DailyRecordConstants.EXPENSE_INCOME_MARK.equals(value10); + + SaveDailyExpenseExcelCmd dailyExpenseCmd = new SaveDailyExpenseExcelCmd( + null, + dailyRecordSeq, + DailyInputType.OCR, + DailyRecordConstants.EXPENSE_CATEGORY, + getCellValue(row.getCell(10)), + credit, + getCellValue(row.getCell(13)), + getCellValue(row.getCell(14)), + toNumberOrNull(getCellValue(row.getCell(15)), Double.class), + unitCode.getKey(), + unitCode.getValue(), + toNumberOrNull(getCellValue(row.getCell(17)), Long.class), + toNumberOrNull(getCellValue(row.getCell(18)), Long.class), + getCellValue(row.getCell(11))); + //지출내역 등록 + dailyExpenseMapper.createDailyExpenseExcel(AuditUtil.create(dailyExpenseCmd)); + + //daily_record 테이블 업데이트 + UpdateDailyRecordStatusCmd command = AuditUtil.update( + new UpdateDailyRecordStatusCmd( + null, + Integer.parseInt(String.valueOf(dailyRecordSeq)), + null, + "DONE", + "EXPENSE", + "TARGET" + ) + ); + dailyRecordMapper.updateDailyRecordStatusExcel(command); + } + } catch (Exception e) { + // ❗ 예외 발생 시 insert 메소드 호출 + try { + saveExcelUploadLog( updateMonthlyInputStatusMapper, originalFileName, getCellValue(row.getCell(2)), + sheetNum + "번 Sheet(4.수입(지출))의 " + sheetRow + "번ROW에서 에러 발생", loginUser, e + ); + erroeCnt++; + } catch (Exception logEx) { + // 로그 기록 중 예외가 나더라도 전체 멈추지 않게 처리 + logEx.printStackTrace(); + } + } + } + + //5.임업노동 투입내역 + if (s == 5) { + try { + + // 🔸 (1) 엑셀 컬럼별 기대 타입 정의 + Map requiredTypes = Map.ofEntries( + entry(7, CellType.NUMERIC), // 날 + entry(8, CellType.NUMERIC), // 짜 + entry(15, CellType.NUMERIC), // 수확량 + entry(16, CellType.STRING), // 단위 + entry(18, CellType.NUMERIC), // 노동투입시간 경영주 + entry(19, CellType.NUMERIC) // 노동투입시간 배우자 + ); + + // 🔸 (2) 검증 수행 + for (Map.Entry entry : requiredTypes.entrySet()) { + int colIdx = entry.getKey(); + CellType expected = entry.getValue(); + validateCellType(row.getCell(colIdx), expected, + sheetNum + "번 Sheet의 " + (i + 1) + "행 " + colIdx + "열"); + } + + //'날' null check + requireCellValue(row.getCell(7), 7, sheetRow); + //daily_record(일계부 일별 작성상태) 등록 + Long dailyRecordSeq = createDailyRecordFromExcel(getCellValue(row.getCell(2)), checkHouseholdNum.getHouseholdSeq(), getCellValue(row.getCell(7)), getCellValue(row.getCell(8))); + + //코드값 매핑 + AbstractMap.SimpleEntry unitCode = resolveUnit(unitCodeMap, getCellValue(row.getCell(16)), "code.record.unit"); + AbstractMap.SimpleEntry areaCode = resolveUnit(areaMap, getCellValue(row.getCell(14)), "code.record.area"); + + // 작업면적이 직접입력일 경우 area_unit_code 항목에는 null값 들어가도록 처리 + String areaUnitCode = ""; + if(!"code.record.area.self".equals(areaCode.getKey())){ + areaUnitCode = areaCode.getKey(); + } + + SaveDailyWorkExcelCmd dailyWorkCmd = new SaveDailyWorkExcelCmd( + null, + dailyRecordSeq, + getCellValue(row.getCell(9)), //formVO.getItemName(), + getCellValue(row.getCell(10)), //formVO.getItemMark(), + getCellValue(row.getCell(11)), //formVO.getWorkName(), + getCellValue(row.getCell(12)), //formVO.getWorkMark(), + toNumberOrNull(getCellValue(row.getCell(13)), Double.class), //formVO.getWorkLandArea(), + areaUnitCode, //formVO.getAreaUnitCode(), + areaCode.getValue(), //formVO.getAreaUnitSelf(), + toNumberOrNull(getCellValue(row.getCell(15)), Double.class), //formVO.getHarvestQuantity(), + unitCode.getKey(), //formVO.getHarvestUnitCode(), + unitCode.getValue(), //formVO.getHarvestUnitSelf(), + toNumberOrNull(getCellValue(row.getCell(18)), Double.class), //formVO.getOwnerTime(), + toNumberOrNull(getCellValue(row.getCell(19)), Double.class), //formVO.getSpouseTime(), + toNumberOrNull(getCellValue(row.getCell(20)), Double.class), //formVO.getFamilyMHours(), + toNumberOrNull(getCellValue(row.getCell(21)), Double.class), //formVO.getFamilyFHours(), + toNumberOrNull(getCellValue(row.getCell(22)), Double.class), //formVO.getHiredMHours(), + toNumberOrNull(getCellValue(row.getCell(23)), Double.class), //formVO.getHiredFHours(), + toNumberOrNull(getCellValue(row.getCell(24)), Double.class), //formVO.getSharedMHours(), + toNumberOrNull(getCellValue(row.getCell(25)), Double.class), //formVO.getSharedFHours(), + toNumberOrNull(getCellValue(row.getCell(26)), Double.class), //formVO.getVolunteerMHours(), + toNumberOrNull(getCellValue(row.getCell(27)), Double.class)); //formVO.getVolunteerFHours()); + + //임업노동 투입내역 등록 + dailyWorkMapper.createDailyWorkExcel(AuditUtil.create(dailyWorkCmd)); + + //daily_record 테이블 업데이트 + UpdateDailyRecordStatusCmd command = AuditUtil.update( + new UpdateDailyRecordStatusCmd( + null, + Integer.parseInt(String.valueOf(dailyRecordSeq)), + null, + "DONE", + "WORK", + "TARGET" + ) + ); + dailyRecordMapper.updateDailyRecordStatusExcel(command); + } catch (Exception e) { + // ❗ 예외 발생 시 insert 메소드 호출 + try { + saveExcelUploadLog( updateMonthlyInputStatusMapper, originalFileName, getCellValue(row.getCell(2)), + sheetNum + "번 Sheet(5.임업노동 투입내역)의 " + sheetRow + "번ROW에서 에러 발생", loginUser, e + ); + erroeCnt++; + } catch (Exception logEx) { + // 로그 기록 중 예외가 나더라도 전체 멈추지 않게 처리 + logEx.printStackTrace(); + } + } + } + //6.동력사용시간 + if (s == 6) { + try { + + // 🔸 (1) 엑셀 컬럼별 기대 타입 정의 + Map requiredTypes = Map.ofEntries( + entry(7, CellType.NUMERIC), // 날 + entry(8, CellType.NUMERIC), // 짜 + entry(11, CellType.NUMERIC), // 자가시간 + entry(12, CellType.NUMERIC) // 임차시간 + ); + + // 🔸 (2) 검증 수행 + for (Map.Entry entry : requiredTypes.entrySet()) { + int colIdx = entry.getKey(); + CellType expected = entry.getValue(); + validateCellType(row.getCell(colIdx), expected, + sheetNum + "번 Sheet의 " + (i + 1) + "행 " + colIdx + "열"); + } + + //'날' null check + requireCellValue(row.getCell(7), 7, sheetRow); + //daily_record(일계부 일별 작성상태) 등록 + Long dailyRecordSeq = createDailyRecordFromExcel(month, checkHouseholdNum.getHouseholdSeq(), getCellValue(row.getCell(7)), getCellValue(row.getCell(8))); + + SaveDailyPowerExcelCmd dailyPowerCmd = new SaveDailyPowerExcelCmd( + null, + dailyRecordSeq, + getCellValue(row.getCell(9)), //formVO.getEquipmentName(), + getCellValue(row.getCell(10)), //formVO.getEquipmentMark(), + toNumberOrNull(getCellValue(row.getCell(11)), Double.class), //formVO.getOwnedHours(), + toNumberOrNull(getCellValue(row.getCell(12)), Double.class)); //formVO.getLeasedHours() + + //동력 사용시간 등록 + dailyPowerMapper.createDailyPowerExcel(AuditUtil.create(dailyPowerCmd)); + + //daily_record 테이블 업데이트 + UpdateDailyRecordStatusCmd command = AuditUtil.update( + new UpdateDailyRecordStatusCmd( + null, + Integer.parseInt(String.valueOf(dailyRecordSeq)), + null, + "DONE", + "POWER", + "TARGET" + ) + ); + dailyRecordMapper.updateDailyRecordStatusExcel(command); + } catch (Exception e) { + // ❗ 예외 발생 시 insert 메소드 호출 + try { + saveExcelUploadLog( updateMonthlyInputStatusMapper, originalFileName, getCellValue(row.getCell(2)), + sheetNum + "번 Sheet(6.동력사용시간)의 " + sheetRow + "번ROW에서 에러 발생", loginUser, e + ); + erroeCnt++; + } catch (Exception logEx) { + // 로그 기록 중 예외가 나더라도 전체 멈추지 않게 처리 + logEx.printStackTrace(); + } + } + } + + //7.자가임업생산물 중 자가소비량 + if (s == 7) { + try { + // 🔸 (1) 엑셀 컬럼별 기대 타입 정의 + Map requiredTypes = Map.ofEntries( + entry(7, CellType.NUMERIC), // 날 + entry(8, CellType.NUMERIC), // 짜 + entry(13, CellType.NUMERIC), // 수량 + entry(14, CellType.STRING), // 단위 + entry(15, CellType.NUMERIC) // 현물(평가액) + ); + + // 🔸 (2) 검증 수행 + for (Map.Entry entry : requiredTypes.entrySet()) { + int colIdx = entry.getKey(); + CellType expected = entry.getValue(); + validateCellType(row.getCell(colIdx), expected, + sheetNum + "번 Sheet의 " + (i + 1) + "행 " + colIdx + "열"); + } + + //'날' null check + requireCellValue(row.getCell(7), 7, sheetRow); + //daily_record(일계부 일별 작성상태) 등록 + Long dailyRecordSeq = createDailyRecordFromExcel(month, checkHouseholdNum.getHouseholdSeq(), getCellValue(row.getCell(7)), getCellValue(row.getCell(8))); + + //코드값 매핑 + AbstractMap.SimpleEntry unitCode = resolveUnit(unitCodeMap, getCellValue(row.getCell(14)), "code.record.unit"); + + SaveDailyForestryExcelCmd dailyForestryCmd = new SaveDailyForestryExcelCmd( + null, + dailyRecordSeq, + getCellValue(row.getCell(9)), //incomeMark + DailyRecordConstants.FORESTRY_EXPENSE_MARK, //expenseMark + getCellValue(row.getCell(11)), //formVO.getProductName(), + getCellValue(row.getCell(12)), //formVO.getUsage(), + toNumberOrNull(getCellValue(row.getCell(13)), Double.class), //formVO.getQuantity(), + unitCode.getKey(), //formVO.getUnitCode(), + unitCode.getValue(), //.getUnitSelf(), + toNumberOrNull(getCellValue(row.getCell(15)), Long.class)); //formVO.getEstimatedValue()); + + // 자가임업생산물 중 자가소비량 등록 + dailyForestryMapper.createDailyForestryExcel(AuditUtil.create(dailyForestryCmd)); + + //daily_record 테이블 업데이트 + UpdateDailyRecordStatusCmd command = AuditUtil.update( + new UpdateDailyRecordStatusCmd( + null, + Integer.parseInt(String.valueOf(dailyRecordSeq)), + null, + "DONE", + "FORESTRY", + "TARGET" + ) + ); + dailyRecordMapper.updateDailyRecordStatusExcel(command); + } catch (Exception e) { + // ❗ 예외 발생 시 insert 메소드 호출 + try { + saveExcelUploadLog( updateMonthlyInputStatusMapper, originalFileName, getCellValue(row.getCell(2)), + sheetNum + "번 Sheet(7.자가임업생산물 중 자가소비량)의 " + sheetRow + "번ROW에서 에러 발생", loginUser, e + ); + erroeCnt++; + } catch (Exception logEx) { + // 로그 기록 중 예외가 나더라도 전체 멈추지 않게 처리 + logEx.printStackTrace(); + } + } + } + + //8.자가농업생산물 중 자가소비량 + if (s == 8) { + try { + + // 🔸 (1) 엑셀 컬럼별 기대 타입 정의 + Map requiredTypes = Map.ofEntries( + entry(7, CellType.NUMERIC), // 날 + entry(13, CellType.NUMERIC), // 수량 + entry(14, CellType.STRING), // 단위 + entry(15, CellType.NUMERIC) // 현물(평가액) + ); + + // 🔸 (2) 검증 수행 + for (Map.Entry entry : requiredTypes.entrySet()) { + int colIdx = entry.getKey(); + CellType expected = entry.getValue(); + validateCellType(row.getCell(colIdx), expected, + sheetNum + "번 Sheet의 " + (i + 1) + "행 " + colIdx + "열"); + } + + //'날' null check + requireCellValue(row.getCell(7), 7, sheetRow); + //daily_record(일계부 일별 작성상태) 등록 + + //날짜 컬럼이 없고 차수 컬럼이 존재 차수에 따라 날짜 데이터 셋팅 + String tmpDegree = getCellValue(row.getCell(7)); + String tmpExcelStartDate = null; + String tmpExcelEndDate = null; + if ("1".equals(tmpDegree)) { + tmpExcelStartDate = "7"; + tmpExcelEndDate = "7"; + } else if ("2".equals(tmpDegree)) { + tmpExcelStartDate = "14"; + tmpExcelEndDate = "14"; + } else if ("3".equals(tmpDegree)) { + tmpExcelStartDate = "21"; + tmpExcelEndDate = "21"; + } else if ("4".equals(tmpDegree)) { + tmpExcelStartDate = "30"; + tmpExcelEndDate = "31"; + } + + Long dailyRecordSeq = createDailyRecordFromExcel(month, checkHouseholdNum.getHouseholdSeq(), tmpExcelStartDate, tmpExcelEndDate); + + //코드값 매핑 + AbstractMap.SimpleEntry unitCode = resolveUnit(unitCodeMap, getCellValue(row.getCell(14)), "code.record.unit"); + AbstractMap.SimpleEntry farmingCode = resolveUnit(farmingMap, getCellValue(row.getCell(10)), "code.record.farming"); + + SaveDailyFarmingCmd dailyFarmingCmd = new SaveDailyFarmingCmd( + null, + dailyRecordSeq, + getCellValue(row.getCell(8)), //markMap.get("incomeMark"), + getCellValue(row.getCell(9)), //markMap.get("expenseMark"), + farmingCode.getKey(), //formVO.getProductCode(), + farmingCode.getValue(), //formVO.getProductSelf(), + getCellValue(row.getCell(12)), //formVO.getUsage(), + toNumberOrNull(getCellValue(row.getCell(13)), Double.class), //formVO.getQuantity(), + unitCode.getKey(), //formVO.getUnitCode(), + unitCode.getValue(), //formVO.getUnitSelf(), + toNumberOrNull(getCellValue(row.getCell(15)).replaceAll(",", ""), Long.class)); //formVO.getEstimatedValue()); + + // 자가농업생산물 중 자가소비량 등록 + dailyFarmingMapper.createDailyFarming(AuditUtil.create(dailyFarmingCmd)); + + //daily_record 테이블 업데이트 + UpdateDailyRecordStatusCmd command = AuditUtil.update( + new UpdateDailyRecordStatusCmd( + null, + Integer.parseInt(String.valueOf(dailyRecordSeq)), + null, + "DONE", + "FARMING", + "TARGET" + ) + ); + dailyRecordMapper.updateDailyRecordStatusExcel(command); + } catch (Exception e) { + // ❗ 예외 발생 시 insert 메소드 호출 + try { + saveExcelUploadLog( updateMonthlyInputStatusMapper, originalFileName, getCellValue(row.getCell(2)), + sheetNum + "번 Sheet(8.자가농업생산물 중 자가소비량)의 " + sheetRow + "번ROW에서 에러 발생", loginUser, e + ); + erroeCnt++; + } catch (Exception logEx) { + // 로그 기록 중 예외가 나더라도 전체 멈추지 않게 처리 + logEx.printStackTrace(); + } + } + } + } else { + throw new IllegalArgumentException(sheetNum + "번 Sheet의 임가번호(" + householdNum + ")는 없습니다.\n임가를 먼저 등록해주세요."); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + throw new IllegalArgumentException(sheetNum + "번 Sheet의 " + sheetRow + "번ROW 에러 발생"); + } + workbook.close(); + // 전체 시트 row 수와 성공 건수 리턴 + return new ExcelUploadResultVO(totalRows, erroeCnt, errorList); + } + // 셀 값을 문자열로 변환 private String getCellValue(Cell cell) { if (cell == null) return ""; @@ -270,4 +1026,226 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut household.getRegionDetailCode() != null && !household.getRegionDetailCode().isEmpty() && household.getAddress() != null && !household.getAddress().isEmpty(); } + + public Map getAllCodeMaps(String parentId) { + try { + List codeList = uiCodeMapper.findAllCodes(parentId); + return codeList == null ? Collections.emptyMap() : + codeList.stream() + .collect(Collectors.toMap( + UICodeView::getCodeValue, + UICodeView::getId, + (v1, v2) -> v1 + )); + } catch (Exception e) { + System.err.println("🔥 [getAllCodeMaps] Error while loading codes for parentId = " + parentId); + return Collections.emptyMap(); // 실패 시 빈 맵 반환 (NPE 방지) + } + } + + public Map getAllCodeTextMaps(String parentId) { + try { + List codeList = uiCodeMapper.findAllCodeTexts(parentId); + return codeList == null ? Collections.emptyMap() : + codeList.stream() + .collect(Collectors.toMap( + UICodeView::getCodeText, + UICodeView::getId, + (v1, v2) -> v1 + )); + } catch (Exception e) { + System.err.println("🔥 [getAllCodeMaps] Error while loading codes for parentId = " + parentId); + return Collections.emptyMap(); // 실패 시 빈 맵 반환 (NPE 방지) + } + } + + public Map getDayGroupMap() { + try { + List groupList = dailyRecordMapper.getDailyDayGroup(); + return groupList == null ? Collections.emptyMap() : + groupList.stream() + .collect(Collectors.toMap( + dto -> String.valueOf(dto.getStartDay()), + dto -> String.valueOf(dto.getGroupNo()) + )); + } catch (Exception e) { + System.err.println("🔥 [getDayGroupMap] Error while loading daily_day_group: " + e.getMessage()); + return Collections.emptyMap(); + } + } + + public Long createDailyRecordFromExcel(String month, Long checkHouseholdNum, String excelStartDate, String excelEndDate) { + + if("7".equals(excelStartDate)){ + excelEndDate = "7"; + }else if("14".equals(excelStartDate)){ + excelEndDate = "14"; + }else if("21".equals(excelStartDate)){ + excelEndDate = "21"; + } + + // DTO 생성 + CreateDailyRecordExcelCmd dailyRecordCmd = new CreateDailyRecordExcelCmd( + null, // id (신규이므로 null) + month, + 0, // dayGroupNo — 필요시 수정 + checkHouseholdNum, + null, + null, + WAITING, + TODAY_NONE, TODAY_NONE, TODAY_NONE, TODAY_NONE, TODAY_NONE, TODAY_NONE, + excelStartDate, // excelStartDate + excelEndDate // excelEndDate + ); + + // 생성자 / 수정자 등의 감사 필드 세팅 + dailyRecordCmd = AuditUtil.create(dailyRecordCmd); + // Mapper 호출 → id 반환 + Long dailyRecordSeq = dailyRecordMapper.createDailyRecordExcel(dailyRecordCmd); + + return dailyRecordSeq; + } + + @SuppressWarnings("unchecked") + private T toNumberOrNull(String cellValue, Class type) { + if (cellValue == null || cellValue.trim().isEmpty()) { + return null; + } + + try { + String trimmed = cellValue.trim(); + if (type == Double.class) { + return (T) Double.valueOf(trimmed); + } else if (type == Long.class) { + return (T) Long.valueOf(trimmed); + } else if (type == Integer.class) { + return (T) Integer.valueOf(trimmed); + } else if (type == Float.class) { + return (T) Float.valueOf(trimmed); + } else { + throw new IllegalArgumentException("지원하지 않는 타입입니다: " + type.getSimpleName()); + } + } catch (NumberFormatException e) { + return null; + } + } + + // 공통 유닛 처리 메서드 + private AbstractMap.SimpleEntry resolveUnit( + Map unitMap, + String cellValue, + String parentId + ) { + // 1️⃣ cellValue가 null이면 (null, null) 반환 + if ("".equals(cellValue)) { + return new AbstractMap.SimpleEntry<>(null, null); + } + + // 2️⃣ unitMap에서 코드 조회 + String code = unitMap.get(cellValue); + + // 3️⃣ 코드가 없으면 parentId.self로 처리 + if (code == null) { + return new AbstractMap.SimpleEntry<>(parentId + ".self", cellValue); + } + + // 4️⃣ 정상 매핑된 경우 + return new AbstractMap.SimpleEntry<>(code, null); + } + + private AbstractMap.SimpleEntry resolveUnit2( + Map unitMap, + String cellValue, + String parentId + ) { + // 1️⃣ cellValue가 null이면 (null, null) 반환 + if (cellValue == null || "".equals(cellValue)) { + return new AbstractMap.SimpleEntry<>(parentId + ".self", cellValue); + } + + // 2️⃣ unitMap에서 값으로 키를 찾는 방법 + String code = null; + for (Map.Entry entry : unitMap.entrySet()) { + if (entry.getKey().equals(cellValue)) { + code = entry.getValue(); // 값이 일치하는 키를 가져옴 + break; + } + } + + // 3️⃣ 코드가 없으면 parentId.self로 처리 + if (code == null) { + return new AbstractMap.SimpleEntry<>(parentId + ".self", cellValue); + } + + // 4️⃣ 정상 매핑된 경우 + return new AbstractMap.SimpleEntry<>(code, cellValue); + } + + /** + * 엑셀 업로드 중 발생한 에러 로그를 DB에 저장하는 공통 메소드 + * + * @param mapper Mapper 객체 + * @param fileName 업로드된 엑셀 파일명 + * @param month 등록월 + * @param errorMessage 오류 메시지 + * @param createdBy 작성자 (로그인 사용자 ID) + * @return true: 성공, false: 실패 + */ + public static boolean saveExcelUploadLog( + UpdateMonthlyInputStatusMapper mapper, + String fileName, + String month, + String errorMessage, + String createdBy, + Exception exception + ) { + try { + String errorDetail = exception.toString(); + mapper.createExcelUploadLog( + AuditUtil.update( + new SaveExcelUploadLogCmd(fileName, month, errorMessage, errorDetail, createdBy) + ) + ); + return true; + } catch (Exception e) { + return false; + } + } + + // 💡 셀 값 검증용 메소드 + private String requireCellValue(Cell cell, int columnIndex, int sheetRow) { + String value = getCellValue(cell); + if (value == null || value.isBlank()) { + // 예외를 던지면 호출한 곳의 catch 블록으로 전파됨 + throw new IllegalArgumentException(sheetRow + "행의 " + columnIndex + "번 셀 값이 비어 있습니다."); + } + return value; + } + + // Cell 타입검증 + private void validateCellType(Cell cell, CellType expectedType, String cellDescription) { + if (cell == null) { + return; // 비어 있는 셀은 통과 (필요시 예외로 바꿀 수 있음) + } + + // 셀의 값을 문자열로 통일해서 가져오기 + String value = getCellValue(cell).trim(); + + // 완전히 빈칸이면 통과 + if (value.isEmpty()) { + return; + } + + boolean isNumericValue = value.matches("^-?\\d*(\\.\\d+)?$"); // 숫자 또는 소수 + + // 기대 타입이 숫자인데 값이 숫자가 아닐 경우 + if (expectedType == CellType.NUMERIC && !isNumericValue) { + throw new IllegalArgumentException(cellDescription + " 은(는) 숫자여야 합니다. 현재 값: " + value); + } + + // 기대 타입이 문자열인데 값이 숫자로만 구성된 경우 + if (expectedType == CellType.STRING && isNumericValue) { + throw new IllegalArgumentException(cellDescription + " 은(는) 문자열이어야 합니다. 현재 값: " + value); + } + } } \ No newline at end of file diff --git a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/adapters/web/ExcelUploadCreateHouseholdController.java b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/adapters/web/ExcelUploadCreateHouseholdController.java index 0f12d483..7d4b10b0 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/adapters/web/ExcelUploadCreateHouseholdController.java +++ b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/adapters/web/ExcelUploadCreateHouseholdController.java @@ -17,6 +17,7 @@ class ExcelUploadCreateHouseholdController { private final ExcelUploadCreateHouseholdPortIn excelUploadCreateHouseholdPortIn; + // 임가현황 > 엑셀 업로드 @PostMapping(path = "/api/household/excelUpload") ResponseEntity operate(@RequestParam("file") MultipartFile file ) throws IOException { try { @@ -29,4 +30,18 @@ class ExcelUploadCreateHouseholdController { .body("잘못된 데이터 형식입니다: " + e.getMessage()); } } + + // 임가현황 > 엑셀 업로드(일계부) + @PostMapping(path = "/api/household/dailyExcelUpload") + ResponseEntity dailyExcelUpload(@RequestParam("file") MultipartFile file ) throws IOException { + try { + return ResponseEntity.status(HttpStatus.OK).body(excelUploadCreateHouseholdPortIn.dailyExcelUpload(file)); + } catch (IOException e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body("엑셀 파일 처리 중 오류가 발생했습니다: " + e.getMessage()); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(e.getMessage()); + } + } } \ No newline at end of file diff --git a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/ExcelUploadCreateHouseholdPortIn.java b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/ExcelUploadCreateHouseholdPortIn.java index 5931e9c8..45a1540c 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/ExcelUploadCreateHouseholdPortIn.java +++ b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/ExcelUploadCreateHouseholdPortIn.java @@ -7,4 +7,5 @@ import java.io.IOException; public interface ExcelUploadCreateHouseholdPortIn { ExcelUploadResultVO operate(MultipartFile file) throws IOException; + ExcelUploadResultVO dailyExcelUpload(MultipartFile file) throws IOException; } \ No newline at end of file diff --git a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/ExcelUploadCreateHouseholdPortOut.java b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/ExcelUploadCreateHouseholdPortOut.java index 7f68e860..7bd4b2fe 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/ExcelUploadCreateHouseholdPortOut.java +++ b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/ExcelUploadCreateHouseholdPortOut.java @@ -6,5 +6,6 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; public interface ExcelUploadCreateHouseholdPortOut { - ExcelUploadResultVO operate(MultipartFile file) throws IOException; + ExcelUploadResultVO operate(MultipartFile file) throws IOException; + ExcelUploadResultVO dailyExcelUpload(MultipartFile file) throws IOException; } \ No newline at end of file diff --git a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/application/ExcelUploadCreateHouseholdService.java b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/application/ExcelUploadCreateHouseholdService.java index c2bf4f81..333eb43b 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/application/ExcelUploadCreateHouseholdService.java +++ b/admin/src/main/java/app/module/admin/usecase/household/excelUploadCreateHousehold/ports/application/ExcelUploadCreateHouseholdService.java @@ -14,8 +14,13 @@ import java.io.IOException; class ExcelUploadCreateHouseholdService implements ExcelUploadCreateHouseholdPortIn { private final ExcelUploadCreateHouseholdPortOut portOut; - @Override - public ExcelUploadResultVO operate(MultipartFile file) throws IOException { - return portOut.operate(file); - } + @Override + public ExcelUploadResultVO operate(MultipartFile file) throws IOException { + return portOut.operate(file); + } + + @Override + public ExcelUploadResultVO dailyExcelUpload(MultipartFile file) throws IOException { + return portOut.dailyExcelUpload(file); + } } \ No newline at end of file diff --git a/admin/src/main/java/app/module/admin/usecase/household/getHouseholdStatusUI/adapters/web/GetHouseholdStatusUIController.java b/admin/src/main/java/app/module/admin/usecase/household/getHouseholdStatusUI/adapters/web/GetHouseholdStatusUIController.java index 228ffe7c..d6b225a0 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/getHouseholdStatusUI/adapters/web/GetHouseholdStatusUIController.java +++ b/admin/src/main/java/app/module/admin/usecase/household/getHouseholdStatusUI/adapters/web/GetHouseholdStatusUIController.java @@ -5,6 +5,7 @@ import app.module.admin.config.application.util.DateUiUtil; import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn; import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd; import app.module.admin.usecase.household.getHouseholdStatusUI.adapters.web.model.GetHouseholdStatusUIReqVO; +import app.module.core.config.constants.DailyRecordConstants; import app.module.core.usecase.uicode.list.ports.UICodeListPortIn; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Controller; @@ -14,6 +15,8 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; +import java.time.LocalDate; +import java.util.stream.IntStream; @Controller @RequiredArgsConstructor class GetHouseholdStatusUIController { @@ -45,7 +48,12 @@ class GetHouseholdStatusUIController { // 임가 상세 정보 model.addAttribute("householdInfo", getHouseholdStatusPortIn.operate(new GetHouseholdStatusCmd(seq)).orElse(null)); - + //입력 수정 가능 년도 + int currentYear = LocalDate.now().getYear(); + model.addAttribute("targetYear", IntStream.rangeClosed(DailyRecordConstants.START_YEAR, currentYear).boxed().toList()); + model.addAttribute("startYear", DailyRecordConstants.START_YEAR); + model.addAttribute("startMonth", DailyRecordConstants.START_MONTH_OF_START_YEAR); + model.addAttribute("currentDate", LocalDate.now()); return "households/{seq}"; } } \ No newline at end of file diff --git a/admin/src/main/java/app/module/admin/usecase/household/monthlyInputStatus/updateMonthlyInputStatus/adapters/persistence/UpdateMonthlyInputStatusMapper.java b/admin/src/main/java/app/module/admin/usecase/household/monthlyInputStatus/updateMonthlyInputStatus/adapters/persistence/UpdateMonthlyInputStatusMapper.java index 47990c58..661aa34d 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/monthlyInputStatus/updateMonthlyInputStatus/adapters/persistence/UpdateMonthlyInputStatusMapper.java +++ b/admin/src/main/java/app/module/admin/usecase/household/monthlyInputStatus/updateMonthlyInputStatus/adapters/persistence/UpdateMonthlyInputStatusMapper.java @@ -1,5 +1,6 @@ package app.module.admin.usecase.household.monthlyInputStatus.updateMonthlyInputStatus.adapters.persistence; +import app.module.admin.usecase.household.monthlyInputStatus.updateMonthlyInputStatus.ports.application.domain.SaveExcelUploadLogCmd; import app.module.admin.usecase.household.monthlyInputStatus.updateMonthlyInputStatus.ports.application.domain.UpdateForestProductStatusCmd; import org.apache.ibatis.annotations.Mapper; @@ -8,4 +9,5 @@ public interface UpdateMonthlyInputStatusMapper { void updateForestProductStatus(UpdateForestProductStatusCmd cmd); void updateBankInputStatus(UpdateForestProductStatusCmd cmd); void updateBankOutputStatus(UpdateForestProductStatusCmd cmd); + void createExcelUploadLog(SaveExcelUploadLogCmd cmd); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/monthlyInputStatus/updateMonthlyInputStatus/ports/application/domain/SaveExcelUploadLogCmd.java b/admin/src/main/java/app/module/admin/usecase/household/monthlyInputStatus/updateMonthlyInputStatus/ports/application/domain/SaveExcelUploadLogCmd.java new file mode 100644 index 00000000..1a0814bc --- /dev/null +++ b/admin/src/main/java/app/module/admin/usecase/household/monthlyInputStatus/updateMonthlyInputStatus/ports/application/domain/SaveExcelUploadLogCmd.java @@ -0,0 +1,17 @@ +package app.module.admin.usecase.household.monthlyInputStatus.updateMonthlyInputStatus.ports.application.domain; + +import app.module.core.config.adapters.persistence.component.AuditCommand; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +public class SaveExcelUploadLogCmd extends AuditCommand { + private String fileName; + private String month; + private String errorMessage; + private String errorDetail; + private String createdBy; +} diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/bankAutoTransfer/saveBankAutoTransferExpense/adapters/persistence/SaveBankAutoTransferExpenseMapper.java b/admin/src/main/java/app/module/admin/usecase/household/tab/bankAutoTransfer/saveBankAutoTransferExpense/adapters/persistence/SaveBankAutoTransferExpenseMapper.java index 83474bb4..4eeca716 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/bankAutoTransfer/saveBankAutoTransferExpense/adapters/persistence/SaveBankAutoTransferExpenseMapper.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/bankAutoTransfer/saveBankAutoTransferExpense/adapters/persistence/SaveBankAutoTransferExpenseMapper.java @@ -1,10 +1,12 @@ package app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferExpense.adapters.persistence; import app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferExpense.ports.application.domain.SaveBankAutoTransferExpenseOutCmd; +import app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferExpense.ports.application.domain.SaveBankAutoTransferExpenseOutExcelCmd; import org.apache.ibatis.annotations.Mapper; @Mapper public interface SaveBankAutoTransferExpenseMapper { void createBankAutoTransferExpense(SaveBankAutoTransferExpenseOutCmd cmd); void updateBankAutoTransferExpense(SaveBankAutoTransferExpenseOutCmd cmd); + void createBankAutoTransferExpenseExcel(SaveBankAutoTransferExpenseOutExcelCmd cmd); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/bankAutoTransfer/saveBankAutoTransferExpense/ports/application/domain/SaveBankAutoTransferExpenseOutExcelCmd.java b/admin/src/main/java/app/module/admin/usecase/household/tab/bankAutoTransfer/saveBankAutoTransferExpense/ports/application/domain/SaveBankAutoTransferExpenseOutExcelCmd.java new file mode 100644 index 00000000..6f075448 --- /dev/null +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/bankAutoTransfer/saveBankAutoTransferExpense/ports/application/domain/SaveBankAutoTransferExpenseOutExcelCmd.java @@ -0,0 +1,28 @@ +package app.module.admin.usecase.household.tab.bankAutoTransfer.saveBankAutoTransferExpense.ports.application.domain; + +import app.module.core.config.adapters.persistence.component.AuditCommand; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +public class SaveBankAutoTransferExpenseOutExcelCmd extends AuditCommand { + private Long bankAutoTransferId; + private Long householdSeq; + private String recordMonth; + private String expenseCode; + private String transferCategoryCode; + private String transferCategory; + private String sourcePurpose; + private String count; + private String unitCode; + private String unit; + private Long price; + private String transferType; + private String category; + private Long monthlyInputStatusId; + private String bankAutoTransferOutputStatus; + private String cropCode; +} diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/getDailyRecordStatusDetail/ports/application/domain/GetDailyExpenseRecords.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/getDailyRecordStatusDetail/ports/application/domain/GetDailyExpenseRecords.java index dec8d670..57767840 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/getDailyRecordStatusDetail/ports/application/domain/GetDailyExpenseRecords.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/getDailyRecordStatusDetail/ports/application/domain/GetDailyExpenseRecords.java @@ -27,4 +27,5 @@ public class GetDailyExpenseRecords { private String attachmentURL; private String startDay; private String endDay; + private Boolean ocrErrorResult; } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/getDailyRecordStatusDetail/ports/application/domain/GetDailyIncomeRecords.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/getDailyRecordStatusDetail/ports/application/domain/GetDailyIncomeRecords.java index 4f84dd5e..ae67f11c 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/getDailyRecordStatusDetail/ports/application/domain/GetDailyIncomeRecords.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/getDailyRecordStatusDetail/ports/application/domain/GetDailyIncomeRecords.java @@ -30,4 +30,5 @@ public class GetDailyIncomeRecords { private String attachmentURL; private String startDay; private String endDay; + private Boolean ocrErrorResult; } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/adapters/persistence/RemoveDailyDao.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/adapters/persistence/RemoveDailyDao.java index 70c13112..bef1426d 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/adapters/persistence/RemoveDailyDao.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/adapters/persistence/RemoveDailyDao.java @@ -42,4 +42,33 @@ public class RemoveDailyDao implements RemoveDailyPortOut { safeLogger.error("[RemoveDaily] Current step is null. cmd: {}", command); } } + + + + @UpdateCommand + @Override + public void operateStatus(RemoveDailyCmd command) { + if (command.getCurrentStep() != null) { + safeLogger.error("[RemoveDaily] cmd: {}", command); + + if (DailySort.INCOME.equals(command.getCurrentStep())) { + mapper.removeDailyIncome(command); +// mapper.removeDailyIncomeReceipt(command); + } else if (DailySort.WORK.equals(command.getCurrentStep())) { + mapper.removeDailyWork(command); + } else if (DailySort.EXPENSE.equals(command.getCurrentStep())) { + mapper.removeDailyExpense(command); +// mapper.removeDailyExpenseReceipt(command); + } else if (DailySort.POWER.equals(command.getCurrentStep())) { + mapper.removeDailyPower(command); + } else if (DailySort.FORESTRY.equals(command.getCurrentStep())) { + mapper.removeDailyForestry(command); + } else if (DailySort.FARMING.equals(command.getCurrentStep())) { + mapper.removeDailyFarming(command); + } + + } else { + safeLogger.error("[RemoveDaily] Current step is null. cmd: {}", command); + } + } } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/RemoveDailyPortIn.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/RemoveDailyPortIn.java index 12d29912..91a7fe50 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/RemoveDailyPortIn.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/RemoveDailyPortIn.java @@ -4,4 +4,5 @@ import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.w public interface RemoveDailyPortIn { void operate(RemoveDailyReqVO reqVO); + void operateStatus(RemoveDailyReqVO reqVO); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/RemoveDailyPortOut.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/RemoveDailyPortOut.java index 4cd1d147..a1bfb033 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/RemoveDailyPortOut.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/RemoveDailyPortOut.java @@ -4,4 +4,5 @@ import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.appl public interface RemoveDailyPortOut { void operate(RemoveDailyCmd command); + void operateStatus(RemoveDailyCmd command); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/application/RemoveDailyService.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/application/RemoveDailyService.java index 56e0c918..f5b3612e 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/application/RemoveDailyService.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/removeDaily/ports/application/RemoveDailyService.java @@ -20,4 +20,13 @@ public class RemoveDailyService implements RemoveDailyPortIn { portOut.operate(command); } + + @Override + public void operateStatus(RemoveDailyReqVO reqVO) { + RemoveDailyCmd command = new RemoveDailyCmd( + reqVO.getSelectedIds(), + reqVO.getCurrentStep()); + + portOut.operateStatus(command); + } } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/persistence/SaveDailyExpenseDao.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/persistence/SaveDailyExpenseDao.java index 2d8f75d7..9b919442 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/persistence/SaveDailyExpenseDao.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/persistence/SaveDailyExpenseDao.java @@ -1,5 +1,6 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence; +import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.persistence.RemoveDailyMapper; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.SaveDailyExpensePortOut; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.GetDailyExpenseCmd; @@ -17,6 +18,8 @@ public class SaveDailyExpenseDao implements SaveDailyExpensePortOut { private final SaveDailyExpenseMapper dailyExpenseMapper; + private final RemoveDailyMapper removeDailyMapper; + @Override public GetDailyExpenseDto detail(GetDailyExpenseCmd command) { @@ -27,9 +30,12 @@ public class SaveDailyExpenseDao implements SaveDailyExpensePortOut { @Override public void create(GetDailyExpenseCmd findCmd, SaveDailyExpenseCmd command) { Integer existCount = dailyExpenseMapper.getRecordExistCount(findCmd); - if (existCount == 0) { - dailyExpenseMapper.createDailyExpense(command); - + if (existCount == 0 ) { + if(findCmd.getId()== null || findCmd.getId() == 0 ) { + dailyExpenseMapper.createDailyExpense(command); + } else { + dailyExpenseMapper.updateDailyExpenseOnlyId(command); + } safeLogger.debug("[CreateDailyExpense] command={}", command); } else { dailyExpenseMapper.updateDailyExpense(command); diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/persistence/SaveDailyExpenseMapper.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/persistence/SaveDailyExpenseMapper.java index fee1bee5..52350805 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/persistence/SaveDailyExpenseMapper.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/persistence/SaveDailyExpenseMapper.java @@ -3,6 +3,7 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adap import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.GetDailyExpenseCmd; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.SaveDailyExpenseCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain.SaveDailyExpenseExcelCmd; import org.apache.ibatis.annotations.Mapper; @Mapper @@ -36,4 +37,12 @@ public interface SaveDailyExpenseMapper { * @param command 수정 데이터 */ void updateDailyExpense(SaveDailyExpenseCmd command); + void updateDailyExpenseOnlyId(SaveDailyExpenseCmd command); + + /** + * 일계부 지출 등록_Excel + * + * @param command 등록 데이터 + */ + void createDailyExpenseExcel(SaveDailyExpenseExcelCmd command); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/SaveDailyExpenseController.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/SaveDailyExpenseController.java index 8da1cae8..519a827f 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/SaveDailyExpenseController.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/SaveDailyExpenseController.java @@ -1,12 +1,21 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web; +import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.web.modal.RemoveDailyReqVO; +import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.RemoveDailyPortIn; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.persistence.modal.GetDailyExpenseDto; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.DailyExpenseUIReqVO; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.model.SaveDailyExpenseReqVO; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adapters.web.validator.SaveDailyExpenseValidator; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.SaveDailyExpensePortIn; +import app.module.core.config.application.enums.DailySort; +import app.module.core.config.application.enums.DailyStatus; +import app.module.core.config.application.enums.DailyTargetStatus; import app.module.core.config.application.exception.NoRecordDataException; +import app.module.core.config.application.util.DailyUtil; +import app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto; +import app.module.core.usecase.daily.dayGroup.ports.DailyDayGroupPortIn; import app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto; +import app.module.core.usecase.daily.record.adapters.web.model.CreateDailyRecordReqVO; import app.module.core.usecase.daily.record.ports.DailyRecordPortIn; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -15,6 +24,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; +import java.util.HashSet; +import java.util.Set; + @RestController @RequiredArgsConstructor @RequestMapping(path = "/api/household/daily/expense") @@ -23,6 +35,11 @@ public class SaveDailyExpenseController { private final SaveDailyExpensePortIn dailyExpensePortIn; private final SaveDailyExpenseValidator dailyExpenseValidator; + + private final DailyDayGroupPortIn dailyDayGroupPortIn; + private final RemoveDailyPortIn removeDailyPortIn; + private final DailyUtil dailyUtil; + /** * 일계부 지출 조회 * @@ -59,12 +76,28 @@ public class SaveDailyExpenseController { DailyRecordDto dailyRecord = this.vaildGetDailyRecord(formVO.getDailyId()); + + String monthPadded = formVO.getTargetMonth().length() == 1 ? "0" + formVO.getTargetMonth() : formVO.getTargetMonth(); + String formRecordMonth = formVO.getTargetYear() + monthPadded; + + if( !( formRecordMonth.equals(dailyRecord.getRecordMonth()) && formVO.getTargetDayGroup().equals(dailyRecord.getGroupNo()) ) ){ + DailyDayGroupDto dailyDayGroupDto = dailyDayGroupPortIn.detailbyGroupNo(formVO.getTargetDayGroup()); + dailyRecord = getOtherDailyRecord(formRecordMonth, dailyDayGroupDto, dailyRecord.getHouseholdSeq()); + + } + formVO.setSearchMonth(dailyRecord.getRecordMonth()); formVO.setGroupNo(dailyRecord.getGroupNo()); formVO.setDailyId(dailyRecord.getId()); dailyExpensePortIn.create(formVO); + if (!dailyRecord.getExpenseStatus().equals(DailyTargetStatus.TARGET)) { + dailyRecordPortIn.updateByStatus(dailyRecord.getRecordMonth(), dailyRecord.getGroupNo(), dailyRecord.getHouseholdSeq(), "EXPENSE", DailyTargetStatus.TARGET.name()); + } + + + return ResponseEntity.status(HttpStatus.OK).body(formVO); } @@ -81,4 +114,34 @@ public class SaveDailyExpenseController { return dailyRecord; } + + + private DailyRecordDto getOtherDailyRecord(String searchMonth, DailyDayGroupDto dailyDayGroupDto, Long householdSeq) { + + DailyRecordDto dailyRecord = dailyRecordPortIn.detail(searchMonth, dailyDayGroupDto.getGroupNo(), householdSeq); + + if (dailyRecord == null || dailyRecord.getId() == null) { + CreateDailyRecordReqVO createDailyRecordReqVO = new CreateDailyRecordReqVO(); + createDailyRecordReqVO.setTodayNone("N"); + createDailyRecordReqVO.setAllStatus(DailyStatus.DONE); + + createDailyRecordReqVO.setExpenseStatus(DailyTargetStatus.TARGET); + createDailyRecordReqVO.setFarmingStatus(DailyTargetStatus.TODAY_NONE); + createDailyRecordReqVO.setRecordMonth(searchMonth); + createDailyRecordReqVO.setDayGroupNo(dailyDayGroupDto.getGroupNo()); + + createDailyRecordReqVO.setStartDate(dailyUtil.getDayToLocalDate(searchMonth, dailyDayGroupDto.getStartDay())); + createDailyRecordReqVO.setEndDate(dailyUtil.getDayToLocalDate(searchMonth, dailyDayGroupDto.getEndDay())); + + + createDailyRecordReqVO.setHouseholdSeq(householdSeq); + + dailyRecordPortIn.create(createDailyRecordReqVO); + + dailyRecord = dailyRecordPortIn.detail(searchMonth, dailyDayGroupDto.getGroupNo(), householdSeq); + + } + return dailyRecord; + } + } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/model/SaveDailyExpenseReqVO.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/model/SaveDailyExpenseReqVO.java index c415cfde..d3ca330f 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/model/SaveDailyExpenseReqVO.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/model/SaveDailyExpenseReqVO.java @@ -3,6 +3,7 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.adap import app.module.core.config.application.enums.DailyInputType; import jakarta.validation.constraints.NotBlank; import lombok.Getter; +import lombok.NonNull; import lombok.Setter; import lombok.ToString; @@ -48,4 +49,15 @@ public class SaveDailyExpenseReqVO extends DailyExpenseUIReqVO { * 현물평가액 */ private Long estimatedValue; + + @NonNull + private String targetYear; + + @NonNull + private String targetMonth; + + @NonNull + private Integer targetDayGroup; + + private Long id; } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/validator/SaveDailyExpenseValidator.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/validator/SaveDailyExpenseValidator.java index a87c974d..82db238b 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/validator/SaveDailyExpenseValidator.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/adapters/web/validator/SaveDailyExpenseValidator.java @@ -21,29 +21,29 @@ public class SaveDailyExpenseValidator implements Validator { public void validate(Object target, Errors errors) { SaveDailyExpenseReqVO vo = (SaveDailyExpenseReqVO) target; - if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) { - errors.rejectValue( - "quantity", CommonConstants.VALID_CODE_NOTBLANK, - "수량을 입력해 주세요."); - } - - if (vo.getQuantity() != null && vo.getQuantity() <= 0) { - errors.rejectValue( - "quantity", CommonConstants.VALID_CODE_INVALID_ZERO, - "수량은 0 이상 입력해 주세요."); - } - - if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) { - errors.rejectValue( - "unitCode", CommonConstants.VALID_CODE_NOTBLANK, - "단위를 선택해 주세요."); - } - - if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { - errors.rejectValue( - "unitSelf", CommonConstants.VALID_CODE_NOTBLANK, - "단위를 입력해 주세요."); - } +// if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) { +// errors.rejectValue( +// "quantity", CommonConstants.VALID_CODE_NOTBLANK, +// "수량을 입력해 주세요."); +// } +// +// if (vo.getQuantity() != null && vo.getQuantity() <= 0) { +// errors.rejectValue( +// "quantity", CommonConstants.VALID_CODE_INVALID_ZERO, +// "수량은 0 이상 입력해 주세요."); +// } +// +// if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) { +// errors.rejectValue( +// "unitCode", CommonConstants.VALID_CODE_NOTBLANK, +// "단위를 선택해 주세요."); +// } +// +// if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { +// errors.rejectValue( +// "unitSelf", CommonConstants.VALID_CODE_NOTBLANK, +// "단위를 입력해 주세요."); +// } if (vo.getPrice() == null && vo.getEstimatedValue() == null) { errors.rejectValue( diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/ports/application/domain/SaveDailyExpenseExcelCmd.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/ports/application/domain/SaveDailyExpenseExcelCmd.java new file mode 100644 index 00000000..b3919c2f --- /dev/null +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyExpense/ports/application/domain/SaveDailyExpenseExcelCmd.java @@ -0,0 +1,35 @@ +package app.module.admin.usecase.household.tab.dailyRecord.saveDailyExpense.ports.application.domain; + +import app.module.core.config.adapters.persistence.component.AuditCommand; +import app.module.core.config.application.enums.DailyInputType; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@AllArgsConstructor +@ToString +public class SaveDailyExpenseExcelCmd extends AuditCommand { + private Long id; + private Long dailyRecordSeq; + private DailyInputType inputType; + /** + * 유형 + */ + private String category; + /** + * 수입 부호 + */ + private String incomeMark; + private Boolean credit; + private String expenseKind; + private String sourcePurpose; + private Double quantity; + private String unitCode; + private String unitSelf; + private Long price; + private Long estimatedValue; + private String expenseMark; +} diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyForestry/adapters/persistence/SaveDailyForestryMapper.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyForestry/adapters/persistence/SaveDailyForestryMapper.java index 5df9912b..01cd15a7 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyForestry/adapters/persistence/SaveDailyForestryMapper.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyForestry/adapters/persistence/SaveDailyForestryMapper.java @@ -3,6 +3,7 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.ada import app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.adapters.persistence.modal.GetDailyForestryDto; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.ports.application.domain.GetDailyForestryCmd; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.ports.application.domain.SaveDailyForestryCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.ports.application.domain.SaveDailyForestryExcelCmd; import org.apache.ibatis.annotations.Mapper; @Mapper @@ -36,4 +37,11 @@ public interface SaveDailyForestryMapper { * @param command 수정 데이터 */ void updateDailyForestry(SaveDailyForestryCmd command); + + /** + * 일계부 임업생산 등록_Excel + * + * @param command 등록 데이터 + */ + void createDailyForestryExcel(SaveDailyForestryExcelCmd command); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyForestry/ports/application/domain/SaveDailyForestryExcelCmd.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyForestry/ports/application/domain/SaveDailyForestryExcelCmd.java new file mode 100644 index 00000000..cd9b2628 --- /dev/null +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyForestry/ports/application/domain/SaveDailyForestryExcelCmd.java @@ -0,0 +1,24 @@ +package app.module.admin.usecase.household.tab.dailyRecord.saveDailyForestry.ports.application.domain; + +import app.module.core.config.adapters.persistence.component.AuditCommand; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@AllArgsConstructor +@ToString +public class SaveDailyForestryExcelCmd extends AuditCommand { + private Long id; + private Long dailyRecordSeq; + private String incomeMark; + private String expenseMark; + private String productName; + private String usage; + private Double quantity; + private String unitCode; + private String unitSelf; + private Long estimatedValue; +} diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/persistence/SaveDailyIncomeDao.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/persistence/SaveDailyIncomeDao.java index b6abd24a..650cc33d 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/persistence/SaveDailyIncomeDao.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/persistence/SaveDailyIncomeDao.java @@ -27,8 +27,12 @@ public class SaveDailyIncomeDao implements SaveDailyIncomePortOut { @Override public void create(GetDailyIncomeCmd findCmd, SaveDailyIncomeCmd command) { Integer existCount = dailyIncomeMapper.getRecordExistCount(findCmd); - if (existCount == 0) { - dailyIncomeMapper.createDailyIncome(command); + if (existCount == 0 ) { + if(findCmd.getId()== null || findCmd.getId() == 0 ) { + dailyIncomeMapper.createDailyIncome(command); + } else { + dailyIncomeMapper.updateDailyIncomeOnlyId(command); + } safeLogger.debug("[CreateDailyIncome] command={}", command); } else { diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/persistence/SaveDailyIncomeMapper.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/persistence/SaveDailyIncomeMapper.java index 861e9935..38e8d4a0 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/persistence/SaveDailyIncomeMapper.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/persistence/SaveDailyIncomeMapper.java @@ -3,6 +3,7 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapt import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.persistence.modal.GetDailyIncomeDto; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.ports.application.domain.GetDailyIncomeCmd; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.ports.application.domain.SaveDailyIncomeCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.ports.application.domain.SaveDailyIncomeExcelCmd; import org.apache.ibatis.annotations.Mapper; @Mapper @@ -36,4 +37,12 @@ public interface SaveDailyIncomeMapper { * @param command 수정 데이터 */ void updateDailyIncome(SaveDailyIncomeCmd command); + void updateDailyIncomeOnlyId(SaveDailyIncomeCmd command); + + /** + * 일계부 수입 등록_Excel + * + * @param command 등록 데이터 + */ + void createDailyIncomeExcel(SaveDailyIncomeExcelCmd command); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/SaveDailyIncomeController.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/SaveDailyIncomeController.java index 716de5f5..cfab97e9 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/SaveDailyIncomeController.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/SaveDailyIncomeController.java @@ -1,12 +1,21 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.web; +import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.web.modal.RemoveDailyReqVO; +import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.RemoveDailyPortIn; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.persistence.modal.GetDailyIncomeDto; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.web.model.DailyIncomeUIReqVO; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.web.model.SaveDailyIncomeReqVO; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.web.validator.SaveDailyIncomeValidator; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.ports.SaveDailyIncomePortIn; +import app.module.core.config.application.enums.DailySort; +import app.module.core.config.application.enums.DailyStatus; +import app.module.core.config.application.enums.DailyTargetStatus; import app.module.core.config.application.exception.NoRecordDataException; +import app.module.core.config.application.util.DailyUtil; +import app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto; +import app.module.core.usecase.daily.dayGroup.ports.DailyDayGroupPortIn; import app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto; +import app.module.core.usecase.daily.record.adapters.web.model.CreateDailyRecordReqVO; import app.module.core.usecase.daily.record.ports.DailyRecordPortIn; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -15,6 +24,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; +import java.util.HashSet; +import java.util.Set; + @RestController @RequiredArgsConstructor @RequestMapping(path = "/api/household/daily/income") @@ -23,6 +35,10 @@ public class SaveDailyIncomeController { private final SaveDailyIncomePortIn dailyIncomePortIn; private final SaveDailyIncomeValidator dailyIncomeValidator; + private final DailyDayGroupPortIn dailyDayGroupPortIn; + private final RemoveDailyPortIn removeDailyPortIn; + private final DailyUtil dailyUtil; + /** * 일계부 수입 조회 * @@ -59,12 +75,26 @@ public class SaveDailyIncomeController { DailyRecordDto dailyRecord = this.vaildGetDailyRecord(formVO.getDailyId()); + + String monthPadded = formVO.getTargetMonth().length() == 1 ? "0" + formVO.getTargetMonth() : formVO.getTargetMonth(); + String formRecordMonth = formVO.getTargetYear() + monthPadded; + + if( !( formRecordMonth.equals(dailyRecord.getRecordMonth()) && formVO.getTargetDayGroup().equals(dailyRecord.getGroupNo()) ) ){ + DailyDayGroupDto dailyDayGroupDto = dailyDayGroupPortIn.detailbyGroupNo(formVO.getTargetDayGroup()); + dailyRecord = getOtherDailyRecord(formRecordMonth, dailyDayGroupDto, dailyRecord.getHouseholdSeq()); + + } + formVO.setSearchMonth(dailyRecord.getRecordMonth()); formVO.setGroupNo(dailyRecord.getGroupNo()); formVO.setDailyId(dailyRecord.getId()); dailyIncomePortIn.create(formVO); + if(!dailyRecord.getIncomeStatus().equals(DailyTargetStatus.TARGET)) { + dailyRecordPortIn.updateByStatus(dailyRecord.getRecordMonth(), dailyRecord.getGroupNo(), dailyRecord.getHouseholdSeq(), "INCOME", DailyTargetStatus.TARGET.name()); + } + return ResponseEntity.status(HttpStatus.OK).body(formVO); } @@ -81,4 +111,36 @@ public class SaveDailyIncomeController { return dailyRecord; } + + private DailyRecordDto getOtherDailyRecord(String searchMonth, DailyDayGroupDto dailyDayGroupDto, Long householdSeq) { + + DailyRecordDto dailyRecord = dailyRecordPortIn.detail(searchMonth, dailyDayGroupDto.getGroupNo(), householdSeq); + + if (dailyRecord == null || dailyRecord.getId() == null) { + CreateDailyRecordReqVO createDailyRecordReqVO = new CreateDailyRecordReqVO(); + createDailyRecordReqVO.setTodayNone("N"); + createDailyRecordReqVO.setAllStatus(DailyStatus.DONE); + createDailyRecordReqVO.setIncomeStatus(DailyTargetStatus.TARGET); + createDailyRecordReqVO.setFarmingStatus(DailyTargetStatus.TODAY_NONE); + createDailyRecordReqVO.setRecordMonth(searchMonth); + createDailyRecordReqVO.setDayGroupNo(dailyDayGroupDto.getGroupNo()); + + createDailyRecordReqVO.setStartDate(dailyUtil.getDayToLocalDate(searchMonth, dailyDayGroupDto.getStartDay())); + createDailyRecordReqVO.setEndDate(dailyUtil.getDayToLocalDate(searchMonth, dailyDayGroupDto.getEndDay())); + + + createDailyRecordReqVO.setHouseholdSeq(householdSeq); + + dailyRecordPortIn.create(createDailyRecordReqVO); + + dailyRecord = dailyRecordPortIn.detail(searchMonth, dailyDayGroupDto.getGroupNo(), householdSeq); + + + + } + + + return dailyRecord; + } + } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/model/SaveDailyIncomeReqVO.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/model/SaveDailyIncomeReqVO.java index cdb49a64..974f99b9 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/model/SaveDailyIncomeReqVO.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/model/SaveDailyIncomeReqVO.java @@ -3,6 +3,7 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapt import app.module.core.config.application.enums.DailyInputType; import jakarta.validation.constraints.NotBlank; import lombok.Getter; +import lombok.NonNull; import lombok.Setter; import lombok.ToString; @@ -52,4 +53,15 @@ public class SaveDailyIncomeReqVO extends DailyIncomeUIReqVO { * 현물평가액 */ private Long estimatedValue; + + @NonNull + private String targetYear; + + @NonNull + private String targetMonth; + + @NonNull + private Integer targetDayGroup; + + private Long id; } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/validator/SaveDailyIncomeValidator.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/validator/SaveDailyIncomeValidator.java index bb6c175e..24ff8711 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/validator/SaveDailyIncomeValidator.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/adapters/web/validator/SaveDailyIncomeValidator.java @@ -21,29 +21,29 @@ public class SaveDailyIncomeValidator implements Validator { public void validate(Object target, Errors errors) { SaveDailyIncomeReqVO vo = (SaveDailyIncomeReqVO) target; - if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) { - errors.rejectValue( - "quantity", CommonConstants.VALID_CODE_NOTBLANK, - "수량을 입력해 주세요."); - } - - if (vo.getQuantity() != null && vo.getQuantity() <= 0) { - errors.rejectValue( - "quantity", CommonConstants.VALID_CODE_INVALID_ZERO, - "수량은 0 이상 입력해 주세요."); - } - - if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) { - errors.rejectValue( - "unitCode", CommonConstants.VALID_CODE_NOTBLANK, - "단위를 선택해 주세요."); - } - - if ("code.record.unit.self".equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { - errors.rejectValue( - "unitSelf", CommonConstants.VALID_CODE_NOTBLANK, - "단위를 입력해 주세요."); - } +// if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) { +// errors.rejectValue( +// "quantity", CommonConstants.VALID_CODE_NOTBLANK, +// "수량을 입력해 주세요."); +// } +// +// if (vo.getQuantity() != null && vo.getQuantity() <= 0) { +// errors.rejectValue( +// "quantity", CommonConstants.VALID_CODE_INVALID_ZERO, +// "수량은 0 이상 입력해 주세요."); +// } +// +// if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) { +// errors.rejectValue( +// "unitCode", CommonConstants.VALID_CODE_NOTBLANK, +// "단위를 선택해 주세요."); +// } +// +// if ("code.record.unit.self".equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { +// errors.rejectValue( +// "unitSelf", CommonConstants.VALID_CODE_NOTBLANK, +// "단위를 입력해 주세요."); +// } if (vo.getPrice() == null && vo.getEstimatedValue() == null) { errors.rejectValue( diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/ports/application/domain/SaveDailyIncomeExcelCmd.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/ports/application/domain/SaveDailyIncomeExcelCmd.java new file mode 100644 index 00000000..bc8884fa --- /dev/null +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyIncome/ports/application/domain/SaveDailyIncomeExcelCmd.java @@ -0,0 +1,36 @@ +package app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.ports.application.domain; + +import app.module.core.config.adapters.persistence.component.AuditCommand; +import app.module.core.config.application.enums.DailyInputType; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@AllArgsConstructor +@ToString +public class SaveDailyIncomeExcelCmd extends AuditCommand { + private Long id; + private Long dailyRecordSeq; + private DailyInputType inputType; + /** + * 유형 + */ + private String category; + /** + * 지출 부호 + */ + private String expenseMark; + private Boolean credit; + private String cropCode; + private String incomeKind; + private String sourcePurpose; + private Double quantity; + private String unitCode; + private String unitSelf; + private Long price; + private Long estimatedValue; + private String incomeMark; +} diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyPower/adapters/persistence/SaveDailyPowerMapper.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyPower/adapters/persistence/SaveDailyPowerMapper.java index 31187f99..f0d549e8 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyPower/adapters/persistence/SaveDailyPowerMapper.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyPower/adapters/persistence/SaveDailyPowerMapper.java @@ -3,6 +3,7 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.adapte import app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.adapters.persistence.modal.GetDailyPowerDto; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.ports.application.domain.GetDailyPowerCmd; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.ports.application.domain.SaveDailyPowerCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.ports.application.domain.SaveDailyPowerExcelCmd; import org.apache.ibatis.annotations.Mapper; @Mapper @@ -36,4 +37,11 @@ public interface SaveDailyPowerMapper { * @param command 수정 데이터 */ void updateDailyPower(SaveDailyPowerCmd command); + + /** + * 일계부 동력 사용시간 등록_Excel + * + * @param command 등록 데이터 + */ + void createDailyPowerExcel(SaveDailyPowerExcelCmd command); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyPower/ports/application/domain/SaveDailyPowerExcelCmd.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyPower/ports/application/domain/SaveDailyPowerExcelCmd.java new file mode 100644 index 00000000..5588d77f --- /dev/null +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyPower/ports/application/domain/SaveDailyPowerExcelCmd.java @@ -0,0 +1,20 @@ +package app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.ports.application.domain; + +import app.module.core.config.adapters.persistence.component.AuditCommand; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@AllArgsConstructor +@ToString +public class SaveDailyPowerExcelCmd extends AuditCommand { + private Long id; + private Long dailyRecordSeq; + private String equipmentName; + private String equipmentMark; + private Double ownedHours; + private Double leasedHours; +} diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyWork/adapters/persistence/SaveDailyWorkMapper.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyWork/adapters/persistence/SaveDailyWorkMapper.java index 0243f089..c7102ad9 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyWork/adapters/persistence/SaveDailyWorkMapper.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyWork/adapters/persistence/SaveDailyWorkMapper.java @@ -3,6 +3,7 @@ package app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.adapter import app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.adapters.persistence.modal.GetDailyWorkDto; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.ports.application.domain.GetDailyWorkCmd; import app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.ports.application.domain.SaveDailyWorkCmd; +import app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.ports.application.domain.SaveDailyWorkExcelCmd; import org.apache.ibatis.annotations.Mapper; @Mapper @@ -36,4 +37,11 @@ public interface SaveDailyWorkMapper { * @param command 수정 데이터 */ void updateDailyWork(SaveDailyWorkCmd command); + + /** + * 일계부 노동투입 등록_Excel + * + * @param command 등록 데이터 + */ + void createDailyWorkExcel(SaveDailyWorkExcelCmd command); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyWork/ports/application/domain/SaveDailyWorkExcelCmd.java b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyWork/ports/application/domain/SaveDailyWorkExcelCmd.java new file mode 100644 index 00000000..c9976efb --- /dev/null +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/dailyRecord/saveDailyWork/ports/application/domain/SaveDailyWorkExcelCmd.java @@ -0,0 +1,36 @@ +package app.module.admin.usecase.household.tab.dailyRecord.saveDailyWork.ports.application.domain; + +import app.module.core.config.adapters.persistence.component.AuditCommand; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@AllArgsConstructor +@ToString +public class SaveDailyWorkExcelCmd extends AuditCommand { + private Long id; + private Long dailyRecordSeq; + private String itemName; + private String itemMark; + private String workName; + private String workMark; + private Double workLandArea; + private String areaUnitCode; + private String areaUnitSelf; + private Double harvestQuantity; + private String harvestUnitCode; + private String harvestUnitSelf; + private Double ownerTime; + private Double spouseTime; + private Double familyMHours; + private Double familyFHours; + private Double hiredMHours; + private Double hiredFHours; + private Double sharedMHours; + private Double sharedFHours; + private Double volunteerMHours; + private Double volunteerFHours; +} diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/forestProduct/saveForestProduct/adapters/persistence/SaveForestProductMapper.java b/admin/src/main/java/app/module/admin/usecase/household/tab/forestProduct/saveForestProduct/adapters/persistence/SaveForestProductMapper.java index f754e7ed..6b89d792 100644 --- a/admin/src/main/java/app/module/admin/usecase/household/tab/forestProduct/saveForestProduct/adapters/persistence/SaveForestProductMapper.java +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/forestProduct/saveForestProduct/adapters/persistence/SaveForestProductMapper.java @@ -1,6 +1,7 @@ package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.persistence; import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd; +import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductExcelCmd; import org.apache.ibatis.annotations.Mapper; @Mapper @@ -8,4 +9,5 @@ public interface SaveForestProductMapper { String getForestProductStatus(Long monthlyInputStatusId); void createForestProduct(SaveForestProductCmd cmd); void updateForestProduct(SaveForestProductCmd cmd); + void createForestProductExcel(SaveForestProductExcelCmd cmd); } diff --git a/admin/src/main/java/app/module/admin/usecase/household/tab/forestProduct/saveForestProduct/ports/application/domain/SaveForestProductExcelCmd.java b/admin/src/main/java/app/module/admin/usecase/household/tab/forestProduct/saveForestProduct/ports/application/domain/SaveForestProductExcelCmd.java new file mode 100644 index 00000000..187cf03e --- /dev/null +++ b/admin/src/main/java/app/module/admin/usecase/household/tab/forestProduct/saveForestProduct/ports/application/domain/SaveForestProductExcelCmd.java @@ -0,0 +1,35 @@ +package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain; + +import app.module.core.config.adapters.persistence.component.AuditCommand; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +public class SaveForestProductExcelCmd extends AuditCommand { + private Long forestProductId; + private Long householdSeq; + private Long monthlyInputStatusId; + private String recordMonth; + private String streetNum; + private String landType; + private String town; + private String cropName; + private String cropCode; + private String landArea; + private String availableArea; + private String mainYield; + private String mainYieldUnitCode; + private String mainYieldUnit; + private String mainSaleAmount; + private String mainSaleUnitCode; + private String mainSaleUnit; + private String subYield; + private String subYieldUnitCode; + private String subYieldUnit; + private String subSaleAmount; + private String subSaleUnitCode; + private String subSaleUnit; +} diff --git a/admin/src/main/resources/mappers/household/CheckHouseholdNumMapper.xml b/admin/src/main/resources/mappers/household/CheckHouseholdNumMapper.xml index 972cee13..545db6c1 100644 --- a/admin/src/main/resources/mappers/household/CheckHouseholdNumMapper.xml +++ b/admin/src/main/resources/mappers/household/CheckHouseholdNumMapper.xml @@ -3,10 +3,11 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > - + \ No newline at end of file diff --git a/admin/src/main/resources/mappers/household/GetDailyRecordStatusDetailMapper.xml b/admin/src/main/resources/mappers/household/GetDailyRecordStatusDetailMapper.xml index 5075a9ae..3e4768d4 100644 --- a/admin/src/main/resources/mappers/household/GetDailyRecordStatusDetailMapper.xml +++ b/admin/src/main/resources/mappers/household/GetDailyRecordStatusDetailMapper.xml @@ -47,7 +47,8 @@ uf.id AS file_id, uf.name AS file_name, uf.origin_name AS file_origin_name, - uf.path AS file_path + uf.path AS file_path, + di.ocr_error_result AS ocrErrorResult , EXTRACT(DAY FROM CAST(dr.start_date as date)) as start_day , EXTRACT(DAY FROM CAST(dr.end_date as date)) as end_day @@ -163,7 +164,8 @@ uf.id AS file_id, uf.name AS file_name, uf.origin_name AS file_origin_name, - uf.path AS file_path + uf.path AS file_path, + de.ocr_error_result AS ocrErrorResult , EXTRACT(DAY FROM CAST(dr.start_date as date)) as start_day , EXTRACT(DAY FROM CAST(dr.end_date as date)) as end_day diff --git a/admin/src/main/resources/mappers/household/GetDailyRecordsStatusMapper.xml b/admin/src/main/resources/mappers/household/GetDailyRecordsStatusMapper.xml index d5aa2325..f9481a30 100644 --- a/admin/src/main/resources/mappers/household/GetDailyRecordsStatusMapper.xml +++ b/admin/src/main/resources/mappers/household/GetDailyRecordsStatusMapper.xml @@ -6,67 +6,109 @@ diff --git a/admin/src/main/resources/mappers/household/SaveBankAutoTransferExpenseMapper.xml b/admin/src/main/resources/mappers/household/SaveBankAutoTransferExpenseMapper.xml index 031d304f..be14d395 100644 --- a/admin/src/main/resources/mappers/household/SaveBankAutoTransferExpenseMapper.xml +++ b/admin/src/main/resources/mappers/household/SaveBankAutoTransferExpenseMapper.xml @@ -57,4 +57,44 @@ WHERE id = #{bankAutoTransferId} + + + /* createBankAutoTransferExpenseExcel : 은행자동이체(지출) 등록 */ + INSERT INTO bank_auto_transfer + ( + household_seq, + crop_code, + month, + expense_code, + transfer_category_code, + transfer_category, + source_purpose, + count, + unit_code, + unit, + price, + transfer_type, + monthly_input_status_id, + category, + + ) + VALUES + ( + #{householdSeq}, + #{cropCode}, + #{recordMonth}, + #{expenseCode}, + #{transferCategoryCode}, + #{transferCategory}, + #{sourcePurpose}, + #{count}, + #{unitCode}, + #{unit}, + #{price}, + #{transferType}, + #{monthlyInputStatusId}, + #{category}, + + ) + \ No newline at end of file diff --git a/admin/src/main/resources/mappers/household/SaveForestProductMapper.xml b/admin/src/main/resources/mappers/household/SaveForestProductMapper.xml index 0f9b4dd7..dffa9d89 100644 --- a/admin/src/main/resources/mappers/household/SaveForestProductMapper.xml +++ b/admin/src/main/resources/mappers/household/SaveForestProductMapper.xml @@ -92,4 +92,60 @@ WHERE id = #{forestProductId} + + + /* createForestProduct : 임산물 현황 등록 */ + INSERT INTO forest_product + ( + household_seq, + month, + street_num, + land_type, + town, + crop_name, + crop_code, + land_area, + available_area, + main_yield, + main_yield_unit_code, + main_yield_unit, + main_sale_amount, + main_sale_unit_code, + main_sale_unit, + sub_yield, + sub_yield_unit_code, + sub_yield_unit, + sub_sale_amount, + sub_sale_unit_code, + sub_sale_unit, + monthly_input_status_id, + + ) + VALUES + ( + #{householdSeq}, + #{recordMonth}, + #{streetNum}, + #{landType}, + #{town}, + #{cropName}, + #{cropCode}, + #{landArea}, + #{availableArea}, + #{mainYield}, + #{mainYieldUnitCode}, + #{mainYieldUnit}, + #{mainSaleAmount}, + #{mainSaleUnitCode}, + #{mainSaleUnit}, + #{subYield}, + #{subYieldUnitCode}, + #{subYieldUnit}, + #{subSaleAmount}, + #{subSaleUnitCode}, + #{subSaleUnit}, + #{monthlyInputStatusId}, + + ) + \ No newline at end of file diff --git a/admin/src/main/resources/mappers/household/UpdateMonthlyInputStatusMapper.xml b/admin/src/main/resources/mappers/household/UpdateMonthlyInputStatusMapper.xml index 9032cf58..cfe1cad6 100644 --- a/admin/src/main/resources/mappers/household/UpdateMonthlyInputStatusMapper.xml +++ b/admin/src/main/resources/mappers/household/UpdateMonthlyInputStatusMapper.xml @@ -29,4 +29,10 @@ WHERE is_deleted = false AND id = #{id} + + + INSERT INTO excel_uploade_log (file_name, month, error_message, error_detail,created_at, created_by) + VALUES (#{fileName}, #{month}, #{errorMessage}, #{errorDetail}, now(), #{createdBy}) + + \ No newline at end of file diff --git a/admin/src/main/resources/mappers/household/daily/SaveDailyExpenseMapper.xml b/admin/src/main/resources/mappers/household/daily/SaveDailyExpenseMapper.xml index af768bb7..70b2b5be 100644 --- a/admin/src/main/resources/mappers/household/daily/SaveDailyExpenseMapper.xml +++ b/admin/src/main/resources/mappers/household/daily/SaveDailyExpenseMapper.xml @@ -50,9 +50,43 @@ , unit_self = #{unitSelf} , price = #{price} , estimated_value = #{estimatedValue} + , ocr_error_result = false where is_deleted = false and daily_record_seq = #{dailyRecordSeq} and id = #{id} + + update daily_expense set + , is_credit = #{credit} + , income_mark = #{incomeMark} + , expense_kind = #{expenseKind} + , source_purpose = #{sourcePurpose} + , quantity = #{quantity} + , unit_code = #{unitCode} + , unit_self = #{unitSelf} + , price = #{price} + , estimated_value = #{estimatedValue} + , ocr_error_result = false + , daily_record_seq = #{dailyRecordSeq} + where is_deleted = false + and id = #{id} + + + + insert into daily_expense ( + daily_record_seq, input_type, category, income_mark, expense_mark + , is_credit, expense_kind, source_purpose + , quantity, unit_code, unit_self, price, estimated_value + , is_deleted + , + ) values ( + #{dailyRecordSeq}, #{inputType}, #{category}, #{incomeMark}, #{expenseMark} + , #{credit}, #{expenseKind}, #{sourcePurpose} + , #{quantity}, #{unitCode}, #{unitSelf}, #{price}, #{estimatedValue} + , false + , + ) + + diff --git a/admin/src/main/resources/mappers/household/daily/SaveDailyForestryMapper.xml b/admin/src/main/resources/mappers/household/daily/SaveDailyForestryMapper.xml index 45018ccc..370efaac 100644 --- a/admin/src/main/resources/mappers/household/daily/SaveDailyForestryMapper.xml +++ b/admin/src/main/resources/mappers/household/daily/SaveDailyForestryMapper.xml @@ -53,4 +53,20 @@ and id = #{id} + + insert into daily_forestry ( + daily_record_seq, income_mark, expense_mark + , product_name, usage + , quantity, unit_code, unit_self, estimated_value + , is_deleted + , + ) values ( + #{dailyRecordSeq}, #{incomeMark}, #{expenseMark} + , #{productName}, #{usage} + , #{quantity}, #{unitCode}, #{unitSelf}, #{estimatedValue} + , false + , + ) + + diff --git a/admin/src/main/resources/mappers/household/daily/SaveDailyIncomeMapper.xml b/admin/src/main/resources/mappers/household/daily/SaveDailyIncomeMapper.xml index 56ad9c7c..17f797e4 100644 --- a/admin/src/main/resources/mappers/household/daily/SaveDailyIncomeMapper.xml +++ b/admin/src/main/resources/mappers/household/daily/SaveDailyIncomeMapper.xml @@ -51,9 +51,43 @@ , unit_self = #{unitSelf} , price = #{price} , estimated_value = #{estimatedValue} + , ocr_error_result = false where is_deleted = false and daily_record_seq = #{dailyRecordSeq} and id = #{id} + + update daily_income set + , is_credit = #{credit} + , expense_mark = #{expenseMark} + , crop_code = #{cropCode} + , income_kind = #{incomeKind} + , source_purpose = #{sourcePurpose} + , quantity = #{quantity} + , unit_code = #{unitCode} + , unit_self = #{unitSelf} + , price = #{price} + , estimated_value = #{estimatedValue} + , ocr_error_result = false + , daily_record_seq = #{dailyRecordSeq} + where is_deleted = false + and id = #{id} + + + + insert into daily_income ( + daily_record_seq, input_type, category, income_mark, expense_mark + , is_credit, crop_code, income_kind, source_purpose + , quantity, unit_code, unit_self, price, estimated_value + , is_deleted + , + ) values ( + #{dailyRecordSeq}, #{inputType}, #{category}, #{incomeMark}, #{expenseMark} + , #{credit}, #{cropCode}, #{incomeKind}, #{sourcePurpose} + , #{quantity}, #{unitCode}, #{unitSelf}, #{price}, #{estimatedValue} + , false + , + ) + diff --git a/admin/src/main/resources/mappers/household/daily/SaveDailyPowerMapper.xml b/admin/src/main/resources/mappers/household/daily/SaveDailyPowerMapper.xml index edd89058..d96a28ee 100644 --- a/admin/src/main/resources/mappers/household/daily/SaveDailyPowerMapper.xml +++ b/admin/src/main/resources/mappers/household/daily/SaveDailyPowerMapper.xml @@ -46,4 +46,17 @@ and id = #{id} + + insert into daily_power ( + daily_record_seq + , equipment_name, equipment_mark,owned_hours, leased_hours + , is_deleted + , + ) values ( + #{dailyRecordSeq} + , #{equipmentName}, #{equipmentMark}, #{ownedHours}, #{leasedHours} + , false + , + ) + diff --git a/admin/src/main/resources/mappers/household/daily/SaveDailyWorkMapper.xml b/admin/src/main/resources/mappers/household/daily/SaveDailyWorkMapper.xml index 47d2d626..69da899b 100644 --- a/admin/src/main/resources/mappers/household/daily/SaveDailyWorkMapper.xml +++ b/admin/src/main/resources/mappers/household/daily/SaveDailyWorkMapper.xml @@ -68,4 +68,22 @@ and id = #{id} + + insert into daily_work ( + daily_record_seq + , item_name, item_mark, work_name, work_mark + , work_land_area, area_unit_code, area_unit_self, harvest_quantity, harvest_unit_code, harvest_unit_self + , owner_time, spouse_time, family_m_hours, family_f_hours, hired_m_hours, hired_f_hours, shared_m_hours, shared_f_hours, volunteer_m_hours, volunteer_f_hours + , is_deleted + , + ) values ( + #{dailyRecordSeq} + , #{itemName}, #{itemMark},#{workName}, #{workMark} + , #{workLandArea}, #{areaUnitCode}, #{areaUnitSelf}, #{harvestQuantity}, #{harvestUnitCode}, #{harvestUnitSelf} + , #{ownerTime}, #{spouseTime}, #{familyMHours}, #{familyFHours}, #{hiredMHours}, #{hiredFHours}, #{sharedMHours}, #{sharedFHours}, #{volunteerMHours}, #{volunteerFHours} + , false + , + ) + + diff --git a/admin/src/main/resources/static/assets/scripts/common.js b/admin/src/main/resources/static/assets/scripts/common.js index 9ee5287a..d35cea9b 100644 --- a/admin/src/main/resources/static/assets/scripts/common.js +++ b/admin/src/main/resources/static/assets/scripts/common.js @@ -1,5 +1,5 @@ etUI.utils.ready(function() { - console.log('document ready'); + etUI.initUI(); }) \ No newline at end of file diff --git a/admin/src/main/resources/static/scripts/ajaxUtils.js b/admin/src/main/resources/static/scripts/ajaxUtils.js index 0ace25d8..8b5ed5f4 100644 --- a/admin/src/main/resources/static/scripts/ajaxUtils.js +++ b/admin/src/main/resources/static/scripts/ajaxUtils.js @@ -125,7 +125,7 @@ var ajaxUtil = { console.error('statusCode: 403'); }, 422:function(rstData, status) { - console.log(rstData); + // console.log(rstData); // options type : 1. alert, 2. field if (options.handle422Type === 'alert') { if (typeof errorCallback !== 'undefined') { @@ -171,14 +171,14 @@ var ajaxUtil = { }, success : function(rstData, status) { ajaxUtil._hideWaiting(); - console.log('succ', rstData) + // console.log('succ', rstData) if (typeof successCallback !== 'undefined') { successCallback(rstData, status); } }, error : function(rstData) { ajaxUtil._hideWaiting(); - console.log('error') + // console.log('error') if (!(rstData.status == 500 || rstData.status == 422 || rstData.status == 400)) { if (typeof errorCallback !== 'undefined') { errorCallback(rstData.status, rstData); diff --git a/admin/src/main/resources/static/ui/uiUtil.js b/admin/src/main/resources/static/ui/uiUtil.js index 7359e595..fda3be99 100644 --- a/admin/src/main/resources/static/ui/uiUtil.js +++ b/admin/src/main/resources/static/ui/uiUtil.js @@ -241,7 +241,7 @@ uiUtil.uploadFile = (fileUploadType, input) => { $("meta[name='_csrf']").attr("content")); }, success(res) { - console.log(res); + // console.log(res); // 에러 메세지가 있었다면 초기화 $(input).removeClass('is-invalid'); diff --git a/admin/src/main/resources/templates/admin/adminCreateForm.html b/admin/src/main/resources/templates/admin/adminCreateForm.html index 17dff0cd..896d55ed 100644 --- a/admin/src/main/resources/templates/admin/adminCreateForm.html +++ b/admin/src/main/resources/templates/admin/adminCreateForm.html @@ -205,7 +205,7 @@ checkDuplicate = response <= 0; }, function (code, rstData) { - console.log("error : ", code); + // console.log("error : ", code); if(code == 400) alert("아이디를 입력해주세요."); if(code == 422) alert(rstData.responseText); checkDuplicate = false; diff --git a/admin/src/main/resources/templates/common/modal-researcher-mapping.html b/admin/src/main/resources/templates/common/modal-researcher-mapping.html index 306f8fca..e31342c2 100644 --- a/admin/src/main/resources/templates/common/modal-researcher-mapping.html +++ b/admin/src/main/resources/templates/common/modal-researcher-mapping.html @@ -138,7 +138,7 @@ }); }, function (code, rstData) { - console.log("error : ", code); + console.log("error : "); }, 'get', 'json' @@ -228,7 +228,7 @@ const selectedResearcher = researcherList.find(r => r.adminSeq == selectedAdminSeq); - console.log("선택된 조사원 : ", selectedResearcher); + // console.log("선택된 조사원 : ", selectedResearcher); // import 해준 html 에서 아래 함수를 선언해주면 selectedResearcher 값을 사용할 수 있음. getSelectedResearcher(selectedResearcher, () => { diff --git a/admin/src/main/resources/templates/households/create.html b/admin/src/main/resources/templates/households/create.html index 56f3ce07..b1b689a9 100644 --- a/admin/src/main/resources/templates/households/create.html +++ b/admin/src/main/resources/templates/households/create.html @@ -360,7 +360,7 @@ checkDuplicate = !response.isDuplicated; }, function (code, rstData) { // 실패 - console.log("error : ", code); + // console.log("error : ", code); if(code == 400) alert("임가번호를 입력해주세요."); }, 'get', @@ -386,12 +386,12 @@ function(response) { // 성공 alert("등록이 완료되었습니다."); location.href = '/households'; - console.log("code", response) + // console.log("code", response) }, function (code, rstData) { - console.log("code", code) - console.log("rstData", rstData) + // console.log("code", code) + // console.log("rstData", rstData) if(code == 422) alert(rstData.responseText); if(code == 400) alert(rstData.responseJSON.message); //임가번호 중복체크 diff --git a/admin/src/main/resources/templates/households/households.html b/admin/src/main/resources/templates/households/households.html index 5c363d67..f61d4ece 100644 --- a/admin/src/main/resources/templates/households/households.html +++ b/admin/src/main/resources/templates/households/households.html @@ -284,6 +284,9 @@
+ @@ -359,7 +362,7 @@ '/api/households', dataOj, function(response) { // 성공 - console.log("response", response); + // console.log("response", response); $('#totalElements').text(response.totalElements); @@ -424,7 +427,7 @@ })); }, function (code, rstData) { // 실패 - console.log("error : ", code); + console.log("error : "); }, 'get', 'json' diff --git a/admin/src/main/resources/templates/households/modal/modal-bank-auto-transfer-income.html b/admin/src/main/resources/templates/households/modal/modal-bank-auto-transfer-income.html index 78869818..30431318 100644 --- a/admin/src/main/resources/templates/households/modal/modal-bank-auto-transfer-income.html +++ b/admin/src/main/resources/templates/households/modal/modal-bank-auto-transfer-income.html @@ -176,13 +176,13 @@ `/api/household/bankAutoTransferIncome/${id}`, {}, (response) => { - console.log("은행자동이체(수입) 상세 응답값 : ", response); + // console.log("은행자동이체(수입) 상세 응답값 : ", response); setBankIncomeFormData(response); document.querySelector(".modal-bank-income").ui.open(); }, function (code, rstData) { - console.log("error : ", code); + console.log("error : "); }, 'get', 'json' @@ -254,7 +254,7 @@ if (!f) return; let dataOj = $(f).serializeObject(); - console.log("dataOj", dataOj); + // console.log("dataOj", dataOj); ajaxUtil._ajaxMethod( '/api/household/bank/income/save', diff --git a/admin/src/main/resources/templates/households/modal/modal-daily-expense.html b/admin/src/main/resources/templates/households/modal/modal-daily-expense.html index 273429b2..4ae9a980 100644 --- a/admin/src/main/resources/templates/households/modal/modal-daily-expense.html +++ b/admin/src/main/resources/templates/households/modal/modal-daily-expense.html @@ -10,13 +10,19 @@ + + + + + +