|
|
@@ -0,0 +1,173 @@ |
|
|
|
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.datascope.model.DataScopeDTO; |
|
|
|
import com.hz.pm.api.datascope.utils.DataScopeUtil; |
|
|
|
import com.hz.pm.api.projectlib.helper.ProjectManageUtil; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.Project; |
|
|
|
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; |
|
|
|
import com.hz.pm.api.user.security.model.UserFullInfoDTO; |
|
|
|
import com.hz.pm.api.user.util.LoginUserUtil; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
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; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* AmountApprovalManage |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @author WendyYang |
|
|
|
* @since 17:10 2024/9/4 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class AmountApprovalManage { |
|
|
|
|
|
|
|
private final IProjectService projectService; |
|
|
|
private final UserInfoHelper userInfoHelper; |
|
|
|
private final MhUnitCache mhUnitCache; |
|
|
|
|
|
|
|
|
|
|
|
private boolean projectQueryPermission(LambdaQueryWrapper<Project> query, UserFullInfoDTO user) { |
|
|
|
boolean queryState = true; |
|
|
|
Optional<DataScopeDTO> currDs = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); |
|
|
|
if (!currDs.isPresent()) { |
|
|
|
log.warn("没有取到权限信息 当前查询 没有权限条件"); |
|
|
|
queryState = false; |
|
|
|
} else { |
|
|
|
switch (currDs.get().getRole()) { |
|
|
|
case NORMAL_MEMBER: |
|
|
|
//普通用户 只能看到自己单位去申报的 |
|
|
|
query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr()); |
|
|
|
break; |
|
|
|
case COMPANY_MANAGER: |
|
|
|
List<Long> childUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()); |
|
|
|
List<String> viewUnitIdList = CollUtils.convert(childUnitIds, String::valueOf); |
|
|
|
//单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 |
|
|
|
query.and(q1 -> q1.in(Project::getBuildOrgCode, viewUnitIdList) |
|
|
|
.or(q2 -> q2.eq(Project::getStage, ProjectStatus.NOT_APPROVED.getCode()) |
|
|
|
.in(Project::getSuperOrgCode, viewUnitIdList))); |
|
|
|
break; |
|
|
|
case SUPER_ADMIN: |
|
|
|
//超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 |
|
|
|
break; |
|
|
|
case VISITOR: |
|
|
|
//访客可以看全市的 |
|
|
|
break; |
|
|
|
case DASHBOARD: |
|
|
|
break; |
|
|
|
default: |
|
|
|
//没有权限的话 就让它查不到 |
|
|
|
queryState = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return queryState; |
|
|
|
} |
|
|
|
|
|
|
|
public PageVo<ProjectLibListItemVO> page(ProjectListReq req) { |
|
|
|
LambdaQueryWrapper<Project> query = ProjectManageUtil.initQuery(); |
|
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
|
if (!projectQueryPermission(query, user)) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
ProjectManageUtil.projectQuery(query, req); |
|
|
|
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))); |
|
|
|
} |
|
|
|
} |
|
|
|
Page<Project> page = projectService.page(req.page(), query); |
|
|
|
long total = page.getTotal(); |
|
|
|
if (total == 0) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { |
|
|
|
ProjectLibListItemVO item = new ProjectLibListItemVO(); |
|
|
|
item.setId(w.getId()); |
|
|
|
item.setProjectCode(w.getProjectCode()); |
|
|
|
item.setProjectName(w.getProjectName()); |
|
|
|
item.setStage(w.getStage()); |
|
|
|
item.setStatus(w.getStatus()); |
|
|
|
item.setProjectYear(w.getProjectYear()); |
|
|
|
item.setProjectType(w.getProjectType()); |
|
|
|
item.setDeclaredAmount(w.getDeclareAmount()); |
|
|
|
item.setBuildOrg(w.getBuildOrgName()); |
|
|
|
item.setCreateOn(w.getCreateOn()); |
|
|
|
item.setApprovedAmount(w.getApprovalAmount()); |
|
|
|
item.setReviewAmount(w.getReviewAmount()); |
|
|
|
return item; |
|
|
|
}); |
|
|
|
return PageVo.of(records, total); |
|
|
|
} |
|
|
|
|
|
|
|
public AmountApprovalProgressStatisticsVO progressStatistics(ProjectListReq req) { |
|
|
|
LambdaQueryWrapper<Project> query = ProjectManageUtil.initQuery(); |
|
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); |
|
|
|
if (!projectQueryPermission(query, user)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
ProjectManageUtil.projectQuery(query, req); |
|
|
|
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))); |
|
|
|
} |
|
|
|
} |
|
|
|
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.setUnApprovalCount(stat.getTotalCount() - stat.getApprovalCount()); |
|
|
|
return stat; |
|
|
|
} |
|
|
|
|
|
|
|
public void submitAmountApproval(SubmitAmountApprovalReq req) { |
|
|
|
Project project = projectService.getNewestNoNull(req.getProjectId()); |
|
|
|
Assert.isTrue(ProjectStatus.STOPPED.eq(project.getStage()), "项目终止中"); |
|
|
|
LambdaUpdateWrapper<Project> wrapper = Wrappers.lambdaUpdate(Project.class) |
|
|
|
.set(Project::getApprovalAmountFile, req.getApprovalAmountFile()) |
|
|
|
.set(Project::getApprovalAmount, req.getApprovalAmount()) |
|
|
|
.set(Project::getReviewAmount, req.getReviewAmount()) |
|
|
|
.eq(Project::getId, project.getId()); |
|
|
|
projectService.update(wrapper); |
|
|
|
} |
|
|
|
|
|
|
|
} |