|
@@ -86,7 +86,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public BasicCourse findByCourseCode(String courseCode, Long schoolId) {
|
|
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)) {
|
|
if (Objects.isNull(basicCourse)) {
|
|
throw ExceptionResultEnum.ERROR.exception("未找到课程编号为[" + courseCode + "]的基础课程");
|
|
throw ExceptionResultEnum.ERROR.exception("未找到课程编号为[" + courseCode + "]的基础课程");
|
|
}
|
|
}
|
|
@@ -97,8 +98,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
@Override
|
|
@Override
|
|
public void createCourse(Long schoolId, String courseCode, String courseName) {
|
|
public void createCourse(Long schoolId, String courseCode, String courseName) {
|
|
// 向'basic_course'表新增数据 - 教研分析用
|
|
// 向'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) {
|
|
if (basicCourseList.size() == 0) {
|
|
BasicCourse basicCourse = new BasicCourse();
|
|
BasicCourse basicCourse = new BasicCourse();
|
|
basicCourse.setId(SystemConstant.getDbUuid());
|
|
basicCourse.setId(SystemConstant.getDbUuid());
|
|
@@ -114,18 +115,22 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
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);
|
|
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();
|
|
List<BasicCourseResult> list = iPage.getRecords();
|
|
for (BasicCourseResult basicCourseResult : list) {
|
|
for (BasicCourseResult basicCourseResult : list) {
|
|
Long courseId = basicCourseResult.getId();
|
|
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());
|
|
Set<Long> clazzIdSet = basicUserCourseList.stream().map(BasicUserCourse::getClazzId).collect(Collectors.toSet());
|
|
List<ClazzDatasourceResult> clazzDatasourceResultList = new ArrayList<>();
|
|
List<ClazzDatasourceResult> clazzDatasourceResultList = new ArrayList<>();
|
|
if (clazzIdSet.size() > 0) {
|
|
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) {
|
|
for (BasicClazz clazz : clazzList) {
|
|
ClazzDatasourceResult clazzDatasourceResult = new ClazzDatasourceResult();
|
|
ClazzDatasourceResult clazzDatasourceResult = new ClazzDatasourceResult();
|
|
clazzDatasourceResult.setId(clazz.getId());
|
|
clazzDatasourceResult.setId(clazz.getId());
|
|
@@ -136,9 +141,10 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
basicCourseResult.setClazzList(clazzDatasourceResultList);
|
|
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)) {
|
|
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);
|
|
List<SysUserResult> sysUserResultList = sysUserService.findCourseSysUserResultByTeachIdSet(teachIdSet);
|
|
basicCourseResult.setTeachList(sysUserResultList);
|
|
basicCourseResult.setTeachList(sysUserResultList);
|
|
}
|
|
}
|
|
@@ -158,10 +164,11 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
basicTeachCourseService.updateByCourseIdAndTeacherList(basicCourseParams.getId(), basicCourseParams.getTeachIdSet());
|
|
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) {
|
|
} catch (Exception e) {
|
|
if (e instanceof DataIntegrityViolationException || e instanceof BadSqlGrammarException) {
|
|
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);
|
|
throw ExceptionResultEnum.SQL_ERROR.exception(content);
|
|
} else if (e instanceof ApiException) {
|
|
} else if (e instanceof ApiException) {
|
|
ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
|
|
ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
|
|
@@ -189,6 +196,25 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
}
|
|
}
|
|
return basicCourse.getCode();
|
|
return basicCourse.getCode();
|
|
}).collect(Collectors.toSet());
|
|
}).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);
|
|
Set<Map<String, Object>> mapList = basicCourseMapper.findExamTaskByCourseCode(schoolId, courseCodeSet);
|
|
if (mapList.size() > 0) {
|
|
if (mapList.size() > 0) {
|
|
StringBuilder courseNames = new StringBuilder();
|
|
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) + "]已经生成了命题任务,不允许删除");
|
|
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);
|
|
return this.removeByIds(idList);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -235,62 +259,65 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
public List<BasicCourseParams> executeImportBasicCourseLogic(MultipartFile file) throws IOException, NoSuchFieldException {
|
|
public List<BasicCourseParams> executeImportBasicCourseLogic(MultipartFile file) throws IOException, NoSuchFieldException {
|
|
Map<Integer, List<String>> errorMap = new HashMap<>();
|
|
Map<Integer, List<String>> errorMap = new HashMap<>();
|
|
InputStream inputStream = file.getInputStream();
|
|
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);
|
|
return this.executeBasicCourseImportLogic(finalList, errorMap);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -335,7 +362,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@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();
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
Long schoolId = sysUser.getSchoolId();
|
|
Long schoolId = sysUser.getSchoolId();
|
|
List<BasicCourseParams> addBasicCourseParamsList = new ArrayList<>();
|
|
List<BasicCourseParams> addBasicCourseParamsList = new ArrayList<>();
|
|
@@ -351,10 +379,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
// 原始excel中的行索引
|
|
// 原始excel中的行索引
|
|
Integer rowIndex = basicCourseImportDto.getRowIndex();
|
|
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)) {
|
|
if (Objects.isNull(sysOrg)) {
|
|
this.updateErrorInfoMap(errorMap, rowIndex, "输入的开课学院[" + teachingRoomName + "]不存在");
|
|
this.updateErrorInfoMap(errorMap, rowIndex, "输入的开课学院[" + teachingRoomName + "]不存在");
|
|
continue;
|
|
continue;
|
|
@@ -364,10 +390,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
if (SystemConstant.strNotNull(clazz)) {
|
|
if (SystemConstant.strNotNull(clazz)) {
|
|
String[] clazzList = clazz.split(SystemConstant.COMMA);
|
|
String[] clazzList = clazz.split(SystemConstant.COMMA);
|
|
for (String clzName : clazzList) {
|
|
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)) {
|
|
if (Objects.isNull(basicClazz)) {
|
|
this.updateErrorInfoMap(errorMap, rowIndex, "所选择班级[" + clzName + "]不存在");
|
|
this.updateErrorInfoMap(errorMap, rowIndex, "所选择班级[" + clzName + "]不存在");
|
|
continue;
|
|
continue;
|
|
@@ -388,11 +412,9 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
for (int k = 0; k < nameList.length; k++) {
|
|
for (int k = 0; k < nameList.length; k++) {
|
|
String name = nameList[k].trim();
|
|
String name = nameList[k].trim();
|
|
String code = codeList[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)) {
|
|
if (Objects.isNull(sysUserDb)) {
|
|
this.updateErrorInfoMap(errorMap, rowIndex, "姓名[" + name + "],工号[" + code + "]不存在");
|
|
this.updateErrorInfoMap(errorMap, rowIndex, "姓名[" + name + "],工号[" + code + "]不存在");
|
|
continue;
|
|
continue;
|
|
@@ -414,10 +436,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
basicCourseParams.setTeachingRoomId(teachingRoomId);
|
|
basicCourseParams.setTeachingRoomId(teachingRoomId);
|
|
basicCourseParams.setClazzIdSet(clazzIdSet);
|
|
basicCourseParams.setClazzIdSet(clazzIdSet);
|
|
basicCourseParams.setTeachIdSet(teachIdSet);
|
|
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)) {
|
|
if (Objects.nonNull(old)) {
|
|
basicCourseParams.setId(old.getId());
|
|
basicCourseParams.setId(old.getId());
|
|
}
|
|
}
|
|
@@ -432,11 +452,12 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
|
|
|
// 同步更新命题任务中的课程名称
|
|
// 同步更新命题任务中的课程名称
|
|
for (BasicCourse basicCourse : editBasicCourse) {
|
|
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) {
|
|
} catch (Exception e) {
|
|
if (e instanceof DataIntegrityViolationException || e instanceof BadSqlGrammarException) {
|
|
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);
|
|
throw ExceptionResultEnum.SQL_ERROR.exception(content);
|
|
} else if (e instanceof ApiException) {
|
|
} else if (e instanceof ApiException) {
|
|
ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
|
|
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());
|
|
Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
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);
|
|
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()) {
|
|
if (courseExportDtos.isEmpty()) {
|
|
throw ExceptionResultEnum.ERROR.exception("没有可导出数据");
|
|
throw ExceptionResultEnum.ERROR.exception("没有可导出数据");
|
|
}
|
|
}
|
|
for (BasicCourseExportDto basicCourseExportDto : courseExportDtos) {
|
|
for (BasicCourseExportDto basicCourseExportDto : courseExportDtos) {
|
|
Long courseId = basicCourseExportDto.getId();
|
|
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());
|
|
Set<Long> clazzIdSet = basicUserCourseList.stream().map(BasicUserCourse::getClazzId).collect(Collectors.toSet());
|
|
if (clazzIdSet.size() > 0) {
|
|
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()) {
|
|
if (!clazzList.isEmpty()) {
|
|
List<String> clazzNameList = clazzList.stream().map(BasicClazz::getClazzName).collect(Collectors.toList());
|
|
List<String> clazzNameList = clazzList.stream().map(BasicClazz::getClazzName).collect(Collectors.toList());
|
|
basicCourseExportDto.setClazzName(String.join(",", clazzNameList));
|
|
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());
|
|
Set<Long> teachIdSet = basicTeachCourseList.stream().map(BasicTeachCourse::getUserId).collect(Collectors.toSet());
|
|
if (!CollectionUtils.isEmpty(teachIdSet)) {
|
|
if (!CollectionUtils.isEmpty(teachIdSet)) {
|
|
List<SysUserResult> sysUserResultList = sysUserService.findCourseSysUserResultByTeachIdSet(teachIdSet);
|
|
List<SysUserResult> sysUserResultList = sysUserService.findCourseSysUserResultByTeachIdSet(teachIdSet);
|
|
@@ -496,7 +522,6 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
basicCourseExportDto.setTeachName(String.join(",", teachNameList));
|
|
basicCourseExportDto.setTeachName(String.join(",", teachNameList));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- basicCourseExportDto.setEnableName(basicCourseExportDto.getEnable() ? "启用" : "禁用");
|
|
|
|
}
|
|
}
|
|
ExcelUtil.excelExport("课程数据", BasicCourseExportDto.class, courseExportDtos, response);
|
|
ExcelUtil.excelExport("课程数据", BasicCourseExportDto.class, courseExportDtos, response);
|
|
}
|
|
}
|
|
@@ -543,10 +568,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
String courseName = basicCourseParams.getCourseName();
|
|
String courseName = basicCourseParams.getCourseName();
|
|
// 校验课程编号
|
|
// 校验课程编号
|
|
String courseCode = basicCourseParams.getCourseCode();
|
|
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 (Objects.nonNull(checkCode)) {
|
|
if (!checkCode.getId().equals(id)) {
|
|
if (!checkCode.getId().equals(id)) {
|
|
throw ExceptionResultEnum.ERROR.exception("课程编码[" + courseCode + "]重复");
|
|
throw ExceptionResultEnum.ERROR.exception("课程编码[" + courseCode + "]重复");
|
|
@@ -554,12 +577,12 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
}
|
|
}
|
|
// 校验教研室id
|
|
// 校验教研室id
|
|
Long teachingRoomId = basicCourseParams.getTeachingRoomId();
|
|
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();
|
|
Set<Long> clazzIdSet = basicCourseParams.getClazzIdSet();
|
|
|
|
|