From ddc0f14384619b9618f26a3f363f679833a68b3d Mon Sep 17 00:00:00 2001 From: yangbin <yangbin@qq.com> Date: 星期三, 16 四月 2025 09:51:32 +0800 Subject: [PATCH] 自动化产线集成模块添加数据查询 --- lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java | 47 ++++++++++++++++++++--------------------------- 1 files changed, 20 insertions(+), 27 deletions(-) diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java index cdfca7e..bbb90bc 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/service/impl/FlowDefinitionServiceImpl.java @@ -9,10 +9,8 @@ import org.apache.commons.io.IOUtils; import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.impl.identity.Authentication; import org.flowable.engine.ProcessEngineConfiguration; import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.repository.ProcessDefinitionQuery; @@ -24,12 +22,11 @@ import org.jeecg.common.util.SpringContextUtils; import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; -import org.jeecg.modules.flowable.apithird.entity.ActStatus; +import org.jeecg.modules.flowable.apithird.common.constant.ProcessConstants; +import org.jeecg.modules.flowable.apithird.common.enums.FlowComment; import org.jeecg.modules.flowable.apithird.entity.SysUser; import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; import org.jeecg.modules.flowable.apithird.service.IFlowThirdService; -import org.jeecg.modules.flowable.apithird.common.constant.ProcessConstants; -import org.jeecg.modules.flowable.apithird.common.enums.FlowComment; import org.jeecg.modules.flowable.domain.dto.FlowNextDto; import org.jeecg.modules.flowable.domain.dto.FlowProcDefDto; import org.jeecg.modules.flowable.factory.FlowServiceFactory; @@ -65,7 +62,7 @@ ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey); long count = processDefinitionQuery.count(); - return count > 0 ? true : false; + return count > 0; } @@ -145,7 +142,7 @@ public Result readXml(String deployId) throws IOException { ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName()); - String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name()); + String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); return Result.OK("", result); } @@ -158,7 +155,7 @@ FlowMyBusiness business = flowMyBusinessService.getOne(flowMyBusinessLambdaQueryWrapper); ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(business.getProcessDefinitionId()).singleResult(); InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName()); - String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name()); + String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); return Result.OK("", result); } @@ -239,6 +236,7 @@ * @return */ @Override + @Transactional(rollbackFor = {Exception.class}) public Result<?> startProcessInstanceByKey(String procDefKey, Map<String, Object> variables) { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(procDefKey) @@ -271,15 +269,10 @@ ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); // 缁欑涓�姝ョ敵璇蜂汉鑺傜偣璁剧疆浠诲姟鎵ц浜哄拰鎰忚 Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult(); - if (!sysUser.getUsername().equals(task.getAssignee())){ - return Result.error("褰撳墠鐢ㄦ埛涓嶆槸娴佺▼鍙戣捣浜�"); - } if (Objects.nonNull(task)) { - taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getRealname() + "鍙戣捣娴佺▼鐢宠"); + taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), variables.get("organization").toString()); taskService.setAssignee(task.getId(), sysUser.getUsername()); task.setDescription(variables.get("organization").toString()); - // 鏇存柊浠诲姟 - taskService.saveTask(task); //taskService.complete(task.getId(), variables); } //璁剧疆鎵�鏈夌敵璇蜂汉 @@ -318,6 +311,15 @@ String serviceImplName = business.getServiceImplName(); FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), variables); + business.setProcessDefinitionId(procDefId) + .setProcessInstanceId(processInstance.getProcessInstanceId()) +//// .setActStatus(ActStatus.start) + .setProposer(sysUser.getUsername()) + .setTaskId(task2.getId()) + .setTaskName(nextTask.getName()) + .setTaskNameId(nextTask.getId()) + .setPriority(nextTask.getPriority()) + .setDoneUsers(doneUserList.toJSONString()); if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){ // 鍒犻櫎鍚庨噸鍐� for (Task task2One : task2List) { @@ -332,24 +334,15 @@ } } business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); + }else { + // 涓氬姟灞傛病鏈夋寚瀹氬�欓�変汉锛岀洿鎺ヨ鐩� + business.setTodoUsers(JSON.toJSONString(collect_username)); } - - business.setProcessDefinitionId(procDefId) - .setProcessInstanceId(processInstance.getProcessInstanceId()) - .setActStatus(ActStatus.start) - .setProposer(sysUser.getUsername()) - .setTaskId(task2.getId()) - .setTaskName(nextTask.getName()) - .setTaskNameId(nextTask.getId()) - .setPriority(nextTask.getPriority()) - .setDoneUsers(doneUserList.toJSONString()) - .setTodoUsers(JSON.toJSONString(collect_username)) - ; } else { // **娌℃湁涓嬩竴涓妭鐐癸紝娴佺▼宸茬粡缁撴潫浜� business.setProcessDefinitionId(procDefId) .setProcessInstanceId(processInstance.getProcessInstanceId()) - .setActStatus(ActStatus.pass) +// .setActStatus(ActStatus.pass) .setProposer(sysUser.getUsername()) .setDoneUsers(doneUserList.toJSONString()) ; -- Gitblit v1.9.3