diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java index 1fab0be..6134969 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java @@ -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 subOrgSet = getSubOrgList(empPosUnitCode); - List 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 borrowProjectIdSet = new HashSet<>(); - List 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 projectIdSet = new HashSet<>(); - List projects = - projectList.stream().filter(p -> projectIdSet.add(p.getId())).collect(Collectors.toList()); + Page 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 records = - projects.stream().skip((long)(pageNumber - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); + // 获取本单位及下属单位的单位code + Set subOrgSet = getSubOrgList(empPosUnitCode); - List vos = records.stream().map(p -> { + List 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 subOrgSet, Project project) { + // 从申请借阅信息表中查出本单位及下属单位审批通过的项目 + HashSet borrowProjectIdSet = new HashSet<>(); + List 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 getSubOrgList(String empPosUnitCode) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java index 7e77620..88814c9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java @@ -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);