Commit 67e548d54567777c60bfbde9f1213491bb87cdfa
1 parent
97948502
【代码评审】BPM:任务前置、后置通知
Showing
5 changed files
with
15 additions
and
33 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| ... | ... | @@ -63,7 +63,6 @@ import org.springframework.context.annotation.Lazy; |
| 63 | 63 | import org.springframework.stereotype.Service; |
| 64 | 64 | import org.springframework.transaction.annotation.Transactional; |
| 65 | 65 | import org.springframework.validation.annotation.Validated; |
| 66 | -import org.springframework.web.client.RestTemplate; | |
| 67 | 66 | |
| 68 | 67 | import java.util.*; |
| 69 | 68 | |
| ... | ... | @@ -268,6 +267,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 268 | 267 | FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); |
| 269 | 268 | List<FlowNode> nextFlowNodes = BpmnModelUtils.getNextFlowNodes(flowElement, bpmnModel, processVariables); |
| 270 | 269 | |
| 270 | + // TODO @小北:还是可以优化下哈;“4. 组装节点信息” 只拼接出 candidateUserIds;之后,再第二次循环,查询用户和部门信息,进行拼接 | |
| 271 | 271 | // 2. 收集所有节点的候选用户 ID |
| 272 | 272 | Set<Long> allCandidateUsers = new HashSet<>(); |
| 273 | 273 | for (FlowNode node : nextFlowNodes) { |
| ... | ... | @@ -290,7 +290,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 290 | 290 | List<UserSimpleBaseVO> candidateUsers = new ArrayList<>(); |
| 291 | 291 | for (Long userId : candidateUserIds) { |
| 292 | 292 | UserSimpleBaseVO user = BpmProcessInstanceConvert.INSTANCE.buildUser(userId, userMap, deptMap); |
| 293 | - if (user != null){ | |
| 293 | + if (user != null) { | |
| 294 | 294 | candidateUsers.add(user); |
| 295 | 295 | } |
| 296 | 296 | } |
| ... | ... | @@ -932,10 +932,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 932 | 932 | BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getProcessAfterTriggerSetting(); |
| 933 | 933 | |
| 934 | 934 | BpmHttpRequestUtils.executeBpmHttpRequest(instance, |
| 935 | - setting.getUrl(), | |
| 936 | - setting.getHeader(), | |
| 937 | - setting.getBody(), | |
| 938 | - true, setting.getResponse()); | |
| 935 | + setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse()); | |
| 939 | 936 | } |
| 940 | 937 | } |
| 941 | 938 | }); |
| ... | ... | @@ -954,10 +951,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 954 | 951 | } |
| 955 | 952 | BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getProcessBeforeTriggerSetting(); |
| 956 | 953 | BpmHttpRequestUtils.executeBpmHttpRequest(instance, |
| 957 | - setting.getUrl(), | |
| 958 | - setting.getHeader(), | |
| 959 | - setting.getBody(), | |
| 960 | - true, setting.getResponse()); | |
| 954 | + setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse()); | |
| 961 | 955 | }); |
| 962 | 956 | } |
| 963 | 957 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| ... | ... | @@ -1176,7 +1176,6 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 1176 | 1176 | } |
| 1177 | 1177 | updateTaskStatus(task.getId(), BpmTaskStatusEnum.RUNNING.getStatus()); |
| 1178 | 1178 | |
| 1179 | - // 2. 处理自动通过的情况,例如说:1)无审批人时,是否自动通过、不通过;2)非【人工审核】时,是否自动通过、不通过 | |
| 1180 | 1179 | ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); |
| 1181 | 1180 | if (processInstance == null) { |
| 1182 | 1181 | log.error("[processTaskCreated][taskId({}) 没有找到流程实例]", task.getId()); |
| ... | ... | @@ -1188,15 +1187,15 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 1188 | 1187 | log.error("[processTaskCreated][processDefinitionId({}) 没有找到流程定义]", processInstance.getProcessDefinitionId()); |
| 1189 | 1188 | return; |
| 1190 | 1189 | } |
| 1191 | - // 任务前置通知 | |
| 1190 | + | |
| 1191 | + // 2. 任务前置通知 | |
| 1192 | 1192 | if (ObjUtil.isNotNull(processDefinitionInfo.getTaskBeforeTriggerSetting())){ |
| 1193 | 1193 | BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getTaskBeforeTriggerSetting(); |
| 1194 | 1194 | BpmHttpRequestUtils.executeBpmHttpRequest(processInstance, |
| 1195 | - setting.getUrl(), | |
| 1196 | - setting.getHeader(), | |
| 1197 | - setting.getBody(), | |
| 1198 | - true, setting.getResponse()); | |
| 1195 | + setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse()); | |
| 1199 | 1196 | } |
| 1197 | + | |
| 1198 | + // 3. 处理自动通过的情况,例如说:1)无审批人时,是否自动通过、不通过;2)非【人工审核】时,是否自动通过、不通过 | |
| 1200 | 1199 | BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(processInstance.getProcessDefinitionId()); |
| 1201 | 1200 | FlowElement userTaskElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); |
| 1202 | 1201 | Integer approveType = BpmnModelUtils.parseApproveType(userTaskElement); |
| ... | ... | @@ -1421,14 +1420,12 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 1421 | 1420 | log.error("[processTaskCompleted][processDefinitionId({}) 没有找到流程定义]", processInstance.getProcessDefinitionId()); |
| 1422 | 1421 | return; |
| 1423 | 1422 | } |
| 1424 | - // 任务前置通知 | |
| 1423 | + | |
| 1424 | + // 任务后置通知 | |
| 1425 | 1425 | if (ObjUtil.isNotNull(processDefinitionInfo.getTaskAfterTriggerSetting())){ |
| 1426 | 1426 | BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getTaskAfterTriggerSetting(); |
| 1427 | 1427 | BpmHttpRequestUtils.executeBpmHttpRequest(processInstance, |
| 1428 | - setting.getUrl(), | |
| 1429 | - setting.getHeader(), | |
| 1430 | - setting.getBody(), | |
| 1431 | - true, setting.getResponse()); | |
| 1428 | + setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse()); | |
| 1432 | 1429 | } |
| 1433 | 1430 | } |
| 1434 | 1431 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/listener/BpmUserTaskListener.java
| ... | ... | @@ -52,10 +52,7 @@ public class BpmUserTaskListener implements TaskListener { |
| 52 | 52 | listenerHandler.getBody().add(new BpmSimpleModelNodeVO.HttpRequestParam().setKey("taskId") |
| 53 | 53 | .setType(BpmHttpRequestParamTypeEnum.FIXED_VALUE.getType()).setValue(delegateTask.getId())); |
| 54 | 54 | BpmHttpRequestUtils.executeBpmHttpRequest(processInstance, |
| 55 | - listenerHandler.getPath(), | |
| 56 | - listenerHandler.getHeader(), | |
| 57 | - listenerHandler.getBody(), | |
| 58 | - false, null); | |
| 55 | + listenerHandler.getPath(), listenerHandler.getHeader(), listenerHandler.getBody(), false, null); | |
| 59 | 56 | |
| 60 | 57 | // 3. 是否需要后续操作?TODO 芋艿:待定! |
| 61 | 58 | } | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmHttpCallbackTrigger.java
| ... | ... | @@ -45,10 +45,7 @@ public class BpmHttpCallbackTrigger extends BpmAbstractHttpRequestTrigger { |
| 45 | 45 | .setKey("taskDefineKey") // 重要:回调请求 taskDefineKey 需要传给被调用方,用于回调执行 |
| 46 | 46 | .setType(BpmHttpRequestParamTypeEnum.FIXED_VALUE.getType()).setValue(setting.getCallbackTaskDefineKey())); |
| 47 | 47 | BpmHttpRequestUtils.executeBpmHttpRequest(processInstance, |
| 48 | - setting.getUrl(), | |
| 49 | - setting.getHeader(), | |
| 50 | - setting.getBody(), | |
| 51 | - false, null); | |
| 48 | + setting.getUrl(), setting.getHeader(), setting.getBody(), false, null); | |
| 52 | 49 | } |
| 53 | 50 | |
| 54 | 51 | } | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmSyncHttpRequestTrigger.java
| ... | ... | @@ -40,10 +40,7 @@ public class BpmSyncHttpRequestTrigger extends BpmAbstractHttpRequestTrigger { |
| 40 | 40 | // 2. 发起请求 |
| 41 | 41 | ProcessInstance processInstance = processInstanceService.getProcessInstance(processInstanceId); |
| 42 | 42 | BpmHttpRequestUtils.executeBpmHttpRequest(processInstance, |
| 43 | - setting.getUrl(), | |
| 44 | - setting.getHeader(), | |
| 45 | - setting.getBody(), | |
| 46 | - true, setting.getResponse()); | |
| 43 | + setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse()); | |
| 47 | 44 | } |
| 48 | 45 | |
| 49 | 46 | } | ... | ... |