[FO] 일계부 자가임업 CRUD, 공통 수정

This commit is contained in:
김현주
2025-06-20 15:11:38 +09:00
parent 14fc4e1886
commit e434e4240e
30 changed files with 1235 additions and 51 deletions

View File

@@ -25,7 +25,7 @@ public class DailyExpenseController {
private final CoreUtil coreUtil;
private final DailyRecordPortIn dailyRecordService;
private final DailyExpensePortIn dailyExpensePortIn;
private final CreateDailyExpenseValidator createDailyExpenseValidator;
private final CreateDailyExpenseValidator createValidator;
/**
* 일계부 지출 등록 처리
@@ -35,14 +35,13 @@ public class DailyExpenseController {
* @param id 수입 일련번호
* @param formVO 입력 데이터
* @param bindingResult BindingResult
* @return
*/
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @PathVariable("id") String id
, @Valid @RequestBody CreateDailyExpenseReqVO formVO, BindingResult bindingResult) {
createDailyExpenseValidator.validate(formVO, bindingResult);
createValidator.validate(formVO, bindingResult);
if (bindingResult.hasErrors()) {
return coreUtil.getErrorInfo(bindingResult);
}
@@ -67,7 +66,6 @@ public class DailyExpenseController {
* @param groupNo 검색 그룹
* @param formVO 입력 데이터
* @param bindingResult BindingResult
* @return
*/
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
@@ -96,7 +94,6 @@ public class DailyExpenseController {
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @return
*/
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
@@ -119,7 +116,6 @@ public class DailyExpenseController {
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @return
*/
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);

View File

@@ -37,7 +37,6 @@ public class DailyExpenseUIController {
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @param searchType 수정여부
* @return
*/
@GetMapping(path = "/{searchMonth}/{groupNo}")
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
@@ -66,7 +65,6 @@ public class DailyExpenseUIController {
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @param id 수입 일련번호
* @return
*/
@GetMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
public String formBySelf(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
@@ -102,7 +100,6 @@ public class DailyExpenseUIController {
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @return
*/
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);

View File

@@ -12,7 +12,7 @@ import lombok.ToString;
@ToString(callSuper = true)
public class CreateDailyExpenseReqVO extends DailyUIReqVO {
/**
* 수입 일련번호
* 지출 일련번호
*/
private Long id;
/**

View File

@@ -23,7 +23,7 @@ public class DailyExpenseUIReqVO extends DailyUIReqVO {
}
/**
* 수입 일련번호
* 지출 일련번호
*/
private Long id;
}

View File

@@ -11,7 +11,7 @@ import lombok.ToString;
@ToString(callSuper = true)
public class RemoveDailyExpenseReqVO extends DailyUIReqVO {
/**
* 수입 일련번호
* 지출 일련번호
*/
@NotBlank(message = "{valid.common.required}")
private String id;

View File

@@ -21,7 +21,7 @@ public class GetDailyExpenseCmd {
*/
private Long householdSeq;
/**
* 수입 일련번호
* 지출 일련번호
*/
private Long id;
}

View File

@@ -0,0 +1,48 @@
package app.module.front.usecase.daily.forestry.adapters.persistence;
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortOut;
import app.module.front.usecase.daily.forestry.ports.application.domain.CreateDailyForestryCmd;
import app.module.front.usecase.daily.forestry.ports.application.domain.GetDailyForestryCmd;
import app.module.front.usecase.daily.forestry.ports.application.domain.RemoveDailyForestryCmd;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.util.List;
@Slf4j
@Repository
@RequiredArgsConstructor
public class DailyForestryDao implements DailyForestryPortOut {
private final DailyForestryMapper mapper;
@Override
public List<DailyForestryDto> list(GetDailyForestryCmd command) {
return mapper.getDailyForestryList(command);
}
@Override
public void create(GetDailyForestryCmd findCmd, CreateDailyForestryCmd command) {
Integer existCount = mapper.getRecordExistCount(findCmd);
if (existCount == 0) {
mapper.createDailyForestry(command);
log.debug("[CreateDailyForestry] record={}", command);
} else {
mapper.updateDailyForestry(command);
log.debug("[UpdateDailyForestry] record={}", command);
}
}
@Override
public void remove(GetDailyForestryCmd findCmd, RemoveDailyForestryCmd command) {
Integer existCount = mapper.getRecordExistCount(findCmd);
if (existCount != 0) {
mapper.removeDailyForestry(command);
log.debug("[RemoveDailyForestry] record={}", command);
}
}
}

View File

@@ -0,0 +1,50 @@
package app.module.front.usecase.daily.forestry.adapters.persistence;
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
import app.module.front.usecase.daily.forestry.ports.application.domain.CreateDailyForestryCmd;
import app.module.front.usecase.daily.forestry.ports.application.domain.GetDailyForestryCmd;
import app.module.front.usecase.daily.forestry.ports.application.domain.RemoveDailyForestryCmd;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface DailyForestryMapper {
/**
* 일계부 자가임업 목록 조회
*
* @param command 검색 조건
* @return 수입 목록
*/
List<DailyForestryDto> getDailyForestryList(GetDailyForestryCmd command);
/**
* 일계부 자가임업 데이터 존재 여부
*
* @param command 검색 조건
* @return 중복 개수
*/
Integer getRecordExistCount(GetDailyForestryCmd command);
/**
* 일계부 자가임업 등록
*
* @param command 등록 데이터
*/
void createDailyForestry(CreateDailyForestryCmd command);
/**
* 일계부 자가임업 수정
*
* @param command 수정 데이터
*/
void updateDailyForestry(CreateDailyForestryCmd command);
/**
* 일계부 자가임업 삭제
*
* @param command 삭제 데이터
*/
void removeDailyForestry(RemoveDailyForestryCmd command);
}

View File

@@ -0,0 +1,26 @@
package app.module.front.usecase.daily.forestry.adapters.persistence.model;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DailyForestryDto {
private Long id;
private Long dailyRecordSeq;
private String productName;
private String usage;
private String quantity;
private String unitCode;
private String unitLabel;
private String unitSelf;
private Integer estimatedValue;
/**
* 수정 가능 여부
* @return true=가능, false=불가능(등록 상태)
*/
public boolean isUpdated() {
return this.id != null && this.id != 0L;
}
}

View File

@@ -0,0 +1,131 @@
package app.module.front.usecase.daily.forestry.adapters.web;
import app.module.core.config.application.exception.NoRecordDataException;
import app.module.core.config.application.util.CoreUtil;
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
import app.module.front.usecase.daily.forestry.adapters.web.model.RemoveDailyForestryReqVO;
import app.module.front.usecase.daily.forestry.adapters.web.validator.CreateDailyForestryValidator;
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortIn;
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(path = "/api/record/forestry")
public class DailyForestryController {
private final CoreUtil coreUtil;
private final DailyRecordPortIn dailyRecordService;
private final DailyForestryPortIn dailyForestryPortIn;
private final CreateDailyForestryValidator createValidator;
/**
* 일계부 자가임업 등록 처리
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @param id 수입 일련번호
* @param formVO 입력 데이터
* @param bindingResult BindingResult
*/
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @PathVariable("id") String id
, @Valid @RequestBody CreateDailyForestryReqVO formVO, BindingResult bindingResult) {
createValidator.validate(formVO, bindingResult);
if (bindingResult.hasErrors()) {
return coreUtil.getErrorInfo(bindingResult);
}
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
formVO.setSearchMonth(searchMonth);
formVO.setGroupNo(Integer.parseInt(groupNo));
formVO.setId(Long.parseLong(id));
formVO.setDailyRecordSeq(dailyRecord.getId());
log.debug("formVO: {}", formVO);
dailyForestryPortIn.create(formVO);
return ResponseEntity.status(HttpStatus.OK).body(formVO);
}
/**
* 일계부 자가임업 삭제 처리
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @param formVO 입력 데이터
* @param bindingResult BindingResult
*/
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @Valid @RequestBody RemoveDailyForestryReqVO formVO, BindingResult bindingResult) {
log.debug("before formVO: {}", formVO);
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());
}
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
log.debug("formVO: {}", formVO);
dailyForestryPortIn.remove(formVO);
return ResponseEntity.status(HttpStatus.OK).body(formVO);
}
/**
* 일계부 자가임업 전체 삭제 처리
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
*/
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
RemoveDailyForestryReqVO formVO = new RemoveDailyForestryReqVO();
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
log.debug("formVO: {}", formVO);
dailyForestryPortIn.remove(formVO);
return ResponseEntity.status(HttpStatus.OK).body(formVO);
}
/**
* 일계부 유효성 체크 및 데이터 조회
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
*/
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
log.debug("getRecordUIReq: {}", reqVO);
DailyRecordDto dailyRecord = dailyRecordService.detail(reqVO);
if (dailyRecord == null || dailyRecord.getId() == null) {
throw new NoRecordDataException();
}
return dailyRecord;
}
}

View File

@@ -0,0 +1,115 @@
package app.module.front.usecase.daily.forestry.adapters.web;
import app.module.core.config.application.exception.NoRecordDataException;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
import app.module.front.usecase.daily.forestry.adapters.web.model.DailyForestryUIReqVO;
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortIn;
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.adapters.web.model.DailySort;
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.thymeleaf.util.StringUtils;
import java.util.List;
@Slf4j
@Controller
@RequiredArgsConstructor
@RequestMapping(path = "/record/forestry")
public class DailyForestryUIController {
private final UICodeListPortIn uiCodeListPortIn;
private final DailyRecordPortIn dailyRecordPortIn;
private final DailyForestryPortIn dailyForestryPortIn;
/**
* 일계부 자가임업 목록 화면
*
* @param model Model
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @param searchType 수정여부
*/
@GetMapping(path = "/{searchMonth}/{groupNo}")
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @RequestParam(name = "type", required = false) String searchType) {
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
DailyForestryUIReqVO reqVO = new DailyForestryUIReqVO(searchMonth, groupNo);
log.debug("reqVO: {}", reqVO);
List<DailyForestryDto> forestryList = dailyForestryPortIn.list(reqVO);
model.addAttribute("reqVO", reqVO);
model.addAttribute("dailyRecord", dailyRecord);
model.addAttribute("forestryList", forestryList);
model.addAttribute("moveStep", !"update".equals(searchType));
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.FORESTRY));
return "record/forestry/index";
}
/**
* 일계부 자가임업 등록 화면
*
* @param model Model
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @param id 수입 일련번호
*/
@GetMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
public String formBySelf(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @PathVariable("id") String id) {
DailyForestryUIReqVO reqVO = new DailyForestryUIReqVO(searchMonth, groupNo);
if (StringUtils.isEmpty(id)) {
reqVO.setId(0L);
} else {
reqVO.setId(Long.parseLong(id));
}
log.debug("reqVO: {}", reqVO);
DailyForestryDto detail = new DailyForestryDto();
if (reqVO.getId() != 0L) {
detail = dailyForestryPortIn.detail(reqVO);
if (detail == null || !detail.isUpdated()) {
throw new NoRecordDataException();
}
}
model.addAttribute("recordCrop", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("recordUnit", uiCodeListPortIn.connect("code.record.unit"));
model.addAttribute("reqVO", reqVO);
model.addAttribute("detail", detail);
return "record/forestry/form";
}
/**
* 일계부 유효성 체크 및 데이터 조회
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
*/
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
log.debug("getRecordUIReq: {}", reqVO);
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(reqVO);
if (dailyRecord == null || dailyRecord.getId() == null) {
throw new NoRecordDataException();
}
return dailyRecord;
}
}

