From 1f8f14560b6bcb77fad0af8a15679261b53a82be Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Mon, 20 Mar 2023 23:01:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=85=E5=8A=9E=E4=B8=AD=E5=BF=83=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/common/util/ExcelDownUtil.java | 62 +++- .../projectlib/manage/AnnualPlanLibManage.java | 2 +- .../pmapi/projectlib/manage/ProjectLibManage.java | 2 +- .../controller/TodoCenterController.java | 8 +- .../pmapi/todocenter/manage/TodoCenterManage.java | 379 +++++++++++++-------- 5 files changed, 298 insertions(+), 155 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java index ff57b93..e6d760a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java @@ -16,7 +16,8 @@ import com.ningdatech.basic.util.NdDateUtils; import com.ningdatech.pmapi.common.enumeration.ExportOptionEnum; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.projectlib.model.entity.Project; -import com.wflow.workflow.enums.ProcessStatusEnum; +import com.wflow.workflow.bean.vo.ProcessInstanceVo; +import com.wflow.workflow.bean.vo.ProcessTaskVo; import org.apache.commons.collections4.CollectionUtils; import org.apache.http.HttpStatus; @@ -137,23 +138,24 @@ public class ExcelDownUtil { response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + encodeName(fileName) + ".xls"); } - public static List> getExportDatas(List columnList, List projects) { + public static List> getTaskExportDatas(List columnList,List taskVoList, Map projectInfoMap) { // 表体行数据集合 List> rowList = Lists.newArrayList(); for (ExportOptionEnum column : columnList) { List columnValues = Lists.newArrayList(); columnValues.add(column.getDesc()); - projects.stream().sorted(Comparator.comparing(Project::getId)).forEach(record -> { - String s = JSON.toJSONString(record); + taskVoList.stream().forEach(taskVo -> { + Project project = projectInfoMap.get(taskVo.getInstanceId()); + String s = JSON.toJSONString(project); JSONObject jsonObject = JSON.parseObject(s); String columnValue = null; if (column.name().equals(ExportOptionEnum.processStatusName.name())){ - columnValue = ProcessStatusEnum.getDescByCode(record.getProcessStatus()); + columnValue = taskVo.getStatus(); }else if (column.name().equals(ExportOptionEnum.processLaunchTime.name())){ - columnValue = NdDateUtils.format(record.getCreateOn(), "yyyy-MM-dd HH:mm"); + columnValue = NdDateUtils.format(taskVo.getCreateTime(), "yyyy-MM-dd HH:mm"); }else if (column.name().equals(ExportOptionEnum.processHandleTime.name())){ - columnValue = NdDateUtils.format(record.getUpdateOn(), "yyyy-MM-dd HH:mm"); + columnValue = NdDateUtils.format(taskVo.getTaskEndTime(), "yyyy-MM-dd HH:mm"); }else { columnValue = String.valueOf(jsonObject.get(column.toString())); } @@ -164,4 +166,50 @@ public class ExcelDownUtil { return rowList; } + + public static List> getInstExportDatas(List columnList,List instanceVoList, Map projectInfoMap) { + + // 表体行数据集合 + List> rowList = Lists.newArrayList(); + for (ExportOptionEnum column : columnList) { + List columnValues = Lists.newArrayList(); + columnValues.add(column.getDesc()); + instanceVoList.stream().forEach(instanceVo -> { + Project project = projectInfoMap.get(instanceVo.getInstanceId()); + String s = JSON.toJSONString(project); + JSONObject jsonObject = JSON.parseObject(s); + String columnValue = null; + if (column.name().equals(ExportOptionEnum.processStatusName.name())){ + columnValue = instanceVo.getStatus(); + }else if (column.name().equals(ExportOptionEnum.processLaunchTime.name())){ + columnValue = NdDateUtils.format(instanceVo.getStartTime(), "yyyy-MM-dd HH:mm"); + }else { + columnValue = String.valueOf(jsonObject.get(column.toString())); + } + columnValues.add(columnValue); + }); + rowList.add(columnValues); + } + return rowList; + } + + + public static List> getProjectExportDatas(List columnList,List projects) { + + // 表体行数据集合 + List> rowList = Lists.newArrayList(); + for (ExportOptionEnum column : columnList) { + List columnValues = Lists.newArrayList(); + columnValues.add(column.getDesc()); + projects.stream().forEach(project -> { + String s = JSON.toJSONString(project); + JSONObject jsonObject = JSON.parseObject(s); + String columnValue = String.valueOf(jsonObject.get(column.toString())); + columnValues.add(columnValue); + }); + rowList.add(columnValues); + } + return rowList; + } + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java index 82ef878..f2ca34f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java @@ -248,7 +248,7 @@ public class AnnualPlanLibManage { List sheetsNames = new ArrayList<>(); sheetsNames.add(fileName); // 表体行数据集合 - List> exportDatas = ExcelDownUtil.getExportDatas(param.getExportOptionList(), projects); + List> exportDatas = ExcelDownUtil.getProjectExportDatas(param.getExportOptionList(), projects); // sheet列表集合 List>> sheets = new ArrayList<>(); sheets.add(exportDatas); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 69f6453..39c142d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -148,7 +148,7 @@ public class ProjectLibManage { List sheetsNames = new ArrayList<>(); sheetsNames.add(fileName); // 表体行数据集合 - List> exportDatas = ExcelDownUtil.getExportDatas(param.getExportOptionList(), projects); + List> exportDatas = ExcelDownUtil.getProjectExportDatas(param.getExportOptionList(), projects); // sheet列表集合 List>> sheets = new ArrayList<>(); sheets.add(exportDatas); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java index 8e40dc2..33d062a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java @@ -44,7 +44,7 @@ public class TodoCenterController { * @return */ @GetMapping("/todo-list/{isTemporaryAugment}") - public PageVo todoList(@ModelAttribute ToBeProcessedReq param, + public PageVo todoList(@Valid @ModelAttribute ToBeProcessedReq param, @PathVariable Integer isTemporaryAugment){ param.setIsTemporaryAugment(isTemporaryAugment); return todoCenterManage.todoProjectList(param); @@ -119,8 +119,7 @@ public class TodoCenterController { public PageVo mySubmittedList(@ModelAttribute ToBeProcessedReq param, @PathVariable Integer isTemporaryAugment){ param.setIsTemporaryAugment(isTemporaryAugment); - PageVo result = todoCenterManage.mySubmittedList(param); - return result; + return todoCenterManage.mySubmittedList(param); } /** @@ -146,8 +145,7 @@ public class TodoCenterController { public PageVo ccmeList(@Valid @ModelAttribute ToBeProcessedReq param, @PathVariable Integer isTemporaryAugment){ param.setIsTemporaryAugment(isTemporaryAugment); - PageVo result = todoCenterManage.ccmeList(param); - return result; + return todoCenterManage.ccmeList(param); } /** diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 0c53558..db6f2dc 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -2,7 +2,7 @@ package com.ningdatech.pmapi.todocenter.manage; import cn.hutool.core.codec.Base64; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.io.resource.ResourceUtil; +import cn.hutool.core.date.DatePattern; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -62,10 +62,12 @@ import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.service.IUserInfoService; import com.ningdatech.pmapi.user.util.LoginUserUtil; +import com.sun.org.apache.bcel.internal.generic.NEW; import com.wflow.contants.HisProInsEndActId; import com.wflow.exception.BusinessException; import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; import com.wflow.workflow.bean.dto.ReqProcessHandlerDTO; +import com.wflow.workflow.bean.dto.TodoCenterListReqDTO; import com.wflow.workflow.bean.process.ProgressNode; import com.wflow.workflow.bean.process.enums.NodeTypeEnum; import com.wflow.workflow.bean.vo.ProcessInstanceVo; @@ -82,6 +84,7 @@ import org.flowable.bpmn.model.*; import org.flowable.engine.HistoryService; import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.runtime.ActivityInstance; +import org.flowable.task.api.Task; import org.springframework.beans.BeanUtils; import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Component; @@ -91,9 +94,10 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; -import java.net.URL; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import static com.ningdatech.pmapi.todocenter.constant.WorkNotice.*; import static com.wflow.workflow.task.TriggerServiceTask.runtimeService; @@ -138,13 +142,39 @@ public class TodoCenterManage { public PageVo todoProjectList(ToBeProcessedReq param) { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - //因为要解耦 不能把项目和工作流一起查 - //1.先查出用户工作流 - List userTodoList = processTaskService.getUserTodoList(param.getProcessDefId(), String.valueOf(userId)); - if (CollUtil.isEmpty(userTodoList)) { + + // 查出项目库项目 + ProjectListReq projectListReq = new ProjectListReq(); + BeanUtils.copyProperties(param, projectListReq); + List projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + + + // 查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + req.setInstCodes(instCodes); + Integer pageNumber = param.getPageNumber(); + Integer pageSize = param.getPageSize(); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + BeanUtils.copyProperties(param,req); + List todoList = processTaskService.getUserTodoList(req); + + if (CollUtil.isEmpty(todoList)) { return PageVo.empty(); } - List instCodes = userTodoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList()); + + List userTodoList = todoList.stream() + .skip((long) (pageNumber - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); Set processSet = Sets.newHashSet(); Map taskMap = userTodoList.stream() @@ -153,27 +183,21 @@ public class TodoCenterManage { .filter(v -> processSet.add(v.getInstanceId())) .collect(Collectors.toMap(ProcessTaskVo::getInstanceId, v -> v)); - //2.再分页查询项目信息 - ProjectListReq projectListReq = new ProjectListReq(); - projectListReq.setInstCodes(instCodes); - BeanUtils.copyProperties(param, projectListReq); - PageVo projectPage = projectLibManage.projectLibList(projectListReq); - - if (0L == projectPage.getTotal()) { - return PageVo.empty(); - } - - List resVos = projectPage.getRecords().stream().map(d -> { + List resVos = userTodoList.stream().map(d -> { + Project projectInfo = projectInfoMap.get(d.getInstanceId()); ResToBeProcessedVO res = new ResToBeProcessedVO(); - BeanUtils.copyProperties(d, res); - res.setProjectId(d.getId()); - ProcessTaskVo taskVo = taskMap.get(d.getInstCode()); + BeanUtils.copyProperties(projectInfo, res); + res.setProjectId(projectInfo.getId()); + ProcessTaskVo taskVo = taskMap.get(d.getInstanceId()); res.setNodeId(taskVo.getTaskDefKey()); res.setProcessStatusName(taskVo.getStatus()); - res.setProcessLaunchTime(d.getCreateOn()); + LocalDateTime launchTime = NdDateUtils.date2LocalDateTime(d.getCreateTime()); + String timeStr = NdDateUtils.format(launchTime, DatePattern.NORM_DATETIME_MINUTE_PATTERN); + LocalDateTime processLaunchTime = LocalDateTime.parse(timeStr, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MINUTE_PATTERN)); + res.setProcessLaunchTime(processLaunchTime); return res; }).collect(Collectors.toList()); - return PageVo.of(resVos, projectPage.getTotal()); + return PageVo.of(resVos, todoList.size()); } /** @@ -188,19 +212,28 @@ public class TodoCenterManage { public void exportTodoList(HttpServletResponse response, ToBeProcessedExportReq param) { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - param.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); - param.setPageSize(CommonConst.EXPORT_PAGE_SIZE); - - //因为要解耦 不能把项目和工作流一起查 - //1.先查出用户工作流 - List userTodoList = processTaskService.getUserTodoList(param.getProcessDefId(), String.valueOf(userId)); - List instCodes = userTodoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList()); - //2.再查询项目信息 + // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); - projectListReq.setInstCodes(instCodes); BeanUtils.copyProperties(param, projectListReq); - List projects = CollUtil.isEmpty(userTodoList) ? Collections.emptyList() : projectLibManage.projectList(projectListReq); + List projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + + + // 查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + req.setInstCodes(instCodes); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + BeanUtils.copyProperties(param,req); + List userTodoList = processTaskService.getUserTodoList(req); ExcelExportWriter excelExportWriter = new ExcelExportWriter(); String fileName = null; @@ -211,7 +244,7 @@ public class TodoCenterManage { } excelExportWriter.setFileName(fileName); List sheetsNames = Lists.newArrayList(fileName); - List> exportDatas = ExcelDownUtil.getExportDatas(param.getExportOptionList(), projects); + List> exportDatas = ExcelDownUtil.getTaskExportDatas(param.getExportOptionList(), userTodoList, projectInfoMap); // sheet列表集合 List>> sheets = Lists.newArrayList(); sheets.add(exportDatas); @@ -652,9 +685,6 @@ public class TodoCenterManage { List progressInfo = progressInstanceDetail.getProgressInfo(); buildUserUtils.buildUserByProcessInfo(progressInfo); - //// 装配节点审核人员信息 - //buildUser(progressInfo, userMap); - ProcessProgressDetailVo res = new ProcessProgressDetailVo(); res.setProcessProgressVo(progressInstanceDetail); res.setStatus(progressInstanceDetail.getStatus()); @@ -671,44 +701,59 @@ public class TodoCenterManage { * @since 2023/02/03 */ public PageVo idoList(ToBeProcessedReq param) { + // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - // 查出用户已处理工作流 - List userIdoList = processTaskService.getUserIdoList(param.getProcessDefId(), String.valueOf(userId)); - if (CollUtil.isEmpty(userIdoList)) { - return PageVo.empty(); - } - - List instCodes = userIdoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList()); - - Set processSet = Sets.newHashSet(); - Map taskMap = userIdoList.stream() - .sorted((t1,t2) -> t2.getTaskEndTime().compareTo(t1.getTaskEndTime())) - .collect(Collectors.toList()).stream() - .filter(v -> processSet.add(v.getInstanceId())) - .collect(Collectors.toMap(ProcessTaskVo::getInstanceId, v -> v)); - - // 分页查询项目信息 + // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); - projectListReq.setInstCodes(instCodes); BeanUtils.copyProperties(param, projectListReq); - - PageVo projectPage = projectLibManage.projectLibList(projectListReq); - if (0L == projectPage.getTotal()) { + List projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + + + // 查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + Integer pageNumber = param.getPageNumber(); + Integer pageSize = param.getPageSize(); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + req.setInstCodes(instCodes); + List iDoList = processTaskService.getUserIdoList(req); + + if (CollUtil.isEmpty(iDoList)) { return PageVo.empty(); } - List resVos = projectPage.getRecords().stream().map(d -> { + + List userIdoList = iDoList.stream() + .skip((long) (pageNumber - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); + + List resVos = userIdoList.stream().map(d -> { ResToBeProcessedVO res = new ResToBeProcessedVO(); - BeanUtils.copyProperties(d, res); - res.setProjectId(d.getId()); - ProcessTaskVo taskVo = taskMap.get(d.getInstCode()); - res.setProcessStatusName(taskVo.getStatus()); - res.setProcessLaunchTime(d.getCreateOn()); - res.setProcessHandleTime(NdDateUtils.date2LocalDateTime(taskVo.getTaskEndTime())); + Project projectInfo = projectInfoMap.get(d.getInstanceId()); + BeanUtils.copyProperties(projectInfo, res); + res.setProjectId(projectInfo.getId()); + res.setProcessStatusName(d.getStatus()); + LocalDateTime launchTime = NdDateUtils.date2LocalDateTime(d.getCreateTime()); + String launchTimeStr = NdDateUtils.format(launchTime, DatePattern.NORM_DATETIME_MINUTE_PATTERN); + LocalDateTime processLaunchTime = LocalDateTime.parse(launchTimeStr, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MINUTE_PATTERN)); + res.setProcessLaunchTime(processLaunchTime); + LocalDateTime handleTime = NdDateUtils.date2LocalDateTime(d.getTaskEndTime()); + String handleTimeStr = NdDateUtils.format(handleTime, DatePattern.NORM_DATETIME_MINUTE_PATTERN); + LocalDateTime processHandleTime = LocalDateTime.parse(handleTimeStr, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MINUTE_PATTERN)); + res.setProcessHandleTime(processHandleTime); return res; }).collect(Collectors.toList()); - return PageVo.of(resVos, projectPage.getTotal()); + return PageVo.of(resVos, iDoList.size()); } /** @@ -724,19 +769,27 @@ public class TodoCenterManage { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - param.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); - param.setPageSize(CommonConst.EXPORT_PAGE_SIZE); - - // 查询用户已处理工作流 - List userIdoList = processTaskService.getUserIdoList(param.getProcessDefId(), String.valueOf(userId)); - List instCodes = userIdoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList()); - - // 查询项目信息 + //因为要解耦 不能把项目和工作流一起查 + // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); - projectListReq.setInstCodes(instCodes); BeanUtils.copyProperties(param, projectListReq); - List projects = CollUtil.isEmpty(userIdoList) ? Collections.emptyList() : - projectLibManage.projectList(projectListReq); + List projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + + // 查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + req.setInstCodes(instCodes); + List userIdoList = processTaskService.getUserIdoList(req); + ExcelExportWriter excelExportWriter = new ExcelExportWriter(); @@ -751,7 +804,7 @@ public class TodoCenterManage { List sheetsNames = new ArrayList<>(); sheetsNames.add(fileName); - List> exportDatas = ExcelDownUtil.getExportDatas(param.getExportOptionList(), projects); + List> exportDatas = ExcelDownUtil.getTaskExportDatas(param.getExportOptionList(), userIdoList, projectInfoMap); // sheet列表集合 List>> sheets = new ArrayList<>(); sheets.add(exportDatas); @@ -775,36 +828,51 @@ public class TodoCenterManage { public PageVo mySubmittedList(ToBeProcessedReq param) { // 获取登录用户ID - Long startUserId = LoginUserUtil.getUserId(); - // 查出登录用户已提交工作流 - List userSubmittedList = processInstanceService.getUserSubmittedList(String.valueOf(startUserId), param.getProcessDefId(), null); - Map instanceVoMap = userSubmittedList.stream() - .collect(Collectors.toMap(ProcessInstanceVo::getInstanceId, v -> v)); - if (CollUtil.isEmpty(userSubmittedList)) { - return PageVo.empty(); - } - List instCodes = userSubmittedList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList()); + Long userId = LoginUserUtil.getUserId(); - // 分页查询项目信息 + // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); - projectListReq.setInstCodes(instCodes); BeanUtils.copyProperties(param, projectListReq); - - PageVo projectPage = projectLibManage.projectLibList(projectListReq); - if (0L == projectPage.getTotal()) { + List projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + + // 查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + Integer pageNumber = param.getPageNumber(); + Integer pageSize = param.getPageSize(); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + req.setInstCodes(instCodes); + List submittedList = processInstanceService.getUserSubmittedList(req); + + if (CollUtil.isEmpty(submittedList)) { return PageVo.empty(); } - List resVos = projectPage.getRecords().stream().map(d -> { + List userSubmittedList = submittedList.stream() + .skip((long) (pageNumber - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); + + + List resVos = userSubmittedList.stream().map(d -> { ResToBeProcessedVO res = new ResToBeProcessedVO(); + Project project = projectInfoMap.get(d.getInstanceId()); BeanUtils.copyProperties(d, res); - res.setProjectId(d.getId()); - ProcessInstanceVo instanceVo = instanceVoMap.get(d.getInstCode()); - res.setProcessStatusName(instanceVo.getStatus()); - res.setProcessLaunchTime(d.getCreateOn()); + res.setBuildOrg(project.getBuildOrgName()); + res.setProjectId(project.getId()); + res.setProcessStatusName(d.getStatus()); + res.setProcessLaunchTime(NdDateUtils.date2LocalDateTime(d.getStartTime())); return res; }).collect(Collectors.toList()); - return PageVo.of(resVos, projectPage.getTotal()); + return PageVo.of(resVos,submittedList.size()); } /** @@ -821,19 +889,25 @@ public class TodoCenterManage { // 获取登录用户ID long userId = LoginUserUtil.getUserId(); - param.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); - param.setPageSize(CommonConst.EXPORT_PAGE_SIZE); - // 查询用户已处理工作流 - List userSubmittedList = processInstanceService.getUserSubmittedList(String.valueOf(userId), param.getProcessDefId(), null); - List instCodes = userSubmittedList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList()); - - // 查询项目信息 + // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); - projectListReq.setInstCodes(instCodes); BeanUtils.copyProperties(param, projectListReq); - List projects = CollUtil.isEmpty(userSubmittedList) ? Collections.emptyList() : - projectLibManage.projectList(projectListReq); - projectLibManage.projectList(projectListReq); + List projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + + // 查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + req.setInstCodes(instCodes); + List userSubmittedList = processInstanceService.getUserSubmittedList(req); ExcelExportWriter excelExportWriter = new ExcelExportWriter(); @@ -848,7 +922,7 @@ public class TodoCenterManage { List sheetsNames = new ArrayList<>(); sheetsNames.add(fileName); // 表体行数据集合 - List> exportDatas = ExcelDownUtil.getExportDatas(param.getExportOptionList(), projects); + List> exportDatas = ExcelDownUtil.getInstExportDatas(param.getExportOptionList(), userSubmittedList, projectInfoMap); // sheet列表集合 List>> sheets = new ArrayList<>(); sheets.add(exportDatas); @@ -870,39 +944,54 @@ public class TodoCenterManage { * @since 2023/02/11 */ public PageVo ccmeList(ToBeProcessedReq param) { - // 获取当前登录用户ID - Long userId = LoginUserUtil.getUserId(); - // 查询抄送登录用户的工作流 - List ccMeList = processInstanceService.getCcMeList(param.getProcessDefId(), String.valueOf(userId)); - if (CollUtil.isEmpty(ccMeList)) { - return PageVo.empty(); - } - List instCodes = ccMeList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList()); - Map instanceVoMap = ccMeList.stream() - .collect(Collectors.toMap(ProcessInstanceVo::getInstanceId, v -> v)); + // 获取登录用户ID + Long userId = LoginUserUtil.getUserId(); - // 分页查询项目信息 + // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); - projectListReq.setInstCodes(instCodes); BeanUtils.copyProperties(param, projectListReq); + List projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + + // 查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + Integer pageNumber = param.getPageNumber(); + Integer pageSize = param.getPageSize(); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + req.setInstCodes(instCodes); + BeanUtils.copyProperties(param,req); + List ccMeList = processInstanceService.getCcMeList(req); - PageVo projectPage = projectLibManage.projectLibList(projectListReq); - if (0L == projectPage.getTotal()) { + if (CollUtil.isEmpty(ccMeList)) { return PageVo.empty(); } - List resVos = projectPage.getRecords().stream().map(d -> { + List ccMeInstList = ccMeList.stream() + .skip((long) (pageNumber - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); + + List resVos = ccMeInstList.stream().map(d -> { ResToBeProcessedVO res = new ResToBeProcessedVO(); + Project project = projectInfoMap.get(d.getInstanceId()); BeanUtils.copyProperties(d, res); - ProcessInstanceVo instanceVo = instanceVoMap.get(d.getInstCode()); - res.setNodeId(instanceVo.getNodeId()); - res.setProjectId(d.getId()); - res.setProcessStatusName(instanceVo.getStatus()); - res.setProcessLaunchTime(d.getCreateOn()); + res.setNodeId(d.getNodeId()); + res.setProjectId(project.getId()); + res.setBuildOrg(project.getBuildOrgName()); + res.setProcessStatusName(d.getStatus()); + res.setProcessLaunchTime(NdDateUtils.date2LocalDateTime(d.getStartTime())); return res; }).collect(Collectors.toList()); - return PageVo.of(resVos, projectPage.getTotal()); + return PageVo.of(resVos, ccMeList.size()); } /** @@ -919,18 +1008,26 @@ public class TodoCenterManage { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - param.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); - param.setPageSize(CommonConst.EXPORT_PAGE_SIZE); - - // 查询抄送登录用户的工作流 - List ccMeList = processInstanceService.getCcMeList(param.getProcessDefId(), String.valueOf(userId)); - List instCodes = ccMeList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList()); - - // 查询项目信息 + // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); - projectListReq.setInstCodes(instCodes); BeanUtils.copyProperties(param, projectListReq); - List projects = CollUtil.isEmpty(ccMeList) ? Collections.emptyList() : projectLibManage.projectList(projectListReq); + List projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); + + // 分页查出用户工作流 + TodoCenterListReqDTO req = new TodoCenterListReqDTO(); + req.setProcessDefId(param.getProcessDefId()); + req.setUserId(String.valueOf(userId)); + req.setInstCodes(instCodes); + BeanUtils.copyProperties(param,req); + List ccMeList = processInstanceService.getCcMeList(req); ExcelExportWriter excelExportWriter = new ExcelExportWriter(); @@ -945,7 +1042,7 @@ public class TodoCenterManage { List sheetsNames = new ArrayList<>(); sheetsNames.add(fileName); // 表体行数据集合 - List> exportDatas = ExcelDownUtil.getExportDatas(param.getExportOptionList(), projects); + List> exportDatas = ExcelDownUtil.getInstExportDatas(param.getExportOptionList(), ccMeList, projectInfoMap); // sheet列表集合 List>> sheets = new ArrayList<>(); sheets.add(exportDatas);