Browse Source

3.4.0 update

xiaofei 11 months ago
parent
commit
820a579779

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/ExamDetailParams.java

@@ -15,6 +15,7 @@ public class ExamDetailParams {
     private String courseId;
     private Double backupCount;
     private Integer totalSubjects; // 总数量,适用于模式2
+    private List<Long> basicStudentIds; // 考生ID,适用于模式2
     private Long printHouseId; // 总印刷室,适用于模式2
     private String className; // 适用班级,适用于模式2
     private List<ExamDetailList> list;
@@ -99,6 +100,14 @@ public class ExamDetailParams {
         this.className = className;
     }
 
+    public List<Long> getBasicStudentIds() {
+        return basicStudentIds;
+    }
+
+    public void setBasicStudentIds(List<Long> basicStudentIds) {
+        this.basicStudentIds = basicStudentIds;
+    }
+
     public List<ExamDetailList> getList() {
         return list;
     }

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -254,7 +254,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         // 校验试卷编号存在时,任课教师,考试时间,考点考场均必填;
         BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
         boolean needPaperNumber = (basicSchool.getHasPaperNumber() != null && basicSchool.getHasPaperNumber()) || ExamModelEnum.MODEL4.equals(basicExam.getExamModel());
-        if (needPaperNumber && StringUtils.isBlank(paperNumber)) {
+        if ((needPaperNumber && StringUtils.isBlank(paperNumber)) || (StringUtils.isBlank(paperNumber) && StringUtils.isNotBlank(paperType))) {
             errorMsgList.add("试卷编号必填");
         }
 
@@ -279,7 +279,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         basicExamStudent.setTeacherId(teacherId);
 
         // 同一课程+教学班下只能有一位任课老师
-        List<BasicExamStudent> basicExamStudentList = this.listByExamIdAndCourseIdAndTeachClassName(basicExamStudent.getExamId(), basicExamStudent.getCourseId(), basicExamStudent.getTeachClassName());
+//        List<BasicExamStudent> basicExamStudentList = this.listByExamIdAndCourseIdAndTeachClassName(basicExamStudent.getExamId(), basicExamStudent.getCourseId(), basicExamStudent.getTeachClassName());
 //        if (CollectionUtils.isNotEmpty(basicExamStudentList)) {
 //            List<Long> teacherIds = basicExamStudentList.stream().filter(m -> m.getTeacherId() != null).map(BasicExamStudent::getTeacherId).distinct().collect(Collectors.toList());
 //            if (teacherIds.size() > 1 || (basicExamStudent.getTeacherId() != null && teacherIds.get(0) != null && basicExamStudent.getTeacherId().equals(teacherIds.get(0)))) {

+ 55 - 44
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -18,8 +18,8 @@ import com.qmth.distributed.print.business.bean.params.*;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
 import com.qmth.distributed.print.business.bean.result.WorkResult;
 import com.qmth.distributed.print.business.bean.result.examTaskStudent.ExamTaskStudentObjectResult;
-import com.qmth.distributed.print.business.bean.result.statistics.ScanCountResult;
 import com.qmth.distributed.print.business.bean.result.statistics.PrintCountResult;
+import com.qmth.distributed.print.business.bean.result.statistics.ScanCountResult;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.*;
 import com.qmth.distributed.print.business.mapper.ExamTaskMapper;
@@ -1170,19 +1170,10 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 examPrintPlan.setStatus(PrintPlanStatusEnum.READY);
                 examPrintPlanService.save(examPrintPlan);
 
-                // 查询考试+课程下已用过的班级
-                Map<String, String> usedClassNameMap = new HashMap<>();
                 List<ExamDetailCourseDto> examDetailCourseList = examDetailService.listByExamIdAndCourseId(schoolId, examTask.getExamId(), examTask.getCourseId());
-                if (!CollectionUtils.isEmpty(examDetailCourseList)) {
-                    examDetailCourseList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).forEach(m -> {
-                        for (String className : m.getClazzName().split(",")) {
-                            usedClassNameMap.put(className, String.format("%s(%s)", m.getRealName(), m.getLoginName()));
-                        }
-                    });
-                }
 
-                // 已使用过的班级集合(报错用)
-                List<String> errorClassNames = new ArrayList<>();
+                // 查询考试+课程下已用过的班级
+                Map<Long, String> basicStudentIdUserMap = new HashMap<>();
 
                 String paperNumber = examTask.getPaperNumber();
                 if (ExamModelEnum.MODEL1.equals(basicExam.getExamModel())) {
@@ -1193,12 +1184,23 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                             throw ExceptionResultEnum.ERROR.exception("选择的考试对象[" + className + "]下没有考生");
                         }
 
-                        if (MapUtils.isNotEmpty(usedClassNameMap)) {
-                            for (String name : examDetailList.getClassName().split(",")) {
-                                if (usedClassNameMap.containsKey(name)) {
-                                    errorClassNames.add(name);
+                        if (!CollectionUtils.isEmpty(examDetailCourseList)) {
+                            examDetailCourseList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).forEach(m -> {
+                                examStudentService.listByExamDetailCourseId(m.getId()).stream().filter(t -> t.getBasicStudentId() != null).forEach(s -> basicStudentIdUserMap.put(s.getBasicStudentId(), String.format("%s(%s)", m.getRealName(), m.getLoginName())));
+                            });
+                        }
+
+                        // 校验班级或班级内考生是否已命题
+                        List<Long> examTaskStudentObjectParamList = examDetailList.getExamTaskStudentObjectParamList();
+                        if (MapUtils.isNotEmpty(basicStudentIdUserMap)) {
+                            examTaskStudentObjectParamList.forEach(i -> {
+                                if (basicStudentIdUserMap.containsKey(i)) {
+                                    BasicExamStudent basicExamStudent = basicExamStudentService.getById(i);
+                                    if (basicExamStudent != null) {
+                                        throw ExceptionResultEnum.ERROR.exception("教学班[" + basicExamStudent.getTeachClassName() + "]内有考生已被[" + basicStudentIdUserMap.get(i) + "]选择");
+                                    }
                                 }
-                            }
+                            });
                         }
 
                         ExamDetail examDetail = new ExamDetail();
@@ -1238,7 +1240,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                         examDetailCourseService.save(examDetailCourse);
 
                         // 更新实际考生数量
-                        List<Long> examTaskStudentObjectParamList = examDetailList.getExamTaskStudentObjectParamList();
                         List<ExamStudent> examStudents = examStudentService.saveStudentForExamApply(examTask, examDetailList.getExtendFields(), examTaskStudentObjectParamList, examDetailCourse.getId(), sysUser);
 
                         if (!CollectionUtils.isEmpty(examStudents)) {
@@ -1258,6 +1259,17 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                         }
                     }
                 } else if (ExamModelEnum.MODEL2.equals(basicExam.getExamModel())) {
+                    // 查询考试+课程下已用过的班级
+                    Map<String, String> usedClassNameMap = new HashMap<>();
+                    if (!CollectionUtils.isEmpty(examDetailCourseList)) {
+                        examDetailCourseList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).forEach(m -> {
+                            for (String className : m.getClazzName().split(",")) {
+                                usedClassNameMap.put(className, String.format("%s(%s)", m.getRealName(), m.getLoginName()));
+                            }
+                        });
+                    }
+
+                    List<String> errorClassNames = new ArrayList<>();
                     if (StringUtils.isNotBlank(examDetailParams.getClassName()) && MapUtils.isNotEmpty(usedClassNameMap)) {
                         for (String s : examDetailParams.getClassName().split(",")) {
                             if (usedClassNameMap.containsKey(s)) {
@@ -1265,6 +1277,31 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                             }
                         }
                     }