View File

@@ -0,0 +1,46 @@
package app.module.front.usecase.daily.forestry.adapters.web.model;
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString(callSuper = true)
public class CreateDailyForestryReqVO extends DailyUIReqVO {
/**
* 자가임업 일련번호
*/
private Long id;
/**
* 일계부 일련번호
*/
private Long dailyRecordSeq;
/**
* 생산물
*/
@NotBlank(message = "생산물을 입력해 주세요.")
private String productName;
/**
* 용도
*/
private String usage;
/**
* 수량
*/
private Double quantity;
/**
* 단위 코드
*/
private String unitCode;
/**
* 단위 직접 입력
*/
private String unitSelf;
/**
* 현물평가액
*/
private Integer estimatedValue;
}

View File

@@ -0,0 +1,24 @@
package app.module.front.usecase.daily.forestry.adapters.web.model;
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.tika.utils.StringUtils;
@Getter
@Setter
@ToString(callSuper = true)
public class DailyForestryUIReqVO extends DailyUIReqVO {
public DailyForestryUIReqVO(String month, String no) {
setSearchMonth(month);
if (!StringUtils.isBlank(no)) {
setGroupNo(Integer.parseInt(no));
}
}
/**
* 자가임업 일련번호
*/
private Long id;
}

View File

@@ -0,0 +1,22 @@
package app.module.front.usecase.daily.forestry.adapters.web.model;
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString(callSuper = true)
public class RemoveDailyForestryReqVO extends DailyUIReqVO {
/**
* 자가임업 일련번호
*/
@NotBlank(message = "{valid.common.required}")
private String id;
/**
* 일계부 일련번호
*/
private Long dailyRecordSeq;
}

