|
|
@@ -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<Project> 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<Project> 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); |
|
|
|
} |
|
|
|