Quellcode durchsuchen

Merge branch 'dev'
merge

wangliang vor 4 Jahren
Ursprung
Commit
d5bfe29a83

+ 62 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentCourseDto.java

@@ -0,0 +1,62 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.entity.ExamStudent;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 考生科目 dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/5/14
+ */
+public class ExamStudentCourseDto extends ExamStudent {
+
+    @ApiModelProperty(value = "科目编码")
+    private String courseCode;
+
+    @ApiModelProperty(value = "科目名称")
+    private String courseName;
+
+    @ApiModelProperty(value = "A3数量")
+    private Integer paperPageA3;
+
+    @ApiModelProperty("试卷编号")
+    private String paperNumber;
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public Integer getPaperPageA3() {
+        return paperPageA3;
+    }
+
+    public void setPaperPageA3(Integer paperPageA3) {
+        this.paperPageA3 = paperPageA3;
+    }
+}

+ 6 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExaminationImportDto.java

@@ -25,23 +25,23 @@ public class ExaminationImportDto {
     private String siteNumber;
 
     @ApiModelProperty(value = "姓名")
-    @ExcelDBFieldDesc(name = "姓名",length = 15)
+    @ExcelDBFieldDesc(name = "姓名",length = 50)
     private String studentName;
 
     @ApiModelProperty(value = "课程代码")
-    @ExcelDBFieldDesc(name = "课程代码",length = 10)
+    @ExcelDBFieldDesc(name = "课程代码",length = 30)
     private String courseCode;
 
     @ApiModelProperty(value = "课程名称")
-    @ExcelDBFieldDesc(name = "课程名称",length = 20)
+    @ExcelDBFieldDesc(name = "课程名称",length = 50)
     private String courseName;
 
     @ApiModelProperty(value = "考点")
-    @ExcelDBFieldDesc(name = "考点",length = 10)
+    @ExcelDBFieldDesc(name = "考点",length = 30)
     private String examPlace;
 
     @ApiModelProperty(value = "考场")
-    @ExcelDBFieldDesc(name = "考场",length = 10)
+    @ExcelDBFieldDesc(name = "考场",length = 30)
     private String examRoom;
 
     @ApiModelProperty(value = "考试日期")
@@ -53,7 +53,7 @@ public class ExaminationImportDto {
     private String examTime;
 
     @ApiModelProperty(value = "试卷编号")
-    @ExcelDBFieldDesc(name = "试卷编号",length = 15)
+    @ExcelDBFieldDesc(name = "试卷编号",length = 30)
     private String paperNumber;
 
     @ApiModelProperty(value = "备选字段集合")

+ 52 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/OrgCenterTypeEnum.java

@@ -0,0 +1,52 @@
+package com.qmth.distributed.print.business.enums;
+
+import com.qmth.distributed.print.business.enums.result.EnumResult;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description: 机构用户中心机构类别
+ * @Author: CaoZixuan
+ * @Date: 2021-03-27
+ */
+public enum OrgCenterTypeEnum {
+    NETWORK("NETWORK","高校网院"),
+    COLLEGE("COLLEGE","高校教务处"),
+    UNDERGRADUATE("UNDERGRADUATE","本科招办"),
+    POSTGRADUATE("COLLEGE","研究生招办"),
+    MINISTRY("MINISTRY","考试院"),
+    AOPENG("AOPENG","奥鹏"),
+    PARTNER("PARTNER","合作机构"),
+    OTHER("OTHER","其他"),
+    ;
+
+    OrgCenterTypeEnum(String typeCode, String typeName) {
+        this.typeCode = typeCode;
+        this.typeName = typeName;
+    }
+
+    private final String typeCode;
+    private final String typeName;
+
+    public String getTypeCode() {
+        return typeCode;
+    }
+
+    public String getTypeName() {
+        return typeName;
+    }
+    public static List<EnumResult> listTypes() {
+        List<EnumResult> list = new ArrayList<EnumResult>();
+        for (OrgCenterTypeEnum value : OrgCenterTypeEnum.values()) {
+            EnumResult result = new EnumResult();
+            result.setName(value.name());
+            result.setOrdinal(value.ordinal());
+            result.setCode(value.getTypeCode());
+            result.setDesc(value.getTypeName());
+            list.add(result);
+        }
+        return list;
+    }
+
+}

+ 12 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java

@@ -1,8 +1,11 @@
 package com.qmth.distributed.print.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.entity.ExamStudent;
+import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -16,4 +19,13 @@ import java.util.Map;
 public interface ExamStudentMapper extends BaseMapper<ExamStudent> {
 
     Map<String, Object> getStudentDetail(Long id);
+
+    /**
+     * 根据科目查询考生
+     *
+     * @param schoolId
+     * @param examDetailCourseIds
+     * @return
+     */
+    List<ExamStudentCourseDto> queryBySchoolIdAndExamDetailCourseIds(@Param("schoolId") Long schoolId, @Param("examDetailCourseIds") List<Long> examDetailCourseIds);
 }

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

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 
@@ -22,4 +23,13 @@ public interface ExamStudentService extends IService<ExamStudent> {
     List<String> listByExamDetailCourseId(String examDetailCourseId);
 
     Map<String, Object> getStudentDetail(Long id);
+
+    /**
+     * 根据科目查询考生
+     *
+     * @param schoolId
+     * @param examDetailCourseIds
+     * @return
+     */
+    List<ExamStudentCourseDto> queryBySchoolIdAndExamDetailCourseIds(Long schoolId, List<Long> examDetailCourseIds);
 }

+ 20 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 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.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 import com.qmth.distributed.print.business.mapper.ExamStudentMapper;
@@ -11,6 +12,7 @@ import com.qmth.distributed.print.business.service.ExamStudentService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -27,6 +29,9 @@ import java.util.stream.Collectors;
 @Service
 public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamStudent> implements ExamStudentService {
 
+    @Resource
+    ExamStudentMapper examStudentMapper;
+
     @Override
     public void updatePaperType(List<Long> examDetailCourseIds, String relatePaperType) {
         UpdateWrapper<ExamStudent> updateWrapper = new UpdateWrapper<>();
@@ -39,8 +44,8 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         QueryWrapper<ExamStudent> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourseId);
         List<ExamStudent> examStudents = this.list(queryWrapper);
-        if(!examStudents.isEmpty()){
-            List<String> strings = examStudents.stream().filter(m-> StringUtils.isNotBlank(m.getPaperType())).map(m->m.getPaperType()).distinct().collect(Collectors.toList());
+        if (!examStudents.isEmpty()) {
+            List<String> strings = examStudents.stream().filter(m -> StringUtils.isNotBlank(m.getPaperType())).map(m -> m.getPaperType()).distinct().collect(Collectors.toList());
             return strings;
         }
         return null;
@@ -50,10 +55,22 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
     public Map<String, Object> getStudentDetail(Long id) {
         Map<String, Object> map = this.baseMapper.getStudentDetail(id);
         Object extendFields = map.get("extendFields");
-        if(Objects.nonNull(extendFields)){
+        if (Objects.nonNull(extendFields)) {
             List<Map> list = JSONObject.parseArray(extendFields.toString(), Map.class);
             map.put("extendFields", list);
         }
         return map;
     }
+
+    /**
+     * 根据科目查询考生
+     *
+     * @param schoolId
+     * @param examDetailCourseIds
+     * @return
+     */
+    @Override
+    public List<ExamStudentCourseDto> queryBySchoolIdAndExamDetailCourseIds(Long schoolId, List<Long> examDetailCourseIds) {
+        return examStudentMapper.queryBySchoolIdAndExamDetailCourseIds(schoolId, examDetailCourseIds);
+    }
 }

+ 21 - 9
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/OrgCenterDataDisposeServiceImpl.java

@@ -1,18 +1,22 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.qmth.distributed.print.business.entity.BasicSchool;
+import com.qmth.distributed.print.business.enums.OrgCenterTypeEnum;
 import com.qmth.distributed.print.business.service.BasicSchoolService;
 import com.qmth.distributed.print.business.service.CallApiOrgCenterService;
 import com.qmth.distributed.print.business.service.OrgCenterDataDisposeService;
 import com.qmth.distributed.print.common.contant.SystemConstant;
+import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -60,15 +64,23 @@ public class OrgCenterDataDisposeServiceImpl implements OrgCenterDataDisposeServ
             String logo = String.valueOf(map.get("logo"));
             String accessKey = String.valueOf(map.get("accessKey"));
             String accessSecret = String.valueOf(map.get("accessSecret"));
-            BasicSchool school = new BasicSchool();
-            school.setId(id);
-            school.setCode(code);
-            school.setName(name);
-            school.setEnable(true);
-            school.setAccessKey(accessKey);
-            school.setAccessSecret(accessSecret);
-            school.setLogo(logo);
-            basicSchoolService.save(school);
+            Map typeMap = JSONObject.parseObject(String.valueOf(map.get("type")));
+            String typeCode = String.valueOf(typeMap.get("code"));
+            String typeName = String.valueOf(typeMap.get("name"));
+            if (!Arrays.stream(OrgCenterTypeEnum.values()).map(OrgCenterTypeEnum::getTypeCode).collect(Collectors.toList()).contains(typeCode)) {
+                throw ExceptionResultEnum.ERROR.exception("机构类型在枚举中不存在 + typeCode = " + typeCode);
+            }
+            if (!OrgCenterTypeEnum.PARTNER.getTypeCode().equals(typeCode)) {
+                BasicSchool school = new BasicSchool();
+                school.setId(id);
+                school.setCode(code);
+                school.setName(name);
+                school.setEnable(true);
+                school.setAccessKey(accessKey);
+                school.setAccessSecret(accessSecret);
+                school.setLogo(logo);
+                basicSchoolService.save(school);
+            }
         }
     }
 }

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

@@ -171,8 +171,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
      * @param paperTypeParam
      * @param basicAttachmentList
      * @param attachmentIds
-     * @param ftlList
-     * @param basicSchool
      * @param list
      * @return
      * @throws IOException
@@ -186,25 +184,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                                     String paperTypeParam,
                                                     List<BasicAttachment> basicAttachmentList,
                                                     Set<Long> attachmentIds,
-                                                    Set<File> ftlList,
-                                                    BasicSchool basicSchool,
                                                     List<PdfDto>... list
     ) throws IOException, DocumentException {
         if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
             for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
-                if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
-                    //获取普通印品
-                    JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
-                    for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
-                        JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
-                        if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
-                            Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
-                            BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
-                            createPdfUtil.createCheckIn(examDetail, basicAttachment, list[0], (Integer) jsonObjectOrdinary.get("backupCount"));
-                        }
-                    }
-                }
-
                 List<PdfDto> paperPdfTempList = new ArrayList<>();//所有试卷
                 List<PdfDto> examStudentTempPdfList = new ArrayList<>();//所有题卡
                 List<PdfDto> backupPaperTempPdfList = new ArrayList<>();//备份试卷