View File

@@ -0,0 +1,29 @@
package app.module.front.usecase.daily.forestry.adapters.web.validator;
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
import lombok.RequiredArgsConstructor;
import org.apache.tika.utils.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
@Component
@RequiredArgsConstructor
public class CreateDailyForestryValidator implements Validator {
@Override
public boolean supports(Class<?> clazz) {
return CreateDailyForestryReqVO.class.equals(clazz);
}
@Override
public void validate(Object target, Errors errors) {
CreateDailyForestryReqVO vo = (CreateDailyForestryReqVO) target;
if (vo.getEstimatedValue() == null) {
errors.rejectValue(
"estimatedValue", "valid.common.required",
"현물평가액을 입력해 주세요.");
}
}
}

View File

@@ -0,0 +1,40 @@
package app.module.front.usecase.daily.forestry.ports;
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
import app.module.front.usecase.daily.forestry.adapters.web.model.DailyForestryUIReqVO;
import app.module.front.usecase.daily.forestry.adapters.web.model.RemoveDailyForestryReqVO;
import java.util.List;
public interface DailyForestryPortIn {
/**
* 일계부 자가임업 조회
*
* @param reqVO 검색 조건
* @return 자가임업 목록
*/
List<DailyForestryDto> list(DailyForestryUIReqVO reqVO);
/**
* 일계부 자가임업 조회
*
* @param reqVO 검색 조건
* @return 자가임업 상세
*/
DailyForestryDto detail(DailyForestryUIReqVO reqVO);
/**
* 일계부 자가임업 등록
*
* @param formVO 입력 데이터
*/
void create(CreateDailyForestryReqVO formVO);
/**
* 일계부 자가임업 삭제
*
* @param formVO 삭제 검색 조건
*/
void remove(RemoveDailyForestryReqVO formVO);
}

View File

@@ -0,0 +1,34 @@
package app.module.front.usecase.daily.forestry.ports;
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
import app.module.front.usecase.daily.forestry.ports.application.domain.CreateDailyForestryCmd;
import app.module.front.usecase.daily.forestry.ports.application.domain.GetDailyForestryCmd;
import app.module.front.usecase.daily.forestry.ports.application.domain.RemoveDailyForestryCmd;
import java.util.List;
public interface DailyForestryPortOut {
/**
* 일계부 자가임업 조회
*
* @param command 검색 조건
* @return 자가임업 목록
*/
List<DailyForestryDto> list(GetDailyForestryCmd command);
/**
* 일계부 자가임업 등록
*
* @param findCmd 검색 조건
* @param command 입력 데이터
*/
void create(GetDailyForestryCmd findCmd, CreateDailyForestryCmd command);
/**
* 일계부 자가임업 삭제
*
* @param findCmd 검색 조건
* @param command 삭제 검색 조건
*/
void remove(GetDailyForestryCmd findCmd, RemoveDailyForestryCmd command);
}

View File

