Commit 86dc3763fc92637a4e1d31e42d16abbeaee507db
1 parent
623a41d4
【代码评审】Bpm:数据报表
Showing
4 changed files
with
70 additions
and
67 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java
| @@ -109,24 +109,25 @@ public class BpmProcessInstanceController { | @@ -109,24 +109,25 @@ public class BpmProcessInstanceController { | ||
| 109 | processDefinitionMap, categoryMap, taskMap, userMap, deptMap, processDefinitionInfoMap)); | 109 | processDefinitionMap, categoryMap, taskMap, userMap, deptMap, processDefinitionInfoMap)); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | - @GetMapping("/report-page") | ||
| 113 | - @Operation(summary = "获得流程实例报表的分页列表", description = "获得流程实例报表的分页列表") | ||
| 114 | - public CommonResult<BpmProcessInstanceReportPageRespVO> getProcessInstanceReportPage( | ||
| 115 | - @Valid BpmProcessInstanceReportPageReqVO pageReqVO) { | ||
| 116 | - PageResult<HistoricProcessInstance> pageResult = processInstanceService.getProcessInstanceReportPage(pageReqVO); | ||
| 117 | - if (CollUtil.isEmpty(pageResult.getList())) { | ||
| 118 | - return success(new BpmProcessInstanceReportPageRespVO().setPageResult(PageResult.empty(pageResult.getTotal()))); | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - // 拼接返回 | ||
| 122 | - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | ||
| 123 | - convertSet(pageResult.getList(), processInstance -> NumberUtils.parseLong(processInstance.getStartUserId()))); | ||
| 124 | - BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService.getProcessDefinitionInfo( | ||
| 125 | - pageReqVO.getProcessDefinitionId() | ||
| 126 | - ); | ||
| 127 | - return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceReportPage(pageResult, | ||
| 128 | - userMap, processDefinitionInfo)); | ||
| 129 | - } | 112 | + // TODO @lesan:貌似少提交了。ps:不确定和 getProcessInstanceManagerPage 接口的差异哈。 |
| 113 | +// @GetMapping("/report-page") | ||
| 114 | +// @Operation(summary = "获得流程实例报表的分页列表", description = "获得流程实例报表的分页列表") | ||
| 115 | +// public CommonResult<BpmProcessInstanceReportPageRespVO> getProcessInstanceReportPage( | ||
| 116 | +// @Valid BpmProcessInstanceReportPageReqVO pageReqVO) { | ||
| 117 | +// PageResult<HistoricProcessInstance> pageResult = processInstanceService.getProcessInstanceReportPage(pageReqVO); | ||
| 118 | +// if (CollUtil.isEmpty(pageResult.getList())) { | ||
| 119 | +// return success(new BpmProcessInstanceReportPageRespVO().setPageResult(PageResult.empty(pageResult.getTotal()))); | ||
| 120 | +// } | ||
| 121 | +// | ||
| 122 | +// // 拼接返回 | ||
| 123 | +// Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | ||
| 124 | +// convertSet(pageResult.getList(), processInstance -> NumberUtils.parseLong(processInstance.getStartUserId()))); | ||
| 125 | +// BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService.getProcessDefinitionInfo( | ||
| 126 | +// pageReqVO.getProcessDefinitionId() | ||
| 127 | +// ); | ||
| 128 | +// return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceReportPage(pageResult, | ||
| 129 | +// userMap, processDefinitionInfo)); | ||
| 130 | +// } | ||
| 130 | 131 | ||
| 131 | @PostMapping("/create") | 132 | @PostMapping("/create") |
| 132 | @Operation(summary = "新建流程实例") | 133 | @Operation(summary = "新建流程实例") |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java
| @@ -26,6 +26,7 @@ import org.flowable.task.api.TaskInfo; | @@ -26,6 +26,7 @@ import org.flowable.task.api.TaskInfo; | ||
| 26 | 26 | ||
| 27 | import java.util.*; | 27 | import java.util.*; |
| 28 | import java.util.concurrent.Callable; | 28 | import java.util.concurrent.Callable; |
| 29 | +import java.util.stream.Collectors; | ||
| 29 | 30 | ||
| 30 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | 31 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| 31 | 32 | ||
| @@ -212,7 +213,8 @@ public class FlowableUtils { | @@ -212,7 +213,8 @@ public class FlowableUtils { | ||
| 212 | || !BpmModelFormTypeEnum.NORMAL.getType().equals(processDefinitionInfo.getFormType())) { | 213 | || !BpmModelFormTypeEnum.NORMAL.getType().equals(processDefinitionInfo.getFormType())) { |
| 213 | return null; | 214 | return null; |
| 214 | } | 215 | } |
| 215 | - List<KeyValue<String, String>> summaryList; | 216 | + |
| 217 | + // 解析表单配置 | ||
| 216 | Map<String, BpmFormFieldVO> formFieldsMap = new HashMap<>(); | 218 | Map<String, BpmFormFieldVO> formFieldsMap = new HashMap<>(); |
| 217 | processDefinitionInfo.getFormFields().forEach(formFieldStr -> { | 219 | processDefinitionInfo.getFormFields().forEach(formFieldStr -> { |
| 218 | BpmFormFieldVO formField = JsonUtils.parseObject(formFieldStr, BpmFormFieldVO.class); | 220 | BpmFormFieldVO formField = JsonUtils.parseObject(formFieldStr, BpmFormFieldVO.class); |
| @@ -220,10 +222,11 @@ public class FlowableUtils { | @@ -220,10 +222,11 @@ public class FlowableUtils { | ||
| 220 | formFieldsMap.put(formField.getField(), formField); | 222 | formFieldsMap.put(formField.getField(), formField); |
| 221 | } | 223 | } |
| 222 | }); | 224 | }); |
| 225 | + | ||
| 226 | + // 情况一:当自定义了摘要 | ||
| 223 | if (ObjectUtil.isNotNull(processDefinitionInfo.getSummarySetting()) | 227 | if (ObjectUtil.isNotNull(processDefinitionInfo.getSummarySetting()) |
| 224 | && Boolean.TRUE.equals(processDefinitionInfo.getSummarySetting().getEnable())) { | 228 | && Boolean.TRUE.equals(processDefinitionInfo.getSummarySetting().getEnable())) { |
| 225 | - // 情况一:当自定义了摘要 | ||
| 226 | - summaryList = convertList(processDefinitionInfo.getSummarySetting().getSummary(), item -> { | 229 | + return convertList(processDefinitionInfo.getSummarySetting().getSummary(), item -> { |
| 227 | BpmFormFieldVO formField = formFieldsMap.get(item); | 230 | BpmFormFieldVO formField = formFieldsMap.get(item); |
| 228 | if (formField != null) { | 231 | if (formField != null) { |
| 229 | return new KeyValue<String, String>(formField.getTitle(), | 232 | return new KeyValue<String, String>(formField.getTitle(), |
| @@ -231,15 +234,14 @@ public class FlowableUtils { | @@ -231,15 +234,14 @@ public class FlowableUtils { | ||
| 231 | } | 234 | } |
| 232 | return null; | 235 | return null; |
| 233 | }); | 236 | }); |
| 234 | - } else { | ||
| 235 | - // 情况二:默认摘要展示前三个表单字段 | ||
| 236 | - summaryList = new ArrayList<>(formFieldsMap.entrySet().stream() | ||
| 237 | - .limit(3) | ||
| 238 | - .map(entry -> new KeyValue<>(entry.getValue().getTitle(), | ||
| 239 | - processVariables.getOrDefault(entry.getValue().getField(), "").toString())) | ||
| 240 | - .toList()); | ||
| 241 | } | 237 | } |
| 242 | - return summaryList; | 238 | + |
| 239 | + // 情况二:默认摘要展示前三个表单字段 | ||
| 240 | + return formFieldsMap.entrySet().stream() | ||
| 241 | + .limit(3) | ||
| 242 | + .map(entry -> new KeyValue<>(entry.getValue().getTitle(), | ||
| 243 | + processVariables.getOrDefault(entry.getValue().getField(), "").toString())) | ||
| 244 | + .collect(Collectors.toList()); | ||
| 243 | } | 245 | } |
| 244 | 246 | ||
| 245 | // ========== Task 相关的工具方法 ========== | 247 | // ========== Task 相关的工具方法 ========== |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java
| @@ -84,7 +84,7 @@ public interface BpmProcessInstanceService { | @@ -84,7 +84,7 @@ public interface BpmProcessInstanceService { | ||
| 84 | PageResult<HistoricProcessInstance> getProcessInstancePage(Long userId, | 84 | PageResult<HistoricProcessInstance> getProcessInstancePage(Long userId, |
| 85 | @Valid BpmProcessInstancePageReqVO pageReqVO); | 85 | @Valid BpmProcessInstancePageReqVO pageReqVO); |
| 86 | 86 | ||
| 87 | - PageResult<HistoricProcessInstance> getProcessInstanceReportPage(@Valid BpmProcessInstanceReportPageReqVO pageReqVO); | 87 | +// PageResult<HistoricProcessInstance> getProcessInstanceReportPage(@Valid BpmProcessInstanceReportPageReqVO pageReqVO); |
| 88 | 88 | ||
| 89 | // TODO @芋艿:重点在 review 下 | 89 | // TODO @芋艿:重点在 review 下 |
| 90 | /** | 90 | /** |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| @@ -180,43 +180,43 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -180,43 +180,43 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 180 | return new PageResult<>(processInstanceList, processInstanceCount); | 180 | return new PageResult<>(processInstanceList, processInstanceCount); |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | - @Override | ||
| 184 | - public PageResult<HistoricProcessInstance> getProcessInstanceReportPage(BpmProcessInstanceReportPageReqVO pageReqVO) { | ||
| 185 | - // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页 | ||
| 186 | - HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery() | ||
| 187 | - .includeProcessVariables() | ||
| 188 | - .processInstanceTenantId(FlowableUtils.getTenantId()) | ||
| 189 | - .orderByProcessInstanceStartTime().desc(); | ||
| 190 | - if (pageReqVO.getStartUserId() != null) { | ||
| 191 | - processInstanceQuery.startedBy(String.valueOf(pageReqVO.getStartUserId())); | ||
| 192 | - } | ||
| 193 | - if (StrUtil.isNotEmpty(pageReqVO.getName())) { | ||
| 194 | - processInstanceQuery.processInstanceNameLike("%" + pageReqVO.getName() + "%"); | ||
| 195 | - } | ||
| 196 | - if (StrUtil.isNotEmpty(pageReqVO.getProcessDefinitionKey())) { | ||
| 197 | - processInstanceQuery.processDefinitionKey(pageReqVO.getProcessDefinitionKey()); | ||
| 198 | - } | ||
| 199 | - if (pageReqVO.getStatus() != null) { | ||
| 200 | - processInstanceQuery.variableValueEquals(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_STATUS, pageReqVO.getStatus()); | ||
| 201 | - } | ||
| 202 | - if (ArrayUtil.isNotEmpty(pageReqVO.getCreateTime())) { | ||
| 203 | - processInstanceQuery.startedAfter(DateUtils.of(pageReqVO.getCreateTime()[0])); | ||
| 204 | - processInstanceQuery.startedBefore(DateUtils.of(pageReqVO.getCreateTime()[1])); | ||
| 205 | - } | ||
| 206 | - if (ArrayUtil.isNotEmpty(pageReqVO.getEndTime())) { | ||
| 207 | - processInstanceQuery.finishedAfter(DateUtils.of(pageReqVO.getEndTime()[0])); | ||
| 208 | - processInstanceQuery.finishedBefore(DateUtils.of(pageReqVO.getEndTime()[1])); | ||
| 209 | - } | ||
| 210 | - // TODO 流程表单数据也要支持查询 | ||
| 211 | - // 查询数量 | ||
| 212 | - long processInstanceCount = processInstanceQuery.count(); | ||
| 213 | - if (processInstanceCount == 0) { | ||
| 214 | - return PageResult.empty(processInstanceCount); | ||
| 215 | - } | ||
| 216 | - // 查询列表 | ||
| 217 | - List<HistoricProcessInstance> processInstanceList = processInstanceQuery.listPage(PageUtils.getStart(pageReqVO), pageReqVO.getPageSize()); | ||
| 218 | - return new PageResult<>(processInstanceList, processInstanceCount); | ||
| 219 | - } | 183 | +// @Override |
| 184 | +// public PageResult<HistoricProcessInstance> getProcessInstanceReportPage(BpmProcessInstanceReportPageReqVO pageReqVO) { | ||
| 185 | +// // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页 | ||
| 186 | +// HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery() | ||
| 187 | +// .includeProcessVariables() | ||
| 188 | +// .processInstanceTenantId(FlowableUtils.getTenantId()) | ||
| 189 | +// .orderByProcessInstanceStartTime().desc(); | ||
| 190 | +// if (pageReqVO.getStartUserId() != null) { | ||
| 191 | +// processInstanceQuery.startedBy(String.valueOf(pageReqVO.getStartUserId())); | ||
| 192 | +// } | ||
| 193 | +// if (StrUtil.isNotEmpty(pageReqVO.getName())) { | ||
| 194 | +// processInstanceQuery.processInstanceNameLike("%" + pageReqVO.getName() + "%"); | ||
| 195 | +// } | ||
| 196 | +// if (StrUtil.isNotEmpty(pageReqVO.getProcessDefinitionKey())) { | ||
| 197 | +// processInstanceQuery.processDefinitionKey(pageReqVO.getProcessDefinitionKey()); | ||
| 198 | +// } | ||
| 199 | +// if (pageReqVO.getStatus() != null) { | ||
| 200 | +// processInstanceQuery.variableValueEquals(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_STATUS, pageReqVO.getStatus()); | ||
| 201 | +// } | ||
| 202 | +// if (ArrayUtil.isNotEmpty(pageReqVO.getCreateTime())) { | ||
| 203 | +// processInstanceQuery.startedAfter(DateUtils.of(pageReqVO.getCreateTime()[0])); | ||
| 204 | +// processInstanceQuery.startedBefore(DateUtils.of(pageReqVO.getCreateTime()[1])); | ||
| 205 | +// } | ||
| 206 | +// if (ArrayUtil.isNotEmpty(pageReqVO.getEndTime())) { | ||
| 207 | +// processInstanceQuery.finishedAfter(DateUtils.of(pageReqVO.getEndTime()[0])); | ||
| 208 | +// processInstanceQuery.finishedBefore(DateUtils.of(pageReqVO.getEndTime()[1])); | ||
| 209 | +// } | ||
| 210 | +// // TODO 流程表单数据也要支持查询 | ||
| 211 | +// // 查询数量 | ||
| 212 | +// long processInstanceCount = processInstanceQuery.count(); | ||
| 213 | +// if (processInstanceCount == 0) { | ||
| 214 | +// return PageResult.empty(processInstanceCount); | ||
| 215 | +// } | ||
| 216 | +// // 查询列表 | ||
| 217 | +// List<HistoricProcessInstance> processInstanceList = processInstanceQuery.listPage(PageUtils.getStart(pageReqVO), pageReqVO.getPageSize()); | ||
| 218 | +// return new PageResult<>(processInstanceList, processInstanceCount); | ||
| 219 | +// } | ||
| 220 | 220 | ||
| 221 | private Map<String, String> getFormFieldsPermission(BpmnModel bpmnModel, | 221 | private Map<String, String> getFormFieldsPermission(BpmnModel bpmnModel, |
| 222 | String activityId, String taskId) { | 222 | String activityId, String taskId) { |