Browse Source

fix:bugfix

caozixuan 1 year ago
parent
commit
a457eefec8
16 changed files with 226 additions and 165 deletions
  1. 3 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/BasicTeachClazzMapper.java
  2. 3 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicTeachClazzService.java
  3. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ConditionService.java
  4. 20 14
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java
  5. 3 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicTeachClazzServiceImpl.java
  6. 9 8
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ConditionServiceImpl.java
  7. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachCourseServiceImpl.java
  8. 4 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/SyncBasicExamStudentImportService.java
  9. 3 0
      distributed-print-business/src/main/resources/mapper/BasicTeachClazzMapper.xml
  10. 1 1
      distributed-print-business/src/main/resources/mapper/TeachClazzMapper.xml
  11. 3 2
      distributed-print/src/main/java/com/qmth/distributed/print/api/ConditionController.java
  12. BIN
      distributed-print/src/main/resources/temps/basicExamStudent.xlsx
  13. 0 21
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/BasicCourseExportDto.java
  14. 17 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/mapper/BasicCourseMapper.java
  15. 128 105
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java
  16. 30 0
      teachcloud-common/src/main/resources/mapper/BasicCourseMapper.xml

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

@@ -20,8 +20,9 @@ public interface BasicTeachClazzMapper extends BaseMapper<BasicTeachClazz> {
     /**
      * 查询教学课程字典集合
      *
-     * @param examId 考试id
+     * @param examId    考试id
+     * @param clazzName 班级名称
      * @return 教学课程字典集合
      */
-    List<BasicTeachClazzResult> findTeachClazzList(@Param("examId") Long examId);
+    List<BasicTeachClazzResult> findTeachClazzList(@Param("examId") Long examId, @Param("clazzName") String clazzName);
 }

+ 3 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicTeachClazzService.java

@@ -31,8 +31,9 @@ public interface BasicTeachClazzService extends IService<BasicTeachClazz> {
     /**
      * 查询所有加血版
      *
-     * @param examId 考试id
+     * @param examId    考试id
+     * @param clazzName 班级名称
      * @return 教学班结果
      */
-    List<BasicTeachClazzResult> findAllTeachClazz(Long examId);
+    List<BasicTeachClazzResult> findAllTeachClazz(Long examId, String clazzName);
 }

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

@@ -28,5 +28,5 @@ public interface ConditionService {
 
     List<SysOrg> listCollege();
 
-    List<BasicTeachClazzResult> listBasicTeachClazz(Long examId);
+    List<BasicTeachClazzResult> listBasicTeachClazz(Long examId, String clazzName);
 }

+ 20 - 14
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -213,26 +213,32 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
             errorMsgList.add("缺少教学班名称");
         }
 
-        // 校验2 试卷编号存在时,任课教师,考试时间,考点考场均必填;
         Long teacherId = null;
+        if (SystemConstant.strNotNull(teacherCode) && !SystemConstant.strNotNull(teacherName)){
+            errorMsgList.add("存在任课老师工号,但缺少任课老师姓名");
+        }
+        if (SystemConstant.strNotNull(teacherName) && !SystemConstant.strNotNull(teacherCode)){
+            errorMsgList.add("存在任课老师姓名,但缺少任课老师工号");
+        }
+        if (SystemConstant.strNotNull(teacherName) && SystemConstant.strNotNull(teacherCode)){
+            // 存在教师信息,根据工号查询,不存在报错(缺少机构信息没法直接创建教师)
+            SysUser teacher = sysUserService.getOne(
+                    new QueryWrapper<SysUser>().lambda().eq(SysUser::getSchoolId, schoolId)
+                            .eq(SysUser::getCode, teacherCode).eq(SysUser::getRealName, teacherName)
+                            .last(SystemConstant.LIMIT1));
+            if (Objects.isNull(teacher)) {
+                errorMsgList.add(String.format("工号为[%s],姓名为[%s]的老师不存在,请先创建", teacherCode, teacherName));
+            } else {
+                teacherId = teacher.getId();
+            }
+        }
+
+        // 校验2 试卷编号存在时,任课教师,考试时间,考点考场均必填;
         if (SystemConstant.strNotNull(paperNumber)) {
             String hasPaperNumberError = "存在试卷编号时: ";
             if (!SystemConstant.strNotNull(teacherCode) || !SystemConstant.strNotNull(teacherName)) {
                 errorMsgList.add(hasPaperNumberError + "缺少任课教师信息");
-            } else {
-                // 存在教师信息,根据工号查询,不存在报错(缺少机构信息没法直接创建教师),存在更新姓名
-                SysUser teacher = sysUserService.getOne(
-                        new QueryWrapper<SysUser>().lambda().eq(SysUser::getSchoolId, schoolId)
-                                .eq(SysUser::getCode, teacherCode).eq(SysUser::getRealName, teacherName)
-                                .last(SystemConstant.LIMIT1));
-                if (Objects.isNull(teacher)) {
-                    errorMsgList.add(String.format("工号为[%s],姓名为[%s]的教师不存在,请先创建", teacherCode, teacherName));
-                } else {
-                    teacherId = teacher.getId();
-                }
-
             }
-
             if (!SystemConstant.longNotNull(examStartTime) || !SystemConstant.longNotNull(examEndTime)) {
                 errorMsgList.add(hasPaperNumberError + "缺少考试时间");
             }

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

@@ -48,7 +48,8 @@ public class BasicTeachClazzServiceImpl extends ServiceImpl<BasicTeachClazzMappe
     }
 
     @Override