@@ -0,0 +1,129 @@
package app.module.front.usecase.daily.forestry.ports.application;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
import app.module.front.config.application.util.AuditUtil;
import app.module.front.config.constants.CommonConstants;
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
import app.module.front.usecase.daily.forestry.adapters.web.model.DailyForestryUIReqVO;
import app.module.front.usecase.daily.forestry.adapters.web.model.RemoveDailyForestryReqVO;
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortIn;
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortOut;
import app.module.front.usecase.daily.forestry.ports.application.domain.CreateDailyForestryCmd;
import app.module.front.usecase.daily.forestry.ports.application.domain.GetDailyForestryCmd;
import app.module.front.usecase.daily.forestry.ports.application.domain.RemoveDailyForestryCmd;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
@RequiredArgsConstructor
public class DailyForestryService implements DailyForestryPortIn {
private final DailyForestryPortOut portOut;
private final UICodeListPortIn uiCodeListPortIn;
@Override
public List<DailyForestryDto> list(DailyForestryUIReqVO reqVO) {
return this.getRefineList(reqVO);
}
@Override
public DailyForestryDto detail(DailyForestryUIReqVO reqVO) {
List<DailyForestryDto> list = this.getRefineList(reqVO);
if (list.isEmpty()) {
return null;
}
return list.get(0);
}
/**
* 목록 데이터 조회
*
* @param reqVO 검색 조건
* @return 공통 처리된 목록
*/
private List<DailyForestryDto> getRefineList(DailyForestryUIReqVO reqVO) {
List<DailyForestryDto> list = portOut.list(new GetDailyForestryCmd(reqVO.getSearchMonth(),
reqVO.getGroupNo(),
reqVO.getHouseholdSeq(),
reqVO.getId()));
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
for (DailyForestryDto dto : list) {
if (CommonConstants.UNIT_CODE_SELF.equals(dto.getUnitCode())) {
dto.setUnitLabel(dto.getUnitSelf());
} else {
dto.setUnitLabel(this.getCodeLabel(dto.getUnitCode(), recordUnit));
}
}
return list;
}
/**
* 코드명 조회
*
* @param codeId 코드
* @param codeList 공통 코드 목록
* @return 코드명
*/
private String getCodeLabel(String codeId, List<UICodeElement> codeList) {
String returnValue = null;
for (UICodeElement codeSetup : codeList) {
if (codeSetup.getId().equalsIgnoreCase(codeId)) {
returnValue = codeSetup.getCodeText();
break;
}
}
return returnValue;
}
@Override
public void create(CreateDailyForestryReqVO formVO) {
GetDailyForestryCmd findCmd = new GetDailyForestryCmd(
formVO.getSearchMonth(),
formVO.getGroupNo(),
formVO.getHouseholdSeq(),
formVO.getId());
CreateDailyForestryCmd command = AuditUtil.create(
new CreateDailyForestryCmd(
formVO.getId(),
formVO.getDailyRecordSeq(),
"81011", // [정책] 81011 고정
formVO.getProductName(),
formVO.getUsage(),
formVO.getQuantity(),
formVO.getUnitCode(),
formVO.getUnitSelf(),
formVO.getEstimatedValue()));
portOut.create(findCmd, command);
}
@Override
public void remove(RemoveDailyForestryReqVO formVO) {
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
GetDailyForestryCmd findCmd = new GetDailyForestryCmd(
formVO.getSearchMonth(),
formVO.getGroupNo(),
formVO.getHouseholdSeq(),
id);
RemoveDailyForestryCmd command = AuditUtil.delete(
new RemoveDailyForestryCmd(
formVO.getSearchMonth(),
formVO.getGroupNo(),
id,
formVO.getDailyRecordSeq()));
portOut.remove(findCmd, command);
}
}

View File

@@ -0,0 +1,23 @@
package app.module.front.usecase.daily.forestry.ports.application.domain;
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@AllArgsConstructor
@ToString
public class CreateDailyForestryCmd extends FrontAuditCommand {
private Long id;
private Long dailyRecordSeq;
private String expenseMark;
private String productName;
private String usage;
private Double quantity;
private String unitCode;
private String unitSelf;
private Integer estimatedValue;
}

View File

@@ -0,0 +1,27 @@
package app.module.front.usecase.daily.forestry.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class GetDailyForestryCmd {
/**
* 검색 월(yyyyMM)
*/
private String searchMonth;
/**
* 검색 그룸번호
*/
private Integer groupNo;
/**
* 임가 일련번호
*/
private Long householdSeq;
/**
* 자가임업 일련번호
*/
private Long id;
}

View File

@@ -0,0 +1,18 @@
package app.module.front.usecase.daily.forestry.ports.application.domain;
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@AllArgsConstructor
@ToString
public class RemoveDailyForestryCmd extends FrontAuditCommand {
private String searchMonth;
private Integer groupNo;
private Long id;
private Long dailyRecordSeq;
}

View File

