From e6b26674b3b81bd76587ca84d966827468b20130 Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Mon, 19 Jun 2023 11:12:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=A1=A3=E6=A1=88=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/filemanage/manage/ProjectFileManage.java | 129 +++++++-------------- 1 file changed, 40 insertions(+), 89 deletions(-) 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 7d4b1ed..bdba048 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 @@ -80,81 +80,37 @@ public class ProjectFileManage { Integer pageNumber = param.getPageNumber(); Integer pageSize = param.getPageSize(); - // 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.ARCHIVED.getCode()) - // .orderByDesc(Project::getUpdateOn)); - //if(0L == page.getTotal()){ - // return PageVo.empty(); - //} - //List vos = page.getRecords().stream().map(p -> { - // ProjectFileListVO vo = new ProjectFileListVO(); - // vo.setId(p.getId()); - // // 判断该项目是否可以查阅(用户只可查阅自己及下属单位的项目档案) - // List ordCodeList = Lists.newArrayList(); - // String empPosUnitCode = userFullInfo.getEmpPosUnitCode(); - // ordCodeList.add(empPosUnitCode); - // List 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 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.ARCHIVED.getCode()) - .orderByDesc(Project::getUpdateOn)); + .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)); // 从申请借阅信息表中查出本单位及下属单位审批通过的项目添加到列表中 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()); + 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)){ + 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()); - if (CollUtil.isEmpty(projectList)){ + if (CollUtil.isEmpty(projects)) { return PageVo.empty(); } - List records = projectList.stream().skip((long) (pageNumber - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); + List records = + projects.stream().skip((long)(pageNumber - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); List vos = records.stream().map(p -> { ProjectFileListVO vo = new ProjectFileListVO(); @@ -169,35 +125,32 @@ public class ProjectFileManage { // 判断当前项目,当前登录用户是否已经开启了申请借阅并且没有审批完成 String instCode = p.getInstCode(); // 获取流程实例 - HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery() - .processInstanceId(instCode) - .singleResult(); - ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) - .eq(ProjectInst::getInstCode, instCode)); + 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())){ + 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,projectList.size()); + return PageVo.of(vos, projectList.size()); } private Set getSubOrgList(String empPosUnitCode) { HashSet orgSet = new HashSet<>(); // 先将自己加入子集 orgSet.add(empPosUnitCode); - Set subOrgList = dingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) - .eq(DingOrganization::getParentCode, empPosUnitCode)).stream() - .map(DingOrganization::getOrganizationCode) - .collect(Collectors.toSet()); + Set 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)); @@ -208,7 +161,6 @@ public class ProjectFileManage { public ProjectFileVO file(Long projectId) { ProjectDetailVO projectDetailVo = projectLibManage.getProjectDetail(projectId); - return null; } @@ -224,16 +176,14 @@ public class ProjectFileManage { Project project = projectService.getNewProject(projectId); VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!"); - //首先要判断 项目当前状态 是不是 已归档 - VUtils.isTrue(!ProjectStatusEnum.ARCHIVED.getCode().equals(project.getStatus())) - .throwMessage("提交失败 该项目不是 已归档"); + // 首先要判断 项目当前状态 是不是 已归档 + VUtils.isTrue(!ProjectStatusEnum.ARCHIVED.getCode().equals(project.getStatus())).throwMessage("提交失败 该项目不是 已归档"); String regionCode = user.getRegionCode(); WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) - .eq(WflowModels::getRegionCode, regionCode) - .eq(WflowModels::getProcessType, ProjectProcessStageEnum.APPLY_BORROW.getCode()) - .last(BizConst.LIMIT_1)); + .eq(WflowModels::getRegionCode, regionCode) + .eq(WflowModels::getProcessType, ProjectProcessStageEnum.APPLY_BORROW.getCode()).last(BizConst.LIMIT_1)); if (Objects.isNull(model)) { log.error("此 【{}】区域找不到申请借阅流程配置", regionCode); @@ -243,20 +193,21 @@ public class ProjectFileManage { ProcessStartParamsVo params = new ProcessStartParamsVo(); params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); params.setProcessUsers(Collections.emptyMap()); - //放入条件判断的项目字段 - //把条件值给放入工作流 + // 放入条件判断的项目字段 + // 把条件值给放入工作流 defaultDeclaredProjectManage.buildCondition(params, project); // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode, project); - String instanceId = processInstanceService.newStartProcess(model.getProcessDefId(), model.getFormId(), params, orgModelMap); + String instanceId = + processInstanceService.newStartProcess(model.getProcessDefId(), model.getFormId(), params, orgModelMap); log.info("申请借阅申报成功 【{}】", instanceId); // 保存项目借阅实例相关 projectLibManage.saveProjectByApplyBorrow(project, user, instanceId); - //发送给第一个审批人消息 - noticeManage.sendFirtUser(project,model.getFormName(),instanceId, - WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); + // 发送给第一个审批人消息 + noticeManage.sendFirtUser(project, model.getFormName(), instanceId, WorkNoticeContant.PASS_MSG_TEMPLATE, + MsgTypeEnum.PROJECT_REVIEW); return instanceId; }