-    public List<BasicTeachClazzResult> findAllTeachClazz(Long examId) {
-        return this.baseMapper.findTeachClazzList(examId);
+    public List<BasicTeachClazzResult> findAllTeachClazz(Long examId, String clazzName) {
+        clazzName = SystemConstant.translateSpecificSign(clazzName);
+        return this.baseMapper.findTeachClazzList(examId, clazzName);
     }
 }

+ 9 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ConditionServiceImpl.java

@@ -95,7 +95,7 @@ public class ConditionServiceImpl implements ConditionService {
         // 入库审核菜单
         else if ("41".equals(privilegeIdString)) {
             return conditionMapper.listCourseForAudit(semesterId, examId, enable);
-        } else if("47".equals(privilegeIdString)){
+        } else if ("47".equals(privilegeIdString)) {
             dpr = basicRoleDataPermissionService.findDataPermission(privilegeId);
             return conditionMapper.listCourseForPlanTask(semesterId, examId, printPlanIds, dpr);
         }
@@ -105,7 +105,8 @@ public class ConditionServiceImpl implements ConditionService {
             if (basicCourses.isEmpty()) {
                 dpr = basicRoleDataPermissionService.findDataPermission(privilegeId);
             }
-            return conditionMapper.listCourseForScore(semesterId, examId, basicCourses, MarkPaperStatus.FINISH.name(), dpr);
+            return conditionMapper.listCourseForScore(semesterId, examId, basicCourses, MarkPaperStatus.FINISH.name(),
+                    dpr);
         } else {
             dpr = basicRoleDataPermissionService.findDataPermission(privilegeId);
             return conditionMapper.listCourse(semesterId, examId, enable, printPlanIds, dpr);
@@ -135,7 +136,7 @@ public class ConditionServiceImpl implements ConditionService {
         // 入库审核菜单
         else if ("41".equals(privilegeIdString)) {
             return conditionMapper.listPaperNumberAudit(semesterId, examId, courseCode);
-        } else if("47".equals(privilegeIdString)){
+        } else if ("47".equals(privilegeIdString)) {
             return conditionMapper.listPaperNumberPlanTask(semesterId, examId, printPlanIds, courseCode, dpr);
         } else {
             return conditionMapper.listPaperNumber(semesterId, examId, courseCode, printPlanIds, dpr);
@@ -150,7 +151,8 @@ public class ConditionServiceImpl implements ConditionService {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
 
         if ("client".equals(source)) {
-            String[] examDetailStatus = new String[]{ExamDetailStatusEnum.NEW.name(), PrintPlanStatusEnum.READY.name()};
+            String[] examDetailStatus = new String[] { ExamDetailStatusEnum.NEW.name(),
+                    PrintPlanStatusEnum.READY.name() };
             return conditionMapper.listPrintPlanForClient(semesterId, examId, examDetailStatus);
         } else {
             // 如果byAssignUser为true时,不能通过层级关系查询
@@ -180,15 +182,14 @@ public class ConditionServiceImpl implements ConditionService {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         SysOrg rootOrg = sysOrgService.findRootOrg(schoolId);
         QueryWrapper<SysOrg> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(SysOrg::getParentId, rootOrg.getId())
-                .isNull(SysOrg::getType)
+        queryWrapper.lambda().eq(SysOrg::getParentId, rootOrg.getId()).isNull(SysOrg::getType)
                 .orderByAsc(SysOrg::getCreateTime);
         return sysOrgService.list(queryWrapper);
     }
 
     @Override
-    public List<BasicTeachClazzResult> listBasicTeachClazz(Long examId) {
-        return basicTeachClazzService.findAllTeachClazz(examId);
+    public List<BasicTeachClazzResult> listBasicTeachClazz(Long examId, String clazzName) {
+        return basicTeachClazzService.findAllTeachClazz(examId, clazzName);
     }
 
 }

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

@@ -444,7 +444,7 @@ public class TeachCourseServiceImpl extends ServiceImpl<TeachCourseMapper, Teach
             throw ExceptionResultEnum.ERROR.exception("教学课程不存在");
         }
         // 教学课程主管责任人
-        Long leaderId = teachCourse.getUserId();
+        Long leaderId = teachCourse.getCreateId();
 
         if (SystemConstant.strNotNull(userInfo)) {
             userInfo = SystemConstant.translateSpecificSign(userInfo);

+ 4 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/SyncBasicExamStudentImportService.java

@@ -76,7 +76,6 @@ public class SyncBasicExamStudentImportService extends SyncImportTaskTemplate {
         int successCount = 0;
         int errorCount = 0;
         List<BasicExamStudentDto> errorDataList = new ArrayList<>();
-        boolean importResult = true;
 
         try {
             TaskLogicService taskLogicService = SpringContextHolder.getBean(TaskLogicService.class);
@@ -96,11 +95,11 @@ public class SyncBasicExamStudentImportService extends SyncImportTaskTemplate {
                 // 有异常数据
                 errorDataList = JSON.parseArray(JSON.toJSONString(result.get(SystemConstant.ERROR_DATA_LIST)),
                         BasicExamStudentDto.class);
+                throw ExceptionResultEnum.ERROR.exception("导入考生字典失败,请通过'导入结果查询'查看错误原因");
             }
-
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e.getMessage());
-            throw ExceptionResultEnum.ERROR.exception("导入考生字典失败");
+            throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         } finally {//生成文件
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}{4}{5}{6}{7}",
                     DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, dataCount,
@@ -118,15 +117,14 @@ public class SyncBasicExamStudentImportService extends SyncImportTaskTemplate {
                 } finally {
                     tbTask.setSummary("创建考生字典导入错误数据文件失败" + stringJoinerSummary);
                 }
-                importResult = false;
             } else {
                 tbTask.setSummary(stringJoinerSummary.toString());
                 tbTask.setResult(TaskResultEnum.SUCCESS);
             }
             tbTask.setStatus(TaskStatusEnum.FINISH);
-            super.createTxt(tbTask);
+            tbTaskService.updateById(tbTask);
         }
-        return ResultUtil.ok(importResult);
+        return ResultUtil.ok();
     }
 
     private void createLocalErrorExcel(List<BasicExamStudentDto> basicExamStudentDtoList, File excelFileTemp)

+ 3 - 0
distributed-print-business/src/main/resources/mapper/BasicTeachClazzMapper.xml

@@ -15,6 +15,9 @@
             <if test="examId != null">
                 AND exam_id = #{examId}
             </if>
+            <if test="clazzName != null and clazzName != ''">
+                AND clazz_name LIKE CONCAT('%',#{clazzName},'%')
+            </if>
         </where>
     </select>
 </mapper>

+ 1 - 1
distributed-print-business/src/main/resources/mapper/TeachClazzMapper.xml

@@ -18,7 +18,7 @@
                 AND teach_course_id = #{teachCourseId}
             </if>
             <if test="teachClazzName != null and teachClazzName != ''">
-                AND teach_clazz_name LIKE CONCAT('%',#{teachClazzName},'%')
+                AND clazz_name LIKE CONCAT('%',#{teachClazzName},'%')
             </if>
             <if test="belongTeachCourseId != null">
                 AND belong_teach_course_id = #{belongTeachCourseId}

+ 3 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/ConditionController.java

@@ -112,7 +112,8 @@ public class ConditionController {
     @ApiOperation(value = "教学班字典")
     @RequestMapping(value = "/list_basic_teach_clazz", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = Map.class) })
-    public Result listBasicTeachClazz(@ApiParam(value = "考试ID", required = true) @RequestParam(value = "examId") String examId) {
-        return ResultUtil.ok(conditionService.listBasicTeachClazz(SystemConstant.convertIdToLong(examId)));
+    public Result listBasicTeachClazz(@ApiParam(value = "考试ID", required = true) @RequestParam(value = "examId") String examId,
+            @ApiParam(value = "名称") @RequestParam(value = "clazzName", required = false) String clazzName) {
+        return ResultUtil.ok(conditionService.listBasicTeachClazz(SystemConstant.convertIdToLong(examId), clazzName));
     }
 }

BIN
distributed-print/src/main/resources/temps/basicExamStudent.xlsx


+ 0 - 21
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/BasicCourseExportDto.java

@@ -35,11 +35,6 @@ public class BasicCourseExportDto {
     @ExcelProperty(name = "授课老师", width = 20, index = 5)
     private String teachName = "";
 
-    private Boolean enable;
-
-    @ExcelProperty(name = "状态", width = 15, index = 6)
-    private String enableName;
-
     public String getTeachName() {
         return teachName;
     }
@@ -95,20 +90,4 @@ public class BasicCourseExportDto {
     public void setClazzName(String clazzName) {
         this.clazzName = clazzName;
     }
-
-    public Boolean getEnable() {
-        return enable;
-    }
-
-    public void setEnable(Boolean enable) {
-        this.enable = enable;
-    }
-
-    public String getEnableName() {
-        return enableName;
-    }
-
-    public void setEnableName(String enableName) {
-        this.enableName = enableName;
-    }
 }

+ 17 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/mapper/BasicCourseMapper.java

@@ -7,6 +7,7 @@ import com.qmth.teachcloud.common.bean.dto.BasicCourseExportDto;
 import com.qmth.teachcloud.common.bean.dto.CourseInfoDto;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.bean.result.BasicCourseResult;
+import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import org.apache.ibatis.annotations.Param;
 
@@ -62,4 +63,20 @@ public interface BasicCourseMapper extends BaseMapper<BasicCourse> {
      * @return 已占用课程编号集合
      */
     List<String> findOccupiedCourseCode(@Param("examId") Long examId, @Param("userId") Long userId);
+
+    /**
+     * 查询考生字典中的课程名集合
+     *
+     * @param courseCodeSet 课程编号集合
+     * @return 课程名集合
+     */
+    List<String> findBasicExamStudentCourseName(@Param("schoolId") Long schoolId, @Param("courseCodeSet") Set<String> courseCodeSet);
+
+    /**
+     * 查询教学课程中的课程名集合
+     *
+     * @param courseCodeSet 课程编号集合
+     * @return 课程名集合
+     */
+    List<String> findTeachCourseCourseName(@Param("schoolId") Long schoolId, @Param("courseCodeSet") Set<String> courseCodeSet);
 }

+ 128 - 105
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java

@@ -86,7 +86,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
 
     @Override
     public BasicCourse findByCourseCode(String courseCode, Long schoolId) {
-        BasicCourse basicCourse = this.getOne(new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getCode, courseCode).eq(BasicCourse::getSchoolId, schoolId));
+        BasicCourse basicCourse = this.getOne(
+                new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getCode, courseCode).eq(BasicCourse::getSchoolId, schoolId));
         if (Objects.isNull(basicCourse)) {
             throw ExceptionResultEnum.ERROR.exception("未找到课程编号为[" + courseCode + "]的基础课程");
         }
@@ -97,8 +98,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
     @Override
     public void createCourse(Long schoolId, String courseCode, String courseName) {
         // 向'basic_course'表新增数据 - 教研分析用
-        List<BasicCourse> basicCourseList = this.list(new QueryWrapper<BasicCourse>().lambda()
-                .eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode));
+        List<BasicCourse> basicCourseList = this.list(
+                new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode));
         if (basicCourseList.size() == 0) {
             BasicCourse basicCourse = new BasicCourse();
             basicCourse.setId(SystemConstant.getDbUuid());
@@ -114,18 +115,22 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
         Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
 
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
+        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(),
+                ServletUtil.getRequest().getServletPath());
 
         courseName = SystemConstant.translateSpecificSign(courseName);
-        IPage<BasicCourseResult> iPage = basicCourseMapper.findBasicCoursePage(new Page<>(pageNumber, pageSize), belongOrgId, courseName, startCreateTime, endCreateTime, schoolId, dpr);
+        IPage<BasicCourseResult> iPage = basicCourseMapper.findBasicCoursePage(new Page<>(pageNumber, pageSize),
+                belongOrgId, courseName, startCreateTime, endCreateTime, schoolId, dpr);
         List<BasicCourseResult> list = iPage.getRecords();
         for (BasicCourseResult basicCourseResult : list) {
             Long courseId = basicCourseResult.getId();
-            List<BasicUserCourse> basicUserCourseList = basicUserCourseService.list(new QueryWrapper<BasicUserCourse>().lambda().eq(BasicUserCourse::getCourseId, courseId));
+            List<BasicUserCourse> basicUserCourseList = basicUserCourseService.list(
+                    new QueryWrapper<BasicUserCourse>().lambda().eq(BasicUserCourse::getCourseId, courseId));
             Set<Long> clazzIdSet = basicUserCourseList.stream().map(BasicUserCourse::getClazzId).collect(Collectors.toSet());
             List<ClazzDatasourceResult> clazzDatasourceResultList = new ArrayList<>();
             if (clazzIdSet.size() > 0) {
-                List<BasicClazz> clazzList = basicClazzService.list(new QueryWrapper<BasicClazz>().lambda().in(BasicClazz::getId, clazzIdSet).orderByAsc(BasicClazz::getCreateTime));
+                List<BasicClazz> clazzList = basicClazzService.list(
+                        new QueryWrapper<BasicClazz>().lambda().in(BasicClazz::getId, clazzIdSet).orderByAsc(BasicClazz::getCreateTime));
                 for (BasicClazz clazz : clazzList) {
                     ClazzDatasourceResult clazzDatasourceResult = new ClazzDatasourceResult();
                     clazzDatasourceResult.setId(clazz.getId());
@@ -136,9 +141,10 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
                 basicCourseResult.setClazzList(clazzDatasourceResultList);
             }
 
-            List<BasicTeachCourse> basicTeachCourseList = basicTeachCourseService.list(new QueryWrapper<BasicTeachCourse>().lambda().eq(BasicTeachCourse::getCourseId, courseId));
+            List<BasicTeachCourse> basicTeachCourseList = basicTeachCourseService.list(
+                    new QueryWrapper<BasicTeachCourse>().lambda().eq(BasicTeachCourse::getCourseId, courseId));
             if (!CollectionUtils.isEmpty(basicTeachCourseList)) {
-                Set<Long> teachIdSet = basicTeachCourseList.stream().map(s -> s.getUserId()).collect(Collectors.toSet());
+                Set<Long> teachIdSet = basicTeachCourseList.stream().map(BasicTeachCourse::getUserId).collect(Collectors.toSet());
                 List<SysUserResult> sysUserResultList = sysUserService.findCourseSysUserResultByTeachIdSet(teachIdSet);
                 basicCourseResult.setTeachList(sysUserResultList);
             }
@@ -158,10 +164,11 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
             basicTeachCourseService.updateByCourseIdAndTeacherList(basicCourseParams.getId(), basicCourseParams.getTeachIdSet());
 
             // 同步更新命题任务中的课程名称
-            this.baseMapper.updateCourseNameFormExamTask(sysUser.getSchoolId(), editBasicCourse.getCode(), editBasicCourse.getName());
+            this.baseMapper.updateCourseNameFormExamTask(sysUser.getSchoolId(), editBasicCourse.getCode(),
+                    editBasicCourse.getName());
         } catch (Exception e) {
             if (e instanceof DataIntegrityViolationException || e instanceof BadSqlGrammarException) {
-                String content = JdbcErrorUtil.parseErrorMsg(e.getMessage().toString());
+                String content = JdbcErrorUtil.parseErrorMsg(e.getMessage());
                 throw ExceptionResultEnum.SQL_ERROR.exception(content);
             } else if (e instanceof ApiException) {
                 ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
@@ -189,6 +196,25 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
             }
             return basicCourse.getCode();
         }).collect(Collectors.toSet());
+
+        Map<String, String> courseMap = this.list(
+                        new QueryWrapper<BasicCourse>().lambda().in(BasicCourse::getId, idList)).stream()
+                .collect(Collectors.toMap(BasicCourse::getCode, BasicCourse::getName));
+        // 考生字典数据不包含该课程校验
+        List<String> basicExamStudentCourseNameList = basicCourseMapper.findBasicExamStudentCourseName(schoolId,
+                courseCodeSet).stream().map(courseMap::get).collect(Collectors.toList());
+        if (!CollectionUtils.isEmpty(basicExamStudentCourseNameList)) {
+            throw ExceptionResultEnum.ERROR.exception(
+                    String.format("考生字典中包含[%s]课程,不能删除", String.join(",", basicExamStudentCourseNameList)));
+        }
+        // 教学课程不包含该课程校验
+        List<String> teachCourseCourseNameList = basicCourseMapper.findTeachCourseCourseName(schoolId, courseCodeSet).stream().map(courseMap::get).collect(Collectors.toList());
+        if (!CollectionUtils.isEmpty(teachCourseCourseNameList)) {
+            throw ExceptionResultEnum.ERROR.exception(
+                    String.format("教学课程中包含[%s]课程,不能删除", String.join(",", teachCourseCourseNameList)));
+        }
+
+        // 命题任务不包含该课程校验
         Set<Map<String, Object>> mapList = basicCourseMapper.findExamTaskByCourseCode(schoolId, courseCodeSet);
         if (mapList.size() > 0) {
             StringBuilder courseNames = new StringBuilder();
@@ -198,14 +224,12 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
             throw ExceptionResultEnum.ERROR.exception("课程[" + courseNames.substring(0, courseNames.length() - 1) + "]已经生成了命题任务,不允许删除");
         }
         // 课程批量删除
-        basicUserCourseService.remove(new QueryWrapper<BasicUserCourse>().lambda()
-                .in(BasicUserCourse::getCourseId, idList)
-                .eq(BasicUserCourse::getSchoolId, sysUser.getSchoolId()));
+        basicUserCourseService.remove(
+                new QueryWrapper<BasicUserCourse>().lambda().in(BasicUserCourse::getCourseId, idList).eq(BasicUserCourse::getSchoolId, sysUser.getSchoolId()));
 
         // 老师批量删除
-        basicTeachCourseService.remove(new QueryWrapper<BasicTeachCourse>().lambda()
-                .in(BasicTeachCourse::getCourseId, idList)
-                .eq(BasicTeachCourse::getSchoolId, sysUser.getSchoolId()));
+        basicTeachCourseService.remove(
+                new QueryWrapper<BasicTeachCourse>().lambda().in(BasicTeachCourse::getCourseId, idList).eq(BasicTeachCourse::getSchoolId, sysUser.getSchoolId()));
         return this.removeByIds(idList);
     }
 
@@ -235,62 +259,65 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
     public List<BasicCourseParams> executeImportBasicCourseLogic(MultipartFile file) throws IOException, NoSuchFieldException {
         Map<Integer, List<String>> errorMap = new HashMap<>();
         InputStream inputStream = file.getInputStream();
-        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicCourseImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
-            Map<String, BasicCourseImportDto> courseDtoMap = new HashMap<>();
-            for (int i = 0; i < finalExcelList.size(); i++) {
-                LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
-                List<Object> basicCourseImportDtoList = excelMap.get(i);
-                List<BasicCourseImportDto> duplicateData = new ArrayList<>();
-                for (int y = 0; y < Objects.requireNonNull(basicCourseImportDtoList).size(); y++) {
-                    BasicCourseImportDto basicCourseImportDto = (BasicCourseImportDto) basicCourseImportDtoList.get(y);
-                    basicCourseImportDto.setRowIndex(y + 1);
-                    String courseName = basicCourseImportDto.getCourseName();
-                    String courseCode = basicCourseImportDto.getCourseCode();
-                    String teachingRoomName = basicCourseImportDto.getTeachingRoomName();
-                    String clazz = basicCourseImportDto.getClazz();
-                    String name = basicCourseImportDto.getName();
-                    String code = basicCourseImportDto.getCode();
-                    String emptyCheckError = ExcelUtil.checkExcelField(basicCourseImportDto);
-                    if (SystemConstant.strNotNull(emptyCheckError)) {
-                        if (errorMap.containsKey(y + 1)) {
-                            errorMap.get(y + 1).add(emptyCheckError);
-                        } else {
-                            List<String> errorInfo = new ArrayList<>();
-                            errorInfo.add(emptyCheckError);
-                            errorMap.put(y + 1, errorInfo);
-                        }
-                    } else {
-                        if (courseDtoMap.containsKey(courseCode)) {
-                            BasicCourseImportDto primaryCell = courseDtoMap.get(courseCode);
-                            String primaryName = primaryCell.getCourseName();
-                            String primaryTeachingRoomName = primaryCell.getTeachingRoomName();
-                            if (!Objects.equals(primaryName, courseName)) {
-                                String cellException = "课程编码[" + courseCode + "],存在不同的课程名称";
-                                this.updateErrorInfoMap(errorMap, y + 1, cellException);
+        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicCourseImportDto.class, DescribeImportDto.class),
+                (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+                    Map<String, BasicCourseImportDto> courseDtoMap = new HashMap<>();
+                    for (int i = 0; i < finalExcelList.size(); i++) {
+                        LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
+                        List<Object> basicCourseImportDtoList = excelMap.get(i);
+                        List<BasicCourseImportDto> duplicateData = new ArrayList<>();
+                        for (int y = 0; y < Objects.requireNonNull(basicCourseImportDtoList).size(); y++) {
+                            BasicCourseImportDto basicCourseImportDto = (BasicCourseImportDto) basicCourseImportDtoList.get(
+                                    y);
+                            basicCourseImportDto.setRowIndex(y + 1);
+                            String courseName = basicCourseImportDto.getCourseName();
+                            String courseCode = basicCourseImportDto.getCourseCode();
+                            String teachingRoomName = basicCourseImportDto.getTeachingRoomName();
+                            String clazz = basicCourseImportDto.getClazz();
+                            String name = basicCourseImportDto.getName();
+                            String code = basicCourseImportDto.getCode();
+                            String emptyCheckError = ExcelUtil.checkExcelField(basicCourseImportDto);
+                            if (SystemConstant.strNotNull(emptyCheckError)) {
+                                if (errorMap.containsKey(y + 1)) {
+                                    errorMap.get(y + 1).add(emptyCheckError);
+                                } else {
+                                    List<String> errorInfo = new ArrayList<>();
+                                    errorInfo.add(emptyCheckError);
+                                    errorMap.put(y + 1, errorInfo);
+                                }
+                            } else {
+                                if (courseDtoMap.containsKey(courseCode)) {
+                                    BasicCourseImportDto primaryCell = courseDtoMap.get(courseCode);
+                                    String primaryName = primaryCell.getCourseName();
+                                    String primaryTeachingRoomName = primaryCell.getTeachingRoomName();
+                                    if (!Objects.equals(primaryName, courseName)) {
+                                        String cellException = "课程编码[" + courseCode + "],存在不同的课程名称";
+                                        this.updateErrorInfoMap(errorMap, y + 1, cellException);
+                                    }
+                                    if (!Objects.equals(primaryTeachingRoomName, teachingRoomName)) {
+                                        String cellException = "课程编码[" + courseCode + "],存在不同的开课学院";
+                                        this.updateErrorInfoMap(errorMap, y + 1, cellException);
+                                    }
+                                    String primaryClazz = primaryCell.getClazz();
+                                    if (SystemConstant.strNotNull(clazz)) {
+                                        primaryClazz = primaryClazz + SystemConstant.COMMA + clazz;
+                                        primaryCell.setClazz(primaryClazz);
+                                    }
+                                    duplicateData.add(basicCourseImportDto);
+                                } else {
+                                    courseDtoMap.put(courseCode, basicCourseImportDto);
+                                }
                             }
-                            if (!Objects.equals(primaryTeachingRoomName, teachingRoomName)) {
-                                String cellException = "课程编码[" + courseCode + "],存在不同的开课学院";
-                                this.updateErrorInfoMap(errorMap, y + 1, cellException);
+                            if (Objects.nonNull(courseCode) && (!courseCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)
+                                    || courseCode.length() < 3 || courseCode.length() > 30)) {
+                                this.updateErrorInfoMap(errorMap, y + 1, "课程编码[" + courseCode + "]不符合输入规范");
                             }
-                            String primaryClazz = primaryCell.getClazz();
-                            if (SystemConstant.strNotNull(clazz)) {
-                                primaryClazz = primaryClazz + SystemConstant.COMMA + clazz;
-                                primaryCell.setClazz(primaryClazz);
-                            }
-                            duplicateData.add(basicCourseImportDto);
-                        } else {
-                            courseDtoMap.put(courseCode, basicCourseImportDto);
                         }
+                        // 删除重复的(需要累加的)excel数据
+                        basicCourseImportDtoList.removeAll(duplicateData);
                     }
-                    if (Objects.nonNull(courseCode) && (!courseCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE) || courseCode.length() < 3 || courseCode.length() > 30)) {
-                        this.updateErrorInfoMap(errorMap, y + 1, "课程编码[" + courseCode + "]不符合输入规范");
-                    }
-                }
-                // 删除重复的(需要累加的)excel数据
-                basicCourseImportDtoList.removeAll(duplicateData);
-            }
-            return finalExcelList;
-        }, 2);
+                    return finalExcelList;
+                }, 2);
         return this.executeBasicCourseImportLogic(finalList, errorMap);
     }
 
@@ -335,7 +362,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public List<BasicCourseParams> executeBasicCourseImportLogic(List<LinkedMultiValueMap<Integer, Object>> finalList, Map<Integer, List<String>> errorMap) {
+    public List<BasicCourseParams> executeBasicCourseImportLogic(List<LinkedMultiValueMap<Integer, Object>> finalList,
+            Map<Integer, List<String>> errorMap) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Long schoolId = sysUser.getSchoolId();
         List<BasicCourseParams> addBasicCourseParamsList = new ArrayList<>();
@@ -351,10 +379,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
                 // 原始excel中的行索引
                 Integer rowIndex = basicCourseImportDto.getRowIndex();
 
-                SysOrg sysOrg = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
-                        .eq(SysOrg::getSchoolId, schoolId)
-                        .eq(SysOrg::getEnable, true)
-                        .eq(SysOrg::getName, teachingRoomName));
+                SysOrg sysOrg = sysOrgService.getOne(
+                        new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId).eq(SysOrg::getEnable, true).eq(SysOrg::getName, teachingRoomName));
                 if (Objects.isNull(sysOrg)) {
                     this.updateErrorInfoMap(errorMap, rowIndex, "输入的开课学院[" + teachingRoomName + "]不存在");
                     continue;
@@ -364,10 +390,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
                 if (SystemConstant.strNotNull(clazz)) {
                     String[] clazzList = clazz.split(SystemConstant.COMMA);
                     for (String clzName : clazzList) {
-                        BasicClazz basicClazz = basicClazzService.getOne(new QueryWrapper<BasicClazz>().lambda()
-                                .eq(BasicClazz::getEnable, true)
-                                .eq(BasicClazz::getSchoolId, schoolId)
-                                .eq(BasicClazz::getClazzName, clzName));
+                        BasicClazz basicClazz = basicClazzService.getOne(
+                                new QueryWrapper<BasicClazz>().lambda().eq(BasicClazz::getEnable, true).eq(BasicClazz::getSchoolId, schoolId).eq(BasicClazz::getClazzName, clzName));
                         if (Objects.isNull(basicClazz)) {
                             this.updateErrorInfoMap(errorMap, rowIndex, "所选择班级[" + clzName + "]不存在");
                             continue;
@@ -388,11 +412,9 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
                     for (int k = 0; k < nameList.length; k++) {
                         String name = nameList[k].trim();
                         String code = codeList[k].trim();
-                        SysUser sysUserDb = sysUserService.getOne(new QueryWrapper<SysUser>().lambda()
-                                .eq(SysUser::getEnable, true)
-                                .eq(SysUser::getSchoolId, schoolId)
-                                .eq(SysUser::getRealName, name)
-                                .eq(SysUser::getCode, code));
+                        SysUser sysUserDb = sysUserService.getOne(
+                                new QueryWrapper<SysUser>().lambda().eq(SysUser::getEnable, true).eq(SysUser::getSchoolId, schoolId).eq(SysUser::getRealName, name)
+                                        .eq(SysUser::getCode, code));
                         if (Objects.isNull(sysUserDb)) {
                             this.updateErrorInfoMap(errorMap, rowIndex, "姓名[" + name + "],工号[" + code + "]不存在");
                             continue;
@@ -414,10 +436,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
                 basicCourseParams.setTeachingRoomId(teachingRoomId);
                 basicCourseParams.setClazzIdSet(clazzIdSet);
                 basicCourseParams.setTeachIdSet(teachIdSet);
-                BasicCourse old = this.getOne(new QueryWrapper<BasicCourse>().lambda()
-                        .eq(BasicCourse::getSchoolId, schoolId)
-                        .eq(BasicCourse::getEnable, true)
-                        .eq(BasicCourse::getCode, courseCode));
+                BasicCourse old = this.getOne(
+                        new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getEnable, true).eq(BasicCourse::getCode, courseCode));
                 if (Objects.nonNull(old)) {
                     basicCourseParams.setId(old.getId());
                 }
@@ -432,11 +452,12 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
 
                 // 同步更新命题任务中的课程名称
                 for (BasicCourse basicCourse : editBasicCourse) {
-                    this.baseMapper.updateCourseNameFormExamTask(sysUser.getSchoolId(), basicCourse.getCode(), basicCourse.getName());
+                    this.baseMapper.updateCourseNameFormExamTask(sysUser.getSchoolId(), basicCourse.getCode(),
+                            basicCourse.getName());
                 }
             } catch (Exception e) {
                 if (e instanceof DataIntegrityViolationException || e instanceof BadSqlGrammarException) {
-                    String content = JdbcErrorUtil.parseErrorMsg(e.getMessage().toString());
+                    String content = JdbcErrorUtil.parseErrorMsg(e.getMessage());
                     throw ExceptionResultEnum.SQL_ERROR.exception(content);
                 } else if (e instanceof ApiException) {
                     ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
@@ -468,26 +489,31 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
         Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
 
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
+        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(),
+                ServletUtil.getRequest().getServletPath());
 
         courseName = SystemConstant.translateSpecificSign(courseName);
-        List<BasicCourseExportDto> courseExportDtos = basicCourseMapper.listExportData(belongOrgId, courseName, startCreateTime, endCreateTime, schoolId, dpr);
+        List<BasicCourseExportDto> courseExportDtos = basicCourseMapper.listExportData(belongOrgId, courseName,
+                startCreateTime, endCreateTime, schoolId, dpr);
         if (courseExportDtos.isEmpty()) {
             throw ExceptionResultEnum.ERROR.exception("没有可导出数据");
         }
         for (BasicCourseExportDto basicCourseExportDto : courseExportDtos) {
             Long courseId = basicCourseExportDto.getId();
-            List<BasicUserCourse> basicUserCourseList = basicUserCourseService.list(new QueryWrapper<BasicUserCourse>().lambda().eq(BasicUserCourse::getCourseId, courseId));
+            List<BasicUserCourse> basicUserCourseList = basicUserCourseService.list(
+                    new QueryWrapper<BasicUserCourse>().lambda().eq(BasicUserCourse::getCourseId, courseId));
             Set<Long> clazzIdSet = basicUserCourseList.stream().map(BasicUserCourse::getClazzId).collect(Collectors.toSet());
             if (clazzIdSet.size() > 0) {
-                List<BasicClazz> clazzList = basicClazzService.list(new QueryWrapper<BasicClazz>().lambda().in(BasicClazz::getId, clazzIdSet).orderByAsc(BasicClazz::getCreateTime));
+                List<BasicClazz> clazzList = basicClazzService.list(
+                        new QueryWrapper<BasicClazz>().lambda().in(BasicClazz::getId, clazzIdSet).orderByAsc(BasicClazz::getCreateTime));
                 if (!clazzList.isEmpty()) {
                     List<String> clazzNameList = clazzList.stream().map(BasicClazz::getClazzName).collect(Collectors.toList());
                     basicCourseExportDto.setClazzName(String.join(",", clazzNameList));
                 }
             }
 
-            List<BasicTeachCourse> basicTeachCourseList = basicTeachCourseService.list(new QueryWrapper<BasicTeachCourse>().lambda().eq(BasicTeachCourse::getCourseId, courseId));
+            List<BasicTeachCourse> basicTeachCourseList = basicTeachCourseService.list(
+                    new QueryWrapper<BasicTeachCourse>().lambda().eq(BasicTeachCourse::getCourseId, courseId));
             Set<Long> teachIdSet = basicTeachCourseList.stream().map(BasicTeachCourse::getUserId).collect(Collectors.toSet());
             if (!CollectionUtils.isEmpty(teachIdSet)) {
                 List<SysUserResult> sysUserResultList = sysUserService.findCourseSysUserResultByTeachIdSet(teachIdSet);
@@ -496,7 +522,6 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
                     basicCourseExportDto.setTeachName(String.join(",", teachNameList));
                 }
             }
-            basicCourseExportDto.setEnableName(basicCourseExportDto.getEnable() ? "启用" : "禁用");
         }
         ExcelUtil.excelExport("课程数据", BasicCourseExportDto.class, courseExportDtos, response);
     }
@@ -543,10 +568,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
             String courseName = basicCourseParams.getCourseName();
             // 校验课程编号
             String courseCode = basicCourseParams.getCourseCode();
-            BasicCourse checkCode = this.getOne(new QueryWrapper<BasicCourse>().lambda()
-                    .eq(BasicCourse::getCode, courseCode)
-                    .eq(BasicCourse::getSchoolId, schoolId)
-                    .eq(BasicCourse::getEnable, true));
+            BasicCourse checkCode = this.getOne(
+                    new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getCode, courseCode).eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getEnable, true));
             if (Objects.nonNull(checkCode)) {
                 if (!checkCode.getId().equals(id)) {
                     throw ExceptionResultEnum.ERROR.exception("课程编码[" + courseCode + "]重复");
@@ -554,12 +577,12 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
             }
             // 校验教研室id
             Long teachingRoomId = basicCourseParams.getTeachingRoomId();
-//            if (Objects.isNull(sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
-//                    .eq(SysOrg::getId, teachingRoomId)
-//                    .eq(SysOrg::getEnable, true)
-//                    .eq(SysOrg::getType, OrgTypeEnum.TEACHING_ROOM)))) {
-//                throw ExceptionResultEnum.ERROR.exception("所选教研室不存在");
-//            }
+            //            if (Objects.isNull(sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
+            //                    .eq(SysOrg::getId, teachingRoomId)
+            //                    .eq(SysOrg::getEnable, true)
+            //                    .eq(SysOrg::getType, OrgTypeEnum.TEACHING_ROOM)))) {
+            //                throw ExceptionResultEnum.ERROR.exception("所选教研室不存在");
+            //            }
             // 校验班级
             Set<Long> clazzIdSet = basicCourseParams.getClazzIdSet();
 

+ 30 - 0
teachcloud-common/src/main/resources/mapper/BasicCourseMapper.xml

@@ -190,4 +190,34 @@
             </if>
         </where>
     </select>
+    <select id="findBasicExamStudentCourseName" resultType="java.lang.String">
+        SELECT DISTINCT
+            (course_code)
+        FROM
+            basic_exam_student
+        <where>
+            AND school_id = #{schoolId}
+            <if test="courseCodeSet != null and courseCodeSet != '' and courseCodeSet.size > 0">
+                AND course_code IN
+                <foreach collection="courseCodeSet" item="item" index="index" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
+    <select id="findTeachCourseCourseName" resultType="java.lang.String">
+        SELECT DISTINCT
+            (course_code)
+        FROM
+            teach_course
+        <where>
+            AND school_id = #{schoolId}
+            <if test="courseCodeSet != null and courseCodeSet != '' and courseCodeSet.size > 0">
+                AND course_code IN
+                <foreach collection="courseCodeSet" item="item" index="index" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
 </mapper>