@@ -7,7 +7,6 @@ import app.module.front.usecase.daily.income.adapters.web.model.RemoveDailyIncom
import app.module.front.usecase.daily.income.adapters.web.validator.CreateDailyIncomeValidator;
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
import jakarta.validation.Valid;
@@ -18,9 +17,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@RestController
@RequiredArgsConstructor
@@ -29,7 +25,7 @@ public class DailyIncomeController {
private final CoreUtil coreUtil;
private final DailyRecordPortIn dailyRecordPortIn;
private final DailyIncomePortIn dailyIncomePortIn;
private final CreateDailyIncomeValidator createDailyIncomeValidator;
private final CreateDailyIncomeValidator createValidator;
/**
* 일계부 수입 등록 처리
@@ -45,7 +41,7 @@ public class DailyIncomeController {
, @PathVariable("id") String id
, @Valid @RequestBody CreateDailyIncomeReqVO formVO, BindingResult bindingResult) {
createDailyIncomeValidator.validate(formVO, bindingResult);
createValidator.validate(formVO, bindingResult);
if (bindingResult.hasErrors()) {
return coreUtil.getErrorInfo(bindingResult);
}

View File

@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping(path = "/api/record/daily")
public class DailyRecordController {
private final DailyRecordPortIn dailyRecordPortIn;
private final CreateDailyRecordValidator createDailyRecordValidator;
private final CreateDailyRecordValidator createValidator;
/**
* 일계부 항목 등록 처리
@@ -34,7 +34,7 @@ public class DailyRecordController {
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @Valid @RequestBody CreateDailyRecordReqVO formVO, BindingResult bindingResult) {
createDailyRecordValidator.validate(formVO, bindingResult);
createValidator.validate(formVO, bindingResult);
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());

View File

@@ -3,6 +3,8 @@ package app.module.front.usecase.daily.record.adapters.web;
import app.module.core.config.application.exception.NoMatchingURIException;
import app.module.front.usecase.daily.expense.adapters.web.model.DailyExpenseUIReqVO;
import app.module.front.usecase.daily.expense.ports.DailyExpensePortIn;
import app.module.front.usecase.daily.forestry.adapters.web.model.DailyForestryUIReqVO;
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortIn;
import app.module.front.usecase.daily.income.adapters.persistence.model.DailyIncomeDto;
import app.module.front.usecase.daily.income.adapters.web.model.DailyIncomeUIReqVO;
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
@@ -13,6 +15,8 @@ import app.module.front.usecase.daily.record.adapters.web.model.DailyStatus;
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
import app.module.front.usecase.daily.record.adapters.web.validator.CreateDailyRecordValidator;
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
import app.module.front.usecase.daily.work.adapters.web.model.DailyWorkUIReqVO;
import app.module.front.usecase.daily.work.ports.DailyWorkPortIn;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
@@ -31,7 +35,9 @@ public class DailyRecordUIController {
private final DailyRecordPortIn dailyRecordPortIn;
private final DailyIncomePortIn dailyIncomePortIn;
private final DailyExpensePortIn dailyExpensePortIn;
private final DailyWorkPortIn dailyWorkPortIn;
private final DailyPowerPortIn dailyPowerPortIn;
private final DailyForestryPortIn dailyForestryPortIn;
/**
* 일계부 항목 등록 화면
@@ -83,9 +89,9 @@ public class DailyRecordUIController {
} else {
model.addAttribute("incomeList", dailyIncomePortIn.list(new DailyIncomeUIReqVO(searchMonth, groupNo)));
model.addAttribute("expenseList", dailyExpensePortIn.list(new DailyExpenseUIReqVO(searchMonth, groupNo)));
model.addAttribute("workList", null); // TODO
model.addAttribute("workList", dailyWorkPortIn.list(new DailyWorkUIReqVO(searchMonth, groupNo)));
model.addAttribute("powerList", dailyPowerPortIn.list(new DailyPowerUIReqVO(searchMonth, groupNo)));
model.addAttribute("forestryList", null); // TODO
model.addAttribute("forestryList", dailyForestryPortIn.list(new DailyForestryUIReqVO(searchMonth, groupNo)));
model.addAttribute("farmingList", null); // TODO
}

View File

@@ -2,7 +2,12 @@ package app.module.front.usecase.daily.work.adapters.persistence.model;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
@Slf4j
@Getter
@Setter
public class DailyWorkDto {
@@ -38,4 +43,24 @@ public class DailyWorkDto {
public boolean isUpdated() {
return this.id != null && this.id != 0L;
}
public BigDecimal getTotalHour() {
BigDecimal totalHour = BigDecimal.ZERO;
try {
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.ownerTime, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.spouseTime, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.familyMHours, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.familyFHours, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.hiredMHours, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.hiredFHours, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.sharedMHours, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.sharedFHours, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.volunteerMHours, "0")));
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.volunteerFHours, "0")));
} catch (Exception e) {
log.warn("[DataParse] work BigDecimal.", e);
}
return totalHour;
}
}

View File

@@ -0,0 +1,70 @@
<?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.front.usecase.daily.forestry.adapters.persistence.DailyForestryMapper">
<select id="getDailyForestryList"
resultType="app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto">
select ds.id, ds.daily_record_seq
, ds.product_name, ds.usage
, ds.quantity, ds.unit_code, ds.unit_self, ds.estimated_value
from daily_forestry ds
<include refid="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
where ds.is_deleted = false
<if test="id != null and id != '0'">
and ds.id = ${id}
</if>
order by
ds.id desc
</select>
<select id="getRecordExistCount" resultType="int">
select count(1)
from daily_forestry ds
<include refid="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
where ds.is_deleted = false
<if test="id != null and id != '0'">
and ds.id = ${id}
</if>
</select>
<insert id="createDailyForestry" useGeneratedKeys="true" keyProperty="id">
insert into daily_forestry (
daily_record_seq, expense_mark
, product_name, usage
, quantity, unit_code, unit_self, estimated_value
, is_deleted
, <include refid="common.fields.CreateUpdateBaseColumns"/>
) values (
#{dailyRecordSeq}, #{expenseMark}
, #{productName}, #{usage}
, #{quantity}, #{unitCode}, #{unitSelf}, #{estimatedValue}
, false
, <include refid="common.fields.CreateUpdateBaseValues"/>
)
</insert>
<update id="updateDailyForestry">
update daily_forestry set <include refid="common.fields.UpdateBaseSet"/>
, expense_mark = #{expenseMark}
, product_name = #{productName}
, usage = #{usage}
, quantity = #{quantity}
, unit_code = #{unitCode}
, unit_self = #{unitSelf}
, estimated_value = #{estimatedValue}
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
and id = #{id}
</update>
<update id="removeDailyForestry">
update daily_forestry set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
<if test="id != null and id != ''">
and id = #{id}
</if>
</update>
</mapper>

View File

@@ -30,8 +30,11 @@
<div class="list-item"
th:each="item, itemStatus : ${dailyRecord.targetList}"
th:classappend="${(item.name eq 'INCOME' && #lists.isEmpty(incomeList))
|| (item.name eq 'WORK' && #lists.isEmpty(workList))
|| (item.name eq 'EXPENSE' && #lists.isEmpty(expenseList))
|| (item.name eq 'POWER' && #lists.isEmpty(powerList))} ? 'no-data'"
|| (item.name eq 'POWER' && #lists.isEmpty(powerList))
|| (item.name eq 'FORESTRY' && #lists.isEmpty(forestryList))
|| (item.name eq 'FARMING' && #lists.isEmpty(farmingList))} ? 'no-data'"
>
<div class="item-tit-group">
<p class="item-name">[[${item.desc}]]</p>
@@ -47,7 +50,7 @@
</th:block>
<th:block th:each="child, childStatus : ${incomeList}">
<li>
<p>[[${child.categorySelf}]]</p>
<p>[[${child.incomeKind}]]</p>
<span th:if="${not #strings.isEmpty(child.price)}"
th:text="|${#numbers.formatInteger(child.price, 1, 'COMMA')}원|">302,000원</span>
<span th:if="${not #strings.isEmpty(child.estimatedValue)}"
@@ -66,7 +69,7 @@
</th:block>
<th:block th:each="child, childStatus : ${expenseList}">
<li>
<p>[[${child.categorySelf}]]</p>
<p>[[${child.expenseKind}]]</p>
<span th:if="${not #strings.isEmpty(child.price)}"
th:text="|${#numbers.formatInteger(child.price, 1, 'COMMA')}원|">302,000원</span>
<span th:if="${not #strings.isEmpty(child.estimatedValue)}"
@@ -74,8 +77,8 @@
</li>
</th:block>
</ul>
<!--/* TODO 임업노동 투입 */-->
<!--/*<ul class="detail-list"
<!--/* 임업노동 투입 */-->
<ul class="detail-list"
th:if="${item.name eq 'WORK'}"
>
<th:block th:if="${#strings.isEmpty(workList)}">
@@ -85,28 +88,14 @@
</th:block>
<th:block th:each="child, childStatus : ${workList}">
<li>
<p>호두</p>
<p>[[${child.itemName}]]</p>
<span>
<span>수확</span>
<span>총 23시간</span>
</span>
</li>
<li>
<p>밤</p>
<span>
<span>줍기</span>
<span>총 12시간</span>
</span>
</li>
<li>
<p>밤</p>
<span>
<span>선별</span>
<span>총 2시간</span>
<span>[[${child.workName}]]</span>
<span>총 [[${child.totalHour}]]시간</span>
</span>
</li>
</th:block>
</ul>*/-->
</ul>
<!--/* 동력 사용시간 */-->
<ul class="detail-list"
th:if="${item.name eq 'POWER'}"
@@ -120,13 +109,29 @@
<li>
<p>[[${child.equipmentName}]]</p>
<span th:if="${not #strings.isEmpty(child.ownedHours)}"
th:text="|총${#numbers.formatInteger(child.ownedHours, 1, 'COMMA')}시간|">총8시간</span>
th:text="|총 ${#numbers.formatInteger(child.ownedHours, 1, 'COMMA')}시간|">총8시간</span>
<span th:if="${not #strings.isEmpty(child.leasedHours)}"
th:text="|총${#numbers.formatInteger(child.leasedHours, 1, 'COMMA')}시간|">총8시간</span>
th:text="|총 ${#numbers.formatInteger(child.leasedHours, 1, 'COMMA')}시간|">총8시간</span>
</li>
</th:block>
</ul>
<!--/* 임업생산물 중 자가소비량 */-->
<ul class="detail-list"
th:if="${item.name eq 'FORESTRY'}"
>
<th:block th:if="${#lists.isEmpty(forestryList)}">
<li>
<p>없음</p>
</li>
</th:block>
<th:block th:each="child, childStatus : ${forestryList}">
<li>
<p>[[${child.productName}]]</p>
<span th:if="${not #strings.isEmpty(child.estimatedValue)}"
th:text="|${#numbers.formatInteger(child.estimatedValue, 1, 'COMMA')}원|">302,000원</span>
</li>
</th:block>
</ul>
<!--/* TODO 임업생산물 중 자가소비량 */-->
<!--/* TODO 농업생산물 중 자가소비량 */-->
</div>
</div>

View File

@@ -70,7 +70,7 @@
</span>
</label>
</div>
<!--/*<div class="component-input">
<div class="component-input">
<label class="switch-inner type-txt">
<span class="switch-label">자가임업 생산물 중 자가소비량</span>
<input type="checkbox" name="forestryStatus" value="TARGET" data-target="forestry"
@@ -79,7 +79,7 @@
<span class="switch-handle"></span>
</span>
</label>
</div>*/-->
</div>
<!--/* [정책] 자가농업 생산물 중 자가소비량은 7일차 등록일에만 노출 및 선택, 21일 이후는 마지막 날 */-->
<!--/*<div class="component-input"
th:if="${reqVO.groupNo eq 4 or reqVO.groupNo eq 8 or reqVO.groupNo eq 12

View File

@@ -0,0 +1,120 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org" lang="ko">
<th:block>
<div class="modal-content-inner">
<p class="form-desc">필수입력</p>
<form name="reqModalForm">
<input type="hidden" name="id" th:value="${detail.id}">
<section class="form-group">
<div class="component-input">
<div class="input-label">
<label for="productName" class="label-txt">
생산물
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
</label>
</div>
<div class="input-field">
<input type="text" id="productName" name="productName" th:value="${detail.productName}" maxlength="30" placeholder="생산물을 입력해 주세요">
</div>
</div>
<div class="component-input">
<div class="input-label">
<label for="usage" class="label-txt">
용도
</label>
</div>
<div class="input-field">
<input type="text" id="usage" name="usage" th:value="${detail.usage}" maxlength="30" placeholder="용도를 입력해 주세요">
</div>
</div>
</section>
<hr>
<section class="form-group">
<div class="component-input">
<div class="input-label">
<label for="quantity" class="label-txt">
수량
</label>
</div>
<div class="input-field">
<input type="number" inputmode="decimal" pattern="[0-9]*" id="quantity" name="quantity"
th:value="${detail.quantity}" maxlength="10" placeholder="수량을 입력해 주세요">
</div>
<ul class="guide-info">
<li>예 : 2, 2.5</li>
</ul>
</div>
<div class="select-group">
<div class="select-label">
<p class="label-txt">
단위
</p>
</div>
<div id="unitCode" class="component-select bottom-sheet" data-props-default="단위를 선택해 주세요" data-props-type="bottomSheet">
<input type="hidden" name="unitCode" th:value="${detail.unitCode}">
<button type="button" class="select-box">
<span class="select-txt"></span>
</button>
<div class="select-options">
<div class="select-header">
<p>단위</p>
<button type="button" class="select-close">
<span class="hide-txt">닫기</span>
</button>
</div>
<div class="select-scroll">
<ul class="">
<li class="option" th:each="uiCode : ${recordUnit}"
th:data-value="${uiCode.id}"
th:text="${uiCode.codeText}"
th:selected="${uiCode.id eq detail.unitCode ? 'current' : ''}"
></li>
</ul>
</div>
</div>
</div>
<div class="component-input" data-option="직접 입력">
<div class="input-field">
<input type="text" name="unitSelf" th:value="${detail.unitSelf}" maxlength="30" placeholder="단위를 입력해 주세요">
</div>
</div>
</div>
</section>
<hr>
<section class="form-group">
<div class="component-input">
<div class="input-label">
<label for="estimatedValue" class="label-txt">
현물평가액
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
</label>
</div>
<div class="input-field type-price">
<input type="number" inputmode="numeric" pattern="[0-9]*" id="estimatedValue" name="estimatedValue"
th:value="${detail.estimatedValue}" maxlength="10" placeholder="금액을 입력해 주세요">
<span class="input-field-txt">원</span>
</div>
<ul class="guide-info">
<li>예 : 30000</li>
</ul>
</div>
</section>
<div class="component-btns">
<div class="btns-row">
<button type="button" class="btn btn-full btn-l btn-primary" onclick="modalControl.createVaild();">
<span class="btn-txt">등록</span>
</button>
</div>
</div>
</form>
</div>
</th:block>
</html>

View File

@@ -0,0 +1,207 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout-none}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org" lang="ko">
<div layout:fragment="content" th:classappend="acco-wrap">
<main id="content" role="main">
<div class="inner">
<hgroup class="tit-group">
<h3>
<th:block th:if="${dailyRecord.startDay eq dailyRecord.endDay}">
[[${#temporals.format(dailyRecord.startDate, 'M월 d일')}]], <br>
</th:block>
<th:block th:if="not ${dailyRecord.startDay eq dailyRecord.endDay}">
[[${#temporals.format(dailyRecord.startDate, 'M월 d일')}]]~[[${#temporals.format(dailyRecord.endDate, 'd일')}]], <br>
</th:block>
<strong>임업생산물 중 자가소비량 [[${#lists.isEmpty(forestryList) ? 0 : #lists.size(forestryList)}]]건 등록</strong>
되었습니다.
</h3>
<p th:if="${#lists.isEmpty(forestryList)}">자가임업생산물 중 자가소비량 내역을 등록해 주세요.</p>
<p th:unless="${#lists.isEmpty(forestryList)}">등록 내용을 확인하거나 다음 단계로 이동하세요.</p>
</hgroup>
<!--/* 신규 등록 */-->
<th:block th:if="${#lists.isEmpty(forestryList)}">
<button type="button" class="btn btn-m btn-secondary btn-full button-modal01" data-testid="button-modal01"
th:disabled="${#strings.equals(dailyRecord.forestryStatus, 'TODAY_NONE')}">
<i class="ico-small" aria-hidden="true"
th:classappend="${#strings.equals(dailyRecord.forestryStatus, 'TODAY_NONE') ? 'ico-add-disabled' : 'ico-add'}"></i>
<span class="btn-txt">추가 등록</span>
</button>
<div class="component-input align-center">
<label class="checkbox-inner" id="todayNone">
<input type="checkbox" name="todayNone"
data-type="FORESTRY"
th:checked="${#strings.equals(dailyRecord.forestryStatus, 'TODAY_NONE')}">
<span class="checkbox-item">
<span class="checkbox-txt">금일 등록내용 없음</span>
</span>
</label>
</div>
<ul class="info-bullet-list">
<li>
다른 임가가 생산한 것을 취득하거나 외부로부터의 구입 • 증여한 것은 제외해 주세요.
</li>
</ul>
</th:block>
<!--/* 목록 */-->
<th:block th:unless="${#lists.isEmpty(forestryList)}">
<section class="regist-item-area">
<p class="total">
<span>총 <strong>[[${#lists.size(forestryList)}]]</strong>건</span>
<button type="button" class="btn-reset" onclick="krip.daily.resetConfirm()">
<i class="ico-reset ico-small" aria-hidden="true"></i>
<span>초기화</span>
</button>
</p>
<div class="item-list">
<div class="list-item"
th:each="item, itemStatus : ${forestryList}">
<div class="item-tit-group">
<p class="item-name">[[${item.productName}]]</p>
<div class="btn-group">
<button type="button" class="delete" th:onclick="krip.daily.removeConfirm([[${item.id}]])"><span class="hide-txt">삭제</span></button>
<button type="button" class="edit" th:onclick="krip.daily.createModal([[${item.id}]])"><span class="hide-txt">수정</span></button>
</div>
</div>
<ul class="detail-list">
<li th:if="${not #strings.isEmpty(item.usage)}">
<p>용도</p>
<span th:text="${item.usage}">0시간</span>
</li>
<li th:if="${not #strings.isEmpty(item.quantity)}">
<p>수량</p>
<span th:text="|${item.quantity}${#strings.defaultString(item.unitLabel,'')}|">500g</span>
</li>
<li th:if="${not #strings.isEmpty(item.estimatedValue)}">
<p>현물평가액</p>
<span th:text="|${#numbers.formatInteger(item.estimatedValue, 1, 'COMMA')}원|">302,000원</span>
</li>
</ul>
</div>
</div>
<button type="button" class="btn btn-m btn-secondary btn-full button-modal01" data-testid="button-modal01">
<i class="ico-add ico-small" aria-hidden="true"></i>
<span class="btn-txt">추가 등록</span>
</button>
<ul class="info-bullet-list">
<li>
다른 임가가 생산한 것을 취득하거나 외부로부터의 구입 • 증여한 것은 제외해 주세요.
</li>
</ul>
</section>
</th:block>
</div>
</main>
<!-- 하단 고정 버튼 -->
<div class="component-btns fixed"
th:if="${moveStep}">
<div class="btns-row">
<button type="button" class="btn btn-l btn-secondary" onclick="krip.daily.goToPrev();">
<span class="btn-txt">이전 단계로 이동</span>
</button>
<button type="button" class="btn btn-l btn-primary"
th:disabled="${not #strings.equals(dailyRecord.forestryStatus, 'TODAY_NONE') and #lists.isEmpty(forestryList)}"
th:onclick="krip.daily.goToNext([[${nextStep}]], [[${reqVO.searchMonth}]], [[${reqVO.groupNo}]])">
<span class="btn-txt">다음 단계로 이동</span>
</button>
</div>
</div>
<!-- 모달 팝업 -->
<div class="layer-wrap">
<div class="component-modal acco-wrap formModal" data-props-dimm-click="true">
<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">
<!--/* form */-->
</div>
<button type="button" class="modal-close"></button>
</div>
</div>
</div>
</div>
<!-- //모달 팝업 -->
<!-- /* 건의사항 모달 팝업 */ -->
<th:block th:replace="~{/record/comment-modal}"></th:block>
<!-- /* //건의사항 모달 팝업 */ -->
</div>
<section layout:fragment="script">
<script th:src="@{/static/ui/page/daily-record.js}"></script>
<script th:inline="javascript">
$(function() {
formControl.init();
});
let ENV = {
httpUrl: {
root: /*[[|/record/forestry/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
form: /*[[|/record/forestry/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl',
create: /*[[|/api/record/forestry/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
remove: /*[[|/api/record/forestry/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
reset: /*[[|/api/record/forestry/${reqVO.searchMonth}/${reqVO.groupNo}/reset|]]*/'resetUrl',
},
modal: {
// 등록 버튼
selectorId: '.button-modal01',
// 등록 영역
selector: '.formModal',
},
month: /*[[${reqVO.searchMonth}]]*/'month',
groupNo: /*[[${reqVO.groupNo}]]*/'groupNo',
submitted: false,
};
let formControl = {
init() {
krip.daily.baseBindUI();
},
};
let modalControl = {
_bindModelUI() {
const $select2 = document.querySelector('#unitCode');
const selectboxInstance2 = new etUI.components.SelectBox();
selectboxInstance2.core.init($select2, {
selectItemCallback({selectValue, dataValue}){
console.log('selectItemCallback', selectValue, dataValue)
$('input[name="unitCode"]').val(dataValue)
etUI.pages.initDirectInputToggle();
}
});
const $formWrap = $(ENV.modal.selector).find('form');
// data set
selectboxInstance2.setValue($formWrap.find('input[name="unitCode"]').val());
},
createVaild() {
modalControl.create();
},
create() {
const f = document.reqModalForm;
const obj = $(f).serializeObject();
console.log(obj)
ajaxUtil._ajaxAsync(
ENV.httpUrl.create.replace('{id}', f.id.value ? f.id.value : '0'),
obj,
function (rstData, status) {
location.reload();
},
);
},
};
</script>
</section>
</html>