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 acd78d1..2b0c7c9 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 @@ -2,24 +2,38 @@ package com.glxp.sale.admin.idc.controller; import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.StrUtil; +import com.glxp.sale.admin.idc.service.DownloadRestTemplate; +import com.glxp.sale.admin.service.param.SystemParamConfigService; +import lombok.extern.slf4j.Slf4j; +import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.*; +import org.springframework.http.client.ClientHttpRequest; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; 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.RequestCallback; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; @@ -29,9 +43,6 @@ import com.glxp.sale.admin.idc.dao.DbDao; import com.glxp.sale.admin.idc.service.IdcService; import com.glxp.sale.common.res.BaseResponse; -import cn.hutool.core.io.IoUtil; -import lombok.extern.slf4j.Slf4j; - /** * 中继服务接口 @@ -54,7 +65,7 @@ public class IdcController { return idcService.receive( request, content, files); } - + //@Log("数据同步测试") @RequestMapping(value = "/spssync/common/test") public BaseResponse test(HttpServletRequest request, @RequestBody Map params) { @@ -86,6 +97,16 @@ public class IdcController { public Object mapi(HttpServletRequest request, HttpServletResponse httpServletResponse) { String uri = parseUri(request.getRequestURL().toString()); + log.info(uri); + String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service"); + if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) { + uri = uri.replace("mapi/", ""); + } + String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_host"); + if (StrUtil.isNotEmpty(upperServerHost)) { + uri = upperServerHost + "/" + uri; + } + log.info(uri); if (uri.contains("getImage")) { return redirectIamge(request, httpServletResponse, uri); } else { @@ -137,8 +158,6 @@ public class IdcController { } private byte[] redirectIamge(HttpServletRequest request, HttpServletResponse httpServletResponse, String uri) { - uri = uri.replace("mapi/", ""); - uri = "http://116.204.106.103:9150/UDI_SPMS_SERVER/" + uri; RestTemplate restTemplate = new RestTemplate(); // HttpEntity httpEntity = buildHeader(request); log.info(request.getMethod()); @@ -185,14 +204,15 @@ public class IdcController { } + @Resource + SystemParamConfigService systemParamConfigService; + + private JSONObject redirect(HttpServletRequest request, String uri) { RestTemplate restTemplate = new RestTemplate(); HttpEntity httpEntity = buildHeader(request); - log.info(uri); - uri = uri.replace("mapi/", ""); - uri = "http://116.204.106.103:9150/UDI_SPMS_SERVER/" + uri; - log.info(uri); + ResponseEntity responseBody = null; if (request.getMethod().equals("POST")) responseBody = restTemplate.postForEntity(uri, httpEntity, JSONObject.class); diff --git a/api-admin/src/main/resources/schemas/schema_v2.1.sql b/api-admin/src/main/resources/schemas/schema_v2.1.sql index 60b29ec..f7ee5c5 100644 --- a/api-admin/src/main/resources/schemas/schema_v2.1.sql +++ b/api-admin/src/main/resources/schemas/schema_v2.1.sql @@ -1 +1,7 @@ -CALL Pro_Temp_ColumnWork ('basic_export_status','receiveStatus','varchar(255) ', 1); \ No newline at end of file +CALL Pro_Temp_ColumnWork('basic_export_status', 'receiveStatus', 'varchar(255) ', 1); + + + +INSERT ignore INTO `system_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`, + `paramType`, `paramExplain`) +VALUES (516, NULL, '是否顶级中继服务', 'is_top_service', '1', 1, 0, '0:否,1:是');