월별임산물

This commit is contained in:
주우성
2025-06-15 17:32:22 +09:00
parent 4f9eeb9e02
commit 0bc85b825c
5 changed files with 237 additions and 18 deletions

View File

@@ -0,0 +1,109 @@
package app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web;
import app.module.core.config.application.enums.MonthStatus;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.config.application.util.CoreUtil;
import app.module.core.usecase.household.getHousehold.ports.GetHouseholdPortIn;
import app.module.core.usecase.household.getHousehold.ports.application.domain.GetHousehold;
import app.module.core.usecase.household.getHousehold.ports.application.domain.GetHouseholdCmd;
import app.module.core.usecase.household.updateFrontHousehold.ports.UpdateFrontHouseholdPortIn;
import app.module.core.usecase.household.updateFrontHousehold.ports.application.domain.UpdateFrontHouseholdCmd;
import app.module.core.usecase.monthly.getMonthlyInputStatus.ports.GetMonthlyInputStatusPortIn;
import app.module.core.usecase.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatus;
import app.module.core.usecase.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatusCmd;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.GetPrevMonthlyInputStatusPortIn;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd;
import app.module.core.usecase.monthly.updateMonthlyInputStatus.ports.UpdateMonthlyInputStatusPortIn;
import app.module.core.usecase.monthly.updateMonthlyInputStatus.ports.application.domain.UpdateMonthlyInputStatusCmd;
import app.module.core.usecase.product.createForestProduct.ports.CreateForestProductPortIn;
import app.module.core.usecase.product.createForestProduct.ports.application.domain.CreateForestProductCmd;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.GetMonthlyForestProductsPortIn;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProducts;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import app.module.front.config.application.response.ApiResponse;
import app.module.front.config.application.util.AuthUtil;
import app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model.CreateMonthlyProductReqVO;
import app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model.CreateMonthlyReqVO;
import app.module.front.usecase.info.user.updateUserUI.adapters.web.model.UpdateUserReqVO;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@Controller
@RequiredArgsConstructor
class CreateMonthlyController {
private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn;
private final CreateForestProductPortIn createForestProductPortIn;
private final UpdateMonthlyInputStatusPortIn updateMonthlyInputStatusPortIn;
private final CoreUtil coreUtil;
@PostMapping(path = "/api/front/info/monthly/create")
ResponseEntity<?> operate(@RequestBody @Valid CreateMonthlyReqVO reqVO, BindingResult bindingResult){
if (bindingResult.hasErrors()) {
return coreUtil.getErrorInfo(bindingResult);
}
GetMonthlyInputStatus currentMonthlyInfo =
getMonthlyInputStatusPortIn.operate(
new GetMonthlyInputStatusCmd(
reqVO.getId(), AuthUtil.getUserSeq())).orElse(null);
if(!reqVO.getStatus() && reqVO.getProductList()!=null && !reqVO.getProductList().isEmpty()){ // 등록없음 처리가 아님.
for(CreateMonthlyProductReqVO item : reqVO.getProductList()){
createForestProductPortIn.operate(new CreateForestProductCmd(
AuthUtil.getUserSeq(),
item.getStreetNum(),
item.getLandType(),
item.getTown(),
item.getAvailableArea(),
item.getCropName(),
null,
item.getLandArea(),
currentMonthlyInfo.getMonth(),
item.getMainYield(),
item.getMainYieldUnitCode(),
item.getMainSaleAmount(),
item.getMainSaleUnitCode(),
item.getSubYield(),
item.getSubYieldUnitCode(),
item.getSubSaleAmount(),
item.getSubSaleUnitCode(),
currentMonthlyInfo.getId()
));
}
updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd(
currentMonthlyInfo.getId(),
AuthUtil.getUserSeq(),
currentMonthlyInfo.getMonth(),
MonthStatus.REGISTERED,
currentMonthlyInfo.getBankAutoTransferStatus()
));
} else {
updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd(
currentMonthlyInfo.getId(),
AuthUtil.getUserSeq(),
currentMonthlyInfo.getMonth(),
MonthStatus.NOTHING,
currentMonthlyInfo.getBankAutoTransferStatus()
));
}
return ResponseEntity.ok(ApiResponse.success(null));
}
}

