From cc44920da3d40b8248b67560026e891afdd1a6ab Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期四, 08 五月 2025 17:57:14 +0800 Subject: [PATCH] 1.查询可以被引用的部件接口开发完成 2.借用部件(可批量) 开发完成 3.修改原有新增、修改部件接口 完成 4.修改原有删除文档与导入文档接口 完成 5.修改工作流问题 --- lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java | 108 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 96 insertions(+), 12 deletions(-) diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java index c9ae8f1..6b715e9 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java @@ -668,6 +668,29 @@ flowTaskVo.setTaskId(business.getTaskId()); return findReturnTaskList(flowTaskVo); } + + /** + * 缁撴潫娴佺▼ + * @param processInstanceId 娴佺▼瀹炰緥 ID + * @param deleteReason 瀹氫箟鍒犻櫎鍘熷洜 + */ + public Result<?> end(String processInstanceId, String deleteReason) { + try { + // 寮哄埗缁撴潫娴佺▼瀹炰緥 + runtimeService.deleteProcessInstance(processInstanceId, deleteReason); + // 鍒犻櫎鍏宠仈娴佺▼鐨勪笟鍔� + FlowMyBusiness flowMyBusiness=flowMyBusinessService.getFlowMyBusiness(processInstanceId); + flowMyBusinessService.removeById(flowMyBusiness.getId()); + System.out.println("Process instance with ID " + processInstanceId + " has been forcefully ended."); + } catch (Exception e) { + System.err.println("Failed to force end process instance: " + e.getMessage()); + } + + // 鍏抽棴娴佺▼寮曟搸 + processEngine.close(); + return Result.OK("娴佺▼宸茬粨鏉�"); + } + /** * 鑾峰彇鎵�鏈夊彲鍥為��鐨勮妭鐐� * @@ -916,6 +939,63 @@ return Result.OK(); } + + /** + * 鍒ゆ柇澶氫釜浠诲姟鏄惁澶勪簬鍚屼竴娴佺▼鑺傜偣 + * @param taskIds 閫楀彿鍒嗛殧鐨勪换鍔D瀛楃涓� + * @return 缁熶竴缁撴灉灏佽 + */ + @Override + public Result isSameNode(String taskIds) { + // 1. 鍙傛暟鏍¢獙 + if (StringUtils.isBlank(taskIds)) { + return Result.error("浠诲姟ID涓嶈兘涓虹┖"); + } + + // 2. 鍒嗗壊浠诲姟ID + String[] taskIdArray = taskIds.split(","); + if (taskIdArray.length == 0) { + return Result.error("鏈彁渚涙湁鏁堢殑浠诲姟ID"); + } + + // 3. 鍗曚换鍔$洿鎺ヨ繑鍥瀟rue + if (taskIdArray.length == 1) { + return Result.ok(true); + } + + // 4. 澶氫换鍔℃鏌ラ�昏緫 + String referenceNodeId = null; + String currentNodeId = null; + for (String taskId : taskIdArray) { + // 4.1 鏌ヨ浠诲姟瀹炰緥 + Task task = taskService.createTaskQuery() + .taskId(taskId.trim()) + .singleResult(); + + // 4.2 浠诲姟涓嶅瓨鍦ㄥ鐞� + if (task == null) { + return Result.error("浠诲姟涓嶅瓨鍦�: " + taskId); + } + + // 4.3 鑾峰彇鑺傜偣鏍囪瘑锛圱askDefinitionKey锛� + currentNodeId = task.getTaskDefinitionKey(); + + // 4.4 棣栨閬嶅巻鍒濆鍖栧弬鑰冭妭鐐� + if (referenceNodeId == null) { + referenceNodeId = currentNodeId; + continue; + } + + // 4.5 鑺傜偣涓嶄竴鑷寸洿鎺ヨ繑鍥� + if (!referenceNodeId.equals(currentNodeId)) { + return Result.ok("鑺傜偣涓嶄竴鑷�"); + } + } + + // 5. 鎵�鏈変换鍔¤妭鐐逛竴鑷� + return Result.ok(currentNodeId); + } + /** * 浠e姙浠诲姟鍒楄〃 * @@ -982,26 +1062,30 @@ Page page = new Page(pageNum, pageSize); String username = iFlowThirdService.getLoginUser().getUsername(); flowMyBusinessDto.setCurrentUser(username); - IPage<FlowTaskDto> flowTaskDtoIPage = flowMyBusinessService.getPageListMyBusiness(page,flowMyBusinessDto); - flowTaskDtoIPage.getRecords().forEach(flowTaskDto -> { - // 娴佺▼瀹氫箟淇℃伅 - ProcessDefinition pd = repositoryService.createProcessDefinitionQuery() - .processDefinitionId(flowTaskDto.getProcessDefinitionId()) - .singleResult(); - flowTaskDto.setDeployId(pd.getDeploymentId()); - flowTaskDto.setProcDefName(pd.getName()); - flowTaskDto.setProcDefVersion(pd.getVersion()); - flowTaskDto.setCategory(pd.getCategory()); + List<FlowTaskDto> list = flowMyBusinessService.ListMyBusiness(flowMyBusinessDto); + list.forEach(flowTaskDto -> { // 娴佺▼鍙戣捣浜轰俊鎭� HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(flowTaskDto.getProcInsId()) .singleResult(); SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId()); - flowTaskDto.setStartUserId(startUser.getUsername()); - flowTaskDto.setStartUserName(startUser.getRealname()); + if (startUser!=null){ + flowTaskDto.setStartUserId(startUser.getUsername()); + flowTaskDto.setStartUserName(startUser.getRealname()); + } List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername,"锛�")); + if (flowTaskDto.getTodoUsers() == null){ + flowTaskDto.setTodoUsers(""); + }else { + //鍘婚櫎[] + flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\\[", "").replaceAll("\\]", "")); + flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\"", "")); + } }); + IPage<FlowTaskDto> flowTaskDtoIPage = new Page<>(); + flowTaskDtoIPage.setRecords(list); + flowTaskDtoIPage.setTotal(page.getTotal()); return Result.OK(flowTaskDtoIPage); } -- Gitblit v1.9.3