Ver Fonte

Merge remote-tracking branch 'origin/dev_v3.4.0' into dev_v3.4.0

wangliang há 11 meses atrás
pai
commit
944d806c86
36 ficheiros alterados com 936 adições e 637 exclusões
  1. 12 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/analyze/GradeInitResult.java
  2. 7 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ConditionMapper.java
  3. 1 22
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java
  4. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/GradeInitializeMapper.java
  5. 3 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicExamStudentService.java
  6. 4 19
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamStudentService.java
  7. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskService.java
  8. 4 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/GradeInitializeService.java
  9. 7 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/GradePaperDimensionService.java
  10. 11 7
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/GradePaperStructService.java
  11. 48 43
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java
  12. 13 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ConditionServiceImpl.java
  13. 7 9
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java
  14. 17 25
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java
  15. 2 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  16. 86 60
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeBatchServiceImpl.java
  17. 5 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeInitializeServiceImpl.java
  18. 61 43
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradePaperDimensionServiceImpl.java
  19. 61 37
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradePaperStructServiceImpl.java
  20. 1 5
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/PdfTaskLogicService.java
  21. 257 227
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/ImportLogicServiceImpl.java
  22. 112 0
      distributed-print-business/src/main/resources/mapper/ConditionMapper.xml
  23. 34 69
      distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml
  24. 8 5
      distributed-print-business/src/main/resources/mapper/GradeInitializeMapper.xml
  25. 4 2
      distributed-print-business/src/main/resources/mapper/GradePaperDimensionMapper.xml
  26. 5 4
      distributed-print-business/src/main/resources/mapper/GradePaperStructMapper.xml
  27. 4 4
      distributed-print/src/main/java/com/qmth/distributed/print/api/GradePaperController.java
  28. 3 5
      distributed-print/src/main/java/com/qmth/distributed/print/api/GradePaperDimensionController.java
  29. 34 27
      distributed-print/src/main/java/com/qmth/distributed/print/api/GradePaperStructController.java
  30. 48 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/result/MarkQuestionResult.java
  31. 7 1
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/mapper/MarkQuestionMapper.java
  32. 3 0
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkQuestionService.java
  33. 1 0
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkStudentService.java
  34. 6 0
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkQuestionServiceImpl.java
  35. 7 0
      teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java
  36. 50 0
      teachcloud-mark/src/main/resources/mapper/MarkQuestionMapper.xml

+ 12 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/analyze/GradeInitResult.java

@@ -20,6 +20,10 @@ public class GradeInitResult {
     @ApiModelProperty(value = "考试名称")
     private String examName;
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "课程id")
+    private Long courseId;
+
     @ApiModelProperty(value = "课程编号")
     private String courseCode;
 
@@ -68,6 +72,14 @@ public class GradeInitResult {
         this.examName = examName;
     }
 
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
     public String getCourseCode() {
         return courseCode;
     }

+ 7 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ConditionMapper.java

@@ -74,4 +74,11 @@ public interface ConditionMapper {
 
     List<String> listPaperNumberFromBasicExamStudent(@Param("examId") Long examId, @Param("courseId") Long courseId, @Param("dpr") DataPermissionRule dpr);
 
+    List<BasicCourse> listCourseForPrintCount(@Param("examId") Long examId, @Param("openCollegeId") Long openCollegeId, @Param("dpr") DataPermissionRule dpr);
+
+    List<BasicCourse> listCourseForScanCount(@Param("examId") Long examId, @Param("openCollegeId") Long openCollegeId, @Param("dpr") DataPermissionRule dpr);
+
+    List<String> listPaperNumberForPrintCount(@Param("examId") Long examId, @Param("courseId") Long courseId, @Param("dpr") DataPermissionRule dpr);
+
+    List<String> listPaperNumberForScanCount(@Param("examId") Long examId, @Param("courseId") Long courseId, @Param("dpr") DataPermissionRule dpr);
 }

+ 1 - 22
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java

@@ -24,15 +24,6 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudent> {
     @SuppressWarnings("MybatisXMapperMethodInspection")
     Map<String, Object> getStudentDetail(Long id);
 
-    /**
-     * 根据科目查询考生
-     *
-     * @param schoolId
-     * @param examDetailCourseIds
-     * @return
-     */
-    List<ExamStudentCourseDto> queryBySchoolIdAndExamDetailCourseIds(@Param("schoolId") Long schoolId, @Param("examDetailCourseIds") List<Long> examDetailCourseIds);
-
     /**
      * 根据班级id查询考生,班级可以是教学班或行政班(两表查)
      *
@@ -43,21 +34,9 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudent> {
     List<ExamStudent> listExamStudentBySchoolIdAndClazzId(@Param("schoolId") Long schoolId, @Param("classId") String classId);
 
 
-    @SuppressWarnings("MybatisXMapperMethodInspection")
-    List<ExamStudentCourseClassDto> listExamStudentByPaperNumberAndPaperType(@Param("batchId") Long batchId, @Param("examId") Long examId, @Param("paperNumber") String paperNumber,
-                                                                             @Param("paperType") String paperType);
+    List<ExamStudentCourseClassDto> listMarkStudentInfo(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("paperType") String paperType);
 
     List<ExamStudent> listByExamDetailCourseIdNotIntMarkStudent(@Param("examDetailCourseId") Long examDetailCourseId, @Param("paperType") String paperType);
 
-    /**
-     * 查询班级和老师信息
-     *
-     * @param examId
-     * @param courseCode
-     * @param paperNumber
-     * @return
-     */
-    ExamStudentDto queryExamStudent(@Param("examId") Long examId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber);
-
     List<ExamStudentInfo> listByExamDetailCourseId(Long examDetailCourseId);
 }

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/GradeInitializeMapper.java

@@ -21,7 +21,7 @@ public interface GradeInitializeMapper {
      * @param iPage      分页参数
      * @param semesterId 学期id
      * @param examId     考试id
-     * @param courseCode 课程编号
+     * @param courseId 课程id
      * @param dpr     命题教师id
      * @param schoolId   学校id
      * @return 结果
@@ -29,7 +29,7 @@ public interface GradeInitializeMapper {
     IPage<GradeInitResult> findNeedAnalyzedPaper(@Param("iPage") Page<GradeInitResult> iPage,
                                                  @Param("semesterId") Long semesterId,
                                                  @Param("examId") Long examId,
-                                                 @Param("courseCode") String courseCode,
+                                                 @Param("courseId") Long courseId,
                                                  @Param("dpr") DataPermissionRule dpr,
                                                  @Param("schoolId") Long schoolId);
 

+ 3 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicExamStudentService.java

@@ -66,7 +66,7 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
      * @param requestUser           请求人
      * @return 考生字典
      */
-    BasicExamStudent editEntityHelp(BasicExamStudentParam basicExamStudentParam, BasicExam basicExam, List<String> oldPaperNumberList, SysUser requestUser);
+    BasicExamStudent editEntityHelp(BasicExamStudentParam basicExamStudentParam, BasicExam basicExam, SysUser requestUser);
 
     List<BasicExamStudent> listByExamIdAndPaperNumber(Long examId, String paperNumber);
 
@@ -93,4 +93,6 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
     ExamStudentDto queryExamStudent(Long examId, Long courseId, String paperNumber);
 
     List<BasicExamStudent> listByExamIdAndCourseIdAndTeachClassName(Long examId, Long courseId, String teachClassName);
+
+    void clearPaperNumberAndPaperType(List<Long> ids);
 }

+ 4 - 19
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamStudentService.java

@@ -25,34 +25,19 @@ public interface ExamStudentService extends IService<ExamStudent> {
 
     Map<String, Object> getStudentDetail(Long id);
 
-    /**
-     * 根据科目查询考生
-     *
-     * @param schoolId
-     * @param examDetailCourseIds
-     * @return
-     */
-    List<ExamStudentCourseDto> queryBySchoolIdAndExamDetailCourseIds(Long schoolId, List<Long> examDetailCourseIds);
-
     void removeByExamDetailCourseId(Long id);
 
     List<ExamStudent> listByExamDetailCourseIdNotIntMarkStudent(Long examDetailCourseId, String paperType);
 
     List<ExamStudent> listByExamDetailCourseId1(Long examDetailCourseId);
 
-    /**
-     * 查询班级和老师信息
-     *
-     * @param examId
-     * @param courseCode
-     * @param paperNumber
-     * @return
-     */
-    ExamStudentDto queryExamStudent(Long examId, String courseCode, String paperNumber);
-
     List<ExamStudent> saveStudentForExamApply(ExamTask examTask, String extendFields, List<Long> examTaskStudentObjectParamList, Long examDetailCourseId, SysUser sysUser);
 
     List<ExamStudentInfo> listByExamDetailCourseId(Long examDetailCourseId);
 
     void updateAttachmentIdById(ExamStudentInfo t);
+
+    int countByExamIdAndPaperNumberAndStudentCode(Long examId, String paperNumber, String studentCode);
+
+    void deleteByBasicStudentId(Long basicStudentId);
 }

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

@@ -176,7 +176,7 @@ public interface ExamTaskService extends IService<ExamTask> {
 
     List<String> listPaperNumber(String param, List<Long> printPlanIdList);
 
-    ExamTask getByExamIdAndCourseCodeAndPaperNumber(Long examId, String courseCode, String paperNumber);
+    ExamTask getByExamIdAndPaperNumber(Long examId, String paperNumber);
 
     ExamTask getByExamIdAndCourseIdAndPaperNumber(Long examId, Long courseId, String paperNumber);
 

+ 4 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/GradeInitializeService.java

@@ -17,13 +17,14 @@ public interface GradeInitializeService {
      *
      * @param semesterId  学期id
      * @param examId      考试id
-     * @param courseCode  课程编号
+     * @param courseId    课程id
      * @param requestUser 请求的命题老师
      * @return 试卷结果
      */
-    IPage<GradeInitResult> findNeedAnalyzedPaper(Long semesterId, Long examId, String courseCode, SysUser requestUser, int pageNumber, int pageSize);
+    IPage<GradeInitResult> findNeedAnalyzedPaper(Long semesterId, Long examId, Long courseId, SysUser requestUser, int pageNumber, int pageSize);
 
     long countByPropositionTeacherId(GradeAnalyzePaperStatusEnum status, Boolean ready);
 
-    IPage<GradeInitResult> listNeedAnalyzedPaperToWork(SysUser requestUser, Integer pageNumber, Integer pageSize, GradeAnalyzePaperStatusEnum status, Boolean ready);
+    IPage<GradeInitResult> listNeedAnalyzedPaperToWork(SysUser requestUser, Integer pageNumber, Integer pageSize,
+            GradeAnalyzePaperStatusEnum status, Boolean ready);
 }

+ 7 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/GradePaperDimensionService.java

@@ -31,7 +31,8 @@ public interface GradePaperDimensionService extends IService<GradePaperDimension
      * @param requestUser 请求用户
      * @return 结果集
      */
-    List<GradePaperDimensionResult> findGradePaperDimensionList(Long examId, String paperNumber, String paperType, SysUser requestUser);
+    List<GradePaperDimensionResult> findGradePaperDimensionList(Long examId, String paperNumber, String paperType,
+            SysUser requestUser);
 
     /**
      * 批量保存分析试卷维度数据
@@ -51,7 +52,8 @@ public interface GradePaperDimensionService extends IService<GradePaperDimension
      * @param paperName   试卷名称
      * @param requestUser 请求用户
      */
-    void importGradePaperKnowledgeDimension(MultipartFile file, Long examId, String paperNumber, String paperType, String paperName, SysUser requestUser) throws IOException, NoSuchFieldException;
+    void importGradePaperKnowledgeDimension(MultipartFile file, Long examId, String paperNumber, String paperType,
+            String paperName, SysUser requestUser) throws IOException, NoSuchFieldException;
 
     /**
      * 分析 - 试卷能力维度数据导入
@@ -68,11 +70,10 @@ public interface GradePaperDimensionService extends IService<GradePaperDimension
     /**
      * 分析 - 试卷维度模板导出
      *
-     * @param courseCode    试卷编号
-     * @param courseName    试卷名称
+     * @param courseId      课程id
      * @param dimensionType 维度类型
      */
-    void exportGradePaperDimensionTemplate(String courseCode, String courseName, DimensionEnum dimensionType) throws Exception;
+    void exportGradePaperDimensionTemplate(Long courseId, DimensionEnum dimensionType) throws Exception;
 
-    List<PaperDimension> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId,Long examId, String paperNumber, String paperType);
+    List<PaperDimension> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId, Long examId, String paperNumber, String paperType);
 }

+ 11 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/GradePaperStructService.java

@@ -5,6 +5,7 @@ import com.qmth.distributed.print.business.bean.dto.open.PaperStructure;
 import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructParam;
 import com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructResult;
 import com.qmth.distributed.print.business.entity.GradePaperStruct;
+import com.qmth.teachcloud.common.bean.result.MarkQuestionResult;
 import com.qmth.teachcloud.common.entity.MarkQuestion;
 import com.qmth.teachcloud.common.entity.SysUser;
 import org.springframework.web.multipart.MultipartFile;
@@ -29,10 +30,11 @@ public interface GradePaperStructService extends IService<GradePaperStruct> {
      * @param paperNumber      试卷编号
      * @param paperType        试卷类型
      * @param requestUser      请求的用户
-     * @param markQuestionList
+     * @param markQuestionList markQuestionList
      * @return 结果
      */
-    List<GradePaperStructResult> findGradePaperStructureResultList(Long examId, String paperNumber, String paperType, SysUser requestUser, List<MarkQuestion> markQuestionList);
+    List<GradePaperStructResult> findGradePaperStructureResultList(Long examId, String paperNumber, String paperType,
+            SysUser requestUser, List<MarkQuestionResult> markQuestionList);
 
     /**
      * 批量保存分析试卷结构
@@ -46,12 +48,14 @@ public interface GradePaperStructService extends IService<GradePaperStruct> {
      * 分析 - 试卷结构数据导入
      *
      * @param file        excel 文件
+     * @param examId      考试id
      * @param paperNumber 试卷编号
      * @param paperType   试卷类型
      * @param paperName   试卷名称
      * @param requestUser 请求用户
      */
-    void importGradePaperStruct(MultipartFile file, String paperNumber, String paperType, String paperName, SysUser requestUser) throws IOException, NoSuchFieldException;
+    void importGradePaperStruct(MultipartFile file, Long examId, String paperNumber, String paperType, String paperName,
+            SysUser requestUser) throws IOException, NoSuchFieldException;
 
     /**
      * 分析 - 试卷结构模板导出
@@ -59,12 +63,12 @@ public interface GradePaperStructService extends IService<GradePaperStruct> {
      * @param paperNumber      试卷编号
      * @param paperType        试卷类型
      * @param requestUser      请求用户
-     * @param markQuestionList
+     * @param markQuestionList markQuestionList
      * @throws Exception 异常
      */
-    void exportGradePaperStructTemplate(Long examId, String paperNumber, String paperType, SysUser requestUser, List<MarkQuestion> markQuestionList) throws Exception;
+    void exportGradePaperStructTemplate(Long examId, String paperNumber, String paperType, SysUser requestUser, List<MarkQuestionResult> markQuestionList) throws Exception;
 
-    List<PaperStructure> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId,Long examId, String paperNumber, String paperType);
+    List<PaperStructure> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId, Long examId, String paperNumber, String paperType);
 
     /**
      * 更新云阅卷试卷结构
@@ -76,7 +80,7 @@ public interface GradePaperStructService extends IService<GradePaperStruct> {
      * @param schoolId         学校id
      * @param paperNumber      试卷编号
      * @param paperType        试卷类型
-     * @param markQuestionList
+     * @param markQuestionList markQuestionList
      */
     void updateExamCloudPaperStruct(Long schoolId, String paperNumber, String paperType, List<MarkQuestion> markQuestionList);
 }

+ 48 - 43
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.Update;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -84,6 +85,8 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     private MarkTaskService markTaskService;
     @Resource
     private ExamTaskDetailService examTaskDetailService;
+    @Resource
+    private ExamStudentService examStudentService;
 
     @Override
     public IPage<BasicExamStudentResult> page(Long semesterId, Long examId, Long courseId, String paperNumber,
@@ -150,8 +153,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     public Long save(BasicExamStudentParam basicExamStudentParam, SysUser requestUser) {
         BasicExam basicExam = basicExamService.getById(basicExamStudentParam.getExamId());
         BasicExamStudent basicExamStudentOld = this.getById(basicExamStudentParam.getId());
-        List<String> oldPaperNumberList = new ArrayList<>();
-        BasicExamStudent basicExamStudent = this.editEntityHelp(basicExamStudentParam, basicExam, oldPaperNumberList, requestUser);
+        BasicExamStudent basicExamStudent = this.editEntityHelp(basicExamStudentParam, basicExam, requestUser);
         this.saveOrUpdate(basicExamStudent);
         // 更新扫描阅卷数据
         this.updateMarkData(basicExam.getId(), Arrays.asList(basicExamStudent), Arrays.asList(basicExamStudentOld.getPaperNumber()), requestUser.getId());
@@ -195,7 +197,8 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
                         throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
                     }
                 }