@@ -262,7 +245,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     //获取试卷pdf
                     PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, examPrintPlan.getBackupCount(), backupPaperTempPdfList);
                     examDetailCourse.setPaperPagesA3(Objects.nonNull(pdfDto) ? pdfDto.getPageCount() : examDetailCourse.getPaperPagesA3());
-                    list[1].addAll(backupPaperTempPdfList);
+                    list[0].addAll(backupPaperTempPdfList);
 
                     basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
                     for (ExamCardDetail examCardDetail : examCardDetailList) {
@@ -277,7 +260,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             examDetailCourse.setCardPagesA3(basicAttachment.getPages());
                             basicAttachmentList.add(basicAttachment);
                         }
-                        list[2].addAll(cardPdfTempList);
+                        list[1].addAll(cardPdfTempList);
 
                         //查询考生
                         QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
@@ -285,42 +268,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 .eq(ExamStudent::getExamDetailCourseId, examDetailCourse.getId());
                         List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
 
-                        if (Objects.nonNull(examPrintPlan.getVariableContent())) {
-                            //获取变量印品
-                            JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
-                            for (int i = 0; i < jsonArrayVariable.size(); i++) {
-                                JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
-                                String type = (String) jsonObjectVariable.get("type");
-                                if (Objects.nonNull(jsonObjectVariable.get("attachmentId")) && !Objects.equals("", jsonObjectVariable.get("attachmentId"))) {
-                                    Long attachmentId = Long.parseLong((String) jsonObjectVariable.get("attachmentId"));
-                                    BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
-                                    ftlList.add(commonService.getFile(basicAttachment.getPath(), false));
-                                    if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
-                                        createPdfUtil.createSignBook(basicAttachment, basicSchool.getName(), examDetail, examDetailCourse, examStudentList, list[3], (Integer) jsonObjectVariable.get("backupCount"));
-                                    } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
-                                        if (Objects.nonNull(pdfDto)) {
-                                            createPdfUtil.createPaperPackage(pdfDto.isTag(), basicAttachment, basicSchool.getName(), examDetail, examDetailCourse, examStudentList, list[3], (Integer) jsonObjectVariable.get("backupCount"));
-                                        }
-                                    }
-                                }
-                            }
-                        }
-
-                        Collections.sort(list[3], new Comparator<PdfDto>() {
-                            @Override
-                            public int compare(PdfDto o1, PdfDto o2) {
-                                return o1.getSequence() > o2.getSequence() ? 1 : -1;
-                            }
-                        });
-
                         for (ExamStudent t : examStudentList) {
                             if (Objects.nonNull(pdfDto)) {
                                 createPdfUtil.getExamStudentPaperPdf(paperPdfDto, paperPdfTempList);
                             }
                             basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, examDetail, examDetailCourse, sysUser.getId(), examStudentTempPdfList));
                         }