+
+                    // 选择学生时,不校验
+                    boolean containsPrivilege = teachcloudCommonService.containsPrivilege(sysUser.getId(), "button", "SelectStudent");
+                    if (!containsPrivilege || ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
+                        Map<String, Set<String>> finalMap = new HashMap<>();
+                        StringJoiner stringJoiner = new StringJoiner(",");
+                        for (String errorClassName : errorClassNames) {
+                            String key = usedClassNameMap.get(errorClassName);
+                            Set<String> value;
+                            if (finalMap.containsKey(key)) {
+                                value = finalMap.get(key);
+                            } else {
+                                value = new HashSet<>();
+                            }
+                            value.add(errorClassName);
+                            finalMap.put(key, value);
+                        }
+                        for (Map.Entry<String, Set<String>> entry : finalMap.entrySet()) {
+                            stringJoiner.add("考试对象[" + String.join(",", entry.getValue()) + "]已被[" + entry.getKey() + "]选择");
+                        }
+                        if (StringUtils.isNotBlank(stringJoiner.toString())) {
+                            throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
+                        }
+                    }
+
                     ExamDetail examDetail = new ExamDetail();
                     examDetail.setId(SystemConstant.getDbUuid());
                     examDetail.setPackageCode("1" + redisCounterUtil.getCounter(schoolId, 6, "packageCode"));
