|
|
@@ -2,14 +2,13 @@ package com.ningdatech.pmapi.todocenter.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.NdDateUtils; |
|
|
|
import com.ningdatech.pmapi.common.enumeration.ExportOptionEnum; |
|
|
|
import com.ningdatech.pmapi.common.constant.CommonConstant; |
|
|
|
import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; |
|
|
|
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent; |
|
|
|
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; |
|
|
@@ -29,9 +28,7 @@ import com.ningdatech.pmapi.todocenter.bean.entity.ProgressNode; |
|
|
|
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; |
|
|
|
import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo; |
|
|
|
import com.ningdatech.pmapi.todocenter.bean.vo.ProgressNodeAuditInfoVo; |
|
|
|
import com.ningdatech.pmapi.todocenter.constant.HisProInsEndActId; |
|
|
|
import com.ningdatech.pmapi.todocenter.enumeration.IsAppendProjectEnum; |
|
|
|
import com.ningdatech.pmapi.todocenter.enumeration.ProcessStatusEnum; |
|
|
|
import com.ningdatech.pmapi.todocenter.extension.cmd.BackToHisApprovalNodeCmd; |
|
|
|
import com.ningdatech.pmapi.todocenter.extension.cmd.SaveCommentCmd; |
|
|
|
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO; |
|
|
@@ -45,6 +42,7 @@ import com.ningdatech.zwdd.client.ZwddClient; |
|
|
|
import com.wflow.bean.entity.WflowCcTasks; |
|
|
|
import com.wflow.bean.entity.WflowModelHistorys; |
|
|
|
import com.wflow.bean.entity.WflowModels; |
|
|
|
import com.wflow.contants.HisProInsEndActId; |
|
|
|
import com.wflow.exception.BusinessException; |
|
|
|
import com.wflow.mapper.WflowCcTasksMapper; |
|
|
|
import com.wflow.mapper.WflowModelHistorysMapper; |
|
|
@@ -59,9 +57,9 @@ import com.wflow.workflow.bean.vo.ProcessInstanceVo; |
|
|
|
import com.wflow.workflow.bean.vo.ProcessTaskVo; |
|
|
|
import com.wflow.workflow.config.WflowGlobalVarDef; |
|
|
|
import com.wflow.workflow.enums.ProcessHandlerEnum; |
|
|
|
import com.wflow.workflow.enums.ProcessStatusEnum; |
|
|
|
import com.wflow.workflow.service.*; |
|
|
|
import com.wflow.workflow.service.FormService; |
|
|
|
import com.wflow.workflow.utils.Executor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.assertj.core.util.Lists; |
|
|
@@ -70,15 +68,12 @@ import org.flowable.bpmn.model.*; |
|
|
|
import org.flowable.engine.*; |
|
|
|
import org.flowable.engine.history.HistoricActivityInstance; |
|
|
|
import org.flowable.engine.history.HistoricProcessInstance; |
|
|
|
import org.flowable.engine.history.HistoricProcessInstanceQuery; |
|
|
|
import org.flowable.engine.runtime.ActivityInstance; |
|
|
|
import org.flowable.engine.runtime.Execution; |
|
|
|
import org.flowable.engine.task.Comment; |
|
|
|
import org.flowable.task.api.Task; |
|
|
|
import org.flowable.task.api.TaskInfo; |
|
|
|
import org.flowable.task.api.TaskQuery; |
|
|
|
import org.flowable.task.api.history.HistoricTaskInstance; |
|
|
|
import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery; |
|
|
|
import org.flowable.variable.api.history.HistoricVariableInstance; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
@@ -122,6 +117,8 @@ public class TodoCenterManage { |
|
|
|
private final IDingEmployeeInfoService dingEmployeeInfoService; |
|
|
|
private final IDingOrganizationService dingOrganizationService; |
|
|
|
|
|
|
|
private final ProcessInstanceService processInstanceService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 待办中心待我处理项目列表查询 |
|
|
|
* |
|
|
@@ -172,6 +169,9 @@ public class TodoCenterManage { |
|
|
|
// 获取登录用户ID |
|
|
|
// long userId = LoginUserUtil.getUserId(); |
|
|
|
String userId = param.getUserId(); |
|
|
|
param.setPageNumber(CommonConstant.EXPORT_PAGE_NUMBER); |
|
|
|
param.setPageSize(CommonConstant.EXPORT_PAGE_SIZE); |
|
|
|
|
|
|
|
//因为要解耦 不能把项目和工作流一起查 |
|
|
|
//1.先查出用户工作流 |
|
|
|
List<ProcessTaskVo> userTodoList = processTaskService.getUserTodoList(param.getProcessDefId(),userId); |
|
|
@@ -192,27 +192,12 @@ public class TodoCenterManage { |
|
|
|
} |
|
|
|
excelExportWriter.setFileName(fileName); |
|
|
|
List<String> sheetsNames = Lists.newArrayList(fileName); |
|
|
|
|
|
|
|
// 表体行数据集合 |
|
|
|
List<List<String>> rowList = Lists.newArrayList(); |
|
|
|
// 表体列数据集合 |
|
|
|
List<ExportOptionEnum> columnList = param.getExportOptionList(); |
|
|
|
for (ExportOptionEnum column : columnList) { |
|
|
|
List<String> columnValues = Lists.newArrayList(); |
|
|
|
columnValues.add(column.getDesc()); |
|
|
|
projects.stream().sorted(Comparator.comparing(Project::getId)).forEach(record -> { |
|
|
|
String s = JSON.toJSONString(record); |
|
|
|
JSONObject jsonObject = JSON.parseObject(s); |
|
|
|
String columnValue = String.valueOf(jsonObject.get(column.toString())); |
|
|
|
columnValues.add(columnValue); |
|
|
|
}); |
|
|
|
rowList.add(columnValues); |
|
|
|
} |
|
|
|
List<List<String>> exportDatas = ExcelDownUtil.getExportDatas(param, projects); |
|
|
|
// sheet列表集合 |
|
|
|
List<List<List<String>>> sheets = Lists.newArrayList(); |
|
|
|
sheets.add(rowList); |
|
|
|
sheets.add(exportDatas); |
|
|
|
excelExportWriter.setHeads(sheets); |
|
|
|
excelExportWriter.setDatas(rowList); |
|
|
|
excelExportWriter.setDatas(exportDatas); |
|
|
|
excelExportWriter.setSheets(sheetsNames); |
|
|
|
excelExportWriter.setHeadPropertyClass(List.class); |
|
|
|
excelExportWriter.setHeadPropertyFlag(Boolean.FALSE); |
|
|
@@ -840,21 +825,7 @@ public class TodoCenterManage { |
|
|
|
.variableName(WflowGlobalVarDef.WFLOW_FORMS) |
|
|
|
.singleResult(); |
|
|
|
List<HistoricVariableInstance> formDatas = null; |
|
|
|
//if (nodeId.equals("undefined")) { |
|
|
|
// List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(instanceId).list(); |
|
|
|
// formDatas = historyService |
|
|
|
// .createHistoricVariableInstanceQuery() |
|
|
|
// .executionIds(historicTaskInstances.stream() |
|
|
|
// .map(HistoricTaskInstance::getExecutionId) |
|
|
|
// .collect(Collectors.toSet())) |
|
|
|
// .processInstanceId(instanceId) |
|
|
|
// .list(); |
|
|
|
//} else { |
|
|
|
// formDatas = historyService |
|
|
|
// .createHistoricVariableInstanceQuery() |
|
|
|
// .processInstanceId(instanceId) |
|
|
|
// .list(); |
|
|
|
//} |
|
|
|
|
|
|
|
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() |
|
|
|
.processInstanceId(instanceId).list(); |
|
|
|
formDatas = historyService.createHistoricVariableInstanceQuery() |
|
|
@@ -868,25 +839,11 @@ public class TodoCenterManage { |
|
|
|
.processInstanceId(instanceId).variableName(WflowGlobalVarDef.WFLOW_NODE_PROPS).singleResult(); |
|
|
|
Map<String, Object> nodePropsValue = (Map<String, Object>) nodeProps.getValue(); |
|
|
|
|
|
|
|
ProcessNode<?> currentNode = null; |
|
|
|
|
|
|
|
//if (StrUtil.isNotBlank(nodeId)) { |
|
|
|
// // 搜索当前版本流程的配置 |
|
|
|
// WflowModelHistorys modelHistory = modelHistorysMapper.selectOne(new QueryWrapper<>(WflowModelHistorys.builder() |
|
|
|
// .processDefId(instance.getProcessDefinitionId()) |
|
|
|
// .version(instance.getProcessDefinitionVersion()) |
|
|
|
// .build())); |
|
|
|
// currentNode = nodeCatchService.reloadProcessByStr(modelHistory.getProcess()).get(nodeId); |
|
|
|
//} |
|
|
|
// 搜索当前版本流程的配置 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WflowModelHistorys modelHistory = modelHistorysMapper.selectOne(new QueryWrapper<>(WflowModelHistorys.builder() |
|
|
|
.processDefId(instance.getProcessDefinitionId()) |
|
|
|
.version(instance.getProcessDefinitionVersion()) |
|
|
|
.build())); |
|
|
|
currentNode = nodeCatchService.reloadProcessByStr(modelHistory.getProcess()).get("undefined"); |
|
|
|
ProcessNode<?> currentNode = nodeCatchService.reloadProcessByStr(modelHistory.getProcess()).get("undefined"); |
|
|
|
|
|
|
|
//UserInfo userInfo = userInfoService.getById(Long.valueOf(instance.getStartUserId())); |
|
|
|
//HashSet<String> userSet = new HashSet<>(); |
|
|
@@ -1046,99 +1003,31 @@ public class TodoCenterManage { |
|
|
|
// 获取登录用户ID |
|
|
|
// long userId = LoginUserUtil.getUserId(); |
|
|
|
|
|
|
|
Long userId = 381496L; |
|
|
|
// Long userId = 6418616L; |
|
|
|
// Long userId = 61769799L; |
|
|
|
|
|
|
|
// 自定义sql查询所有已办的任务实例 |
|
|
|
String nativeSql = "SELECT aht.* FROM ACT_HI_TASKINST AS aht \n" |
|
|
|
+ "LEFT JOIN ACT_HI_VARINST AS ahv ON SUBSTRING(ahv.NAME_, 9) = aht.ID_ AND ahv.NAME_ LIKE 'approve_%'\n" |
|
|
|
+ "WHERE aht.ASSIGNEE_ = " + userId + " AND ahv.NAME_ IS NOT NULL \n" + "ORDER BY aht.END_TIME_ DESC"; |
|
|
|
NativeHistoricTaskInstanceQuery taskInstanceQuery = |
|
|
|
historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql); |
|
|
|
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list(); |
|
|
|
|
|
|
|
Set<String> taskProcessInsIds = taskInstances.stream() |
|
|
|
.map(HistoricTaskInstance::getProcessInstanceId) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
// List<Project> results = getHandledProjects(param, taskProcessInsIds); |
|
|
|
List<Project> results = Lists.newArrayList(); |
|
|
|
|
|
|
|
// 总数 |
|
|
|
int total = results.size(); |
|
|
|
// 获取传入的分页参数 |
|
|
|
Integer pageNumber = param.getPageNumber(); |
|
|
|
Integer pageSize = param.getPageSize(); |
|
|
|
List<Project> records = results.stream() |
|
|
|
.skip((long) (pageNumber - 1) * pageSize) |
|
|
|
.limit(pageSize) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
// 把已办任务实例一次性取出来,减少查询次数 |
|
|
|
Map<String, HistoricTaskInstance> taskInstanceMap = taskInstances.stream() |
|
|
|
.collect(Collectors.toMap(HistoricTaskInstance::getProcessInstanceId, v -> v)); |
|
|
|
String userId = param.getUserId(); |
|
|
|
// 查出用户已处理工作流 |
|
|
|
List<ProcessTaskVo> userIdoList = processTaskService.getUserIdoList(param.getProcessDefId(), userId); |
|
|
|
List<String> instCodes = userIdoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
Map<String, HistoricProcessInstance> instanceMap = isNotEmpty(taskInstances) |
|
|
|
? historyService.createHistoricProcessInstanceQuery() |
|
|
|
.processInstanceIds(taskProcessInsIds) |
|
|
|
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) |
|
|
|
: new HashMap<>(); |
|
|
|
Set<String> staterUsers = new HashSet<>(); |
|
|
|
|
|
|
|
List<ResToBeProcessedVO> resVos = records.stream().map(d -> { |
|
|
|
// 分页查询项目信息 |
|
|
|
ProjectListReq projectListReq = new ProjectListReq(); |
|
|
|
projectListReq.setInstCodes(instCodes); |
|
|
|
BeanUtils.copyProperties(param,projectListReq); |
|
|
|
|
|
|
|
PageVo<ProjectLibListItemVO> projectPage = projectLibManage.projectLibList(projectListReq); |
|
|
|
if (0L == projectPage.getTotal()) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<ResToBeProcessedVO> resVos = projectPage.getRecords().stream().map(d -> { |
|
|
|
ResToBeProcessedVO res = new ResToBeProcessedVO(); |
|
|
|
BeanUtils.copyProperties(d, res); |
|
|
|
res.setProjectId(d.getId()); |
|
|
|
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus())); |
|
|
|
LocalDateTime processLaunchTime = d.getCreateOn(); |
|
|
|
String launchTimeFormat = NdDateUtils.format(processLaunchTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime launchTime = LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessLaunchTime(launchTime); |
|
|
|
LocalDateTime processHandleTime = d.getUpdateOn(); |
|
|
|
String handleTimeFormat = NdDateUtils.format(processHandleTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime handleTime = LocalDateTime.parse(handleTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessHandleTime(handleTime); |
|
|
|
|
|
|
|
// 从已处理任务实例列表中取出当前登录用户及项目实例对应的任务实例 |
|
|
|
HistoricTaskInstance task = taskInstanceMap.get(d.getInstCode()); |
|
|
|
HistoricProcessInstance instance = instanceMap.get(task.getProcessInstanceId()); |
|
|
|
|
|
|
|
// 从缓存取 |
|
|
|
staterUsers.add(instance.getStartUserId()); |
|
|
|
ProcessTaskVo processTaskVo = ProcessTaskVo |
|
|
|
.builder() |
|
|
|
.taskId(task.getId()) |
|
|
|
.taskName(task.getName()) |
|
|
|
.taskDefKey(task.getTaskDefinitionKey()) |
|
|
|
.processDefId(task.getProcessDefinitionId()) |
|
|
|
.executionId(task.getExecutionId()) |
|
|
|
.nodeId(task.getTaskDefinitionKey()) |
|
|
|
.deployId(instance.getDeploymentId()) |
|
|
|
.processDefName(instance.getProcessDefinitionName()) |
|
|
|
.version(instance.getProcessDefinitionVersion()) |
|
|
|
.instanceId(task.getProcessInstanceId()) |
|
|
|
.ownerId(instance.getStartUserId()) |
|
|
|
.createTime(instance.getStartTime()) |
|
|
|
.taskCreateTime(task.getCreateTime()) |
|
|
|
.build(); |
|
|
|
res.setProcessTaskInfo(processTaskVo); |
|
|
|
res.setProcessLaunchTime(d.getCreateOn()); |
|
|
|
res.setProcessHandleTime(d.getUpdateOn()); |
|
|
|
return res; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
if (isEmpty(resVos)) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
// 取用户信息,减少数据库查询,一次构建 |
|
|
|
List<ResToBeProcessedVO> result = null; |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream().peek(v -> v.getProcessTaskInfo() |
|
|
|
// .setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// return PageVo.of(result, total); |
|
|
|
return PageVo.of(resVos, total); |
|
|
|
return PageVo.of(resVos,projectPage.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -1151,27 +1040,22 @@ public class TodoCenterManage { |
|
|
|
* @since 2023/02/06 |
|
|
|
*/ |
|
|
|
public void idoExport(HttpServletResponse response, ToBeProcessedExportReq param) { |
|
|
|
param.setPageNumber(1); |
|
|
|
param.setPageSize(10000); |
|
|
|
// 获取登录用户ID |
|
|
|
// long userId = LoginUserUtil.getUserId(); |
|
|
|
Long userId = 381496L; |
|
|
|
// 自定义sql查询所有已办的任务实例 |
|
|
|
String nativeSql = "SELECT aht.* FROM ACT_HI_TASKINST AS aht \n" |
|
|
|
+ "LEFT JOIN ACT_HI_VARINST AS ahv ON SUBSTRING(ahv.NAME_, 9) = aht.ID_ AND ahv.NAME_ LIKE 'approve_%'\n" |
|
|
|
+ "WHERE aht.ASSIGNEE_ = " + userId + " AND ahv.NAME_ IS NOT NULL \n" + "ORDER BY aht.END_TIME_ DESC"; |
|
|
|
NativeHistoricTaskInstanceQuery taskInstanceQuery = |
|
|
|
historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql); |
|
|
|
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list(); |
|
|
|
|
|
|
|
// 把已办任务流程实例一次性取出来,减少查询次数 |
|
|
|
Set<String> taskProcessInsIds = taskInstances.stream() |
|
|
|
.map(HistoricTaskInstance::getProcessInstanceId) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq(); |
|
|
|
BeanUtils.copyProperties(param, toBeProcessedReq); |
|
|
|
// List<Project> records = getHandledProjects(toBeProcessedReq, taskProcessInsIds); |
|
|
|
List<Project> records = Lists.newArrayList(); |
|
|
|
|
|
|
|
String userId = param.getUserId(); |
|
|
|
param.setPageNumber(CommonConstant.EXPORT_PAGE_NUMBER); |
|
|
|
param.setPageSize(CommonConstant.EXPORT_PAGE_SIZE); |
|
|
|
|
|
|
|
// 查询用户已处理工作流 |
|
|
|
List<ProcessTaskVo> userIdoList = processTaskService.getUserIdoList(param.getProcessDefId(), userId); |
|
|
|
List<String> instCodes = userIdoList.stream().map(ProcessTaskVo::getInstanceId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 查询项目信息 |
|
|
|
ProjectListReq projectListReq = new ProjectListReq(); |
|
|
|
projectListReq.setInstCodes(instCodes); |
|
|
|
BeanUtils.copyProperties(param, projectListReq); |
|
|
|
List<Project> projects = projectLibManage.projectList(projectListReq); |
|
|
|
|
|
|
|
ExcelExportWriter excelExportWriter = new ExcelExportWriter(); |
|
|
|
|
|
|
@@ -1186,26 +1070,12 @@ public class TodoCenterManage { |
|
|
|
List<String> sheetsNames = new ArrayList<>(); |
|
|
|
sheetsNames.add(fileName); |
|
|
|
|
|
|
|
// 表体行数据集合 |
|
|
|
List<List<String>> rowList = new ArrayList<>(); |
|
|
|
// 表体列数据集合 |
|
|
|
List<ExportOptionEnum> columnList = param.getExportOptionList(); |
|
|
|
for (ExportOptionEnum column : columnList) { |
|
|
|
List<String> columnValues = new ArrayList<>(); |
|
|
|
columnValues.add(column.getDesc()); |
|
|
|
records.stream().sorted(Comparator.comparing(Project::getId)).forEach(record -> { |
|
|
|
String s = JSON.toJSONString(record); |
|
|
|
JSONObject jsonObject = JSON.parseObject(s); |
|
|
|
String columnValue = String.valueOf(jsonObject.get(column.toString())); |
|
|
|
columnValues.add(columnValue); |
|
|
|
}); |
|
|
|
rowList.add(columnValues); |
|
|
|
} |
|
|
|
List<List<String>> exportDatas = ExcelDownUtil.getExportDatas(param, projects); |
|
|
|
// sheet列表集合 |
|
|
|
List<List<List<String>>> sheets = new ArrayList<>(); |
|
|
|
sheets.add(rowList); |
|
|
|
sheets.add(exportDatas); |
|
|
|
excelExportWriter.setHeads(sheets); |
|
|
|
excelExportWriter.setDatas(rowList); |
|
|
|
excelExportWriter.setDatas(exportDatas); |
|
|
|
excelExportWriter.setSheets(sheetsNames); |
|
|
|
excelExportWriter.setHeadPropertyClass(List.class); |
|
|
|
excelExportWriter.setHeadPropertyFlag(Boolean.FALSE); |
|
|
@@ -1223,128 +1093,32 @@ public class TodoCenterManage { |
|
|
|
*/ |
|
|
|
public PageVo<ResToBeProcessedVO> mySubmittedList(ToBeProcessedReq param) { |
|
|
|
|
|
|
|
// 获取登录用户ID |
|
|
|
// Long startUserId = LoginUserUtil.getUserId(); |
|
|
|
Long startUserId = 381496L; |
|
|
|
HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery(); |
|
|
|
Executor.builder().ifNotBlankNext(String.valueOf(startUserId), instanceQuery::startedBy); |
|
|
|
List<HistoricProcessInstance> historicProcessInstances = instanceQuery.orderByProcessInstanceStartTime() |
|
|
|
.desc().orderByProcessInstanceEndTime().desc().list(); |
|
|
|
Set<String> historicProcessInstanceIds = historicProcessInstances.stream() |
|
|
|
.map(HistoricProcessInstance::getId).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
// List<Project> results = getMySubmittedProjects(param, historicProcessInstanceIds); |
|
|
|
List<Project> results = Lists.newArrayList(); |
|
|
|
|
|
|
|
// 总数 |
|
|
|
int total = results.size(); |
|
|
|
// 获取传入的分页参数 |
|
|
|
Integer pageNumber = param.getPageNumber(); |
|
|
|
Integer pageSize = param.getPageSize(); |
|
|
|
List<Project> records = results.stream() |
|
|
|
.skip((long) (pageNumber - 1) * pageSize) |
|
|
|
.limit(pageSize) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
String userId = param.getUserId(); |
|
|
|
// 查出登录用户已提交工作流 |
|
|
|
List<ProcessInstanceVo> userSubmittedList = processInstanceService.getUserSubmittedList(userId, param.getProcessDefId(), null); |
|
|
|
List<String> instCodes = userSubmittedList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 把已办任务流程实例一次性取出来,减少查询次数 |
|
|
|
Map<String, HistoricProcessInstance> instanceMap = isNotEmpty(historicProcessInstances) ? historyService |
|
|
|
.createHistoricProcessInstanceQuery() |
|
|
|
.processInstanceIds(historicProcessInstances.stream() |
|
|
|
.map(HistoricProcessInstance::getId) |
|
|
|
.collect(Collectors.toSet())) |
|
|
|
.list().stream() |
|
|
|
.collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>(); |
|
|
|
|
|
|
|
Set<String> staterUsers = new HashSet<>(); |
|
|
|
|
|
|
|
List<ResToBeProcessedVO> resVos = |
|
|
|
records.stream().map(d -> { |
|
|
|
ResToBeProcessedVO res = new ResToBeProcessedVO(); |
|
|
|
BeanUtils.copyProperties(d, res); |
|
|
|
res.setProjectId(d.getId()); |
|
|
|
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus())); |
|
|
|
LocalDateTime processLaunchTime = d.getCreateOn(); |
|
|
|
String launchTimeFormat = NdDateUtils.format(processLaunchTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime launchTime = LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessLaunchTime(launchTime); |
|
|
|
HistoricProcessInstance ist = instanceMap.get(d.getInstCode()); |
|
|
|
staterUsers.add(ist.getStartUserId()); |
|
|
|
|
|
|
|
ProcessInstanceVo processInstanceVo = getProcessInstanceVos(ist); |
|
|
|
res.setProcessInstanceInfo(processInstanceVo); |
|
|
|
return res; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
// 分页查询项目信息 |
|
|
|
ProjectListReq projectListReq = new ProjectListReq(); |
|
|
|
projectListReq.setInstCodes(instCodes); |
|
|
|
BeanUtils.copyProperties(param,projectListReq); |
|
|
|
|
|
|
|
if (isEmpty(resVos)) { |
|
|
|
PageVo<ProjectLibListItemVO> projectPage = projectLibManage.projectLibList(projectListReq); |
|
|
|
if (0L == projectPage.getTotal()) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
// 取用户信息,减少数据库查询,一次构建 |
|
|
|
List<ResToBeProcessedVO> result = null; |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream() |
|
|
|
// .peek(v -> v.getProcessInstanceInfo().setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// return PageVo.of(result, total); |
|
|
|
return PageVo.of(resVos, total); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取流程实例信息 |
|
|
|
* |
|
|
|
* @param ist 流程实例 |
|
|
|
* @return java.util.List<com.wflow.workflow.bean.vo.ProcessInstanceVo> |
|
|
|
* @author CMM |
|
|
|
* @since 2023/02/06 |
|
|
|
*/ |
|
|
|
private ProcessInstanceVo getProcessInstanceVos(HistoricProcessInstance ist) { |
|
|
|
Map<String, String> instanceNodeMap = new HashMap<>(); |
|
|
|
ProcessInstanceVo instanceVo = ProcessInstanceVo |
|
|
|
.builder() |
|
|
|
.processDefId(ist.getProcessDefinitionId()) |
|
|
|
.instanceId(ist.getId()) |
|
|
|
.nodeId(instanceNodeMap.get(ist.getId())) |
|
|
|
.formId(ist.getProcessDefinitionKey()) |
|
|
|
.staterUserId(ist.getStartUserId()) |
|
|
|
.startTime(ist.getStartTime()) |
|
|
|
.finishTime(ist.getEndTime()) |
|
|
|
.processDefName(ist.getProcessDefinitionName()) |
|
|
|
.result(ist.getEndActivityId()) |
|
|
|
.version(ist.getProcessDefinitionVersion()) |
|
|
|
.build(); |
|
|
|
|
|
|
|
if (Objects.isNull(ist.getEndActivityId())) { |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.UNDER_REVIEW.name()); |
|
|
|
} else if (HisProInsEndActId.BACK.equals(ist.getEndActivityId())) { |
|
|
|
// 被流程发起人退回的审核节点状态,此时项目回到上一个状态,当前流程结束 |
|
|
|
// (由前一个审核人撤回的流程,未结束,仍在审核中) |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.BE_BACKED.name()); |
|
|
|
} else if (HisProInsEndActId.REJECT.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.BE_REJECTED.name()); |
|
|
|
} else if (HisProInsEndActId.END.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setStatus(ProcessStatusEnum.APPROVED.name()); |
|
|
|
} |
|
|
|
|
|
|
|
if (ObjectUtil.isNull(ist.getEndActivityId())) { |
|
|
|
// 没有结束,还在走流程,获取任务 |
|
|
|
List<Task> list = taskService.createTaskQuery().processInstanceId(ist.getId()).includeIdentityLinks().active().list(); |
|
|
|
instanceVo.setNodeId(Optional.ofNullable(instanceVo.getNodeId()).orElseGet(() -> { |
|
|
|
if (isNotEmpty(list)) { |
|
|
|
return list.get(0).getTaskDefinitionKey(); |
|
|
|
} |
|
|
|
return null; |
|
|
|
})); |
|
|
|
instanceVo.setTaskName(StrUtil.join("、", list.stream().map(TaskInfo::getName).collect(Collectors.toSet()))); |
|
|
|
} else { |
|
|
|
if (HisProInsEndActId.WITHDRAW.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setTaskName(ProcessStatusEnum.WITHDRAW.getDesc()); |
|
|
|
} else if (HisProInsEndActId.REJECT.equals(ist.getEndActivityId())) { |
|
|
|
instanceVo.setTaskName(ProcessStatusEnum.BE_REJECTED.getDesc()); |
|
|
|
} else { |
|
|
|
instanceVo.setTaskName(ProcessStatusEnum.APPROVED.getDesc()); |
|
|
|
} |
|
|
|
} |
|
|
|
return instanceVo; |
|
|
|
List<ResToBeProcessedVO> resVos = projectPage.getRecords().stream().map(d -> { |
|
|
|
ResToBeProcessedVO res = new ResToBeProcessedVO(); |
|
|
|
BeanUtils.copyProperties(d, res); |
|
|
|
res.setProjectId(d.getId()); |
|
|
|
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus())); |
|
|
|
res.setProcessLaunchTime(d.getCreateOn()); |
|
|
|
return res; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return PageVo.of(resVos,projectPage.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -1358,23 +1132,21 @@ public class TodoCenterManage { |
|
|
|
*/ |
|
|
|
public void exportMySubmittedList(HttpServletResponse response, ToBeProcessedExportReq param) { |
|
|
|
|
|
|
|
param.setPageNumber(1); |
|
|
|
param.setPageSize(10000); |
|
|
|
// Long startUserId = LoginUserUtil.getUserId(); |
|
|
|
Long startUserId = 381496L; |
|
|
|
HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery(); |
|
|
|
Executor.builder().ifNotBlankNext(String.valueOf(startUserId), instanceQuery::startedBy); |
|
|
|
List<HistoricProcessInstance> historicProcessInstances = instanceQuery |
|
|
|
.orderByProcessInstanceStartTime().desc() |
|
|
|
.orderByProcessInstanceEndTime().desc() |
|
|
|
.list(); |
|
|
|
Set<String> historicProcessInstanceIds = historicProcessInstances.stream() |
|
|
|
.map(h -> h.getId()) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq(); |
|
|
|
BeanUtils.copyProperties(param, toBeProcessedReq); |
|
|
|
// List<Project> records = getMySubmittedProjects(toBeProcessedReq, historicProcessInstanceIds); |
|
|
|
List<Project> records = Lists.newArrayList(); |
|
|
|
// 获取登录用户ID |
|
|
|
// long userId = LoginUserUtil.getUserId(); |
|
|
|
|
|
|
|
String userId = param.getUserId(); |
|
|
|
param.setPageNumber(CommonConstant.EXPORT_PAGE_NUMBER); |
|
|
|
param.setPageSize(CommonConstant.EXPORT_PAGE_SIZE); |
|
|
|
// 查询用户已处理工作流 |
|
|
|
List<ProcessInstanceVo> userSubmittedList = processInstanceService.getUserSubmittedList(userId, param.getProcessDefId(), null); |
|
|
|
List<String> instCodes = userSubmittedList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 查询项目信息 |
|
|
|
ProjectListReq projectListReq = new ProjectListReq(); |
|
|
|
projectListReq.setInstCodes(instCodes); |
|
|
|
BeanUtils.copyProperties(param, projectListReq); |
|
|
|
List<Project> projects = projectLibManage.projectList(projectListReq); |
|
|
|
|
|
|
|
ExcelExportWriter excelExportWriter = new ExcelExportWriter(); |
|
|
|
|
|
|
@@ -1388,27 +1160,13 @@ public class TodoCenterManage { |
|
|
|
|
|
|
|
List<String> sheetsNames = new ArrayList<>(); |
|
|
|
sheetsNames.add(fileName); |
|
|
|
|
|
|
|
// 表体行数据集合 |
|
|
|
List<List<String>> rowList = new ArrayList<>(); |
|
|
|
// 表体列数据集合 |
|
|
|
List<ExportOptionEnum> columnList = param.getExportOptionList(); |
|
|
|
for (ExportOptionEnum column : columnList) { |
|
|
|
List<String> columnValues = new ArrayList<>(); |
|
|
|
columnValues.add(column.getDesc()); |
|
|
|
records.stream().sorted(Comparator.comparing(Project::getId)).forEach(record -> { |
|
|
|
String s = JSON.toJSONString(record); |
|
|
|
JSONObject jsonObject = JSON.parseObject(s); |
|
|
|
String columnValue = String.valueOf(jsonObject.get(column.toString())); |
|
|
|
columnValues.add(columnValue); |
|
|
|
}); |
|
|
|
rowList.add(columnValues); |
|
|
|
} |
|
|
|
List<List<String>> exportDatas = ExcelDownUtil.getExportDatas(param, projects); |
|
|
|
// sheet列表集合 |
|
|
|
List<List<List<String>>> sheets = new ArrayList<>(); |
|
|
|
sheets.add(rowList); |
|
|
|
sheets.add(exportDatas); |
|
|
|
excelExportWriter.setHeads(sheets); |
|
|
|
excelExportWriter.setDatas(rowList); |
|
|
|
excelExportWriter.setDatas(exportDatas); |
|
|
|
excelExportWriter.setSheets(sheetsNames); |
|
|
|
excelExportWriter.setHeadPropertyClass(List.class); |
|
|
|
excelExportWriter.setHeadPropertyFlag(Boolean.FALSE); |
|
|
@@ -1427,64 +1185,31 @@ public class TodoCenterManage { |
|
|
|
public PageVo<ResToBeProcessedVO> ccmeList(ToBeProcessedReq param) { |
|
|
|
// 获取当前登录用户ID |
|
|
|
// Long userId = LoginUserUtil.getUserId(); |
|
|
|
String userId = param.getUserId(); |
|
|
|
|
|
|
|
Long userId = 381496L; |
|
|
|
List<WflowCcTasks> ccTasks = ccTasksMapper.selectList(Wrappers.lambdaQuery(WflowCcTasks.class) |
|
|
|
.eq(WflowCcTasks::getUserId, String.valueOf(userId)).orderByDesc(WflowCcTasks::getCreateTime)); |
|
|
|
List<String> processInsIds = ccTasks.stream() |
|
|
|
.map(WflowCcTasks::getInstanceId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
// 查询抄送登录用户的工作流 |
|
|
|
List<ProcessInstanceVo> ccMeList = processInstanceService.getCcMeList(param.getProcessDefId(), userId); |
|
|
|
List<String> instCodes = ccMeList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// List<Project> results = getCcMeProjects(param, processInsIds); |
|
|
|
List<Project> results = Lists.newArrayList(); |
|
|
|
|
|
|
|
// 总数 |
|
|
|
int total = results.size(); |
|
|
|
// 获取传入的分页参数 |
|
|
|
Integer pageNumber = param.getPageNumber(); |
|
|
|
Integer pageSize = param.getPageSize(); |
|
|
|
List<Project> records = results.stream() |
|
|
|
.skip((long) (pageNumber - 1) * pageSize) |
|
|
|
.limit(pageSize) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
// 分页查询项目信息 |
|
|
|
ProjectListReq projectListReq = new ProjectListReq(); |
|
|
|
projectListReq.setInstCodes(instCodes); |
|
|
|
BeanUtils.copyProperties(param,projectListReq); |
|
|
|
|
|
|
|
Set<String> staterUsers = new HashSet<>(); |
|
|
|
// 将抄送我的流程实例一次性取出来,减少查询次数 |
|
|
|
Map<String, HistoricProcessInstance> instanceMap = isNotEmpty(ccTasks) |
|
|
|
? historyService.createHistoricProcessInstanceQuery() |
|
|
|
.processInstanceIds(ccTasks.stream().map(WflowCcTasks::getInstanceId).collect(Collectors.toSet())) |
|
|
|
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) |
|
|
|
: new HashMap<>(); |
|
|
|
List<ResToBeProcessedVO> resVos = |
|
|
|
records.stream().map(d -> { |
|
|
|
ResToBeProcessedVO res = new ResToBeProcessedVO(); |
|
|
|
BeanUtils.copyProperties(d, res); |
|
|
|
res.setProjectId(d.getId()); |
|
|
|
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus())); |
|
|
|
LocalDateTime processLaunchTime = d.getCreateOn(); |
|
|
|
String launchTimeFormat = NdDateUtils.format(processLaunchTime, "yyyy-MM-dd HH:mm"); |
|
|
|
LocalDateTime launchTime = LocalDateTime.parse(launchTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); |
|
|
|
res.setProcessLaunchTime(launchTime); |
|
|
|
HistoricProcessInstance ist = instanceMap.get(d.getInstCode()); |
|
|
|
staterUsers.add(ist.getStartUserId()); |
|
|
|
|
|
|
|
ProcessInstanceVo processInstanceVo = getProcessInstanceVos(ist); |
|
|
|
res.setProcessInstanceInfo(processInstanceVo); |
|
|
|
return res; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
if (isEmpty(resVos)) { |
|
|
|
PageVo<ProjectLibListItemVO> projectPage = projectLibManage.projectLibList(projectListReq); |
|
|
|
if (0L == projectPage.getTotal()) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
// 取用户信息,减少数据库查询,一次构建 |
|
|
|
List<ResToBeProcessedVO> result = null; |
|
|
|
if (isNotEmpty(staterUsers)) { |
|
|
|
//Map<String, ProcessInstanceUserDto> userMap = userInfoService.getUserMapByIds(staterUsers); |
|
|
|
//result = resVos.stream() |
|
|
|
// .peek(v -> v.getProcessInstanceInfo().setStartUser(userMap.get(v.getProcessTaskInfo().getOwnerId()))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
} |
|
|
|
// return PageVo.of(result, total); |
|
|
|
return PageVo.of(resVos, total); |
|
|
|
|
|
|
|
List<ResToBeProcessedVO> resVos = projectPage.getRecords().stream().map(d -> { |
|
|
|
ResToBeProcessedVO res = new ResToBeProcessedVO(); |
|
|
|
BeanUtils.copyProperties(d, res); |
|
|
|
res.setProjectId(d.getId()); |
|
|
|
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus())); |
|
|
|
res.setProcessLaunchTime(d.getCreateOn()); |
|
|
|
return res; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return PageVo.of(resVos,projectPage.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -1498,22 +1223,22 @@ public class TodoCenterManage { |
|
|
|
*/ |
|
|
|
public void exportCcMeProjectList(HttpServletResponse response, ToBeProcessedExportReq param) { |
|
|
|
|
|
|
|
param.setPageNumber(1); |
|
|
|
param.setPageSize(10000); |
|
|
|
// 获取当前登录用户ID |
|
|
|
// Long userId = LoginUserUtil.getUserId(); |
|
|
|
// 获取登录用户ID |
|
|
|
// long userId = LoginUserUtil.getUserId(); |
|
|
|
|
|
|
|
Long userId = 381496L; |
|
|
|
List<WflowCcTasks> ccTasks = ccTasksMapper.selectList(Wrappers.lambdaQuery(WflowCcTasks.class) |
|
|
|
.eq(WflowCcTasks::getUserId, String.valueOf(userId)).orderByDesc(WflowCcTasks::getCreateTime)); |
|
|
|
List<String> processInsIds = ccTasks.stream() |
|
|
|
.map(WflowCcTasks::getInstanceId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
String userId = param.getUserId(); |
|
|
|
param.setPageNumber(CommonConstant.EXPORT_PAGE_NUMBER); |
|
|
|
param.setPageSize(CommonConstant.EXPORT_PAGE_SIZE); |
|
|
|
|
|
|
|
ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq(); |
|
|
|
BeanUtils.copyProperties(param, toBeProcessedReq); |
|
|
|
// List<Project> records = getCcMeProjects(toBeProcessedReq, processInsIds); |
|
|
|
List<Project> records = Lists.newArrayList(); |
|
|
|
// 查询抄送登录用户的工作流 |
|
|
|
List<ProcessInstanceVo> ccMeList = processInstanceService.getCcMeList(param.getProcessDefId(), userId); |
|
|
|
List<String> instCodes = ccMeList.stream().map(ProcessInstanceVo::getInstanceId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 查询项目信息 |
|
|
|
ProjectListReq projectListReq = new ProjectListReq(); |
|
|
|
projectListReq.setInstCodes(instCodes); |
|
|
|
BeanUtils.copyProperties(param, projectListReq); |
|
|
|
List<Project> projects = projectLibManage.projectList(projectListReq); |
|
|
|
|
|
|
|
ExcelExportWriter excelExportWriter = new ExcelExportWriter(); |
|
|
|
|
|
|
@@ -1527,27 +1252,13 @@ public class TodoCenterManage { |
|
|
|
|
|
|
|
List<String> sheetsNames = new ArrayList<>(); |
|
|
|
sheetsNames.add(fileName); |
|
|
|
|
|
|
|
// 表体行数据集合 |
|
|
|
List<List<String>> rowList = new ArrayList<>(); |
|
|
|
// 表体列数据集合 |
|
|
|
List<ExportOptionEnum> columnList = param.getExportOptionList(); |
|
|
|
for (ExportOptionEnum column : columnList) { |
|
|
|
List<String> columnValues = new ArrayList<>(); |
|
|
|
columnValues.add(column.getDesc()); |
|
|
|
records.stream().sorted(Comparator.comparing(Project::getId)).forEach(record -> { |
|
|
|
String s = JSON.toJSONString(record); |
|
|
|
JSONObject jsonObject = JSON.parseObject(s); |
|
|
|
String columnValue = String.valueOf(jsonObject.get(column.toString())); |
|
|
|
columnValues.add(columnValue); |
|
|
|
}); |
|
|
|
rowList.add(columnValues); |
|
|
|
} |
|
|
|
List<List<String>> exportDatas = ExcelDownUtil.getExportDatas(param, projects); |
|
|
|
// sheet列表集合 |
|
|
|
List<List<List<String>>> sheets = new ArrayList<>(); |
|
|
|
sheets.add(rowList); |
|
|
|
sheets.add(exportDatas); |
|
|
|
excelExportWriter.setHeads(sheets); |
|
|
|
excelExportWriter.setDatas(rowList); |
|
|
|
excelExportWriter.setDatas(exportDatas); |
|
|
|
excelExportWriter.setSheets(sheetsNames); |
|
|
|
excelExportWriter.setHeadPropertyClass(List.class); |
|
|
|
excelExportWriter.setHeadPropertyFlag(Boolean.FALSE); |
|
|
|