ソースを参照

[bug]审核样本导出

caozixuan 4 年 前
コミット
75c8e6826b

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

@@ -662,17 +662,19 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
             // 处理试卷样品
             List<Map> paperInfo = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
+            if (Objects.isNull(paperInfo)) {
+                throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
+            }
             System.out.println("paperInfo = " + JSON.toJSONString(paperInfo));
             Set<Long> attPaperIds = new HashSet<>();
             for (Map paperMap : paperInfo) {
-                if (Objects.isNull(paperMap.get("attachmentId"))) {
-                    throw ExceptionResultEnum.ERROR.exception("未找到附件id");
+                if (Objects.nonNull(paperMap.get("attachmentId")) && String.valueOf(paperMap.get("attachmentId")).length() > 0 && !String.valueOf(paperMap.get("attachmentId")).equals("null")) {
+                    Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
+                    attPaperIds.add(attachmentId);
                 }
-                Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
-                attPaperIds.add(attachmentId);
             }
-            List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
-            if (Objects.nonNull(paperAttachmentList)) {
+            if (attPaperIds.size() > 0) {
+                List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
                 for (BasicAttachment paperAttachment : paperAttachmentList) {
                     JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
                     String paperPath = firstPath + File.separator + "试卷" + File.separator + paperAttachment.getName() + paperAttachment.getType();
@@ -692,8 +694,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
                 attConfirmIds.add(attachmentId);
             }
-            List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
-            if (Objects.nonNull(confirmAttachmentList)) {
+            if (attConfirmIds.size() > 0) {
+                List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
                 for (BasicAttachment confirmAttachment : confirmAttachmentList) {
                     JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
                     String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
@@ -729,7 +731,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
                 String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
                 ossUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath);
-                count++;
             } else {
                 List<ExamCardDetail> examCardDetailList = examCardDetailService.list(new QueryWrapper<ExamCardDetail>().lambda().eq(ExamCardDetail::getCardId, cardId));
                 if (examCardDetailList.size() != 1) {
@@ -744,8 +745,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     localFile.getParentFile().mkdirs();
                 }
                 FileCopyUtils.copy(bytes, localFile);
-                count++;
             }
+            count++;
         }
         ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), true);
         ossUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));