Merge branch 'dev' into test

test
wj 2 years ago
commit d22a9f388f

@ -1,15 +1,14 @@
package com.glxp.sale.admin.controller.sync; package com.glxp.sale.admin.controller.sync;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.glxp.sale.admin.constant.*; 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.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.SpGetHttp;
import com.glxp.sale.admin.http.SpPostHttp; import com.glxp.sale.admin.http.SpPostHttp;
import com.glxp.sale.admin.idc.utils.UriUtils; import com.glxp.sale.admin.idc.utils.UriUtils;
@ -257,7 +256,7 @@ public class SpsSyncDataController {
throw new RuntimeException("系统异常,文件名为空"); throw new RuntimeException("系统异常,文件名为空");
} }
relaySyncResponse = RelaySyncResponse.builder() relaySyncResponse = RelaySyncResponse.builder()
.taskId(one.getId()) .taskId(one.getTaskId())
.fileContent(this.readDataFile(one.getCacheFilePath())) .fileContent(this.readDataFile(one.getCacheFilePath()))
.build(); .build();
} }

@ -16,10 +16,6 @@ import com.glxp.sale.admin.idc.service.FileService;
import com.glxp.sale.common.res.BaseResponse; import com.glxp.sale.common.res.BaseResponse;
/** /**
* *
*/ */
@ -56,6 +52,4 @@ public class FileController {
} }
} }

@ -1,37 +1,37 @@
package com.glxp.sale.admin.idc.controller; package com.glxp.sale.admin.idc.controller;
import java.io.UnsupportedEncodingException; import cn.hutool.core.util.StrUtil;
import java.net.URLEncoder; import cn.hutool.http.HttpRequest;
import java.util.Enumeration; import cn.hutool.http.HttpResponse;
import java.util.HashMap; import cn.hutool.http.HttpUtil;
import java.util.Map;
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 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 com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glxp.sale.admin.idc.dao.DbDao; import com.glxp.sale.admin.idc.dao.DbDao;
import com.glxp.sale.admin.idc.service.IdcService; import com.glxp.sale.admin.idc.service.IdcService;
import com.glxp.sale.admin.idc.utils.UriUtils; import com.glxp.sale.admin.idc.utils.UriUtils;
import com.glxp.sale.admin.service.param.SystemParamConfigService; import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.util.MyStrUtil;
import com.glxp.sale.common.res.BaseResponse; import com.glxp.sale.common.res.BaseResponse;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; 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;
/** /**
@ -149,6 +149,7 @@ public class IdcController {
if (StrUtil.isNotEmpty(upperServerHost)) { if (StrUtil.isNotEmpty(upperServerHost)) {
uri = upperServerHost + "/" + uri; uri = upperServerHost + "/" + uri;
} }
uri = changeUri(uri);
log.info(uri); log.info(uri);
if (uri.contains("getImage")) { if (uri.contains("getImage")) {
return redirectIamge(request, httpServletResponse, uri); return redirectIamge(request, httpServletResponse, uri);
@ -157,6 +158,67 @@ 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")) {
if (uri.contains("SP_SYNC_SERVER")) {
uri = uri.replace("SP_SYNC_SERVER/", "");
}
} else {
uri = MyStrUtil.deDup(uri);
}
log.error("changeUri = " + uri);
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) { private byte[] redirectIamge(HttpServletRequest request, HttpServletResponse httpServletResponse, String uri) {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();

@ -221,7 +221,7 @@ public class FileServiceImpl implements FileService {
if(config!=null&&config.get("paramValue")!=null) if(config!=null&&config.get("paramValue")!=null)
host = config.get("paramValue").toString(); host = config.get("paramValue").toString();
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace();
} }
if(!StringUtils.isEmpty(host)) { if(!StringUtils.isEmpty(host)) {
String result = IDCUtils.post(host+"/spssync/file/downloadFile", params); String result = IDCUtils.post(host+"/spssync/file/downloadFile", params);

@ -8,7 +8,7 @@ import lombok.Getter;
@Getter @Getter
public enum ResultEnum { public enum ResultEnum {
SUCCESS(0, "success"), SUCCESS(20000, "success"),
NOT_NETWORK(1, "系统繁忙,请稍后再试。"), NOT_NETWORK(1, "系统繁忙,请稍后再试。"),
LOGIN_VERIFY_FALL(2, "登录失效"), LOGIN_VERIFY_FALL(2, "登录失效"),
PARAM_VERIFY_FALL(3, "参数验证错误"), PARAM_VERIFY_FALL(3, "参数验证错误"),

@ -18,7 +18,7 @@ public class ResultVOUtils {
*/ */
public static BaseResponse success(Object data) { public static BaseResponse success(Object data) {
BaseResponse<Object> baseResponse = new BaseResponse<>(); BaseResponse<Object> baseResponse = new BaseResponse<>();
baseResponse.setCode(20000); baseResponse.setCode(ResultEnum.SUCCESS.getCode());
baseResponse.setMessage("success"); baseResponse.setMessage("success");
baseResponse.setData(data); baseResponse.setData(data);
return baseResponse; return baseResponse;

Loading…
Cancel
Save