-                markStudentService.deleteByExamIdAndPaperNumberAndStudentCode(basicExamStudent.getExamId(), basicExamStudent.getPaperNumber(), basicExamStudent.getStudentCode());
+                examStudentService.deleteByBasicStudentId(basicExamStudent.getId());
+                markStudentService.deleteByBasicStudentId(basicExamStudent.getId());
                 // 更新扫描数据
                 long count = markStudentService.countByExamIdAndPaperNumber(basicExamStudent.getExamId(), basicExamStudent.getPaperNumber(), null);
                 if (count == 0) {
@@ -218,7 +221,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
      * @return 考生对象
      */
     @Override
-    public BasicExamStudent editEntityHelp(BasicExamStudentParam basicExamStudentParam, BasicExam basicExam, List<String> oldPaperNumberList, SysUser requestUser) {
+    public BasicExamStudent editEntityHelp(BasicExamStudentParam basicExamStudentParam, BasicExam basicExam, SysUser requestUser) {
         List<String> errorMsgList = new ArrayList<>();
         Long schoolId = requestUser.getSchoolId();
         Long requestUserId = requestUser.getId();
@@ -226,6 +229,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         String paperNumber = basicExamStudentParam.getPaperNumber();
         String teacherName = basicExamStudentParam.getTeacherName();
         String teacherCode = basicExamStudentParam.getTeacherCode();
+        String paperType = basicExamStudentParam.getPaperType();
 
         Long teacherId = null;
         if (SystemConstant.strNotNull(teacherCode) && !SystemConstant.strNotNull(teacherName)) {
@@ -237,10 +241,10 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         if (StringUtils.isNotBlank(teacherCode) && StringUtils.isNotBlank(teacherName)) {
             SysUser sysUser = sysUserService.getByLoginName(schoolId, teacherCode);
             if (sysUser == null) {
-                errorMsgList.add("任课老师工号[" + teacherCode + "]不存在");
+                errorMsgList.add("任课老师工号[" + teacherCode + "]用户不存在");
             } else {
                 if (!sysUser.getEnable()) {
-                    errorMsgList.add("任课老师工号[" + teacherCode + "]已禁用");
+                    errorMsgList.add("任课老师工号[" + teacherCode + "]用户已禁用");
                 } else if (!sysUser.getRealName().equals(teacherName)) {
                     errorMsgList.add("任课老师[" + teacherName + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
                 } else {
@@ -266,12 +270,11 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
             ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamIdAndCourseIdAndPaperNumber(basicExamStudentParam.getExamId(), null, basicExamStudentParam.getPaperNumber());
             if (examTaskDetail != null) {
                 if (!examTaskDetail.getPaperType().contains(basicExamStudentParam.getPaperType())) {
-                    throw ExceptionResultEnum.ERROR.exception("试卷编号[" + basicExamStudentParam.getPaperNumber() + "]的命题任务卷型为[" + examTaskDetail.getPaperType() + "],只能从中取一个");
+                    throw ExceptionResultEnum.ERROR.exception("试卷编号[" + basicExamStudentParam.getPaperNumber() + "]的命题任务卷型为[" + examTaskDetail.getPaperType() + "]");
                 }
             }
         }
 
-
         BasicExamStudent basicExamStudent = new BasicExamStudent();
         BeanUtils.copyProperties(basicExamStudentParam, basicExamStudent);
         basicExamStudent.setSchoolId(schoolId);
@@ -279,36 +282,27 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
 
         // 同一课程+教学班下只能有一位任课老师
         List<BasicExamStudent> basicExamStudentList = this.listByExamIdAndCourseIdAndTeachClassName(basicExamStudent.getExamId(), basicExamStudent.getCourseId(), basicExamStudent.getTeachClassName());
-        if(CollectionUtils.isNotEmpty(basicExamStudentList)){
-            List<Long> teacherIds = basicExamStudentList.stream().map(BasicExamStudent::getTeacherId).distinct().collect(Collectors.toList());
-            if(teacherIds.size() >1){
-                throw ExceptionResultEnum.ERROR.exception("课程下同一教学班,只允许有一个任课老师");
-            } else{
-                if(basicExamStudent.getTeacherId() != null && teacherIds.get(0) == null){
-                    throw ExceptionResultEnum.ERROR.exception("教学班其它学生任课老师为空,本次不填任课老师信息");
-                } else if (basicExamStudent.getTeacherId() == null && teacherIds.get(0) != null){
-                    throw ExceptionResultEnum.ERROR.exception("教学班其它学生任课老师不为空,任课老师必填");
-                } else if (basicExamStudent.getTeacherId() != null && teacherIds.get(0) != null && basicExamStudent.getTeacherId().equals(teacherIds.get(0))){
-                    throw ExceptionResultEnum.ERROR.exception("任课老师与教学班其它学生任课老师不一致");
-                }
-            }
-        }
+//        if (CollectionUtils.isNotEmpty(basicExamStudentList)) {
+//            List<Long> teacherIds = basicExamStudentList.stream().filter(m -> m.getTeacherId() != null).map(BasicExamStudent::getTeacherId).distinct().collect(Collectors.toList());
+//            if (teacherIds.size() > 1 || (basicExamStudent.getTeacherId() != null && teacherIds.get(0) != null && basicExamStudent.getTeacherId().equals(teacherIds.get(0)))) {
+//                throw ExceptionResultEnum.ERROR.exception("同课程同教学班,只允许设置一个任课老师");
+//            }
+//        }
 
         if (SystemConstant.longNotNull(basicExamStudent.getId())) {
             // 编辑 (学号不可更改)
             BasicExamStudent dbBasicExamStudent = this.getById(basicExamStudent.getId());
             if (Objects.isNull(dbBasicExamStudent)) {
-                throw ExceptionResultEnum.ERROR.exception("考生不存在");
+                throw ExceptionResultEnum.ERROR.exception("未查询到此考生");
             }
             if (!basicExamStudent.getStudentCode().equals(dbBasicExamStudent.getStudentCode())) {
-                throw ExceptionResultEnum.ERROR.exception("学号不可更改");
+                throw ExceptionResultEnum.ERROR.exception("不允许修改学号");
             }
-            MarkStudent markStudent = markStudentService.findByExamIdAndPaperNumberAndStudentCode(dbBasicExamStudent.getExamId(), dbBasicExamStudent.getPaperNumber(), dbBasicExamStudent.getStudentCode());
-            if (markStudent != null && markStudent.getUpload() && StringUtils.isNotBlank(paperNumber) && !paperNumber.equals(dbBasicExamStudent.getPaperNumber())) {
-                throw ExceptionResultEnum.ERROR.exception("考生已扫描,不能修改试卷编号");
+            if (StringUtils.isNotBlank(dbBasicExamStudent.getPaperNumber()) && dbBasicExamStudent.getPaperNumber().equals(paperNumber)) {
+                throw ExceptionResultEnum.ERROR.exception("不允许修改试卷编号");
             }
-            if (ExamModelEnum.MODEL4.equals(basicExam.getExamModel()) && dbBasicExamStudent != null) {
-                oldPaperNumberList.add(dbBasicExamStudent.getPaperNumber());
+            if (StringUtils.isNotBlank(dbBasicExamStudent.getPaperType()) && dbBasicExamStudent.getPaperNumber().equals(paperType)) {
+                throw ExceptionResultEnum.ERROR.exception("不允许修改卷型");
             }
             basicExamStudent.updateInfo(requestUserId);
         } else {
@@ -316,13 +310,11 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
             if (this.count(new QueryWrapper<BasicExamStudent>().lambda()
                     .eq(BasicExamStudent::getExamId, basicExamStudent.getExamId()).eq(BasicExamStudent::getCourseId, basicExamStudent.getCourseId())
                     .eq(BasicExamStudent::getStudentCode, basicExamStudent.getStudentCode())) > 0) {
-                throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]重复", basicExamStudent.getStudentCode()));
+                throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]考生已存在", basicExamStudent.getStudentCode()));
             }
             basicExamStudent.insertInfo(requestUserId);
         }
 
-        // 校验任课老师
-
         parserRequiredField(basicExamStudent);
         return basicExamStudent;
     }
@@ -424,6 +416,9 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     public void updatePaperNumberAndPaperTypeById(List<ExamStudent> examStudentList) {
         for (ExamStudent examStudent : examStudentList) {
             BasicExamStudent basicExamStudent = this.getById(examStudent.getBasicStudentId());
+            if (StringUtils.isNoneBlank(basicExamStudent.getPaperNumber(), basicExamStudent.getPaperType())) {
+                throw ExceptionResultEnum.ERROR.exception(String.format("试卷编号[%s],学号[%s]考生在试卷编号[%s]生成了印刷任务", examStudent.getPaperNumber(), examStudent.getStudentCode(), basicExamStudent.getPaperNumber()));
+            }
             List<CodeNameEnableValue> requiredFieldList = basicExamStudent.getRequiredFieldList();
             for (CodeNameEnableValue codeNameEnableValue : requiredFieldList) {
                 if (RequiredFieldsEnum.PAPER_NUMBER.getCode().equals(codeNameEnableValue.getCode())) {
@@ -460,17 +455,17 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         }
 
         // 更新历史数据试卷编号
-        if (CollectionUtils.isNotEmpty(oldPaperNumberList)) {
-            for (String paperNumber : oldPaperNumberList) {
-                long studentCount = markStudentService.countByExamIdAndPaperNumber(examId, paperNumber, null);
-                if (studentCount > 0) {
-                    markPaperService.updateStudentCountByExamIdAndPaperNumberAndPaperType(examId, paperNumber, null);
-                    markPaperService.updateUploadCount(examId, paperNumber, markStudentService.countUploadedByExamIdAndPaperNumber(examId, paperNumber));
-                } else {
-                    markPaperService.deleteByExamIdAndPaperNumber(examId, paperNumber);
-                }
-            }
-        }
+//        if (CollectionUtils.isNotEmpty(oldPaperNumberList)) {
+//            for (String paperNumber : oldPaperNumberList) {
+//                long studentCount = markStudentService.countByExamIdAndPaperNumber(examId, paperNumber, null);
+//                if (studentCount > 0) {
+//                    markPaperService.updateStudentCountByExamIdAndPaperNumberAndPaperType(examId, paperNumber, null);
+//                    markPaperService.updateUploadCount(examId, paperNumber, markStudentService.countUploadedByExamIdAndPaperNumber(examId, paperNumber));
+//                } else {
+//                    markPaperService.deleteByExamIdAndPaperNumber(examId, paperNumber);
+//                }
+//            }
+//        }
     }
 
     @Override
@@ -520,4 +515,14 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
                 .eq(BasicExamStudent::getTeachClassName, teachClassName);
         return this.list(queryWrapper);
     }
+
+    @Override
+    public void clearPaperNumberAndPaperType(List<Long> ids) {
+        UpdateWrapper<BasicExamStudent> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().set(BasicExamStudent::getPaperNumber, null)
+                .set(BasicExamStudent::getPaperType, null)
+                .in(BasicExamStudent::getId, ids)
+                .isNull(BasicExamStudent::getPaperType);
+        this.update(updateWrapper);
+    }
 }

+ 13 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ConditionServiceImpl.java

@@ -139,6 +139,12 @@ public class ConditionServiceImpl implements ConditionService {
         // 文档管理(577)
         else if ("577".equals(privilegeIdString)) {
             return conditionMapper.listCourseForDocument(examId, dpr);
+        } // 印刷任务统计(2088)
+        else if ("2088".equals(privilegeIdString)) {
+            return conditionMapper.listCourseForPrintCount(examId, openCollegeId, dpr);
+        } // 扫描任务统计(2089)
+        else if ("2089".equals(privilegeIdString)) {
+            return conditionMapper.listCourseForScanCount(examId, openCollegeId, dpr);
         } else {
             return conditionMapper.listCourse(semesterId, examId, enable, printPlanIds, dpr);
         }
@@ -198,7 +204,13 @@ public class ConditionServiceImpl implements ConditionService {
         // 下载管理(653)
         else if ("653".equals(privilegeIdString)) {
             return conditionMapper.listPaperNumberFromExamTaskByUserIdAndPass(examId, courseId, dpr);
-        } else {
+        } // 印刷任务统计(2088)
+        else if ("2088".equals(privilegeIdString)) {
+            return conditionMapper.listPaperNumberForPrintCount(examId, courseId, dpr);
+        } // 扫描任务统计(2089)
+        else if ("2089".equals(privilegeIdString)) {
+            return conditionMapper.listPaperNumberForScanCount(examId, courseId, dpr);
+        }else {
             return conditionMapper.listPaperNumber(semesterId, examId, courseId, printPlanIds, dpr);
         }
     }

+ 7 - 9
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java

@@ -74,8 +74,8 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
 
     @Resource
     private ExamDetailCourseService examDetailCourseService;
-
-
+    @Resource
+    private BasicExamStudentService basicExamStudentService;
     @Resource
     private BasicExamRuleService basicExamRuleService;
 
@@ -94,9 +94,6 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     @Resource
     private BasicAttachmentService basicAttachmentService;
 
-    @Resource
-    private SysOrgService sysOrgService;
-
     @Resource
     RedisCounterUtil redisCounterUtil;
 
@@ -897,9 +894,9 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
         if (ExamDetailStatusEnum.WAITING.equals(examDetail.getStatus())) {
             throw ExceptionResultEnum.ERROR.exception("考场数据已提交印刷,请先撤回后再删除");
         } else if (ExamDetailStatusEnum.PRINTING.equals(examDetail.getStatus())) {
-            throw ExceptionResultEnum.ERROR.exception("考场数据已提交印刷,正在打印中,无法删除");
+            throw ExceptionResultEnum.ERROR.exception("考场数据已提交印刷,正在打印中,不允许删除");
         } else if (ExamDetailStatusEnum.FINISH.equals(examDetail.getStatus()) && examDetail.getNormal()) {
-            throw ExceptionResultEnum.ERROR.exception("考场数据已打印完成,无法删除");
+            throw ExceptionResultEnum.ERROR.exception("考场数据已打印完成,不允许删除");
         }
         //删除exam_detail
         this.removeById(id);
@@ -931,13 +928,14 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
                             markPaperPackageService.deleteByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber());
                             markQuestionService.deleteByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber());
                             scanAnswerCardService.deleteByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber());
+                        } else {
                             for (String paperType : examDetailCourse.getPaperNumber().split(",")) {
                                 markPaperService.updateStudentCountByExamIdAndPaperNumberAndPaperType(examDetail.getExamId(), examDetailCourse.getPaperNumber(), paperType);
                             }
                         }
-                        ;
+                        // 清空考生管理中试卷编号和卷型
+                        basicExamStudentService.clearPaperNumberAndPaperType(examStudents.stream().filter(m->m.getBasicStudentId() != null).map(ExamStudent::getBasicStudentId).collect(Collectors.toList()));
                     }
-
                     examStudentService.removeByIds(examStudentIds);
                 }
             }

+ 17 - 25
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java

@@ -17,6 +17,7 @@ import com.qmth.distributed.print.business.service.ExamStudentService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.mark.entity.MarkStudent;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
@@ -69,18 +70,6 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         return map;
     }
 
-    /**
-     * 根据科目查询考生
-     *
-     * @param schoolId
-     * @param examDetailCourseIds
-     * @return
-     */
-    @Override
-    public List<ExamStudentCourseDto> queryBySchoolIdAndExamDetailCourseIds(Long schoolId, List<Long> examDetailCourseIds) {
-        return examStudentMapper.queryBySchoolIdAndExamDetailCourseIds(schoolId, examDetailCourseIds);
-    }
-
     @Override
     public void removeByExamDetailCourseId(Long id) {
         UpdateWrapper<ExamStudent> updateWrapper = new UpdateWrapper<>();
@@ -101,19 +90,6 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         return this.list(queryWrapper);
     }
 
-    /**
-     * 查询班级和老师信息
-     *
-     * @param examId
-     * @param courseCode
-     * @param paperNumber
-     * @return
-     */
-    @Override
-    public ExamStudentDto queryExamStudent(Long examId, String courseCode, String paperNumber) {
-        return this.baseMapper.queryExamStudent(examId, courseCode, paperNumber);
-    }
-
     @Override
     public List<ExamStudent> saveStudentForExamApply(ExamTask examTask, String extendFields, List<Long> examTaskStudentObjectParamList, Long examDetailCourseId, SysUser sysUser) {
         List<ExamStudent> examStudentList = new ArrayList<>();
@@ -148,4 +124,20 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         updateWrapper.lambda().set(ExamStudent::getAttachmentId, t.getAttachmentId()).eq(ExamStudent::getId, t.getExamStudentId());
         this.update(updateWrapper);
     }
