Parcourir la source

IRS档案

tags/24080901
PoffyZhang il y a 1 an
Parent
révision
887a8ff7e0
1 fichiers modifiés avec 25 ajouts et 7 suppressions
  1. +25
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/IrsProjectManage.java

+ 25
- 7
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/IrsProjectManage.java Voir le fichier

@@ -1,23 +1,24 @@
package com.ningdatech.pmapi.irs.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
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.google.common.collect.Lists;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.dashboard.model.vo.ProtraitProjectOutputVO;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
@@ -40,25 +41,42 @@ public class IrsProjectManage {
*/
public PageVo<ProjectLibListItemVO> list(ProjectListReq req) {
Page<Project> page = req.page();
UserInfoDetails user = LoginUserUtil.loginUserDetail();
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class)
.eq(StringUtils.isNotBlank(req.getAreaCode()),Project::getAreaCode,req.getAreaCode())
.eq(StringUtils.isNotBlank(req.getRegionCode()),Project::getAreaCode,req.getRegionCode())
.eq(StringUtils.isNotBlank(req.getProjectType()),Project::getProjectType,req.getProjectType())
.eq(Objects.nonNull(req.getStatus()),Project::getStatus,req.getStatus())
.eq(Objects.nonNull(req.getStage()),Project::getStage,req.getStage())
.ge(Objects.nonNull(req.getApproveAmountMin()),Project::getApprovalAmount,req.getApproveAmountMin())
.le(Objects.nonNull(req.getApproveAmountMax()),Project::getApprovalAmount,req.getApproveAmountMax())
.eq(Objects.nonNull(req.getProjectYear()),Project::getProjectYear,req.getProjectYear())
.ge(Objects.nonNull(req.getCreateOnMin()),Project::getCreateOn,req.getCreateOnMin())
.le(Objects.nonNull(req.getCreateOnMax()),Project::getCreateOn,req.getCreateOnMax())
.like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName())
.like(StringUtils.isNotBlank(req.getBuildOrgName()),Project::getBuildOrgName,req.getBuildOrgName())
.gt(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode())
.orderByDesc(Project::getUpdateOn);
buildPermission(wrapper,user);
projectService.page(page,wrapper);

if(CollUtil.isEmpty(page.getRecords())){
return PageVo.empty();
}
List<ProjectLibListItemVO> res = page.getRecords().stream().map(p -> {
ProjectLibListItemVO vo = new ProjectLibListItemVO();
vo.setId(p.getId());
vo.setProjectName(p.getProjectName());
vo.setProjectCode(p.getProjectCode());
ProjectLibListItemVO vo = BeanUtil.copyProperties(p,ProjectLibListItemVO.class);
return vo;
}).collect(Collectors.toList());
return PageVo.of(res,page.getTotal());
}

private void buildPermission(LambdaQueryWrapper<Project> wrapper, UserInfoDetails user) {
if(user.getSuperAdmin()){
log.info("超管 都可看 项目档案列表");
}else if(user.getRegionAdmin()){
wrapper.eq(Project::getAreaCode,user.getRegionCode());
}else{
wrapper.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode());
}
}
}

Chargement…
Annuler
Enregistrer