|
@@ -109,16 +109,11 @@ public class FileServiceImpl implements FileService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String upload(final String userName, String fileType, final MultipartFile file) {
|
|
public String upload(final String userName, String fileType, final MultipartFile file) {
|
|
|
- String message = "";
|
|
|
|
|
if (StringUtils.isEmpty(userName)) {
|
|
if (StringUtils.isEmpty(userName)) {
|
|
|
- message = "未传入当前账套名称!";
|
|
|
|
|
- logger.error(message);
|
|
|
|
|
- return message;
|
|
|
|
|
|
|
+ return "未传入当前账套名称!";
|
|
|
}
|
|
}
|
|
|
if (file == null) {
|
|
if (file == null) {
|
|
|
- message = "文件为空,无法进行上传!";
|
|
|
|
|
- logger.error(message);
|
|
|
|
|
- return message;
|
|
|
|
|
|
|
+ return "文件为空,无法进行上传!";
|
|
|
}
|
|
}
|
|
|
if (StringUtils.isEmpty(fileType)) {
|
|
if (StringUtils.isEmpty(fileType)) {
|
|
|
fileType = "jrxml";
|
|
fileType = "jrxml";
|
|
@@ -126,8 +121,6 @@ public class FileServiceImpl implements FileService {
|
|
|
|
|
|
|
|
// 如果上传的是模板zip包,直接获取字节数据,将其解压到相应的账套下
|
|
// 如果上传的是模板zip包,直接获取字节数据,将其解压到相应的账套下
|
|
|
if (fileType.equals("zip")) {
|
|
if (fileType.equals("zip")) {
|
|
|
- message = "文件上传成功";
|
|
|
|
|
- logger.info(message);
|
|
|
|
|
new Thread(new Runnable() {
|
|
new Thread(new Runnable() {
|
|
|
@Override
|
|
@Override
|
|
|
public void run() {
|
|
public void run() {
|
|
@@ -138,7 +131,7 @@ public class FileServiceImpl implements FileService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}).start();
|
|
}).start();
|
|
|
- return message;
|
|
|
|
|
|
|
+ return "文件上传成功";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String fileName = file.getOriginalFilename();
|
|
String fileName = file.getOriginalFilename();
|
|
@@ -162,24 +155,17 @@ public class FileServiceImpl implements FileService {
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
file.transferTo(targetFile);
|
|
file.transferTo(targetFile);
|
|
|
- message = "成功上传文件至:" + targetFile.getPath();
|
|
|
|
|
- logger.info(message);
|
|
|
|
|
- return message;
|
|
|
|
|
|
|
+ return "成功上传文件至:" + targetFile.getPath();
|
|
|
} catch (IllegalStateException | IOException e) {
|
|
} catch (IllegalStateException | IOException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- message = "文件上传失败: " + fileName;
|
|
|
|
|
- logger.error(message);
|
|
|
|
|
- return message;
|
|
|
|
|
|
|
+ return "文件上传失败: " + fileName;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String upload(String filePath, Boolean isAbsolutePath, MultipartFile[] files) {
|
|
public String upload(String filePath, Boolean isAbsolutePath, MultipartFile[] files) {
|
|
|
- String message = "";
|
|
|
|
|
if (ArrayUtils.isEmpty(files)) {
|
|
if (ArrayUtils.isEmpty(files)) {
|
|
|
- message = "文件为空,无法进行上传!";
|
|
|
|
|
- logger.error(message);
|
|
|
|
|
- return message;
|
|
|
|
|
|
|
+ return "文件为空,无法进行上传!";
|
|
|
}
|
|
}
|
|
|
filePath = getAbsolutePath(filePath, isAbsolutePath);
|
|
filePath = getAbsolutePath(filePath, isAbsolutePath);
|
|
|
File targetFile = new File(filePath + "/" + files[0].getOriginalFilename());
|
|
File targetFile = new File(filePath + "/" + files[0].getOriginalFilename());
|
|
@@ -187,18 +173,20 @@ public class FileServiceImpl implements FileService {
|
|
|
if (!targetFile.getParentFile().exists()) {
|
|
if (!targetFile.getParentFile().exists()) {
|
|
|
targetFile.getParentFile().mkdirs();
|
|
targetFile.getParentFile().mkdirs();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
for (MultipartFile file : files) {
|
|
for (MultipartFile file : files) {
|
|
|
targetFile = new File(targetFile.getParent() + "/" + file.getOriginalFilename());
|
|
targetFile = new File(targetFile.getParent() + "/" + file.getOriginalFilename());
|
|
|
try {
|
|
try {
|
|
|
file.transferTo(targetFile);
|
|
file.transferTo(targetFile);
|
|
|
- message += "成功上传文件至:" + targetFile.getPath() + "\n";
|
|
|
|
|
|
|
+ stringBuilder.append("成功上传文件至:");
|
|
|
} catch (IllegalStateException | IOException e) {
|
|
} catch (IllegalStateException | IOException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- message += "上传文件失败: " + targetFile.getPath() + "\n";
|
|
|
|
|
|
|
+ stringBuilder.append("上传文件失败:");
|
|
|
}
|
|
}
|
|
|
|
|
+ stringBuilder.append(targetFile.getPath()).append("\n");
|
|
|
}
|
|
}
|
|
|
- logger.info(message);
|
|
|
|
|
- return message;
|
|
|
|
|
|
|
+ return stringBuilder.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|