-                        list[4].addAll(paperPdfTempList);
-                        list[5].addAll(examStudentTempPdfList);
+                        list[2].addAll(paperPdfTempList);
+                        list[3].addAll(examStudentTempPdfList);
                         examStudentService.saveOrUpdateBatch(examStudentList);
                         jsonObject.put("card", jsonArray);
                         examCardDetail.setAttachmentId(jsonObject.toJSONString());
@@ -334,6 +289,64 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return basicAttachmentList;
     }
 
+    /**
+     * 创建A4文件
+     *
+     * @param examPrintPlan
+     * @param examDetail
+     * @param basicSchool
+     * @param ftlList
+     * @param examDetailCourseListIds
+     * @param list
+     * @throws IOException
+     * @throws DocumentException
+     */
+    @Transactional
+    public void createA4File(ExamPrintPlan examPrintPlan, ExamDetail examDetail, BasicSchool basicSchool, Set<File> ftlList, List<Long> examDetailCourseListIds, List<PdfDto>... list) throws IOException, DocumentException {
+        if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
+            //获取普通印品
+            JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
+            for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
+                JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
+                if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
+                    Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
+                    BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
+                    createPdfUtil.createCheckIn(examDetail, basicAttachment, list[0], (Integer) jsonObjectOrdinary.get("backupCount"));
+                }
+            }
+        }
+
+        if (Objects.nonNull(examPrintPlan.getVariableContent())) {
+            List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
+            int count = (int) examStudentCourseDtoList.stream().filter(s -> s.getPaperPageA3() > 2).count();
+            boolean tag = count > 0 ? true : false;
+
+            //获取变量印品
+            JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
+            for (int i = 0; i < jsonArrayVariable.size(); i++) {
+                JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
+                String type = (String) jsonObjectVariable.get("type");
+                if (Objects.nonNull(jsonObjectVariable.get("attachmentId")) && !Objects.equals("", jsonObjectVariable.get("attachmentId"))) {
+                    Long attachmentId = Long.parseLong((String) jsonObjectVariable.get("attachmentId"));
+                    BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
+                    ftlList.add(commonService.getFile(basicAttachment.getPath(), false));
+                    if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
+                        createPdfUtil.createSignBook(basicAttachment, basicSchool.getName(), examDetail, examStudentCourseDtoList, list[1], (Integer) jsonObjectVariable.get("backupCount"));
+                    } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
+                        createPdfUtil.createPaperPackage(tag, basicAttachment, basicSchool.getName(), examDetail, examStudentCourseDtoList, list[1], (Integer) jsonObjectVariable.get("backupCount"));
+                    }
+                }
+            }
+        }
+
+        Collections.sort(list[1], new Comparator<PdfDto>() {
+            @Override
+            public int compare(PdfDto o1, PdfDto o2) {
+                return o1.getSequence() > o2.getSequence() ? 1 : -1;
+            }
+        });
+    }
+
     /**
      * 创建pdf逻辑
      *
@@ -390,6 +403,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
                 }
                 List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
+                List<Long> examDetailCourseListIds = examDetailCourseList.stream().map(s -> s.getId()).collect(Collectors.toList());
+
                 List<PdfDto> variablePdfList = new ArrayList<>();//变量印品(签到表、卷袋贴)
                 List<PdfDto> ordinaryPdfList = new ArrayList<>();//普通印品(登记表)
                 List<PdfDto> paperPdfList = new ArrayList<>();//所有试卷
@@ -405,16 +420,21 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         paperTypeParam,
                         basicAttachmentList,
                         attachmentIds,
-                        ftlList,
-                        basicSchool,
-                        ordinaryPdfList,
                         backupPaperPdfList,
                         cardPdfList,
-                        variablePdfList,
                         paperPdfList,
                         examStudentPdfList);
+
+                createA4File(examPrintPlan, examDetail, basicSchool, ftlList, examDetailCourseListIds, ordinaryPdfList, variablePdfList);
+
                 //合并pdf
-                basicAttachmentList.add(createPdfUtil.mergePdf(basicExamRule, tbTask, examDetail, sysUser.getId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
+                String dirNameA3 = createPdfUtil.mergeA3Pdf(paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList);
+                String dirNameA4 = createPdfUtil.mergeA4Pdf(variablePdfList, ordinaryPdfList);
+
+                List<PdfDto> mergePdfDeleteList = new ArrayList<>();
+                mergePdfDeleteList.addAll(examStudentPdfList);
+                mergePdfDeleteList.addAll(cardPdfList);
+                basicAttachmentList.add(createPdfUtil.mergePdfSaveDb(dirNameA4, dirNameA3, tbTask, sysUser.getId(), examDetail, basicExamRule, mergePdfDeleteList));
             }
             updateExamPrintPlan(basicExamRule, examPrintPlan);
             map.computeIfAbsent("size", v -> examDetailList.size());

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

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.Gson;
 import com.itextpdf.text.DocumentException;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.PaperPdfDto;
 import com.qmth.distributed.print.business.bean.dto.PdfDto;
@@ -92,29 +93,32 @@ public class CreatePdfUtil {
      * @param tag
      * @param basicAttachment
      * @param schoolName
-     * @param examDetailCourse
      * @param examStudentList
      * @param variablePdfList
      * @param printCount
      * @throws IOException
      */
