|
@@ -156,7 +156,6 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public Boolean removeBasicCourseBatch(List<Long> idList) {
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
if (CollectionUtils.isEmpty(idList)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("请选择删除的课程");
|
|
|
}
|
|
@@ -166,11 +165,6 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
if (basicCourse == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- // 教师课程数据
|
|
|
- int countTeachCourseByCourseId = this.baseMapper.countTeachCourseByCourseId(courseId);
|
|
|
- if (countTeachCourseByCourseId > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程代码[" + basicCourse.getCode() + "],课程名称[" + basicCourse.getName() + "]已有老师绑定,不能删除");
|
|
|
- }
|
|
|
// 考生管理
|
|
|
int countBasicExamStudentByCourseId = this.baseMapper.countBasicExamStudentByCourseId(courseId);
|
|
|
if (countBasicExamStudentByCourseId > 0) {
|
|
@@ -181,18 +175,9 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
if (countExamTaskByCourseId > 0) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("课程代码[" + basicCourse.getCode() + "],课程名称[" + basicCourse.getName() + "]下已有命题数据,不能删除");
|
|
|
}
|
|
|
- // 题卡管理
|
|
|
- int countExamCardByCourseId = this.baseMapper.countExamCardByCourseId(courseId);
|
|
|
- if (countExamCardByCourseId > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程代码[" + basicCourse.getCode() + "],课程名称[" + basicCourse.getName() + "]下已有题卡数据,不能删除");
|
|
|
- }
|
|
|
- // 扫描阅卷课程
|
|
|
- int countMarkPaperByCourseId = this.baseMapper.countMarkPaperByCourseId(courseId);
|
|
|
- if (countMarkPaperByCourseId > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程代码[" + basicCourse.getCode() + "],课程名称[" + basicCourse.getName() + "]下已有扫描课程数据,不能删除");
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
+ // 删除课程管理中老师课程
|
|
|
+ this.baseMapper.deleteTeachCourseByCourseIds(idList);
|
|
|
return this.removeByIds(idList);
|
|
|
}
|
|
|
|
|
@@ -297,46 +282,52 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
} else {
|
|
|
throw ExceptionResultEnum.ERROR.exception("只能导入后缀为.xls或.xlsx文件");
|
|
|
}
|
|
|
-
|
|
|
List<BasicCourseImportDto> courseImportDtoList = excelReader.getObjectList(BasicCourseImportDto.class);
|
|
|
if (CollectionUtils.isEmpty(courseImportDtoList)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("未读取到有效数据");
|
|
|
}
|
|
|
-
|
|
|
+ List<BasicCourse> basicCourseList = new ArrayList<>();
|
|
|
+ List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(sysUser.getSchoolId(), null);
|
|
|
+ if (CollectionUtils.isEmpty(sysOrgList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学校没有学院机构");
|
|
|
+ }
|
|
|
+ Map<String, Long> teachingRoomNameIdMap = sysOrgList.stream().collect(Collectors.toMap(SysOrg::getName, SysOrg::getId));
|
|
|
for (BasicCourseImportDto basicCourseImportDto : courseImportDtoList) {
|
|
|
String courseName = basicCourseImportDto.getCourseName();
|
|
|
String courseCode = basicCourseImportDto.getCourseCode();
|
|
|
String teachingRoomName = basicCourseImportDto.getTeachingRoomName();
|
|
|
// 所有字段为空,跳过
|
|
|
- if(StringUtils.isAllBlank(courseCode, courseName, teachingRoomName)){
|
|
|
+ if (StringUtils.isAllBlank(courseCode, courseName, teachingRoomName)) {
|
|
|
continue;
|
|
|
}
|
|
|
- if (StringUtils.isBlank(courseName) || StringUtils.isBlank(courseCode) || StringUtils.isBlank(teachingRoomName)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程名称、课程代码、开课学院不能为空");
|
|
|
+ if (StringUtils.isAnyBlank(courseCode, courseName, teachingRoomName)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程代码、课程名称、开课学院不能为空");
|
|
|
}
|
|
|
// 去空格
|
|
|
courseName = StringUtils.deleteWhitespace(courseName);
|
|
|
courseCode = StringUtils.deleteWhitespace(courseCode);
|
|
|
teachingRoomName = StringUtils.deleteWhitespace(teachingRoomName);
|
|
|
// 校验开课学院
|
|
|
- List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(sysUser.getSchoolId(), teachingRoomName);
|
|
|
- if (CollectionUtils.isEmpty(sysOrgList)) {
|
|
|
+ if (!teachingRoomNameIdMap.containsKey(teachingRoomName)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("开课学院[" + teachingRoomName + "]在学院层级不存在");
|
|
|
}
|
|
|
- SysOrg sysOrg = sysOrgList.get(0);
|
|
|
+
|
|
|
+ Long teachingRoomId = teachingRoomNameIdMap.get(teachingRoomName);
|
|
|
+
|
|
|
// 校验课程代码和开课学院
|
|
|
- BasicCourse basicCourse = this.getByTeachRoomIdAndCode(sysOrg.getId(), courseCode);
|
|
|
+ BasicCourse basicCourse = this.getByTeachRoomIdAndCode(teachingRoomId, courseCode);
|
|
|
if (basicCourse != null) {
|
|
|
basicCourse.setName(courseName);
|
|
|
basicCourse.setUpdateId(sysUser.getId());
|
|
|
basicCourse.setUpdateTime(System.currentTimeMillis());
|
|
|
basicCourse.setEnable(true);
|
|
|
} else {
|
|
|
- basicCourse = new BasicCourse(sysUser.getSchoolId(), sysOrg.getId(), courseCode, courseName);
|
|
|
+ basicCourse = new BasicCourse(sysUser.getSchoolId(), teachingRoomId, courseCode, courseName);
|
|
|
basicCourse.insertInfo(sysUser.getId());
|
|
|
}
|
|
|
- this.saveOrUpdate(basicCourse);
|
|
|
+ basicCourseList.add(basicCourse);
|
|
|
}
|
|
|
+ this.saveOrUpdateBatch(basicCourseList);
|
|
|
} catch (Exception e) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("导入失败:" + e.getMessage());
|
|
|
}
|