Commit 9b426436bee0f12b0285c8db2331b49c04acd865
1 parent
0983d5b5
review:【bpm 工作流】流程打印
Showing
4 changed files
with
19 additions
and
11 deletions
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java
| ... | ... | @@ -192,16 +192,18 @@ public class BpmProcessInstanceController { |
| 192 | 192 | @GetMapping("/get-bpmn-model-view") |
| 193 | 193 | @Operation(summary = "获取流程实例的 BPMN 模型视图", description = "在【流程详细】界面中,进行调用") |
| 194 | 194 | @Parameter(name = "id", description = "流程实例的编号", required = true) |
| 195 | - public CommonResult<BpmProcessInstanceBpmnModelViewRespVO> getProcessInstanceBpmnModelView(@RequestParam(value = "id") String id) { | |
| 195 | + public CommonResult<BpmProcessInstanceBpmnModelViewRespVO> getProcessInstanceBpmnModelView( | |
| 196 | + @RequestParam(value = "id") String id) { | |
| 196 | 197 | return success(processInstanceService.getProcessInstanceBpmnModelView(id)); |
| 197 | 198 | } |
| 198 | 199 | |
| 199 | 200 | @GetMapping("/get-print-data") |
| 200 | - @Operation(summary = "获得打印数据") | |
| 201 | + @Operation(summary = "获得流程实例的打印数据") | |
| 201 | 202 | @Parameter(name = "id", description = "流程实例的编号", required = true) |
| 202 | 203 | @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") |
| 203 | - public CommonResult<BpmProcessPrintDataRespVO> getPrintData(@RequestParam("processInstanceId") String processInstanceId) { | |
| 204 | - return success(processInstanceService.getPrintData(getLoginUserId(), processInstanceId)); | |
| 204 | + public CommonResult<BpmProcessPrintDataRespVO> getProcessInstancePrintData( | |
| 205 | + @RequestParam("processInstanceId") String processInstanceId) { | |
| 206 | + return success(processInstanceService.getProcessInstancePrintData(getLoginUserId(), processInstanceId)); | |
| 205 | 207 | } |
| 206 | 208 | |
| 207 | 209 | } | ... | ... |
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessPrintDataRespVO.java
| ... | ... | @@ -5,8 +5,8 @@ import lombok.Data; |
| 5 | 5 | |
| 6 | 6 | import java.util.List; |
| 7 | 7 | |
| 8 | - | |
| 9 | -@Schema(description = "管理后台 - 打印数据 Response VO") | |
| 8 | +// TODO @lesan:这个可能复用 BpmApprovalDetailRespVO 哇? | |
| 9 | +@Schema(description = "管理后台 - 流程实例的打印数据 Response VO") | |
| 10 | 10 | @Data |
| 11 | 11 | public class BpmProcessPrintDataRespVO { |
| 12 | 12 | |
| ... | ... | @@ -14,6 +14,7 @@ public class BpmProcessPrintDataRespVO { |
| 14 | 14 | |
| 15 | 15 | private Integer processStatus; |
| 16 | 16 | |
| 17 | + // TODO @lesan:通过字典? | |
| 17 | 18 | private String processStatusShow; |
| 18 | 19 | |
| 19 | 20 | private String processInstanceId; |
| ... | ... | @@ -22,6 +23,7 @@ public class BpmProcessPrintDataRespVO { |
| 22 | 23 | |
| 23 | 24 | private String processName; |
| 24 | 25 | |
| 26 | + // TODO @lesan:UserSimpleBaseVO 替代 startUser、startUserDept; | |
| 25 | 27 | private String startUser; |
| 26 | 28 | |
| 27 | 29 | private String startUserDept; | ... | ... |
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java
| ... | ... | @@ -119,7 +119,7 @@ public interface BpmProcessInstanceService { |
| 119 | 119 | * @param processInstanceId 流程实例id |
| 120 | 120 | * @return 打印所需数据 |
| 121 | 121 | */ |
| 122 | - BpmProcessPrintDataRespVO getPrintData(Long loginUserId, String processInstanceId); | |
| 122 | + BpmProcessPrintDataRespVO getProcessInstancePrintData(Long loginUserId, String processInstanceId); | |
| 123 | 123 | |
| 124 | 124 | // ========== Update 写入相关方法 ========== |
| 125 | 125 | ... | ... |
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| ... | ... | @@ -735,7 +735,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | @Override |
| 738 | - public BpmProcessPrintDataRespVO getPrintData(Long loginUserId, String processInstanceId) { | |
| 738 | + public BpmProcessPrintDataRespVO getProcessInstancePrintData(Long loginUserId, String processInstanceId) { | |
| 739 | 739 | // TODO 方法抽离 |
| 740 | 740 | // 流程实例 |
| 741 | 741 | HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance(processInstanceId); |
| ... | ... | @@ -747,7 +747,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 747 | 747 | .getProcessDefinitionInfo(historicProcessInstance.getProcessDefinitionId()); |
| 748 | 748 | BpmModelMetaInfoVO.PrintTemplateSetting printTemplateSetting = processDefinitionInfo.getPrintTemplateSetting(); |
| 749 | 749 | List<String> formFieldList = processDefinitionInfo.getFormFields(); |
| 750 | - List<JSONObject> formFieldObjList = formFieldList.stream().map(JSONUtil::parseObj).toList(); | |
| 750 | + List<JSONObject> formFieldObjList = formFieldList != null ? formFieldList.stream().map(JSONUtil::parseObj).toList() | |
| 751 | + : ListUtil.of(); | |
| 751 | 752 | List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery() |
| 752 | 753 | .finished() |
| 753 | 754 | .includeTaskLocalVariables() |
| ... | ... | @@ -758,7 +759,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 758 | 759 | Set<Long> userIds = convertSet(tasks, item -> Long.valueOf(item.getAssignee())); |
| 759 | 760 | userIds.add(loginUserId); |
| 760 | 761 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); |
| 761 | - HashMap<String, String> printDataMap = new HashMap<>(8 + formFieldList.size()); | |
| 762 | + HashMap<String, String> printDataMap = new HashMap<>(8 + formFieldObjList.size()); | |
| 762 | 763 | // 返回打印所需数据 |
| 763 | 764 | BpmProcessPrintDataRespVO printData = new BpmProcessPrintDataRespVO(); |
| 764 | 765 | // 打印模板是否开启 |
| ... | ... | @@ -776,6 +777,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 776 | 777 | printData.setStartUser(startUser.getNickname()); |
| 777 | 778 | printData.setStartUserDept(dept.getName()); |
| 778 | 779 | // 审批历史 |
| 780 | + // TODO @lesan:打印的时候,未来节点打印么? | |
| 779 | 781 | List<BpmProcessPrintDataRespVO.ApproveNode> approveNodes = new ArrayList<>(tasks.size()); |
| 780 | 782 | tasks.forEach(item -> { |
| 781 | 783 | Map<String, Object> taskLocalVariables = item.getTaskLocalVariables(); |
| ... | ... | @@ -793,8 +795,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 793 | 795 | }); |
| 794 | 796 | printData.setApproveNodes(approveNodes); |
| 795 | 797 | // 表单数据 |
| 798 | + // TODO @lesan:这个可以在端上搞么?主要考虑,vben 和 vue3 plus 可能使用了不同的前端框架;可能直接使用 form-create 前端的工具方法,会更方便。 | |
| 796 | 799 | Map<String, Object> processVariables = historicProcessInstance.getProcessVariables(); |
| 797 | - List<BpmProcessPrintDataRespVO.FormField> formFields = new ArrayList<>(formFieldList.size()); | |
| 800 | + List<BpmProcessPrintDataRespVO.FormField> formFields = new ArrayList<>(formFieldObjList.size()); | |
| 798 | 801 | formFieldObjList.forEach(item -> { |
| 799 | 802 | BpmProcessPrintDataRespVO.FormField formField = new BpmProcessPrintDataRespVO.FormField(); |
| 800 | 803 | formField.setFormName(item.getStr("title")); |
| ... | ... | @@ -834,6 +837,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 834 | 837 | Elements mention = document.getElementsByAttributeValue("data-w-e-type", "mention"); |
| 835 | 838 | mention.forEach(item -> { |
| 836 | 839 | String mentionId = JSONUtil.parseObj(URLUtil.decode(item.attr("data-info"))).getStr("id"); |
| 840 | + // TODO @lesan:这里要求非空; | |
| 837 | 841 | item.html(printDataMap.get(mentionId)); |
| 838 | 842 | }); |
| 839 | 843 | // 替换流程记录 | ... | ... |