일계부 데이터 Excel 일괄 업로드 기능 추가
관리자 > 임가현황
This commit is contained in:
46
README.md
46
README.md
@@ -184,7 +184,53 @@ spring:
|
||||
username: ENC(...)
|
||||
password: ENC(...)
|
||||
```
|
||||
작성_1 : pom.xml에 의존성추가
|
||||
```pom
|
||||
<dependency>
|
||||
<groupId>com.github.ulisesbocchio</groupId>
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>3.0.5</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
작성_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 구성
|
||||
|
||||
95
admin/src/main/java/app/module/admin/BulkUrlShortener.java
Normal file
95
admin/src/main/java/app/module/admin/BulkUrlShortener.java
Normal file
@@ -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<Integer> 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<String> 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<String, String> 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<String> resp = CLIENT.send(req, HttpResponse.BodyHandlers.ofString());
|
||||
if (resp.statusCode() != 200) throw new IOException("HTTP " + resp.statusCode());
|
||||
|
||||
Map<String, Object> 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<String, String> 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 로 저장되었습니다 ✅");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,5 +10,6 @@ import lombok.Setter;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class CheckHouseholdNum {
|
||||
private Boolean isDuplicated; // 사용여부
|
||||
private Boolean isDuplicated; // 사용여부
|
||||
private Long householdSeq; // 가구일련번호
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,5 @@ import java.io.IOException;
|
||||
|
||||
public interface ExcelUploadCreateHouseholdPortIn {
|
||||
ExcelUploadResultVO operate(MultipartFile file) throws IOException;
|
||||
ExcelUploadResultVO dailyExcelUpload(MultipartFile file) throws IOException;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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}";
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -27,4 +27,5 @@ public class GetDailyExpenseRecords {
|
||||
private String attachmentURL;
|
||||
private String startDay;
|
||||
private String endDay;
|
||||
private Boolean ocrErrorResult;
|
||||
}
|
||||
|
||||
@@ -30,4 +30,5 @@ public class GetDailyIncomeRecords {
|
||||
private String attachmentURL;
|
||||
private String startDay;
|
||||
private String endDay;
|
||||
private Boolean ocrErrorResult;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -3,10 +3,11 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper
|
||||
namespace="app.module.admin.usecase.household.checkHouseholdNum.adapters.persistence.CheckHouseholdNumMapper">
|
||||
<select id="checkHouseholdNum"
|
||||
resultType="app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum">
|
||||
SELECT COUNT(*) > 0 AS is_duplicated
|
||||
FROM household
|
||||
WHERE household_num = #{householdNum};
|
||||
</select>
|
||||
<select id="checkHouseholdNum"
|
||||
resultType="app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum">
|
||||
SELECT COUNT(*) > 0 AS is_duplicated, seq AS householdSeq
|
||||
FROM household
|
||||
WHERE household_num = #{householdNum}
|
||||
GROUP BY SEQ;
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -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
|
||||
<if test="searchMonth == true">
|
||||
, 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
|
||||
<if test="searchMonth == true">
|
||||
, EXTRACT(DAY FROM CAST(dr.start_date as date)) as start_day
|
||||
, EXTRACT(DAY FROM CAST(dr.end_date as date)) as end_day
|
||||
|
||||
@@ -6,67 +6,109 @@
|
||||
<select id="getDailyRecordsStatus"
|
||||
resultType="app.module.admin.usecase.household.tab.dailyRecord.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatus">
|
||||
/* getDailyRecordsStatus : 일계부 등록 현황 리스트 조회 */
|
||||
WITH data_counts AS (
|
||||
SELECT
|
||||
dr.id,
|
||||
COUNT(DISTINCT di.id) AS income_cnt,
|
||||
COUNT(DISTINCT dw.id) AS work_cnt,
|
||||
COUNT(DISTINCT de.id) AS expense_cnt,
|
||||
COUNT(DISTINCT dp.id) AS power_cnt,
|
||||
COUNT(DISTINCT dfs.id) AS forestry_cnt,
|
||||
COUNT(distinct dfm.id) AS farming_cnt
|
||||
FROM daily_record dr
|
||||
LEFT JOIN daily_income di ON di.daily_record_seq = dr.id AND di.is_deleted = false
|
||||
LEFT JOIN daily_work dw ON dw.daily_record_seq = dr.id AND dw.is_deleted = false
|
||||
LEFT JOIN daily_expense de ON de.daily_record_seq = dr.id AND de.is_deleted = false
|
||||
LEFT JOIN daily_power dp ON dp.daily_record_seq = dr.id AND dp.is_deleted = false
|
||||
LEFT JOIN daily_forestry dfs ON dfs.daily_record_seq = dr.id AND dfs.is_deleted = false
|
||||
LEFT JOIN daily_farming dfm on dfm.daily_record_seq = dr.id and dfm.is_deleted = false
|
||||
WHERE dr.household_seq = #{householdSeq}
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND dr.is_deleted = false
|
||||
GROUP BY dr.id
|
||||
),
|
||||
month_check AS (
|
||||
SELECT
|
||||
#{recordMonth} = TO_CHAR(CURRENT_DATE, 'YYYYMM') AS is_current_month,
|
||||
EXTRACT(DAY FROM (TO_DATE(#{recordMonth}, 'YYYYMM') + INTERVAL '1 MONTH - 1 day')) AS month_last_day /* recordMonth 의 말일 */
|
||||
)
|
||||
WITH
|
||||
-- 각 일자별 항목별 개수를 미리 계산
|
||||
income AS (
|
||||
SELECT daily_record_seq, COUNT(*) AS income_cnt
|
||||
FROM daily_income
|
||||
WHERE is_deleted = false
|
||||
GROUP BY daily_record_seq
|
||||
),
|
||||
work AS (
|
||||
SELECT daily_record_seq, COUNT(*) AS work_cnt
|
||||
FROM daily_work
|
||||
WHERE is_deleted = false
|
||||
GROUP BY daily_record_seq
|
||||
),
|
||||
expense AS (
|
||||
SELECT daily_record_seq, COUNT(*) AS expense_cnt
|
||||
FROM daily_expense
|
||||
WHERE is_deleted = false
|
||||
GROUP BY daily_record_seq
|
||||
),
|
||||
power AS (
|
||||
SELECT daily_record_seq, COUNT(*) AS power_cnt
|
||||
FROM daily_power
|
||||
WHERE is_deleted = false
|
||||
GROUP BY daily_record_seq
|
||||
),
|
||||
forestry AS (
|
||||
SELECT daily_record_seq, COUNT(*) AS forestry_cnt
|
||||
FROM daily_forestry
|
||||
WHERE is_deleted = false
|
||||
GROUP BY daily_record_seq
|
||||
),
|
||||
farming AS (
|
||||
SELECT daily_record_seq, COUNT(*) AS farming_cnt
|
||||
FROM daily_farming
|
||||
WHERE is_deleted = false
|
||||
GROUP BY daily_record_seq
|
||||
),
|
||||
-- record 테이블에 각 항목별 count를 결합
|
||||
data_counts AS (
|
||||
SELECT
|
||||
dr.id,
|
||||
COALESCE(income.income_cnt, 0) AS income_cnt,
|
||||
COALESCE(work.work_cnt, 0) AS work_cnt,
|
||||
COALESCE(expense.expense_cnt, 0) AS expense_cnt,
|
||||
COALESCE(power.power_cnt, 0) AS power_cnt,
|
||||
COALESCE(forestry.forestry_cnt, 0) AS forestry_cnt,
|
||||
COALESCE(farming.farming_cnt, 0) AS farming_cnt
|
||||
FROM daily_record dr
|
||||
LEFT JOIN income ON income.daily_record_seq = dr.id
|
||||
LEFT JOIN work ON work.daily_record_seq = dr.id
|
||||
LEFT JOIN expense ON expense.daily_record_seq = dr.id
|
||||
LEFT JOIN power ON power.daily_record_seq = dr.id
|
||||
LEFT JOIN forestry ON forestry.daily_record_seq = dr.id
|
||||
LEFT JOIN farming ON farming.daily_record_seq = dr.id
|
||||
WHERE dr.household_seq = #{householdSeq}
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND dr.is_deleted = false
|
||||
),
|
||||
-- 현재 월 여부와 말일 계산
|
||||
month_check AS (
|
||||
SELECT
|
||||
(#{recordMonth} = TO_CHAR(CURRENT_DATE, 'YYYYMM')) AS is_current_month,
|
||||
EXTRACT(DAY FROM (TO_DATE(#{recordMonth}, 'YYYYMM') + INTERVAL '1 MONTH - 1 day')) AS month_last_day
|
||||
)
|
||||
SELECT
|
||||
dr.id AS id,
|
||||
ddg.group_no AS day_group_no,
|
||||
/* 해당 월의 말일을 기준으로 종료일을 제한하여 일자 그룹 표시 */
|
||||
ddg.start_day ||
|
||||
CASE
|
||||
WHEN ddg.start_day = LEAST(ddg.end_day, mc.month_last_day)
|
||||
THEN ''
|
||||
ELSE '-' || LEAST(ddg.end_day, mc.month_last_day)
|
||||
END AS day_group,
|
||||
CASE
|
||||
WHEN mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE) THEN 'WAITING' /* 대기 */
|
||||
WHEN dr.all_status IN ('DONE', 'TODAY_NONE') THEN 'DONE' /* 작성완료 */
|
||||
WHEN dr.all_status = 'WAITING' THEN 'INCOMPLETE' /* 미완료 */
|
||||
ELSE 'EMPTY' /* 미작성 */
|
||||
END AS all_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.income_status, dc.income_cnt) AS income_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.work_status, dc.work_cnt) AS work_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.expense_status, dc.expense_cnt) AS expense_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.power_status, dc.power_cnt) AS power_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.forestry_status, dc.forestry_cnt) AS forestry_status,
|
||||
fn_get_farming_status(
|
||||
ddg.start_day,
|
||||
dr.record_month,
|
||||
mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE),
|
||||
dr.farming_status,
|
||||
dc.farming_cnt
|
||||
) AS farming_status
|
||||
dr.id AS id,
|
||||
ddg.group_no AS day_group_no,
|
||||
-- 일자 범위 표시
|
||||
ddg.start_day ||
|
||||
CASE
|
||||
WHEN ddg.start_day = LEAST(ddg.end_day, mc.month_last_day)
|
||||
THEN ''
|
||||
ELSE '-' || LEAST(ddg.end_day, mc.month_last_day)
|
||||
END AS day_group,
|
||||
-- 전체 상태
|
||||
CASE
|
||||
WHEN mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE) THEN 'WAITING'
|
||||
WHEN dr.all_status IN ('DONE', 'TODAY_NONE') THEN 'DONE'
|
||||
WHEN dr.all_status = 'WAITING' THEN 'INCOMPLETE'
|
||||
ELSE 'EMPTY'
|
||||
END AS all_status,
|
||||
-- 세부 상태
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.income_status, dc.income_cnt) AS income_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.work_status, dc.work_cnt) AS work_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.expense_status, dc.expense_cnt) AS expense_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.power_status, dc.power_cnt) AS power_status,
|
||||
fn_get_status(mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE), dr.forestry_status, dc.forestry_cnt) AS forestry_status,
|
||||
fn_get_farming_status(
|
||||
ddg.start_day,
|
||||
dr.record_month,
|
||||
mc.is_current_month AND ddg.start_day > EXTRACT(DAY FROM CURRENT_DATE),
|
||||
dr.farming_status,
|
||||
dc.farming_cnt
|
||||
) AS farming_status
|
||||
FROM daily_day_group ddg
|
||||
CROSS JOIN month_check mc
|
||||
LEFT JOIN daily_record dr ON ddg.group_no = dr.day_group_no
|
||||
AND dr.household_seq = #{householdSeq}
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND dr.is_deleted = false
|
||||
LEFT JOIN data_counts dc ON dc.id = dr.id
|
||||
CROSS JOIN month_check mc
|
||||
LEFT JOIN daily_record dr
|
||||
ON ddg.group_no = dr.day_group_no
|
||||
AND dr.household_seq = #{householdSeq}
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND dr.is_deleted = false
|
||||
LEFT JOIN data_counts dc ON dc.id = dr.id
|
||||
WHERE ddg.start_day <= mc.month_last_day
|
||||
ORDER BY ddg.start_day
|
||||
</select>
|
||||
|
||||
@@ -57,4 +57,44 @@
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{bankAutoTransferId}
|
||||
</update>
|
||||
|
||||
<insert id="createBankAutoTransferExpenseExcel">
|
||||
/* 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,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{householdSeq},
|
||||
#{cropCode},
|
||||
#{recordMonth},
|
||||
#{expenseCode},
|
||||
#{transferCategoryCode},
|
||||
#{transferCategory},
|
||||
#{sourcePurpose},
|
||||
#{count},
|
||||
#{unitCode},
|
||||
#{unit},
|
||||
#{price},
|
||||
#{transferType},
|
||||
#{monthlyInputStatusId},
|
||||
#{category},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -92,4 +92,60 @@
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{forestProductId}
|
||||
</update>
|
||||
|
||||
<insert id="createForestProductExcel">
|
||||
/* 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,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{householdSeq},
|
||||
#{recordMonth},
|
||||
#{streetNum},
|
||||
#{landType},
|
||||
#{town},
|
||||
#{cropName},
|
||||
#{cropCode},
|
||||
#{landArea},
|
||||
#{availableArea},
|
||||
#{mainYield},
|
||||
#{mainYieldUnitCode},
|
||||
#{mainYieldUnit},
|
||||
#{mainSaleAmount},
|
||||
#{mainSaleUnitCode},
|
||||
#{mainSaleUnit},
|
||||
#{subYield},
|
||||
#{subYieldUnitCode},
|
||||
#{subYieldUnit},
|
||||
#{subSaleAmount},
|
||||
#{subSaleUnitCode},
|
||||
#{subSaleUnit},
|
||||
#{monthlyInputStatusId},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -29,4 +29,10 @@
|
||||
WHERE is_deleted = false
|
||||
AND id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="createExcelUploadLog">
|
||||
INSERT INTO excel_uploade_log (file_name, month, error_message, error_detail,created_at, created_by)
|
||||
VALUES (#{fileName}, #{month}, #{errorMessage}, #{errorDetail}, now(), #{createdBy})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -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>
|
||||
|
||||
<update id="updateDailyExpenseOnlyId">
|
||||
update daily_expense set <include refid="common.fields.UpdateBaseSet"/>
|
||||
, 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}
|
||||
</update>
|
||||
|
||||
<insert id="createDailyExpenseExcel" useGeneratedKeys="true" keyProperty="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
|
||||
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) values (
|
||||
#{dailyRecordSeq}, #{inputType}, #{category}, #{incomeMark}, #{expenseMark}
|
||||
, #{credit}, #{expenseKind}, #{sourcePurpose}
|
||||
, #{quantity}, #{unitCode}, #{unitSelf}, #{price}, #{estimatedValue}
|
||||
, false
|
||||
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -53,4 +53,20 @@
|
||||
and id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="createDailyForestryExcel" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into daily_forestry (
|
||||
daily_record_seq, income_mark, expense_mark
|
||||
, product_name, usage
|
||||
, quantity, unit_code, unit_self, estimated_value
|
||||
, is_deleted
|
||||
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) values (
|
||||
#{dailyRecordSeq}, #{incomeMark}, #{expenseMark}
|
||||
, #{productName}, #{usage}
|
||||
, #{quantity}, #{unitCode}, #{unitSelf}, #{estimatedValue}
|
||||
, false
|
||||
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -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>
|
||||
|
||||
<update id="updateDailyIncomeOnlyId">
|
||||
update daily_income set <include refid="common.fields.UpdateBaseSet"/>
|
||||
, 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}
|
||||
</update>
|
||||
|
||||
<insert id="createDailyIncomeExcel" useGeneratedKeys="true" keyProperty="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
|
||||
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) values (
|
||||
#{dailyRecordSeq}, #{inputType}, #{category}, #{incomeMark}, #{expenseMark}
|
||||
, #{credit}, #{cropCode}, #{incomeKind}, #{sourcePurpose}
|
||||
, #{quantity}, #{unitCode}, #{unitSelf}, #{price}, #{estimatedValue}
|
||||
, false
|
||||
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
||||
|
||||
@@ -46,4 +46,17 @@
|
||||
and id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="createDailyPowerExcel" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into daily_power (
|
||||
daily_record_seq
|
||||
, equipment_name, equipment_mark,owned_hours, leased_hours
|
||||
, is_deleted
|
||||
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) values (
|
||||
#{dailyRecordSeq}
|
||||
, #{equipmentName}, #{equipmentMark}, #{ownedHours}, #{leasedHours}
|
||||
, false
|
||||
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
||||
|
||||
@@ -68,4 +68,22 @@
|
||||
and id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="createDailyWorkExcel" useGeneratedKeys="true" keyProperty="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
|
||||
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) values (
|
||||
#{dailyRecordSeq}
|
||||
, #{itemName}, #{itemMark},#{workName}, #{workMark}
|
||||
, #{workLandArea}, #{areaUnitCode}, #{areaUnitSelf}, #{harvestQuantity}, #{harvestUnitCode}, #{harvestUnitSelf}
|
||||
, #{ownerTime}, #{spouseTime}, #{familyMHours}, #{familyFHours}, #{hiredMHours}, #{hiredFHours}, #{sharedMHours}, #{sharedFHours}, #{volunteerMHours}, #{volunteerFHours}
|
||||
, false
|
||||
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
etUI.utils.ready(function() {
|
||||
console.log('document ready');
|
||||
|
||||
|
||||
etUI.initUI();
|
||||
})
|
||||
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, () => {
|
||||
|
||||
@@ -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); //임가번호 중복체크
|
||||
|
||||
@@ -284,6 +284,9 @@
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<!-- 관리자만 노출 -->
|
||||
<button type="button" class="btn" th:if="${userRole == 'ROLE_ADMIN'}" onclick="showExcelDailyModal();" >
|
||||
<span class="btn-txt">엑셀 업로드(일계부)</span>
|
||||
</button>
|
||||
<button type="button" class="btn" th:if="${userRole == 'ROLE_ADMIN'}" onclick="showExcelHouseholdModal();" >
|
||||
<span class="btn-txt">엑셀 업로드</span>
|
||||
</button>
|
||||
@@ -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'
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -10,13 +10,19 @@
|
||||
<input type="hidden" name="id">
|
||||
<input type="hidden" name="dailyId">
|
||||
|
||||
<input type="hidden" name="startYear" th:value="${startYear}"/>
|
||||
<input type="hidden" name="startMonth" th:value="${startMonth}"/>
|
||||
<input type="hidden" name="currentDate" th:value="${currentDate}"/>
|
||||
<input type="hidden" name="selectedGroupNo" value=""/>
|
||||
|
||||
|
||||
<div class="component-modal mypage-wrap modal01 modal-daily-expense" data-props-dimm-click="true" data-state="close">
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
<div class="modal-container">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-tit">
|
||||
일계부 수입
|
||||
일계부 지출
|
||||
</h3>
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
@@ -31,7 +37,28 @@
|
||||
<col width="25.3%" />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>등록일</th>
|
||||
<td colspan="2">
|
||||
<div class="d-flex">
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="targetYear" required>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="targetMonth" required>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="targetDayGroup" required>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>외상 또는 카드 구입 여부</th>
|
||||
<td class="radio-group" colspan="4">
|
||||
@@ -159,10 +186,156 @@
|
||||
form.price.value = '';
|
||||
form.estimatedValue.value = '';
|
||||
|
||||
const currentDateStr = form.currentDate ? form.currentDate.value : ''; // "2025-08-09"
|
||||
const selectedGroupNo = form.selectedGroupNo ? form.selectedGroupNo.value : ''; // "2025-08-09"
|
||||
const startYear = form.startYear ? parseInt(form.startYear.value, 10) : 2024;
|
||||
const startMonth = form.startMonth ? parseInt(form.startMonth.value, 10) : 8;
|
||||
|
||||
// 오늘 Y/M/D 파싱
|
||||
const ymd = /^(\d{4})-(\d{2})-(\d{2})$/.exec(currentDateStr);
|
||||
const cur = ymd ? { y: +ymd[1], m: +ymd[2], d: +ymd[3] } : { y: null, m: null, d: null };
|
||||
if (!cur.y || !cur.m || !cur.d) return;
|
||||
|
||||
// selectedGroupNo가 있으면 초기 연/월은 #recordMonthStr(value: "yyyyMM")에서 취득
|
||||
let baseY = cur.y, baseM = cur.m;
|
||||
if (selectedGroupNo) {
|
||||
const rmSel = document.getElementById('recordMonthStr');
|
||||
const rmVal = rmSel?.value || '';
|
||||
const rm = /^(\d{4})(\d{2})$/.exec(rmVal);
|
||||
if (rm) { baseY = +rm[1]; baseM = +rm[2]; }
|
||||
}
|
||||
|
||||
// 연/월 셀렉트 요소
|
||||
const yearSel = form.targetYear;
|
||||
const monthSel = form.targetMonth;
|
||||
const daySel = form.targetDayGroup;
|
||||
|
||||
// 일자 그룹 정의(1~17)
|
||||
const DAY_GROUPS = [
|
||||
{ groupNo: 1, startDay: 1, endDay: 2 },
|
||||
{ groupNo: 2, startDay: 3, endDay: 4 },
|
||||
{ groupNo: 3, startDay: 5, endDay: 6 },
|
||||
{ groupNo: 4, startDay: 7, endDay: 7 },
|
||||
{ groupNo: 5, startDay: 8, endDay: 9 },
|
||||
{ groupNo: 6, startDay: 10, endDay: 11 },
|
||||
{ groupNo: 7, startDay: 12, endDay: 13 },
|
||||
{ groupNo: 8, startDay: 14, endDay: 14 },
|
||||
{ groupNo: 9, startDay: 15, endDay: 16 },
|
||||
{ groupNo: 10, startDay: 17, endDay: 18 },
|
||||
{ groupNo: 11, startDay: 19, endDay: 20 },
|
||||
{ groupNo: 12, startDay: 21, endDay: 21 },
|
||||
{ groupNo: 13, startDay: 22, endDay: 23 },
|
||||
{ groupNo: 14, startDay: 24, endDay: 25 },
|
||||
{ groupNo: 15, startDay: 26, endDay: 27 },
|
||||
{ groupNo: 16, startDay: 28, endDay: 29 },
|
||||
{ groupNo: 17, startDay: 30, endDay: 31 },
|
||||
];
|
||||
const daysInMonth = (y, m) => new Date(y, m, 0).getDate();
|
||||
const findGroupNoByDay = (day) => {
|
||||
const g = DAY_GROUPS.find(g => day >= g.startDay && day <= g.endDay);
|
||||
return g ? g.groupNo : null;
|
||||
};
|
||||
|
||||
// 연도 옵션: startYear ~ currentDate.year
|
||||
function fillYears(preselectYear) {
|
||||
if (!yearSel) return;
|
||||
yearSel.innerHTML = '';
|
||||
for (let y = startYear; y <= cur.y; y++) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = String(y);
|
||||
opt.textContent = `${y}년`;
|
||||
yearSel.appendChild(opt);
|
||||
}
|
||||
// 선택: selectedGroupNo 있으면 baseY, 없으면 cur.y
|
||||
const pickY = (typeof preselectYear === 'number') ? preselectYear : cur.y;
|
||||
yearSel.value = String(pickY);
|
||||
}
|
||||
|
||||
// 월 옵션: (startYear → startMonth~12), (cur.y → 1~cur.m), (그 외 과거연도 → 1~12)
|
||||
function fillMonths(year, preselectMonth) {
|
||||
if (!monthSel) return;
|
||||
monthSel.innerHTML = '';
|
||||
let from = 1, to = 12;
|
||||
if (year === startYear) from = startMonth;
|
||||
if (year === cur.y) to = cur.m;
|
||||
|
||||
for (let m = from; m <= to; m++) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = String(m);
|
||||
opt.textContent = `${m}월`;
|
||||
monthSel.appendChild(opt);
|
||||
}
|
||||
// 선택: selectedGroupNo 있으면 baseM, 없으면 cur.m (범위 밖이면 첫 항목)
|
||||
const candidate = (typeof preselectMonth === 'number') ? preselectMonth : cur.m;
|
||||
monthSel.value = (candidate >= from && candidate <= to)
|
||||
? String(candidate)
|
||||
: (monthSel.options[0]?.value || '');
|
||||
}
|
||||
|
||||
// 일자그룹 옵션: 존재 & 미래 제외
|
||||
function fillDayGroups(year, month, preselectGroupNo) {
|
||||
if (!daySel) return;
|
||||
daySel.innerHTML = '';
|
||||
|
||||
// "선택하세요" 옵션 추가
|
||||
const placeholder = document.createElement('option');
|
||||
placeholder.value = '';
|
||||
placeholder.textContent = '선택하세요';
|
||||
daySel.appendChild(placeholder);
|
||||
|
||||
const dim = daysInMonth(year, month);
|
||||
const isCurYM = (year === cur.y && month === cur.m);
|
||||
const maxDay = isCurYM ? cur.d : dim;
|
||||
|
||||
const candidates = DAY_GROUPS
|
||||
.filter(g => g.endDay <= dim)
|
||||
.filter(g => g.startDay <= maxDay);
|
||||
|
||||
candidates.forEach(g => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = String(g.groupNo);
|
||||
opt.textContent = (g.startDay === g.endDay) ? `${g.startDay}일` : `${g.startDay}~${g.endDay}일`;
|
||||
daySel.appendChild(opt);
|
||||
});
|
||||
|
||||
// 선택 우선순위: 전달된 groupNo가 리스트에 있으면 → 그것, 아니면 첫 항목
|
||||
let pick = preselectGroupNo ? String(preselectGroupNo) : '';
|
||||
if (pick && ![...daySel.options].some(o => o.value === pick)) pick = '';
|
||||
if (!pick) pick = daySel.options[0]?.value || '';
|
||||
if (pick) daySel.value = pick;
|
||||
}
|
||||
|
||||
// ----- 초기 세팅 -----
|
||||
// 1) 연도/월 옵션은 currentDate 기준으로 생성
|
||||
fillYears(selectedGroupNo ? baseY : undefined);
|
||||
fillMonths(parseInt(yearSel.value, 10), selectedGroupNo ? baseM : undefined);
|
||||
|
||||
// 2) 일자그룹 선택값 계산
|
||||
const initGroupNo = selectedGroupNo
|
||||
? parseInt(selectedGroupNo, 10)
|
||||
: findGroupNoByDay(cur.d);
|
||||
|
||||
fillDayGroups(parseInt(yearSel.value, 10), parseInt(monthSel.value, 10), initGroupNo);
|
||||
|
||||
// ----- 이벤트 -----
|
||||
yearSel?.addEventListener('change', function () {
|
||||
const y = parseInt(this.value, 10);
|
||||
// selectedGroupNo가 있으면 월 선택은 baseM 유지 시도(범위 밖이면 첫 항목)
|
||||
fillMonths(y, selectedGroupNo ? baseM : undefined);
|
||||
// 일그룹: selectedGroupNo 우선(존재하지 않으면 폴백)
|
||||
fillDayGroups(y, parseInt(monthSel.value, 10), selectedGroupNo ? parseInt(selectedGroupNo, 10) : undefined);
|
||||
});
|
||||
|
||||
monthSel?.addEventListener('change', function () {
|
||||
const y = parseInt(yearSel.value, 10);
|
||||
fillDayGroups(y, parseInt(this.value, 10), selectedGroupNo ? parseInt(selectedGroupNo, 10) : undefined);
|
||||
});
|
||||
|
||||
document.getElementById('isCredit_N').checked = true;
|
||||
priceDisabledReset(form.price, form.estimatedValue);
|
||||
}
|
||||
|
||||
|
||||
// 일계부 상세 값 set
|
||||
const setDailyExpenseFormData = (data) => {
|
||||
const form = document.reqExpenseForm;
|
||||
@@ -199,6 +372,11 @@
|
||||
mf.groupNo.value = document.reqForm.groupNo.value;
|
||||
mf.dailyId.value = document.reqForm.dailyId.value;
|
||||
mf.id.value = (id === undefined) ? '' : id;
|
||||
// if(id === undefined){
|
||||
// mf.selectedGroupNo.value = null;
|
||||
// } else {
|
||||
mf.selectedGroupNo.value = document.reqForm.groupNo.value;
|
||||
// }
|
||||
|
||||
resetDailyExpenseForm();
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
<input type="hidden" name="id">
|
||||
<input type="hidden" name="dailyId">
|
||||
|
||||
<input type="hidden" name="startYear" th:value="${startYear}"/>
|
||||
<input type="hidden" name="startMonth" th:value="${startMonth}"/>
|
||||
<input type="hidden" name="currentDate" th:value="${currentDate}"/>
|
||||
<input type="hidden" name="selectedGroupNo" value=""/>
|
||||
<div class="component-modal mypage-wrap modal01 modal-daily-income" data-props-dimm-click="true" data-state="close">
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
@@ -31,7 +35,28 @@
|
||||
<col width="25.3%" />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>등록일</th>
|
||||
<td colspan="2">
|
||||
<div class="d-flex">
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="targetYear" required>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="targetMonth" required>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="targetDayGroup" required>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>외상판매 여부</th>
|
||||
<td class="radio-group">
|
||||
@@ -172,6 +197,151 @@
|
||||
form.price.value = '';
|
||||
form.estimatedValue.value = '';
|
||||
|
||||
const currentDateStr = form.currentDate ? form.currentDate.value : ''; // "2025-08-09"
|
||||
const selectedGroupNo = form.selectedGroupNo ? form.selectedGroupNo.value : ''; // "2025-08-09"
|
||||
const startYear = form.startYear ? parseInt(form.startYear.value, 10) : 2024;
|
||||
const startMonth = form.startMonth ? parseInt(form.startMonth.value, 10) : 8;
|
||||
|
||||
// 오늘 Y/M/D 파싱
|
||||
const ymd = /^(\d{4})-(\d{2})-(\d{2})$/.exec(currentDateStr);
|
||||
const cur = ymd ? { y: +ymd[1], m: +ymd[2], d: +ymd[3] } : { y: null, m: null, d: null };
|
||||
if (!cur.y || !cur.m || !cur.d) return;
|
||||
|
||||
// selectedGroupNo가 있으면 초기 연/월은 #recordMonthStr(value: "yyyyMM")에서 취득
|
||||
let baseY = cur.y, baseM = cur.m;
|
||||
if (selectedGroupNo) {
|
||||
const rmSel = document.getElementById('recordMonthStr');
|
||||
const rmVal = rmSel?.value || '';
|
||||
const rm = /^(\d{4})(\d{2})$/.exec(rmVal);
|
||||
if (rm) { baseY = +rm[1]; baseM = +rm[2]; }
|
||||
}
|
||||
|
||||
// 연/월 셀렉트 요소
|
||||
const yearSel = form.targetYear;
|
||||
const monthSel = form.targetMonth;
|
||||
const daySel = form.targetDayGroup;
|
||||
|
||||
// 일자 그룹 정의(1~17)
|
||||
const DAY_GROUPS = [
|
||||
{ groupNo: 1, startDay: 1, endDay: 2 },
|
||||
{ groupNo: 2, startDay: 3, endDay: 4 },
|
||||
{ groupNo: 3, startDay: 5, endDay: 6 },
|
||||
{ groupNo: 4, startDay: 7, endDay: 7 },
|
||||
{ groupNo: 5, startDay: 8, endDay: 9 },
|
||||
{ groupNo: 6, startDay: 10, endDay: 11 },
|
||||
{ groupNo: 7, startDay: 12, endDay: 13 },
|
||||
{ groupNo: 8, startDay: 14, endDay: 14 },
|
||||
{ groupNo: 9, startDay: 15, endDay: 16 },
|
||||
{ groupNo: 10, startDay: 17, endDay: 18 },
|
||||
{ groupNo: 11, startDay: 19, endDay: 20 },
|
||||
{ groupNo: 12, startDay: 21, endDay: 21 },
|
||||
{ groupNo: 13, startDay: 22, endDay: 23 },
|
||||
{ groupNo: 14, startDay: 24, endDay: 25 },
|
||||
{ groupNo: 15, startDay: 26, endDay: 27 },
|
||||
{ groupNo: 16, startDay: 28, endDay: 29 },
|
||||
{ groupNo: 17, startDay: 30, endDay: 31 },
|
||||
];
|
||||
const daysInMonth = (y, m) => new Date(y, m, 0).getDate();
|
||||
const findGroupNoByDay = (day) => {
|
||||
const g = DAY_GROUPS.find(g => day >= g.startDay && day <= g.endDay);
|
||||
return g ? g.groupNo : null;
|
||||
};
|
||||
|
||||
// 연도 옵션: startYear ~ currentDate.year
|
||||
function fillYears(preselectYear) {
|
||||
if (!yearSel) return;
|
||||
yearSel.innerHTML = '';
|
||||
for (let y = startYear; y <= cur.y; y++) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = String(y);
|
||||
opt.textContent = `${y}년`;
|
||||
yearSel.appendChild(opt);
|
||||
}
|
||||
// 선택: selectedGroupNo 있으면 baseY, 없으면 cur.y
|
||||
const pickY = (typeof preselectYear === 'number') ? preselectYear : cur.y;
|
||||
yearSel.value = String(pickY);
|
||||
}
|
||||
|
||||
// 월 옵션: (startYear → startMonth~12), (cur.y → 1~cur.m), (그 외 과거연도 → 1~12)
|
||||
function fillMonths(year, preselectMonth) {
|
||||
if (!monthSel) return;
|
||||
monthSel.innerHTML = '';
|
||||
let from = 1, to = 12;
|
||||
if (year === startYear) from = startMonth;
|
||||
if (year === cur.y) to = cur.m;
|
||||
|
||||
for (let m = from; m <= to; m++) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = String(m);
|
||||
opt.textContent = `${m}월`;
|
||||
monthSel.appendChild(opt);
|
||||
}
|
||||
// 선택: selectedGroupNo 있으면 baseM, 없으면 cur.m (범위 밖이면 첫 항목)
|
||||
const candidate = (typeof preselectMonth === 'number') ? preselectMonth : cur.m;
|
||||
monthSel.value = (candidate >= from && candidate <= to)
|
||||
? String(candidate)
|
||||
: (monthSel.options[0]?.value || '');
|
||||
}
|
||||
|
||||
// 일자그룹 옵션: 존재 & 미래 제외
|
||||
function fillDayGroups(year, month, preselectGroupNo) {
|
||||
if (!daySel) return;
|
||||
daySel.innerHTML = '';
|
||||
|
||||
// "선택하세요" 옵션 추가
|
||||
const placeholder = document.createElement('option');
|
||||
placeholder.value = '';
|
||||
placeholder.textContent = '선택하세요';
|
||||
daySel.appendChild(placeholder);
|
||||
|
||||
const dim = daysInMonth(year, month);
|
||||
const isCurYM = (year === cur.y && month === cur.m);
|
||||
const maxDay = isCurYM ? cur.d : dim;
|
||||
|
||||
const candidates = DAY_GROUPS
|
||||
.filter(g => g.endDay <= dim)
|
||||
.filter(g => g.startDay <= maxDay);
|
||||
|
||||
candidates.forEach(g => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = String(g.groupNo);
|
||||
opt.textContent = (g.startDay === g.endDay) ? `${g.startDay}일` : `${g.startDay}~${g.endDay}일`;
|
||||
daySel.appendChild(opt);
|
||||
});
|
||||
|
||||
// 선택 우선순위: 전달된 groupNo가 리스트에 있으면 → 그것, 아니면 첫 항목
|
||||
let pick = preselectGroupNo ? String(preselectGroupNo) : '';
|
||||
if (pick && ![...daySel.options].some(o => o.value === pick)) pick = '';
|
||||
if (!pick) pick = daySel.options[0]?.value || '';
|
||||
if (pick) daySel.value = pick;
|
||||
}
|
||||
|
||||
// ----- 초기 세팅 -----
|
||||
// 1) 연도/월 옵션은 currentDate 기준으로 생성
|
||||
fillYears(selectedGroupNo ? baseY : undefined);
|
||||
fillMonths(parseInt(yearSel.value, 10), selectedGroupNo ? baseM : undefined);
|
||||
|
||||
// 2) 일자그룹 선택값 계산
|
||||
const initGroupNo = selectedGroupNo
|
||||
? parseInt(selectedGroupNo, 10)
|
||||
: findGroupNoByDay(cur.d);
|
||||
|
||||
fillDayGroups(parseInt(yearSel.value, 10), parseInt(monthSel.value, 10), initGroupNo);
|
||||
|
||||
// ----- 이벤트 -----
|
||||
yearSel?.addEventListener('change', function () {
|
||||
const y = parseInt(this.value, 10);
|
||||
// selectedGroupNo가 있으면 월 선택은 baseM 유지 시도(범위 밖이면 첫 항목)
|
||||
fillMonths(y, selectedGroupNo ? baseM : undefined);
|
||||
// 일그룹: selectedGroupNo 우선(존재하지 않으면 폴백)
|
||||
fillDayGroups(y, parseInt(monthSel.value, 10), selectedGroupNo ? parseInt(selectedGroupNo, 10) : undefined);
|
||||
});
|
||||
|
||||
monthSel?.addEventListener('change', function () {
|
||||
const y = parseInt(yearSel.value, 10);
|
||||
fillDayGroups(y, parseInt(this.value, 10), selectedGroupNo ? parseInt(selectedGroupNo, 10) : undefined);
|
||||
});
|
||||
|
||||
document.getElementById('isCredit_N').checked = true;
|
||||
priceDisabledReset(form.price, form.estimatedValue);
|
||||
}
|
||||
@@ -213,6 +383,11 @@
|
||||
mf.groupNo.value = document.reqForm.groupNo.value;
|
||||
mf.dailyId.value = document.reqForm.dailyId.value;
|
||||
mf.id.value = (id === undefined) ? '' : id;
|
||||
// if(id === undefined){
|
||||
// mf.selectedGroupNo.value = null;
|
||||
// } else {
|
||||
mf.selectedGroupNo.value = document.reqForm.groupNo.value;
|
||||
// }
|
||||
|
||||
resetDailyIncomeForm();
|
||||
|
||||
|
||||
@@ -6,37 +6,76 @@
|
||||
<form autocomplete="off" method="get" name="reqHouseholdExcelForm">
|
||||
|
||||
<div class="component-modal mypage-wrap modal01 modal-excel-household" data-props-dimm-click="true" data-state="close">
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
<div class="modal-container type-small">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-tit">
|
||||
임가 등록 엑셀업로드
|
||||
</h3>
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
<div class="modal-content-inner">
|
||||
<label for="householdFile" class="input-file-btn">
|
||||
<input type="file" name="file" id="householdFile" accept=".xlsx, .xls">
|
||||
</label>
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn btn-primary" onclick="ExcelUploadHousehold();">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
<div class="modal-container type-small">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-tit">
|
||||
임가 등록 엑셀업로드
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
<div class="modal-content-inner">
|
||||
<label for="householdFile" class="input-file-btn">
|
||||
<input type="file" name="file" id="householdFile" accept=".xlsx, .xls">
|
||||
</label>
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn btn-primary" onclick="ExcelUploadHousehold();">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="modal-close"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="modal-close"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="component-modal mypage-wrap modal01 modal-excel-daily" data-props-dimm-click="true" data-state="close">
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
<div class="modal-container type-small">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-tit">
|
||||
일계부 등록 엑셀업로드
|
||||
</h3>
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
<div class="modal-content-inner">
|
||||
<label for="dailyFile" class="input-file-btn">
|
||||
<input type="file" name="file" id="dailyFile" accept=".xlsx, .xls">
|
||||
</label>
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn btn-primary" onclick="ExcelUploadDaily();">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="modal-close"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// 일계부 엑셀업로드 모달창 띄우기
|
||||
const showExcelDailyModal = () => {
|
||||
document.querySelector(".modal-excel-daily").ui.open();
|
||||
const fileInput = document.getElementById("householdFile");
|
||||
if (fileInput) {
|
||||
fileInput.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
// 임가방문정보 모달창 띄우기
|
||||
const showExcelHouseholdModal = () => {
|
||||
document.querySelector(".modal-excel-household").ui.open();
|
||||
@@ -93,6 +132,51 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 일계부정보 등록
|
||||
const ExcelUploadDaily = () => {
|
||||
event.preventDefault();
|
||||
|
||||
const fileInput = document.getElementById('dailyFile');
|
||||
if (fileInput.files.length === 0) {
|
||||
alert('업로드할 엑셀 파일을 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 로딩바 show
|
||||
ajaxUtil._showWaiting();
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('file', fileInput.files[0]);
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '/api/household/dailyExcelUpload',
|
||||
data: formData,
|
||||
contentType: false, // * 중요 *
|
||||
processData: false, // * 중요 *
|
||||
enctype: 'multipart/form-data', // * 중요 *
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res) {
|
||||
ajaxUtil._hideWaiting(); // 로딩바 hide
|
||||
alert("일계부 데이터 엑셀 업로드를 완료(실패 "+res.success+"건) 하였습니다.");
|
||||
document.querySelector(".modal-excel-household").ui.close();
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
ajaxUtil._hideWaiting();
|
||||
let message = "엑셀 업로드 중 오류가 발생하였습니다.";
|
||||
if (xhr.responseText) {
|
||||
message = xhr.responseText;
|
||||
}
|
||||
alert(message);
|
||||
document.querySelector(".modal-excel-household").ui.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -261,7 +261,7 @@
|
||||
`/api/forestProduct/${id}`,
|
||||
{},
|
||||
(response) => {
|
||||
console.log("임산물현황 상세 응답값 : ", response);
|
||||
// console.log("임산물현황 상세 응답값 : ", response);
|
||||
setForestProductFormData(response);
|
||||
|
||||
document.querySelector(".modal-forest-product").ui.open();
|
||||
|
||||
@@ -143,12 +143,12 @@
|
||||
`/api/visitInfo/${id}`,
|
||||
{},
|
||||
(response) => {
|
||||
console.log("임가방문정보 상세 응답값 : ", response);
|
||||
// console.log("임가방문정보 상세 응답값 : ", response);
|
||||
setVisitFormData(response);
|
||||
document.querySelector(".modal-visit-info").ui.open();
|
||||
},
|
||||
function (code, rstData) {
|
||||
console.log("error : ", code);
|
||||
console.log("error : ");
|
||||
},
|
||||
'get',
|
||||
'json'
|
||||
@@ -184,7 +184,7 @@
|
||||
const f = document.reqVisitForm;
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
console.log("dataOj", dataOj);
|
||||
// console.log("dataOj", dataOj);
|
||||
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/visitInfo/save',
|
||||
@@ -214,7 +214,7 @@
|
||||
|
||||
datepicker.core.init($el, {
|
||||
dateSelectCallback: function (selectedDate) {
|
||||
console.log('선택된 날짜:', selectedDate);
|
||||
// console.log('선택된 날짜:', selectedDate);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
recordMonth: f.recordMonth.value
|
||||
},
|
||||
(response) => { // 성공
|
||||
console.log("은행자동이체내역 조회 : ", response);
|
||||
// console.log("은행자동이체내역 조회 : ", response);
|
||||
gridBankIncomeTable(response.incomes);
|
||||
gridBankExpenseTable(response.expenses);
|
||||
},
|
||||
|
||||
@@ -373,7 +373,7 @@
|
||||
recordMonth: f.recordMonth.value
|
||||
},
|
||||
function(response) { // 성공
|
||||
console.log("일계부 현황 리스트 조회 : ", response);
|
||||
// console.log("일계부 현황 리스트 조회 : ", response);
|
||||
const listArea = $('.tab-content .daily-record-list');
|
||||
const detailArea = $('.tab-content .daily-record-detail');
|
||||
const tbody = listArea.find('tbody');
|
||||
@@ -445,7 +445,7 @@
|
||||
'/api/household/dailyRecordStatus',
|
||||
{ recordSeq: id, recordMonth: f.recordMonth.value },
|
||||
function(response) { // 성공
|
||||
console.log("일계부 등록 상세 데이터 : ", response);
|
||||
// console.log("일계부 등록 상세 데이터 : ", response);
|
||||
|
||||
// 금일 데이터 없음 체크
|
||||
$('#incomeStatus').attr('checked', response.status.incomeStatus === 'TODAY_NONE');
|
||||
@@ -472,7 +472,7 @@
|
||||
gridFarmingTable(response.status.farmingStatus, response.farmings);
|
||||
|
||||
if (groupNo === 1) {
|
||||
console.log(groupNo, response.monthlyCarryOver)
|
||||
// console.log(groupNo, response.monthlyCarryOver)
|
||||
if (response.monthlyCarryOver != null) {
|
||||
$('#carryOver').text(Number(response.monthlyCarryOver).toLocaleString() + '원');
|
||||
} else {
|
||||
@@ -514,6 +514,7 @@
|
||||
}
|
||||
|
||||
let tmpl = '';
|
||||
// console.log(data)
|
||||
$(data).each((idx, item) => {
|
||||
tmpl +=
|
||||
`
|
||||
@@ -527,14 +528,17 @@
|
||||
</td>
|
||||
<td>${item.isCredit ? "Y" : "N"}</td> <!-- 외상판매 -->
|
||||
<td>${ifNullHyphen(item.cropText)}</td><!-- 재배형태 -->
|
||||
<td class="underline"><a href="javascript:void(0);" onclick="showDailyIncomeModal(${item.id});">${ifNullHyphen(item.incomeKind)}</a></td> <!-- 수입의 종류 -->
|
||||
<td class="underline">
|
||||
<a href="javascript:void(0);" onclick="showDailyIncomeModal(${item.id});">${ifNullHyphen(item.incomeKind)}</a>
|
||||
${item.ocrErrorResult ? '<br><span style="color:red">(확인필요)</span>' : ''}
|
||||
</td> <!-- 수입의 종류 -->
|
||||
<td>${ifNullHyphen(item.sourcePurpose)}</td><!-- 수입원 -->
|
||||
<td class="align-right">${formatNumberWithComma(item.quantity)}</td><!-- 수량 -->
|
||||
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
|
||||
<td class="align-right">${formatNumberWithComma(item.price)}</td><!-- 현금(원) -->
|
||||
<td class="align-right">${formatNumberWithComma(item.estimatedValue)}</td><!-- 현물평가액 -->
|
||||
<td class="align-center">
|
||||
${item.fileId ? `<a href="${item.attachmentURL}" download>다운로드</a>` : '-'}
|
||||
${item.fileId ? `<a href="javascript:void(0);" onclick="downloadFile('${item.attachmentURL}','수입','${ifNullHyphen(item.incomeKind)}','${idx+1}')" download>다운로드</a>` : '-'}
|
||||
</td>
|
||||
<td>
|
||||
${item.updatedBy}<br>
|
||||
@@ -609,6 +613,8 @@
|
||||
}
|
||||
|
||||
let tmpl = '';
|
||||
|
||||
|
||||
$(data).each((idx, item) => {
|
||||
tmpl +=
|
||||
`
|
||||
@@ -621,14 +627,16 @@
|
||||
</div>
|
||||
</td>
|
||||
<td>${item.isCredit ? "Y" : "N"}</td> <!-- 외상 또는 카드구입 -->
|
||||
<td class="underline"><a href="javascript:void(0);" onclick="showDailyExpenseModal(${item.id});">${ifNullHyphen(item.expenseKind)}</a></td> <!-- 지출의 종류 -->
|
||||
<td class="underline"><a href="javascript:void(0);" onclick="showDailyExpenseModal(${item.id});">${ifNullHyphen(item.expenseKind)}</a>
|
||||
${item.ocrErrorResult ? '<br><span style="color:red">(확인필요)</span>' : ''}
|
||||
</td> <!-- 지출의 종류 -->
|
||||
<td>${ifNullHyphen(item.sourcePurpose)}</td><!-- 용도 -->
|
||||
<td class="align-right">${ifNullHyphen(item.quantity)}</td><!-- 수량 -->
|
||||
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
|
||||
<td class="align-right">${formatNumberWithComma(item.price)}</td><!-- 현금(원) -->
|
||||
<td class="align-right">${formatNumberWithComma(item.estimatedValue)}</td><!-- 현물평가액 -->
|
||||
<td class="align-center">
|
||||
${item.fileId ? `<a href="${item.attachmentURL}" download>다운로드</a>` : '-'}
|
||||
${item.fileId ? `<a href="javascript:void(0);" onclick="downloadFile('${item.attachmentURL}','지출','${ifNullHyphen(item.expenseKind)}','${idx+1}')" download>다운로드</a>` : '-'}
|
||||
</td>
|
||||
<td>
|
||||
${item.updatedBy}<br>
|
||||
@@ -853,7 +861,7 @@
|
||||
const saveDaily = (el) => {
|
||||
const currentStep = $(el).data('step');
|
||||
const currentModalId = $(el).data('modalId');
|
||||
console.log('saveDaily', currentStep, currentModalId);
|
||||
// console.log('saveDaily', currentStep, currentModalId);
|
||||
|
||||
if (currentStep === 'INCOME') {
|
||||
showDailyIncomeModal();
|
||||
@@ -874,7 +882,7 @@
|
||||
const removeDaily = (el) => {
|
||||
const currentStep = $(el).data('step');
|
||||
const currentListId = $(el).data('listId');
|
||||
console.log('removeDaily', currentStep, currentListId);
|
||||
// console.log('removeDaily', currentStep, currentListId);
|
||||
|
||||
if ($('#'+currentListId).find('input[type="checkbox"]:checked').length === 0) {
|
||||
alert('삭제내용은 최소 1건은 선택해야 합니다.');
|
||||
@@ -892,7 +900,7 @@
|
||||
const obj = {};
|
||||
obj.selectedIds = selectedValues;
|
||||
obj.currentStep = currentStep;
|
||||
console.log(obj)
|
||||
// console.log(obj)
|
||||
|
||||
etUI.dialog.confirm({
|
||||
title: '삭제 안내',
|
||||
@@ -910,6 +918,22 @@
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const downloadFile = (url,type, title, num) => {
|
||||
const houseHoldNum = document.getElementById("targetHouseHoldNum").innerText;
|
||||
const yearMonth = document.getElementById("recordMonthStr").value;
|
||||
let text = document.querySelector("h3._selectedGroupNo").innerText;
|
||||
let day = text.match(/\d+/)[0].padStart(2, "0");
|
||||
const changeFileName = houseHoldNum+"_"+yearMonth+""+day+"_"+type+"_"+title.replace(/\s+/g, "")+"_"+num.padStart(3, "0");
|
||||
|
||||
const urlReplace = `${url}?rename=${encodeURIComponent(changeFileName)}`;
|
||||
|
||||
const a = document.createElement("a");
|
||||
a.href = urlReplace;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</html>
|
||||
@@ -76,7 +76,7 @@
|
||||
recordMonth: f.recordMonth.value
|
||||
},
|
||||
(response) => { // 성공
|
||||
console.log("임산물 현황 리스트 조회 : ", response);
|
||||
// console.log("임산물 현황 리스트 조회 : ", response);
|
||||
|
||||
const tbody = $('.tab-content.forest-product tbody');
|
||||
tbody.empty();
|
||||
@@ -189,7 +189,7 @@
|
||||
|
||||
// 이번달 등록내용 없음 수정 처리
|
||||
const updateForestProductNone = (obj) => {
|
||||
console.log(obj);
|
||||
// console.log(obj);
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/household/forestProduct/nothing',
|
||||
JSON.stringify(obj),
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
recordMonth: f.recordMonth.value
|
||||
},
|
||||
(response) => { // 성공
|
||||
console.log("임가 방문정보 조회 : ", response);
|
||||
// console.log("임가 방문정보 조회 : ", response);
|
||||
const tbody = $('.tab-content.household-visit tbody');
|
||||
|
||||
tbody.empty();
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<tr>
|
||||
<th>임가번호</th>
|
||||
<td>
|
||||
<span th:text="${householdInfo.householdNum}">16750</span>
|
||||
<span th:text="${householdInfo.householdNum}" id="targetHouseHoldNum">16750</span>
|
||||
</td>
|
||||
<th>경영주</th>
|
||||
<td>
|
||||
@@ -133,7 +133,7 @@
|
||||
<button type="button" class="tab-label select-tab" data-tab-type="household-visit" data-tab-value="tab4">임가방문정보</button>
|
||||
|
||||
<div class="component-select select-date">
|
||||
<select class="select-list" name="recordMonth" required onchange="onRecordMonthChange();">
|
||||
<select class="select-list" name="recordMonth" id="recordMonthStr" required onchange="onRecordMonthChange();">
|
||||
<option th:each="m : ${monthList}"
|
||||
th:value="${m.value}"
|
||||
th:text="${m.label}"
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
let visitDatePicker;
|
||||
|
||||
document.getElementById('visitDate').addEventListener('change', function (e) {
|
||||
console.log("날짜 변경됨:", e.target.value);
|
||||
// console.log("날짜 변경됨:", e.target.value);
|
||||
});
|
||||
|
||||
const showHouseholdModal2 = (seq) => {
|
||||
|
||||
@@ -162,7 +162,6 @@
|
||||
|
||||
},
|
||||
function (code, rstData) {
|
||||
console.log("왜지 ");
|
||||
|
||||
},
|
||||
'get',
|
||||
|
||||
@@ -432,7 +432,7 @@
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
console.log('nextNode is ', item);
|
||||
// console.log('nextNode is ', item);
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -126,4 +126,41 @@ public class CommonUtil {
|
||||
flashMessages.add(msg);
|
||||
session.setAttribute("flashAlertMessages", flashMessages);
|
||||
}
|
||||
|
||||
public static String normalizePath(String path) {
|
||||
if (path == null || path.trim().isEmpty()) {
|
||||
log.warn("normalizePath: Input path is null or empty, returning default path");
|
||||
String defaultPath = System.getProperty("user.home") + File.separator + "Downloads";
|
||||
return Paths.get(defaultPath).toAbsolutePath().normalize().toString();
|
||||
}
|
||||
|
||||
try {
|
||||
// Paths.get을 사용하여 경로 정규화
|
||||
Path normalizedPath = Paths.get(path).toAbsolutePath().normalize();
|
||||
String result = normalizedPath.toString();
|
||||
log.debug("Normalized path: {}", result);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("Error normalizing path: {}", path, e);
|
||||
throw new IllegalArgumentException("Failed to normalize path: " + path, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void createDirectories(File directory) {
|
||||
if (directory == null) {
|
||||
throw new IllegalArgumentException("Directory cannot be null");
|
||||
}
|
||||
try {
|
||||
if (!directory.exists()) {
|
||||
boolean created = directory.mkdirs();
|
||||
log.info("Directory created: {} (Success: {})", directory.getAbsolutePath(), created);
|
||||
}
|
||||
if (!directory.canWrite()) {
|
||||
throw new IOException("No write permission for directory: " + directory.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to create directory: {}", directory.getAbsolutePath(), e);
|
||||
throw new RuntimeException("Failed to create directory", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,16 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class DailyUtil {
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
/**
|
||||
* int -> localdate
|
||||
* @param month 월(yyyyMM)
|
||||
@@ -179,4 +183,39 @@ public class DailyUtil {
|
||||
returnValue.put("expenseMark", expenseMark);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* dateStr 문자열을 기준으로 수정 가능 여부 반환
|
||||
* @param dateStr 수정 대상 월 (예: "2025-04-03")
|
||||
* @return true = 수정 가능, false = 수정 불가
|
||||
*/
|
||||
public boolean isEditable(String dateStr) {
|
||||
try {
|
||||
LocalDate date = LocalDate.parse(dateStr, DATE_FORMATTER);
|
||||
|
||||
// 대상 월
|
||||
YearMonth targetMonth = YearMonth.from(date);
|
||||
|
||||
// 마감일 계산
|
||||
LocalDate limitDate;
|
||||
if (DailyRecordConstants.MODIFY_LIMIT_DAY == 31) {
|
||||
limitDate = targetMonth
|
||||
.plusMonths(DailyRecordConstants.MODIFY_LIMIT_MONTH)
|
||||
.atEndOfMonth();
|
||||
} else {
|
||||
limitDate = targetMonth
|
||||
.plusMonths(DailyRecordConstants.MODIFY_LIMIT_MONTH)
|
||||
.atDay(DailyRecordConstants.MODIFY_LIMIT_DAY);
|
||||
}
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
// 오늘이 마감일 이후면 수정 불가
|
||||
return !today.isAfter(limitDate);
|
||||
} catch (Exception e) {
|
||||
return false; // 형식 오류나 파싱 실패 → 수정 불가
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,5 +62,12 @@ public final class DailyRecordConstants {
|
||||
* 날짜 기준 정책
|
||||
*/
|
||||
public static final int MODIFY_LIMIT_DAY = 31;
|
||||
|
||||
/**
|
||||
* admin 년도 시작일
|
||||
*/
|
||||
public static final int START_YEAR = 2024;
|
||||
/**
|
||||
* 첫 시작년도의 시작 월
|
||||
*/
|
||||
public static final int START_MONTH_OF_START_YEAR = 8;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.module.core.usecase.daily.dayGroup.adapters.persistence;
|
||||
|
||||
|
||||
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.DailyDayGroupPortOut;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class DailyDayGroupDao implements DailyDayGroupPortOut {
|
||||
private final DailyDayGroupMapper dailyRecordMapper;
|
||||
|
||||
@Override
|
||||
public DailyDayGroupDto detail(String searchDay) {
|
||||
return dailyRecordMapper.getDailyDayGroup(searchDay);
|
||||
}
|
||||
@Override
|
||||
public DailyDayGroupDto detailbyGroupNo(Integer groupNo) {
|
||||
return dailyRecordMapper.getDailyDayGroupByGroupNo(groupNo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.core.usecase.daily.dayGroup.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DailyDayGroupMapper {
|
||||
|
||||
DailyDayGroupDto getDailyDayGroup(String searchDay);
|
||||
DailyDayGroupDto getDailyDayGroupByGroupNo(Integer groupNo);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.core.usecase.daily.dayGroup.adapters.persistence.model;
|
||||
|
||||
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 lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class DailyDayGroupDto {
|
||||
|
||||
private Integer groupNo;
|
||||
private Integer startDay;
|
||||
private Integer endDay;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.core.usecase.daily.dayGroup.ports;
|
||||
|
||||
import app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto;
|
||||
|
||||
public interface DailyDayGroupPortIn {
|
||||
DailyDayGroupDto detail(String searchDay);
|
||||
DailyDayGroupDto detailbyGroupNo(Integer groupNo);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package app.module.core.usecase.daily.dayGroup.ports;
|
||||
|
||||
|
||||
import app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto;
|
||||
|
||||
public interface DailyDayGroupPortOut {
|
||||
|
||||
DailyDayGroupDto detail(String searchDay);
|
||||
|
||||
DailyDayGroupDto detailbyGroupNo(Integer groupNo);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package app.module.core.usecase.daily.dayGroup.ports.application;
|
||||
|
||||
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.dayGroup.ports.DailyDayGroupPortOut;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyDayGroupService implements DailyDayGroupPortIn {
|
||||
private final DailyDayGroupPortOut portOut;
|
||||
|
||||
@Override
|
||||
public DailyDayGroupDto detail(String searchDay) {
|
||||
return portOut.detail(searchDay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyDayGroupDto detailbyGroupNo(Integer groupNo) {
|
||||
return portOut.detailbyGroupNo(groupNo);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
package app.module.core.usecase.daily.record.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto;
|
||||
import app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordAlertDto;
|
||||
import app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||
import app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordStatusDto;
|
||||
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.GetDailyRecordCmd;
|
||||
import app.module.core.usecase.daily.record.ports.application.domain.UpdateDailyRecordStatusCmd;
|
||||
import app.module.core.usecase.uicode.view.ports.application.domain.UICodeView;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -62,5 +65,19 @@ public interface DailyRecordMapper {
|
||||
List<DailyRecordAlertDto> selectDailyNoRegister(@Param("searchMonth") String searchMonth, @Param("householdSeq")Long householdSeq);
|
||||
List<String> selectMonthNoRegister(@Param("searchMonth")String searchMonth, @Param("householdSeq")Long householdSeq);
|
||||
|
||||
/**
|
||||
* 일계부 항목 등록(생성)_Excel 업로드
|
||||
*
|
||||
* @param command 등록 데이터
|
||||
*/
|
||||
Long createDailyRecordExcel(CreateDailyRecordExcelCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 항목의 상태 수정_Excel 업로드
|
||||
*
|
||||
* @param command 수정 데이터
|
||||
*/
|
||||
void updateDailyRecordStatusExcel(UpdateDailyRecordStatusCmd command);
|
||||
|
||||
List<DailyRecordDto> getDailyDayGroup();
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ public class DailyRecordDto {
|
||||
*/
|
||||
private boolean modifiable;
|
||||
|
||||
private Long householdSeq;
|
||||
|
||||
/**
|
||||
* 현재 단계
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package app.module.core.usecase.daily.record.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import app.module.core.config.application.enums.DailyStatus;
|
||||
import app.module.core.config.application.enums.DailyTargetStatus;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class CreateDailyRecordExcelCmd extends AuditCommand {
|
||||
private Long id;
|
||||
private String recordMonth;
|
||||
private int dayGroupNo;
|
||||
private Long householdSeq;
|
||||
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
private DailyStatus allStatus;
|
||||
private DailyTargetStatus incomeStatus;
|
||||
private DailyTargetStatus workStatus;
|
||||
private DailyTargetStatus expenseStatus;
|
||||
private DailyTargetStatus powerStatus;
|
||||
private DailyTargetStatus forestryStatus;
|
||||
private DailyTargetStatus farmingStatus;
|
||||
|
||||
private String excelStartDate;
|
||||
private String excelEndDate;
|
||||
}
|
||||
@@ -28,7 +28,6 @@ class UpdateFileDao implements UpdateFilePortOut {
|
||||
command.getType().getName()
|
||||
)));
|
||||
|
||||
|
||||
if (!deletedFileList.isEmpty()) {
|
||||
mapper.deleteFile(
|
||||
AuditUtil.delete(new UpdateUploadFileParam(
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
@@ -43,7 +44,9 @@ class GetAttachmentController {
|
||||
private String uploadStorageType;
|
||||
|
||||
@GetMapping(path = "/content-disposition/attachment/{fileId}")
|
||||
ResponseEntity<?> operate(@PathVariable Long fileId) throws MalformedURLException {
|
||||
ResponseEntity<?> operate(@PathVariable Long fileId,
|
||||
@RequestParam(value = "rename", required = false) String rename
|
||||
) throws MalformedURLException {
|
||||
|
||||
GetFile getFile;
|
||||
try {
|
||||
@@ -54,8 +57,17 @@ class GetAttachmentController {
|
||||
.body("파일을 찾을 수 없습니다: " + e.getMessage());
|
||||
}
|
||||
|
||||
int dot = getFile.getOriginName().lastIndexOf('.');
|
||||
String ext = (dot != -1) ? getFile.getOriginName().substring(dot) : "";
|
||||
|
||||
// rename이 있으면 이름 교체, 없으면 원본 유지
|
||||
String baseName = (rename != null && !rename.isBlank()) ? rename :
|
||||
(dot != -1 ? getFile.getOriginName().substring(0, dot) : getFile.getOriginName());
|
||||
|
||||
String fileName = baseName + ext;
|
||||
|
||||
// HTTP 헤더 설정
|
||||
String encodedFileName = URLEncoder.encode(getFile.getOriginName(), StandardCharsets.UTF_8)
|
||||
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8)
|
||||
.replace("+", "%20");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encodedFileName);
|
||||
|
||||
@@ -3,9 +3,12 @@ package app.module.core.usecase.uicode.view.adapters.persistence;
|
||||
import app.module.core.usecase.uicode.view.ports.application.domain.UICodeView;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mapper
|
||||
public interface UICodeViewMapper {
|
||||
Optional<UICodeView> findById(String id);
|
||||
List<UICodeView> findAllCodes(String parentId);
|
||||
List<UICodeView> findAllCodeTexts(String parentId);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@ package app.module.core.usecase.uicode.view.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UICodeView {
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="app.module.core.usecase.daily.dayGroup.adapters.persistence.DailyDayGroupMapper">
|
||||
|
||||
<select id="getDailyDayGroup" resultType="app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto">
|
||||
select
|
||||
group_no
|
||||
, start_day
|
||||
, end_day
|
||||
from daily_day_group
|
||||
where
|
||||
(start_day = CAST(#{searchDay} AS SMALLINT) or end_day = CAST(#{searchDay} AS SMALLINT))
|
||||
and
|
||||
is_deleted = false
|
||||
Limit 1
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getDailyDayGroupByGroupNo" resultType="app.module.core.usecase.daily.dayGroup.adapters.persistence.model.DailyDayGroupDto">
|
||||
select
|
||||
group_no
|
||||
, start_day
|
||||
, end_day
|
||||
from daily_day_group
|
||||
where
|
||||
group_no = #{groupNo}
|
||||
and
|
||||
is_deleted = false
|
||||
Limit 1
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -6,7 +6,7 @@
|
||||
resultType="app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto">
|
||||
select ddg.group_no, ddg.start_day, ddg.end_day
|
||||
, dr.id, dr.record_month, dr.day_group_no, dr.start_date, dr.end_date
|
||||
, dr.all_status, dr.income_status, dr.work_status, dr.expense_status, dr.power_status, dr.forestry_status, dr.farming_status
|
||||
, dr.all_status, dr.income_status, dr.work_status, dr.expense_status, dr.power_status, dr.forestry_status, dr.farming_status, dr.household_seq
|
||||
from daily_day_group ddg
|
||||
<if test="dailyRecordSeq == null">
|
||||
left join
|
||||
@@ -185,4 +185,74 @@
|
||||
and ddg.is_deleted = false
|
||||
</sql>
|
||||
|
||||
<select id="createDailyRecordExcel" resultType="long">
|
||||
WITH existing AS (
|
||||
SELECT id
|
||||
FROM daily_record
|
||||
WHERE household_seq = #{householdSeq}
|
||||
AND record_month = #{recordMonth}
|
||||
AND start_date = TO_DATE(#{recordMonth} || LPAD(#{excelStartDate}::text, 2, '0'), 'YYYYMMDD')
|
||||
),
|
||||
ins AS (
|
||||
INSERT INTO daily_record (
|
||||
household_seq, record_month, day_group_no, start_date, end_date,
|
||||
all_status, income_status, work_status, expense_status, power_status, forestry_status, farming_status,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
)
|
||||
SELECT
|
||||
#{householdSeq},
|
||||
#{recordMonth},
|
||||
g.group_no,
|
||||
TO_DATE(#{recordMonth} || LPAD(#{excelStartDate}::text, 2, '0'), 'YYYYMMDD'),
|
||||
TO_DATE(#{recordMonth} || LPAD(#{excelEndDate}::text, 2, '0'), 'YYYYMMDD'),
|
||||
#{allStatus}, #{incomeStatus}, #{workStatus}, #{expenseStatus}, #{powerStatus}, #{forestryStatus}, #{farmingStatus},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
FROM daily_day_group g
|
||||
WHERE g.is_deleted = false
|
||||
AND g.start_day = CAST(#{excelStartDate} AS smallint)
|
||||
AND NOT EXISTS (SELECT 1 FROM existing)
|
||||
RETURNING id
|
||||
)
|
||||
SELECT id FROM ins
|
||||
UNION ALL
|
||||
SELECT id FROM existing
|
||||
</select>
|
||||
|
||||
<update id="updateDailyRecordStatusExcel">
|
||||
update daily_record set <include refid="common.fields.UpdateBaseSet"/>
|
||||
<if test="allStatus != null and allStatus != ''">
|
||||
, all_status = #{allStatus}
|
||||
</if>
|
||||
<if test="targetType != null and targetType != ''">
|
||||
<choose>
|
||||
<when test="targetType eq 'INCOME'">
|
||||
, income_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'WORK'">
|
||||
, work_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'EXPENSE'">
|
||||
, expense_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'POWER'">
|
||||
, power_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'FORESTRY'">
|
||||
, forestry_status = #{targetStatus}
|
||||
</when>
|
||||
<when test="targetType eq 'FARMING'">
|
||||
, farming_status = #{targetStatus}
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
where is_deleted = false
|
||||
and id = #{dayGroupNo}
|
||||
</update>
|
||||
|
||||
<select id="getDailyDayGroup" resultType="app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto">
|
||||
select start_day, group_no
|
||||
from daily_day_group
|
||||
where is_deleted = false
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -21,4 +21,24 @@
|
||||
ORDER BY order_no ASC
|
||||
</select>
|
||||
|
||||
<select id="findAllCodes"
|
||||
resultType="app.module.core.usecase.uicode.view.ports.application.domain.UICodeView">
|
||||
/* findById : UICode 상세 조회 */
|
||||
SELECT id, code_value
|
||||
FROM uicode
|
||||
WHERE parent_id = #{parentId}
|
||||
AND is_deleted = false
|
||||
</select>
|
||||
|
||||
<select id="findAllCodeTexts"
|
||||
resultType="app.module.core.usecase.uicode.view.ports.application.domain.UICodeView">
|
||||
/* findById : UICode 상세 조회 */
|
||||
SELECT id, code_text
|
||||
FROM uicode
|
||||
WHERE parent_id = #{parentId}
|
||||
AND is_deleted = false
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1372,6 +1372,7 @@ CREATE TABLE public.daily_expense (
|
||||
deleted_at timestamp(6) NULL, -- 삭제일
|
||||
deleted_by varchar(255) NULL, -- 삭제자
|
||||
is_deleted bool DEFAULT false NULL, -- 삭제여부
|
||||
ocr_error_result bool DEFAULT false NULL, -- ORC판독오류유무
|
||||
CONSTRAINT daily_expense_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT fk_daily_expense__daily_record FOREIGN KEY (daily_record_seq) REFERENCES public.daily_record(id)
|
||||
);
|
||||
@@ -1399,6 +1400,7 @@ COMMENT ON COLUMN public.daily_expense.updated_by IS '수정자';
|
||||
COMMENT ON COLUMN public.daily_expense.deleted_at IS '삭제일';
|
||||
COMMENT ON COLUMN public.daily_expense.deleted_by IS '삭제자';
|
||||
COMMENT ON COLUMN public.daily_expense.is_deleted IS '삭제여부';
|
||||
COMMENT ON COLUMN public.daily_expense.ocr_error_result IS 'ORC판독오류유무';
|
||||
|
||||
|
||||
|
||||
@@ -1528,6 +1530,7 @@ CREATE TABLE public.daily_income (
|
||||
deleted_at timestamp(6) NULL, -- 삭제일
|
||||
deleted_by varchar(255) NULL, -- 삭제자
|
||||
is_deleted bool DEFAULT false NULL, -- 삭제여부
|
||||
ocr_error_result bool DEFAULT false NULL, -- ORC판독오류유무
|
||||
CONSTRAINT daily_income_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT fk_daily_income__daily_record FOREIGN KEY (daily_record_seq) REFERENCES public.daily_record(id)
|
||||
);
|
||||
@@ -1556,6 +1559,7 @@ COMMENT ON COLUMN public.daily_income.updated_by IS '수정자';
|
||||
COMMENT ON COLUMN public.daily_income.deleted_at IS '삭제일';
|
||||
COMMENT ON COLUMN public.daily_income.deleted_by IS '삭제자';
|
||||
COMMENT ON COLUMN public.daily_income.is_deleted IS '삭제여부';
|
||||
COMMENT ON COLUMN public.daily_income.ocr_error_result IS 'ORC판독오류유무';
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -57,4 +57,6 @@ public class CreateDailyExpenseReqVO extends DailyUIReqVO {
|
||||
* 현물평가액
|
||||
*/
|
||||
private Long estimatedValue;
|
||||
|
||||
private Boolean ocrErrorResult;
|
||||
}
|
||||
|
||||
@@ -21,27 +21,27 @@ public class CreateDailyExpenseValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyExpenseReqVO vo = (CreateDailyExpenseReqVO) target;
|
||||
|
||||
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"quantity", CommonConstants.VALID_CODE_NOTBLANK,
|
||||
"수량을 입력해 주세요.");
|
||||
} else if(vo.getQuantity() != null && vo.getQuantity() <= 0){
|
||||
errors.rejectValue(
|
||||
"quantity", CommonConstants.VALID_CODE_NOTZERO,
|
||||
"입력값은 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,
|
||||
// "수량을 입력해 주세요.");
|
||||
// } else if(vo.getQuantity() != null && vo.getQuantity() <= 0){
|
||||
// errors.rejectValue(
|
||||
// "quantity", CommonConstants.VALID_CODE_NOTZERO,
|
||||
// "입력값은 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(
|
||||
|
||||
@@ -132,7 +132,9 @@ public class DailyExpenseService implements DailyExpensePortIn {
|
||||
formVO.getUnitCode(),
|
||||
formVO.getUnitSelf(),
|
||||
formVO.getPrice(),
|
||||
formVO.getEstimatedValue()));
|
||||
formVO.getEstimatedValue(),
|
||||
formVO.getOcrErrorResult()
|
||||
));
|
||||
|
||||
portOut.create(findCmd, command);
|
||||
formVO.setId(command.getId());
|
||||
|
||||
@@ -31,4 +31,6 @@ public class CreateDailyExpenseCmd extends FrontAuditCommand {
|
||||
private String unitSelf;
|
||||
private Long price;
|
||||
private Long estimatedValue;
|
||||
private Boolean ocrErrorResult = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -60,4 +60,6 @@ public class CreateDailyIncomeReqVO extends DailyUIReqVO {
|
||||
* 현물평가액
|
||||
*/
|
||||
private Long estimatedValue;
|
||||
|
||||
private Boolean ocrErrorResult;
|
||||
}
|
||||
|
||||
@@ -21,27 +21,27 @@ public class CreateDailyIncomeValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyIncomeReqVO vo = (CreateDailyIncomeReqVO) target;
|
||||
|
||||
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"quantity", CommonConstants.VALID_CODE_NOTBLANK,
|
||||
"수량을 입력해 주세요.");
|
||||
} else if(vo.getQuantity() != null && vo.getQuantity() <= 0){
|
||||
errors.rejectValue(
|
||||
"quantity", CommonConstants.VALID_CODE_NOTZERO,
|
||||
"입력값은 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,
|
||||
// "수량을 입력해 주세요.");
|
||||
// } else if(vo.getQuantity() != null && vo.getQuantity() <= 0){
|
||||
// errors.rejectValue(
|
||||
// "quantity", CommonConstants.VALID_CODE_NOTZERO,
|
||||
// "입력값은 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(
|
||||
|
||||
@@ -136,7 +136,9 @@ public class DailyIncomeService implements DailyIncomePortIn {
|
||||
formVO.getUnitCode(),
|
||||
formVO.getUnitSelf(),
|
||||
formVO.getPrice(),
|
||||
formVO.getEstimatedValue()));
|
||||
formVO.getEstimatedValue(),
|
||||
formVO.getOcrErrorResult()
|
||||
));
|
||||
|
||||
|
||||
portOut.create(findCmd, command);
|
||||
|
||||
@@ -32,4 +32,5 @@ public class CreateDailyIncomeCmd extends FrontAuditCommand {
|
||||
private String unitSelf;
|
||||
private Long price;
|
||||
private Long estimatedValue;
|
||||
private Boolean ocrErrorResult = false;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
package app.module.front.usecase.daily.receipt.adapters.web;
|
||||
|
||||
import app.module.core.config.application.enums.DailyStatus;
|
||||
import app.module.core.config.application.enums.DailyTargetStatus;
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
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 app.module.core.usecase.file.createFile.ports.CreateFilePortIn;
|
||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile;
|
||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
|
||||
import app.module.core.usecase.file.saveToStorage.ports.SaveToStoragePortIn;
|
||||
import app.module.core.usecase.file.saveToStorage.ports.application.domain.SaveToStorage;
|
||||
import app.module.front.config.application.util.AuthUtil;
|
||||
import app.module.front.usecase.daily.expense.adapters.web.model.CreateDailyExpenseReqVO;
|
||||
import app.module.front.usecase.daily.expense.ports.DailyExpensePortIn;
|
||||
import app.module.front.usecase.daily.income.adapters.web.model.CreateDailyIncomeReqVO;
|
||||
@@ -33,8 +40,13 @@ import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -50,6 +62,12 @@ public class DailyReceiptController {
|
||||
private final DailyReceiptPortIn dailyReceiptPortIn;
|
||||
private final DailyExpensePortIn dailyExpensePortIn;
|
||||
|
||||
private final DailyDayGroupPortIn dailyDayGroupPortIn;
|
||||
|
||||
|
||||
private final DailyUtil dailyUtil;
|
||||
|
||||
private boolean errorItem = false;
|
||||
/**
|
||||
* 일계부 영수증 등록
|
||||
*/
|
||||
@@ -110,7 +128,7 @@ public class DailyReceiptController {
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param id 수입 일련번호
|
||||
* @param id 수입 일련번호(존재유무에 따라, create/update
|
||||
* @param reqVOList 영수증 데이터
|
||||
*/
|
||||
@PostMapping(path = "/{inputType}/{searchMonth}/{groupNo}/form/{id}")
|
||||
@@ -122,18 +140,56 @@ public class DailyReceiptController {
|
||||
@RequestPart(value = "reqVO") List<CreateReceiptFileReqVO> reqVOList,
|
||||
@RequestPart(value = "file") List<MultipartFile> files ) throws IOException {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
Map<String, Integer> addedDate = new HashMap<>();
|
||||
|
||||
this.errorItem = false;
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
|
||||
String judgeSearchMonth = searchMonth;
|
||||
String judgeGroupNo = groupNo;
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(judgeSearchMonth, judgeGroupNo);;
|
||||
|
||||
MultipartFile file = files.get(i);
|
||||
CreateReceiptFileReqVO createReceiptFileReqVO = reqVOList.get(i);
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
try {
|
||||
String ocrDateStr = createReceiptFileReqVO.getOcr().getDate();
|
||||
LocalDate ocrDate = LocalDate.parse(ocrDateStr, formatter);
|
||||
|
||||
LocalDate startDate = dailyRecord.getStartDate();
|
||||
LocalDate endDate = dailyRecord.getEndDate();
|
||||
|
||||
if (isBefore(today, createReceiptFileReqVO.getOcr().getDate())
|
||||
&& !(ocrDate.equals(startDate) || ocrDate.equals(endDate))
|
||||
) {
|
||||
|
||||
if (!dailyUtil.isEditable(createReceiptFileReqVO.getOcr().getDate())) {
|
||||
continue;
|
||||
}
|
||||
LocalDate date = LocalDate.parse(createReceiptFileReqVO.getOcr().getDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
judgeSearchMonth = String.format("%d%02d", date.getYear(), date.getMonthValue());
|
||||
int day = date.getDayOfMonth();
|
||||
DailyDayGroupDto dailyDayGroupDto = dailyDayGroupPortIn.detail(String.valueOf(day));
|
||||
|
||||
dailyRecord = getOtherDailyRecord(judgeSearchMonth, dailyDayGroupDto, inputType);
|
||||
judgeGroupNo = String.valueOf(dailyDayGroupDto.getGroupNo());
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("OCR Date ERROR : date={}", createReceiptFileReqVO.getOcr().getDate());
|
||||
}
|
||||
|
||||
// storage 에 물리적 파일 저장. `LOCAL` or `S3`
|
||||
SaveToStorage saveToStorage =
|
||||
saveToStoragePortIn
|
||||
.operate(createReceiptFileReqVO.getFileUploadType(), file)
|
||||
.orElseThrow(() -> new RuntimeException("물리적 파일 저장에 실패했습니다."));
|
||||
|
||||
|
||||
// DB 에 파일정보 저장
|
||||
CreateFile createFile =
|
||||
createFilePortIn
|
||||
@@ -151,19 +207,25 @@ public class DailyReceiptController {
|
||||
|
||||
// 1. 레코드 저장
|
||||
for(ReceiptItem item : createReceiptFileReqVO.getOcr().getItems()){
|
||||
|
||||
//날짜별 카운트 추가
|
||||
addedDate.merge(formatDateRange(dailyRecord.getStartDate(),dailyRecord.getEndDate()), 1, Integer::sum);
|
||||
|
||||
if("income".equals(inputType)) {
|
||||
CreateDailyIncomeReqVO formVO = new CreateDailyIncomeReqVO();
|
||||
formVO.setSearchMonth(searchMonth);
|
||||
formVO.setGroupNo(Integer.parseInt(groupNo));
|
||||
formVO.setSearchMonth(judgeSearchMonth);
|
||||
formVO.setGroupNo(Integer.parseInt(judgeGroupNo));
|
||||
formVO.setId(Long.parseLong(id));
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
formVO.setInputType(DailyInputType.OCR);
|
||||
formVO.setCredit(false);
|
||||
formVO.setSourcePurpose(createReceiptFileReqVO.getOcr().getStoreName());
|
||||
formVO.setIncomeKind(item.getName());
|
||||
formVO.setQuantity((double) item.getQuantity());
|
||||
formVO.setPrice((long) item.getTotalPrice());
|
||||
formVO.setSourcePurpose(limitLengthOrNull(createReceiptFileReqVO.getOcr().getStoreName(),100));
|
||||
formVO.setIncomeKind(limitLengthOrNull(item.getName(),100));
|
||||
|
||||
formVO.setQuantity(toDoubleOrNull(item.getQuantity()));
|
||||
formVO.setPrice(toLongOrNull(item.getTotalPrice()));
|
||||
log.debug("formVO: {}", formVO);
|
||||
formVO.setOcrErrorResult(this.errorItem);
|
||||
dailyIncomePortIn.create(formVO);
|
||||
//has 파일에 매핑 시키기
|
||||
dailyReceiptPortIn.insertReceiptMappingFile(new CreateReceiptHasFileReqVO(FileUploadType.INCOME.getName(),formVO.getId(),createFile.getId()));
|
||||
@@ -171,18 +233,18 @@ public class DailyReceiptController {
|
||||
}else if ("expense".equals(inputType)) {
|
||||
|
||||
CreateDailyExpenseReqVO formVO = new CreateDailyExpenseReqVO();
|
||||
formVO.setSearchMonth(searchMonth);
|
||||
formVO.setGroupNo(Integer.parseInt(groupNo));
|
||||
formVO.setSearchMonth(judgeSearchMonth);
|
||||
formVO.setGroupNo(Integer.parseInt(judgeGroupNo));
|
||||
formVO.setId(Long.parseLong(id));
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
formVO.setInputType(DailyInputType.OCR);
|
||||
|
||||
formVO.setCredit(false);
|
||||
formVO.setSourcePurpose(createReceiptFileReqVO.getOcr().getStoreName());
|
||||
formVO.setExpenseKind(item.getName());
|
||||
formVO.setQuantity((double) item.getQuantity());
|
||||
formVO.setPrice((long) item.getTotalPrice());
|
||||
|
||||
formVO.setSourcePurpose(limitLengthOrNull(createReceiptFileReqVO.getOcr().getStoreName(),100));
|
||||
formVO.setExpenseKind(limitLengthOrNull(item.getName(),100));
|
||||
formVO.setQuantity(toDoubleOrNull(item.getQuantity()));
|
||||
formVO.setPrice(toLongOrNull(item.getTotalPrice()));
|
||||
formVO.setOcrErrorResult(this.errorItem);
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyExpensePortIn.create(formVO);
|
||||
@@ -190,11 +252,23 @@ public class DailyReceiptController {
|
||||
//has 파일에 매핑 시키기
|
||||
dailyReceiptPortIn.insertReceiptMappingFile(new CreateReceiptHasFileReqVO(FileUploadType.EXPENSE.getName(),formVO.getId(),createFile.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
//DailyRecord 가 기존에 등록되어 있는경우 등록완료상태로 변경.
|
||||
if(!createReceiptFileReqVO.getOcr().getItems().isEmpty()){
|
||||
if("income".equals(inputType) && !dailyRecord.getIncomeStatus().equals(DailyTargetStatus.TARGET)) {
|
||||
dailyRecordPortIn.updateByStatus(dailyRecord.getRecordMonth(), dailyRecord.getGroupNo(), dailyRecord.getHouseholdSeq(), "INCOME", DailyTargetStatus.TARGET.name());
|
||||
}else if ("expense".equals(inputType) && !dailyRecord.getExpenseStatus().equals(DailyTargetStatus.TARGET)) {
|
||||
dailyRecordPortIn.updateByStatus(dailyRecord.getRecordMonth(), dailyRecord.getGroupNo(), dailyRecord.getHouseholdSeq(), "EXPENSE", DailyTargetStatus.TARGET.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("list", addedDate);
|
||||
body.put("error", this.errorItem);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,4 +296,129 @@ public class DailyReceiptController {
|
||||
}
|
||||
return dailyRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* otherDailyRecord
|
||||
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto getOtherDailyRecord(String searchMonth, DailyDayGroupDto dailyDayGroupDto, String inputType) {
|
||||
Long userSeq = AuthUtil.getUserSeq();
|
||||
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(searchMonth, dailyDayGroupDto.getGroupNo(), userSeq);
|
||||
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
CreateDailyRecordReqVO createDailyRecordReqVO = new CreateDailyRecordReqVO();
|
||||
createDailyRecordReqVO.setTodayNone("N");
|
||||
createDailyRecordReqVO.setAllStatus(DailyStatus.DONE);
|
||||
|
||||
if(inputType.equals("expense")) {
|
||||
createDailyRecordReqVO.setExpenseStatus(DailyTargetStatus.TARGET);
|
||||
} else {
|
||||
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(userSeq);
|
||||
|
||||
dailyRecordPortIn.create(createDailyRecordReqVO);
|
||||
|
||||
dailyRecord = dailyRecordPortIn.detail(searchMonth, dailyDayGroupDto.getGroupNo(), userSeq);
|
||||
}
|
||||
return dailyRecord;
|
||||
}
|
||||
|
||||
|
||||
public Double toDoubleOrNull(Object value) {
|
||||
if (value == null) {
|
||||
this.errorItem = true;
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if(value.toString().trim().equals("0")){
|
||||
this.errorItem = true;
|
||||
return null;
|
||||
}
|
||||
return Double.valueOf(value.toString().trim());
|
||||
} catch (NumberFormatException e) {
|
||||
this.errorItem = true;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Long toLongOrNull(Object value) {
|
||||
if (value == null) {
|
||||
this.errorItem = true;
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if(value.toString().trim().equals("0")){
|
||||
this.errorItem = true;
|
||||
return null;
|
||||
}
|
||||
return Long.valueOf(value.toString().trim());
|
||||
} catch (NumberFormatException e) {
|
||||
this.errorItem = true;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String limitLengthOrNull(String value, int maxLength) {
|
||||
if (value == null) {
|
||||
this.errorItem = true;
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
String trimmed = value.trim();
|
||||
if(trimmed.length() > maxLength || trimmed.isEmpty()){
|
||||
this.errorItem = true;
|
||||
return null;
|
||||
} else {
|
||||
return trimmed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
public boolean isBefore(LocalDate a, String b) {
|
||||
|
||||
if (a == null || b == null) {
|
||||
this.errorItem = true;
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
LocalDate dateB = LocalDate.parse(b, FORMATTER);
|
||||
if(dateB.isBefore(a)){
|
||||
return true;
|
||||
} else {
|
||||
this.errorItem = true;
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.errorItem = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String formatDateRange(LocalDate a, LocalDate b) {
|
||||
if (a == null) return "";
|
||||
|
||||
int month = a.getMonthValue();
|
||||
int dayA = a.getDayOfMonth();
|
||||
|
||||
// b가 null이거나 a와 같으면 "7월 5일"
|
||||
if (b == null || a.equals(b)) {
|
||||
return String.format("%d월 %d일", month, dayA);
|
||||
}
|
||||
|
||||
// a와 b가 다르면 "7월 5~6일"
|
||||
int dayB = b.getDayOfMonth();
|
||||
return String.format("%d월 %d~%d일", month, dayA, dayB);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user