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