|
@@ -4,11 +4,9 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
import com.google.gson.Gson;
|
|
|
-import com.itextpdf.text.DocumentException;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
|
import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
|
|
@@ -18,7 +16,10 @@ import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
|
|
|
import com.qmth.distributed.print.business.bean.result.DictionaryResult;
|
|
|
import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
-import com.qmth.distributed.print.business.enums.*;
|
|
|
+import com.qmth.distributed.print.business.enums.ImageTrajectoryEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.PaperFileDownloadContentEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.PaperFileDownloadExposureStatusEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
|
import com.qmth.distributed.print.business.util.CreatePdfUtil;
|
|
@@ -26,11 +27,13 @@ import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
|
|
|
import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
|
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
|
|
|
-import com.qmth.teachcloud.common.bean.dto.excel.*;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.excel.BasicStudentImportDto;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.excel.DescribeImportDto;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.excel.StatisticsImportDto;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.excel.SysUserImportDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.excel.export.BasicStudentErrorExportDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.excel.export.SysUserErrorExportDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.mark.MarkUser;
|
|
|
-import com.qmth.teachcloud.common.bean.dto.mark.PictureConfig;
|
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
|
import com.qmth.teachcloud.common.bean.params.UserSaveParams;
|
|
|
import com.qmth.teachcloud.common.bean.result.ExcelResult;
|
|
@@ -46,8 +49,6 @@ import com.qmth.teachcloud.common.util.excel.ExcelError;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.setting.MarkGroupDto;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.setting.MarkGroupSingleDto;
|
|
|
import com.qmth.teachcloud.mark.entity.MarkPaper;
|
|
|
-import com.qmth.teachcloud.mark.enums.ScorePolicy;
|
|
|
-import com.qmth.teachcloud.mark.params.MarkQuestionParams;
|
|
|
import com.qmth.teachcloud.mark.service.MarkGroupService;
|
|
|
import com.qmth.teachcloud.mark.service.MarkPaperService;
|
|
|
import com.qmth.teachcloud.mark.service.MarkQuestionService;
|
|
@@ -66,7 +67,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -75,7 +75,10 @@ import org.springframework.util.FileCopyUtils;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.*;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.InputStream;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
@@ -620,148 +623,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public Map<String, Object> executeExportSampleLogic(Map<String, Object> map) throws Exception {
|
|
|
- File zipFile = null;
|
|
|
- String zipLocalRootPath = null;
|
|
|
- try {
|
|
|
- TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
- Long time = System.currentTimeMillis();
|
|
|
- boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
- if (!oss && Objects.nonNull(dictionaryConfig.fssPublicDomain()) && !StringUtils.isBlank(dictionaryConfig.fssPublicDomain().getConfig()) && !dictionaryConfig.fssPublicDomain().getConfig().startsWith(SystemConstant.START_PARENT)) {
|
|
|
- stringJoiner.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
|
|
|
- }
|
|
|
- stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.FILE, true);
|
|
|
- stringJoiner.add("导出审核样本_" + time).add(SystemConstant.ZIP_PREFIX);
|
|
|
-
|
|
|
- String zipDirName = FileUtil.replaceSplit(stringJoiner.toString());
|
|
|
- zipFile = SystemConstant.getFileTempDirVar(SystemConstant.ZIP_PREFIX);
|
|
|
- zipLocalRootPath = zipFile.getParent() + File.separator + time;
|
|
|
-
|
|
|
- // 跟文件路径
|
|
|
- Long[] ids = (Long[]) map.get("ids");
|
|
|
- int count = 0;
|
|
|
- for (Long id : ids) {
|
|
|
- ExamTask examTask = examTaskService.getById(id);
|
|
|
- if (Objects.isNull(examTask)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务不存在", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
- }
|
|
|
- String examTaskSign = examTask.getCourseName() + SystemConstant.HYPHEN + examTask.getPaperNumber();
|
|
|
- String firstPath = zipLocalRootPath + File.separator + examTaskSign;
|
|
|
- ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(id);
|
|
|
- if (examTaskDetail == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的" + ExceptionResultEnum.EXAM_TASK_NOT_SUBMIT.getMessage(), examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
- }
|
|
|
-
|
|
|
- // 收集处理试卷和题卡
|
|
|
- List<PaperInfoVo> paperInfoVos = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
|
|
|
- if (CollectionUtils.isEmpty(paperInfoVos)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务未上传试卷或题卡", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
- }
|
|
|
-
|
|
|
- for (PaperInfoVo paperInfoVo : paperInfoVos) {
|
|
|
- // 下载试卷
|
|
|
- Long attachmentId = Long.valueOf(paperInfoVo.getAttachmentId());
|
|
|
- if (Objects.nonNull(attachmentId)) {
|
|
|
- BasicAttachment paperAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
|
|
|
- UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
- String paperPath = firstPath + File.separator + "试卷" + File.separator + paperInfoVo.getName() + "-" + paperAttachment.getName() + paperAttachment.getType();
|
|
|
- if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), paperPath, uploadFileEnum.getFssType());
|
|
|
- } else {
|
|
|
- FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), paperPath);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 下载题卡
|
|
|
- Long cardId = Long.valueOf(paperInfoVo.getCardId());
|
|
|
- if (cardId != null) {
|
|
|
- String paperType = paperInfoVo.getName();
|
|
|
- ExamCard examCard = examCardService.getById(cardId);
|
|
|
- if (Objects.isNull(examCard)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡不存在", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
|
- }
|
|
|
- MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
|
- if (MakeMethodEnum.SELECT.equals(makeMethodEnum) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
- Long cardAttachmentId = examCard.getAttachmentId();
|
|
|
- if (cardAttachmentId == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
|
- }
|
|
|
- BasicAttachment cardAttachment = basicAttachmentService.getById(cardAttachmentId);
|
|
|
- if (Objects.isNull(cardAttachment)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未找到上传附件数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
|
- }
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
|
|
|
- // 题卡路径
|
|
|
- String cardPath = firstPath + File.separator + "题卡" + File.separator + paperType + "-" + cardAttachment.getName() + cardAttachment.getType();
|
|
|
- UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
-
|
|
|
- if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath, uploadFileEnum.getFssType());
|
|
|
- } else {
|
|
|
- FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), cardPath);
|
|
|
- }
|
|
|
- } else {
|
|
|
- String htmlContent = examCard.getHtmlContent();
|
|
|
- byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
- // 题卡路径
|
|
|
- String cardPath = firstPath + File.separator + "题卡" + File.separator + paperType + "-" + examCard.getTitle() + SystemConstant.HTML_PREFIX;
|
|
|
- File localFile = new File(cardPath);
|
|
|
- if (!localFile.getParentFile().exists()) {
|
|
|
- localFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- FileCopyUtils.copy(bytes, localFile);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 处理审核样品
|
|
|
- List<Map> confirmInfo = JSONObject.parseArray(examTaskDetail.getPaperConfirmAttachmentIds(), Map.class);
|
|
|
- for (Map confirmMap : confirmInfo) {
|
|
|
- if (Objects.isNull(confirmMap.get("attachmentId"))) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
- }
|
|
|
- Long confirmAttachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
|
|
|
- BasicAttachment confirmAttachment = basicAttachmentService.getById(confirmAttachmentId);
|
|
|
- if (confirmAttachment == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未找到上传数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
- }
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
|
|
|
- UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
- String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
|
|
|
- if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), confirmPath, uploadFileEnum.getFssType());
|
|
|
- } else {
|
|
|
- FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), confirmPath);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- count++;
|
|
|
- }
|
|
|
- JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
|
|
|
- tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
|
- map.put("count", count);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(SystemConstant.LOG_ERROR, e);
|
|
|
- if (e instanceof ApiException) {
|
|
|
- ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
|
|
|
- } else {
|
|
|
- ResultUtil.error(e.getMessage());
|
|
|
- }
|
|
|
- } finally {
|
|
|
- if (Objects.nonNull(zipFile)) {
|
|
|
- zipFile.delete();
|
|
|
- }
|
|
|
- if (Objects.nonNull(zipLocalRootPath)) {
|
|
|
- ConvertUtil.delFolder(zipLocalRootPath);
|
|
|
- }
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Map<String, Object> executeExportPaperAndCardLogic(Map<String, Object> map) {
|
|
|
String zipLocalRootPath = null;
|