|
@@ -25,7 +25,6 @@ import com.qmth.distributed.print.business.util.CreatePdfUtil;
|
|
import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.teachcloud.common.bean.dto.excel.*;
|
|
import com.qmth.teachcloud.common.bean.dto.excel.*;
|
|
-import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
|
|
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
@@ -1451,7 +1450,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional
|
|
public Map<String, Object> executeDownloadScoreLogic(Map<String, Object> map) throws Exception {
|
|
public Map<String, Object> executeDownloadScoreLogic(Map<String, Object> map) throws Exception {
|
|
|
|
+ File zipFile = null;
|
|
|
|
+ List<File> sourceFiles = null;
|
|
|
|
+ List<TSyncExamStudentScore> errorTSyncExamStudentScoreList = null;
|
|
try {
|
|
try {
|
|
SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
Long semesterId = null, orgId = null, majorId = null, clazzId = null;
|
|
Long semesterId = null, orgId = null, majorId = null, clazzId = null;
|
|
@@ -1464,6 +1467,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
List<TSyncExamStudentScoreResult> tSyncExamStudentScoreResultList = tSyncExamStudentScoreService.export(sysUser.getSchoolId(), semesterId, orgId, majorId, clazzId, courseCode);
|
|
List<TSyncExamStudentScoreResult> tSyncExamStudentScoreResultList = tSyncExamStudentScoreService.export(sysUser.getSchoolId(), semesterId, orgId, majorId, clazzId, courseCode);
|
|
if (Objects.nonNull(tSyncExamStudentScoreResultList) && tSyncExamStudentScoreResultList.size() > 0) {
|
|
if (Objects.nonNull(tSyncExamStudentScoreResultList) && tSyncExamStudentScoreResultList.size() > 0) {
|
|
|
|
+ List<TSyncExamStudentScore> tSyncExamStudentScoreList = new Gson().fromJson(JacksonUtil.parseJson(tSyncExamStudentScoreResultList), new TypeToken<List<TSyncExamStudentScore>>() {
|
|
|
|
+ }.getType());
|
|
LocalDateTime nowTime = LocalDateTime.now();
|
|
LocalDateTime nowTime = LocalDateTime.now();
|
|
StringJoiner stringJoiner = new StringJoiner("");
|
|
StringJoiner stringJoiner = new StringJoiner("");
|
|
stringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
|
|
stringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
|
|
@@ -1473,54 +1478,61 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
.add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
|
|
.add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
|
|
.add(String.format("%02d", nowTime.getDayOfMonth()))
|
|
.add(String.format("%02d", nowTime.getDayOfMonth()))
|
|
.add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
|
|
.add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
|
|
- File zipFile = new File(stringJoiner.toString() + dirZipName.toString());
|
|
|
|
- if (!zipFile.getParentFile().exists()) {
|
|
|
|
|
|
+ zipFile = new File(stringJoiner.toString() + dirZipName.toString());
|
|
|
|
+ if (!zipFile.exists()) {
|
|
zipFile.getParentFile().mkdirs();
|
|
zipFile.getParentFile().mkdirs();
|
|
zipFile.createNewFile();
|
|
zipFile.createNewFile();
|
|
}
|
|
}
|
|
- List<File> sourceFiles = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- for (TSyncExamStudentScoreResult t : tSyncExamStudentScoreResultList) {
|
|
|
|
|
|
+ sourceFiles = new ArrayList<>();
|
|
|
|
+ List<TSyncExamStudentScore> updateTSyncExamStudentScoreList = new ArrayList<>();
|
|
|
|
+ errorTSyncExamStudentScoreList = new ArrayList<>();
|
|
|
|
+ for (TSyncExamStudentScore t : tSyncExamStudentScoreList) {
|
|
|
|
+ boolean update = Objects.isNull(t.getTrajectoryUrls()) ? true : false;
|
|
|
|
+ t = tSyncExamStudentScoreService.createImageTrajectory(t, ImageTrajectoryEnum.DOWNLOAD);
|
|
if (Objects.nonNull(t.getTrajectoryUrls())) {
|
|
if (Objects.nonNull(t.getTrajectoryUrls())) {
|
|
- sourceFiles.add(fileStoreUtil.ossDownload(t.getTrajectoryUrls(), stringJoiner.toString() + t.getTrajectoryUrls(), UploadFileEnum.FILE.getFssType()));
|
|
|
|
|
|
+ sourceFiles.add(t.getTrajectoryFile());
|
|
} else {
|
|
} else {
|
|
- if (Objects.nonNull(t.getSheetUrls())) {
|
|
|
|
- String format = t.getSheetUrls().substring(t.getSheetUrls().lastIndexOf("."), t.getSheetUrls().length());
|
|
|
|
- File file = new File(t.getSheetUrls());
|
|
|
|
- StringJoiner dirImageName = new StringJoiner("");
|
|
|
|
- dirImageName.add(UploadFileEnum.FILE.getTitle()).add(File.separator);
|
|
|
|
- dirImageName.add(String.valueOf(nowTime.getYear())).add(File.separator)
|
|
|
|
- .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
|
|
|
|
- .add(String.format("%02d", nowTime.getDayOfMonth()))
|
|
|
|
- .add(File.separator).add(SystemConstant.getUuid()).add(format);
|
|
|
|
- File fileTarget = new File(stringJoiner.toString() + dirImageName.toString());
|
|
|
|
- ImageTrajectoryUtil.createImage(file, fileTarget, 10, 10);
|
|
|
|
- sourceFiles.add(fileTarget);
|
|
|
|
- fileStoreUtil.ossUpload(dirImageName.toString(), fileTarget, DigestUtils.md5Hex(new FileInputStream(fileTarget)), UploadFileEnum.FILE.getFssType());
|
|
|
|
- t.setTrajectoryUrls(dirImageName.toString());
|
|
|
|
- }
|
|
|
|
|
|
+ errorTSyncExamStudentScoreList.add(t);
|
|
|
|
+ }
|
|
|
|
+ if (update || Objects.isNull(t.getTrajectoryUrls())) {
|
|
|
|
+ updateTSyncExamStudentScoreList.add(t);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- FileUtil.doZip(zipFile, sourceFiles);
|
|
|
|
-
|
|
|
|
- boolean oss = (boolean) map.get(SystemConstant.OSS);
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- if (oss) {//上传至oss
|
|
|
|
- fileStoreUtil.ossUpload(dirZipName.toString(), zipFile, DigestUtils.md5Hex(new FileInputStream(zipFile)), UploadFileEnum.FILE.getFssType());
|
|
|
|
- jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
|
- jsonObject.put(SystemConstant.PATH, dirZipName.toString());
|
|
|
|
- } else {
|
|
|
|
- jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
|
|
|
|
- jsonObject.put(SystemConstant.PATH, stringJoiner.toString() + dirZipName.toString());
|
|
|
|
|
|
+ tSyncExamStudentScoreService.saveOrUpdateBatch(updateTSyncExamStudentScoreList);
|
|
|
|
+ if (Objects.nonNull(sourceFiles) && sourceFiles.size() > 0) {
|
|
|
|
+ FileUtil.doZip(zipFile, sourceFiles);
|
|
|
|
+ boolean oss = (boolean) map.get(SystemConstant.OSS);
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ if (oss) {//上传至oss
|
|
|
|
+ fileStoreUtil.ossUpload(dirZipName.toString(), zipFile, DigestUtils.md5Hex(new FileInputStream(zipFile)), UploadFileEnum.FILE.getFssType());
|
|
|
|
+ jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
|
+ jsonObject.put(SystemConstant.PATH, dirZipName.toString());
|
|
|
|
+ } else {
|
|
|
|
+ jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
|
|
|
|
+ jsonObject.put(SystemConstant.PATH, stringJoiner.toString() + dirZipName.toString());
|
|
|
|
+ }
|
|
|
|
+ jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
|
|
|
|
+ TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
|
+ tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
}
|
|
}
|
|
- fileStoreUtil.ossUpload(dirZipName.toString(), zipFile, DigestUtils.md5Hex(new FileInputStream(zipFile)), UploadFileEnum.FILE.getFssType());
|
|
|
|
- TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
|
- tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
|
|
}
|
|
}
|
|
- map.computeIfAbsent("count", v -> Objects.isNull(tSyncExamStudentScoreResultList) ? 0 : tSyncExamStudentScoreResultList.size());
|
|
|
|
|
|
+ List<File> finalSourceFiles = sourceFiles;
|
|
|
|
+ map.computeIfAbsent("count", v -> Objects.isNull(finalSourceFiles) ? 0 : finalSourceFiles.size());
|
|
|
|
+ if (Objects.nonNull(errorTSyncExamStudentScoreList) && errorTSyncExamStudentScoreList.size() > 0) {
|
|
|
|
+ StringJoiner stringJoiner = new StringJoiner("").add("\r\n");
|
|
|
|
+ for (TSyncExamStudentScore t : errorTSyncExamStudentScoreList) {
|
|
|
|
+ stringJoiner.add("[").add(t.getStudentCode()).add(",").add(t.getName()).add("]\r\n");
|
|
|
|
+ }
|
|
|
|
+ List<TSyncExamStudentScore> finalErrorTSyncExamStudentScoreList = errorTSyncExamStudentScoreList;
|
|
|
|
+ map.computeIfAbsent("error", v -> "其中未下载成功数据" + finalErrorTSyncExamStudentScoreList.size() + "条:" + stringJoiner.toString());
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("请求出错", e);
|
|
log.error("请求出错", e);
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ if (Objects.nonNull(zipFile)) {
|
|
|
|
+ zipFile.delete();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|