-    public void createPaperPackage(boolean tag, BasicAttachment basicAttachment, String schoolName, ExamDetail examDetail, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
+    public void createPaperPackage(boolean tag, BasicAttachment basicAttachment, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
         if (Objects.isNull(basicAttachment)) {
             throw ExceptionResultEnum.ERROR.exception("找不到附件");
         }
         Map<String, Object> htmlMap = new HashMap<>();
-        htmlMap.put("examDetailCourseId", examDetailCourse.getId());
+        if (Objects.nonNull(examStudentList) && examStudentList.size() > 0) {
+            htmlMap.put("examDetailCourseId", examStudentList.get(0).getExamDetailCourseId());
+            htmlMap.put("courseName", examStudentList.get(0).getCourseName());
+            htmlMap.put("courseCode", examStudentList.get(0).getCourseCode());
+        } else {
+            htmlMap.put("examDetailCourseId", "");
+            htmlMap.put("courseName", "");
+            htmlMap.put("courseCode", "");
+        }
         htmlMap.put("schoolName", schoolName);
-        htmlMap.put("courseName", examDetailCourse.getCourseName());
-        htmlMap.put("courseCode", examDetailCourse.getCourseCode());
         htmlMap.put("examSite", examDetail.getExamPlace());
         htmlMap.put("examRoom", examDetail.getExamRoom());
         htmlMap.put("startTime", DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DEFAULT_DATE_PATTERN));
         htmlMap.put("endTime", DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DEFAULT_DATE_PATTERN));
         htmlMap.put("paperCode", examDetail.getPackageCode());
