|
@@ -204,6 +204,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
SysUser sysUser = (SysUser) map.get(SystemConstant.SYS_USER);
|
|
|
Long schoolId = sysUser.getSchoolId();
|
|
|
List<BasicCourseParams> addBasicCourseParamsList = new ArrayList<>();
|
|
|
+ Map<String,BasicCourseParams> courseMap = new HashMap<>();
|
|
|
+
|
|
|
|
|
|
for (int i = 0; i < finalList.size(); i++) {
|
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);
|
|
@@ -220,13 +222,17 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
String teachingRoomName = basicCourseImportDto.getTeachingRoomName();
|
|
|
String clazz = basicCourseImportDto.getClazz();
|
|
|
|
|
|
- SysOrg sysOrg = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId).eq(SysOrg::getEnable, true).eq(SysOrg::getType, OrgTypeEnum.TEACHING_ROOM).eq(SysOrg::getName, teachingRoomName));
|
|
|
+ SysOrg sysOrg = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
|
|
|
+ .eq(SysOrg::getSchoolId, schoolId)
|
|
|
+ .eq(SysOrg::getEnable, true)
|
|
|
+ .eq(SysOrg::getType, OrgTypeEnum.TEACHING_ROOM)
|
|
|
+ .eq(SysOrg::getName, teachingRoomName));
|
|
|
if (Objects.isNull(sysOrg)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("输入的教研室【" + teachingRoomName + "】不存在");
|
|
|
}
|
|
|
Long teachingRoomId = sysOrg.getId();
|
|
|
String[] clazzList = clazz.split(clazzSplit);
|
|
|
- List<Long> clazzIdList = new ArrayList<>();
|
|
|
+ Set<Long> clazzIdSet = new TreeSet<>();
|
|
|
for (String clzName : clazzList) {
|
|
|
BasicClazz basicClazz = basicClazzService.getOne(new QueryWrapper<BasicClazz>().lambda()
|
|
|
.eq(BasicClazz::getEnable, true)
|
|
@@ -235,19 +241,35 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
if (Objects.isNull(basicClazz)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("所选择【班级】" + clzName + "不存在");
|
|
|
}
|
|
|
- clazzIdList.add(basicClazz.getId());
|
|
|
+ clazzIdSet.add(basicClazz.getId());
|
|
|
}
|
|
|
|
|
|
BasicCourseParams basicCourseParams = new BasicCourseParams();
|
|
|
- basicCourseParams.setCourseCode(courseCode);
|
|
|
- basicCourseParams.setCourseName(courseName);
|
|
|
- basicCourseParams.setTeachingRoomId(teachingRoomId);
|
|
|
- basicCourseParams.setClazzIdList(clazzIdList);
|
|
|
- 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());
|
|
|
+ if (courseMap.containsKey(courseCode)){
|
|
|
+ basicCourseParams = courseMap.get(courseCode);
|
|
|
+ if (!courseName.equals(basicCourseParams.getCourseName())){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("excel中相同【课程编号】:" + courseCode + ",存在不同的【课程名称】异常");
|
|
|
+ }
|
|
|
+ if (!teachingRoomId.equals(basicCourseParams.getTeachingRoomId())){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("excel中相同【课程编号】:" + courseCode + ",存在不同的【所属教研室】异常");
|
|
|
+ }
|
|
|
+ Set<Long> oldClazzIdSet = basicCourseParams.getClazzIdSet();
|
|
|
+ oldClazzIdSet.addAll(clazzIdSet);
|
|
|
+ } else {
|
|
|
+ basicCourseParams.setCourseCode(courseCode);
|
|
|
+ basicCourseParams.setCourseName(courseName);
|
|
|
+ basicCourseParams.setTeachingRoomId(teachingRoomId);
|
|
|
+ basicCourseParams.setClazzIdSet(clazzIdSet);
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ courseMap.put(courseCode,basicCourseParams);
|
|
|
+ addBasicCourseParamsList.add(basicCourseParams);
|
|
|
}
|
|
|
- addBasicCourseParamsList.add(basicCourseParams);
|
|
|
}
|
|
|
List<BasicCourse> editBasicCourse = this.editEntityHelp(addBasicCourseParamsList, sysUser);
|
|
|
this.saveOrUpdateBatch(editBasicCourse);
|
|
@@ -303,10 +325,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
throw ExceptionResultEnum.ERROR.exception("所选教研室不存在");
|
|
|
}
|
|
|
// 校验班级
|
|
|
- List<Long> clazzIdList = basicCourseParams.getClazzIdList();
|
|
|
- if (clazzIdList.size() != clazzIdList.stream().distinct().count()) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("输入的班级重复");
|
|
|
- }
|
|
|
+ Set<Long> clazzIdSet = basicCourseParams.getClazzIdSet();
|
|
|
|
|
|
//基础数据组装
|
|
|
Long orgId;
|
|
@@ -336,7 +355,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
basicCourse.setOrgId(orgId);
|
|
|
|
|
|
// 根据课程id和授课班级集合更新'basic_user_course'表
|
|
|
- basicUserCourseService.updateByCourseIdAndClazzList(id, clazzIdList, sysUser, orgId);
|
|
|
+ basicUserCourseService.updateByCourseIdAndClazzList(id, clazzIdSet, sysUser, orgId);
|
|
|
|
|
|
basicCourseList.add(basicCourse);
|
|
|
}
|