|
@@ -110,6 +110,9 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
|
|
|
StringJoiner stringJoiner = new StringJoiner("");
|
|
|
stringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
|
|
|
List<String> trailUrlsList = tSyncExamStudentScore.getTrailUrls();
|
|
|
+
|
|
|
+ String hostUrl = SystemConstant.getLocalFileHost(dictionaryConfig.sysDomain().getFileHost());
|
|
|
+
|
|
|
if (Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls())) {
|
|
|
JSONArray jsonArray = JSONArray.parseArray(tSyncExamStudentScore.getSheetUrls());
|
|
|
JSONObject syncDataJson = JSONObject.parseObject(tSyncExamStudentScore.getSyncData());
|
|
@@ -130,7 +133,7 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
|
|
|
continue;
|
|
|
}
|
|
|
String url = (String) jsonArray.get(i);
|
|
|
- String format = url.substring(url.lastIndexOf("."), url.length());
|
|
|
+ String sheetName = url.substring(url.lastIndexOf("/"));
|
|
|
LocalDateTime nowTime = LocalDateTime.now();
|
|
|
StringJoiner dirJpgName = new StringJoiner("");
|
|
|
dirJpgName.add(UploadFileEnum.FILE.getTitle()).add(File.separator)
|
|
@@ -139,7 +142,7 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
|
|
|
.add(String.format("%02d", nowTime.getDayOfMonth()))
|
|
|
.add(File.separator)
|
|
|
.add(tSyncExamStudentScore.getExamNumber())
|
|
|
- .add(File.separator).add(SystemConstant.getUuid()).add(format);
|
|
|
+ .add(File.separator).add("sheet").add(File.separator).add(sheetName);
|
|
|
File fileSource = new File(stringJoiner.toString() + dirJpgName.toString());
|
|
|
if (!fileSource.exists()) {
|
|
|
fileSource.getParentFile().mkdirs();
|
|
@@ -155,7 +158,7 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
|
|
|
.add(String.format("%02d", nowTime.getDayOfMonth()))
|
|
|
.add(File.separator)
|
|
|
.add(tSyncExamStudentScore.getExamNumber())
|
|
|
- .add(File.separator).add(SystemConstant.getUuid()).add(format);
|
|
|
+ .add(File.separator).add("trail").add(File.separator).add(sheetName);
|
|
|
File fileTarget = new File(stringJoiner.toString() + dirTargetJpgName.toString());
|
|
|
if (!fileTarget.exists()) {
|
|
|
fileTarget.getParentFile().mkdirs();
|
|
@@ -171,7 +174,14 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
|
|
|
}
|
|
|
} else {
|
|
|
if (imageTrajectoryEnum == ImageTrajectoryEnum.PREVIEW) {
|
|
|
- trailUrlsList.add(fileTarget.getPath());
|
|
|
+ String filePath = fileTarget.getPath();
|
|
|
+ String trailUrl;
|
|
|
+ if (filePath.startsWith("/")) {
|
|
|
+ trailUrl = hostUrl + filePath;
|
|
|
+ } else {
|
|
|
+ trailUrl = hostUrl + File.separator + filePath;
|
|
|
+ }
|
|
|
+ trailUrlsList.add(trailUrl);
|
|
|
}
|
|
|
}
|
|
|
jsonImageTrajectoryPathArray.add(dirTargetJpgName.toString());
|
|
@@ -201,7 +211,6 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
|
|
|
if (imageTrajectoryEnum == ImageTrajectoryEnum.DOWNLOAD) {
|
|
|
fileTargetList.add(new File(stringJoiner.toString() + url));
|
|
|
} else {
|
|
|
- String hostUrl = SystemConstant.getLocalFileHost(dictionaryConfig.sysDomain().getFileHost());
|
|
|
String trailUrl;
|
|
|
String filePath = stringJoiner + url;
|
|
|
if (filePath.startsWith("/")) {
|
|
@@ -262,24 +271,23 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
|
|
|
zipFile.getParentFile().mkdirs();
|
|
|
zipFile.createNewFile();
|
|
|
}
|
|
|
- File[] files = tSyncExamStudentScore.getTrajectoryFileList().get(0).getParentFile().listFiles();
|
|
|
- if(files == null || files.length == 0){
|
|
|
+
|
|
|
+ List<File> fileList = tSyncExamStudentScore.getTrajectoryFileList();
|
|
|
+ if(fileList.isEmpty()){
|
|
|
throw ExceptionResultEnum.ERROR.exception("没有可下载文件");
|
|
|
}
|
|
|
- List<File> fileList = new ArrayList<>(Arrays.asList(files));
|
|
|
- fileList.removeAll(tSyncExamStudentScore.getTrajectoryFileList());
|
|
|
+
|
|
|
+ FileUtil.doZip(zipFile, fileList);
|
|
|
+
|
|
|
if (Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss()) {
|
|
|
for (File file : fileList) {
|
|
|
file.delete();
|
|
|
}
|
|
|
}
|
|
|
- FileUtil.doZip(zipFile, Arrays.asList(tSyncExamStudentScore.getTrajectoryFileList().get(0).getParentFile()));
|
|
|
+
|
|
|
HttpServletResponse response = ServletUtil.getResponse();
|
|
|
-// response.setContentType("image/jpeg");
|
|
|
-// outputStream = new BufferedOutputStream(response.getOutputStream());
|
|
|
-// IOUtils.copy(new FileInputStream(zipFile), outputStream);
|
|
|
response.reset();
|
|
|
- response.setHeader("Content-Disposition", "attachment;fileName=" + zipFile.getName());
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + zipFile.getName());
|
|
|
response.addHeader("Content-Length", "" + zipFile.length());
|
|
|
response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
outputStream = new BufferedOutputStream(response.getOutputStream());
|
|
@@ -294,7 +302,7 @@ public class TSyncExamStudentScoreServiceImpl extends ServiceImpl<TSyncExamStude
|
|
|
outputStream.close();
|
|
|
}
|
|
|
if (Objects.nonNull(zipFile)) {
|
|
|
- zipFile.delete();
|
|
|
+ System.out.println(zipFile.delete());
|
|
|
}
|
|
|
}
|
|
|
}
|