-        if (Objects.nonNull(examDetailCourse.getPaperNumber())) {
-            htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
-        }
+        htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
 
         List<String> extendColumnList = examStudentList.stream().map(m -> m.getExtendFields()).distinct().collect(Collectors.toList());
         Set<String> startCollege = new HashSet();
@@ -175,20 +179,25 @@ public class CreatePdfUtil {
      * @param basicAttachment
      * @param schoolName
      * @param examDetail
-     * @param examDetailCourse
      * @param examStudentList
      * @param variablePdfList
      * @param printCount
      */
-    public void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetail examDetail, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
+    public void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
         if (Objects.isNull(basicAttachment)) {
             throw ExceptionResultEnum.ERROR.exception("找不到附件");
         }
         Map<String, Object> htmlMap = new HashMap<>();
-        htmlMap.put("examDetailCourseId", examDetailCourse.getId());
+        if (Objects.nonNull(examStudentList) && examStudentList.size() > 0) {
+            htmlMap.put("examDetailCourseId", examStudentList.get(0).getExamDetailCourseId());
+            htmlMap.put("courseName", examStudentList.get(0).getCourseName());
+            htmlMap.put("courseCode", examStudentList.get(0).getCourseCode());
+        } else {
+            htmlMap.put("examDetailCourseId", "");
+            htmlMap.put("courseName", "");
+            htmlMap.put("courseCode", "");
+        }
         htmlMap.put("schoolName", schoolName);
-        htmlMap.put("courseName", examDetailCourse.getCourseName());
-        htmlMap.put("courseCode", examDetailCourse.getCourseCode());
         htmlMap.put("examRoom", examDetail.getExamRoom());
 
         List<String> extendColumnList = examStudentList.stream().map(m -> m.getExtendFields()).distinct().collect(Collectors.toList());
@@ -207,9 +216,7 @@ public class CreatePdfUtil {
         htmlMap.put("startTime", DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DEFAULT_DATE_PATTERN));
         htmlMap.put("endTime", DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DEFAULT_DATE_PATTERN));
         htmlMap.put("paperCode", examDetail.getPackageCode());