+
+    @Override
+    public int countByExamIdAndPaperNumberAndStudentCode(Long examId, String paperNumber, String studentCode) {
+        QueryWrapper<ExamStudent> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ExamStudent::getExamId, examId)
+                .eq(ExamStudent::getPaperNumber, paperNumber)
+                .eq(ExamStudent::getStudentCode, studentCode);
+        return this.count(queryWrapper);
+    }
+
+    @Override
+    public void deleteByBasicStudentId(Long basicStudentId) {
+        UpdateWrapper<ExamStudent> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().eq(ExamStudent::getBasicStudentId, basicStudentId);
+        this.remove(updateWrapper);
+    }
 }

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

@@ -1647,14 +1647,10 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     }
 
     @Override
-    public ExamTask getByExamIdAndCourseCodeAndPaperNumber(Long examId, String courseCode, String paperNumber) {
+    public ExamTask getByExamIdAndPaperNumber(Long examId,String paperNumber) {
         QueryWrapper<ExamTask> queryWrapper = new QueryWrapper<>();
         LambdaQueryWrapper<ExamTask> lambdaQueryWrapper = queryWrapper.lambda();
-        lambdaQueryWrapper.eq(ExamTask::getExamId, examId);
-        if (StringUtils.isNotBlank(courseCode)) {
-            lambdaQueryWrapper.eq(ExamTask::getCourseId, courseCode);
-        }
-        lambdaQueryWrapper.eq(ExamTask::getPaperNumber, paperNumber);
+        lambdaQueryWrapper.eq(ExamTask::getExamId, examId).eq(ExamTask::getPaperNumber, paperNumber);
         return this.getOne(queryWrapper);
     }
 

+ 86 - 60
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeBatchServiceImpl.java

@@ -36,6 +36,7 @@ import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.ExcelUtil;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.excel.ExcelError;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.poi.ss.usermodel.*;
@@ -98,7 +99,8 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
     public IPage<GradeBatchResult> gradeBatchPage(Long semesterId, Long examId, String batchName, int pageNumber, int pageSize, SysUser requestUser) {
         batchName = SystemConstant.translateSpecificSign(batchName);
         DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission();
-        IPage<GradeBatchResult> page = this.baseMapper.findGradeBatchPage(new Page<>(pageNumber, pageSize), semesterId, examId, batchName, requestUser.getSchoolId(), dpr);
+        IPage<GradeBatchResult> page = this.baseMapper.findGradeBatchPage(new Page<>(pageNumber, pageSize), semesterId,
+                examId, batchName, requestUser.getSchoolId(), dpr);
         for (GradeBatchResult record : page.getRecords()) {
             String txtPath = record.getReportFilePath();
             if (SystemConstant.strNotNull(txtPath)) {
@@ -157,11 +159,34 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
         }
 
         List<ExamStudentCourseClassDto> finalList = new ArrayList<>();
+        List<GradeBatchStudentClazz> gradeBatchStudentClazzList = gradeBatchStudentClazzService.list(
+                new QueryWrapper<GradeBatchStudentClazz>().lambda().eq(GradeBatchStudentClazz::getBatchId, batchId));
+
         for (GradeBatchPaper gradeBatchPaper : gradeBatchPaperList) {
-            List<ExamStudentCourseClassDto> examStudentClassList = examStudentMapper.listExamStudentByPaperNumberAndPaperType(
-                    batchId, gradeBatchPaper.getExamId(), gradeBatchPaper.getPaperNumber(), gradeBatchPaper.getPaperType());
-            if (!examStudentClassList.isEmpty()) {
-                finalList.addAll(examStudentClassList);
+            String paperNumber = gradeBatchPaper.getPaperNumber();
+            String paperType = gradeBatchPaper.getPaperType();
+            Long examId = gradeBatchPaper.getExamId();
+
+            List<ExamStudentCourseClassDto> examStudentClassList = examStudentMapper.listMarkStudentInfo(examId,
+                    paperNumber, paperType);
+            for (ExamStudentCourseClassDto examStudentCourseClassDto : examStudentClassList) {
+                String clazzName = examStudentCourseClassDto.getClazzName();
+                if (!SystemConstant.strNotNull(clazzName)) {
+                    throw ExceptionResultEnum.ERROR.exception(
+                            String.format("试卷编号为[%s],试卷类型为[%s]的考生缺少教学班信息", paperNumber, paperType));
+                }
+
+                List<GradeBatchStudentClazz> gradeBatchStudentClazzPaperInfoList = gradeBatchStudentClazzList.stream()
+                        .filter(e -> e.getPaperNumber().equals(paperNumber) && e.getPaperType().equals(paperType) && e.getClazzName().equals(clazzName)).collect(Collectors.toList());
+
+                if (CollectionUtils.isNotEmpty(gradeBatchStudentClazzPaperInfoList)) {
+                    GradeBatchStudentClazz gradeBatchStudentClazzPaperInfo = gradeBatchStudentClazzPaperInfoList.get(0);
+                    String dbTeacherName = gradeBatchStudentClazzPaperInfo.getTeacherName();
+                    String dbTeacherNumber = gradeBatchStudentClazzPaperInfo.getTeacherNumber();
+                    examStudentCourseClassDto.setTeacherName(dbTeacherName);
+                    examStudentCourseClassDto.setTeacherNumber(dbTeacherNumber);
+                }
+                finalList.add(examStudentCourseClassDto);
             }
         }
 
@@ -224,7 +249,7 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
 
         XSSFRow headRow = sheet.createRow(0);
         // 表头
-        String[] fieldsNameList = {"课程代码", "课程名称", "试卷编号", "试卷类型", "班级名称", "任课老师", "任课老师工号"};
+        String[] fieldsNameList = { "课程代码", "课程名称", "试卷编号", "试卷类型", "班级名称", "任课老师", "任课老师工号" };
         for (int i = 0; i < fieldsNameList.length; i++) {
             XSSFCell cell = headRow.createCell(i);
             cell.setCellValue(fieldsNameList[i]);
@@ -297,57 +322,59 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
     public void uploadFile(Long batchId, MultipartFile file) throws IOException, NoSuchFieldException {
         List<GradeBatchStudentClazzDto> list = new ArrayList<>();
         Map<String, String> teacherMap = new HashMap<>();
-        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradeBatchStudentClazzDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
-            List<ExcelError> excelErrorTemp = new ArrayList<>();
-            // 只允许导入一个sheet
-            if (finalExcelList.size() > 1) {
-                throw ExceptionResultEnum.ERROR.exception("excel中只允许有一个sheet");
-            }
-
-            for (int i = 0; i < finalExcelList.size(); i++) {
-                LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
-                List<Object> gradeBatchStudentTempList = excelMap.get(i);
-                for (int y = 0; y < Objects.requireNonNull(gradeBatchStudentTempList).size(); y++) {
-                    GradeBatchStudentClazzDto gradeBatchStudentClazzDto = (GradeBatchStudentClazzDto) gradeBatchStudentTempList.get(y);
-                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getCourseCode())) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程代码]必填"));
-                    }
-                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getCourseName())) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程名称]必填"));
-                    }
-                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getPaperNumber())) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[试卷编号]必填"));
-                    }
-                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getPaperType())) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[试卷类型]必填"));
+        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradeBatchStudentClazzDto.class),
+                (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+                    List<ExcelError> excelErrorTemp = new ArrayList<>();
+                    // 只允许导入一个sheet
+                    if (finalExcelList.size() > 1) {
+                        throw ExceptionResultEnum.ERROR.exception("excel中只允许有一个sheet");
                     }
-                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getClazzName())) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[班级名称]必填"));
-                    }
-                    String teacherName = gradeBatchStudentClazzDto.getTeacherName();
-                    if (StringUtils.isBlank(teacherName)) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师]必填"));
-                    }
-                    String teacherNumber = gradeBatchStudentClazzDto.getTeacherNumber();
-                    if (StringUtils.isBlank(teacherNumber)) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师工号]必填"));
-                    }
-                    if (teacherMap.containsKey(teacherNumber) && !teacherName.equals(teacherMap.get(teacherNumber))) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel中同一个任课老师工号有多个姓名"));
-                    }
-
-                    teacherMap.put(gradeBatchStudentClazzDto.getTeacherNumber(), gradeBatchStudentClazzDto.getTeacherName());
 
-                    list.add(gradeBatchStudentClazzDto);
-                }
-            }
+                    for (int i = 0; i < finalExcelList.size(); i++) {
+                        LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
+                        List<Object> gradeBatchStudentTempList = excelMap.get(i);
+                        for (int y = 0; y < Objects.requireNonNull(gradeBatchStudentTempList).size(); y++) {
+                            GradeBatchStudentClazzDto gradeBatchStudentClazzDto = (GradeBatchStudentClazzDto) gradeBatchStudentTempList.get(
+                                    y);
+                            if (StringUtils.isBlank(gradeBatchStudentClazzDto.getCourseCode())) {
+                                excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程代码]必填"));
+                            }
+                            if (StringUtils.isBlank(gradeBatchStudentClazzDto.getCourseName())) {
+                                excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程名称]必填"));
+                            }
+                            if (StringUtils.isBlank(gradeBatchStudentClazzDto.getPaperNumber())) {
+                                excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[试卷编号]必填"));
+                            }
+                            if (StringUtils.isBlank(gradeBatchStudentClazzDto.getPaperType())) {
+                                excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[试卷类型]必填"));
+                            }
+                            if (StringUtils.isBlank(gradeBatchStudentClazzDto.getClazzName())) {
+                                excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[班级名称]必填"));
+                            }
+                            String teacherName = gradeBatchStudentClazzDto.getTeacherName();
+                            if (StringUtils.isBlank(teacherName)) {
+                                excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师]必填"));
+                            }
+                            String teacherNumber = gradeBatchStudentClazzDto.getTeacherNumber();
+                            if (StringUtils.isBlank(teacherNumber)) {
+                                excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师工号]必填"));
+                            }
+                            if (teacherMap.containsKey(teacherNumber) && !teacherName.equals(teacherMap.get(teacherNumber))) {
+                                excelErrorTemp.add(new ExcelError(y + 1, "excel中同一个任课老师工号有多个姓名"));
+                            }
+
+                            teacherMap.put(gradeBatchStudentClazzDto.getTeacherNumber(), gradeBatchStudentClazzDto.getTeacherName());
+
+                            list.add(gradeBatchStudentClazzDto);
+                        }
+                    }
 
-            if (excelErrorTemp.size() > 0) {
-                List<String> errors = excelErrorTemp.stream().map(ExcelError::getExcelErrorType).collect(Collectors.toList());
-                throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
-            }
-            return finalExcelList;
-        },1);
+                    if (excelErrorTemp.size() > 0) {
+                        List<String> errors = excelErrorTemp.stream().map(ExcelError::getExcelErrorType).collect(Collectors.toList());
+                        throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
+                    }
+                    return finalExcelList;
+                }, 1);
 
         executeImportGradeBatchStudent(batchId, list);
     }
@@ -420,8 +447,7 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
 
             List<Long> orgIds = dtoList.stream().map(m -> m.getCourseCode() + "##" + m.getPaperNumber()).distinct().map(m -> {
                 String[] strings = m.split("##");
-                // todo xf 20230413
-                ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(gradeBatch.getExamId(), strings[0], strings[1]);
+                ExamTask examTask = examTaskService.getByExamIdAndPaperNumber(gradeBatch.getExamId(), strings[1]);
                 SysOrg sysOrg = sysOrgService.findCollegeLevelOrgByOrgId(examTask.getTeachingRoomId());
                 return sysOrg.getId();
             }).distinct().collect(Collectors.toList());
@@ -444,13 +470,13 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
                 SysOrg userSecondaryOrg = sysOrgService.findCollegeLevelOrgByOrgId(orgId);
                 Long userSecondaryOrgId = userSecondaryOrg.getId();
                 if (!courseSecondaryOrgId.equals(userSecondaryOrgId)) {
-                    throw ExceptionResultEnum.ERROR.exception("导入的excel中,工号为【" + key[0] + "】的用户所在学院为【" + userSecondaryOrg.getName() +
-                            "】,和课程所在学院【" + sysOrgService.getById(courseSecondaryOrgId).getName() + "】不一致");
+                    throw ExceptionResultEnum.ERROR.exception(
+                            "导入的excel中,工号为【" + key[0] + "】的用户所在学院为【" + userSecondaryOrg.getName() + "】,和课程所在学院【" + sysOrgService.getById(courseSecondaryOrgId).getName() + "】不一致");
                 }
                 String dbRealName = sysUser.getRealName();
                 if (!dbRealName.equals(key[1])) {
-                    throw ExceptionResultEnum.ERROR.exception("导入的excel中,工号为【" + key[0] + "】的用户姓名【" + key[1] +
-                            "】,与系统用户姓名【" + dbRealName + "】不一致 请检查excel数据");
+                    throw ExceptionResultEnum.ERROR.exception(
+                            "导入的excel中,工号为【" + key[0] + "】的用户姓名【" + key[1] + "】,与系统用户姓名【" + dbRealName + "】不一致 请检查excel数据");
                 }
                 sysUser.setRealName(key[1]);
                 sysUser.setEnable(true);

+ 5 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeInitializeServiceImpl.java

