From 6569dcc49c5c22e18f5f8cc389b08e4eda14b4ac Mon Sep 17 00:00:00 2001 From: anthonywj Date: Tue, 9 May 2023 15:01:56 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=A4=96=E7=BD=91=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sale/admin/idc/controller/IdcController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java index 6cf93fa..f80e0dc 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java @@ -10,6 +10,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.glxp.sale.admin.util.MyStrUtil; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -149,6 +150,7 @@ public class IdcController { if (StrUtil.isNotEmpty(upperServerHost)) { uri = upperServerHost + "/" + uri; } + uri = changeUri(uri); log.info(uri); if (uri.contains("getImage")) { return redirectIamge(request, httpServletResponse, uri); @@ -157,6 +159,18 @@ public class IdcController { } } + public String changeUri(String uri) { + String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service"); + if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) { + if (uri.contains("SP_SYNC_SERVER")) { + uri = uri.replace("SP_SYNC_SERVER/", ""); + } + } else { + uri = MyStrUtil.deDup(uri); + } + log.error("changeUri = " + uri); + return uri; + } private byte[] redirectIamge(HttpServletRequest request, HttpServletResponse httpServletResponse, String uri) { RestTemplate restTemplate = new RestTemplate(); From c3de69dc956dc9c8c39b050cbc957abe0a51931b Mon Sep 17 00:00:00 2001 From: wj <1285151836@qq.com> Date: Fri, 12 May 2023 16:25:29 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=BD=AC=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/idc/controller/IdcController.java | 98 ++++++++++++++----- 1 file changed, 73 insertions(+), 25 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java index f80e0dc..7994ed9 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java @@ -1,38 +1,37 @@ package com.glxp.sale.admin.idc.controller; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.glxp.sale.admin.util.MyStrUtil; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.multipart.MultipartFile; - +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.glxp.sale.admin.idc.dao.DbDao; import com.glxp.sale.admin.idc.service.IdcService; import com.glxp.sale.admin.idc.utils.UriUtils; import com.glxp.sale.admin.service.param.SystemParamConfigService; +import com.glxp.sale.admin.util.MyStrUtil; import com.glxp.sale.common.res.BaseResponse; - -import cn.hutool.core.util.StrUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; /** @@ -159,6 +158,24 @@ public class IdcController { } } +// @RequestMapping("/dirImages/**") +// public void images(HttpServletRequest request, HttpServletResponse httpServletResponse) { +// String uri = uriUtils.parseUri(request.getRequestURL().toString()); +// +// log.info(uri); +// String imageHost = "http://192.168.0.66:9000"; +// String url = ""; +//// systemParamConfigService.selectValueByParamKey("is_top_service"); +// if (StrUtil.isNotEmpty(imageHost)) { +// String prefix = "dirImages/"; +// url = (imageHost.substring(imageHost.length() - 1) == "/" ? imageHost : imageHost + "/") +// + uri.substring(uri.indexOf(prefix) + prefix.length()); +// +// } +// log.info(url); +// redirectIamge2(request, httpServletResponse, url); +// } + public String changeUri(String uri) { String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service"); if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) { @@ -172,6 +189,37 @@ public class IdcController { return uri; } + private void redirectIamge2(HttpServletRequest request, HttpServletResponse httpServletResponse, String uri) { + HttpRequest result = HttpUtil.createGet(uri); + HttpResponse execute = result.execute(); + execute.headers().forEach((k, v) -> { + httpServletResponse.setHeader(k, v.get(0)); + }); + ServletOutputStream outputStream = null; + InputStream inputStream = null; + try { + outputStream = httpServletResponse.getOutputStream(); + inputStream = execute.bodyStream(); + outputStream.write(inputStream.readAllBytes()); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (outputStream != null) + outputStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + if (inputStream != null) + inputStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + } + private byte[] redirectIamge(HttpServletRequest request, HttpServletResponse httpServletResponse, String uri) { RestTemplate restTemplate = new RestTemplate(); // HttpEntity httpEntity = buildHeader(request); From f08a344c1c080a94d4817414461678d63de2b805 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Tue, 16 May 2023 09:06:27 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/idc/controller/FileController.java | 22 ++++------ .../idc/service/impl/FileServiceImpl.java | 44 +++++++++---------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/FileController.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/FileController.java index 2be613c..00dcc56 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/FileController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/FileController.java @@ -16,10 +16,6 @@ import com.glxp.sale.admin.idc.service.FileService; import com.glxp.sale.common.res.BaseResponse; - - - - /** * 中继服务接口 */ @@ -32,30 +28,28 @@ public class FileController { @RequestMapping(value = "/spssync/file/upload") @ResponseBody public BaseResponse upload(HttpServletRequest request, @RequestBody Map params) { - return fileService.fileUpload(request,params); + return fileService.fileUpload(request, params); } - + @RequestMapping(value = "/spssync/file/download") @ResponseBody public BaseResponse download(HttpServletRequest request, @RequestBody Map params) { - return fileService.fileDownload(request,params); + return fileService.fileDownload(request, params); } - + @RequestMapping(value = "/spssync/file/downloadFile") @ResponseBody public BaseResponse downloadFile(HttpServletRequest request, @RequestBody Map params) { - return fileService.downloadFile(request,params); + return fileService.downloadFile(request, params); } - + @RequestMapping(value = "/spssync/file/uploadFile") public BaseResponse uploadFile(HttpServletRequest request, - @RequestParam(value = "content" , required = false) String content, - @RequestParam(value = "files", required = false) MultipartFile[] files) { + @RequestParam(value = "content", required = false) String content, + @RequestParam(value = "files", required = false) MultipartFile[] files) { // return fileService.receiveFile(request, content, files); } - - } diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/FileServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/FileServiceImpl.java index 74bebd4..bdc492e 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/FileServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/service/impl/FileServiceImpl.java @@ -46,7 +46,7 @@ public class FileServiceImpl implements FileService { private String apiKey; @Value("${API_SECRET}") private String apiSecret; - + @Resource private DbDao dbDao; @Resource @@ -60,7 +60,7 @@ public class FileServiceImpl implements FileService { if(map!=null&&map.get("syncIp")!=null) host = map.get("syncIp").toString(); } catch (Exception ex) { - + } if(StringUtils.isEmpty(host)) { try { @@ -68,7 +68,7 @@ public class FileServiceImpl implements FileService { if(config!=null&&config.get("paramValue")!=null) host = config.get("paramValue").toString(); } catch (Exception ex) { - + } } if(StringUtils.isEmpty(host)) @@ -96,9 +96,9 @@ public class FileServiceImpl implements FileService { } return ResultVOUtils.error(9999,"失败"); } - - - + + + @Override public BaseResponse fileDownload(HttpServletRequest request,Map params) { Map map = dbDao.get("select * from sync_data_set limit 1"); @@ -109,7 +109,7 @@ public class FileServiceImpl implements FileService { } return ResultVOUtils.success(null); } - + @Override public BaseResponse receiveFile(HttpServletRequest request,String content,MultipartFile[] files) { boolean isRelay = false; @@ -121,9 +121,9 @@ public class FileServiceImpl implements FileService { isRelay = true; host = config.get("paramValue").toString(); } - + } catch (Exception ex) { - + } ArrayList saveFiles = new ArrayList<>(); Date startTime = new Date(); @@ -157,12 +157,12 @@ public class FileServiceImpl implements FileService { } return ResultVOUtils.success(null); } - + /*转发图片*/ private String relayFile(ArrayList files, String ip) { String host = ip; String result = ""; - + if (!StringUtils.isEmpty(host)) { host += "/spssync/file/uploadFile"; OkHttpClient client = new OkHttpClient().newBuilder() @@ -185,7 +185,7 @@ public class FileServiceImpl implements FileService { } } } - + RequestBody body = builder.build(); Request req = new Request.Builder() @@ -211,8 +211,8 @@ public class FileServiceImpl implements FileService { } return result; } - - + + @Override public BaseResponse downloadFile(HttpServletRequest request,Map params) { String host = ""; @@ -221,11 +221,11 @@ public class FileServiceImpl implements FileService { if(config!=null&&config.get("paramValue")!=null) host = config.get("paramValue").toString(); } catch (Exception ex) { - + ex.printStackTrace(); } if(!StringUtils.isEmpty(host)) { - String result = IDCUtils.post(host+"/spssync/file/downloadFile", params); - + String result = IDCUtils.post(host+"/spssync/file/downloadFile", params); + JSONObject object = JSON.parseObject(result); boolean success = false; if(object.getInteger("code")==20000) { @@ -237,10 +237,10 @@ public class FileServiceImpl implements FileService { } } if(!success) - ResultVOUtils.error(9999,"失败"); - + ResultVOUtils.error(9999,"失败"); + } - return ResultVOUtils.success(null); + return ResultVOUtils.success(null); } - -} \ No newline at end of file + +} From 6ad32b2933fac5dbfe2b5ee11ab1641351f2d39e Mon Sep 17 00:00:00 2001 From: wj <1285151836@qq.com> Date: Wed, 17 May 2023 16:29:36 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=93=8D=E5=BA=94=E7=A0=81=E6=94=B9?= =?UTF-8?q?=E4=B8=BA20000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/glxp/sale/common/enums/ResultEnum.java | 2 +- .../src/main/java/com/glxp/sale/common/util/ResultVOUtils.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api-common/src/main/java/com/glxp/sale/common/enums/ResultEnum.java b/api-common/src/main/java/com/glxp/sale/common/enums/ResultEnum.java index 0fed18d..8fc34c8 100644 --- a/api-common/src/main/java/com/glxp/sale/common/enums/ResultEnum.java +++ b/api-common/src/main/java/com/glxp/sale/common/enums/ResultEnum.java @@ -8,7 +8,7 @@ import lombok.Getter; @Getter public enum ResultEnum { - SUCCESS(0, "success"), + SUCCESS(20000, "success"), NOT_NETWORK(1, "系统繁忙,请稍后再试。"), LOGIN_VERIFY_FALL(2, "登录失效"), PARAM_VERIFY_FALL(3, "参数验证错误"), diff --git a/api-common/src/main/java/com/glxp/sale/common/util/ResultVOUtils.java b/api-common/src/main/java/com/glxp/sale/common/util/ResultVOUtils.java index 7702da5..20368a6 100644 --- a/api-common/src/main/java/com/glxp/sale/common/util/ResultVOUtils.java +++ b/api-common/src/main/java/com/glxp/sale/common/util/ResultVOUtils.java @@ -18,7 +18,7 @@ public class ResultVOUtils { */ public static BaseResponse success(Object data) { BaseResponse baseResponse = new BaseResponse<>(); - baseResponse.setCode(20000); + baseResponse.setCode(ResultEnum.SUCCESS.getCode()); baseResponse.setMessage("success"); baseResponse.setData(data); return baseResponse; From 2314e8076b533071b3e6ea8d56dd6458d69c6017 Mon Sep 17 00:00:00 2001 From: wj <1285151836@qq.com> Date: Wed, 17 May 2023 17:42:49 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=94=B9=E4=B8=BAtaskId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sale/admin/controller/sync/SpsSyncDataController.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java index 0142a40..2d270d4 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java @@ -1,15 +1,14 @@ package com.glxp.sale.admin.controller.sync; import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.glxp.sale.admin.constant.*; -import com.glxp.sale.admin.dto.RelaySyncDto; import com.glxp.sale.admin.entity.param.SystemParamConfigEntity; -import com.glxp.sale.admin.entity.sync.*; +import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity; +import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity; import com.glxp.sale.admin.http.SpGetHttp; import com.glxp.sale.admin.http.SpPostHttp; import com.glxp.sale.admin.idc.utils.UriUtils; @@ -257,7 +256,7 @@ public class SpsSyncDataController { throw new RuntimeException("系统异常,文件名为空"); } relaySyncResponse = RelaySyncResponse.builder() - .taskId(one.getId()) + .taskId(one.getTaskId()) .fileContent(this.readDataFile(one.getCacheFilePath())) .build(); }