瀏覽代碼

modify:

1. 资金下达相关接口;
tags/24090601
WendyYang 2 月之前
父節點
當前提交
255febb130
共有 2 個文件被更改,包括 20 次插入24 次删除
  1. +4
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java
  2. +16
    -24
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java

+ 4
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java 查看文件

@@ -24,6 +24,10 @@ public class DecimalUtil {
private DecimalUtil() {
}

public static boolean notNullAndGtZero(BigDecimal num) {
return num != null && num.compareTo(BigDecimal.ZERO) > 0;
}

@SafeVarargs
public static <T> BigDecimal sum(Collection<T> objs, Function<T, BigDecimal>... functions) {
if (CollUtil.isEmpty(objs) || ArrayUtil.isEmpty(functions)) {


+ 16
- 24
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java 查看文件

@@ -2,12 +2,12 @@ package com.hz.pm.api.projectlib.manage;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.common.util.DecimalUtil;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.hz.pm.api.datascope.utils.DataScopeUtil;
import com.hz.pm.api.projectlib.helper.ProjectManageUtil;
@@ -16,8 +16,6 @@ import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.req.SubmitAmountApprovalReq;
import com.hz.pm.api.projectlib.model.vo.AmountApprovalProgressStatisticsVO;
import com.hz.pm.api.projectlib.model.vo.AnnualPlanListItemVO;
import com.hz.pm.api.projectlib.model.vo.AnnualPlanProgressStatisticsVO;
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.user.helper.MhUnitCache;
@@ -29,7 +27,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

@@ -98,15 +95,7 @@ public class AmountApprovalManage {
ProjectManageUtil.projectBaseQuery(query);
query.eq(Project::getNewest, Boolean.TRUE)
.ne(Project::getStage, ProjectStatus.STOPPED.getCode());
if (req.getIsAmountApproval() != null) {
if (Boolean.TRUE.equals(req.getIsAmountApproval())) {
query.gt(Project::getApprovalAmount, 0)
.isNotNull(Project::getApprovalAmount);
} else {
query.and(q -> q.isNull(Project::getApprovalAmount)
.or(q1 -> q1.le(Project::getApprovalAmount, 0)));
}
}
buildAmountApprovalFilter(req.getIsAmountApproval(), query);
Page<Project> page = projectService.page(req.page(), query);
long total = page.getTotal();
if (total == 0) {
@@ -131,6 +120,18 @@ public class AmountApprovalManage {
return PageVo.of(records, total);
}

private static void buildAmountApprovalFilter(Boolean isAmountApproval, LambdaQueryWrapper<Project> query) {
if (isAmountApproval != null) {
if (Boolean.TRUE.equals(isAmountApproval)) {
query.gt(Project::getApprovalAmount, 0)
.isNotNull(Project::getApprovalAmount);
} else {
query.and(q -> q.isNull(Project::getApprovalAmount)
.or(q1 -> q1.le(Project::getApprovalAmount, 0)));
}
}
}

public AmountApprovalProgressStatisticsVO progressStatistics(ProjectListReq req) {
LambdaQueryWrapper<Project> query = ProjectManageUtil.initQuery();
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
@@ -141,20 +142,11 @@ public class AmountApprovalManage {
ProjectManageUtil.projectBaseQuery(query);
query.eq(Project::getNewest, Boolean.TRUE)
.ne(Project::getStage, ProjectStatus.STOPPED.getCode());
if (req.getIsAmountApproval() != null) {
if (Boolean.TRUE.equals(req.getIsAmountApproval())) {
query.gt(Project::getApprovalAmount, 0)
.isNotNull(Project::getApprovalAmount);
} else {
query.and(q -> q.isNull(Project::getApprovalAmount)
.or(q1 -> q1.le(Project::getApprovalAmount, 0)));
}
}
buildAmountApprovalFilter(req.getIsAmountApproval(), query);
List<Project> page = projectService.list(query);
AmountApprovalProgressStatisticsVO stat = new AmountApprovalProgressStatisticsVO();
stat.setTotalCount(page.size());
stat.setApprovalCount(CollUtil.count(page, w -> w.getApprovalAmount() != null
&& NumberUtil.isGreater(w.getApprovalAmount(), BigDecimal.ZERO)));
stat.setApprovalCount(CollUtil.count(page, w -> DecimalUtil.notNullAndGtZero(w.getApprovalAmount())));
stat.setUnApprovalCount(stat.getTotalCount() - stat.getApprovalCount());
return stat;
}


Loading…
取消
儲存