@@ -32,15 +32,17 @@ public class GradeInitializeServiceImpl implements GradeInitializeService {
     BasicRoleDataPermissionService basicRoleDataPermissionService;
 
     @Override
-    public IPage<GradeInitResult> findNeedAnalyzedPaper(Long semesterId, Long examId, String courseCode, SysUser requestUser, int pageNumber, int pageSize) {
+    public IPage<GradeInitResult> findNeedAnalyzedPaper(Long semesterId, Long examId, Long courseId, SysUser requestUser, int pageNumber, int pageSize) {
         Long schoolId = requestUser.getSchoolId();
-        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId,requestUser.getId(),ServletUtil.getRequest().getServletPath());
+        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(),
+                ServletUtil.getRequest().getServletPath());
 
         List<String> finished = new ArrayList<>();
         finished.add(GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE.name());
         finished.add(GradeAnalyzePaperStatusEnum.CALCULATING.name());
         finished.add(GradeAnalyzePaperStatusEnum.FINISH_CALCULATE.name());
-        IPage<GradeInitResult> page = gradeInitializeMapper.findNeedAnalyzedPaper(new Page<>(pageNumber, pageSize), semesterId, examId, courseCode, dpr, schoolId);
+        IPage<GradeInitResult> page = gradeInitializeMapper.findNeedAnalyzedPaper(new Page<>(pageNumber, pageSize),
+                semesterId, examId, courseId, dpr, schoolId);
         for (GradeInitResult record : page.getRecords()) {
             String status = record.getStatus();
             if (SystemConstant.strNotNull(status)) {

+ 61 - 43
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradePaperDimensionServiceImpl.java

@@ -15,9 +15,11 @@ import com.qmth.distributed.print.business.mapper.GradePaperDimensionMapper;
 import com.qmth.distributed.print.business.service.GradeBatchPaperService;
 import com.qmth.distributed.print.business.service.GradePaperDimensionService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.DimensionEnum;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.service.BasicCourseService;
 import com.qmth.teachcloud.common.util.ExcelUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
@@ -39,9 +41,13 @@ import java.util.*;
  */
 @Service
 public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimensionMapper, GradePaperDimension> implements GradePaperDimensionService {
+
     @Resource
     private GradeBatchPaperService gradeBatchPaperService;
 
+    @Resource
+    private BasicCourseService basicCourseService;
+
     @Override
     public List<GradePaperDimensionResult> findGradePaperDimensionList(Long examId, String paperNumber, String paperType, SysUser requestUser) {
         return this.baseMapper.findGradePaperDimensionList(examId, paperNumber, paperType, requestUser.getSchoolId());
@@ -58,15 +64,14 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
         List<GradePaperDimensionDatasource> datasource = gradePaperDimensionParam.getDatasource();
 
         gradeBatchPaperService.checkOperateAuth(schoolId, examId, paperNumber, paperType);
-        List<GradePaperDimension> gradePaperDimensionList = this.checkAndBuildGradePaperDimensionList(datasource,examId, paperNumber, paperType, paperName, dimensionType, requestUser);
+        List<GradePaperDimension> gradePaperDimensionList = this.checkAndBuildGradePaperDimensionList(datasource, examId, paperNumber, paperType, paperName, dimensionType, requestUser);
         this.remove(new QueryWrapper<GradePaperDimension>().lambda()
                 .eq(GradePaperDimension::getSchoolId, requestUser.getSchoolId())
-                .eq(GradePaperDimension::getExamId,examId)
-                .eq(GradePaperDimension::getPaperNumber, paperNumber)
+                .eq(GradePaperDimension::getExamId, examId).eq(GradePaperDimension::getPaperNumber, paperNumber)
                 .eq(GradePaperDimension::getPaperType, paperType)
                 .eq(GradePaperDimension::getDimensionType, dimensionType));
         this.saveBatch(gradePaperDimensionList);
-        gradeBatchPaperService.updatePaperAndBatchStatus(schoolId,examId , paperNumber, paperType);
+        gradeBatchPaperService.updatePaperAndBatchStatus(schoolId, examId, paperNumber, paperType);
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -76,12 +81,13 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
             throw ExceptionResultEnum.ERROR.exception("找不到附件");
         }
 
-        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperDimensionKnowledgeDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
-            if (finalExcelErrorList.size() > 0) {
-                throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
-            }
-            return finalExcelList;
-        },1);
+        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperDimensionKnowledgeDto.class),
+                (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+                    if (finalExcelErrorList.size() > 0) {
+                        throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
+                    }
+                    return finalExcelList;
+                }, 1);
         List<GradePaperDimensionDatasource> gradePaperDimensionDatasourceList = new ArrayList<>();
 
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
@@ -91,7 +97,8 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
 
                 for (int y = 0; y < Objects.requireNonNull(importList).size(); y++) {
                     if (importList.get(y) instanceof GradePaperDimensionKnowledgeDto) {
-                        GradePaperDimensionKnowledgeDto gradePaperDimensionKnowledgeDto = (GradePaperDimensionKnowledgeDto) importList.get(y);
+                        GradePaperDimensionKnowledgeDto gradePaperDimensionKnowledgeDto = (GradePaperDimensionKnowledgeDto) importList.get(
+                                y);
 
                         GradePaperDimensionDatasource gradePaperDimensionDatasource = new GradePaperDimensionDatasource();
                         gradePaperDimensionDatasource.setCodePrimary(gradePaperDimensionKnowledgeDto.getCodePrimary());
@@ -115,17 +122,19 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public void importGradePaperAbilityDimension(MultipartFile file, Long examId, String paperNumber, String paperType, String paperName, SysUser requestUser) throws IOException, NoSuchFieldException {
+    public void importGradePaperAbilityDimension(MultipartFile file, Long examId, String paperNumber, String paperType,
+            String paperName, SysUser requestUser) throws IOException, NoSuchFieldException {
         if (Objects.isNull(file)) {
             throw ExceptionResultEnum.ERROR.exception("找不到附件");
         }
 
-        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperDimensionAbilityDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
-            if (finalExcelErrorList.size() > 0) {
-                throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
-            }
-            return finalExcelList;
-        },1);
+        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperDimensionAbilityDto.class),
+                (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+                    if (finalExcelErrorList.size() > 0) {
+                        throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
+                    }
+                    return finalExcelList;
+                }, 1);
         List<GradePaperDimensionDatasource> gradePaperDimensionDatasourceList = new ArrayList<>();
 
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
@@ -135,7 +144,8 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
 
                 for (int y = 0; y < Objects.requireNonNull(importList).size(); y++) {
                     if (importList.get(y) instanceof GradePaperDimensionAbilityDto) {
-                        GradePaperDimensionAbilityDto gradePaperDimensionAbilityDto = (GradePaperDimensionAbilityDto) importList.get(y);
+                        GradePaperDimensionAbilityDto gradePaperDimensionAbilityDto = (GradePaperDimensionAbilityDto) importList.get(
+                                y);
 
                         GradePaperDimensionDatasource gradePaperDimensionDatasource = new GradePaperDimensionDatasource();
                         gradePaperDimensionDatasource.setCodePrimary(gradePaperDimensionAbilityDto.getCodePrimary());
@@ -158,32 +168,39 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public void exportGradePaperDimensionTemplate(String courseCode, String courseName, DimensionEnum dimensionType) throws Exception {
+    public void exportGradePaperDimensionTemplate(Long courseId, DimensionEnum dimensionType) throws Exception {
+        BasicCourse basicCourse = basicCourseService.getById(courseId);
+        String courseCode = basicCourse.getCode();
+        String courseName = basicCourse.getName();
+
         switch (dimensionType) {
-            case KNOWLEDGE:
-                List<GradePaperDimensionKnowledgeDto> kDatasource = new ArrayList<>();
-                GradePaperDimensionKnowledgeDto kCell = new GradePaperDimensionKnowledgeDto();
-                kCell.setCourseCode(courseCode);
-                kCell.setCourseName(courseName);
-                kDatasource.add(kCell);
-                ExcelUtil.excelExport(courseName + "-知识维度导入模板", GradePaperDimensionKnowledgeDto.class, kDatasource, ServletUtil.getResponse());
-                break;
-            case ABILITY:
-                List<GradePaperDimensionAbilityDto> aDatasource = new ArrayList<>();
-                GradePaperDimensionAbilityDto aCell = new GradePaperDimensionAbilityDto();
-                aCell.setCourseCode(courseCode);
-                aCell.setCourseName(courseName);
-                aDatasource.add(aCell);
-                ExcelUtil.excelExport(courseName + "-能力维度导入模板", GradePaperDimensionAbilityDto.class, aDatasource, ServletUtil.getResponse());
-                break;
-            default:
-                break;
+        case KNOWLEDGE:
+            List<GradePaperDimensionKnowledgeDto> kDatasource = new ArrayList<>();
+            GradePaperDimensionKnowledgeDto kCell = new GradePaperDimensionKnowledgeDto();
+            kCell.setCourseCode(courseCode);
+            kCell.setCourseName(courseName);
+            kDatasource.add(kCell);
+            ExcelUtil.excelExport(courseName + "-知识维度导入模板", GradePaperDimensionKnowledgeDto.class, kDatasource,
+                    ServletUtil.getResponse());
+            break;
+        case ABILITY:
+            List<GradePaperDimensionAbilityDto> aDatasource = new ArrayList<>();
+            GradePaperDimensionAbilityDto aCell = new GradePaperDimensionAbilityDto();
+            aCell.setCourseCode(courseCode);
+            aCell.setCourseName(courseName);
+            aDatasource.add(aCell);
+            ExcelUtil.excelExport(courseName + "-能力维度导入模板", GradePaperDimensionAbilityDto.class, aDatasource,
+                    ServletUtil.getResponse());
+            break;
+        default:
+            break;
         }
     }
 
     @Override
-    public List<PaperDimension> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId,Long examId, String paperNumber, String paperType) {
-        return this.baseMapper.findBySchoolIdAndPaperNumberAndPaperType(schoolId,examId, paperNumber, paperType);
+    public List<PaperDimension> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId, Long examId, String paperNumber,
+            String paperType) {
+        return this.baseMapper.findBySchoolIdAndPaperNumberAndPaperType(schoolId, examId, paperNumber, paperType);
     }
 
     /**
@@ -203,7 +220,8 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
      * @param requestUser                       请求用户
      * @return 构建好的维度预新增对象集合
      */
-    private List<GradePaperDimension> checkAndBuildGradePaperDimensionList(List<GradePaperDimensionDatasource> gradePaperDimensionDatasourceList,Long examId, String paperNumber, String paperType, String paperName, DimensionEnum dimensionType, SysUser requestUser) {
+    private List<GradePaperDimension> checkAndBuildGradePaperDimensionList(List<GradePaperDimensionDatasource> gradePaperDimensionDatasourceList,
+            Long examId, String paperNumber, String paperType, String paperName, DimensionEnum dimensionType, SysUser requestUser) {
         // TODO: 2022/6/15 校验如果试卷结构不为空,判断试卷结构中是不是存在
         Map<String, String> checkPrimaryCodeNameMap = new HashMap<>();
         List<GradePaperDimension> gradePaperDimensionList = new ArrayList<>();
@@ -215,7 +233,7 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
             String nameSecond = gradePaperDimensionDatasource.getNameSecond();
             String interpretation = gradePaperDimensionDatasource.getInterpretation();
 
-            if (SystemConstant.isOneNull(examId,paperNumber, paperType, dimensionType, codePrimary, namePrimary)) {
+            if (SystemConstant.isOneNull(examId, paperNumber, paperType, dimensionType, codePrimary, namePrimary)) {
                 throw ExceptionResultEnum.PARAMS_ERROR.exception();
             }
 
@@ -259,4 +277,4 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
         }
         return gradePaperDimensionList;
     }
-}
+}

+ 61 - 37
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradePaperStructServiceImpl.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import com.qmth.distributed.print.business.bean.dto.excel.GradePaperStructDto;
 import com.qmth.distributed.print.business.bean.dto.open.PaperStructure;
-import com.qmth.teachcloud.common.bean.marking.Question;
 import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructDatasource;
 import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructParam;
 import com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructResult;
@@ -16,11 +15,15 @@ import com.qmth.distributed.print.business.mapper.GradePaperStructMapper;
 import com.qmth.distributed.print.business.service.ExamTaskService;
 import com.qmth.distributed.print.business.service.GradeBatchPaperService;
 import com.qmth.distributed.print.business.service.GradePaperStructService;
+import com.qmth.teachcloud.common.bean.marking.Question;
+import com.qmth.teachcloud.common.bean.result.MarkQuestionResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.MarkQuestion;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.ObjectiveType;
+import com.qmth.teachcloud.common.service.BasicCourseService;
 import com.qmth.teachcloud.common.util.ExcelUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.collections4.CollectionUtils;
@@ -47,17 +50,23 @@ import java.util.stream.Stream;
  */
 @Service
 public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMapper, GradePaperStruct> implements GradePaperStructService {
+
     @Resource
     private GradeBatchPaperService gradeBatchPaperService;
+
     @Resource
     private ExamTaskService examTaskService;
 
+    @Resource
+    private BasicCourseService basicCourseService;
+
     @Override
-    public List<GradePaperStructResult> findGradePaperStructureResultList(Long examId, String paperNumber, String paperType, SysUser requestUser, List<MarkQuestion> markQuestionList) {
+    public List<GradePaperStructResult> findGradePaperStructureResultList(Long examId, String paperNumber, String paperType, SysUser requestUser, List<MarkQuestionResult> markQuestionList) {
         Long schoolId = requestUser.getSchoolId();
         List<GradePaperStructResult> result = new ArrayList<>();
         // 先从分析试卷结构表取
-        List<GradePaperStructResult> gradeStructDatasource = this.baseMapper.findStructByGradePaper(schoolId, examId, paperNumber, paperType);
+        List<GradePaperStructResult> gradeStructDatasource = this.baseMapper.findStructByGradePaper(schoolId, examId,
+                paperNumber, paperType);
         if (gradeStructDatasource != null && gradeStructDatasource.size() > 0) {
             // 如果已经设置了试卷结构查询之前配置好的分析参数-试卷结构
             result = gradeStructDatasource;
@@ -71,10 +80,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
             List<Question> examPaperObjList = examCloudPaperStructMap.get(ObjectiveType.OBJECTIVE);
             List<Question> examPaperSubList = examCloudPaperStructMap.get(ObjectiveType.SUBJECTIVE);
 
-            List<ExamTask> examTaskList = examTaskService.list(new QueryWrapper<ExamTask>().lambda()
-                    .eq(ExamTask::getSchoolId, schoolId)
-                    .eq(ExamTask::getExamId, examId)
-                    .eq(ExamTask::getPaperNumber, paperNumber));
+            List<ExamTask> examTaskList = examTaskService.list(
+                    new QueryWrapper<ExamTask>().lambda().eq(ExamTask::getSchoolId, schoolId).eq(ExamTask::getExamId, examId).eq(ExamTask::getPaperNumber, paperNumber));
             if (Objects.isNull(examTaskList)) {
                 throw ExceptionResultEnum.ERROR.exception("没有找到试卷编号对应的命题任务");
             }
@@ -82,12 +89,21 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
                 throw ExceptionResultEnum.ERROR.exception("有多个考试任务异常");
             }
             ExamTask examTask = examTaskList.get(0);
-            String courseCode = examTask.getCourseCode();
-            String courseName = examTask.getCourseName();
+
+            Long courseId = examTask.getCourseId();
+            BasicCourse basicCourse = basicCourseService.getById(courseId);
+            if (Objects.isNull(basicCourse)) {
+                throw ExceptionResultEnum.ERROR.exception("没有找到课程信息");
+            }
+
+            String courseCode = basicCourse.getCode();
+            String courseName = basicCourse.getName();
 
             // 按题号排序
-            examPaperObjList = examPaperObjList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber)).collect(Collectors.toList());
-            examPaperSubList = examPaperSubList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber)).collect(Collectors.toList());
+            examPaperObjList = examPaperObjList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber))
+                    .collect(Collectors.toList());
+            examPaperSubList = examPaperSubList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber))
+                    .collect(Collectors.toList());
             for (Question question : examPaperObjList) {
                 GradePaperStructResult cell = new GradePaperStructResult();
                 cell.setCourseCode(courseCode);
@@ -137,11 +153,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
         // 检验结构正确性并构建分析试卷结构
         List<GradePaperStruct> gradePaperStructList = this.checkAndBuildGradePaperStruct(datasource, examId, paperNumber, paperType, paperName, requestUser);
         // 删除旧的试卷结构
-        this.remove(new QueryWrapper<GradePaperStruct>()
-                .lambda()
-                .eq(GradePaperStruct::getSchoolId, schoolId)
-                .eq(GradePaperStruct::getExamId, examId)
-                .eq(GradePaperStruct::getPaperNumber, paperNumber)
+        this.remove(new QueryWrapper<GradePaperStruct>().lambda().eq(GradePaperStruct::getSchoolId, schoolId)
+                .eq(GradePaperStruct::getExamId, examId).eq(GradePaperStruct::getPaperNumber, paperNumber)
                 .eq(GradePaperStruct::getPaperType, paperType));
         this.saveBatch(gradePaperStructList);
         gradeBatchPaperService.updatePaperAndBatchStatus(schoolId, examId, paperNumber, paperType);
@@ -149,20 +162,23 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public void importGradePaperStruct(MultipartFile file, String paperNumber, String paperType, String paperName, SysUser requestUser) throws IOException, NoSuchFieldException {
+    public void importGradePaperStruct(MultipartFile file, Long examId, String paperNumber, String paperType, String paperName,
+            SysUser requestUser) throws IOException, NoSuchFieldException {
         if (Objects.isNull(file)) {
             throw ExceptionResultEnum.ERROR.exception("找不到附件");
         }
-        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperStructDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
-            if (finalExcelErrorList.size() > 0) {
-                throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
-            }
-            return finalExcelList;
-        }, 1);
+        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperStructDto.class),
+                (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+                    if (finalExcelErrorList.size() > 0) {
+                        throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
+                    }
+                    return finalExcelList;
+                }, 1);
         GradePaperStructParam gradePaperStructParam = new GradePaperStructParam();
         gradePaperStructParam.setPaperNumber(paperNumber);
         gradePaperStructParam.setPaperType(paperType);
         gradePaperStructParam.setPaperName(paperName);
+        gradePaperStructParam.setExamId(examId);
         List<GradePaperStructDatasource> gradePaperStructDatasourceList = new ArrayList<>();
 
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
@@ -191,18 +207,24 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
     }
 
     @Override
-    public void exportGradePaperStructTemplate(Long examId, String paperNumber, String paperType, @NotNull SysUser requestUser, List<MarkQuestion> markQuestionList) throws Exception {
+    public void exportGradePaperStructTemplate(Long examId, String paperNumber, String paperType, @NotNull SysUser requestUser, List<MarkQuestionResult> markQuestionList) throws Exception {
 
-        ExamTask examTask = examTaskService.getOne(new QueryWrapper<ExamTask>().lambda()
-                .eq(ExamTask::getSchoolId, requestUser.getSchoolId())
-                .eq(ExamTask::getPaperNumber, paperNumber));
+        ExamTask examTask = examTaskService.getOne(
+                new QueryWrapper<ExamTask>().lambda().eq(ExamTask::getSchoolId, requestUser.getSchoolId()).eq(ExamTask::getPaperNumber, paperNumber));
         if (Objects.isNull(examTask)) {
             throw ExceptionResultEnum.ERROR.exception("没有找到试卷编号对应的命题任务");
         }
-        String courseCode = examTask.getCourseCode();
-        String courseName = examTask.getCourseName();
+        Long courseId = examTask.getCourseId();
+        BasicCourse basicCourse = basicCourseService.getById(courseId);
+        if (Objects.isNull(basicCourse)) {
+            throw ExceptionResultEnum.ERROR.exception("未找到课程信息");
+        }
+
+        String courseCode = basicCourse.getCode();
+        String courseName = basicCourse.getName();
 
-        List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser, markQuestionList);
+        List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(examId, paperNumber, paperType,
+                requestUser, markQuestionList);
         List<GradePaperStructDto> gradePaperStructDtoList = datasource.stream().flatMap(e -> {
             GradePaperStructDto cell = new GradePaperStructDto();
             cell.setCourseCode(courseCode);
@@ -222,7 +244,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
     }
 
     @Override
-    public List<PaperStructure> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId, Long examId, String paperNumber, String paperType) {
+    public List<PaperStructure> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId, Long examId, String paperNumber,
+            String paperType) {
         return this.baseMapper.findBySchoolIdAndPaperNumberAndPaperType(schoolId, examId, paperNumber, paperType);
     }
 
@@ -236,10 +259,10 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
         // 如果没有客观题 试卷类型传空
         paperType = null;
         // todo 3.3.0待更新
-//        String cloudInfoJson = cloudMarkingTaskUtils.queryPaperStructure(schoolId, examId, subjectCode, paperType);
-//        examPaperStructure.setCloudInfoJson(cloudInfoJson);
-//        examPaperStructure.setStructureChange(false);
-//        examPaperStructureService.updateById(examPaperStructure);
+        //        String cloudInfoJson = cloudMarkingTaskUtils.queryPaperStructure(schoolId, examId, subjectCode, paperType);
+        //        examPaperStructure.setCloudInfoJson(cloudInfoJson);
+        //        examPaperStructure.setStructureChange(false);
+        //        examPaperStructureService.updateById(examPaperStructure);
 
         // 更新grade_paper_struct
         QueryWrapper<GradePaperStruct> willDeleteQueryWrapper = new QueryWrapper<>();
@@ -271,7 +294,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
             gradePaperStruct.setPaperNumber(paperNumber);
             gradePaperStruct.setPaperType(paperType);
             gradePaperStruct.setPaperName(paperName);
-            gradePaperStruct.setQuestionName(e.getBigTopicName() + " " + e.getBigQuestionNumber() + SystemConstant.HYPHEN + e.getSmallQuestionNumber());
+            gradePaperStruct.setQuestionName(
+                    e.getBigTopicName() + " " + e.getBigQuestionNumber() + SystemConstant.HYPHEN + e.getSmallQuestionNumber());
             gradePaperStruct.setNumberType(e.getNumberType());
             gradePaperStruct.setBigQuestionNumber(e.getBigQuestionNumber());
             gradePaperStruct.setSmallQuestionNumber(e.getSmallQuestionNumber());
@@ -289,7 +313,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
         }).collect(Collectors.toList());
     }
 
