xiaof 3 роки тому
батько
коміт
f4b1936dd3

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamPaperStructure.java

@@ -104,7 +104,7 @@ public class ExamPaperStructure extends BaseEntity implements Serializable {
      */
     private Boolean enable;
 
-    @Transient
+    @TableField(exist = false)
     private String paperNumberId;
 
     public Long getSchoolId() {

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

@@ -307,7 +307,7 @@ public class DataSyncServiceImpl implements DataSyncService {
                     syncStructureData.setAnswer(m.getAnswer());
                     return syncStructureData;
                 }).collect(Collectors.toList());
-                boolean syncObjectiveStructure = stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumber() + objectivePaperType, true, null, syncObjectiveStructureDatas);
+                boolean syncObjectiveStructure = stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumberId() + objectivePaperType, true, null, syncObjectiveStructureDatas);
                 if (syncObjectiveStructure) {
                     atomicInteger.getAndIncrement();
                 }
@@ -341,7 +341,7 @@ public class DataSyncServiceImpl implements DataSyncService {
                     syncStructureData.setTotalScore(Double.valueOf(m.getScore()));
                     return syncStructureData;
                 }).collect(Collectors.toList());
-                boolean syncSubjectiveStructure = stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumber() + subjectivePaperType, false, null, syncSubjectiveStructureDatas);
+                boolean syncSubjectiveStructure = stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumberId() + subjectivePaperType, false, null, syncSubjectiveStructureDatas);
                 if (syncSubjectiveStructure) {
                     atomicInteger.getAndIncrement();
                 }
@@ -353,8 +353,8 @@ public class DataSyncServiceImpl implements DataSyncService {
         } catch (ApiException e) {
             throw ExceptionResultEnum.ERROR.exception("试卷结构同步失败:" + e.getMessage());
         } finally {
-            examPaperStructure.setStatus(status);
-            examPaperStructureService.updateById(examPaperStructure);
+//            examPaperStructure.setStatus(status);
+            examPaperStructureService.updateStatusById(examPaperStructure.getId(), status);
         }
     }
 

+ 30 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -19,6 +19,7 @@ import com.qmth.distributed.print.business.mapper.ExamTaskMapper;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
 import com.qmth.distributed.print.business.templete.execute.AsyncPaperReviewPdfExportService;
+import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
 import com.qmth.teachcloud.common.bean.dto.BlurryUserDto;
 import com.qmth.teachcloud.common.bean.dto.MqDto;
 import com.qmth.teachcloud.common.contant.SystemConstant;
@@ -1092,6 +1093,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     @Override
     public void paperDownload(HttpServletResponse response, Long examTaskId) throws Exception {
         String schoolId = ServletUtil.getRequestHeaderSchoolId().toString();
+        ExamTask examTask = this.getById(examTaskId);
         QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
         ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(queryWrapper);
@@ -1101,7 +1103,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
         List<JSONObject> jsonObjectList = JSONObject.parseArray(paperAttachmentIds, JSONObject.class);
         // 本地保存目录
-        String rootPath = SystemConstant.TEMP_FILES_DIR + File.separator + schoolId + File.separator + examTaskDetail.getId();
+        String rootPath = SystemConstant.TEMP_FILES_DIR + File.separator + System.currentTimeMillis();
         List<File> fileList = new ArrayList<>();
         // 试卷
         for (JSONObject jsonObject : jsonObjectList) {
@@ -1112,8 +1114,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 if (attachment == null) {
                     throw ExceptionResultEnum.ERROR.exception("附件数据异常");
                 }
-                String fileName = attachment.getName() + "-" + name + attachment.getType();
-                File file = teachcloudCommonService.copyFile(rootPath, fileName, attachment);
+                String paperPath = rootPath + File.separator + examTask.getPaperNumber();
+                String fileName = "试卷" + "_" + examTask.getPaperNumber() + "_" + name + attachment.getType();
+                File file = teachcloudCommonService.copyFile(paperPath, fileName, attachment);
                 fileList.add(file);
             }
         }
@@ -1122,6 +1125,8 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         Long cardId = examTaskDetail.getCardId();
         if (cardId != null) {
             ExamCard examCard = examCardService.getById(cardId);
+
+            String cardPath = rootPath + File.separator + examTask.getPaperNumber();
             // 通用模板
             if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
                 if (examCard.getTemplateId() != null) {
@@ -1130,9 +1135,18 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                         throw ExceptionResultEnum.ERROR.exception("题卡文件异常");
                     }
                     BasicAttachment attachment = basicAttachmentService.getById(basicTemplate.getAttachmentId());
-                    String fileName = attachment.getName() + attachment.getType();
-                    File file = teachcloudCommonService.copyFile(rootPath, fileName, attachment);
+                    String fileName = "题卡" + "_" + examTask.getPaperNumber() + attachment.getType();
+                    File file = teachcloudCommonService.copyFile(cardPath, fileName, attachment);
                     fileList.add(file);
+
+                    String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
+                    // 转pdf文件
+                    File file1 = new File(cardPdfPath);
+                    if (!file1.exists()) {
+                        file1.createNewFile();
+                    }
+                    HtmlToPdfUtil.convert(file.getPath(), cardPdfPath, PageSizeEnum.A3);
+                    fileList.add(file1);
                 }
             }
             // 自制题卡或者客服制卡
@@ -1141,8 +1155,18 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 if (StringUtils.isBlank(examCardDetail.getHtmlContent())) {
                     throw ExceptionResultEnum.ERROR.exception("题卡内容有误");
                 }
-                File file = basicAttachmentService.saveAttachmentHtml(rootPath, examCard.getTitle() + ".html", examCardDetail.getHtmlContent());
+                String fileName = "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
+                File file = basicAttachmentService.saveAttachmentHtml(cardPath, fileName, examCardDetail.getHtmlContent());
                 fileList.add(file);
+
+                String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
+                // 转pdf文件
+                File file1 = new File(cardPdfPath);
+                if (!file1.exists()) {
+                    file1.createNewFile();
+                }
+                HtmlToPdfUtil.convert(file.getPath(), cardPdfPath, PageSizeEnum.A3);
+                fileList.add(file1);
             }
         }
         if (fileList.size() == 0) {