@@ -1298,32 +1335,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                     examDetailCourse.setCreateId(sysUser.getId());
                     examDetailCourseService.save(examDetailCourse);
                 }
-
-                if (!CollectionUtils.isEmpty(errorClassNames)) {
-                    // 选择学生时,不校验
-                    boolean containsPrivilege = teachcloudCommonService.containsPrivilege(sysUser.getId(), "button", "SelectStudent");
-                    if (!containsPrivilege || ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
-                        Map<String, Set<String>> finalMap = new HashMap<>();
-                        StringJoiner stringJoiner = new StringJoiner(",");
-                        for (String errorClassName : errorClassNames) {
-                            String key = usedClassNameMap.get(errorClassName);
-                            Set<String> value;
-                            if (finalMap.containsKey(key)) {
-                                value = finalMap.get(key);
-                            } else {
-                                value = new HashSet<>();
-                            }
-                            value.add(errorClassName);
-                            finalMap.put(key, value);
-                        }
-                        for (Map.Entry<String, Set<String>> entry : finalMap.entrySet()) {
-                            stringJoiner.add("考试对象[" + String.join(",", entry.getValue()) + "]已被" + entry.getKey() + "选择");
-                        }
-                        if (StringUtils.isNotBlank(stringJoiner.toString())) {
-                            throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
-                        }
-                    }
-                }
             }
 
             if (Objects.nonNull(examTask.getFlowId())) {

+ 3 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncPaperReviewPdfExportService.java

@@ -3,6 +3,7 @@ package com.qmth.distributed.print.business.templete.execute;
 import cn.hutool.core.date.DateUtil;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.templete.export.AsyncExportTaskTemplete;
+import com.qmth.distributed.print.business.templete.service.DownloadLogicService;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.common.contant.SystemConstant;
@@ -45,8 +46,8 @@ public class AsyncPaperReviewPdfExportService extends AsyncExportTaskTemplete {
         TBTaskService tbTaskService = SpringContextHolder.getBean(TBTaskService.class);
         tbTaskService.updateById(tbTask);
         try {
-            TaskLogicService taskLogicService = SpringContextHolder.getBean(TaskLogicService.class);
-            Map<String, Object> result = taskLogicService.executeExportPaperAndCardLogic(map);
+            DownloadLogicService downloadLogicService = SpringContextHolder.getBean(DownloadLogicService.class);
+            Map<String, Object> result = downloadLogicService.executeExportPaperAndCardLogic(map);
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, map.get(SystemConstant.DATA_COUNT), FINISH_SIZE));
             tbTask.setResult(TaskResultEnum.SUCCESS);
         } catch (Exception e) {

+ 0 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java

@@ -28,13 +28,6 @@ public interface TaskLogicService {
      * @throws IOException
      */
     Map<String, Object> executeDownloadPdfLogic(Map<String, Object> map) throws Exception;
-    /**
-     * 导出试卷、题卡pdf
-     *
-     * @param map
-     * @return
-     */
-    Map<String, Object> executeExportPaperAndCardLogic(Map<String, Object> map) throws Exception;
 
     /**
      * 处理导入用户数据
@@ -70,5 +63,4 @@ public interface TaskLogicService {
      */
     Map<String, Object> executeDownloadScoreLogic(Map<String, Object> map) throws Exception;
 
-    Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) throws Exception;
 }

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/DownloadLogicServiceImpl.java

@@ -607,7 +607,7 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
                     if (downloadCard) {
                         Long cardId = Long.valueOf(paperInfoVo.getCardId());
                         ExamCard examCard = examCardService.getById(cardId);
-                        Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
+                        Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("课程["+examTaskDetailDto.getCourseName()+"("+examTaskDetailDto.getCourseCode()+")]、试卷编号["+examTaskDetailDto.getPaperNumber()+"]命题任务未找到卷型["+paperInfoVo.getName()+"]题卡"));
 
                         String cardHtmlPath = zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
                         String cardPdfPath = zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