-    private Map<ObjectiveType, List<Question>> parseExamCloudPaperStruct(List<MarkQuestion> markQuestionList) {
+    private Map<ObjectiveType, List<Question>> parseExamCloudPaperStruct(List<MarkQuestionResult> markQuestionList) {
         Map<ObjectiveType, List<Question>> result = new HashMap<>();
         List<Question> objList = new ArrayList<>();
         List<Question> subList = new ArrayList<>();

+ 1 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/PdfTaskLogicService.java

@@ -9,11 +9,7 @@ import java.util.Map;
 import java.util.StringJoiner;
 
 /**
- * @Description: 任务处理逻辑
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2021/3/29
+ * 任务处理逻辑
  */
 public interface PdfTaskLogicService {
 

+ 257 - 227
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/ImportLogicServiceImpl.java

@@ -10,13 +10,13 @@ import com.qmth.distributed.print.business.bean.dto.SubjectiveStructDto;
 import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentImport;
 import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentParseDto;
 import com.qmth.distributed.print.business.entity.BasicExamRule;
+import com.qmth.distributed.print.business.entity.ExamDetail;
 import com.qmth.distributed.print.business.entity.ExamPrintPlan;
 import com.qmth.distributed.print.business.entity.ExamTask;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.enums.RequiredFieldsEnum;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.service.ImportLogicService;
-import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.bean.dto.mark.MarkUser;
 import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableDisabledValue;
 import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
@@ -33,7 +33,6 @@ import com.qmth.teachcloud.mark.entity.MarkPaper;
 import com.qmth.teachcloud.mark.service.MarkGroupService;
 import com.qmth.teachcloud.mark.service.MarkPaperService;
 import com.qmth.teachcloud.mark.service.MarkQuestionService;
-import com.qmth.teachcloud.mark.service.MarkStudentService;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -65,25 +64,25 @@ public class ImportLogicServiceImpl implements ImportLogicService {
     @Resource
     private BasicExamRuleService basicExamRuleService;
     @Resource
-    BasicCourseService basicCourseService;
+    private BasicCourseService basicCourseService;
     @Resource
-    BasicExamService basicExamService;
+    private BasicExamService basicExamService;
     @Resource
-    SysUserService sysUserService;
+    private SysUserService sysUserService;
     @Resource
-    SysOrgService sysOrgService;
+    private SysOrgService sysOrgService;
     @Resource
-    BasicExamStudentService basicExamStudentService;
+    private BasicExamStudentService basicExamStudentService;
     @Resource
-    MarkPaperService markPaperService;
+    private MarkPaperService markPaperService;
     @Resource
-    MarkStudentService markStudentService;
+    private ExamDetailService examDetailService;
     @Resource
-    MarkQuestionService markQuestionService;
+    private MarkQuestionService markQuestionService;
     @Resource
-    MarkGroupService markGroupService;
+    private MarkGroupService markGroupService;
     @Resource
-    SysRoleService sysRoleService;
+    private SysRoleService sysRoleService;
     @Resource
     private CommonCacheService commonCacheService;
     @Resource
@@ -92,6 +91,8 @@ public class ImportLogicServiceImpl implements ImportLogicService {
     private ExamPrintPlanService examPrintPlanService;
     @Resource
     private ExamTaskService examTaskService;
+    @Resource
+    private ExamStudentService examStudentService;
 
 
     @Transactional
@@ -107,20 +108,20 @@ public class ImportLogicServiceImpl implements ImportLogicService {
         }
         Long semesterId = SystemConstant.convertIdToLong(basicExam.getSemesterId());
 
-        SystemConstant.addSummary(stringJoinerSummary, "开始解析文件内容");
+        SystemConstant.addSummary(stringJoinerSummary, "开始解析导入文件内容");
         BasicExamStudentParseDto basicExamStudentParseDto;
         try {
             // 解析excel文件内容
             basicExamStudentParseDto = this.parseBasicExamStudent(schoolId, inputStream);
         } catch (Exception e) {
-            SystemConstant.addSummary(stringJoinerSummary, "解析文件内容结束,解析失败。" + e.getMessage());
+            SystemConstant.addSummary(stringJoinerSummary, "解析导入文件内容结束,解析失败。" + e.getMessage());
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }
-        SystemConstant.addSummary(stringJoinerSummary, "解析文件内容结束,开始进行数据校验");
+        SystemConstant.addSummary(stringJoinerSummary, "解析导入文件内容结束,开始进行数据校验");
 
         List<BasicExamStudentImport> basicExamStudentImportList = basicExamStudentParseDto.getBasicExamStudentImportList();
         if (CollectionUtils.isEmpty(basicExamStudentImportList)) {
-            throw ExceptionResultEnum.ERROR.exception("没有可导入数据");
+            throw ExceptionResultEnum.ERROR.exception("未读取到有效数据");
         }
 
         List<BasicExamStudent> basicExamStudentList = basicExamStudentService.list(new QueryWrapper<BasicExamStudent>().lambda()
@@ -206,14 +207,14 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 basicExamStudent.setCourseId(basicCourseIdMap.get(key));
             }
 
-            // 校验任课老师
+            // 校验任课老师工号和姓名
             if (StringUtils.isNotBlank(basicExamStudentImport.getTeacherCode()) && StringUtils.isNotBlank(basicExamStudentImport.getTeacherName())) {
                 SysUser sysUser = sysUserService.getByLoginName(schoolId, basicExamStudentImport.getTeacherCode());
                 if (sysUser == null) {
-                    stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]不存在");
+                    stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户不存在");
                 } else {
                     if (!sysUser.getEnable()) {
-                        stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]已禁用");
+                        stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户已禁用");
                     } else if (!sysUser.getRealName().equals(basicExamStudentImport.getTeacherName())) {
                         stringJoiner.add("任课老师[" + basicExamStudentImport.getTeacherName() + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
                     } else {
@@ -222,33 +223,25 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 }
 
                 // 校验同课程下,同一教学班只能有一个任课老师
-                String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
-                if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
-                    Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
-                    if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
-                        stringJoiner.add("同课程下相同教学班,只能有一位任课老师");
-                    }
-                } else {
-                    courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
-                }
-            }
-
-            // 校验课程+学号唯一
-            String courseCodeStudentCode = basicExamStudentImport.getCourseCode() + basicExamStudentImport.getStudentCode();
-            if (courseCodeStudentCodeList.contains(courseCodeStudentCode)) {
-                stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号[" + basicExamStudentImport.getStudentCode() + "]的考生数据");
-            } else {
-                courseCodeStudentCodeList.add(courseCodeStudentCode);
+//                String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
+//                if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
+//                    Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
+//                    if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
+//                        stringJoiner.add("同课程同教学班,只允许设置一个任课老师");
+//                    }
+//                } else {
+//                    courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
+//                }
             }
 
             if (basicExamStudent.getCourseId() != null) {
                 if (courseIdStudentCodeMap.containsKey(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode())) {
                     BasicExamStudent student = courseIdStudentCodeMap.get(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode());
-                    basicExamStudent.setId(student.getId());
-
-                    // 被更改的试卷编号
-                    if (StringUtils.isNotBlank(basicExamStudent.getPaperNumber()) && StringUtils.isNotBlank(student.getPaperNumber()) && !basicExamStudent.getPaperNumber().equals(student.getPaperNumber())) {
-                        oldPaperNumberList.add(student.getPaperNumber());
+                    if (StringUtils.isNotBlank(student.getPaperNumber()) && student.getPaperNumber().equals(basicExamStudent.getPaperNumber())) {
+                        throw ExceptionResultEnum.ERROR.exception("不允许修改试卷编号");
+                    } else {
+                        basicExamStudent.setId(student.getId());
+                        basicExamStudent.setPaperType(student.getPaperType());
                     }
                 }
 
@@ -261,6 +254,14 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                         paperNumberCourseIdMap.put(basicExamStudent.getPaperNumber(), basicExamStudent.getCourseId());
                     }
                 }
+
+                // 校验课程学号唯一
+                String courseCodeStudentCodeKey = basicExamStudent.getCourseId() + basicExamStudentImport.getStudentCode();
+                if (courseCodeStudentCodeList.contains(courseCodeStudentCodeKey)) {
+                    stringJoiner.add(String.format("课程代码[%s],开课学院[%s],学号[%s]存在重复考生", basicExamStudentImport.getCourseCode(), basicExamStudentImport.getTeachingRoomName(), basicExamStudentImport.getStudentCode()));
+                } else {
+                    courseCodeStudentCodeList.add(courseCodeStudentCodeKey);
+                }
             }
 
             if (stringJoiner.toString().length() > 0) {
@@ -288,6 +289,166 @@ public class ImportLogicServiceImpl implements ImportLogicService {
         return map;
     }
 
+    @Transactional
+    @Override
+    public Map<String, Object> executeImportBasicExamStudentTeacherLogic(Map<String, Object> map, StringJoiner stringJoinerSummary) {
+        SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
+        InputStream inputStream = (InputStream) map.get("inputStream");
+        Long examId = SystemConstant.convertIdToLong(String.valueOf(map.get("examId")));
+        Long schoolId = requestUser.getSchoolId();
+        BasicExam basicExam = basicExamService.getById(examId);
+        if (Objects.isNull(basicExam)) {
+            throw ExceptionResultEnum.ERROR.exception("考试不存在");
+        }
+
+        SystemConstant.addSummary(stringJoinerSummary, "开始解析导入文件内容");
+        BasicExamStudentParseDto basicExamStudentParseDto;
+        try {
+            basicExamStudentParseDto = this.parseBasicExamStudent(schoolId, inputStream);
+        } catch (Exception e) {
+            SystemConstant.addSummary(stringJoinerSummary, "解析导入文件内容结束,解析失败。" + e.getMessage());
+            throw ExceptionResultEnum.ERROR.exception(e.getMessage());
+        }
+        SystemConstant.addSummary(stringJoinerSummary, "解析导入文件内容结束,开始进行数据校验");
+
+        List<BasicExamStudentImport> basicExamStudentImportList = basicExamStudentParseDto.getBasicExamStudentImportList();
+        if (CollectionUtils.isEmpty(basicExamStudentImportList)) {
+            throw ExceptionResultEnum.ERROR.exception("未读取到有效数据");
+        }
+
+        List<BasicExamStudent> basicExamStudentList = basicExamStudentService.list(new QueryWrapper<BasicExamStudent>().lambda()
+                .select(BasicExamStudent::getId, BasicExamStudent::getCourseId, BasicExamStudent::getStudentCode, BasicExamStudent::getPaperNumber, BasicExamStudent::getTeachClassName, BasicExamStudent::getTeacherId)
+                .eq(BasicExamStudent::getSchoolId, schoolId).eq(BasicExamStudent::getExamId, examId));
+        Map<String, BasicExamStudent> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), e -> e));
+
+        Map<String, Long> basicCourseIdMap = new HashMap<>();
+        // 课程学号唯一
+        List<String> courseCodeStudentCodeList = new ArrayList<>();
+        // 课程+教学班->任课老师
+        Map<String, Long> courseTeachClassTeacherMap = new HashMap<>();
+        // 是否有错误提示
+        boolean hasError = false;
+
+        // 必填字段为课程代码、开课学院、学号、教学班、任课老师工号、任课老师
+        List<String> requiredCodes = Arrays.asList(RequiredFieldsEnum.STUDENT_CODE.getCode(), RequiredFieldsEnum.COURSE_CODE.getCode(), RequiredFieldsEnum.TEACHING_ROOM_NAME.getCode(), RequiredFieldsEnum.TEACH_CLASS_NAME.getCode(), RequiredFieldsEnum.TEACHER_NAME.getCode(), RequiredFieldsEnum.TEACHER_CODE.getCode());
+
+        List<BasicExamStudent> basicExamStudents = new ArrayList<>();
+        for (BasicExamStudentImport basicExamStudentImport : basicExamStudentImportList) {
+            BasicExamStudent basicExamStudent = new BasicExamStudent();
+            StringJoiner stringJoiner = new StringJoiner(";");
+
+            // 校验excel内容
+            basicExamStudentImport.getRequiredFieldList().forEach(m -> {
+                if (requiredCodes.contains(m.getCode()) && StringUtils.isBlank(m.getValue())) {
+                    stringJoiner.add(m.getName() + "必填");
+                }
+            });
+
+            // 校验课程
+            String key = basicExamStudentImport.getCourseCode() + SystemConstant.HYPHEN + basicExamStudentImport.getTeachingRoomName();
+            if (!basicCourseIdMap.containsKey(key)) {
+                List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(schoolId, basicExamStudentImport.getTeachingRoomName());
+                if (CollectionUtils.isEmpty(sysOrgList)) {
+                    stringJoiner.add("开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]在学院层级不存在");
+                } else {
+                    SysOrg sysOrg = sysOrgList.get(0);
+                    // 校验课程代码和开课学院
+                    BasicCourse basicCourse = basicCourseService.getByTeachRoomIdAndCode(sysOrg.getId(), basicExamStudentImport.getCourseCode());
+                    if (Objects.isNull(basicCourse)) {
+                        stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]在开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]不存在");
+                    } else {
+                        basicExamStudent.setCourseId(basicCourse.getId());
+                        basicCourseIdMap.put(key, basicCourse.getId());
+                    }
+                }
+            } else {
+                basicExamStudent.setCourseId(basicCourseIdMap.get(key));
+            }
+
+            //校验任课老师
+            SysUser sysUser = sysUserService.getByLoginName(schoolId, basicExamStudentImport.getTeacherCode());
+            if (sysUser == null) {
+                stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户不存在");
+            } else {
+                if (!sysUser.getEnable()) {
+                    stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户已禁用");
+                } else if (!sysUser.getRealName().equals(basicExamStudentImport.getTeacherName())) {
+                    stringJoiner.add("任课老师[" + basicExamStudentImport.getTeacherName() + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
+                } else {
+                    basicExamStudent.setTeacherId(sysUser.getId());
+                }
+            }
+
+            if (basicExamStudent.getCourseId() != null) {
+                // 校验同课程下,同一教学班只能有一个任课老师
+//                if (StringUtils.isNotBlank(basicExamStudent.getTeachClassName())) {
+//                    String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
+//                    if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
+//                        Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
+//                        if (teacherId != null && basicExamStudent.getTeacherId() != null && !teacherId.equals(basicExamStudent.getTeacherId())) {
+//                            stringJoiner.add("同课程同教学班,只允许设置一个任课老师");
+//                        }
+//                    } else {
+//                        courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
+//                    }
+//                }
+
+                // 校验课程+学号是否存在
+                if (StringUtils.isNotBlank(basicExamStudentImport.getStudentCode())) {
+                    String studentKey = basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudentImport.getStudentCode();
+                    if (courseIdStudentCodeMap.containsKey(studentKey)) {
+                        BasicExamStudent student = courseIdStudentCodeMap.get(studentKey);
+                        basicExamStudent.setId(student.getId());
+                        basicExamStudent.setPaperNumber(student.getPaperNumber());
+                        basicExamStudent.setPaperType(student.getPaperType());
+                        // 更新requiredFields中的任课老师和任课老师工号
+                        for (CodeNameEnableValue codeNameEnableValue : student.getRequiredFieldList()) {
+                            if (codeNameEnableValue.getCode().equals(RequiredFieldsEnum.TEACHER_CODE.getCode())) {
+                                codeNameEnableValue.setValue(basicExamStudentImport.getTeacherCode());
+                            }
+                            if (codeNameEnableValue.getCode().equals(RequiredFieldsEnum.TEACHER_NAME.getCode())) {
+                                codeNameEnableValue.setValue(basicExamStudentImport.getTeacherName());
+                            }
+                        }
+                        basicExamStudent.setRequiredFields(JSON.toJSONString(student.getRequiredFieldList()));
+                    } else {
+                        stringJoiner.add(String.format("课程代码[%s],开课学院[%s],学号[%s]考生管理中不存在", basicExamStudentImport.getCourseCode(), basicExamStudentImport.getTeachingRoomName(), basicExamStudentImport.getStudentCode()));
+                    }
+                }
+
+                // 校验课程学号唯一
+                String courseCodeStudentCodeKey = basicExamStudent.getCourseId() + basicExamStudentImport.getStudentCode();
+                if (courseCodeStudentCodeList.contains(courseCodeStudentCodeKey)) {
+                    stringJoiner.add(String.format("课程代码[%s],开课学院[%s],学号[%s]存在重复考生", basicExamStudentImport.getCourseCode(), basicExamStudentImport.getTeachingRoomName(), basicExamStudentImport.getStudentCode()));
+                } else {
+                    courseCodeStudentCodeList.add(courseCodeStudentCodeKey);
+                }
+            }
+
+            if (stringJoiner.toString().length() > 0) {
+                basicExamStudentImport.setErrorMsg(stringJoiner.toString());
+            }
+
+            if (!hasError && stringJoiner.toString().length() > 0) {
+                hasError = true;
+            }
+
+            if (stringJoiner.toString().length() == 0) {
+                basicExamStudents.add(basicExamStudent);
+            }
+        }
+
+        map.put(SystemConstant.ERROR_DATA_LIST, basicExamStudentImportList);
+        map.put(SystemConstant.DATASOURCE, basicExamStudents);
+        map.put(SystemConstant.DATA_COUNT, basicExamStudentImportList.size());
+        map.put(SystemConstant.SUCCESS_DATA_COUNT, basicExamStudents.size());
+        map.put(SystemConstant.ERROR_DATA_COUNT, basicExamStudentImportList.size() - basicExamStudents.size());
+        map.put(SystemConstant.HAS_ERROR_DATA, hasError);
+        map.put(SystemConstant.COLUMN_NAMES, basicExamStudentParseDto.getColumnNames());
+
+        return map;
+    }
+
     @Transactional
     @Override
     public Map<String, Object> executeImportExamStudentLogic(Map<String, Object> map, TBTask tbTask, StringJoiner stringJoinerSummary) {
@@ -328,13 +489,13 @@ public class ImportLogicServiceImpl implements ImportLogicService {
 
         List<BasicExamStudentImport> basicExamStudentImportList = basicExamStudentParseDto.getBasicExamStudentImportList();
         if (CollectionUtils.isEmpty(basicExamStudentImportList)) {
-            throw ExceptionResultEnum.ERROR.exception("没有可导入数据");
+            throw ExceptionResultEnum.ERROR.exception("未读取到有效数据");
         }
 
         List<BasicExamStudent> basicExamStudentList = basicExamStudentService.list(new QueryWrapper<BasicExamStudent>().lambda()
                 .select(BasicExamStudent::getId, BasicExamStudent::getCourseId, BasicExamStudent::getStudentCode, BasicExamStudent::getPaperNumber)
                 .eq(BasicExamStudent::getSchoolId, schoolId).eq(BasicExamStudent::getExamId, examId));
-        Map<String, Long> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), BaseEntity::getId));
+        Map<String, BasicExamStudent> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), Function.identity()));
 
         // 文件中试卷编号对应多个课程代码
         Map<String, Long> paperNumberCourseIdInMap = new HashMap<>();