View File

@@ -17,7 +17,6 @@ import app.module.core.usecase.product.getMonthlyForestProducts.ports.applicatio
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import app.module.front.config.application.util.AuthUtil;
import app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model.CreateMonthlyReqVO;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

View File

@@ -0,0 +1,35 @@
package app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public class CreateMonthlyProductReqVO {
private Long id;//
private String streetNum;//
private String landType;//
private String town;//
private Integer availableArea;//
private String cropName;//
private Integer landArea;//
private BigDecimal mainYield;//
private String mainYieldUnitCode;//
private BigDecimal mainSaleAmount;//
private String mainSaleUnitCode;//
private BigDecimal subYield;//
private String subYieldUnitCode;//
private BigDecimal subSaleAmount;//
private String subSaleUnitCode;//
}

View File

@@ -1,16 +1,31 @@
package app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public class CreateMonthlyReqVO {
private String searchField;
private String searchValue;
private Boolean status;
private Long id;
private List<CreateMonthlyProductReqVO> productList;
public List<CreateMonthlyProductReqVO> getProductList() {
return productList != null ? productList : new ArrayList<>();
}
public void setProductList(List<CreateMonthlyProductReqVO> productList) {
this.productList = productList;
}
}

View File

@@ -14,14 +14,14 @@
</hgroup>
<section class="regist-item-area">
<p class="total" th:style="${currentList.totalElements == 0 ? 'display:none':''}" id="listHeader">
<span>총 <strong id="listCount">1</strong>건</span>
<p class="total" style="display: none" id="listHeader"><!-- th:style="${currentList.totalElements == 0 ? 'display:none':''}"-->
<span>총 <strong id="listCount">0</strong>건</span>
<button type="button" class="btn-reset" onclick="formControl.clearAllItems()">
<i class="ico-reset ico-small" aria-hidden="true"></i>
<span>초기화</span>
</button>
</p>
<div class="item-list" th:style="${currentList.totalElements == 0 ? 'display:none':''}" id="listBody">
<div class="item-list" style="display: none" id="listBody"> <!-- th:style="${currentList.totalElements == 0 ? 'display:none':''}"-->
</div>
@@ -30,12 +30,12 @@
<span class="btn-txt">추가 등록</span>
</button>
<button type="button" class="btn btn-m btn-link btn-full" th:if="${pastMonthlyInfo != null && currentList.totalElements == 0}" id="callPastInfoBtn">
<button type="button" class="btn btn-m btn-link btn-full" th:style="${pastMonthlyInfo != null && currentList.totalElements == 0 ? '':'display:none'}" id="callPastInfoBtn">
<span class="btn-txt">이전 정보 불러오기</span>
</button>
<div class="component-input align-center" th:if="${currentList.totalElements == 0}" id="forestProductStatusDiv">
<div class="component-input align-center" th:style="${currentList.totalElements == 0 ? '':'display:none'}" id="forestProductStatusDiv">
<label class="checkbox-inner">
<input type="checkbox" id="forestProductStatus" name="forestProductStatus" th:value="${MonthStatus.NOTHING}" onchange="formControl.handleNoDataToggle()">
<span class="checkbox-item">
@@ -60,7 +60,7 @@
<div class="component-btns fixed">
<div class="btns-row">
<!-- 비활성화 스타일/ 버튼 속성 disable 추가-->
<button type="button" class="btn btn-l btn-primary" id="complateBtn" disabled>
<button type="button" class="btn btn-l btn-primary" id="complateBtn" disabled onclick="formControl.goSave()">
<span class="btn-txt">등록 완료</span>
</button>
</div>
@@ -417,15 +417,20 @@
// ✅ ENV 구조 (전역 설정 및 상태)
let ENV = {
httpUrl: {
root: /*[[#{uri.front.info.monthly.path}]]*/ 'rootUrl'
root: /*[[#{uri.front.info.monthly.path}]]*/ 'rootUrl',
save: /*[[|/api/front#{uri.front.info.monthly.path}/create|]]*/ 'rootUrl'
},
module: {
modalPopup: null
},
data: {
purposeList: /*[[${purposeList}]]*/ [],
unitList: /*[[${unitList}]]*/ [],
productList: []
// productList: /*[[${currentList.content}]]*/ [],
productList: [],
pastProductList : /*[[${pastList.content}]]*/ [],
id: /*[[${currentMonthlyInfo.id}]]*/''
},
elementRefs: {
noDataCheckbox: document.getElementById("forestProductStatus"),
@@ -442,6 +447,8 @@
init() {
this.cacheElements();
this.bindDecimalLimit();
this.setting();
ajaxUtil._alert('select 초기화/지정 방법?\n 6월의 카운트와 추가등록의 카운터의 차이?\n 신규 작성 이후 재진입시의 로직?\n 일단 저장데이터 뿌리는것은 막아둠',null);
},
//모달창
cacheElements() {
@@ -462,6 +469,15 @@
});
});
},
setting(){
if(ENV.data.productList.length > 0) {
ENV.data.productList.forEach(data => productRenderer.addItem(data));
}
this.updateListHeader();
},
pastMonthlyDataPopup(){
//pastProductList 출력하면도미.
},
//등록없음 선택에 따른 추가하기 버튼 잠금
toggleAddButtonState(isEnabled) {
const btn = document.getElementById("addItemBtn");
@@ -472,8 +488,8 @@
},
//등록없음 버튼
handleNoDataToggle() {
const isChecked = ENV.elementRefs.noDataCheckbox.checked;
this.toggleAddButtonState(!isChecked);
this.updateListHeader();
},
// 등록폼 추가
openAddForm() {
@@ -566,13 +582,34 @@
// document.getElementById('listBody').innerHTML = '';
// this.updateListHeader();
},
// 아이템 겟수 처리
// 아이템 겟수 처리 아이템에 따른 레이아웃 정리
updateListHeader() {
const isChecked = ENV.elementRefs.noDataCheckbox.checked;
const btn = document.getElementById("addItemBtn");
const icon = btn.querySelector("i");
const status = document.getElementById('forestProductStatusDiv');
const next = document.getElementById('complateBtn');
const header = document.getElementById('listHeader');
const count = document.getElementById('listCount');
const total = ENV.data.productList.length;
header.style.display = total > 0 ? '' : 'none';
status.style.display = total > 0 ? 'none' : '';
count.textContent = total;
btn.disabled = isChecked;
icon.classList.toggle("ico-add", !isChecked);
icon.classList.toggle("ico-add-disabled", isChecked);
if(isChecked) {
next.disabled = !isChecked;
} else {
next.disabled = total <= 0;
}
},
// 지목 코드
getPurposeLabel(code) {
@@ -583,6 +620,30 @@
getUnitLabel(code) {
const found = ENV.data.unitList.find(i => i.id === code);
return found ? found.codeText : '-';
},
goSave(){
ajaxUtil._ajaxAsync(
ENV.httpUrl.save,
{status : ENV.elementRefs.noDataCheckbox.checked, id:ENV.data.id, productList : ENV.data.productList},
function (rstData, status) {
if(rstData.code ==='SUCCESS'){
ajaxUtil._alert('등록이 완료되었습니다.', null, function () {
/**
* TODO
* 내정보에서만 들어온다는 가정하에서 back을 하게함 SB에는 내정보로 이동하게 되어 있음.
*/
history.back()
});
} else if (rstData.code === 'ERROR'){
ajaxUtil._alert('잠시 뒤에 다시 시도해 주세요.', null);
}
},
);
}
};