From de171807d76a065e18e320c4b5b20818d24dac3e Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 17 Oct 2024 19:36:20 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E8=B5=84=E9=87=91=E4=B8=8B?= =?UTF-8?q?=E8=BE=BE=E5=A2=9E=E5=8A=A0=E7=BB=93=E8=BD=AC=E8=B5=84=E9=87=91?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectlib/manage/AmountApprovalManage.java | 35 ++++++++++++++-------- .../model/req/SubmitAmountApprovalReq.java | 1 - 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java index 4327b86..14d213c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hz.pm.api.App; import com.hz.pm.api.common.exception.ReturnException; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.util.DecimalUtil; @@ -59,6 +60,7 @@ public class AmountApprovalManage { private final IProjectService projectService; private final UserInfoHelper userInfoHelper; private final MhUnitCache mhUnitCache; + private final App app; private boolean projectQueryPermission(LambdaQueryWrapper query, UserFullInfoDTO user) { @@ -173,20 +175,29 @@ public class AmountApprovalManage { || ProjectStatus.CHANGE.eq(project.getStage())) { throw ReturnException.wrap("暂不允许下达资金"); } - BigDecimal totalApprovalAmount = ObjUtil.defaultIfNull(project.getApprovalAmount(), BigDecimal.ZERO); - boolean approved = DecimalUtil.noNullAndGtZero(totalApprovalAmount); - if (!approved && req.getReviewAmount() == null) { - throw ReturnException.wrap("评审总投资不能为空"); - } - BigDecimal currTotalApprovalAmount = NumberUtil.add(totalApprovalAmount, req.getApprovalAmount()); - if (approved && NumberUtil.isGreater(currTotalApprovalAmount, project.getReviewAmount())) { + boolean approved = DecimalUtil.noNullAndGtZero(project.getApprovalAmount()); + BigDecimal reviewAmount = approved ? project.getReviewAmount() : req.getReviewAmount(); + BigDecimal currTotalApprovalAmount = NumberUtil.add(project.getApprovalAmount(), req.getApprovalAmount()); + if (req.getApprovalAmount() != null && NumberUtil.isGreater(currTotalApprovalAmount, reviewAmount)) { throw ReturnException.wrap("暂不允许下达资金"); } - ProjectApprovalAmount lastApprovalAmount = projectApprovalAmountService.getByProjectCode(project.getProjectCode()); - if (lastApprovalAmount != null && req.getCarryOverAmount() != null - && NumberUtil.isGreater(req.getCarryOverAmount(), lastApprovalAmount.getApprovalAmount())) { - throw ReturnException.wrap("结转资金不允许超过上一年度下达资金"); + if (approved) { + if (ObjUtil.isAllEmpty(req.getCarryOverAmount(), req.getApprovalAmount())) { + throw ReturnException.wrap("下达资金或结转资金不能为空"); + } + if (req.getCarryOverAmount() != null) { + ProjectApprovalAmount lastApprovalAmount = projectApprovalAmountService.getByProjectCode(project.getProjectCode()); + if (lastApprovalAmount != null && lastApprovalAmount.getApprovalAmount() == null) { + throw ReturnException.wrap("上一年度未下达资金"); + } + if (lastApprovalAmount != null && NumberUtil.isGreater(req.getCarryOverAmount(), lastApprovalAmount.getApprovalAmount())) { + throw ReturnException.wrap("结转资金不允许超过上一年度下达资金"); + } + } + } else if (ObjUtil.hasNull(req.getReviewAmount() == null, req.getApprovalAmount())) { + throw ReturnException.wrap("评审总投资和下达资金不能为空"); } + Wrapper wrapper = Wrappers.lambdaUpdate(Project.class) .set(StrUtil.isNotBlank(req.getApprovalAmountFile()), Project::getApprovalAmountFile, req.getApprovalAmountFile()) .set(Project::getApprovalAmount, currTotalApprovalAmount) @@ -201,7 +212,7 @@ public class AmountApprovalManage { projectApprovalAmount.setApprovalAmount(req.getApprovalAmount()); projectApprovalAmount.setProjectId(project.getId()); projectApprovalAmount.setProjectCode(project.getProjectCode()); - projectApprovalAmount.setCarryOverAmount(req.getApprovalAmount()); + projectApprovalAmount.setCarryOverAmount(req.getCarryOverAmount()); projectApprovalAmountService.save(projectApprovalAmount); projectService.update(wrapper); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java index 46996c6..6b02728 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java @@ -22,7 +22,6 @@ public class SubmitAmountApprovalReq { private Long projectId; @ApiModelProperty("批复金额") - @NotNull(message = "批复金额不能为空") private BigDecimal approvalAmount; @ApiModelProperty("上一年度结转金额")