@@ -352,6 +513,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
         // 是否有错误提示
         boolean hasError = false;
 
+        // 命题任务列表
         List<ExamTask> examTaskList = examTaskService.listByExamId(examId);
         Map<String, List<ExamTask>> paperNumberMap = examTaskList.stream().collect(Collectors.groupingBy(m -> m.getPaperNumber()));
 
@@ -366,12 +528,13 @@ public class ImportLogicServiceImpl implements ImportLogicService {
             basicExamStudent.setExtendFields(CollectionUtils.isNotEmpty(basicExamStudentImport.getExtendFieldList()) ? JSON.toJSONString(basicExamStudentImport.getExtendFieldList()) : null);
 
             StringJoiner stringJoiner = new StringJoiner(";");
-            // 校验excel内容
+            // 校验必填项
             basicExamStudentImport.getRequiredFieldList().forEach(m -> {
                 if (m.getEnable() && StringUtils.isBlank(m.getValue())) {
                     stringJoiner.add(m.getName() + "必填");
                 }
             });
+            // 校验任课老师,都填或者都不填
             if (StringUtils.isNotBlank(basicExamStudentImport.getTeacherCode()) && StringUtils.isBlank(basicExamStudentImport.getTeacherName())) {
                 stringJoiner.add(RequiredFieldsEnum.TEACHER_NAME.getName() + "必填");
             }
@@ -379,6 +542,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 stringJoiner.add(RequiredFieldsEnum.TEACHER_CODE.getName() + "必填");
             }
 
+            // 解析并校验考试日期、考试时间
             try {
                 Map<String, Object> timeMap = ConvertUtil.analyzeExamTime(basicExamStudentImport.getExamDate(), basicExamStudentImport.getExamTime());
                 basicExamStudent.setExamStartTime(Long.valueOf(String.valueOf(timeMap.get("startTime"))));
@@ -387,7 +551,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 stringJoiner.add(e.getMessage());
             }
 
-            // 校验课程
+            // 校验开课学院是否存在该课程代码
             String key = basicExamStudentImport.getCourseCode() + SystemConstant.HYPHEN + basicExamStudentImport.getTeachingRoomName();
             if (!basicCourseIdMap.containsKey(key)) {
                 List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(schoolId, basicExamStudentImport.getTeachingRoomName());
@@ -410,39 +574,42 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 basicExamStudent.setCourseId(basicCourseIdMap.get(key));
             }
 
-            // 校验试卷编号和课程代码对应关系
+            // 校验试卷编号和课程代码对应关系,试卷编号只能绑定一个课程
             if (paperNumberCourseIdInMap.containsKey(basicExamStudent.getPaperNumber())) {
                 Long courseId = paperNumberCourseIdInMap.get(basicExamStudent.getPaperNumber());
                 if (!basicExamStudent.getCourseId().equals(courseId)) {
-                    stringJoiner.add(String.format("文件中试卷编号[%s]对应多个不同的课程代码", basicExamStudent.getPaperNumber()));
+                    stringJoiner.add(String.format("试卷编号[%s]对应多个不同的课程代码", basicExamStudent.getPaperNumber()));
                 }
             } else {
                 paperNumberCourseIdInMap.put(basicExamStudent.getPaperNumber(), basicExamStudent.getCourseId());
             }
 
+            // 校验试卷编号课程代码是否已命题且命题任务中课程代码是否一致
             if (paperNumberMap.containsKey(basicExamStudent.getPaperNumber())) {
                 List<ExamTask> examTasks = paperNumberMap.get(basicExamStudent.getPaperNumber());
                 if (examTasks.size() > 1) {
-                    stringJoiner.add(String.format("试卷编号[%s]在考试[%s]下有多条命题任务,请联系管理员处理", basicExamStudent.getPaperNumber(), examId));
+                    stringJoiner.add(String.format("试卷编号[%s]在考试[%s]下有多条命题任务,请联系管理员处理", basicExamStudent.getPaperNumber(), basicExam.getName()));
                 } else {
                     Long courseId = paperNumberCourseIdInMap.get(basicExamStudent.getPaperNumber());
                     ExamTask examTask = examTasks.get(0);
                     if (!examTask.getCourseId().equals(courseId)) {
-                        stringJoiner.add(String.format("文件中试卷编号[%s]对应课程代码与命题任务中对应课程代码不一致", basicExamStudent.getPaperNumber()));
+                        stringJoiner.add(String.format("试卷编号[%s]对应课程代码与命题任务中对应课程代码不一致", basicExamStudent.getPaperNumber()));
                     } else {
                         basicExamStudent.setCoursePaperId(String.valueOf(examTask.getId()));
                     }
                 }
+            } else {
+                stringJoiner.add(String.format("试卷编号[%s]未命题", basicExamStudent.getPaperNumber()));
             }
 
-            //校验任课老师
+            //校验任课老师是否存在,且工号和姓名是否与系统一致
             if (StringUtils.isNotBlank(basicExamStudentImport.getTeacherCode()) && StringUtils.isNotBlank(basicExamStudentImport.getTeacherName())) {
                 SysUser sysUser = sysUserService.getByLoginName(schoolId, basicExamStudentImport.getTeacherCode());
                 if (sysUser == null) {
-                    stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]不存在");
+                    stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户不存在");
                 } else {
                     if (!sysUser.getEnable()) {
-                        stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]已禁用");
+                        stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户已禁用");
                     } else if (!sysUser.getRealName().equals(basicExamStudentImport.getTeacherName())) {
                         stringJoiner.add("任课老师[" + basicExamStudentImport.getTeacherName() + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
                     } else {
@@ -451,29 +618,45 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 }
 
                 // 校验同课程下,同一教学班只能有一个任课老师
-                String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
-                if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
-                    Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
-                    if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
-                        stringJoiner.add("同课程下相同教学班,只能有一位任课老师");
-                    }
-                } else {
-                    courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
-                }
+//                String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
+//                if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
+//                    Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
+//                    if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
+//                        stringJoiner.add("同课程下相同教学班,只能有一位任课老师");
+//                    }
+//                } else {
+//                    courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
+//                }
             }
 
-            if (basicExamStudent.getCourseId() != null) {
-                if (courseIdStudentCodeMap.containsKey(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode())) {
-                    basicExamStudent.setId(courseIdStudentCodeMap.get(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode()));
+            // 校验试卷编号学号是否已生成印刷任务
+            int studentCount = examStudentService.countByExamIdAndPaperNumberAndStudentCode(examId, basicExamStudent.getPaperNumber(), basicExamStudent.getStudentCode());
+            if (studentCount > 0) {
+                stringJoiner.add("试卷编号[" + basicExamStudent.getPaperNumber() + "]、学号[" + basicExamStudent.getStudentCode() + "]已有印刷任务,不允许重复导入");
+            } else {
+                if (basicExamStudent.getCourseId() != null) {
+                    // 校验课程学号唯一
+                    String courseCodeStudentCodeKey = basicExamStudent.getCourseId() + basicExamStudent.getStudentCode();
+                    if (courseCodeStudentCodeList.contains(courseCodeStudentCodeKey)) {
+                        stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号[" + basicExamStudentImport.getStudentCode() + "]的考生数据");
+                    } else {
+                        courseCodeStudentCodeList.add(courseCodeStudentCodeKey);
+                    }
+
+                    if (courseIdStudentCodeMap.containsKey(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode())) {
+                        BasicExamStudent basicStudent = courseIdStudentCodeMap.get(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode());
+                        basicExamStudent.setId(basicStudent.getId());
+                    }
                 }
             }
 
-            // 校验课程学号唯一
-            String courseCodeStudentCode = basicExamStudentImport.getCourseCode() + basicExamStudentImport.getStudentCode();
-            if (courseCodeStudentCodeList.contains(courseCodeStudentCode)) {
-                stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号[" + basicExamStudentImport.getStudentCode() + "]的考生数据");
-            } else {
-                courseCodeStudentCodeList.add(courseCodeStudentCode);
+            // 校验试卷编号、考试日期、考试时间、考点、考场是否已命题
+            List<ExamDetail> examDetailList = examDetailService.listExamDetailByExamIdAndCourseIdAndPaperNumber(examId, basicExamStudent.getCourseId(), basicExamStudent.getPaperNumber());
+            if (CollectionUtils.isNotEmpty(examDetailList)) {
+                long count = examDetailList.stream().filter(m -> basicExamStudent.getExamStartTime().equals(m.getExamStartTime()) && basicExamStudent.getExamEndTime().equals(m.getExamEndTime()) && basicExamStudent.getExamPlace().equals(m.getExamPlace()) && basicExamStudent.getExamRoom().equals(m.getExamRoom())).count();
+                if (count != 0) {
+                    stringJoiner.add("试卷编号[" + basicExamStudentImport.getPaperNumber() + "]、考试日期[" + basicExamStudentImport.getExamDate() + "]、考试时间[" + basicExamStudentImport.getExamTime() + "]、考场[" + basicExamStudentImport.getExamPlace() + "]、考点[" + basicExamStudentImport.getExamRoom() + "]已有印刷任务");
+                }
             }
 
             if (stringJoiner.toString().length() > 0) {
@@ -505,7 +688,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
 
     private BasicExamStudentParseDto parseBasicExamStudent(Long schoolId, InputStream inputStream) {
         ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, inputStream, 1);
-        List<DataMap> dataMapList = null;
+        List<DataMap> dataMapList;
         try {
             dataMapList = excelReader.getDataMapList();
         } catch (Exception e) {
@@ -521,13 +704,15 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 throw ExceptionResultEnum.ERROR.exception("通用规则未设置");
             }
 
+            // 必填字段
             Map<String, EnumResult> requiredMap = basicExamRule.getRequiredFieldList().stream().filter(m -> m.getEnable()).collect(Collectors.toMap(EnumResult::getName, e -> e));
+            // 扩展字段
             Map<String, EnumResult> extendMap = basicExamRule.getExtendFieldList().stream().filter(m -> m.getEnable()).collect(Collectors.toMap(EnumResult::getName, e -> e));
 
             // 通用规则表头
             List<String> actualTitleList = Stream.concat(requiredMap.keySet().stream(), extendMap.keySet().stream()).collect(Collectors.toList());
             if (!CollectionUtils.isEqualCollection(Arrays.asList(columnNames), actualTitleList)) {
-                throw ExceptionResultEnum.ERROR.exception("表头有误,表头字段应为【" + String.join(",", actualTitleList) + "】");
+                throw ExceptionResultEnum.ERROR.exception("表头名称错误,正确表头为【" + String.join(",", actualTitleList) + "】");
             }
 
             basicExamStudentParseDto.setColumnNames(columnNames);
@@ -1071,159 +1256,4 @@ public class ImportLogicServiceImpl implements ImportLogicService {
         }
         return map;
     }
-
-    @Transactional
-    @Override
-    public Map<String, Object> executeImportBasicExamStudentTeacherLogic(Map<String, Object> map, StringJoiner stringJoinerSummary) {
-        SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
-        InputStream inputStream = (InputStream) map.get("inputStream");
-        Long examId = SystemConstant.convertIdToLong(String.valueOf(map.get("examId")));
-        Long schoolId = requestUser.getSchoolId();
-        BasicExam basicExam = basicExamService.getById(examId);
-        if (Objects.isNull(basicExam)) {
-            throw ExceptionResultEnum.ERROR.exception("考试不存在");
-        }
-
-        SystemConstant.addSummary(stringJoinerSummary, "开始解析文件内容");
-        BasicExamStudentParseDto basicExamStudentParseDto;
-        try {
-            basicExamStudentParseDto = this.parseBasicExamStudent(schoolId, inputStream);
-        } catch (Exception e) {
-            SystemConstant.addSummary(stringJoinerSummary, "解析文件内容结束,解析失败。" + e.getMessage());
-            throw ExceptionResultEnum.ERROR.exception(e.getMessage());
-        }
-        SystemConstant.addSummary(stringJoinerSummary, "解析文件内容结束,开始进行数据校验");
-
-        List<BasicExamStudentImport> basicExamStudentImportList = basicExamStudentParseDto.getBasicExamStudentImportList();
-        if (CollectionUtils.isEmpty(basicExamStudentImportList)) {
-            throw ExceptionResultEnum.ERROR.exception("没有可导入数据");
-        }
-
-        List<BasicExamStudent> basicExamStudentList = basicExamStudentService.list(new QueryWrapper<BasicExamStudent>().lambda()
-                .select(BasicExamStudent::getId, BasicExamStudent::getCourseId, BasicExamStudent::getStudentCode, BasicExamStudent::getPaperNumber)
-                .eq(BasicExamStudent::getSchoolId, schoolId).eq(BasicExamStudent::getExamId, examId));
-        Map<String, BasicExamStudent> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), e -> e));
-
-        Map<String, Long> basicCourseIdMap = new HashMap<>();
-
-        // 课程学号唯一
-        List<String> courseCodeStudentCodeList = new ArrayList<>();
-        // 课程+教学班->任课老师
-        Map<String, Long> courseTeachClassTeacherMap = new HashMap<>();
-        // 是否有错误提示
-        boolean hasError = false;
-
-        // 必填字段为课程代码、开课学院、学号、教学班、任课老师工号、任课老师
-        List<String> requiredCodes = Arrays.asList(RequiredFieldsEnum.STUDENT_CODE.getCode(), RequiredFieldsEnum.COURSE_CODE.getCode(), RequiredFieldsEnum.TEACHING_ROOM_NAME.getCode(), RequiredFieldsEnum.TEACH_CLASS_NAME.getCode(), RequiredFieldsEnum.TEACHER_NAME.getCode(), RequiredFieldsEnum.TEACHER_CODE.getCode());
-
-        List<BasicExamStudent> basicExamStudents = new ArrayList<>();
-        for (BasicExamStudentImport basicExamStudentImport : basicExamStudentImportList) {
-            BasicExamStudent basicExamStudent = new BasicExamStudent();
-            StringJoiner stringJoiner = new StringJoiner(";");
-
-            // 校验excel内容
-            basicExamStudentImport.getRequiredFieldList().forEach(m -> {
-                if (requiredCodes.contains(m.getCode()) && StringUtils.isBlank(m.getValue())) {
-                    stringJoiner.add(m.getName() + "必填");
-                }
-            });
-
-            // 校验课程
-            String key = basicExamStudentImport.getCourseCode() + SystemConstant.HYPHEN + basicExamStudentImport.getTeachingRoomName();
-            if (!basicCourseIdMap.containsKey(key)) {
-                List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(schoolId, basicExamStudentImport.getTeachingRoomName());
-                if (CollectionUtils.isEmpty(sysOrgList)) {
-                    stringJoiner.add("开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]在学院层级不存在");
-                } else {
-                    SysOrg sysOrg = sysOrgList.get(0);
-                    // 校验课程代码和开课学院
-                    BasicCourse basicCourse = basicCourseService.getByTeachRoomIdAndCode(sysOrg.getId(), basicExamStudentImport.getCourseCode());
-                    if (Objects.isNull(basicCourse)) {
-                        stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]在开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]不存在");
-                    } else {
-                        basicExamStudent.setCourseId(basicCourse.getId());
-                        basicCourseIdMap.put(key, basicCourse.getId());
-                    }
-                }
-            } else {
-                basicExamStudent.setCourseId(basicCourseIdMap.get(key));
-            }
-
-            //校验任课老师
-            SysUser sysUser = sysUserService.getByLoginName(schoolId, basicExamStudentImport.getTeacherCode());
-            if (sysUser == null) {
-                stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]不存在");
-            } else {
-                if (!sysUser.getEnable()) {
-                    stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]已禁用");
-                } else if (!sysUser.getRealName().equals(basicExamStudentImport.getTeacherName())) {
-                    stringJoiner.add("任课老师[" + basicExamStudentImport.getTeacherName() + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
-                } else {
-                    basicExamStudent.setTeacherId(sysUser.getId());
-                }
-            }
-
-            if (basicExamStudent.getCourseId() != null) {
-                // 校验同课程下,同一教学班只能有一个任课老师
-                String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
-                if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
-                    Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
-                    if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
-                        stringJoiner.add("同课程下相同教学班,只能有一位任课老师");
-                    }
-                } else {
-                    courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
-                }
-
-                String studentKey = basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudentImport.getStudentCode();
-                if (courseIdStudentCodeMap.containsKey(studentKey)) {
-                    BasicExamStudent student = courseIdStudentCodeMap.get(studentKey);
-                    basicExamStudent.setId(student.getId());
-                    basicExamStudent.setPaperType(student.getPaperType());
-                    // 更新requiredFields中的任课老师和任课老师工号
-                    for (CodeNameEnableValue codeNameEnableValue : student.getRequiredFieldList()) {
-                        if (codeNameEnableValue.getCode().equals(RequiredFieldsEnum.TEACHER_CODE.getCode())) {
-                            codeNameEnableValue.setValue(basicExamStudentImport.getTeacherCode());
-                        }
-                        if (codeNameEnableValue.getCode().equals(RequiredFieldsEnum.TEACHER_NAME.getCode())) {
-                            codeNameEnableValue.setValue(basicExamStudentImport.getTeacherName());
-                        }
-                    }
-                    basicExamStudent.setRequiredFields(JSON.toJSONString(student.getRequiredFieldList()));
-                } else {
-                    stringJoiner.add(String.format("课程代码[%s],开课学院[%s],学号[%s]考生管理中不存在", basicExamStudentImport.getCourseCode(), basicExamStudentImport.getTeachingRoomName(), basicExamStudentImport.getStudentCode()));
-                }
-            }
-
-            // 校验课程学号唯一
-            String courseCodeStudentCode = basicExamStudentImport.getCourseCode() + basicExamStudentImport.getStudentCode();
-            if (courseCodeStudentCodeList.contains(courseCodeStudentCode)) {
-                stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号[" + basicExamStudentImport.getStudentCode() + "]的考生数据");
-            } else {
-                courseCodeStudentCodeList.add(courseCodeStudentCode);
-            }
-
-            if (stringJoiner.toString().length() > 0) {
-                basicExamStudentImport.setErrorMsg(stringJoiner.toString());
-            }
-
-            if (!hasError && stringJoiner.toString().length() > 0) {
-                hasError = true;
-            }
-
-            if (stringJoiner.toString().length() == 0) {
-                basicExamStudents.add(basicExamStudent);
-            }
-        }
-
-        map.put(SystemConstant.ERROR_DATA_LIST, basicExamStudentImportList);
-        map.put(SystemConstant.DATASOURCE, basicExamStudents);
-        map.put(SystemConstant.DATA_COUNT, basicExamStudentImportList.size());
-        map.put(SystemConstant.SUCCESS_DATA_COUNT, basicExamStudents.size());
-        map.put(SystemConstant.ERROR_DATA_COUNT, basicExamStudentImportList.size() - basicExamStudents.size());
-        map.put(SystemConstant.HAS_ERROR_DATA, hasError);
-        map.put(SystemConstant.COLUMN_NAMES, basicExamStudentParseDto.getColumnNames());
-
-        return map;
-    }
 }