@@ -654,7 +654,7 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
             tbTask.setResultFilePath(jsonObject.toJSONString());
             map.put("count", examTaskDetailDtoList.size());
         } catch (Exception e) {
-            log.error(SystemConstant.LOG_ERROR, e);
+            throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         } finally {
             if (Objects.nonNull(zipFile)) {
                 zipFile.delete();

+ 8 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/ImportLogicServiceImpl.java

@@ -575,13 +575,15 @@ public class ImportLogicServiceImpl implements ImportLogicService {
             }
 
             // 校验试卷编号和课程代码对应关系,试卷编号只能绑定一个课程
-            if (paperNumberCourseIdInMap.containsKey(basicExamStudent.getPaperNumber())) {
-                Long courseId = paperNumberCourseIdInMap.get(basicExamStudent.getPaperNumber());
-                if (!basicExamStudent.getCourseId().equals(courseId)) {
-                    stringJoiner.add(String.format("试卷编号[%s]对应多个不同的课程代码", basicExamStudent.getPaperNumber()));
+            if (basicExamStudent.getCourseId() != null) {
+                if (paperNumberCourseIdInMap.containsKey(basicExamStudent.getPaperNumber())) {
+                    Long courseId = paperNumberCourseIdInMap.get(basicExamStudent.getPaperNumber());
+                    if (!basicExamStudent.getCourseId().equals(courseId)) {
+                        stringJoiner.add(String.format("试卷编号[%s]对应多个不同的课程代码", basicExamStudent.getPaperNumber()));
+                    }
+                } else {
+                    paperNumberCourseIdInMap.put(basicExamStudent.getPaperNumber(), basicExamStudent.getCourseId());
                 }
-            } else {
-                paperNumberCourseIdInMap.put(basicExamStudent.getPaperNumber(), basicExamStudent.getCourseId());
             }
 
             // 校验试卷编号课程代码是否已命题且命题任务中课程代码是否一致

+ 10 - 308
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -8,57 +8,43 @@ import com.google.common.collect.Lists;
 import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.qmth.boot.api.exception.ApiException;
-import com.qmth.distributed.print.business.bean.dto.*;
-import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
-import com.qmth.teachcloud.common.bean.examRule.FieldsDto;
-import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
-import com.qmth.teachcloud.common.bean.result.DictionaryResult;
+import com.qmth.distributed.print.business.bean.dto.ExamDetailPdfDownloadDto;
+import com.qmth.distributed.print.business.bean.dto.ExaminationExportDto;
 import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
-import com.qmth.distributed.print.business.entity.*;
+import com.qmth.distributed.print.business.entity.TCStatisticsTemp;
+import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
+import com.qmth.distributed.print.business.entity.TeachClazz;
 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;
-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.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.SysUserErrorExportDto;
 import com.qmth.teachcloud.common.bean.params.ArraysParams;
-import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
+import com.qmth.teachcloud.common.bean.result.DictionaryResult;
 import com.qmth.teachcloud.common.bean.vo.PrintPathVo;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.*;
-import com.qmth.teachcloud.common.enums.*;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.enums.LocalCatalogEnum;
+import com.qmth.teachcloud.common.enums.PdfTypeEnum;
+import com.qmth.teachcloud.common.enums.UploadFileEnum;
 import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.*;
 import com.qmth.teachcloud.common.util.excel.ExcelError;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.context.annotation.Lazy;
-import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.FileCopyUtils;
 import org.springframework.util.LinkedMultiValueMap;
 
 import javax.annotation.Resource;
@@ -66,8 +52,6 @@ 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.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
@@ -268,113 +252,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return map;
     }
 
-    @Override
-    public Map<String, Object> executeExportPaperAndCardLogic(Map<String, Object> map) {
-        String zipLocalRootPath = null;
-        File zipFile = null;
-        List<File> sourceFileList = null;
-        try {
-            sourceFileList = new ArrayList<>();
-            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;
-
-            List<ExamTaskDetailDto> examTasks = (List<ExamTaskDetailDto>) map.get("examTasks");
-            for (ExamTaskDetailDto examTask : examTasks) {
-                ExamTaskDetailPdfDownloadDto examTaskDetailPdfDownloadDto = examTaskDetailService.findPdfDownload(Long.valueOf(examTask.getId()));
-
-                StringJoiner dirPath = new StringJoiner("");
-                dirPath = dirPath.add(zipLocalRootPath).add(File.separator)
-                        .add(examTaskDetailPdfDownloadDto.getSemesterName()).add(File.separator)
-                        .add(examTaskDetailPdfDownloadDto.getExamName()).add(File.separator)
-                        .add(examTaskDetailPdfDownloadDto.getCourseNameCode().replaceAll(" ", "")).add(File.separator)
-                        .add(examTaskDetailPdfDownloadDto.getPaperNumber()).add(File.separator)
-                        .add(examTaskDetailPdfDownloadDto.getCourseNameCode().replaceAll(" ", "")).add(SystemConstant.HYPHEN)
-                        .add(examTaskDetailPdfDownloadDto.getPaperNumber()).add(SystemConstant.HYPHEN);
-                // 试卷
-                String paperAttachmentIds = examTaskDetailPdfDownloadDto.getPaperAttachmentIds();
-                if (StringUtils.isNotBlank(paperAttachmentIds)) {
-                    List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(paperAttachmentIds);
-                    if (CollectionUtils.isEmpty(paperInfoVoList)) {
-                        throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
-                    }
-                    for (PaperInfoVo paperInfoVo : paperInfoVoList) {
-                        Long attachmentId = Long.valueOf(paperInfoVo.getAttachmentId());
-                        String name = paperInfoVo.getName();
-                        if (Objects.nonNull(attachmentId)) {
-                            BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
-                            if (Objects.nonNull(attachment)) {
-                                String fileName = dirPath + "试卷" + SystemConstant.HYPHEN + name + attachment.getType();
-                                File paperFile = fileUploadService.downloadFile(attachment, fileName);
-                                sourceFileList.add(paperFile);
-                            }
-                        }
-                        Long cardId = Long.valueOf(paperInfoVo.getCardId());
-                        ExamCard examCard = examCardService.getById(cardId);
-                        Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
-
-                        String cardHtmlPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.HTML_PREFIX;
-                        String cardPdfPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.PDF_PREFIX;
-                        // 通用题卡
-                        String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent(), examCard.getCourseId());
-                        // html
-                        File localFile = new File(cardHtmlPath);
-                        if (!localFile.exists()) {
-                            localFile.getParentFile().mkdirs();
-                            localFile.createNewFile();
-                        }
-                        // 生成html文件
-                        FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), localFile);
-                        sourceFileList.add(localFile);
-                        // 转pdf文件
-                        File file = new File(cardPdfPath);
-                        if (!file.exists()) {
-                            file.getParentFile().mkdirs();
-                            file.createNewFile();
-                        }
-                        HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
-                        sourceFileList.add(file);
-                    }
-                }
-            }
-            JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
-            tbTask.setResultFilePath(jsonObject.toJSONString());
-            map.put(SystemConstant.DATA_COUNT, examTasks.size());
-        } 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);
-            }
-            if (!CollectionUtils.isEmpty(sourceFileList)) {
-                for (File file : sourceFileList) {
-                    file.delete();
-                }
-            }
-        }
-        return map;
-    }
-
-
     @Transactional
     @Override
     public Map<String, Object> executeImportSysUserLogic(Map<String, Object> map) throws Exception {
@@ -685,181 +562,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return map;
     }
 
