From 12a956874c8e7eefaf21f9982e428c577eaffe61 Mon Sep 17 00:00:00 2001 From: chengqf <584883665@139.com> Date: Sat, 8 Apr 2023 22:50:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idc/service/impl/IdcServiceImpl.java | 28 ++------------- .../glxp/sale/admin/idc/utils/IDCUtils.java | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/IdcServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/IdcServiceImpl.java index afffe9c..e4fbcc6 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/IdcServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/IdcServiceImpl.java @@ -167,7 +167,7 @@ public class IdcServiceImpl implements IdcService { } logger.info("fetch from ip:" + host); if (!StringUtils.isEmpty(host)) { - String result = post(host + "/spssync/common/list", null); + String result = IDCUtils.post(host + "/spssync/common/list", null); if (IDCUtils.isJson(result)) { JSONObject json = JSON.parseObject(result); @@ -306,7 +306,7 @@ public class IdcServiceImpl implements IdcService { } if (success) { - String ret = post(host + "/spssync/common/success", params); + String ret = IDCUtils.post(host + "/spssync/common/success", params); } @@ -318,29 +318,7 @@ public class IdcServiceImpl implements IdcService { return result; } - private String post(String url, Map params) { - OkHttpClient client = new OkHttpClient().newBuilder() - .build(); - MediaType mediaType = MediaType.parse("application/json"); - RequestBody body = RequestBody.create(mediaType, ""); - if (params != null) - body = RequestBody.create(mediaType, JSON.toJSONString(params)); - Request request = new Request.Builder() - .url(url) - .method("POST", body) - .addHeader("Content-Type", "application/json") - .build(); - String result = ""; - try { - Response response = client.newCall(request).execute(); - result = response.body().string(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return result; - } - + public BaseResponse downlaodSuccess(HttpServletRequest request, Map params) { String sql = "update basic_export_status set receiveStatus='1',endTime=now() where id='" + params.get("taskId") + "'"; diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/utils/IDCUtils.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/utils/IDCUtils.java index ff3f781..c127629 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/utils/IDCUtils.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/utils/IDCUtils.java @@ -1,14 +1,24 @@ package com.glxp.sale.admin.idc.utils; import java.io.File; +import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.alibaba.fastjson.JSON; + +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + @@ -130,4 +140,28 @@ public class IDCUtils { } } + + + public static String post(String url, Map params) { + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType, ""); + if (params != null) + body = RequestBody.create(mediaType, JSON.toJSONString(params)); + Request request = new Request.Builder() + .url(url) + .method("POST", body) + .addHeader("Content-Type", "application/json") + .build(); + String result = ""; + try { + Response response = client.newCall(request).execute(); + result = response.body().string(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return result; + } }