+ 112 - 0
distributed-print-business/src/main/resources/mapper/ConditionMapper.xml

@@ -934,4 +934,116 @@
             </if>
         </if>
     </select>
+    <select id="listCourseForPrintCount" resultType="com.qmth.teachcloud.common.entity.BasicCourse">
+        select
+        distinct bc.id, bc.code,bc.name
+        from exam_task et
+         join basic_course bc on bc.id = et.course_id
+         join t_f_flow_approve tffa on tffa.flow_id = et.flow_id
+        <where>
+            and (et.status = 'SUBMIT' and (et.flow_id is null or (et.flow_id is not null and tffa.status = 'FINISH')))
+            AND et.exam_id = #{examId}
+            <if test="openCollegeId != null">
+                AND bc.teaching_room_id = #{openCollegeId}
+            </if>
+            <if test="dpr != null">
+                <if test="dpr.requestUserId != null">
+                    AND et.user_id = #{dpr.requestUserId}
+                </if>
+                <if test="dpr.courseUserId != null">
+                    AND EXISTS( SELECT 1 FROM (select course_id from teach_course where exam_id = #{examId} and user_id = #{dpr.courseUserId}) tc WHERE tc.course_id = et.course_id)
+                </if>
+                <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
+                    AND bc.teaching_room_id IN
+                    <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+            </if>
+        </where>
+    </select>
+    <select id="listCourseForScanCount" resultType="com.qmth.teachcloud.common.entity.BasicCourse">
+        select
+            distinct bc.id, bc.code,bc.name
+            from mark_paper mp
+             join basic_course bc on bc.id = mp.course_id
+            <where>
+                AND mp.exam_id = #{examId}
+                <if test="openCollegeId != null">
+                    AND bc.teaching_room_id = #{openCollegeId}
+                </if>
+                <if test="dpr != null">
+                    <if test="dpr.requestUserId != null">
+                        AND EXISTS( SELECT 1 FROM  (select exam_id, paper_number,basic_student_id from mark_student where exam_id = #{examId}) ms
+                        join
+                        (select id from basic_exam_student where exam_id = #{examId} and teacher_id = #{dpr.requestUserId}) bes on ms.basic_student_id = bes.id WHERE mp.exam_id = ms.exam_id and mp.paper_number = ms.paper_number)
+                    </if>
+                    <if test="dpr.courseUserId != null">
+                        AND EXISTS( SELECT 1 FROM (select course_id from teach_course where exam_id = #{examId} and user_id = #{dpr.courseUserId}) tc WHERE tc.course_id = mp.course_id)
+                    </if>
+                    <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
+                        AND bc.teaching_room_id IN
+                        <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+                </if>
+            </where>
+    </select>
+    <select id="listPaperNumberForPrintCount" resultType="java.lang.String">
+        select
+        distinct et.paper_number
+        from exam_task et
+         join basic_course bc on bc.id = et.course_id
+         join t_f_flow_approve tffa on tffa.flow_id = et.flow_id
+        <where>
+            and (et.status = 'SUBMIT' and (et.flow_id is null or (et.flow_id is not null and tffa.status = 'FINISH')))
+            AND et.exam_id = #{examId}
+            <if test="courseId != null">
+                AND bc.id = #{courseId}
+            </if>
+            <if test="dpr != null">
+                <if test="dpr.requestUserId != null">
+                    AND et.user_id = #{dpr.requestUserId}
+                </if>
+                <if test="dpr.courseUserId != null">
+                    AND EXISTS( SELECT 1 FROM (select course_id from teach_course where exam_id = #{examId} and user_id = #{dpr.courseUserId}) tc WHERE tc.course_id = et.course_id)
+                </if>
+                <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
+                    AND bc.teaching_room_id IN
+                    <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+            </if>
+        </where>
+    </select>
+    <select id="listPaperNumberForScanCount" resultType="java.lang.String">
+        select
+        distinct mp.paper_number
+        from mark_paper mp
+         join basic_course bc on bc.id = mp.course_id
+        <where>
+            AND mp.exam_id = #{examId}
+            <if test="courseId != null">
+                AND mp.course_id = #{courseId}
+            </if>
+            <if test="dpr != null">
+                <if test="dpr.requestUserId != null">
+                    AND EXISTS( SELECT 1 FROM  (select exam_id, paper_number,basic_student_id from mark_student where exam_id = #{examId}) ms
+                    join
+                    (select id from basic_exam_student where exam_id = #{examId} and teacher_id = #{dpr.requestUserId}) bes on ms.basic_student_id = bes.id WHERE mp.exam_id = ms.exam_id and mp.paper_number = ms.paper_number)
+                </if>
+                <if test="dpr.courseUserId != null">
+                    AND EXISTS( SELECT 1 FROM (select course_id from teach_course where exam_id = #{examId} and user_id = #{dpr.courseUserId}) tc WHERE tc.course_id = mp.course_id)
+                </if>
+                <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
+                    AND bc.teaching_room_id IN
+                    <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+            </if>
+        </where>
+    </select>
 </mapper>

+ 34 - 69
distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml

@@ -56,55 +56,6 @@
         WHERE 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,
-        bc.code as courseCode,
-        bc.name as courseName,
-        edc.paper_pages_a3 as paperPageA3,
-        edc.paper_number as paperNumber,
-        es.clazz_id clazzId,
-        es.clazz_name clazzName,
-        es.teach_clazz_name teachClazzName,
-        es.college_name collegeName,
-        es.major_name majorName,
-        es.teacher_id teacherId,
-        su.real_name teacherName
-        from
-            exam_student es
-                left join exam_detail_course edc on edc.id = es.exam_detail_course_id
-                left join basic_course bc on edc.course_id = bc.id
-                left join sys_user su on es.teacher_id = su.id
-        <where>
-            <if test="schoolId != null and schoolId != ''">
-                and es.school_id = #{schoolId}
-            </if>
-            <if test="examDetailCourseIds != null and examDetailCourseIds != '' and examDetailCourseIds.size > 0">
-                AND es.exam_detail_course_id IN
-                <foreach collection="examDetailCourseIds" item="examDetailCourseId" index="index" open="(" separator=","
-                         close=")">
-                    #{examDetailCourseId}
-                </foreach>
-            </if>
-        </where>
-        order by 0 + cast(es.site_number as char)
-    </select>
     <select id="listExamStudentBySchoolIdAndClazzId"
             resultType="com.qmth.distributed.print.business.entity.ExamStudent">
         SELECT
@@ -199,26 +150,6 @@
                               es.id = ms.id)
     </select>
 
-    <select id="queryExamStudent" resultType="com.qmth.distributed.print.business.bean.dto.ExamStudentDto">
-        SELECT
-            GROUP_CONCAT(DISTINCT es.teach_clazz_name) as clazzNames,
-            GROUP_CONCAT(DISTINCT su.real_name) as teacherNames
-        FROM
-            exam_student es
-            left join sys_user su on su.id = es.teacher_id
-            left join exam_detail_course edc on edc.id = exam_detail_course_id
-        <where>
-            <if test="examId != null and examId != ''">
-                AND es.exam_id = #{examId}
-            </if>
-            <if test="courseCode != null and courseCode != ''">
-                AND edc.course_code = #{courseCode}
-            </if>
-            <if test="paperNumber != null and paperNumber != ''">
-                AND es.paper_number = #{paperNumber}
-            </if>
-        </where>
-    </select>
     <select id="listByExamDetailCourseId" resultType="com.qmth.distributed.print.business.bean.dto.pdf.ExamStudentInfo"
             parameterType="java.lang.Long">
         SELECT
@@ -240,4 +171,38 @@
         WHERE
             es.exam_detail_course_id = #{examDetailCourseId}
     </select>
+
+    <select id="listMarkStudentInfo"
+            resultType="com.qmth.distributed.print.business.bean.dto.ExamStudentCourseClassDto">
+        SELECT
+            bc.code AS courseCode,
+            bc.name AS courseName,
+            ms.paper_number AS paperNumber,
+            ms.paper_type AS paperType,
+            btc.clazz_name AS clazzName,
+            teacher.login_name AS teacherNumber,
+            teacher.real_name AS teacherName
+        FROM
+            mark_student ms
+                LEFT JOIN
+            basic_exam_student bes ON ms.basic_student_id = bes.id
+                LEFT JOIN
+            basic_course bc ON ms.course_id = bc.id
+                LEFT JOIN
+            basic_teach_clazz btc ON btc.id = bes.clazz_id
+                LEFT JOIN
+            sys_user teacher ON teacher.id = bes.teacher_id
+        <where>
+            <if test="examId != null">
+                AND ms.exam_id = #{examId}
+            </if>
+            <if test="paperNumber != null and paperNumber != ''">
+                AND ms.paper_number = #{paperNumber}
+            </if>
+            <if test="paperType != null and paperType != ''">
+                AND ms.paper_type = #{paperType}
+            </if>
+        </where>
+        GROUP BY courseCode , courseName , paperNumber , paperType , clazzName , teacherNumber , teacherName
+    </select>
 </mapper>

+ 8 - 5
distributed-print-business/src/main/resources/mapper/GradeInitializeMapper.xml

@@ -8,8 +8,9 @@
             bs.name AS semesterName,
             be.id AS examId,
             be.name AS examName,
-            et.course_code AS courseCode,
-            et.course_name AS courseName,
+            bc.id AS courseId,
+            bc.code AS courseCode,
+            bc.name AS courseName,
             et.paper_number AS paperNumber,
             pnpt.paper_type AS paperType,
             pnpt.paper_name AS paperName,
@@ -41,6 +42,8 @@
             basic_exam be ON et.exam_id = be.id AND be.enable
                 INNER JOIN
             basic_semester bs ON bs.id = be.semester_id AND bs.enable
+                LEFT JOIN
+            basic_course bc ON et.course_id = bc.id
         <where>
             <if test="schoolId != null and schoolId != ''">
                 AND et.school_id = #{schoolId}
@@ -51,8 +54,8 @@
             <if test="examId != null and examId != ''">
                 AND be.id = #{examId}
             </if>
-            <if test="courseCode != null and courseCode != ''">
-                AND et.course_code = #{courseCode}
+            <if test="courseId != null">
+                AND bc.id = #{courseId}
             </if>
             <if test="dpr != null">
                 <if test="dpr.requestUserId != null">
@@ -66,7 +69,7 @@
                 </if>
             </if>
         </where>
-        ORDER BY bs.name , be.name , et.course_code ,et.exam_id, et.paper_number , pnpt.paper_type
+        ORDER BY bs.name , be.name , et.course_id ,et.exam_id, et.paper_number , pnpt.paper_type
     </select>
 
     <select id="listNeedAnalyzedPaperToWork"

+ 4 - 2
distributed-print-business/src/main/resources/mapper/GradePaperDimensionMapper.xml

@@ -5,8 +5,8 @@
     <select id="findGradePaperDimensionList"
             resultType="com.qmth.distributed.print.business.bean.result.analyze.GradePaperDimensionResult">
         SELECT
-            et.course_code AS courseCode,
-            et.course_name AS courseName,
+            bc.code AS courseCode,
+            bc.name AS courseName,
             gpd.dimension_type AS dimensionType,
             gpd.code_primary AS codePrimary,
             gpd.name_primary AS namePrimary,
@@ -19,6 +19,8 @@
             exam_task et ON gpd.school_id = et.school_id
                 AND gpd.exam_id = et.exam_id
                 AND gpd.paper_number = et.paper_number
+                LEFT JOIN
+            basic_course bc ON et.course_id = bc.id
         <where>
             <if test="schoolId != null and schoolId != ''">
                 AND gpd.school_id = #{schoolId}

+ 5 - 4
distributed-print-business/src/main/resources/mapper/GradePaperStructMapper.xml

@@ -25,8 +25,8 @@
     <select id="findStructByGradePaper"
             resultType="com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructResult">
         SELECT
-            et.course_code AS courseCode,
-            et.course_name AS courseName,
+            bc.code AS courseCode,
+            bc.name AS courseName,
             gps.paper_number AS paperNumber,
             gps.paper_type AS paperType,
             gps.number_type AS numberType,
@@ -44,13 +44,14 @@
                  school_id,
                  exam_id,
                  paper_number,
-                 MAX(course_code) AS course_code,
-                 MAX(course_name) AS course_name
+                 MAX(course_id) AS course_id
              FROM
                  exam_task
              GROUP BY school_id ,exam_id, paper_number) et ON gps.school_id = et.school_id
                 AND gps.exam_Id = et.exam_id
                 AND gps.paper_number = et.paper_number
+                LEFT JOIN
+            basic_course bc ON et.course_id = bc.id
         <where>
             <if test="schoolId != null and schoolId != ''">
                 AND gps.school_id = #{schoolId}

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

@@ -45,14 +45,14 @@ public class GradePaperController {
     @ApiOperation(value = "成绩分析课程数据初始化")
     @RequestMapping(value = "/initialize", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = GradeInitResult.class)})
-    public Result findGradePaperInitialize(@ApiParam(value = "学期id") @RequestParam(required = false) String semesterId,
-                                           @ApiParam(value = "考试id") @RequestParam(required = false) String examId,
-                                           @ApiParam(value = "课程编号") @RequestParam(required = false) String courseCode,
+    public Result findGradePaperInitialize(@ApiParam(value = "学期id") @RequestParam(required = false) Long semesterId,
+                                           @ApiParam(value = "考试id") @RequestParam(required = false) Long examId,
+                                           @ApiParam(value = "课程编号") @RequestParam(required = false) Long courseId,
                                            @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                                            @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
 
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        return ResultUtil.ok(gradeInitializeService.findNeedAnalyzedPaper(SystemConstant.convertIdToLong(semesterId), SystemConstant.convertIdToLong(examId), courseCode, requestUser, pageNumber, pageSize));
+        return ResultUtil.ok(gradeInitializeService.findNeedAnalyzedPaper(semesterId, examId, courseId, requestUser, pageNumber, pageSize));
     }
 
     @ApiOperation(value = "成绩分析课程-查询定义")

+ 3 - 5
distributed-print/src/main/java/com/qmth/distributed/print/api/GradePaperDimensionController.java

@@ -100,15 +100,13 @@ public class GradePaperDimensionController {
     @RequestMapping(value = "/export", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
     @OperationLogDetail(operationType = OperationTypeEnum.EXPORT)
-    public Result gradePaperDimensionExport(@ApiParam(value = "课程编号", required = true) @RequestParam String courseCode,
-                                            @ApiParam(value = "课程名称", required = true) @RequestParam String courseName,
+    public Result gradePaperDimensionExport(@ApiParam(value = "课程Id", required = true) @RequestParam Long courseId,
                                             @ApiParam(value = "维度类型", required = true) @RequestParam DimensionEnum dimensionType) throws Exception {
 
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        if (SystemConstant.isOneNull(courseCode, courseName, dimensionType)) {
+        if (SystemConstant.isOneNull(courseId, dimensionType)) {
             throw ExceptionResultEnum.ERROR.exception("参数不完整");
         }
-        gradePaperDimensionService.exportGradePaperDimensionTemplate(courseCode, courseName, dimensionType);
+        gradePaperDimensionService.exportGradePaperDimensionTemplate(courseId, dimensionType);
         return ResultUtil.ok();
     }
 }

+ 34 - 27
distributed-print/src/main/java/com/qmth/distributed/print/api/GradePaperStructController.java

@@ -5,6 +5,7 @@ import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructP
 import com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructResult;
 import com.qmth.distributed.print.business.service.GradePaperStructService;
 import com.qmth.teachcloud.common.annotation.OperationLogDetail;
+import com.qmth.teachcloud.common.bean.result.MarkQuestionResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.MarkQuestion;
 import com.qmth.teachcloud.common.entity.SysUser;
@@ -39,31 +40,36 @@ import java.util.List;
 @Validated
 //@Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
 public class GradePaperStructController {
+
     @Resource
     private GradePaperStructService gradePaperStructService;
+
     @Resource
     private MarkQuestionService markQuestionService;
 
     @ApiOperation(value = "成绩分析试卷结构-查询")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = GradePaperStructResult.class)})
-    public Result findGradePaperStructList(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
-                                           @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
-                                           @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = GradePaperStructResult.class) })
+    public Result findGradePaperStructList(@ApiParam(value = "考试id", required = true) @RequestParam Long examId, @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
+            @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType) {
 
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         if (SystemConstant.isOneNull(paperNumber, paperType)) {
             throw ExceptionResultEnum.ERROR.exception("试卷参数不完整");
         }
-        List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null);
-        return ResultUtil.ok(gradePaperStructService.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser, markQuestionList));
+        List<MarkQuestionResult> markQuestionList = markQuestionService.listDetailByExamIdAndPaperNumberAndPaperType(
+                examId, paperNumber, paperType, null);
+        return ResultUtil.ok(
+                gradePaperStructService.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser,
+                        markQuestionList));
     }
 
     @ApiOperation(value = "成绩分析试卷结构-新建试卷结构")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "更新成功", response = Result.class) })
     @OperationLogDetail(operationType = OperationTypeEnum.ADD)
-    public Result saveGradePaperStructBatch(@Valid @RequestBody GradePaperStructParam gradePaperStructParam, BindingResult bindingResult) {
+    public Result saveGradePaperStructBatch(@Valid @RequestBody GradePaperStructParam gradePaperStructParam,
+            BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
@@ -74,51 +80,52 @@ public class GradePaperStructController {
 
     @ApiOperation(value = "成绩分析试卷结构-导入")
     @RequestMapping(value = "/import", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     @OperationLogDetail(operationType = OperationTypeEnum.IMPORT)
-    public Result gradePaperStructImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
-                                         @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
-                                         @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType,
-                                         @ApiParam(value = "试卷名称", required = true) @RequestParam String paperName) throws IOException, NoSuchFieldException {
+    public Result gradePaperStructImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @ApiParam(value = "考试id", required = true) @RequestParam Long examId,
+            @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber, @ApiParam(value = "试卷类型", required = true) @RequestParam String paperType,
+            @ApiParam(value = "试卷名称", required = true) @RequestParam String paperName) throws IOException, NoSuchFieldException {
 
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        if (SystemConstant.isOneNull(file, paperNumber, paperType, paperName)) {
+        if (SystemConstant.isOneNull(file, examId, paperNumber, paperType, paperName)) {
             throw ExceptionResultEnum.ERROR.exception("参数不完整");
         }
-        gradePaperStructService.importGradePaperStruct(file, paperNumber, paperType, paperName, requestUser);
+        gradePaperStructService.importGradePaperStruct(file, examId, paperNumber, paperType, paperName, requestUser);
         return ResultUtil.ok();
     }
 
     @ApiOperation(value = "成绩分析试卷结构-模板导出")
     @RequestMapping(value = "/export", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     @OperationLogDetail(operationType = OperationTypeEnum.EXPORT)
-    public Result gradePaperStructExport(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
-                                         @ApiParam(value = "课程编号", required = true) @RequestParam String paperNumber,
-                                         @ApiParam(value = "课程名称", required = true) @RequestParam String paperType) throws Exception {
+    public Result gradePaperStructExport(@ApiParam(value = "考试id", required = true) @RequestParam Long examId, @ApiParam(value = "课程编号", required = true) @RequestParam String paperNumber,
+            @ApiParam(value = "课程名称", required = true) @RequestParam String paperType) throws Exception {
 
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         if (SystemConstant.isOneNull(examId, paperNumber, paperType)) {
             throw ExceptionResultEnum.ERROR.exception("参数不完整");
         }
-        List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null);
-        gradePaperStructService.exportGradePaperStructTemplate(examId, paperNumber, paperType, requestUser, markQuestionList);
+        List<MarkQuestionResult> markQuestionList = markQuestionService.listDetailByExamIdAndPaperNumberAndPaperType(
+                examId, paperNumber, paperType, null);
+        gradePaperStructService.exportGradePaperStructTemplate(examId, paperNumber, paperType, requestUser,
+                markQuestionList);
         return ResultUtil.ok();
     }
 
     @ApiOperation(value = "成绩分析试卷结构-更新试卷机构")
     @RequestMapping(value = "/change_paper_structure", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "更新成功", response = Result.class) })
     @OperationLogDetail(operationType = OperationTypeEnum.UPDATE)
-    public Result updateExamCloudPaperStruct(@ApiParam(value = "考试ID", required = true) @RequestParam Long examId,
-                                             @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
-                                             @ApiParam(value = "试卷类型") @RequestParam(required = false) String paperType) {
+    public Result updateExamCloudPaperStruct(@ApiParam(value = "考试ID", required = true) @RequestParam Long examId, @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber,
+            @ApiParam(value = "试卷类型") @RequestParam(required = false) String paperType) {
         if (SystemConstant.isOneNull(paperNumber)) {
             throw ExceptionResultEnum.ERROR.exception("缺少试卷编号");
         }
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, null);
-        gradePaperStructService.updateExamCloudPaperStruct(requestUser.getSchoolId(), paperNumber, paperType, markQuestionList);
+        List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndPaperType(examId,
+                paperNumber, paperType, null);
+        gradePaperStructService.updateExamCloudPaperStruct(requestUser.getSchoolId(), paperNumber, paperType,
+                markQuestionList);
         return ResultUtil.ok();
     }
 }

+ 48 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/result/MarkQuestionResult.java

@@ -0,0 +1,48 @@
+package com.qmth.teachcloud.common.bean.result;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.teachcloud.common.entity.MarkQuestion;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 试卷结构详情(带课程信息)
+ * @Author: CaoZixuan
+ * @Date: 2024-07-11
+ */
+public class MarkQuestionResult extends MarkQuestion {
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "课程id")
+    private Long courseId;
+
+    @ApiModelProperty(value = "课程编号")
+    private String courseCode;
+
+    @ApiModelProperty(value = "课程名称")
+    private String courseName;
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    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;
+    }
+}

+ 7 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/mapper/MarkQuestionMapper.java

@@ -1,9 +1,12 @@
 package com.qmth.teachcloud.mark.mapper;
 
-import com.qmth.teachcloud.common.entity.MarkQuestion;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.teachcloud.common.bean.result.MarkQuestionResult;
+import com.qmth.teachcloud.common.entity.MarkQuestion;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * <p>
  * 小题信息表 Mapper 接口
@@ -17,4 +20,7 @@ public interface MarkQuestionMapper extends BaseMapper<MarkQuestion> {
     String assembleQuestionsByExamIdAndPaperNumberAndNumber(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("groupNumber") Integer groupNumber);
 
     Double sumTotalScoreByGroupNumber(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("groupNumber") Integer groupNumber);
+
+    List<MarkQuestionResult> listByExamIdAndPaperNumberAndPaperType(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("paperType") String paperType,
+            @Param("objective") Boolean objective);
 }

+ 3 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkQuestionService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import javax.servlet.http.HttpServletResponse;
 
+import com.qmth.teachcloud.common.bean.result.MarkQuestionResult;
 import org.springframework.web.multipart.MultipartFile;
 
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -77,6 +78,8 @@ public interface MarkQuestionService extends IService<MarkQuestion> {
 
     List<MarkQuestion> listByExamIdAndPaperNumberAndPaperType(Long examId, String paperNumber, String paperType, Boolean objective);
 
+    List<MarkQuestionResult> listDetailByExamIdAndPaperNumberAndPaperType(Long examId, String paperNumber, String paperType, Boolean objective);
+
     void deleteByExamIdAndPaperNumber(Long examId, String paperNumber);
 
     /**

+ 1 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkStudentService.java

@@ -209,6 +209,7 @@ public interface MarkStudentService extends IService<MarkStudent> {
     void updateByBasicExamStudent(BasicExamStudent basicExamStudent, MarkPaper markPaper, Set<String> secretNumberSet);
 
     void deleteByExamIdAndPaperNumberAndStudentCode(Long examId, String paperNumber, String studentCode);
+    void deleteByBasicStudentId(Long basicStudentId);
 
     Integer maxCardNumber(Long examId, String paperNumber, String paperType);
 

+ 6 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkQuestionServiceImpl.java

@@ -7,6 +7,7 @@ import java.util.stream.Stream;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 
+import com.qmth.teachcloud.common.bean.result.MarkQuestionResult;
 import com.qmth.teachcloud.mark.service.*;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
@@ -510,6 +511,11 @@ public class MarkQuestionServiceImpl extends ServiceImpl<MarkQuestionMapper, Mar
         return this.list(queryWrapper);
     }
 
+    @Override
+    public List<MarkQuestionResult> listDetailByExamIdAndPaperNumberAndPaperType(Long examId, String paperNumber, String paperType, Boolean objective) {
+        return this.baseMapper.listByExamIdAndPaperNumberAndPaperType(examId, paperNumber, paperType, objective);
+    }
+
     @Override
     public void deleteByExamIdAndPaperNumber(Long examId, String paperNumber) {
         UpdateWrapper<MarkQuestion> updateWrapper = new UpdateWrapper<>();

+ 7 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java

@@ -1805,6 +1805,13 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
         this.remove(updateWrapper);
     }
 
+    @Override
+    public void deleteByBasicStudentId(Long basicStudentId) {
+        UpdateWrapper<MarkStudent> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().eq(MarkStudent::getBasicStudentId, basicStudentId);
+        this.remove(updateWrapper);
+    }
+
     @Override
     public Integer maxCardNumber(Long examId, String paperNumber, String paperType) {
         return this.baseMapper.maxCardNumber(examId, paperNumber, paperType);

+ 50 - 0
teachcloud-mark/src/main/resources/mapper/ClientUpgradeService.xml → teachcloud-mark/src/main/resources/mapper/MarkQuestionMapper.xml

@@ -41,5 +41,55 @@
           AND q.paper_number = #{paperNumber}
           AND q.group_number = #{groupNumber}
     </select>
+    <select id="listByExamIdAndPaperNumberAndPaperType"
+            resultType="com.qmth.teachcloud.common.bean.result.MarkQuestionResult">
+        SELECT
+            mq.id AS id,
+            mq.exam_id AS examId,
+            mq.paper_number AS paperNumber,
+            mq.paper_type AS paperType,
+            mq.objective AS objective,
+            mq.group_number AS groupNumber,
+            mq.main_number AS mainNumber,
+            mq.sub_number AS subNumber,
+            mq.main_title AS mainTitle,
+            mq.answer AS answer,
+            mq.total_score AS totalScore,
+            mq.option_count AS optionCount,
+            mq.interval_score AS intervalScore,
+            mq.objective_policy AS objectivePolicy,
+            mq.question_type AS questionType,
+            mq.name AS name,
+            mq.paper_index AS paperIndex,
+            mq.page_index AS pageIndex,
+            mq.objective_policy_score AS objectivePolicyScore,
+            mq.create_id AS createId,
+            mq.create_time AS createTime,
+            mq.update_id AS updateId,
+            mq.update_time AS updateTime,
+            bc.code AS courseCode,
+            bc.name AS courseName,
+            bc.id AS courseId
+        FROM
+            mark_question mq
+                LEFT JOIN
+            exam_task et ON mq.exam_id = et.exam_id AND et.paper_number = mq.paper_number
+                LEFT JOIN
+            basic_course bc ON et.course_id = bc.id
+        <where>
+            <if test="examId != null">
+                AND mq.exam_id = #{examId}
+            </if>
+            <if test="paperType != null and paperType != ''">
+                AND mq.paper_type = #{paperType}
+            </if>
+            <if test="paperNumber != null and paperNumber != ''">
+                AND mq.paper_number = #{paperNumber}
+            </if>
+            <if test="objective != null">
+                AND mq.objective = #{objective}
+            </if>
+        </where>
+    </select>
 
 </mapper>