代码备份

test^2
anthonywj 2 years ago
parent c3de69dc95
commit f08a344c1c

@ -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<String, Object> params) {
return fileService.fileUpload(request,params);
return fileService.fileUpload(request, params);
}
@RequestMapping(value = "/spssync/file/download")
@ResponseBody
public BaseResponse download(HttpServletRequest request, @RequestBody Map<String, Object> params) {
return fileService.fileDownload(request,params);
return fileService.fileDownload(request, params);
}
@RequestMapping(value = "/spssync/file/downloadFile")
@ResponseBody
public BaseResponse downloadFile(HttpServletRequest request, @RequestBody Map<String, Object> 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);
}
}

@ -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<String,Object> params) {
Map<String, Object> 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<String> saveFiles = new ArrayList<>();
Date startTime = new Date();
@ -157,12 +157,12 @@ public class FileServiceImpl implements FileService {
}
return ResultVOUtils.success(null);
}
/*转发图片*/
private String relayFile(ArrayList<String> 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<String,Object> 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);
}
}
}

Loading…
Cancel
Save