xiaofei 1 an în urmă
părinte
comite
2072ec094a
24 a modificat fișierele cu 288 adăugiri și 106 ștergeri
  1. 24 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/BasicTemplate.java
  2. 2 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamStudentService.java
  3. 2 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java
  4. 8 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java
  5. 6 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java
  6. 28 38
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  7. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java
  8. 15 12
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePrintPdfUtil.java
  9. 47 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfFillUtils.java
  10. 4 1
      distributed-print/install/mysql/init/teachcloud_db.sql
  11. 11 15
      distributed-print/install/mysql/upgrade/3.3.0.sql
  12. 17 10
      distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java
  13. 4 4
      distributed-print/src/main/java/com/qmth/distributed/print/api/TBTaskController.java
  14. 2 1
      teachcloud-common-api/src/main/java/com/qmth/teachcloud/common/api/api/BasicSchoolController.java
  15. 9 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/SchoolDto.java
  16. 1 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java
  17. 12 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicSchool.java
  18. 43 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/CreatePdfTypeEnum.java
  19. 5 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/BasicSchoolService.java
  20. 1 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/TBTaskService.java
  21. 33 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicSchoolServiceImpl.java
  22. 2 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TBTaskServiceImpl.java
  23. 2 1
      teachcloud-common/src/main/resources/mapper/BasicSchoolMapper.xml
  24. 9 6
      teachcloud-mark/src/main/resources/mapper/ScanPackageMapper.xml

+ 24 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/BasicTemplate.java

