Commit 25899d99885c68e40335e748f4b178e8ab613501
1 parent
4364ef09
fix: 代码评审修改
Showing
7 changed files
with
44 additions
and
70 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelMetaInfoVO.java
| @@ -82,13 +82,11 @@ public class BpmModelMetaInfoVO { | @@ -82,13 +82,11 @@ public class BpmModelMetaInfoVO { | ||
| 82 | @Schema(description = "摘要设置", example = "{}") | 82 | @Schema(description = "摘要设置", example = "{}") |
| 83 | private SummarySetting summarySetting; | 83 | private SummarySetting summarySetting; |
| 84 | 84 | ||
| 85 | - // TODO @lesan:processBeforeTriggerSetting;要不叫这个?主要考虑,notify 留给后续的站内信、短信、邮件这种 notify 通知哈。 | ||
| 86 | @Schema(description = "流程前置通知设置", example = "{}") | 85 | @Schema(description = "流程前置通知设置", example = "{}") |
| 87 | - private HttpRequestSetting PreProcessNotifySetting; | 86 | + private HttpRequestSetting processBeforeTriggerSetting; |
| 88 | 87 | ||
| 89 | - // TODO @lesan:processAfterTriggerSetting | ||
| 90 | @Schema(description = "流程后置通知设置", example = "{}") | 88 | @Schema(description = "流程后置通知设置", example = "{}") |
| 91 | - private HttpRequestSetting PostProcessNotifySetting; | 89 | + private HttpRequestSetting processAfterTriggerSetting; |
| 92 | 90 | ||
| 93 | @Schema(description = "流程 ID 规则") | 91 | @Schema(description = "流程 ID 规则") |
| 94 | @Data | 92 | @Data |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java
| @@ -188,16 +188,15 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { | @@ -188,16 +188,15 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { | ||
| 188 | @TableField(typeHandler = JacksonTypeHandler.class) | 188 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 189 | private BpmModelMetaInfoVO.SummarySetting summarySetting; | 189 | private BpmModelMetaInfoVO.SummarySetting summarySetting; |
| 190 | 190 | ||
| 191 | - // TODO @lesan:processBeforeTriggerSetting;要不叫这个?主要考虑,notify 留给后续的站内信、短信、邮件这种 notify 通知哈。 | ||
| 192 | /** | 191 | /** |
| 193 | * 流程前置通知设置 | 192 | * 流程前置通知设置 |
| 194 | */ | 193 | */ |
| 195 | @TableField(typeHandler = JacksonTypeHandler.class, exist = false) // TODO @芋艿:临时注释 exist,因为要合并 master-jdk17 | 194 | @TableField(typeHandler = JacksonTypeHandler.class, exist = false) // TODO @芋艿:临时注释 exist,因为要合并 master-jdk17 |
| 196 | - private BpmModelMetaInfoVO.HttpRequestSetting PreProcessNotifySetting; | 195 | + private BpmModelMetaInfoVO.HttpRequestSetting processBeforeTriggerSetting; |
| 197 | /** | 196 | /** |
| 198 | * 流程后置通知设置 | 197 | * 流程后置通知设置 |
| 199 | */ | 198 | */ |
| 200 | @TableField(typeHandler = JacksonTypeHandler.class, exist = false) // TODO @芋艿:临时注释 exist,因为要合并 master-jdk17 | 199 | @TableField(typeHandler = JacksonTypeHandler.class, exist = false) // TODO @芋艿:临时注释 exist,因为要合并 master-jdk17 |
| 201 | - private BpmModelMetaInfoVO.HttpRequestSetting PostProcessNotifySetting; | 200 | + private BpmModelMetaInfoVO.HttpRequestSetting processAfterTriggerSetting; |
| 202 | 201 | ||
| 203 | } | 202 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmHttpRequestUtils.java
| @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; | @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.core.KeyValue; | 5 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 7 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | 7 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 8 | +import cn.iocoder.yudao.framework.common.util.spring.SpringUtils; | ||
| 8 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; | 9 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; |
| 9 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmHttpRequestParamTypeEnum; | 10 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmHttpRequestParamTypeEnum; |
| 10 | import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; | 11 | import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; |
| @@ -40,11 +41,9 @@ public class BpmHttpRequestUtils { | @@ -40,11 +41,9 @@ public class BpmHttpRequestUtils { | ||
| 40 | List<BpmSimpleModelNodeVO.HttpRequestParam> headerParams, | 41 | List<BpmSimpleModelNodeVO.HttpRequestParam> headerParams, |
| 41 | List<BpmSimpleModelNodeVO.HttpRequestParam> bodyParams, | 42 | List<BpmSimpleModelNodeVO.HttpRequestParam> bodyParams, |
| 42 | Boolean handleResponse, | 43 | Boolean handleResponse, |
| 43 | - List<KeyValue<String, String>> response, | ||
| 44 | - // TODO @lesan:RestTemplate 直接通过 springUtil 获取好咧; | ||
| 45 | - RestTemplate restTemplate, | ||
| 46 | - // TODO @lesan:processInstanceService 直接通过 springUtil 获取好咧; | ||
| 47 | - BpmProcessInstanceService processInstanceService) { | 44 | + List<KeyValue<String, String>> response) { |
| 45 | + RestTemplate restTemplate = SpringUtils.getBean(RestTemplate.class); | ||
| 46 | + BpmProcessInstanceService processInstanceService = SpringUtils.getBean(BpmProcessInstanceService.class); | ||
| 48 | 47 | ||
| 49 | // 1.1 设置请求头 | 48 | // 1.1 设置请求头 |
| 50 | MultiValueMap<String, String> headers = buildHttpHeaders(processInstance, headerParams); | 49 | MultiValueMap<String, String> headers = buildHttpHeaders(processInstance, headerParams); |
| @@ -55,27 +54,27 @@ public class BpmHttpRequestUtils { | @@ -55,27 +54,27 @@ public class BpmHttpRequestUtils { | ||
| 55 | ResponseEntity<String> responseEntity = sendHttpRequest(url, headers, body, restTemplate); | 54 | ResponseEntity<String> responseEntity = sendHttpRequest(url, headers, body, restTemplate); |
| 56 | 55 | ||
| 57 | // 3. 处理返回 | 56 | // 3. 处理返回 |
| 58 | - // TODO @lesan:可以用 if return,让括号小点 | ||
| 59 | - if (Boolean.TRUE.equals(handleResponse)) { | ||
| 60 | - // 3.1 判断是否需要解析返回值 | ||
| 61 | - if (responseEntity == null | ||
| 62 | - || StrUtil.isEmpty(responseEntity.getBody()) | ||
| 63 | - || !responseEntity.getStatusCode().is2xxSuccessful() | ||
| 64 | - || CollUtil.isEmpty(response)) { | ||
| 65 | - return; | ||
| 66 | - } | ||
| 67 | - // 3.2 解析返回值, 返回值必须符合 CommonResult 规范。 | ||
| 68 | - CommonResult<Map<String, Object>> respResult = JsonUtils.parseObjectQuietly(responseEntity.getBody(), | ||
| 69 | - new TypeReference<>() {}); | ||
| 70 | - if (respResult == null || !respResult.isSuccess()) { | ||
| 71 | - return; | ||
| 72 | - } | ||
| 73 | - // 3.3 获取需要更新的流程变量 | ||
| 74 | - Map<String, Object> updateVariables = getNeedUpdatedVariablesFromResponse(respResult.getData(), response); | ||
| 75 | - // 3.4 更新流程变量 | ||
| 76 | - if (CollUtil.isNotEmpty(updateVariables)) { | ||
| 77 | - processInstanceService.updateProcessInstanceVariables(processInstance.getId(), updateVariables); | ||
| 78 | - } | 57 | + if (Boolean.FALSE.equals(handleResponse)) { |
| 58 | + return; | ||
| 59 | + } | ||
| 60 | + // 3.1 判断是否需要解析返回值 | ||
| 61 | + if (responseEntity == null | ||
| 62 | + || StrUtil.isEmpty(responseEntity.getBody()) | ||
| 63 | + || !responseEntity.getStatusCode().is2xxSuccessful() | ||
| 64 | + || CollUtil.isEmpty(response)) { | ||
| 65 | + return; | ||
| 66 | + } | ||
| 67 | + // 3.2 解析返回值, 返回值必须符合 CommonResult 规范。 | ||
| 68 | + CommonResult<Map<String, Object>> respResult = JsonUtils.parseObjectQuietly(responseEntity.getBody(), | ||
| 69 | + new TypeReference<>() {}); | ||
| 70 | + if (respResult == null || !respResult.isSuccess()) { | ||
| 71 | + return; | ||
| 72 | + } | ||
| 73 | + // 3.3 获取需要更新的流程变量 | ||
| 74 | + Map<String, Object> updateVariables = getNeedUpdatedVariablesFromResponse(respResult.getData(), response); | ||
| 75 | + // 3.4 更新流程变量 | ||
| 76 | + if (CollUtil.isNotEmpty(updateVariables)) { | ||
| 77 | + processInstanceService.updateProcessInstanceVariables(processInstance.getId(), updateVariables); | ||
| 79 | } | 78 | } |
| 80 | } | 79 | } |
| 81 | 80 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| @@ -122,9 +122,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -122,9 +122,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 122 | @Resource | 122 | @Resource |
| 123 | private BpmProcessIdRedisDAO processIdRedisDAO; | 123 | private BpmProcessIdRedisDAO processIdRedisDAO; |
| 124 | 124 | ||
| 125 | - @Resource | ||
| 126 | - private RestTemplate restTemplate; | ||
| 127 | - | ||
| 128 | // ========== Query 查询相关方法 ========== | 125 | // ========== Query 查询相关方法 ========== |
| 129 | 126 | ||
| 130 | @Override | 127 | @Override |
| @@ -913,16 +910,14 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -913,16 +910,14 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 913 | BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService. | 910 | BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService. |
| 914 | getProcessDefinitionInfo(instance.getProcessDefinitionId()); | 911 | getProcessDefinitionInfo(instance.getProcessDefinitionId()); |
| 915 | if (ObjUtil.isNotNull(processDefinitionInfo) && | 912 | if (ObjUtil.isNotNull(processDefinitionInfo) && |
| 916 | - ObjUtil.isNotNull(processDefinitionInfo.getPostProcessNotifySetting())) { | ||
| 917 | - BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getPostProcessNotifySetting(); | 913 | + ObjUtil.isNotNull(processDefinitionInfo.getProcessAfterTriggerSetting())) { |
| 914 | + BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getProcessAfterTriggerSetting(); | ||
| 918 | 915 | ||
| 919 | BpmHttpRequestUtils.executeBpmHttpRequest(instance, | 916 | BpmHttpRequestUtils.executeBpmHttpRequest(instance, |
| 920 | setting.getUrl(), | 917 | setting.getUrl(), |
| 921 | setting.getHeader(), | 918 | setting.getHeader(), |
| 922 | setting.getBody(), | 919 | setting.getBody(), |
| 923 | - true, setting.getResponse(), | ||
| 924 | - restTemplate, | ||
| 925 | - this); | 920 | + true, setting.getResponse()); |
| 926 | } | 921 | } |
| 927 | } | 922 | } |
| 928 | }); | 923 | }); |
| @@ -935,18 +930,16 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -935,18 +930,16 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 935 | // 流程前置通知 | 930 | // 流程前置通知 |
| 936 | BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService. | 931 | BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService. |
| 937 | getProcessDefinitionInfo(instance.getProcessDefinitionId()); | 932 | getProcessDefinitionInfo(instance.getProcessDefinitionId()); |
| 938 | - // TODO @lesan:if return 哈。减少括号。 | ||
| 939 | - if (ObjUtil.isNotNull(processDefinitionInfo) && | ||
| 940 | - ObjUtil.isNotNull(processDefinitionInfo.getPreProcessNotifySetting())) { | ||
| 941 | - BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getPreProcessNotifySetting(); | ||
| 942 | - BpmHttpRequestUtils.executeBpmHttpRequest(instance, | ||
| 943 | - setting.getUrl(), | ||
| 944 | - setting.getHeader(), | ||
| 945 | - setting.getBody(), | ||
| 946 | - true, setting.getResponse(), | ||
| 947 | - restTemplate, | ||
| 948 | - this); | 933 | + if (ObjUtil.isNull(processDefinitionInfo) || |
| 934 | + ObjUtil.isNull(processDefinitionInfo.getProcessBeforeTriggerSetting())) { | ||
| 935 | + return; | ||
| 949 | } | 936 | } |
| 937 | + BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getProcessBeforeTriggerSetting(); | ||
| 938 | + BpmHttpRequestUtils.executeBpmHttpRequest(instance, | ||
| 939 | + setting.getUrl(), | ||
| 940 | + setting.getHeader(), | ||
| 941 | + setting.getBody(), | ||
| 942 | + true, setting.getResponse()); | ||
| 950 | }); | 943 | }); |
| 951 | } | 944 | } |
| 952 | 945 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/listener/BpmUserTaskListener.java
| @@ -32,9 +32,6 @@ public class BpmUserTaskListener implements TaskListener { | @@ -32,9 +32,6 @@ public class BpmUserTaskListener implements TaskListener { | ||
| 32 | @Resource | 32 | @Resource |
| 33 | private BpmProcessInstanceService processInstanceService; | 33 | private BpmProcessInstanceService processInstanceService; |
| 34 | 34 | ||
| 35 | - @Resource | ||
| 36 | - private RestTemplate restTemplate; | ||
| 37 | - | ||
| 38 | @Setter | 35 | @Setter |
| 39 | private FixedValue listenerConfig; | 36 | private FixedValue listenerConfig; |
| 40 | 37 | ||
| @@ -58,9 +55,7 @@ public class BpmUserTaskListener implements TaskListener { | @@ -58,9 +55,7 @@ public class BpmUserTaskListener implements TaskListener { | ||
| 58 | listenerHandler.getPath(), | 55 | listenerHandler.getPath(), |
| 59 | listenerHandler.getHeader(), | 56 | listenerHandler.getHeader(), |
| 60 | listenerHandler.getBody(), | 57 | listenerHandler.getBody(), |
| 61 | - false, null, | ||
| 62 | - restTemplate, | ||
| 63 | - processInstanceService); | 58 | + false, null); |
| 64 | 59 | ||
| 65 | // 3. 是否需要后续操作?TODO 芋艿:待定! | 60 | // 3. 是否需要后续操作?TODO 芋艿:待定! |
| 66 | } | 61 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmHttpCallbackTrigger.java
| @@ -22,9 +22,6 @@ import org.springframework.web.client.RestTemplate; | @@ -22,9 +22,6 @@ import org.springframework.web.client.RestTemplate; | ||
| 22 | public class BpmHttpCallbackTrigger extends BpmAbstractHttpRequestTrigger { | 22 | public class BpmHttpCallbackTrigger extends BpmAbstractHttpRequestTrigger { |
| 23 | 23 | ||
| 24 | @Resource | 24 | @Resource |
| 25 | - private RestTemplate restTemplate; | ||
| 26 | - | ||
| 27 | - @Resource | ||
| 28 | private BpmProcessInstanceService processInstanceService; | 25 | private BpmProcessInstanceService processInstanceService; |
| 29 | 26 | ||
| 30 | @Override | 27 | @Override |
| @@ -51,9 +48,7 @@ public class BpmHttpCallbackTrigger extends BpmAbstractHttpRequestTrigger { | @@ -51,9 +48,7 @@ public class BpmHttpCallbackTrigger extends BpmAbstractHttpRequestTrigger { | ||
| 51 | setting.getUrl(), | 48 | setting.getUrl(), |
| 52 | setting.getHeader(), | 49 | setting.getHeader(), |
| 53 | setting.getBody(), | 50 | setting.getBody(), |
| 54 | - false, null, | ||
| 55 | - restTemplate, | ||
| 56 | - processInstanceService); | 51 | + false, null); |
| 57 | } | 52 | } |
| 58 | 53 | ||
| 59 | } | 54 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/http/BpmSyncHttpRequestTrigger.java
| @@ -21,9 +21,6 @@ import org.springframework.web.client.RestTemplate; | @@ -21,9 +21,6 @@ import org.springframework.web.client.RestTemplate; | ||
| 21 | public class BpmSyncHttpRequestTrigger extends BpmAbstractHttpRequestTrigger { | 21 | public class BpmSyncHttpRequestTrigger extends BpmAbstractHttpRequestTrigger { |
| 22 | 22 | ||
| 23 | @Resource | 23 | @Resource |
| 24 | - private RestTemplate restTemplate; | ||
| 25 | - | ||
| 26 | - @Resource | ||
| 27 | private BpmProcessInstanceService processInstanceService; | 24 | private BpmProcessInstanceService processInstanceService; |
| 28 | 25 | ||
| 29 | @Override | 26 | @Override |
| @@ -46,9 +43,7 @@ public class BpmSyncHttpRequestTrigger extends BpmAbstractHttpRequestTrigger { | @@ -46,9 +43,7 @@ public class BpmSyncHttpRequestTrigger extends BpmAbstractHttpRequestTrigger { | ||
| 46 | setting.getUrl(), | 43 | setting.getUrl(), |
| 47 | setting.getHeader(), | 44 | setting.getHeader(), |
| 48 | setting.getBody(), | 45 | setting.getBody(), |
| 49 | - true, setting.getResponse(), | ||
| 50 | - restTemplate, | ||
| 51 | - processInstanceService); | 46 | + true, setting.getResponse()); |
| 52 | } | 47 | } |
| 53 | 48 | ||
| 54 | } | 49 | } |