| @@ -18,5 +18,5 @@ public interface AimService { | |||||
| HashMap<String, Object> queryMetricsParams(String runId) throws Exception; | HashMap<String, Object> queryMetricsParams(String runId) throws Exception; | ||||
| List<Map<String, Object>> getBatchMetric(String runHash, String params); | |||||
| List<Map<String, Object>> getBatchMetric(String runHash, String body); | |||||
| } | } | ||||
| @@ -273,9 +273,9 @@ public class AimServiceImpl implements AimService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<Map<String, Object>> getBatchMetric(String runHash, String params) { | |||||
| public List<Map<String, Object>> getBatchMetric(String runHash, String body) { | |||||
| String url = aimUrl + "/api/runs/" + runHash + "/metric/get-batch"; | String url = aimUrl + "/api/runs/" + runHash + "/metric/get-batch"; | ||||
| String response = HttpUtils.sendPost(url, params); | |||||
| String response = HttpUtils.sendPost(url, null, body); | |||||
| if (StringUtils.isNotEmpty(response)) { | if (StringUtils.isNotEmpty(response)) { | ||||
| return JacksonUtil.parseJSONStr2MapList(response); | return JacksonUtil.parseJSONStr2MapList(response); | ||||
| } | } | ||||
| @@ -7,6 +7,7 @@ import com.ruoyi.platform.domain.Workflow; | |||||
| import com.ruoyi.platform.mapper.WorkflowDao; | import com.ruoyi.platform.mapper.WorkflowDao; | ||||
| import com.ruoyi.platform.service.ExperimentService; | import com.ruoyi.platform.service.ExperimentService; | ||||
| import com.ruoyi.platform.service.WorkflowService; | import com.ruoyi.platform.service.WorkflowService; | ||||
| import com.ruoyi.platform.utils.HttpUtils; | |||||
| import com.ruoyi.platform.utils.JsonUtils; | import com.ruoyi.platform.utils.JsonUtils; | ||||
| import com.ruoyi.platform.utils.MinioUtil; | import com.ruoyi.platform.utils.MinioUtil; | ||||
| import com.ruoyi.platform.utils.NewHttpUtils; | import com.ruoyi.platform.utils.NewHttpUtils; | ||||
| @@ -172,7 +173,7 @@ public class WorkflowServiceImpl implements WorkflowService { | |||||
| Map<String,Object> requestData = new HashMap<>(); | Map<String,Object> requestData = new HashMap<>(); | ||||
| requestData.put("data", oldDag); | requestData.put("data", oldDag); | ||||
| // 发送POST请求到Argo工作流复制接口,并将请求数据转换为JSON | // 发送POST请求到Argo工作流复制接口,并将请求数据转换为JSON | ||||
| String req = httpUtils.sendPost(argoUrl + argoWorkflowCopy,null , JsonUtils.mapToJson(requestData)); | |||||
| String req = HttpUtils.sendPost(argoUrl + argoWorkflowCopy ,null, JsonUtils.mapToJson(requestData)); | |||||
| // 检查响应是否为空或无内容 | // 检查响应是否为空或无内容 | ||||
| if (StringUtils.isEmpty(req)) { | if (StringUtils.isEmpty(req)) { | ||||
| throw new RuntimeException("工作流复制接口响应内容为空"); | throw new RuntimeException("工作流复制接口响应内容为空"); | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.ruoyi.platform.utils; | package com.ruoyi.platform.utils; | ||||
| import cn.hutool.http.HttpRequest; | |||||
| import com.ruoyi.common.core.utils.StringUtils; | import com.ruoyi.common.core.utils.StringUtils; | ||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.http.HttpEntity; | import org.apache.http.HttpEntity; | ||||
| @@ -305,9 +306,9 @@ public class HttpUtils { | |||||
| conn.setRequestProperty("contentType", "utf-8"); | conn.setRequestProperty("contentType", "utf-8"); | ||||
| conn.setDoOutput(true); | conn.setDoOutput(true); | ||||
| conn.setDoInput(true); | conn.setDoInput(true); | ||||
| out = new PrintWriter(conn.getOutputStream()); | |||||
| out.print(param); | |||||
| out.flush(); | |||||
| out = new PrintWriter(conn.getOutputStream()); | |||||
| out.print(param); | |||||
| out.flush(); | |||||
| in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); | in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); | ||||
| String line; | String line; | ||||
| while ((line = in.readLine()) != null) { | while ((line = in.readLine()) != null) { | ||||
| @@ -337,6 +338,19 @@ public class HttpUtils { | |||||
| return result.toString(); | return result.toString(); | ||||
| } | } | ||||
| public static String sendPost(String url, String param, String body){ | |||||
| String urlNameString = url; | |||||
| if (StringUtils.isNotEmpty(param)) { | |||||
| urlNameString = url + "?" + param; | |||||
| } | |||||
| String response = HttpRequest.post(urlNameString) | |||||
| .body(body) // 设置请求体 | |||||
| .contentType("application/json") // 设置Content-Type | |||||
| .execute() | |||||
| .body(); | |||||
| return response; | |||||
| } | |||||
| public static String sendSSLPost(String url, String param) { | public static String sendSSLPost(String url, String param) { | ||||
| StringBuilder result = new StringBuilder(); | StringBuilder result = new StringBuilder(); | ||||
| String urlNameString = url + "?" + param; | String urlNameString = url + "?" + param; | ||||