@@ -69,6 +69,14 @@ public class BasicTemplate extends BaseEntity implements Serializable {
      * 考生信息是否双列显示
      */
     private Boolean diallel;
+    /**
+     * 是否增加空白页
+     */
+    private Boolean addBlankPage;
+    /**
+     * 行间距在初始值基础上扩大倍数
+     */
+    private Double lineHeightTimes;
 
     /**
      * 文字说明
@@ -162,6 +170,22 @@ public class BasicTemplate extends BaseEntity implements Serializable {
         this.diallel = diallel;
     }
 
+    public Boolean getAddBlankPage() {
+        return addBlankPage;
+    }
+
+    public void setAddBlankPage(Boolean addBlankPage) {
+        this.addBlankPage = addBlankPage;
+    }
+
+    public Double getLineHeightTimes() {
+        return lineHeightTimes;
+    }
+
+    public void setLineHeightTimes(Double lineHeightTimes) {
+        this.lineHeightTimes = lineHeightTimes;
+    }
+
     public String getTextDesc() {
         return textDesc;
     }

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

@@ -44,4 +44,6 @@ public interface ExamStudentService extends IService<ExamStudent> {
     List<ExamStudent> listByExamDetailCourseIdNotIntMarkStudent(Long examDetailCourseId);
 
     int countByExamDetailCourseIdAndStudentCode(Long examDetailCourseId, String studentCode);
+
+    List<ExamStudent> listByExamDetailCourseId(Long examDetailCourseId);
 }

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

@@ -8,6 +8,7 @@ import com.qmth.distributed.print.business.bean.dto.PdfPackageDto;
 import com.qmth.distributed.print.business.bean.dto.PdfSignDto;
 import com.qmth.distributed.print.business.bean.params.ExamTaskStudentObjectParam;
 import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
+import com.qmth.distributed.print.business.entity.BasicTemplate;
 import com.qmth.distributed.print.business.entity.ExamDetail;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 import com.qmth.distributed.print.business.entity.ExamTask;
@@ -48,7 +49,7 @@ public interface PrintCommonService {
      */
     BasicAttachment saveAttachmentPdf(ClassifyEnum classifyEnum, ExamDetail examDetail, BasicAttachment basicAttachment, List<PdfDto> pdfList, Integer printCount, Integer sequence, List<File> fileTempList) throws IOException, DocumentException;
 
-    void saveAttachmentSignPdf(PdfSignDto pdfFillDto, ExamDetail examDetail, List<PdfDto> pdfList, Integer printCount, List<File> fileTempList, Boolean diallel);
+    void saveAttachmentSignPdf(PdfSignDto pdfFillDto, ExamDetail examDetail, List<PdfDto> pdfList, Integer printCount, List<File> fileTempList, BasicTemplate basicTemplate);
 
     /**
      * 保存html附件

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java

@@ -118,4 +118,12 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
                 .eq(ExamStudent::getStudentCode, studentCode);
         return this.count(queryWrapper);
     }
+
+    @Override
+    public List<ExamStudent> listByExamDetailCourseId(Long examDetailCourseId) {
+        QueryWrapper<ExamStudent> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourseId)
+                .orderByAsc(ExamStudent::getId);
+        return this.list(queryWrapper);
+    }
 }

+ 6 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java

@@ -260,7 +260,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
      */
     @Override
     @Transactional
-    public void saveAttachmentSignPdf(PdfSignDto pdfFillDto, ExamDetail examDetail, List<PdfDto> pdfList, Integer printCount, List<File> fileTempList, Boolean diallel) {
+    public void saveAttachmentSignPdf(PdfSignDto pdfFillDto, ExamDetail examDetail, List<PdfDto> pdfList, Integer printCount, List<File> fileTempList, BasicTemplate basicTemplate) {
         try {
             boolean oss = dictionaryConfig.sysDomain().isOss();
             StringJoiner pdfStringJoiner = new StringJoiner("");
@@ -273,10 +273,13 @@ public class PrintCommonServiceImpl implements PrintCommonService {
 
             File pdfFileTemp = SystemConstant.getFileTempVar(SystemConstant.PDF_PREFIX);
             fileTempList.add(pdfFileTemp);
-            pdfFileTemp = createPrintPdfUtil.createSignPdf(pdfFillDto, pdfFileTemp.getPath(), diallel);
+            pdfFileTemp = createPrintPdfUtil.createSignPdf(pdfFillDto, pdfFileTemp.getPath(), basicTemplate);
             // 校验签到表是否自动分页。2页及以上的pdf,每页后面都需要补一个空白页
             // 补空白页
-            PdfUtil.addPdfEmptyPage(pdfFileTemp);
+            if (basicTemplate != null && basicTemplate.getAddBlankPage()) {
+                // 补空白页
+                PdfUtil.addPdfEmptyPage(pdfFileTemp);
+            }
 
             String pdfDirName = pdfStringJoiner.toString().replaceAll("\\\\", SystemConstant.ORG_SPLIT);
             //pdf生成和上传

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

@@ -15,20 +15,18 @@ import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
 import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
 import com.qmth.distributed.print.business.bean.result.DictionaryResult;
 import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
-import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
-import com.qmth.distributed.print.business.cache.CreatePdfCacheUtil;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.*;
 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.util.HtmlToPdfUtil;
 import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.bean.dto.excel.*;
 import com.qmth.teachcloud.common.bean.dto.excel.export.BasicStudentErrorExportDto;
 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.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.*;
@@ -183,22 +181,18 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
         SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
         Long examDetailId = tbTask.getEntityId();
-        List<Long> examDetailIds = Objects.nonNull(map.get("examDetailIds")) ? (List<Long>) map.get("examDetailIds") : null;
         //查询printPlan
         ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
         if (Objects.isNull(examPrintPlan)) {
             throw ExceptionResultEnum.EXAM_PRINT_IS_NULL.exception();
         }
         UpdateWrapper<ExamDetail> examDetailQueryWrapper = new UpdateWrapper<>();
-        examDetailQueryWrapper.lambda().eq(ExamDetail::getSchoolId, sysUser.getSchoolId())
-                .eq(ExamDetail::getPrintPlanId, tbTask.getPrintPlanId());
-        if (Objects.nonNull(examDetailId)) {
-            examDetailQueryWrapper.lambda().eq(ExamDetail::getId, examDetailId);
-        } else if (Objects.nonNull(examDetailIds)) {
-            examDetailQueryWrapper.lambda().in(ExamDetail::getId, examDetailIds);
+        if (Objects.isNull(examDetailId)) {
+            throw ExceptionResultEnum.ERROR.exception("生成pdf考场ID异常");
         }
         examDetailQueryWrapper.lambda().set(ExamDetail::getStatus, ExamDetailStatusEnum.CREATING)
-                .set(ExamDetail::getAttachmentPath, null);
+                .set(ExamDetail::getTaskId, tbTask.getId())
+                .eq(ExamDetail::getId, examDetailId);
         examDetailService.update(examDetailQueryWrapper);
 
         //所有考场都撤回,印刷任务状态改为就绪
@@ -221,7 +215,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
      * @param examPrintPlan        印刷计划
      * @param examDetail           考场对象
      * @param sysUser              当前用户
-     * @param specifyPaperType       试卷类型
+     * @param specifyPaperType     试卷类型
      * @param basicAttachmentList  附件集合
      * @param attachmentIds
      * @param fileTempList
@@ -233,11 +227,16 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                                     ExamDetail examDetail,
                                                     SysUser sysUser,
                                                     String specifyPaperType,
+                                                    CreatePdfTypeEnum createPdfType,
                                                     List<BasicAttachment> basicAttachmentList,
                                                     Set<Long> attachmentIds,
                                                     List<File> fileTempList,
-                                                    List<PdfDto> ...list
+                                                    List<PdfDto>... list
     ) throws Exception {
+        if (CreatePdfTypeEnum.SIGN.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType) || CreatePdfTypeEnum.CHECK_IN.equals(createPdfType)) {
+            return null;
+        }
+
         for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
             List<PdfDto> studentPaperPdfList = new ArrayList<>();//所有试卷
             List<PdfDto> studentCardPdfList = new ArrayList<>();//所有题卡
@@ -290,9 +289,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             //抽取卷型
             String paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key, specifyPaperType);
             //查询考生
-            QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
-            examStudentQueryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourse.getId());
-            List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
+            List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
 
             List<String> paperTypes = Arrays.stream(paperType.split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
             // 计算备份数量,默认最小为1份。
@@ -327,7 +324,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             });
 
             // 试卷数据组装
-            if (printContent.contains("PAPER")) {
+            if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PAPER.equals(createPdfType)) && printContent.contains("PAPER")) {
                 List<PaperPdfDto> paperPdfDto = createPdfUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail, fileTempList);
 
                 //获取试卷pdf
@@ -367,7 +364,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
             // 题卡数据组装
             basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
-            if (printContent.contains("CARD")) {
+            if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.CARD.equals(createPdfType)) && printContent.contains("CARD")) {
                 Map<String, ExamCard> examCardDetailMap = new HashMap<>();
                 Map<String, String> cardContentMap = new HashMap<>();
                 for (String s : examDetailCourse.getPaperType().split(",")) {
@@ -439,7 +436,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return basicAttachmentList;
     }
 
-    private static  String getPaperTypeKey(Long examId, String paperNumber, Long examStartTime, Long examEndTime){
+    private static String getPaperTypeKey(Long examId, String paperNumber, Long examStartTime, Long examEndTime) {
         //试卷编号本考场使用卷型key
         StringJoiner stringJoiner = new StringJoiner("_");
         stringJoiner.add(String.valueOf(examId)).add(paperNumber).add(String.valueOf(examStartTime)).add(String.valueOf(examEndTime));
@@ -449,6 +446,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     /**
      * 创建A4文件
      *
+     * @param createPdfType
      * @param examPrintPlan
      * @param examDetail
      * @param basicSchool
@@ -459,10 +457,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
      * @throws DocumentException
      */
     @Transactional
-    public void createA4File(ExamPrintPlan examPrintPlan, ExamDetail examDetail, BasicSchool basicSchool, List<ExamDetailCourse> examDetailCourseList, List<File> fileTempList, List<PdfDto>... list) throws Exception {
+    public void createA4File(CreatePdfTypeEnum createPdfType, ExamPrintPlan examPrintPlan, ExamDetail examDetail, BasicSchool basicSchool, List<ExamDetailCourse> examDetailCourseList, List<File> fileTempList, List<PdfDto>... list) throws Exception {
         // 印品
         String ordinaryContent = examPrintPlan.getOrdinaryContent();
-        if (StringUtils.isNotBlank(ordinaryContent)) {
+        if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.CHECK_IN.equals(createPdfType)) && StringUtils.isNotBlank(ordinaryContent)) {
             //获取普通印品
             JSONArray jsonArrayOrdinary = JSONArray.parseArray(ordinaryContent);
             for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
@@ -486,9 +484,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 String type = (String) jsonObjectVariable.get("type");
                 if (Objects.nonNull(jsonObjectVariable.get("templateId")) && !Objects.equals("", jsonObjectVariable.get("templateId"))) {
                     Long templateId = Long.parseLong((String) jsonObjectVariable.get("templateId"));
-                    if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
+                    if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.SIGN.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
                         createPdfUtil.createSignBook(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, list[1], (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, fileTempList);
-                    } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
+                    } else if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
                         Integer backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
                         createPdfUtil.createPaperPackage(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, list[1], backupCount, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, examPrintPlan.getExamId(), fileTempList);
                     }
@@ -514,29 +512,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         Long examDetailId = tbTask.getEntityId();
         try {
             String specifyPaperType = Objects.nonNull(map.get("paperType")) ? (String) map.get("paperType") : null;
+            CreatePdfTypeEnum createPdfType = Objects.nonNull(map.get(SystemConstant.CREATE_PDF_TYPE)) ? CreatePdfTypeEnum.valueOf((String) map.get(SystemConstant.CREATE_PDF_TYPE)) : CreatePdfTypeEnum.ALL;
 
             //查询printPlan
             ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
-            if (Objects.isNull(examPrintPlan)) {
-                throw ExceptionResultEnum.EXAM_PRINT_IS_NULL.exception();
-            }
 
             BasicSchool basicSchool = commonCacheService.schoolCache(examPrintPlan.getSchoolId());
             BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamId(examPrintPlan.getExamId());
 
             //查询examDetail
-            QueryWrapper<ExamDetail> examDetailQueryWrapper = new QueryWrapper<>();
-            examDetailQueryWrapper.lambda().eq(ExamDetail::getSchoolId, sysUser.getSchoolId())
-                    .eq(ExamDetail::getPrintPlanId, tbTask.getPrintPlanId())
-                    .eq(ExamDetail::getId, examDetailId);
-            List<ExamDetail> examDetailList = examDetailService.list(examDetailQueryWrapper);
-            if (Objects.isNull(examDetailList) || examDetailList.size() == 0) {
+            Set<Long> attachmentIds = new HashSet<>();
+            ExamDetail examDetail = examDetailService.getById(examDetailId);
+            if (examDetail == null) {
                 throw ExceptionResultEnum.EXAM_DETAIL_IS_NULL.exception();
             }
-            Set<Long> attachmentIds = new HashSet<>();
-            ExamDetail examDetail = examDetailList.get(0);
-            // 保存任务ID,方便后面重新生成
-            examDetail.setTaskId(tbTask.getId());
 
             tbTask.setObjName(examDetail.getExamRoom() + SystemConstant.HYPHEN + examDetail.getExamPlace());
             //查询examDetailCourse
@@ -558,6 +547,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     examDetail,
                     sysUser,
                     specifyPaperType,
+                    createPdfType,
                     basicAttachmentList,
                     attachmentIds,
                     fileTempList,
@@ -566,7 +556,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     paperPdfList,
                     examStudentPdfList);
 
-            createA4File(examPrintPlan, examDetail, basicSchool, examDetailCourseList, fileTempList, ordinaryPdfList, variablePdfList);
+            createA4File(createPdfType, examPrintPlan, examDetail, basicSchool, examDetailCourseList, fileTempList, ordinaryPdfList, variablePdfList);
 
             //合并A3(试卷+题卡+备用试卷+备用题卡)
 //                String dirNameA3 = createPdfUtil.mergeA3Pdf(paperPdfList, examStudentPdfList, backupPaperPdfList, backupCardPdfList);
@@ -585,7 +575,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             examDetailService.updateById(examDetail);
 
             updateExamPrintPlan(basicPrintConfig, examPrintPlan);
-            map.computeIfAbsent("size", v -> examDetailList.size());
+            map.putIfAbsent("size", 1);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss()) {

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

@@ -909,7 +909,7 @@ public class CreatePdfUtil {
         }
         pdfFillDto.setStudentPlate(studentPlate);
 
-        printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, variablePdfList, printCount, fileTempList, basicTemplate.getDiallel());
+        printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, variablePdfList, printCount, fileTempList, basicTemplate);
     }
 
     /**

+ 15 - 12
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePrintPdfUtil.java

@@ -4,6 +4,7 @@ import com.itextpdf.text.*;
 import com.itextpdf.text.pdf.*;
 import com.qmth.distributed.print.business.bean.dto.PdfPackageDto;
 import com.qmth.distributed.print.business.bean.dto.PdfSignDto;
+import com.qmth.distributed.print.business.entity.BasicTemplate;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -26,11 +27,11 @@ public class CreatePrintPdfUtil {
     /**
      * 签到表生成
      *
-     * @param pdfFillDto   签到表数据
-     * @param destFileName 文件名
-     * @param diallel      是否双列显示
+     * @param pdfFillDto    签到表数据
+     * @param destFileName  文件名
+     * @param basicTemplate 印品
      */
-    public File createSignPdf(PdfSignDto pdfFillDto, String destFileName, Boolean diallel) throws Exception {
+    public File createSignPdf(PdfSignDto pdfFillDto, String destFileName, BasicTemplate basicTemplate) throws Exception {
 
         // 1:建立Document对象实例
         Document document = new Document(PageSize.A4, 20F, 20F, 40F, 36F);
@@ -50,7 +51,7 @@ public class CreatePrintPdfUtil {
             // 3:打开文档
             document.open();
             //生成pdf
-            this.generateSignPDF(document, pdfWriter, pdfFillDto, diallel);
+            this.generateSignPDF(document, pdfWriter, pdfFillDto, basicTemplate);
             // 5:关闭文档
             document.close();
 
@@ -113,8 +114,10 @@ public class CreatePrintPdfUtil {
      * @param pdfWriter  pdfWriter
      * @param pdfFillDto 签到表数据
      */
-    private void generateSignPDF(Document document, PdfWriter pdfWriter, PdfSignDto pdfFillDto, Boolean diallel) throws DocumentException {
-        diallel = diallel == null ? true : diallel;
+    private void generateSignPDF(Document document, PdfWriter pdfWriter, PdfSignDto pdfFillDto, BasicTemplate basicTemplate) throws DocumentException {
+        Boolean diallel = basicTemplate == null || basicTemplate.getDiallel() == null ? true : basicTemplate.getDiallel();
+        Double lineHeightTimes = basicTemplate == null || basicTemplate.getLineHeightTimes() == null ? 1 : basicTemplate.getLineHeightTimes();
+
         // 空格
         Paragraph blank = new Paragraph(" ");
         // 标题table
@@ -157,7 +160,7 @@ public class CreatePrintPdfUtil {
                     if ("座位号".equals(value)) {
                         value = "座号";
                     }
-                    studentTable.addCell(PdfFillUtils.createCell(value, PdfFillUtils.textFont9, BaseColor.LIGHT_GRAY, Element.ALIGN_CENTER, 0, 1, 1));
+                    studentTable.addCell(PdfFillUtils.createCell1(lineHeightTimes, value, PdfFillUtils.textFont9, BaseColor.LIGHT_GRAY, Element.ALIGN_CENTER, 0, 1, 1));
                     j++;
                 }
             }
@@ -171,19 +174,19 @@ public class CreatePrintPdfUtil {
                 Map<String, String> stringMap1 = studentPlate.get(2 * i);
                 for (int j = 0; j < stringMap1.size(); j++) {
                     String value = stringMap1.get(headKeys[j]);
-                    studentTable.addCell(PdfFillUtils.createCell(value, PdfFillUtils.textFont9, null, Element.ALIGN_CENTER, 0, 1, 1));
+                    studentTable.addCell(PdfFillUtils.createCell1(lineHeightTimes, value, PdfFillUtils.textFont9, null, Element.ALIGN_CENTER, 0, 1, 1));
                 }
 
                 if (studentPlateCount % 2 > 0 && 2 * i + 1 == studentPlate.size()) {
                     for (int i1 = 0; i1 < columnCount; i1++) {
-                        studentTable.addCell(PdfFillUtils.createCell("", PdfFillUtils.textFont9, null, Element.ALIGN_CENTER, 0, 1, 1));
+                        studentTable.addCell(PdfFillUtils.createCell1(lineHeightTimes, "", PdfFillUtils.textFont9, null, Element.ALIGN_CENTER, 0, 1, 1));
                     }
                     continue;
                 }
                 Map<String, String> stringMap2 = studentPlate.get(2 * i + 1);
                 for (int j = 0; j < stringMap2.size(); j++) {
                     String value = stringMap2.get(headKeys[j + columnCount]);
-                    studentTable.addCell(PdfFillUtils.createCell(value, PdfFillUtils.textFont9, null, Element.ALIGN_CENTER, 0, 1, 1));
+                    studentTable.addCell(PdfFillUtils.createCell1(lineHeightTimes, value, PdfFillUtils.textFont9, null, Element.ALIGN_CENTER, 0, 1, 1));
                 }
             }
         }
@@ -613,7 +616,7 @@ public class CreatePrintPdfUtil {
 
         try {
             CreatePrintPdfUtil createPrintPdfUtil = new CreatePrintPdfUtil();
-            createPrintPdfUtil.createSignPdf(pdfFillDto, "/Users/xiaofei/sign.pdf", true);
+            createPrintPdfUtil.createSignPdf(pdfFillDto, "/Users/xiaofei/sign.pdf", null);
 //            createPrintPdfUtil.createPackagePdf(pdfPackageDto, "D:/package.pdf");
         } catch (Exception e) {
             e.printStackTrace();

+ 47 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfFillUtils.java

@@ -15,6 +15,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.List;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -189,7 +191,7 @@ public class PdfFillUtils {
         pdfFillDto.setStudentPlate(studentPlate);
         try {
             CreatePrintPdfUtil createPrintPdfUtil = new CreatePrintPdfUtil();
-            File file = createPrintPdfUtil.createSignPdf(pdfFillDto, fileName, basicTemplate.getDiallel());
+            File file = createPrintPdfUtil.createSignPdf(pdfFillDto, fileName, basicTemplate);
             PrintCommonService printCommonService = SpringContextHolder.getBean(PrintCommonService.class);
             return printCommonService.uploadPdfFile(file, ClassifyEnum.SIGN);
         } catch (
@@ -327,9 +329,9 @@ public class PdfFillUtils {
     /**
      * 填充table
      *
-     * @param value       cell内容
-     * @param font        字体
-     * @param cellColor   背景色
+     * @param value     cell内容
+     * @param font      字体
+     * @param cellColor 背景色
      */
     public static PdfPCell createCell(String value, Font font, BaseColor cellColor, int horizontalAlignment, int disableBorderSide, int rowspan, int colspan) {
         PdfPCell cell = new PdfPCell();
@@ -359,11 +361,50 @@ public class PdfFillUtils {
         return cell;
     }
 
+    /**
+     * 填充table
+     * <p>
+     * +     * @param value     cell内容
+     * +     * @param font      字体
+     * +     * @param cellColor 背景色
+     * +
+     */
+    public static PdfPCell createCell1(Double lineHeightTimes, String value, Font font, BaseColor cellColor, int horizontalAlignment, int disableBorderSide, int rowspan, int colspan) {
+        PdfPCell cell = new PdfPCell();
+        cell.setBorderWidth(0.5F);
+        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+        cell.setHorizontalAlignment(horizontalAlignment);
+        cell.setUseAscender(true);
+        //        cell.setNoWrap(false);
+        if (font != null) {
+            cell.setPhrase(new Phrase(value, font));
+        } else {
+            cell.setPhrase(new Phrase(value));
+        }
+        if (cellColor != null) {
+            cell.setBackgroundColor(cellColor);
+        }
+        //                cell.setFixedHeight(18f);
+        BigDecimal bigDecimal = new BigDecimal(cell.getPhrase().getFont().getSize() * lineHeightTimes * 1.5).setScale(1, RoundingMode.HALF_UP);
+        cell.setMinimumHeight(bigDecimal.floatValue());
+        //        cell.setMinimumHeight(20f);
+        if (disableBorderSide > 0) {
+            cell.disableBorderSide(disableBorderSide);
+        }
+        if (rowspan > 0) {
+            cell.setRowspan(rowspan);
+        }
+        if (colspan > 0) {
+            cell.setColspan(colspan);
+        }
+        return cell;
+    }
+
     /**
      * 填充table
      *
-     * @param value       cell内容
-     * @param font        字体
+     * @param value cell内容
+     * @param font  字体
      */
     public static PdfPCell createTitleCell(String value, Font font, float fixedHeight, int disableBorderSide, int rowspan, int colspan) {
         PdfPCell cell = new PdfPCell();

+ 4 - 1
distributed-print/install/mysql/init/teachcloud_db.sql

@@ -356,6 +356,7 @@ CREATE TABLE IF NOT EXISTS `basic_school` (
         `update_time` bigint DEFAULT NULL COMMENT '更新时间',
         `logo` mediumtext COMMENT '学校logo',
         `init_password` varchar(100) DEFAULT NULL COMMENT '该学校用户的初始密码,默认为12345678',
+        `default_school` TINYINT(1) NULL DEFAULT 0 COMMENT '默认学校',
         PRIMARY KEY (`id`) USING BTREE,
         UNIQUE KEY `code` (`code`) USING BTREE
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学校表';
@@ -439,6 +440,8 @@ CREATE TABLE IF NOT EXISTS `basic_template` (
         `create_time` bigint DEFAULT NULL COMMENT '创建时间',
         `update_id` bigint DEFAULT NULL COMMENT '更新人',
         `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+        `add_blank_page` TINYINT(1) NULL DEFAULT 1 COMMENT '是否增加空白页',
+        `line_height_times` DOUBLE NULL DEFAULT 1 COMMENT '行间距在初始值扩大倍数(默认1)',
         PRIMARY KEY (`id`) USING BTREE
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通用模板';
 
@@ -2976,7 +2979,7 @@ INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1003, '任务释放', '/api/scan/task/omr/release', 'URL', 970, 33, 'AUTH', NULL, 1, 1, 1);
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1004, '任务历史', '/api/scan/task/omr/history', 'URL', 970, 34, 'AUTH', NULL, 1, 1, 1);
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1005, '答题卡二次识别', '/api/scan/answer/refix', 'URL', 970, 35, 'AUTH', NULL, 1, 1, 1);
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1006, '查询条件', 'Condition', 'CONDITION', 970, 1, 'AUTH', '971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1007', 1, 0, 1);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1006, '查询条件', 'Condition', 'CONDITION', 970, 1, 'AUTH', '971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1007,1009,1010', 1, 0, 1);
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1007, '未扫描-导出', '/api/scan/student/unexist/export', 'URL', 970, 36, 'AUTH', NULL, 1, 1, 1);
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1008, '仲裁-评卷历史', '/api/admin/mark/arbitrate/getHistory', 'URL', 917, 20, 'AUTH', NULL, 1, 1, 1);
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1009, '任务列表', '/api/scan/task/omr/list', 'URL', 970, 37, 'AUTH', NULL, 1, 1, 1);

+ 11 - 15
distributed-print/install/mysql/upgrade/3.3.0.sql

@@ -75,7 +75,7 @@ INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('947', '列表', 'List', 'LIST', '946', '1', 'AUTH', '952', '1', '0', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('948', '查询条件', 'Condition', 'CONDITION', '946', '2', 'AUTH', '1', '0', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('949', '查询', 'Select', 'BUTTON', '946', '3', 'AUTH', '952', '1', '0', '1');
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('950', '查看详情', 'Detail', 'LINK', '946', '4', 'AUTH', '953,954,955,956,957,958,959,960', '1', '0', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('950', '查看详情', 'Detail', 'LINK', '946', '4', 'AUTH', '953,954,955,956,957,958,959,960,969', '1', '0', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('951', '查看签到表', 'PackageDetail', 'LINK', '946', '5', 'AUTH', '961', '1', '0', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('952', '列表获取', '/api/admin/mark/setting/scoreList', 'URL', '946', '1', 'AUTH', '1', '1', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('953', '详情列表', '/api/admin/mark/student/score', 'URL', '946', '2', 'AUTH', '1', '1', '1');
@@ -94,7 +94,8 @@ INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('966', '评卷质量重新计算', '/api/admin/mark/quality/update', 'URL', '917', '22', 'AUTH', '1', '1', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('967', '评卷质量给分曲线', '/api/admin/mark/quality/chart', 'URL', '917', '23', 'AUTH', '1', '1', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('968', '绑定评卷员-已绑定评卷员集合', '/api/admin/mark/marker/list_bind_marker', 'URL', '917', '20', 'AUTH', '1', '1', '1');
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `sequence`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('970', '扫描端', 'scan', 'MENU', '11', '971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1007,1009', '1', '0', '0');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('969', '客观题统分', '/api/admin/mark/student/objective/calculate', 'URL', '946', '11', 'AUTH', '1', '1', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `sequence`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('970', '扫描端', 'scan', 'MENU', '11', '971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1007,1009,1010', '1', '0', '0');
 UPDATE `sys_privilege` SET `name` = '打印端', `related` = '200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,973,974,975' WHERE (`id` = '199');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('971', '心跳接口', '/api/scan/server/heartbeat', 'URL', '970', '1', 'AUTH', '1', '1', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('972', '登出接口', '/api/scan/logout', 'URL', '970', '2', 'AUTH', '1', '1', '1');
@@ -131,9 +132,12 @@ INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1003', '任务释放', '/api/scan/task/omr/release', 'URL', '970', '33', 'AUTH', '1', '1', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1004', '任务历史', '/api/scan/task/omr/history', 'URL', '970', '34', 'AUTH', '1', '1', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1005', '答题卡二次识别', '/api/scan/answer/refix', 'URL', '970', '35', 'AUTH', '1', '1', '1');
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`,`related`, `enable`, `default_auth`, `front_display`) VALUES ('1006', '查询条件', 'Condition', 'CONDITION', '970', '1', 'AUTH','971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1007', '1', '0', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`,`related`, `enable`, `default_auth`, `front_display`) VALUES ('1006', '查询条件', 'Condition', 'CONDITION', '970', '1', 'AUTH','971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1007,1009,1010', '1', '0', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1007', '未扫描-导出', '/api/scan/student/unexist/export', 'URL', '970', '36', 'AUTH', '1', '1', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1008', '仲裁-评卷历史', '/api/admin/mark/arbitrate/getHistory', 'URL', '917', '20', 'AUTH', '1', '1', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1009, '任务列表', '/api/scan/task/omr/list', 'URL', 970, 37, 'AUTH', NULL, 1, 1, 1);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('1010', '人工绑定确认', '/api/scan/student/assign/confirm', 'URL', '970', '38', 'AUTH', '1', '1', '1');
+
 DELETE FROM `sys_privilege` WHERE (`id` = '392');
 DELETE FROM `sys_privilege` WHERE (`id` = '393');
 DELETE FROM `sys_privilege` WHERE (`id` = '394');
@@ -225,16 +229,8 @@ UPDATE `sys_privilege` SET `related` = '490,543' WHERE (`id` = '488');
 UPDATE `sys_privilege` SET `related` = '494,544' WHERE (`id` = '489');
 UPDATE `sys_privilege` SET `parent_id` = '489', `sequence` = '2' WHERE (`id` = '544');
 
+ALTER TABLE `basic_template`
+    ADD COLUMN `add_blank_page` TINYINT(1) NULL DEFAULT 1 COMMENT '是否增加空白页' AFTER `update_time`,
+ADD COLUMN `line_height_times` DOUBLE NULL DEFAULT 1 COMMENT '行间距在初始值扩大倍数(默认1)' AFTER `add_blank_page`;
 
-
-
-
-
-ALTER TABLE `mark_student`
-    ADD COLUMN `exam_start_time` BIGINT(20) NULL COMMENT '考试开始时间' AFTER `assign_confirmed`,
-ADD COLUMN `exam_end_time` BIGINT(20) NULL COMMENT '考试结束时间' AFTER `exam_start_time`;
-
-ALTER TABLE `mark_paper`
-    ADD COLUMN `force_mode` TINYINT(1) NULL DEFAULT 1 COMMENT '强制评卷模式(不限为false)' AFTER `mark_mode`;
-ALTER TABLE `mark_student`
-    ADD COLUMN `create_id` BIGINT(20) NULL COMMENT '创建人ID' AFTER `exam_end_time`;
+ALTER TABLE `basic_school` ADD COLUMN `default_school` TINYINT(1) NULL DEFAULT 0 AFTER `init_password`;

+ 17 - 10
distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java

@@ -34,6 +34,7 @@ import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import io.swagger.annotations.*;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -69,25 +70,20 @@ public class SysController {
 
     @Resource
     SysUserService sysUserService;
-
+    @Resource
+    BasicSchoolService basicSchoolService;
     @Resource
     BasicVerifyCodeService basicVerifyCodeService;
-
     @Resource
     DictionaryConfig dictionaryConfig;
-
     @Resource
     CommonCacheService commonCacheService;
-
     @Resource
     PrintCommonService printCommonService;
-
     @Resource
     TBTaskService tbTaskService;
-
     @Resource
     BasicAttachmentService basicAttachmentService;
-
     @Resource
     SysUserRoleService sysUserRoleService;
 
@@ -433,15 +429,24 @@ public class SysController {
     @RequestMapping(value = "/school/query_by_school_code", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "学校信息", response = EditResult.class)})
     @Aac(auth = false)
-    public Result queryBySchoolCode(@ApiParam(value = "机构code", required = true) @RequestParam String code) {
+    public Result queryBySchoolCode(@ApiParam(value = "机构code", required = false) @RequestParam String code) {
         if (Objects.nonNull(code) && code.contains("#")) {
             code = code.substring(0, code.indexOf("#"));
         }
         Map<String, Object> map = new HashMap<>();
         map.put(SystemConstant.VERSION, SystemConstant.VERSION_VALUE);
-        if (!code.equalsIgnoreCase(SystemConstant.ADMIN_CODE)) {
-            BasicSchool basicSchool = commonCacheService.schoolCache(code);
+        if (!SystemConstant.ADMIN_CODE.equalsIgnoreCase(code)) {
+            BasicSchool basicSchool = null;
+            if (StringUtils.isNotBlank(code)) {
+                basicSchool = commonCacheService.schoolCache(code);
+            } else {
+                List<BasicSchool> basicSchoolList = basicSchoolService.listByDefaultSchool(true);
+                if (CollectionUtils.isNotEmpty(basicSchoolList)) {
+                    basicSchool = basicSchoolList.get(0);
+                }
+            }
             Optional.ofNullable(basicSchool).orElseThrow(() -> ExceptionResultEnum.SCHOOL_NO_DATA.exception());
+            code = basicSchool.getCode();
             authInfoService.appHasExpired(code);
             SysConfig sysConfig = commonCacheService.addSysConfigCache(basicSchool.getId(), SystemConstant.ACCOUNT_SMS_VERIFY);
             map.put(SystemConstant.LOGO, basicSchool.getLogo());
@@ -449,6 +454,7 @@ public class SysController {
             map.put("accountSmsVerify", Objects.nonNull(sysConfig) ? Boolean.valueOf(sysConfig.getConfigValue()) : false);
             // 若为在线激活,则允许手机号登录
             map.put("phoneLogin", authInfoService.allowPhoneLogin(basicSchool.getId()));
+            map.put("schoolCode", code);
         } else {
             SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.ADMIN_LOGO_URL);
             map.put(SystemConstant.LOGO, Objects.nonNull(sysConfig) ? sysConfig.getConfigValue() : null);
@@ -456,6 +462,7 @@ public class SysController {
             map.put("accountSmsVerify", false);
             // 若为在线激活,则允许手机号登录,超管默认false
             map.put("phoneLogin", false);
+            map.put("schoolCode", SystemConstant.ADMIN_CODE);
         }
 
 

+ 4 - 4
distributed-print/src/main/java/com/qmth/distributed/print/api/TBTaskController.java

@@ -92,11 +92,11 @@ public class TBTaskController {
     @ApiOperation(value = "重新生成pdf")
     @RequestMapping(value = "/reset_create_pdf", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "重新生成pdf", response = EditResult.class)})
-    public Result resetCreatePdf(@ApiParam(value = "任务id", required = true) @RequestParam String id) {
-        Long taskId = Long.parseLong(id);
-        TBTask tbTask = tbTaskService.getById(taskId);
+    public Result resetCreatePdf(@ApiParam(value = "任务id", required = true) @RequestParam Long id,
+                                 @ApiParam(value = "pdf生成类型") @RequestParam(required = false) String type) {
+        TBTask tbTask = tbTaskService.getById(id);
         examDetailService.resetExamDetail(tbTask.getEntityId(), false);
-        tbTaskService.resetCreatePdf(tbTask);
+        tbTaskService.resetCreatePdf(tbTask, type);
         return ResultUtil.ok(new EditResult());
     }
 

+ 2 - 1
teachcloud-common-api/src/main/java/com/qmth/teachcloud/common/api/api/BasicSchoolController.java

@@ -55,9 +55,10 @@ public class BasicSchoolController {
                          @RequestParam(value = "code") String code,
                          @RequestParam(value = "name") String name,
                          @RequestParam(value = "initPassword") String initPassword,
+                         @RequestParam(value = "defaultSchool") Boolean defaultSchool,
                          @RequestParam(value = "logo", required = false) MultipartFile logo,
                          @RequestParam(value = "logoMd5") String logoMd5) {
-        return ResultUtil.ok(basicSchoolService.updateSchool(id, code, name, initPassword, logo, logoMd5));
+        return ResultUtil.ok(basicSchoolService.updateSchool(id, code, name, initPassword, defaultSchool, logo, logoMd5));
     }
 }
 

+ 9 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/SchoolDto.java

@@ -17,6 +17,7 @@ public class SchoolDto {
 
     private String logo;
     private String initPassword;
+    private Boolean defaultSchool;
 
     public String getId() {
         return id;
@@ -81,4 +82,12 @@ public class SchoolDto {
     public void setInitPassword(String initPassword) {
         this.initPassword = initPassword;
     }
+
+    public Boolean getDefaultSchool() {
+        return defaultSchool;
+    }
+
+    public void setDefaultSchool(Boolean defaultSchool) {
+        this.defaultSchool = defaultSchool;
+    }
 }

+ 1 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -280,6 +280,7 @@ public class SystemConstant {
     public static final int IN_SIZE_MAX = 1000;
     public static final int ALL_CARD = -1;
     public static final String MANUAL = "manual";
+    public static final String CREATE_PDF_TYPE = "createPdfType";
     public static final String DELIMITER = ":";
     public static final String COMMA = ",";
     public static final int FINAL_SCALE = 1;

+ 12 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicSchool.java

@@ -50,6 +50,10 @@ public class BasicSchool extends BaseEntity implements Serializable {
     @TableField(value = "init_password")
     private String initPassword;
 
+    @ApiModelProperty(value = "是否默认指定学校")
+    @TableField(value = "default_school")
+    private Boolean defaultSchool;
+
     public BasicSchool() {
 
     }
@@ -168,4 +172,12 @@ public class BasicSchool extends BaseEntity implements Serializable {
     public void setInitPassword(String initPassword) {
         this.initPassword = initPassword;
     }
+
+    public Boolean getDefaultSchool() {
+        return defaultSchool;
+    }
+
+    public void setDefaultSchool(Boolean defaultSchool) {
+        this.defaultSchool = defaultSchool;
+    }
 }

+ 43 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/CreatePdfTypeEnum.java

@@ -0,0 +1,43 @@
+package com.qmth.teachcloud.common.enums;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * pdf生成类型
+ */
+public enum CreatePdfTypeEnum {
+
+    ALL("全部"),
+    PAPER("试卷"),
+    CARD("题卡"),
+    SIGN("签到表"),
+    PACKAGE("卷袋贴"),
+    CHECK_IN("登记表");
+
+    CreatePdfTypeEnum(String name) {
+        this.name = name;
+    }
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @return
+     */
+    public static List<EnumResult> listTypes() {
+        List<EnumResult> list = new ArrayList<EnumResult>();
+        for (CreatePdfTypeEnum value : CreatePdfTypeEnum.values()) {
+            EnumResult result = new EnumResult();
+            result.setCode(value.name());
+            result.setName(value.getName());
+            result.setOrdinal(value.ordinal());
+            list.add(result);
+        }
+        return list;
+    }
+
+}

+ 5 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/BasicSchoolService.java

@@ -19,5 +19,9 @@ public interface BasicSchoolService extends IService<BasicSchool> {
 
     List<SchoolDto> listSchool(String code);
 
-    boolean updateSchool(Long id, String code, String name, String initPassword, MultipartFile logo, String logoMd5);
+    boolean updateSchool(Long id, String code, String name, String initPassword, Boolean defaultSchool, MultipartFile logo, String logoMd5);
+
+    List<BasicSchool> listByDefaultSchool(boolean defaultSchool);
+
+    void updateDefaultSchool(Long id, boolean defaultSchool);
 }

+ 1 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/TBTaskService.java

@@ -12,7 +12,6 @@ import com.qmth.teachcloud.common.entity.TBTask;
 import com.qmth.teachcloud.common.enums.TaskResultEnum;
 import com.qmth.teachcloud.common.enums.TaskStatusEnum;
 import com.qmth.teachcloud.common.enums.TaskTypeEnum;
-import com.qmth.teachcloud.common.util.Result;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
@@ -142,5 +141,5 @@ public interface TBTaskService extends IService<TBTask> {
 
     IPage<TaskListResult> queryResult(Page<Map> iPage, Long semesterId, Long examId, String courseCode, String paperNumber, TaskStatusEnum status, TaskTypeEnum type, TaskResultEnum result);
 
-    void resetCreatePdf(TBTask tbTask);
+    void resetCreatePdf(TBTask tbTask, String type);
 }

+ 33 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicSchoolServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.teachcloud.common.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.teachcloud.common.bean.dto.SchoolDto;
@@ -13,14 +14,16 @@ import com.qmth.teachcloud.common.service.CommonCacheService;
 import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.util.Base64Util;
 import com.qmth.teachcloud.common.util.FileStoreUtil;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.websocket.RemoteEndpoint;
 import java.util.Base64;
+import java.util.Collection;
 import java.util.List;
-import java.util.Queue;
 
 /**
  * <p>
@@ -57,7 +60,7 @@ public class BasicSchoolServiceImpl extends ServiceImpl<BasicSchoolMapper, Basic
     }
 
     @Override
-    public boolean updateSchool(Long id, String code, String name, String initPassword, MultipartFile logo, String logoMd5) {
+    public boolean updateSchool(Long id, String code, String name, String initPassword, Boolean defaultSchool, MultipartFile logo, String logoMd5) {
         BasicSchool basicSchool = this.getById(id);
         basicSchool.setCode(code);
         basicSchool.setName(name);
@@ -83,6 +86,19 @@ public class BasicSchoolServiceImpl extends ServiceImpl<BasicSchoolMapper, Basic
             sysUserService.update(updateWrapper);
         }
 
+        if (defaultSchool && !basicSchool.getDefaultSchool()) {
+            List<BasicSchool> basicSchools = this.listByDefaultSchool(true);
+            if (CollectionUtils.isNotEmpty(basicSchools)) {
+                for (BasicSchool school : basicSchools) {
+                    this.updateDefaultSchool(school.getId(), false);
+                    // 清除学校缓存
+                    commonCacheService.removeSchoolCache(school.getCode());
+                    commonCacheService.removeSchoolCache(school.getId());
+                }
+            }
+        }
+        basicSchool.setDefaultSchool(defaultSchool);
+
         // 清除学校缓存
         commonCacheService.removeSchoolCache(basicSchool.getCode());
         commonCacheService.removeSchoolCache(basicSchool.getId());
@@ -90,4 +106,19 @@ public class BasicSchoolServiceImpl extends ServiceImpl<BasicSchoolMapper, Basic
         basicSchool.setInitPassword(newInitPassword);
         return this.updateById(basicSchool);
     }
+
+    @Override
+    public List<BasicSchool> listByDefaultSchool(boolean defaultSchool) {
+        QueryWrapper<BasicSchool> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(BasicSchool::getDefaultSchool, defaultSchool);
+        return this.list(queryWrapper);
+    }
+
+    @Override
+    public void updateDefaultSchool(Long id, boolean defaultSchool) {
+        UpdateWrapper<BasicSchool> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().set(BasicSchool::getDefaultSchool, defaultSchool)
+                .eq(BasicSchool::getId, id);
+        this.update(updateWrapper);
+    }
 }

+ 2 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TBTaskServiceImpl.java

@@ -21,7 +21,6 @@ import com.qmth.teachcloud.common.enums.TaskTypeEnum;
 import com.qmth.teachcloud.common.mapper.TBTaskMapper;
 import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
 import com.qmth.teachcloud.common.service.TBTaskService;
-import com.qmth.teachcloud.common.service.TeachcloudCommonService;
 import com.qmth.teachcloud.common.util.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -283,12 +282,13 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
     }
 
     @Override
-    public void resetCreatePdf(TBTask tbTask) {
+    public void resetCreatePdf(TBTask tbTask, String type) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Map<String, Object> map = new HashMap<>();
         map.computeIfAbsent(SystemConstant.TASK, v -> tbTask);
         map.computeIfAbsent(SystemConstant.USER, v -> sysUser);
         map.putIfAbsent(SystemConstant.MANUAL, true);
+        map.putIfAbsent(SystemConstant.CREATE_PDF_TYPE, type);
         MqDto mqDto = new MqDto(MqTagEnum.PDF.getCode(), map, String.valueOf(tbTask.getId()));
         redisUtil.sendMessage(mqDto.getTopic(), mqDto);
     }

+ 2 - 1
teachcloud-common/src/main/resources/mapper/BasicSchoolMapper.xml

@@ -29,7 +29,8 @@
             access_key accessKey,
             access_secret accessSecret,
             logo,
-            init_password initPassword
+            init_password initPassword,
+            default_school defaultSchool
         from basic_school
         where enable = true
         <if test="code != null and code != ''">

+ 9 - 6
teachcloud-mark/src/main/resources/mapper/ScanPackageMapper.xml

@@ -65,19 +65,21 @@
 		FROM
 			scan_package sp
 				JOIN
-			mark_paper mp ON sp.exam_id = mp.exam_id
-			    AND sp.course_paper_id = mp.course_paper_id
-				AND find_in_set(sp.package_code, mp.package_code)
-				LEFT JOIN sys_user su ON mp.user_id = su.id
+			mark_paper_package mpp ON sp.exam_id = mpp.exam_id
+			    AND sp.course_paper_id = mpp.course_paper_id
+				AND sp.package_code = mpp.package_code
 		WHERE
 			sp.exam_id = #{examId}
 			<if test="courseCode != null and courseCode != ''">
-				AND mp.course_code = #{courseCode}
+				AND mpp.course_code = #{courseCode}
 			</if>
 			<if test="coursePaperId != null and coursePaperId != ''">
-				AND mp.course_paper_id = #{coursePaperId}
+				AND mpp.course_paper_id = #{coursePaperId}
 			</if>
 			<if test="dpr != null">
+		  			and exists (select 1 from mark_paper mp
+		  			    			left join sys_user su on mp.user_id = su.id where
+		  			            		mpp.exam_id = mp.exam_id and mpp.course_paper_id = mp.course_paper_id
 				<if test="dpr.requestUserId != null">
 					AND mp.user_id = #{dpr.requestUserId}
 				</if>
@@ -87,6 +89,7 @@
 						#{item}
 					</foreach>
 				</if>
+				)
 			</if>
 	</select>
 </mapper>