xiaof 4 år sedan
förälder
incheckning
82ae2e744f

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/CommonService.java

@@ -149,7 +149,7 @@ public interface CommonService {
      * @param attachment 附件表对象
      * @return
      */
-    public File copyFile(String rootPath, BasicAttachment attachment);
+    public File copyFile(String rootPath, String fileName, BasicAttachment attachment);
 
     /**
      * 下载文件到本地并压缩返回

+ 4 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/CommonServiceImpl.java

@@ -520,12 +520,12 @@ public class CommonServiceImpl implements CommonService {
     }
 
     @Override
-    public File copyFile(String rootPath, BasicAttachment attachment) {
+    public File copyFile(String rootPath, String fileName, BasicAttachment attachment) {
         JSONObject object = JSONObject.parseObject(attachment.getPath());
         String filePath = object.getString(SystemConstant.PATH);
         String type = object.getString(SystemConstant.TYPE);
         if (type.equals(SystemConstant.OSS)) {
-            File localPath = new File(rootPath, attachment.getName() + attachment.getType());
+            File localPath = new File(rootPath, fileName);
             try {
                 File file = ossUtil.ossDownload(filePath, localPath.getPath());
                 return file;
@@ -552,7 +552,7 @@ public class CommonServiceImpl implements CommonService {
         }
         File zipFile = null;
         try {
-            zipFile = FileUtil.file(SystemConstant.DOWNLOAD_TEMP + File.separator + schoolId, time + ".zip");
+            zipFile = FileUtil.file(SystemConstant.TEMP_FILES_DIR + File.separator + schoolId, time + ".zip");
             // 压缩文件
             if (!zipFile.exists()) {
                 zipFile.createNewFile();
@@ -560,7 +560,7 @@ public class CommonServiceImpl implements CommonService {
             File[] srcFiles = files.toArray(new File[files.size()]);
 //            ZipUtil.zip(rootFile.getAbsolutePath(), zipFile.getAbsolutePath(), false);
 
-            ZipUtil.zip(zipFile, false, srcFiles);
+            ZipUtil.zip(zipFile, true, srcFiles);
             outputFile(response, zipFile, String.valueOf(time));
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception("下载失败");

+ 6 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java

@@ -174,7 +174,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
     @Override
     public CardDetailDto getCardDetail(Long cardId) {
         ExamCard examCard = this.getById(cardId);
-        if(!MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())){
+        if (!MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
             return this.baseMapper.getCardDetail(cardId);
         } else {
             return this.baseMapper.getCardDetailBySelect(cardId);
@@ -208,7 +208,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
         // 专卡
         if (SystemConstant.ALL_CARD != cardRuleId) {
             List<ExamCard> customCards = this.baseMapper.listCustom(schoolId, sysUser.getOrgId(), courseCode, CardTypeEnum.CUSTOM.name());
-            if(!customCards.isEmpty()){
+            if (!customCards.isEmpty()) {
                 list.addAll(customCards);
             }
         }
@@ -226,17 +226,18 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
         // 根据题卡取命题任务
         for (Long cardId : cardIds) {
             List<ExamTask> examTasks = examTaskService.listExamTaskByCardId(cardId);
-            if(examTasks.isEmpty() || examTasks.size() > 1){
+            if (examTasks.isEmpty() || examTasks.size() > 1) {
                 throw ExceptionResultEnum.ERROR.exception("题卡数据异常");
             }
             ExamTask examTask = examTasks.get(0);
             StringJoiner sj = new StringJoiner(File.separator);
-            sj.add(rootPath).add(examTask.getSchoolId().toString()).add(examTask.getCourseCode()+"-"+examTask.getCourseName()).add(examTask.getPaperNumber());
+            sj.add(rootPath).add(examTask.getSchoolId().toString()).add(examTask.getCourseCode() + "-" + examTask.getCourseName()).add(examTask.getPaperNumber());
 
             // 附件ID
             ExamCardDetail examCardDetail = examCardDetailService.getByCardId(cardId);
             BasicAttachment attachment = basicAttachmentService.getById(examCardDetail.getCustAttachmentId());
-            commonService.copyFile(sj.toString(), attachment);
+            String fileName = attachment.getName() + attachment.getType();
+            commonService.copyFile(sj.toString(),fileName, attachment);
         }
         // 压缩
         commonService.downloadFileAndZip(response, rootPath, time);

+ 37 - 17
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -508,7 +508,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Set<Long> orgIds = commonService.listSubOrgIds(null);
         Page<ExamTaskDto> page = new Page<>(pageNumber, pageSize);
-        String[] strings = new String[]{ExamStatusEnum.NEW.name()};
+        String[] strings = new String[]{ExamStatusEnum.NEW.name(), ExamStatusEnum.FINISH.name()};
         IPage<ExamTaskDto> examTaskDtoIPage = this.baseMapper.listTaskApply(page, schoolId, auditStatus, reviewStatus, cardRuleId, courseCode, paperNumber, startTime, endTime, strings, sysUser.getId(), orgIds);
         return examTaskDtoIPage;
     }
@@ -667,19 +667,34 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             if (!ExamCardStatusEnum.SUBMIT.name().equals(examCard.getStatus().name())) {
                 throw ExceptionResultEnum.ERROR.exception("请先提交题卡");
             }
+
+            // 是否强制包含试卷
+            BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId();
+            if (basicExamRule.getIncludePaper()) {
+                if (StringUtils.isBlank(examTaskDetail.getPaperAttachmentIds())) {
+                    throw ExceptionResultEnum.ERROR.exception("试卷文件未上传");
+                }
+                List<Map> paperAttachmentIds = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
+                long count = paperAttachmentIds.stream().filter(m -> StringUtils.isBlank(m.get("attachmentId").toString())).count();
+                if (count > 0) {
+                    throw ExceptionResultEnum.ERROR.exception("所有类型的试卷文件必须全部上传");
+                }
+            }
         }
 
         // 更新examTask状态status
         ExamTask examTask = this.getById(examTaskDetail.getExamTaskId());
-        if (examTask.getStatus().name().equals(ExamStatusEnum.SUBMIT.name()) && !examTask.getReview()) {
+        if (examTaskDetail.getOperateType().equals(ExamStatusEnum.SUBMIT.name()) && !examTask.getReview()) {
             examTask.setStatus(ExamStatusEnum.FINISH);
             // 校验是否可以提交打印状态
             commonService.checkData(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber(), (SysUser) ServletUtil.getRequestUser());
+        } else {
+            examTask.setStatus(ExamStatusEnum.valueOf(examTaskDetail.getOperateType()));
         }
 
         UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
         updateWrapper.lambda()
-                .set(ExamTask::getStatus, ExamStatusEnum.valueOf(examTaskDetail.getOperateType()))
+                .set(ExamTask::getStatus, examTask.getStatus())
                 .set(ExamTask::getUpdateId, sysUser.getId())
                 .set(ExamTask::getUpdateTime, System.currentTimeMillis())
                 .set(ExamTask::getReviewStatus, null)
@@ -778,17 +793,21 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
         List<JSONObject> jsonObjectList = JSONObject.parseArray(paperAttachmentIds, JSONObject.class);
         // 本地保存目录
-        String rootPath = SystemConstant.DOWNLOAD_TEMP + File.separator + schoolId + File.separator + examTaskDetail.getId();
+        String rootPath = SystemConstant.TEMP_FILES_DIR + File.separator + schoolId + File.separator + examTaskDetail.getId();
         List<File> fileList = new ArrayList<>();
         // 试卷
         for (JSONObject jsonObject : jsonObjectList) {
-            Long id = jsonObject.getLongValue("attachmentId");
-            BasicAttachment attachment = basicAttachmentService.getById(id);
-            if (attachment == null) {
-                throw ExceptionResultEnum.ERROR.exception("附件数据异常");
+            String id = jsonObject.get("attachmentId").toString();
+            String name = jsonObject.get("name").toString();
+            if (StringUtils.isNotBlank(id)) {
+                BasicAttachment attachment = basicAttachmentService.getById(id);
+                if (attachment == null) {
+                    throw ExceptionResultEnum.ERROR.exception("附件数据异常");
+                }
+                String fileName = attachment.getName() + "-" + name + attachment.getType();
+                File file = commonService.copyFile(rootPath, fileName, attachment);
+                fileList.add(file);
             }
-            File file = commonService.copyFile(rootPath, attachment);
-            fileList.add(file);
         }
 
         // 题卡
@@ -796,24 +815,25 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         if (cardId != null) {
             ExamCard examCard = examCardService.getById(cardId);
             // 通用模板
-            if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())){
-                if(examCard.getTemplateId() != null){
+            if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
+                if (examCard.getTemplateId() != null) {
                     BasicTemplate basicTemplate = basicTemplateService.getById(examCard.getTemplateId());
-                    if(basicTemplate == null){
-                        throw  ExceptionResultEnum.ERROR.exception("题卡文件异常");
+                    if (basicTemplate == null) {
+                        throw ExceptionResultEnum.ERROR.exception("题卡文件异常");
                     }
                     BasicAttachment attachment = basicAttachmentService.getById(basicTemplate.getAttachmentId());
-                    File file = commonService.copyFile(rootPath, attachment);
+                    String fileName = attachment.getName() + attachment.getType();
+                    File file = commonService.copyFile(rootPath, fileName, attachment);
                     fileList.add(file);
                 }
             }
             // 自制题卡或者客服制卡
             else {
                 ExamCardDetail examCardDetail = examCardDetailService.getByCardId(cardId);
-                if(StringUtils.isBlank(examCardDetail.getHtmlContent())){
+                if (StringUtils.isBlank(examCardDetail.getHtmlContent())) {
                     throw ExceptionResultEnum.ERROR.exception("题卡内容有误");
                 }
-                File file = basicAttachmentService.saveAttachmentHtml(rootPath, examCard.getTitle()+".html", examCardDetail.getHtmlContent());
+                File file = basicAttachmentService.saveAttachmentHtml(rootPath, examCard.getTitle() + ".html", examCardDetail.getHtmlContent());
                 fileList.add(file);
             }
         }

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

@@ -175,7 +175,6 @@
             <if test="endTime != null and endTime != ''">
                 and a.startTime &lt;= #{endTime}
             </if>
-            and (a.auditStatus <![CDATA[ <> ]]> 'AUDITED' and a.reviewStatus <![CDATA[ <> ]]> 'PASS')
         </where>
     </select>
     <select id="listTaskReviewUnaudited" resultType="com.qmth.distributed.print.business.bean.dto.ExamTaskDto">