임산물현황 완료일거에요.
This commit is contained in:
@@ -9,6 +9,8 @@ import app.module.core.usecase.monthly.updateMonthlyInputStatus.ports.UpdateMont
|
||||
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.removeMonthForestProducts.ports.RemoveMonthForestProductsPortIn;
|
||||
import app.module.core.usecase.product.removeMonthForestProducts.ports.application.domain.RemoveMonthForestProductsCmd;
|
||||
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;
|
||||
@@ -29,6 +31,8 @@ class CreateMonthlyController {
|
||||
private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn;
|
||||
private final CreateForestProductPortIn createForestProductPortIn;
|
||||
private final UpdateMonthlyInputStatusPortIn updateMonthlyInputStatusPortIn;
|
||||
private final RemoveMonthForestProductsPortIn removeMonthForestProductsPortIn;
|
||||
|
||||
private final CoreUtil coreUtil;
|
||||
|
||||
@PostMapping(path = "/api/front/info/monthly/create")
|
||||
@@ -41,50 +45,57 @@ class CreateMonthlyController {
|
||||
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(),
|
||||
|
||||
if(currentMonthlyInfo!=null) {
|
||||
//TODO 트렌젝션 고려
|
||||
removeMonthForestProductsPortIn.operate(new RemoveMonthForestProductsCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq()));
|
||||
|
||||
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(),
|
||||
item.getMainYield(),
|
||||
item.getMainYieldUnitCode(),
|
||||
item.getMainSaleAmount(),
|
||||
item.getMainSaleUnitCode(),
|
||||
item.getSubYield(),
|
||||
item.getSubYieldUnitCode(),
|
||||
item.getSubSaleAmount(),
|
||||
item.getSubSaleUnitCode(),
|
||||
currentMonthlyInfo.getId()
|
||||
MonthStatus.REGISTERED,
|
||||
currentMonthlyInfo.getBankAutoTransferInputStatus(),
|
||||
currentMonthlyInfo.getBankAutoTransferOutputStatus()
|
||||
));
|
||||
} else {
|
||||
updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd(
|
||||
currentMonthlyInfo.getId(),
|
||||
AuthUtil.getUserSeq(),
|
||||
currentMonthlyInfo.getMonth(),
|
||||
MonthStatus.NOTHING,
|
||||
currentMonthlyInfo.getBankAutoTransferInputStatus(),
|
||||
currentMonthlyInfo.getBankAutoTransferOutputStatus()
|
||||
));
|
||||
}
|
||||
updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd(
|
||||
currentMonthlyInfo.getId(),
|
||||
AuthUtil.getUserSeq(),
|
||||
currentMonthlyInfo.getMonth(),
|
||||
MonthStatus.REGISTERED,
|
||||
currentMonthlyInfo.getBankAutoTransferInputStatus(),
|
||||
currentMonthlyInfo.getBankAutoTransferOutputStatus()
|
||||
));
|
||||
return ResponseEntity.ok(ApiResponse.success(null));
|
||||
} else {
|
||||
updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd(
|
||||
currentMonthlyInfo.getId(),
|
||||
AuthUtil.getUserSeq(),
|
||||
currentMonthlyInfo.getMonth(),
|
||||
MonthStatus.NOTHING,
|
||||
currentMonthlyInfo.getBankAutoTransferInputStatus(),
|
||||
currentMonthlyInfo.getBankAutoTransferOutputStatus()
|
||||
));
|
||||
return ResponseEntity.ok(ApiResponse.failure(null));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ResponseEntity.ok(ApiResponse.success(null));
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,9 @@ 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 java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@@ -50,7 +53,7 @@ class CreateMonthlyUIController {
|
||||
new GetPrevMonthlyInputStatusCmd(
|
||||
id, AuthUtil.getUserSeq())).orElse(null);
|
||||
|
||||
//현재 달 입력 상태 취득
|
||||
//이번달 달 입력 상태 취득
|
||||
GetMonthlyInputStatus currentMonthlyInfo =
|
||||
getMonthlyInputStatusPortIn.operate(
|
||||
new GetMonthlyInputStatusCmd(
|
||||
@@ -75,6 +78,11 @@ class CreateMonthlyUIController {
|
||||
currentMonthlyInfo.getId(), AuthUtil.getUserSeq()));
|
||||
}
|
||||
|
||||
//수정 가능 여부 판단
|
||||
YearMonth yearMonth = YearMonth.parse(currentMonthlyInfo.getMonth());
|
||||
LocalDate maxMonth = yearMonth.plusMonths(1).atDay(15);
|
||||
LocalDate today = LocalDate.now();
|
||||
boolean editable = !today.isAfter(maxMonth);
|
||||
|
||||
|
||||
model.addAttribute("pastMonthlyInfo", pastMonthlyInfo);
|
||||
@@ -87,6 +95,7 @@ class CreateMonthlyUIController {
|
||||
model.addAttribute("unitList", uiCodeListPortIn.connect("code.record.unit"));
|
||||
|
||||
model.addAttribute("MonthStatus", MonthStatus.class);
|
||||
model.addAttribute("editable", editable);
|
||||
|
||||
return "info/monthly/{id}";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user