[BO] 일계부 농업생산물 등록, 수정 [FO] 농업생산물 수입/지출부호 Util 로 변경
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.SaveDailyFarmingMapper;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.modal.GetDailyFarmingDto;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.SaveDailyFarmingPortOut;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.GetDailyFarmingCmd;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.SaveDailyFarmingCmd;
|
||||
import app.module.core.config.application.annotation.CreateCommand;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SaveDailyFarmingDao implements SaveDailyFarmingPortOut {
|
||||
private final SaveDailyFarmingMapper DailyFarmingMapper;
|
||||
|
||||
@Override
|
||||
public GetDailyFarmingDto detail(GetDailyFarmingCmd command) {
|
||||
|
||||
return DailyFarmingMapper.getDailyFarming(command);
|
||||
}
|
||||
|
||||
@CreateCommand
|
||||
@Override
|
||||
public void create(GetDailyFarmingCmd findCmd, SaveDailyFarmingCmd command) {
|
||||
Integer existCount = DailyFarmingMapper.getRecordExistCount(findCmd);
|
||||
if (existCount == 0) {
|
||||
DailyFarmingMapper.createDailyFarming(command);
|
||||
|
||||
log.debug("[CreateDailyFarming] command={}", command);
|
||||
} else {
|
||||
DailyFarmingMapper.updateDailyFarming(command);
|
||||
|
||||
log.debug("[UpdateDailyFarming] command={}", command);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.modal.GetDailyFarmingDto;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.GetDailyFarmingCmd;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.SaveDailyFarmingCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SaveDailyFarmingMapper {
|
||||
/**
|
||||
* 일계부 농업생산 데이터 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 농업생산 데이터
|
||||
*/
|
||||
GetDailyFarmingDto getDailyFarming(GetDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 농업생산 데이터 존재 여부
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 중복 개수
|
||||
*/
|
||||
Integer getRecordExistCount(GetDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 농업생산 등록
|
||||
*
|
||||
* @param command 등록 데이터
|
||||
*/
|
||||
void createDailyFarming(SaveDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 농업생산 수정
|
||||
*
|
||||
* @param command 수정 데이터
|
||||
*/
|
||||
void updateDailyFarming(SaveDailyFarmingCmd command);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.modal;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class GetDailyFarmingDto {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String productCode;
|
||||
private String productLabel;
|
||||
private String productSelf;
|
||||
private String usage;
|
||||
private String quantity;
|
||||
private String unitCode;
|
||||
private String unitLabel;
|
||||
private String unitSelf;
|
||||
private Long estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.modal.GetDailyFarmingDto;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model.DailyFarmingUIReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model.SaveDailyFarmingReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.validator.SaveDailyFarmingValidator;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.SaveDailyFarmingPortIn;
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||
import app.module.core.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/household/daily/farming")
|
||||
public class SaveDailyFarmingController {
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final SaveDailyFarmingPortIn DailyFarmingPortIn;
|
||||
private final SaveDailyFarmingValidator DailyFarmingValidator;
|
||||
|
||||
/**
|
||||
* 일계부 농업생산 조회
|
||||
*
|
||||
* @param id 농업생산 일련번호
|
||||
* @param reqVO 검색 조건
|
||||
*/
|
||||
@GetMapping(path = "/{id}")
|
||||
ResponseEntity<?> detail(@PathVariable("id") String id, @ModelAttribute DailyFarmingUIReqVO reqVO) {
|
||||
|
||||
reqVO.setId(Long.parseLong(id));
|
||||
|
||||
GetDailyFarmingDto detail = DailyFarmingPortIn.detail(reqVO);
|
||||
if (detail == null) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 농업생산 등록 처리
|
||||
*
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
*/
|
||||
@PostMapping(path = "/save")
|
||||
ResponseEntity<?> create(@Valid @RequestBody SaveDailyFarmingReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
DailyFarmingValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(formVO.getDailyId());
|
||||
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyId(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
DailyFarmingPortIn.create(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 유효성 체크 및 데이터 조회
|
||||
*
|
||||
* @param dailyRecordSeq 항목 일련번호
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(Long dailyRecordSeq) {
|
||||
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(dailyRecordSeq);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyFarmingUIReqVO {
|
||||
/**
|
||||
* 검색 월(yyyyMM)
|
||||
*/
|
||||
private String searchMonth;
|
||||
/**
|
||||
* 검색 그룸번호
|
||||
*/
|
||||
private Integer groupNo;
|
||||
/**
|
||||
* 임가 일련번호
|
||||
*/
|
||||
private Long householdSeq;
|
||||
|
||||
/**
|
||||
* 일계부 항목 일련번호
|
||||
*/
|
||||
private Long dailyId;
|
||||
/**
|
||||
* 농업생산 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model.DailyFarmingUIReqVO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class SaveDailyFarmingReqVO extends DailyFarmingUIReqVO {
|
||||
/**
|
||||
* 생산물
|
||||
*/
|
||||
@NotBlank(message = "생산물을 선택해 주세요.")
|
||||
private String productCode;
|
||||
/**
|
||||
* 생산물 직접 입력
|
||||
*/
|
||||
private String productSelf;
|
||||
/**
|
||||
* 용도
|
||||
*/
|
||||
private String usage;
|
||||
/**
|
||||
* 수량
|
||||
*/
|
||||
private Double quantity;
|
||||
/**
|
||||
* 단위 코드
|
||||
*/
|
||||
private String unitCode;
|
||||
/**
|
||||
* 단위 직접 입력
|
||||
*/
|
||||
private String unitSelf;
|
||||
/**
|
||||
* 현물평가액
|
||||
*/
|
||||
private Long estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.validator;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model.SaveDailyFarmingReqVO;
|
||||
import app.module.core.config.constants.CommonConstants;
|
||||
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 SaveDailyFarmingValidator implements Validator {
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return SaveDailyFarmingReqVO.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
SaveDailyFarmingReqVO vo = (SaveDailyFarmingReqVO) target;
|
||||
|
||||
if ("code.record.farming.self".equals(vo.getProductCode()) && StringUtils.isBlank(vo.getProductSelf())) {
|
||||
errors.rejectValue(
|
||||
"productSelf", "valid.common.required",
|
||||
"생산물을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"quantity", "valid.common.required",
|
||||
"수량을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
|
||||
errors.rejectValue(
|
||||
"unitCode", "valid.common.required",
|
||||
"단위를 선택해 주세요.");
|
||||
}
|
||||
|
||||
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||
errors.rejectValue(
|
||||
"unitSelf", "valid.common.required",
|
||||
"단위를 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"estimatedValue", "valid.common.required",
|
||||
"현물평가액을 입력해 주세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.modal.GetDailyFarmingDto;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model.DailyFarmingUIReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model.SaveDailyFarmingReqVO;
|
||||
|
||||
public interface SaveDailyFarmingPortIn {
|
||||
/**
|
||||
* 일계부 농업생산 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 농업생산 상세
|
||||
*/
|
||||
GetDailyFarmingDto detail(DailyFarmingUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 농업생산 등록
|
||||
*
|
||||
* @param formVO 입력 데이터
|
||||
*/
|
||||
void create(SaveDailyFarmingReqVO formVO);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.modal.GetDailyFarmingDto;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.GetDailyFarmingCmd;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.SaveDailyFarmingCmd;
|
||||
|
||||
public interface SaveDailyFarmingPortOut {
|
||||
/**
|
||||
* 일계부 농업생산 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 농업생산 상세
|
||||
*/
|
||||
GetDailyFarmingDto detail(GetDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 농업생산 등록
|
||||
*
|
||||
* @param findCmd 검색 조건
|
||||
* @param command 입력 데이터
|
||||
*/
|
||||
void create(GetDailyFarmingCmd findCmd, SaveDailyFarmingCmd command);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.modal.GetDailyFarmingDto;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model.DailyFarmingUIReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.web.model.SaveDailyFarmingReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.SaveDailyFarmingPortIn;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.SaveDailyFarmingPortOut;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.GetDailyFarmingCmd;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain.SaveDailyFarmingCmd;
|
||||
import app.module.core.config.application.util.DailyUtil;
|
||||
import app.module.core.config.constants.DailyRecordConstants;
|
||||
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SaveDailyFarmingService implements SaveDailyFarmingPortIn {
|
||||
private final SaveDailyFarmingPortOut portOut;
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyUtil dailyUtil;
|
||||
|
||||
@Override
|
||||
public GetDailyFarmingDto detail(DailyFarmingUIReqVO reqVO) {
|
||||
GetDailyFarmingCmd findCmd = new GetDailyFarmingCmd(
|
||||
reqVO.getSearchMonth(),
|
||||
reqVO.getGroupNo(),
|
||||
reqVO.getHouseholdSeq(),
|
||||
reqVO.getId());
|
||||
|
||||
return portOut.detail(findCmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(SaveDailyFarmingReqVO formVO) {
|
||||
GetDailyFarmingCmd findCmd = new GetDailyFarmingCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
formVO.getHouseholdSeq(),
|
||||
formVO.getId());
|
||||
|
||||
HashMap<String, String> markMap = dailyUtil.getMarkByFarming(uiCodeListPortIn.connect("code.record.farming"), formVO.getProductCode());
|
||||
|
||||
SaveDailyFarmingCmd command =
|
||||
new SaveDailyFarmingCmd(
|
||||
formVO.getId(),
|
||||
formVO.getDailyId(),
|
||||
markMap.get("incomeMark"),
|
||||
markMap.get("expenseMark"),
|
||||
formVO.getProductCode(),
|
||||
formVO.getProductSelf(),
|
||||
formVO.getUsage(),
|
||||
formVO.getQuantity(),
|
||||
formVO.getUnitCode(),
|
||||
formVO.getUnitSelf(),
|
||||
formVO.getEstimatedValue());
|
||||
|
||||
portOut.create(findCmd, command);
|
||||
|
||||
dailyRecordPortIn.updateByAllStatus(findCmd.getSearchMonth(), findCmd.getGroupNo(), findCmd.getHouseholdSeq());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class GetDailyFarmingCmd {
|
||||
/**
|
||||
* 검색 월(yyyyMM)
|
||||
*/
|
||||
private String searchMonth;
|
||||
/**
|
||||
* 검색 그룸번호
|
||||
*/
|
||||
private Integer groupNo;
|
||||
/**
|
||||
* 임가 일련번호
|
||||
*/
|
||||
private Long householdSeq;
|
||||
/**
|
||||
* 농업생산 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.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 SaveDailyFarmingCmd extends AuditCommand {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String incomeMark;
|
||||
private String expenseMark;
|
||||
private String productCode;
|
||||
private String productSelf;
|
||||
private String usage;
|
||||
private Double quantity;
|
||||
private String unitCode;
|
||||
private String unitSelf;
|
||||
private Long estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.SaveDailyFarmingMapper">
|
||||
|
||||
<select id="getDailyFarming"
|
||||
resultType="app.module.admin.usecase.household.tab.dailyRecord.saveDailyFarming.adapters.persistence.modal.GetDailyFarmingDto">
|
||||
select ds.id, ds.daily_record_seq
|
||||
, ds.product_code, ds.product_self, ds.usage
|
||||
, ds.quantity, ds.unit_code, ds.unit_self, ds.estimated_value
|
||||
from daily_farming ds
|
||||
<include refid="app.module.core.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||
where ds.is_deleted = false
|
||||
and ds.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getRecordExistCount" resultType="int">
|
||||
select count(1)
|
||||
from daily_farming ds
|
||||
<include refid="app.module.core.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="createDailyFarming" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into daily_farming (
|
||||
daily_record_seq, income_mark, expense_mark
|
||||
, product_code, product_self, usage
|
||||
, quantity, unit_code, unit_self, estimated_value
|
||||
, is_deleted
|
||||
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) values (
|
||||
#{dailyRecordSeq}, #{incomeMark}, #{expenseMark}
|
||||
, #{productCode}, #{productSelf}, #{usage}
|
||||
, #{quantity}, #{unitCode}, #{unitSelf}, #{estimatedValue}
|
||||
, false
|
||||
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateDailyFarming">
|
||||
update daily_farming set <include refid="common.fields.UpdateBaseSet"/>
|
||||
, income_mark = #{incomeMark}
|
||||
, expense_mark = #{expenseMark}
|
||||
, product_code = #{productCode}
|
||||
, product_self = #{productSelf}
|
||||
, 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>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,219 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<div class="layer-wrap" th:fragment="modalFragment">
|
||||
<form autocomplete="off" method="get" name="reqFarmingForm" data-modal-id=".modal-daily-farming">
|
||||
<input type="hidden" name="householdSeq" th:value="${seq}">
|
||||
<input type="hidden" name="searchMonth">
|
||||
<input type="hidden" name="groupNo">
|
||||
<input type="hidden" name="id">
|
||||
<input type="hidden" name="dailyId">
|
||||
|
||||
<div class="component-modal mypage-wrap modal01 modal-daily-farming" 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">
|
||||
<div class="modal-content-inner">
|
||||
<table class="type-form confirm">
|
||||
<colgroup>
|
||||
<col width="8%" />
|
||||
<col width="25.3%" />
|
||||
<col width="8%" />
|
||||
<col width="25.3%" />
|
||||
<col width="8%" />
|
||||
<col width="25.3%" />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<th>생산물<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||
<td>
|
||||
<div class="d-flex">
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="productCode" onchange="selectedUnit(this);" required>
|
||||
<option value="">선택</option>
|
||||
<option th:each="item : ${recordFarming}"
|
||||
th:value="${item.id}"
|
||||
th:text="${item.codeText}">
|
||||
</select>
|
||||
</div>
|
||||
<div class="component-input unit-self-input">
|
||||
<div class="input-field">
|
||||
<input type="text" id="productSelf" name="productSelf" maxlength="30" disabled>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<th>용도</th>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input type="text" id="usage" name="usage" maxlength="30">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>수량</th>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input type="number" inputmode="decimal" pattern="[0-9]*" id="quantity" name="quantity" min="1" max="9999999999"
|
||||
maxlength="10" oninput="limitMaxLength(this);">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<th>단위</th>
|
||||
<td colspan="2">
|
||||
<div class="d-flex">
|
||||
<div class="component-select">
|
||||
<select class="select-list" name="unitCode" onchange="selectedUnit(this);" required>
|
||||
<option value="">선택</option>
|
||||
<option th:each="item : ${recordUnit}"
|
||||
th:value="${item.id}"
|
||||
th:text="${item.codeText}">
|
||||
</select>
|
||||
</div>
|
||||
<div class="component-input unit-self-input">
|
||||
<div class="input-field">
|
||||
<input type="text" id="unitSelf" name="unitSelf" maxlength="30" disabled>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>현물평가액(원)<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input type="number" inputmode="numeric" pattern="[0-9]*" id="estimatedValue" name="estimatedValue" min="1" max="9999999999"
|
||||
maxlength="10" oninput="limitMaxLength(this);">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn btn-primary" onclick="saveDailyFarming();">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="modal-close"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// form 초기화
|
||||
const resetDailyFarmingForm = () => {
|
||||
const form = document.reqFarmingForm;
|
||||
if (!form) return;
|
||||
|
||||
form.productCode.value = '';
|
||||
form.productSelf.value = '';
|
||||
form.usage.value = '';
|
||||
form.quantity.value = '';
|
||||
form.unitCode.value = '';
|
||||
form.unitSelf.value = '';
|
||||
form.estimatedValue.value = '';
|
||||
}
|
||||
|
||||
// 일계부 상세 값 set
|
||||
const setDailyFarmingFormData = (data) => {
|
||||
const form = document.reqFarmingForm;
|
||||
if (!form) return;
|
||||
|
||||
// 폼에 값 세팅
|
||||
form.productCode.value = data.productCode || '';
|
||||
form.productSelf.value = data.productSelf || '';
|
||||
form.usage.value = data.usage || '';
|
||||
form.quantity.value = data.quantity || '';
|
||||
form.unitCode.value = data.unitCode || '';
|
||||
form.unitSelf.value = data.unitSelf || '';
|
||||
form.estimatedValue.value = data.estimatedValue || '';
|
||||
|
||||
// 기타 UI 처리
|
||||
selectedUnit(form.productCode);
|
||||
selectedUnit(form.unitCode);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// 일계부 등록 모달창 띄우기
|
||||
const showDailyFarmingModal = (id) => {
|
||||
const mf = document.reqFarmingForm;
|
||||
mf.searchMonth.value = document.reqForm.recordMonth.value;
|
||||
mf.groupNo.value = document.reqForm.groupNo.value;
|
||||
mf.dailyId.value = document.reqForm.dailyId.value;
|
||||
mf.id.value = (id === undefined) ? '' : id;
|
||||
|
||||
resetDailyFarmingForm();
|
||||
|
||||
if (id !== null && id !== undefined) {
|
||||
const obj = $(f).serializeObject();
|
||||
obj.id = mf.id.value;
|
||||
obj.searchMonth = obj.recordMonth;
|
||||
|
||||
ajaxUtil._ajaxAsyncMethod(
|
||||
`/api/household/daily/farming/${id}`,
|
||||
obj,
|
||||
function (rstData, status) {
|
||||
setDailyFarmingFormData(rstData);
|
||||
|
||||
document.querySelector($(mf).data('modalId')).ui.open();
|
||||
},
|
||||
function () {
|
||||
console.error('Do nothing error.')
|
||||
},
|
||||
'get'
|
||||
);
|
||||
|
||||
} else {
|
||||
document.querySelector($(mf).data('modalId')).ui.open();
|
||||
}
|
||||
}
|
||||
|
||||
const saveDailyFarming = () => {
|
||||
const mf = document.reqFarmingForm;
|
||||
let obj = $(mf).serializeObject();
|
||||
obj.inputType = 'SELF';
|
||||
obj.id = (obj.id === '' ? '0' : obj.id);
|
||||
|
||||
ajaxUtil._ajaxAsyncNoWaiting(
|
||||
'/api/household/daily/farming/save',
|
||||
obj,
|
||||
function () {
|
||||
alert('등록이 완료되었습니다.');
|
||||
|
||||
document.querySelector($(mf).data('modalId')).ui.close();
|
||||
|
||||
getDailyRecordsView(f.dailyId.value, f.groupNo.value, f.dayGroupText.value);
|
||||
},
|
||||
function (code, rstData) {
|
||||
console.error('Do nothing. code: '+ code, rstData);
|
||||
},
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</html>
|
||||
@@ -715,7 +715,7 @@
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
<td class="underline">${ifNullHyphen(item.productName)}</td> <!-- 생산물 -->
|
||||
<td class="underline"><a href="javascript:void(0);" onclick="showDailyFarmingModal(${item.id});">${ifNullHyphen(item.productName)}</a></td> <!-- 생산물 -->
|
||||
<td>${ifNullHyphen(item.usage)}</td><!-- 용도 -->
|
||||
<td class="align-right">${ifNullHyphen(item.quantity)}</td><!-- 수량 -->
|
||||
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
|
||||
@@ -818,8 +818,8 @@
|
||||
showDailyPowerModal();
|
||||
} else if (currentStep === 'FORESTRY') {
|
||||
showDailyForestryModal();
|
||||
} else {
|
||||
alert('TODO : 추가');
|
||||
} else if (currentStep === 'FARMING') {
|
||||
showDailyFarmingModal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,6 +181,7 @@
|
||||
<th:block th:replace="households/modal/modal-daily-expense :: modalFragment"/>
|
||||
<th:block th:replace="households/modal/modal-daily-power :: modalFragment"/>
|
||||
<th:block th:replace="households/modal/modal-daily-forestry :: modalFragment"/>
|
||||
<th:block th:replace="households/modal/modal-daily-farming :: modalFragment"/>
|
||||
|
||||
<!-- 조사원 매핑 모달 -->
|
||||
<th:block th:replace="common/modal-researcher-mapping :: modalFragment"/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.core.config.application.util;
|
||||
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -9,6 +10,8 @@ import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Slf4j
|
||||
@@ -126,4 +129,35 @@ public class DailyUtil {
|
||||
|
||||
return new DecimalFormat("###,###").format(Double.parseDouble(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* 농업 생산물의 UI Code 데이터의 수입부호, 지출부호 조회
|
||||
*
|
||||
* @param uiCodeList UI Code 목록
|
||||
* @param targetCode 조회 코드
|
||||
* @return 수입부호, 지출부호 Map
|
||||
*/
|
||||
public HashMap<String, String> getMarkByFarming(List<UICodeElement> uiCodeList, String targetCode) {
|
||||
String incomeMark = null;
|
||||
String expenseMark = null;
|
||||
if (!"code.record.farming.self".equals(targetCode)) {
|
||||
String returnValue = null;
|
||||
for (UICodeElement codeSetup : uiCodeList) {
|
||||
if (codeSetup.getId().equalsIgnoreCase(targetCode)) {
|
||||
returnValue = codeSetup.getCodeValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue != null) {
|
||||
incomeMark = returnValue.split(",")[0];
|
||||
expenseMark = returnValue.split(",")[1];
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, String> returnValue = new HashMap<>();
|
||||
returnValue.put("incomeMark", incomeMark);
|
||||
returnValue.put("expenseMark", expenseMark);
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.front.usecase.daily.farming.ports.application;
|
||||
|
||||
import app.module.core.config.application.util.DailyUtil;
|
||||
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
@@ -18,6 +19,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@@ -25,8 +27,9 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class DailyFarmingService implements DailyFarmingPortIn {
|
||||
private final DailyFarmingPortOut portOut;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyUtil dailyUtil;
|
||||
|
||||
@Override
|
||||
public List<DailyFarmingDto> list(DailyFarmingUIReqVO reqVO) {
|
||||
@@ -101,30 +104,14 @@ public class DailyFarmingService implements DailyFarmingPortIn {
|
||||
formVO.getHouseholdSeq(),
|
||||
formVO.getId());
|
||||
|
||||
String incomeMark = null;
|
||||
String expenseMark = null;
|
||||
if (!"code.record.farming.self".equals(formVO.getProductCode())) {
|
||||
List<UICodeElement> recordFarming = uiCodeListPortIn.connect("code.record.farming");
|
||||
String returnValue = null;
|
||||
for (UICodeElement codeSetup : recordFarming) {
|
||||
if (codeSetup.getId().equalsIgnoreCase(formVO.getProductCode())) {
|
||||
returnValue = codeSetup.getCodeValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue != null) {
|
||||
incomeMark = returnValue.split(",")[0];
|
||||
expenseMark = returnValue.split(",")[1];
|
||||
}
|
||||
}
|
||||
HashMap<String, String> markMap = dailyUtil.getMarkByFarming(uiCodeListPortIn.connect("code.record.farming"), formVO.getProductCode());
|
||||
|
||||
CreateDailyFarmingCmd command = AuditUtil.create(
|
||||
new CreateDailyFarmingCmd(
|
||||
formVO.getId(),
|
||||
formVO.getDailyRecordSeq(),
|
||||
incomeMark,
|
||||
expenseMark,
|
||||
markMap.get("incomeMark"),
|
||||
markMap.get("expenseMark"),
|
||||
formVO.getProductCode(),
|
||||
formVO.getProductSelf(),
|
||||
formVO.getUsage(),
|
||||
|
||||
Reference in New Issue
Block a user