文件上传修改,路径修改

master
anthonywj 2 years ago
parent 4f7b490d88
commit 164c76858c

@ -16,9 +16,6 @@ import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.idc.service.FileService; import com.glxp.api.idc.service.FileService;
/** /**
* *
*/ */
@ -55,6 +52,4 @@ public class FileController {
} }
} }

@ -54,11 +54,13 @@ public class FileServiceImpl implements FileService {
@Resource @Resource
private IdcService idcService; private IdcService idcService;
private String imagePath = "register/file/image2/"; private String imagePath = "register/file/image2/";
String pdfPath = "pdf/template/";
@Override @Override
public BaseResponse upload(List<String> list) { public BaseResponse upload(List<String> list) {
return fileToUpload(list); return fileToUpload(list);
} }
@Override @Override
public BaseResponse download(List<String> list) { public BaseResponse download(List<String> list) {
return fileToDownload(list); return fileToDownload(list);
@ -95,21 +97,15 @@ public class FileServiceImpl implements FileService {
if (StringUtils.isEmpty(host)) if (StringUtils.isEmpty(host))
return ResultVOUtils.error(9999, "上传地址未配置,请至同步设置中进行设置"); return ResultVOUtils.error(9999, "上传地址未配置,请至同步设置中进行设置");
if (list != null) { if (list != null) {
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
ArrayList<String> files = new ArrayList<>(); ArrayList<String> files = new ArrayList<>();
boolean isExists = true; boolean isExists = true;
List<String> noExitsList = new ArrayList<>(); List<String> noExitsList = new ArrayList<>();
for (String strs : list) { for (String strs : list) {
String[] str = strs.split(","); if (!StringUtils.isEmpty(strs) && FileUtils.isFileExist(strs)) {
for(String s:str) { files.add(strs);
if (!StringUtils.isEmpty(s) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + s)) {
files.add(filePath + filePathSlash + imagePath + s);
} else { } else {
isExists = false; isExists = false;
noExitsList.add(s); noExitsList.add(strs);
}
} }
} }
if (!isExists) if (!isExists)
@ -124,7 +120,6 @@ public class FileServiceImpl implements FileService {
} }
@Override @Override
public BaseResponse fileDownload(HttpServletRequest request, Map<String, Object> params) { public BaseResponse fileDownload(HttpServletRequest request, Map<String, Object> params) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
@ -173,6 +168,8 @@ public class FileServiceImpl implements FileService {
boolean isRelay = false; boolean isRelay = false;
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/"; String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
String host = ""; String host = "";
try { try {
Map<String, Object> config = dbDao.get("select paramValue from system_param_config where paramKey='upper_server_ip'"); Map<String, Object> config = dbDao.get("select paramValue from system_param_config where paramKey='upper_server_ip'");
if (config != null && config.get("paramValue") != null) { if (config != null && config.get("paramValue") != null) {
@ -190,9 +187,15 @@ public class FileServiceImpl implements FileService {
IDCUtils.createDirectory(filePath + filePathSlash + imagePath); IDCUtils.createDirectory(filePath + filePathSlash + imagePath);
try { try {
for (MultipartFile file : files) { for (MultipartFile file : files) {
String imageName = filePath + filePathSlash + imagePath + file.getOriginalFilename(); String flodPath;
if (file.getName().contains(".jrxml") || file.getName().contains(".jasper")) {
flodPath = pdfPath;
} else {
flodPath = imagePath;
}
String imageName = filePath + filePathSlash + flodPath + file.getOriginalFilename();
saveFiles.add(imageName); saveFiles.add(imageName);
IDCUtils.writeFile(file.getBytes(), filePath + filePathSlash + imagePath, file.getOriginalFilename()); IDCUtils.writeFile(file.getBytes(), filePath + filePathSlash + flodPath, file.getOriginalFilename());
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block

@ -1023,7 +1023,27 @@ public class HeartService {
if (dataResponse != null) { if (dataResponse != null) {
dataResponse.setTaskId(taskId); dataResponse.setTaskId(taskId);
dataResponse.setType(BasicExportTypeEnum.SYS_SET_DATA.getRemark()); dataResponse.setType(BasicExportTypeEnum.SYS_SET_DATA.getRemark());
if (CollUtil.isNotEmpty(dataResponse.getSystemPDFTemplateEntities())) {
// List<Map<String, String>> list = new ArrayList<>(spsSyncSysSettingResponse.getSystemPDFTemplateEntities().size() * 2);
List<String> list = new ArrayList<>();
dataResponse.getSystemPDFTemplateEntities().forEach(systemPDFTemplateEntity -> {
list.add(systemPDFTemplateEntity.getPath());
});
BaseResponse<String> response = spGetHttp.postTemplateFile(list);
if (response.getCode() == 20000) {
log.info("模板文件列表上传成功");
// uploadFileLog = "\n模板文件列表上传成功";
} else {
log.info("模板文件上传失败,响应信息:{}", response.getMessage());
// uploadFileLog = "\n模板文件列表上传失败错误信息" + response.getMessage();
}
} }
}
return dataResponse; return dataResponse;
} }

Loading…
Cancel
Save