xiaof 2 жил өмнө
parent
commit
efc6db54c9

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamCardService.java

@@ -44,4 +44,6 @@ public interface ExamCardService extends IService<ExamCard> {
     Long saveGeneric(GenericExamCardParams params) throws Exception;
 
     Boolean deleteGeneric(Long id);
+
+    Long copyCard(Long id);
 }

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

@@ -200,7 +200,7 @@ public class ClientServiceImpl implements ClientService {
                     throw ExceptionResultEnum.ERROR.exception("考场pdf文件丢失");
                 }
 
-                finalMap.put("total", totalPathUrl);
+                finalMap.put("paperTotal", totalPathUrl);
                 // 取试卷
                 Map<String, Map<String, String>> map = mapCourseUrl(examDetailCourses);
                 // 生成试卷List
@@ -367,7 +367,7 @@ public class ClientServiceImpl implements ClientService {
         Map<String, Object> finalMap = new HashMap<>();
         ExamDetail examDetail = examDetailService.getById(examDetailId);
         BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
-        finalMap.put("total", attachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(attachment.getId(), false));
+        finalMap.put("paperTotal", attachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(attachment.getId(), false));
 
         BasicAttachment cardAttachment = basicAttachmentService.getById(examDetail.getCardAttachmentId());
         finalMap.put("cardTotal", cardAttachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(cardAttachment.getId(), false));

+ 71 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java

@@ -31,6 +31,7 @@ import com.qmth.teachcloud.common.service.BasicCourseService;
 import com.qmth.teachcloud.common.service.TeachcloudCommonService;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -94,6 +95,15 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             throw ExceptionResultEnum.ERROR.exception("标题最长只能输入80个字符");
         }
         if (examCardParams.getId() == null) {
+            QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(ExamCard::getSchoolId, schoolId)
+                    .eq(ExamCard::getCourseCode, examCardParams.getCourseCode())
+                    .eq(ExamCard::getTitle, examCardParams.getTitle());
+            List<ExamCard> examCardList = this.list(queryWrapper);
+            if(!examCardList.isEmpty()){
+                throw ExceptionResultEnum.ERROR.exception("题卡名称已存在");
+            }
+
             examCard = new ExamCard();
             examCard.setSchoolId(schoolId);
             if (Objects.isNull(examCardParams.getTemplateId())) {
@@ -128,6 +138,16 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
         }
         // 修改
         else {
+            QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(ExamCard::getSchoolId, schoolId)
+                    .eq(ExamCard::getCourseCode, examCardParams.getCourseCode())
+                    .eq(ExamCard::getTitle, examCardParams.getTitle())
+                    .ne(ExamCard::getId, examCardParams.getId());
+            List<ExamCard> examCardList = this.list(queryWrapper);
+            if(!examCardList.isEmpty()){
+                throw ExceptionResultEnum.ERROR.exception("题卡名称已存在");
+            }
+
             examCard = this.getById(examCardParams.getId());
             examCard.setTitle(examCardParams.getTitle());
             if (!examCardParams.getCourseCode().equals(examCard.getCourseCode())) {
@@ -435,6 +455,57 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
         return this.removeById(id);
     }
 
+    @Transactional
+    @Override
+    public Long copyCard(Long id) {
+        ExamCard examCard = this.getById(id);
+        if (examCard == null) {
+            throw ExceptionResultEnum.ERROR.exception("题卡不存在");
+        }
+        // 复制题卡
+        ExamCard copyExamCard = new ExamCard();
+        BeanUtils.copyProperties(examCard, copyExamCard);
+        Long copyExamCardId = SystemConstant.getDbUuid();
+        copyExamCard.setId(copyExamCardId);
+        String title = checkTitle(examCard);
+        copyExamCard.setTitle(title);
+        this.save(copyExamCard);
+
+        ExamCardDetail examCardDetail = examCardDetailService.getByCardId(id);
+        if (examCardDetail == null) {
+            throw ExceptionResultEnum.ERROR.exception("题卡内容不存在");
+        }
+// 复制题卡内容
+        ExamCardDetail copyExamCardDetail = new ExamCardDetail();
+        BeanUtils.copyProperties(examCardDetail, copyExamCardDetail);
+        copyExamCardDetail.setId(SystemConstant.getDbUuid());
+        copyExamCardDetail.setCardId(copyExamCardId);
+        examCardDetailService.save(copyExamCardDetail);
+
+        return copyExamCardId;
+    }
+
+    /**
+     * 生成新的title
+     *
+     * @param examCard 题卡对象
+     */
+    private String checkTitle(ExamCard examCard) {
+        QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ExamCard::getSchoolId, examCard.getSchoolId())
+                .eq(ExamCard::getCourseCode, examCard.getCourseCode());
+        String title;
+        int i = 1;
+        ExamCard newExamCard;
+        do {
+            title = examCard.getTitle() + "副本" + i;
+            queryWrapper.lambda().eq(ExamCard::getTitle, title);
+            newExamCard = this.getOne(queryWrapper);
+            i++;
+        } while (newExamCard != null);
+        return title;
+    }
+
     /**
      * 数据验证
      *

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

@@ -355,6 +355,10 @@ public class CreatePdfUtil {
                         stringSet.addAll(teachClazzNames);
                     }
                     basicMap.put("value", String.join(",", stringSet));
+                } else if ("examCount".equals(code)) {
+                    basicMap.put("value", String.valueOf(examStudentList.size()));
+                } else if ("actualExamCount".equals(code)) {
+                    basicMap.put("value", "");
                 }
                 basicPlate.add(basicMap);
 

+ 2 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfFillUtils.java

@@ -127,7 +127,8 @@ public class PdfFillUtils {
             Map<String, String> basicMap = new HashMap<>();
             basicMap.put("code", object.getString("code"));
             basicMap.put("name", object.getString("name"));
-            basicMap.put("value", "xxx");
+            // 实考人数默认为“”
+            basicMap.put("value", !"actualExamCount".equals(object.getString("code")) ? "xxx" : " ");
             basicPlate.add(basicMap);
         }
         pdfPackageDto.setBasicPlate(basicPlate);

+ 12 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamCardController.java

@@ -91,7 +91,7 @@ public class ExamCardController {
      * @param id 题卡ID
      * @return Result
      */
-    @ApiOperation(value = "新增/修改")
+    @ApiOperation(value = "删除")
     @RequestMapping(value = "/delete_generic", method = RequestMethod.POST)
     public Result save(@RequestParam(value = "id") Long id) {
         Boolean success = examCardService.deleteGeneric(id);
@@ -196,4 +196,15 @@ public class ExamCardController {
         examCardService.downloadFiles(response, arraysParams);
     }
 
+    /**
+     * 复制题卡
+     *
+     * @param id 题卡id
+     */
+    @ApiOperation(value = "复制题卡")
+    @RequestMapping(value = "/copy", method = RequestMethod.POST)
+    public Result copyCard(Long id) {
+        Long copyCardId = examCardService.copyCard(id);
+        return ResultUtil.ok(String.valueOf(copyCardId), "");
+    }
 }