Browse Source

Merge remote-tracking branch 'origin/master'

tags/24080901
PoffyZhang 1 year ago
parent
commit
a495ce30f1
2 changed files with 29 additions and 43 deletions
  1. +25
    -41
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java
  2. +4
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java

+ 25
- 41
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java View File

@@ -4,13 +4,13 @@ import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.exception.BizException;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.file.entity.File;
import com.ningdatech.file.entity.vo.result.AttachFileVo;
import com.ningdatech.file.service.FileService;
import com.ningdatech.file.utils.StrPool;
import com.ningdatech.pmapi.common.constant.BizConst;
@@ -59,11 +59,7 @@ import com.wflow.workflow.service.ProcessInstanceService;
import com.wflow.workflow.service.ProcessModelService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.flowable.engine.HistoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
@@ -71,11 +67,8 @@ import org.flowable.engine.task.Comment;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
@@ -115,46 +108,26 @@ public class ProjectFileManage {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
String employeeCode = userFullInfo.getEmployeeCode();
String empPosUnitCode = userFullInfo.getEmpPosUnitCode();
Integer pageNumber = param.getPageNumber();
Integer pageSize = param.getPageSize();

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.ACCEPTED.getCode()).orderByDesc(Project::getUpdateOn));

// 从申请借阅信息表中查出本单位及下属单位审批通过的项目添加到列表中
HashSet<Long> borrowProjectIdSet = new HashSet<>();
List<ProjectApplyBorrow> applyBorrowList = projectApplyBorrowService
.list(Wrappers.lambdaQuery(ProjectApplyBorrow.class)
.in(ProjectApplyBorrow::getApplyBorrowEmpPosUnitCode, subOrgSet)
.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);
}
}
// 对整合后的档案列表去重
HashSet<Long> projectIdSet = new HashSet<>();
List<Project> projects =
projectList.stream().filter(p -> projectIdSet.add(p.getId())).collect(Collectors.toList());
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.ACCEPTED.getCode())
.orderByDesc(Project::getUpdateOn));

if (CollUtil.isEmpty(projects)) {
if(0L == page.getTotal()){
return PageVo.empty();
}

List<Project> records =
projects.stream().skip((long)(pageNumber - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
// 获取本单位及下属单位的单位code
Set<String> subOrgSet = getSubOrgList(empPosUnitCode);

List<ProjectFileListVO> vos = records.stream().map(p -> {
List<ProjectFileListVO> vos = page.getRecords().stream().map(p -> {
ProjectFileListVO vo = new ProjectFileListVO();
vo.setId(p.getId());
// 用户只可查阅自己及下属单位的项目档案
if (subOrgSet.contains(p.getBuildOrgCode())) {
// 用户只可查阅自己及下属单位的项目档案和已经申请借阅通过的项目档案
if (subOrgSet.contains(p.getBuildOrgCode()) || checkCanRead(subOrgSet,p)) {
vo.setCanRead(Boolean.TRUE);
}
vo.setBuildOrgName(p.getBuildOrgName());
@@ -182,7 +155,18 @@ public class ProjectFileManage {
return vo;
}).collect(Collectors.toList());

return PageVo.of(vos, projects.size());
return PageVo.of(vos, page.getTotal());
}

private boolean checkCanRead(Set<String> subOrgSet, Project project) {
// 从申请借阅信息表中查出本单位及下属单位审批通过的项目
HashSet<Long> borrowProjectIdSet = new HashSet<>();
List<Long> applyBorrowProjectIdList = projectApplyBorrowService
.list(Wrappers.lambdaQuery(ProjectApplyBorrow.class)
.in(ProjectApplyBorrow::getApplyBorrowEmpPosUnitCode, subOrgSet)
.eq(ProjectApplyBorrow::getIsSuccess, Boolean.TRUE))
.stream().map(ProjectApplyBorrow::getProjectId).filter(borrowProjectIdSet::add).collect(Collectors.toList());
return applyBorrowProjectIdList.contains(project.getId());
}

private Set<String> getSubOrgList(String empPosUnitCode) {


+ 4
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java View File

@@ -93,8 +93,10 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle {
.eq(ProjectStatusChange::getProjectId, projectId)
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.PROJECT_APPROVAL.name())
.last("limit 1"));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
if (Objects.nonNull(projectStatusChange)) {
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
}
}
processDetailVO.setProcessName(CommonConst.PROJECT_APPROVAL);
processSchedule.add(processDetailVO);


Loading…
Cancel
Save