-        if (Objects.nonNull(examDetailCourse.getPaperNumber())) {
-            htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
-        }
+        htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetail.getPackageCode(), false));
 
         int totalCount = examStudentList.size();
         if (totalCount > 0) {
@@ -219,7 +226,7 @@ public class CreatePdfUtil {
                 Map subMap = new HashMap();
                 subMap.put("index", i + 1);
                 int studentCount;
-                List<ExamStudent> subStudents;
+                List<ExamStudentCourseDto> subStudents;
                 if (pageCount == 1) {
                     studentCount = totalCount;
                     subStudents = examStudentList;
@@ -391,12 +398,12 @@ public class CreatePdfUtil {
         //已曝光卷型
         String exposedPaperType = examTaskDetail.getExposedPaperType();
         if (drawRule == DrawRuleEnum.ONE) {
-            if (Objects.isNull(unexposedPaperType)) {
+            if (Objects.isNull(unexposedPaperType) || Objects.equals(unexposedPaperType.trim(), "")) {
                 CreatePdfCacheUtil.deletePaperType(key);
                 throw ExceptionResultEnum.ERROR.exception("当前没有未曝光的卷型");
             }
         } else {
-            if (Objects.isNull(exposedPaperType) && Objects.isNull(unexposedPaperType)) {
+            if ((Objects.isNull(exposedPaperType) || Objects.equals(exposedPaperType.trim(), "")) && (Objects.isNull(unexposedPaperType) || Objects.equals(unexposedPaperType.trim(), ""))) {
                 CreatePdfCacheUtil.deletePaperType(key);
                 throw ExceptionResultEnum.ERROR.exception("当前没有未曝光的卷型");
             }
@@ -446,38 +453,35 @@ public class CreatePdfUtil {
     }
 
     /**
-     * 合并pdf
+     * 合并A3 pdf
      *
-     * @param tbTask
-     * @param examDetail
-     * @param userId
      * @param list
      * @return
      * @throws IOException
      */
-    public BasicAttachment mergePdf(BasicExamRule basicExamRule, TBTask tbTask, ExamDetail examDetail, Long userId, List<PdfDto>... list) throws IOException {
+    public String mergeA3Pdf(List<PdfDto>... list) throws IOException {
         List<PdfDto> mergePdfA3List = new ArrayList<>();
+        for (int i = 0; i < list.length; i++) {
+            mergePdfA3List.addAll(list[i]);
+        }
+        List<String> pathA3List = mergePdfA3List.stream().map(PdfDto::getPath).collect(Collectors.toList());
+        return PdfUtil.mergePdf(pathA3List.toArray(new String[mergePdfA3List.size()]), null);
+    }
+
+    /**
+     * 合并A4 pdf
+     *
+     * @param list
+     * @return
+     * @throws IOException
+     */
+    public String mergeA4Pdf(List<PdfDto>... list) throws IOException {
         List<PdfDto> mergePdfA4List = new ArrayList<>();
-        List<PdfDto> mergePdfDeleteList = new ArrayList<>();
-//        AtomicInteger pageA4Count = new AtomicInteger(0);
-//        AtomicInteger pageA3Count = new AtomicInteger(0);
         for (int i = 0; i < list.length; i++) {
-            if (list[i].size() > 0 && list[i].get(0).getPageSize() == PageSizeEnum.A4) {
-//                pageA4Count.addAndGet(list[i].stream().mapToInt(PdfDto::getPageCount).sum());
-                mergePdfA4List.addAll(list[i]);
-            } else if (list[i].size() > 0 && list[i].get(0).getPageSize() == PageSizeEnum.A3) {
-//                pageA3Count.addAndGet(list[i].stream().mapToInt(PdfDto::getPageCount).sum());
-                mergePdfA3List.addAll(list[i]);
-            }
+            mergePdfA4List.addAll(list[i]);
         }
-//        mergePdfDeleteA3List.addAll(list[2]);
-        mergePdfDeleteList.addAll(list[3]);
-        mergePdfDeleteList.addAll(list[5]);
         List<String> pathA4List = mergePdfA4List.stream().map(PdfDto::getPath).collect(Collectors.toList());
-        List<String> pathA3List = mergePdfA3List.stream().map(PdfDto::getPath).collect(Collectors.toList());
-        String dirNameA4 = PdfUtil.mergePdf(pathA4List.toArray(new String[mergePdfA4List.size()]), null);
-        String dirNameA3 = PdfUtil.mergePdf(pathA3List.toArray(new String[mergePdfA3List.size()]), null);
-        return mergePdfSaveDb(dirNameA4, dirNameA3, tbTask, userId, examDetail, basicExamRule, mergePdfDeleteList);
+        return PdfUtil.mergePdf(pathA4List.toArray(new String[mergePdfA4List.size()]), null);
     }
 
     /**

+ 40 - 0
distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml

@@ -46,4 +46,44 @@
             a.id = #{id}
     </select>
 
+    <select id="queryBySchoolIdAndExamDetailCourseIds" resultType="com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto">
+        select
+            es.id,
+            es.school_id as schoolId,
+            es.exam_detail_course_id as examDetailCourseId,
+            es.student_name as studentName,
+            es.student_code as studentCode,
+            es.ticket_number as ticketNumber,
+            es.site_number as siteNumber,
+            es.print_paper as printPaper,
+            es.print_card as printCard,
+            es.extend_fields as extendFields,
+            es.paper_type as paperType,
+            es.create_id as createId,
+            es.create_time as createTime,
+            es.update_id as updateId,
+            es.update_time as updateTime,
+            es.attachment_id as attachmentId,
+            edc.course_code as courseCode,
+            edc.course_name as courseName,
+            edc.paper_pages_a3 as paperPageA3,
+            edc.paper_number as paperNumber
+        from
+            exam_student es
+        left join exam_detail_course edc on
+            edc.id = es.exam_detail_course_id
+            <where>
+                <if test="schoolId != null and schoolId != ''">
+                    and es.school_id = #{schoolId}
+                </if>
+                <if test="examDetailCourseIds != null">
+                    AND edc.id IN
+                    <foreach collection="examDetailCourseIds" item="examDetailCourseId" index="index" open="(" separator="," close=")">
+                        #{examDetailCourseId}
+                    </foreach>
+                </if>
+            </where>
+            order by edc.course_code
+    </select>
+
 </mapper>

+ 3 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/EnumsController.java

@@ -85,6 +85,9 @@ public class EnumsController {
         } else if (type.equals(EnumType.CARD_REQUIRED_FIELDS.name())) {
             //题卡必选字段
             list = CardRequiredFieldsEnum.listTypes();
+        } else if (type.equals(EnumType.ORG_CENTER_TYPE_ENUM.name())) {
+            //机构用户中心类型
+            list = OrgCenterTypeEnum.listTypes();
         } else if (type.equals(EnumType.PRINT_PLAN_STATUS_ENUM.name())) {
             //印刷计划状态
             list = PrintPlanStatusEnum.listTypes();

+ 277 - 0
distributed-print/src/test/java/com/qmth/distributed/print/BasicUserImportTest.java

@@ -0,0 +1,277 @@
+package com.qmth.distributed.print;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.qmth.distributed.print.business.entity.*;
+import com.qmth.distributed.print.business.enums.RoleTypeEnum;
+import com.qmth.distributed.print.business.service.*;
+import com.qmth.distributed.print.common.contant.SystemConstant;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
+import org.junit.platform.commons.util.StringUtils;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 用户数据导入、课程导入、组织机构导入
+ */
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class BasicUserImportTest {
+    @Autowired
+    private BasicCourseService basicCourseService;
+    @Autowired
+    private SysUserService sysUserService;
+    @Autowired
+    private SysOrgService sysOrgService;
+    @Autowired
+    private BasicUserCourseService basicUserCourseService;
+    @Autowired
+    private SysRoleService sysRoleService;
+    @Autowired
+    private SysUserRoleService sysUserRoleService;
+    @Autowired
+    private SysRolePrivilegeService sysRolePrivilegeService;
+
+    // 学校Id
+    private Long schoolId = 5l;
+
+    // 用户数据文件
+    String userFile = "D:\\20210514_追加命题及课程数据-2.xlsx";
+    // 课程数据文件
+    String courseFile = "D:\\20210514_追加命题及课程数据-1.xlsx";
+
+
+    @Test
+    public void importBasicCourse() throws Exception {
+        List<BasicCourse> courses = readCourseFile();
+        for (BasicCourse cours : courses) {
+            QueryWrapper<BasicCourse> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(BasicCourse::getCode, cours.getCode());
+            BasicCourse basicCourse = basicCourseService.getOne(queryWrapper);
+            if (basicCourse != null) {
+                if (basicCourse.getName().equals(cours.getName())) {
+                    continue;
+                } else {
+                    throw new Exception(String.format("s%代码已存在,名称不一致,数据库:s%,文件中:s%", cours.getCode(), basicCourse.getName(), cours.getName()));
+                }
+            }
+
+            cours.setId(SystemConstant.getDbUuid());
+            cours.setCreateId(124882698949885952l);
+            cours.setSchoolId(schoolId);
+            basicCourseService.save(cours);
+        }
+    }
+
+    @Test
+//    @Transactional
+    public void importBasicUser() throws Exception {
+        List<Map<String, String>> users = readUserFile();
+        for (Map<String, String> userMap : users) {
+            // sys_org
+            String orgCode = userMap.get("orgCode");
+            String orgName = userMap.get("orgName");
+            QueryWrapper<SysOrg> orgQueryWrapper = new QueryWrapper<>();
+            orgQueryWrapper.lambda().eq(SysOrg::getSchoolId, schoolId).eq(SysOrg::getCode, orgCode);
+            SysOrg sysOrg = sysOrgService.getOne(orgQueryWrapper);
+            if (sysOrg != null) {
+                if (!sysOrg.getName().equals(orgName)) {
+                    throw new Exception(String.format("s%代码已存在,名称不一致,数据库:s%,文件中:s%", orgCode, sysOrg.getName(), orgName));
+                }
+            } else {
+                sysOrg = new SysOrg();
+                sysOrg.setId(SystemConstant.getDbUuid());
+                sysOrg.setSchoolId(schoolId);
+                sysOrg.setCode(orgCode);
+                sysOrg.setName(orgName);
+                sysOrg.setParentId(100l);
+                sysOrgService.save(sysOrg);
+            }
+
+            // sys_user
+            String loginName = userMap.get("loginName");
+            String realName = userMap.get("realName");
+            String mobileNumber = userMap.get("mobileNumber");
+            String password = userMap.get("password");
+            QueryWrapper<SysUser> userQueryWrapper = new QueryWrapper<>();
+            userQueryWrapper.lambda().eq(SysUser::getSchoolId, schoolId).eq(SysUser::getLoginName, loginName);
+            SysUser sysUser = sysUserService.getOne(userQueryWrapper);
+            if(sysUser == null){
+                sysUser = new SysUser();
+                sysUser.setId(SystemConstant.getDbUuid());
+                sysUser.setSchoolId(schoolId);
+                sysUser.setLoginName(loginName);
+                sysUser.setRealName(realName);
+                sysUser.setPassword(password);
+                sysUser.setMobileNumber(mobileNumber);
+                sysUser.setOrgId(sysOrg.getId());
+                sysUserService.save(sysUser);
+            } else {
+                sysUser.setEnable(true);
+                sysUser.setMobileNumber(mobileNumber);
+                sysUserService.updateById(sysUser);
+
+                String a = "update `sys_user` set mobile_number = %s, enable = true where id = %s;";
+                System.out.println(String.format(a, mobileNumber, sysUser.getId()));
+            }
+
+            // sys_user_role
+            String roleType = userMap.get("roleType");
+            QueryWrapper<SysRole> roleQueryWrapper = new QueryWrapper<>();
+            roleQueryWrapper.lambda().eq(SysRole::getType, roleType);
+            SysRole sysRole = sysRoleService.getOne(roleQueryWrapper);
+            if (sysRole == null) {
+                throw new Exception("角色不存在");
+            }
+
+            UpdateWrapper<SysUserRole> sysUserRoleUpdateWrapper = new UpdateWrapper<>();
+            sysUserRoleUpdateWrapper.lambda().eq(SysUserRole::getUserId, sysUser.getId());
+            sysUserRoleService.remove(sysUserRoleUpdateWrapper);
+
+            QueryWrapper<SysRolePrivilege> rolePrivilegeQueryWrapper = new QueryWrapper<>();
+            rolePrivilegeQueryWrapper.lambda().eq(SysRolePrivilege::getRoleId, sysRole.getId()).eq(SysRolePrivilege::getEnable, true);
+            List<SysRolePrivilege> rolePrivileges = sysRolePrivilegeService.list(rolePrivilegeQueryWrapper);
+            List<SysUserRole> userRoles = new ArrayList<>();
+            for (SysRolePrivilege rolePrivilege : rolePrivileges) {
+                SysUserRole sysUserRole = new SysUserRole();
+                sysUserRole.setId(SystemConstant.getDbUuid());
+                sysUserRole.setUserId(sysUser.getId());
+                sysUserRole.setRoleId(rolePrivilege.getRoleId());
+                sysUserRole.setPrivilegeId(rolePrivilege.getPrivilegeId());
+                sysUserRole.setEnable(true);
+                userRoles.add(sysUserRole);
+            }
+            sysUserRoleService.saveBatch(userRoles);
+
+            // sys_user_course
+            String courseCodeses = userMap.get("courseCode");
+            if(roleType.equals(RoleTypeEnum.QUESTION_TEACHER.name())){
+                if(StringUtils.isBlank(courseCodeses)){
+                    throw new Exception("命题老师课程不能为空");
+                }
+
+                List<BasicUserCourse> userCourses = new ArrayList<>();
+                String[] courseCodes = courseCodeses.split(",");
+                for (String courseCode : courseCodes) {
+                    String[] coursees = courseCode.split("/");
+                    QueryWrapper<BasicCourse> basicCourseQueryWrapper = new QueryWrapper<>();
+                    basicCourseQueryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, coursees[0]);
+                    BasicCourse basicCourse = basicCourseService.getOne(basicCourseQueryWrapper);
+                    if(basicCourse == null){
+                        throw new Exception("命题老师对应课程不存在,"+ coursees[0]);
+                    }
+                    BasicUserCourse basicUserCourse = new BasicUserCourse();
+                    basicUserCourse.setId(SystemConstant.getDbUuid());
+                    basicUserCourse.setUserId(sysUser.getId());
+                    basicUserCourse.setCourseId(basicCourse.getId());
+                    userCourses.add(basicUserCourse);
+                }
+                basicUserCourseService.saveBatch(userCourses);
+            }
+        }
+    }
+
+    /**
+     * 读取课程数据文件
+     *
+     * @return
+     * @throws Exception
+     */
+    private List<BasicCourse> readCourseFile() throws Exception {
+        File file = new File(courseFile);
+        if (!file.exists()) {
+            throw new Exception("课程数据文件不存在");
+        }
+        FileInputStream fileInputStream = new FileInputStream(file);
+        XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
+        XSSFSheet sheet = workbook.getSheetAt(0);
+
+        List<BasicCourse> courseList = new ArrayList<>();
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            BasicCourse basicCourse = new BasicCourse();
+            Row row = sheet.getRow(i);
+            // 用户名
+            Cell cell0 = row.getCell(0);
+            basicCourse.setCode(cell0 == null ? null : cell0.getStringCellValue());
+            // 姓名
+            Cell cell1 = row.getCell(1);
+            basicCourse.setName(cell1 == null ? null : cell1.getStringCellValue());
+            courseList.add(basicCourse);
+        }
+        return courseList;
+    }
+
+    /**
+     * 读取用户数据文件
+     *
+     * @return
+     * @throws Exception
+     */
+    private List<Map<String, String>> readUserFile() throws Exception {
+        File file = new File(userFile);
+        if (!file.exists()) {
+            throw new Exception("用户数据文件不存在");
+        }
+        FileInputStream fileInputStream = new FileInputStream(file);
+        XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
+        XSSFSheet sheet = workbook.getSheetAt(0);
+
+        List<Map<String, String>> userList = new ArrayList<>();
+        for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+            Map<String, String> map = new HashMap<>();
+            Row row = sheet.getRow(i);
+            // 用户名
+            Cell cell0 = row.getCell(0);
+            map.put("loginName", cell0 == null ? null : cell0.getStringCellValue());
+            // 姓名
+            Cell cell1 = row.getCell(1);
+            map.put("realName", cell1 == null ? null : cell1.getStringCellValue());
+            // 手机号
+            Cell cell2 = row.getCell(2);
+            map.put("mobileNumber", cell2 == null ? null : cell2.getStringCellValue());
+            // 密码
+            Cell cell4 = row.getCell(4);
+            map.put("password", cell4 == null ? null : cell4.getStringCellValue());
+            // 角色Code
+            Cell cell5 = row.getCell(5);
+            map.put("roleType", cell5 == null ? null : cell5.getStringCellValue());
+            // 机构code
+            Cell cell8 = row.getCell(8);
+            map.put("orgCode", cell8 == null ? null : cell8.getStringCellValue());
+            // 机构名称
+            Cell cell9 = row.getCell(9);
+            map.put("orgName", cell9 == null ? null : cell9.getStringCellValue());
+            // 命题老师可操作课程代码
+            Cell cell10 = row.getCell(10);
+            map.put("courseCode", cell10 == null ? null : cell10.getStringCellValue());
+            userList.add(map);
+        }
+
+        return userList;
+    }
+
+    @Test
+    public void createCourse() {
+        QueryWrapper<BasicCourse> courseQueryWrapper = new QueryWrapper<>();
+        courseQueryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId);
+        List<BasicCourse> courses = basicCourseService.list(courseQueryWrapper);
+        for (BasicCourse cours : courses) {
+            String a = "INSERT INTO `basic_course` VALUES (%s,1,'%s','%s',124882698949885952,1620464769921,NULL,1620464769921);";
+            System.out.println(String.format(a, SystemConstant.getDbUuid(), cours.getCode(), cours.getName()));
+        }
+    }
+
+}