Browse Source

modify:

1. 资金下达增加结转资金;
tags/24102401
WendyYang 2 months ago
parent
commit
49e9399644
5 changed files with 44 additions and 28 deletions
  1. +7
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java
  2. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/ProjectApprovalAmount.java
  3. +32
    -23
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java
  4. +2
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java
  5. +2
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectApprovalAmountService.java

+ 7
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java View File

@@ -84,4 +84,11 @@ public class DecimalUtil {
return objs.stream().min(Comparator.comparing(function)).orElse(null);
}

public static BigDecimal sum(BigDecimal... nums) {
if (ArrayUtil.isEmpty(nums)) {
return BigDecimal.ZERO;
}
return Arrays.stream(nums).filter(Objects::nonNull).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
}

}

+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/ProjectApprovalAmount.java View File

@@ -30,7 +30,7 @@ public class ProjectApprovalAmount implements Serializable {
@ApiModelProperty("下达资金")
private BigDecimal approvalAmount;

@ApiModelProperty("上一年度结转资金")
@ApiModelProperty("结转资金")
private BigDecimal carryOverAmount;

@ApiModelProperty("年度")


+ 32
- 23
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java View File

@@ -181,49 +181,51 @@ public class AmountApprovalManage {
if (req.getApprovalAmount() != null && NumberUtil.isGreater(currTotalApprovalAmount, reviewAmount)) {
throw ReturnException.wrap("暂不允许下达资金");
}
Integer nextYear = null;
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("结转资金不允许超过上一年度下达资金");
ProjectApprovalAmount last = projectApprovalAmountService.last(project.getProjectCode());
BigDecimal lastTotalAmount = DecimalUtil.sum(last.getApprovalAmount(), last.getCarryOverAmount());
if (NumberUtil.isGreater(req.getCarryOverAmount(), lastTotalAmount)) {
throw ReturnException.wrap("结转资金不允许超过上一年度总资金");
}
nextYear = last.getApprovalYear() + 1;
}
} 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)
.set(req.getReviewAmount() != null, Project::getReviewAmount, req.getReviewAmount())
.set(Project::getUpdateOn, LocalDateTime.now())
.set(Project::getUpdateBy, LoginUserUtil.getUserId())
.eq(Project::getId, project.getId());

Integer currProjectYear = getLastApprovalYear(project);
if (nextYear == null) {
nextYear = getLastApprovalYear(project);
}
if (req.getApprovalAmount() != null) {
Wrapper<Project> projectWrapper = Wrappers.lambdaUpdate(Project.class)
.set(StrUtil.isNotBlank(req.getApprovalAmountFile()), Project::getApprovalAmountFile, req.getApprovalAmountFile())
.set(Project::getApprovalAmount, currTotalApprovalAmount)
.set(req.getReviewAmount() != null, Project::getReviewAmount, req.getReviewAmount())
.set(Project::getUpdateOn, LocalDateTime.now())
.set(Project::getUpdateBy, LoginUserUtil.getUserId())
.eq(Project::getId, project.getId());
projectService.update(projectWrapper);
}
ProjectApprovalAmount projectApprovalAmount = new ProjectApprovalAmount();
projectApprovalAmount.setApprovalYear(currProjectYear);
projectApprovalAmount.setApprovalYear(nextYear);
projectApprovalAmount.setApprovalAmount(req.getApprovalAmount());
projectApprovalAmount.setProjectId(project.getId());
projectApprovalAmount.setProjectCode(project.getProjectCode());
projectApprovalAmount.setCarryOverAmount(req.getCarryOverAmount());
projectApprovalAmountService.save(projectApprovalAmount);
projectService.update(wrapper);
}

private Integer getLastApprovalYear(Project project) {
ProjectApprovalAmount lastApprovalAmount = projectApprovalAmountService.getByProjectCode(project.getProjectCode());
ProjectApprovalAmount last = projectApprovalAmountService.last(project.getProjectCode());
Integer currProjectYear;
if (lastApprovalAmount == null) {
if (last == null) {
currProjectYear = project.getProjectYear();
} else {
currProjectYear = lastApprovalAmount.getApprovalYear() + 1;
currProjectYear = last.getApprovalYear() + 1;
}
return currProjectYear;
}
@@ -247,8 +249,15 @@ public class AmountApprovalManage {
}

public List<ProjectApprovalAmountDTO> listApprovalAmounts(String projectCode) {
List<ProjectApprovalAmount> approvalAmounts = projectApprovalAmountService.listByProjectCode(projectCode);
return BeanUtil.copyToList(approvalAmounts, ProjectApprovalAmountDTO.class);
List<ProjectApprovalAmount> approvalAmounts = projectApprovalAmountService.listAsc(projectCode);
List<ProjectApprovalAmountDTO> retData = BeanUtil.copyToList(approvalAmounts, ProjectApprovalAmountDTO.class);
for (int i = 0; i < retData.size() - 1; i++) {
ProjectApprovalAmountDTO curr = retData.get(i);
ProjectApprovalAmountDTO next = retData.get(i + 1);
curr.setCarryOverAmount(next.getCarryOverAmount());
next.setCarryOverAmount(null);
}
return retData;
}

}

+ 2
- 2
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java View File

@@ -150,6 +150,7 @@ public class ProjectLibManage {
private final ProjectReviewManage projectReviewManage;
private final IMeetingInnerProjectService meetingInnerProjectService;
private final IProjectApprovalAmountService projectApprovalAmountService;
private final AmountApprovalManage amountApprovalManage;

public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) {
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req);
@@ -717,8 +718,7 @@ public class ProjectLibManage {
retProjectDetail.buildDynamicForm(project.getDynamicForm());
String projectCode = project.getProjectCode();
if (DecimalUtil.noNullAndGtZero(project.getApprovalAmount())) {
List<ProjectApprovalAmount> approvalAmounts = projectApprovalAmountService.listByProjectCode(projectCode);
retProjectDetail.setApprovalAmounts(BeanUtil.copyToList(approvalAmounts, ProjectApprovalAmountDTO.class));
retProjectDetail.setApprovalAmounts(amountApprovalManage.listApprovalAmounts(projectCode));
}
// 查询应用
List<ProjectApplication> applications = applicationService.list(projectCode, project.getVersion(), project.getIsConstruct());


+ 2
- 2
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/IProjectApprovalAmountService.java View File

@@ -18,7 +18,7 @@ import java.util.List;
*/
public interface IProjectApprovalAmountService extends IService<ProjectApprovalAmount> {

default ProjectApprovalAmount getByProjectCode(String projectCode) {
default ProjectApprovalAmount last(String projectCode) {
Wrapper<ProjectApprovalAmount> query = Wrappers.lambdaQuery(ProjectApprovalAmount.class)
.eq(ProjectApprovalAmount::getProjectCode, projectCode)
.orderByDesc(ProjectApprovalAmount::getApprovalYear)
@@ -26,7 +26,7 @@ public interface IProjectApprovalAmountService extends IService<ProjectApprovalA
return getOne(query);
}

default List<ProjectApprovalAmount> listByProjectCode(String projectCode) {
default List<ProjectApprovalAmount> listAsc(String projectCode) {
Wrapper<ProjectApprovalAmount> query = Wrappers.lambdaQuery(ProjectApprovalAmount.class)
.eq(ProjectApprovalAmount::getProjectCode, projectCode)
.orderByAsc(ProjectApprovalAmount::getApprovalYear);


Loading…
Cancel
Save