From 1c7f8ccf40c19d4f9fddacec162e1209b711f7ce Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期一, 07 七月 2025 13:49:00 +0800 Subject: [PATCH] 设备点检业务流程增加企业微信消息推送 --- lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowTaskServiceImpl.java | 69 ++++++++++++++++++++++++++++++++-- 1 files changed, 64 insertions(+), 5 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 8ce1dab..95ac97a 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 @@ -19,6 +19,7 @@ import org.flowable.common.engine.api.FlowableObjectNotFoundException; import org.flowable.common.engine.impl.identity.Authentication; import org.flowable.engine.ProcessEngineConfiguration; +import org.flowable.engine.TaskService; import org.flowable.engine.history.HistoricActivityInstance; import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstanceQuery; @@ -34,6 +35,7 @@ import org.flowable.task.api.TaskQuery; import org.flowable.task.api.history.HistoricTaskInstance; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.SpringContextUtils; import org.jeecg.modules.flowable.apithird.business.dto.FlowMyBusinessDto; @@ -50,6 +52,7 @@ import org.jeecg.modules.flowable.domain.dto.FlowTaskDto; import org.jeecg.modules.flowable.domain.dto.FlowViewerDto; import org.jeecg.modules.flowable.domain.vo.FlowTaskVo; +import org.jeecg.modules.flowable.domain.vo.WorkTaskDataVo; import org.jeecg.modules.flowable.factory.FlowServiceFactory; import org.jeecg.modules.flowable.flow.CustomProcessDiagramGenerator; import org.jeecg.modules.flowable.flow.FindNextNodeUtil; @@ -78,6 +81,8 @@ private IFlowThirdService iFlowThirdService; @Autowired FlowMyBusinessServiceImpl flowMyBusinessService; + @Autowired + private TaskService taskService; /** * 瀹屾垚浠诲姟 * @@ -1069,11 +1074,18 @@ HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(flowTaskDto.getProcInsId()) .singleResult(); - SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId()); - flowTaskDto.setStartUserId(startUser.getUsername()); - flowTaskDto.setStartUserName(startUser.getRealname()); - List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); - flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername,"锛�")); + if(historicProcessInstance != null) { + SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId()); + if(startUser == null) { + flowTaskDto.setStartUserId(""); + flowTaskDto.setStartUserName(""); + }else { + flowTaskDto.setStartUserId(startUser.getUsername()); + flowTaskDto.setStartUserName(startUser.getRealname()); + } + List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); + flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername,"锛�")); + } }); IPage<FlowTaskDto> flowTaskDtoIPage = new Page<>(); flowTaskDtoIPage.setRecords(list); @@ -1374,6 +1386,53 @@ return Result.OK(flowNextDto); } + @Override + public WorkTaskDataVo getPreviousFlowInfo(String dataId) { + FlowMyBusiness flowMyBusiness = flowMyBusinessService.getByDataId(dataId); + if (flowMyBusiness == null) { + throw new JeecgBootException("鏈壘鍒版祦绋嬫暟鎹紒"); + } + + String taskId = flowMyBusiness.getTaskId(); + String processInstanceId = flowMyBusiness.getProcessInstanceId(); + WorkTaskDataVo taskDataVo = new WorkTaskDataVo(); + // 濡傛灉褰撳墠浠诲姟ID涓虹┖锛屽垯灏濊瘯浠庡巻鍙蹭换鍔′腑鑾峰彇鏈�鍚庝竴涓畬鎴愮殑浠诲姟 + if (StringUtils.isBlank(taskId)) { + List<HistoricTaskInstance> historicTasks = historyService + .createHistoricTaskInstanceQuery() + .processInstanceId(processInstanceId) + .orderByTaskCreateTime() + .desc() + .list(); + + if (CollectionUtils.isEmpty(historicTasks)) { + throw new JeecgBootException("鎵句笉鍒板巻鍙蹭换鍔¤褰�"); + } + + HistoricTaskInstance lastTask = historicTasks.get(0); + buildWorkTaskDataVo(taskDataVo, lastTask.getId(), lastTask.getName(), lastTask.getCreateTime()); + } else { + Task task = taskService.createTaskQuery().taskId(taskId).active().singleResult(); + if (task == null) { + throw new JeecgBootException("鎵句笉鍒板搴斾换鍔�"); + } else { + buildWorkTaskDataVo(taskDataVo, task.getId(), task.getName(), task.getCreateTime()); + } + } + return taskDataVo; + } + + private void buildWorkTaskDataVo(WorkTaskDataVo taskDataVo, String id, String name, Date createTime) { + taskDataVo.setId(id); + taskDataVo.setName(name); + taskDataVo.setCreateTime(createTime); + HistoricActivityInstance previousNode = flowMyBusinessService.getPreviousNode(id); + if (previousNode != null) { + taskDataVo.setPreNode(previousNode.getActivityName()); + taskDataVo.setPreNodeAssignee(previousNode.getAssignee()); + } + } + /** * 鑾峰彇涓嬩竴涓妭鐐逛俊鎭�,娴佺▼瀹氫箟涓婄殑鑺傜偣淇℃伅 * @param taskId 褰撳墠鑺傜偣id -- Gitblit v1.9.3