Browse Source

项目档案列表修改

master
CMM 1 year ago
parent
commit
e33342d676
1 changed files with 116 additions and 13 deletions
  1. +116
    -13
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java

+ 116
- 13
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java View File

@@ -1,15 +1,21 @@
package com.ningdatech.pmapi.filemanage.manage;

import cn.hutool.core.collection.CollUtil;
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.function.VUtils;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.filemanage.model.entity.ProjectApplyBorrow;
import com.ningdatech.pmapi.filemanage.model.param.ProjectFileListParam;
import com.ningdatech.pmapi.filemanage.model.vo.ProjectFileListVO;
import com.ningdatech.pmapi.filemanage.model.vo.ProjectFileVO;
import com.ningdatech.pmapi.filemanage.service.INdProjectApplyBorrowService;
import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage;
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
@@ -34,15 +40,13 @@ import com.wflow.workflow.service.ProcessModelService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.flowable.engine.HistoryService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;

/**
@@ -65,25 +69,103 @@ public class ProjectFileManage {
private final NoticeManage noticeManage;
private final IProjectInstService projectInstService;
private final HistoryService historyService;
private final INdProjectApplyBorrowService projectApplyBorrowService;
private final IDingOrganizationService dingOrganizationService;

public PageVo<ProjectFileListVO> list(ProjectFileListParam param) {
Page<Project> page = param.page();
projectService.page(page,Wrappers.lambdaQuery(Project.class)
.like(StringUtils.isNotBlank(param.getProjectName()),Project::getProjectName,param.getProjectName())
.like(StringUtils.isNotBlank(param.getBuildOrgName()),Project::getBuildOrgName,param.getBuildOrgName())

UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
String employeeCode = userFullInfo.getEmployeeCode();
String empPosUnitCode = userFullInfo.getEmpPosUnitCode();
Integer pageNumber = param.getPageNumber();
Integer pageSize = param.getPageSize();

// Page<Project> page = param.page();
//projectService.page(page,Wrappers.lambdaQuery(Project.class)
// .like(StringUtils.isNotBlank(param.getProjectName()),Project::getProjectName,param.getProjectName())
// .like(StringUtils.isNotBlank(param.getBuildOrgName()),Project::getBuildOrgName,param.getBuildOrgName())
// .eq(Project::getStatus,ProjectStatusEnum.ARCHIVED.getCode())
// .orderByDesc(Project::getUpdateOn));
//if(0L == page.getTotal()){
// return PageVo.empty();
//}
//List<ProjectFileListVO> vos = page.getRecords().stream().map(p -> {
// ProjectFileListVO vo = new ProjectFileListVO();
// vo.setId(p.getId());
// // 判断该项目是否可以查阅(用户只可查阅自己及下属单位的项目档案)
// List<String> ordCodeList = Lists.newArrayList();
// String empPosUnitCode = userFullInfo.getEmpPosUnitCode();
// ordCodeList.add(empPosUnitCode);
// List<DingOrganization> subOrgList = dingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
// .eq(DingOrganization::getParentCode, empPosUnitCode));
// if (CollUtil.isNotEmpty(subOrgList)){
//
// }
//
// vo.setCanRead(Boolean.TRUE);
// vo.setBuildOrgName(p.getBuildOrgName());
// vo.setPojectCode(p.getProjectCode());
// vo.setProjectName(p.getProjectName());
// // 判断当前项目,当前登录用户是否已经开启了申请借阅并且没有审批完成
// String instCode = p.getInstCode();
// // 获取流程通过后的流程实例
// HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery()
// .processInstanceId(instCode)
// .singleResult();
// ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
// .eq(ProjectInst::getInstCode, instCode));
// Integer instType = projectInst.getInstType();
// // 从申请借阅信息表中查询当前项目是否有当前登录用户发起的申请借阅审批流程
// ProjectApplyBorrow applyBorrow = projectApplyBorrowService.getOne(Wrappers.lambdaQuery(ProjectApplyBorrow.class)
// .eq(ProjectApplyBorrow::getApplyBorrowEmployeeCode, employeeCode)
// .eq(ProjectApplyBorrow::getProjectId, p.getId())
// .eq(ProjectApplyBorrow::getInstanceId, instCode));
// if (Objects.nonNull(applyBorrow) && InstTypeEnum.APPLY_BORROW.getCode().equals(instType) &&
// !HisProInsEndActId.END.equals(newInstance.getEndActivityId())){
// vo.setCanApplyBorrow(Boolean.FALSE);
// }
// return vo;
//}).collect(Collectors.toList());
//return PageVo.of(vos,page.getTotal());

Set<String> subOrgSet = getSubOrgList(empPosUnitCode);
List<Project> projectList = projectService.list(Wrappers.lambdaQuery(Project.class)
.like(StringUtils.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName())
.like(StringUtils.isNotBlank(param.getBuildOrgName()), Project::getBuildOrgName, param.getBuildOrgName())
.eq(Project::getStatus, ProjectStatusEnum.ARCHIVED.getCode())
// 查出自己及下属单位可查阅的项目档案
.in(Project::getBuildOrgCode,subOrgSet)
.orderByDesc(Project::getUpdateOn));

if(0L == page.getTotal()){
// 从申请借阅信息表中查出本单位审批通过的项目添加到列表中
HashSet<Long> borrowProjectIdSet = new HashSet<>();
List<ProjectApplyBorrow> applyBorrowList = projectApplyBorrowService.list(Wrappers.lambdaQuery(ProjectApplyBorrow.class)
.eq(ProjectApplyBorrow::getApplyBorrowEmpPosUnitCode, empPosUnitCode)
.eq(ProjectApplyBorrow::getIsSuccess, Boolean.TRUE)).stream()
.filter(a -> borrowProjectIdSet.add(a.getProjectId()))
.collect(Collectors.toList());
for (ProjectApplyBorrow applyBorrow : applyBorrowList) {
Long projectId = applyBorrow.getProjectId();
if (Objects.nonNull(projectId)){
Project project = projectService.getById(projectId);
projectList.add(project);
}
}

if (CollUtil.isEmpty(projectList)){
return PageVo.empty();
}
List<ProjectFileListVO> vos = page.getRecords().stream().map(p -> {

List<Project> records = projectList.stream().skip((long) (pageNumber - 1) * pageSize).limit(pageSize).collect(Collectors.toList());

List<ProjectFileListVO> vos = records.stream().map(p -> {
ProjectFileListVO vo = new ProjectFileListVO();
vo.setId(p.getId());
vo.setCanRead(Boolean.TRUE);
vo.setBuildOrgName(p.getBuildOrgName());
vo.setPojectCode(p.getProjectCode());
vo.setProjectName(p.getProjectName());
// 判断当前项目是否已经开启了申请借阅并且没有审批完成
// 判断当前项目,当前登录用户是否已经开启了申请借阅并且没有审批完成
String instCode = p.getInstCode();
// 获取流程通过后的流程实例
HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery()
@@ -92,13 +174,34 @@ public class ProjectFileManage {
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.eq(ProjectInst::getInstCode, instCode));
Integer instType = projectInst.getInstType();
if (InstTypeEnum.APPLY_BORROW.getCode().equals(instType) &&
// 从申请借阅信息表中查询当前项目是否有当前登录用户发起的申请借阅审批流程
ProjectApplyBorrow applyBorrow = projectApplyBorrowService.getOne(Wrappers.lambdaQuery(ProjectApplyBorrow.class)
.eq(ProjectApplyBorrow::getApplyBorrowEmployeeCode, employeeCode)
.eq(ProjectApplyBorrow::getProjectId, p.getId())
.eq(ProjectApplyBorrow::getInstanceId, instCode));
if (Objects.nonNull(applyBorrow) && InstTypeEnum.APPLY_BORROW.getCode().equals(instType) &&
!HisProInsEndActId.END.equals(newInstance.getEndActivityId())){
vo.setCanApplyBorrow(Boolean.FALSE);
}
return vo;
}).collect(Collectors.toList());
return PageVo.of(vos,page.getTotal());

return PageVo.of(vos,projectList.size());
}

private Set<String> getSubOrgList(String empPosUnitCode) {
HashSet<String> orgSet = new HashSet<>();
// 先将自己加入子集
orgSet.add(empPosUnitCode);
Set<String> subOrgList = dingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getParentCode, empPosUnitCode)).stream()
.map(DingOrganization::getOrganizationCode)
.collect(Collectors.toSet());
// 遍历子集
for (String orgCode : subOrgList) {
orgSet.addAll(getSubOrgList(orgCode));
}
return orgSet;
}

public ProjectFileVO file(Long projectId) {


Loading…
Cancel
Save