-    @Transactional(rollbackFor = Exception.class)
-    @Override
-    public Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) {
-        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
-        DownloadPaperFileParam downloadPaperFileParam = (DownloadPaperFileParam) map.get("downloadPaperFileParam");
-        Long semesterId = downloadPaperFileParam.getSemesterId();
-        Long examId = downloadPaperFileParam.getExamId();
-        Long orgId = downloadPaperFileParam.getOrgId();
-        PaperFileDownloadContentEnum paperFileDownloadContent = downloadPaperFileParam.getPaperFileDownloadContentType();
-        if (paperFileDownloadContent == null) {
-            throw ExceptionResultEnum.ERROR.exception("请选择下载文件");
-        }
-        PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus = downloadPaperFileParam.getPaperFileDownloadExposureStatus();
-        if ((PaperFileDownloadContentEnum.ONLY_PAPER.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent)) && Objects.isNull(paperFileDownloadExposureStatus)) {
-            throw ExceptionResultEnum.ERROR.exception("请选择试卷状态");
-        }
-        Boolean namedByCourseInfo = downloadPaperFileParam.getNamedByCourseInfo();
-        Boolean namedByPaperNumber = downloadPaperFileParam.getNamedByPaperNumber();
-        Boolean namedByOriginalFile = downloadPaperFileParam.getNamedByOriginalFile();
-        if (!namedByCourseInfo && !namedByPaperNumber && !namedByOriginalFile) {
-            throw ExceptionResultEnum.ERROR.exception("请选择至少一种命名规则");
-        }
-
-        String courseName = downloadPaperFileParam.getCourseName();
-        Set<Long> idSet = downloadPaperFileParam.getIdSet();
-
-        File zipFile = null;
-        String zipLocalRootPath = null;
-        try {
-            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("下载管理_批量下载_" + System.currentTimeMillis()).add(SystemConstant.ZIP_PREFIX);
-
-            String zipDirName = FileUtil.replaceSplit(stringJoiner.toString());
-            zipFile = SystemConstant.getFileTempDirVarForZip(SystemConstant.getNanoId(), SystemConstant.ZIP_PREFIX);
-            zipLocalRootPath = zipFile.getParent() + File.separator + System.currentTimeMillis();
-
-            boolean downloadPaper = paperFileDownloadContent != null && (PaperFileDownloadContentEnum.ONLY_PAPER.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent));
-            boolean downloadCard = paperFileDownloadContent != null && (PaperFileDownloadContentEnum.ONLY_CARD.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent));
-
-            SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
-            DataPermissionRule dpr = null;
-            if (CollectionUtils.isEmpty(idSet)) {
-                dpr = basicRoleDataPermissionService.findDataPermission(653L, requestUser);
-            }
-            // 查询待下载数据
-            List<ExamTaskDetailDto> examTaskDetailDtoList = downloadService.listExamQuery(semesterId, examId, orgId, courseName, idSet, dpr);
-            List<ExamTaskPaperExportDto> examTaskPaperExportDtoList = new ArrayList<>();
-            for (ExamTaskDetailDto examTaskDetailDto : examTaskDetailDtoList) {
-                ExamTaskPaperExportDto examTaskPaperExportDto = new ExamTaskPaperExportDto(examTaskDetailDto);
-                examTaskPaperExportDtoList.add(examTaskPaperExportDto);
-                List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds());
-                // 选择曝光卷型
-                if (PaperFileDownloadExposureStatusEnum.EXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
-                    if (StringUtils.isBlank(examTaskDetailDto.getExposedPaperType())) {
-                        examTaskPaperExportDto.setResult("没有曝光卷型,下载失败");
-                        continue;
-                    } else {
-                        paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getExposedPaperType());
-                    }
-                }
-                // 选择未曝光卷型
-                if (PaperFileDownloadExposureStatusEnum.UNEXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
-                    if (StringUtils.isBlank(examTaskDetailDto.getUnexposedPaperType())) {
-                        examTaskPaperExportDto.setResult("没有未曝光卷型,下载失败");
-                        continue;
-                    } else {
-                        paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getUnexposedPaperType());
-                    }
-                }
-
-                if (CollectionUtils.isEmpty(paperInfoVoList)) {
-                    examTaskPaperExportDto.setResult("所选试卷状态未查询到上传的试卷信息,下载失败");
-                    continue;
-                }
-
-                // 命题规则
-                StringJoiner sj = new StringJoiner(SystemConstant.HYPHEN);
-                if (namedByCourseInfo) {
-                    sj.add(examTaskDetailDto.getCourseName()).add(examTaskDetailDto.getCourseCode());
-                }
-                if (namedByPaperNumber) {
-                    sj.add(examTaskDetailDto.getPaperNumber());
-                }
-                String fileNamePath = sj.toString();
-
-                // 目录规则(课程名称(课程代码)/试卷编号)
-                String secondPath = examTaskDetailDto.getCourseName() + SystemConstant.HYPHEN + examTaskDetailDto.getCourseCode() + File.separator + examTaskDetailDto.getPaperNumber();
-                for (PaperInfoVo paperInfoVo : paperInfoVoList) {
-                    // 下载试卷
-                    if (downloadPaper) {
-                        // 不管什么命名规则,默认都加上卷型前缀
-                        fileNamePath = "试卷" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
-                        // 原文件名
-                        if (namedByOriginalFile) {
-                            fileNamePath = fileNamePath + File.separator + paperInfoVo.getFilename();
-                        } else {
-                            fileNamePath = fileNamePath + "." + FilenameUtils.getExtension(paperInfoVo.getFilename());
-                        }
-                        Long attachmentId = Long.valueOf(paperInfoVo.getAttachmentId());
-                        if (Objects.nonNull(attachmentId)) {
-                            BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
-                            if (Objects.nonNull(attachment)) {
-                                String fileName = StringUtils.deleteWhitespace(zipLocalRootPath + File.separator + secondPath + File.separator + fileNamePath);
-                                fileUploadService.downloadFile(attachment, fileName);
-                            }
-                        }
-                    }
-                    // 下载题卡
-                    if (downloadCard) {
-                        Long cardId = Long.valueOf(paperInfoVo.getCardId());
-                        ExamCard examCard = examCardService.getById(cardId);
-                        Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
-
-                        String cardHtmlPath = zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
-                        String cardPdfPath = zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
-                        // 原文件名
-                        if (namedByOriginalFile) {
-                            cardHtmlPath = StringUtils.deleteWhitespace(cardHtmlPath + SystemConstant.HYPHEN + examCard.getTitle() + SystemConstant.HTML_PREFIX);
-                            cardPdfPath = StringUtils.deleteWhitespace(cardPdfPath + SystemConstant.HYPHEN + examCard.getTitle() + SystemConstant.PDF_PREFIX);
-                        } else {
-                            cardHtmlPath = StringUtils.deleteWhitespace(cardHtmlPath + SystemConstant.HTML_PREFIX);
-                            cardPdfPath = StringUtils.deleteWhitespace(cardPdfPath + SystemConstant.PDF_PREFIX);
-                        }
-
-                        // html
-                        File localFile = new File(cardHtmlPath);
-                        if (!localFile.exists()) {
-                            localFile.getParentFile().mkdirs();
-                            localFile.createNewFile();
-                        }
-                        // 通用题卡
-                        String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent(), examCard.getCourseId());
-                        // 生成html文件
-                        FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), localFile);
-                        // 转pdf文件
-                        File file = new File(cardPdfPath);
-                        if (!file.exists()) {
-                            file.getParentFile().mkdirs();
-                            file.createNewFile();
-                        }
-                        HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
-                    }
-                    examTaskPaperExportDto.setResult("下载成功");
-                }
-            }
-
-            // 导出文件excel
-            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-            ExcelUtil.excelMake(ExamTaskPaperExportDto.class, examTaskPaperExportDtoList, outputStream);
-            InputStream in = new ByteArrayInputStream(outputStream.toByteArray());
-
-            String excelLocalPath = zipLocalRootPath + File.separator + "下载清单" + "." + SystemConstant.XLSX;
-            FileUtils.copyInputStreamToFile(in, new File(excelLocalPath));
-            // 所有试卷
-            JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
-            tbTask.setResultFilePath(jsonObject.toJSONString());
-            map.put("count", examTaskDetailDtoList.size());
-        } catch (Exception e) {
-            log.error(SystemConstant.LOG_ERROR, e);
-        } finally {
-            if (Objects.nonNull(zipFile)) {
-                zipFile.delete();
-            }
-            if (Objects.nonNull(zipLocalRootPath)) {
-                ConvertUtil.delFolder(zipLocalRootPath);
-            }
-        }
-        return map;
-    }
-
     /**
      * 验证机构是否存在
      *

+ 4 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/ExamCardUtils.java

@@ -0,0 +1,4 @@
+package com.qmth.distributed.print.business.util;
+
+public class ExamCardUtils {
+}

+ 1 - 0
distributed-print-business/src/main/resources/mapper/ExamDetailMapper.xml

@@ -748,6 +748,7 @@
     <select id="listByExamIdAndCourseId"
             resultType="com.qmth.distributed.print.business.bean.dto.ExamDetailCourseDto">
         SELECT
+            edc.id,
             edc.clazz_name clazzName,
             su.login_name loginName,
             su.real_name realName

+ 6 - 3
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/FileUploadServiceImpl.java

@@ -116,9 +116,12 @@ public class FileUploadServiceImpl implements FileUploadService {
     }
 
     /**
-     * @param file
-     * @param fileName
-     * @param uploadFileEnum
+     * 文件上传
+     *
+     * @param inputStream    文件流
+     * @param uploadFileEnum 上传类型
+     * @param fileName       文件名
+     * @param md5            md5
      * @return
      */
     @Override