From 21c2df58bdaf8c8b2749285c60fce815d8ccdb90 Mon Sep 17 00:00:00 2001 From: wj <1285151836@qq.com> Date: Fri, 21 Apr 2023 16:45:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B1=E5=86=85=E5=90=91=E5=A4=96=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/sync/SpsSyncDataController.java | 12 +++++++----- .../java/com/glxp/sale/admin/idc/utils/UriUtils.java | 1 + 2 files changed, 8 insertions(+), 5 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 df413d3..69f1652 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,6 +1,7 @@ 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.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -301,27 +302,28 @@ public class SpsSyncDataController { } @PostMapping("sps/sync/upload/data") - public Object uploadData(HttpServletRequest request, @RequestBody SyncUpLoadRequest upLoadRequest) { + public Object uploadData(HttpServletRequest request) { String uri = uriUtils.parseUri(request.getRequestURL().toString()); String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_ip"); if (StrUtil.isNotEmpty(upperServerHost)) { uri = upperServerHost + "/" + uri; } - JSONObject jsonObject = redirect(request, uri, upLoadRequest.getExportType()); + JSONObject jsonObject = redirect(request, uri); return jsonObject; } - private JSONObject redirect(HttpServletRequest request, String uri, BasicExportTypeEnum exportType) { + private JSONObject redirect(HttpServletRequest request, String uri) { RestTemplate restTemplate = new RestTemplate(); HttpEntity httpEntity = uriUtils.buildHeader(request); String taskId = request.getHeader("taskId"); ResponseEntity responseBody = null; + SyncUpLoadRequest bean = JSONUtil.toBean(httpEntity.getBody(), SyncUpLoadRequest.class); if (request.getMethod().equals("POST")) { //写入日志 - writeUploadLog(taskId, httpEntity.getBody(), exportType); + writeUploadLog(taskId, httpEntity.getBody(), bean.getExportType()); responseBody = restTemplate.postForEntity(uri, httpEntity, JSONObject.class); } else if (request.getMethod().equals("GET")) { - writeUploadLog(taskId, httpEntity.getBody(), exportType); + writeUploadLog(taskId, httpEntity.getBody(), bean.getExportType()); responseBody = restTemplate.exchange(uri, HttpMethod.GET, httpEntity, JSONObject.class); } JSONObject result = responseBody.getBody(); diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/utils/UriUtils.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/utils/UriUtils.java index a03361e..4adcfa9 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/utils/UriUtils.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/utils/UriUtils.java @@ -58,6 +58,7 @@ public class UriUtils { log.info(bodyContent); } catch (IOException e) { e.printStackTrace(); + throw new RuntimeException(e.getMessage()); } } HttpHeaders headers = new HttpHeaders();