|
@@ -19,42 +19,32 @@ public class sending<T> {
|
|
|
// 创建RestTemplate实例
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
|
- public ResponseEntity sendCommonPOST(String url, T param) {
|
|
|
+ public ResponseEntity sendCommonPOST(String url, String httpMethod, T param) {
|
|
|
// 得到当前用户的token 下发流程请求需要携带
|
|
|
String token = SecurityUtils.getLoginUser().getToken();
|
|
|
// 设置请求头
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.set("Authorization", "XIAFA" + token);
|
|
|
- // 构造请求体
|
|
|
- // Map<String, Object> requestBody = new HashMap<>();
|
|
|
// 将请求体和请求头添加到HttpEntity
|
|
|
HttpEntity<Map<String, Object>> requestEntity = (HttpEntity<Map<String, Object>>) new HttpEntity<>(param, headers);
|
|
|
- // 发送POST请求
|
|
|
- ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
|
|
|
- // 处理响应
|
|
|
+ // 发送请求
|
|
|
+ ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.resolve(httpMethod), requestEntity, String.class);
|
|
|
+ // 返回响应
|
|
|
return response;
|
|
|
-// if (response.getStatusCode().is2xxSuccessful()) {
|
|
|
-// String responseBody = response.getBody();
|
|
|
-// System.err.println("Response: " + responseBody);
|
|
|
-// return response;
|
|
|
-// } else {
|
|
|
-// return response.getStatusCode();
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 执行流程排产
|
|
|
*/
|
|
|
public ResponseEntity sendCommonUpdate(T param) {
|
|
|
- return this.sendCommonPOST(bpmProperties.formCommonUpdateIp, param);
|
|
|
+ return this.sendCommonPOST(bpmProperties.formCommonUpdateIp, "POST", param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据脚本key得到所有异常脚本信息
|
|
|
*/
|
|
|
public ResponseEntity sendGetScriptInfo(T param) {
|
|
|
- return this.sendCommonPOST(bpmProperties.getNodeScriptsIp, param);
|
|
|
+ return this.sendCommonPOST(bpmProperties.getNodeScriptsIp, "POST", param);
|
|
|
}
|
|
|
|
|
|
}
|