|
@@ -26,6 +26,7 @@ import com.xjrsoft.module.base.service.IBaseClassCourseService;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.base.service.IBaseCourseSubjectService;
|
|
|
import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
+import com.xjrsoft.module.base.vo.BaseClassCourseExcelVo;
|
|
|
import com.xjrsoft.module.base.vo.BaseClassCourseExportListVo;
|
|
|
import com.xjrsoft.module.base.vo.BaseClassCourseListVo;
|
|
|
import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
|
|
@@ -56,7 +57,6 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @title: 班级课程
|
|
@@ -207,7 +207,7 @@ public class BaseClassCourseController {
|
|
|
@PostMapping("/import")
|
|
|
@ApiOperation(value = "导入")
|
|
|
public RT<Boolean> importData(@RequestParam MultipartFile file) throws IOException {
|
|
|
- List<BaseClassCoursePageVo> savedDataList = EasyExcel.read(file.getInputStream()).headRowNumber(3).head(BaseClassCoursePageVo.class).sheet().doReadSync();
|
|
|
+ List<BaseClassCourseExcelVo> savedDataList = EasyExcel.read(file.getInputStream()).headRowNumber(3).head(BaseClassCourseExcelVo.class).sheet().doReadSync();
|
|
|
|
|
|
List<BaseClassCourse> baseClassCourses = new ArrayList<>();
|
|
|
List<String> duplicateLogs = new ArrayList<>();
|
|
@@ -234,36 +234,54 @@ public class BaseClassCourseController {
|
|
|
semesterMap.put(baseSemester.getName(), baseSemester.getId());
|
|
|
}
|
|
|
|
|
|
- for (BaseClassCoursePageVo vo : savedDataList) {
|
|
|
- String[] textbookNames = vo.getTextbookName().split(" ");
|
|
|
- for (String textbookName : textbookNames) {
|
|
|
- try {
|
|
|
- Long classId = classMap.get(vo.getClassName());
|
|
|
- Long courseId = courseSubjectMap.get(vo.getCourseName());
|
|
|
- Long textbookId = textbookMap.get(textbookName);
|
|
|
- Long baseSemesterId = semesterMap.get(vo.getSemester());
|
|
|
-
|
|
|
- if (baseClassCourseService.checkExits(classId, courseId, textbookId)) {
|
|
|
- duplicateLogs.add(String.format("[输入的信息重复添加] 班级: %s, 课程: %s, 教材: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if (classId != null && courseId != null && textbookId != null && baseSemesterId != null) {
|
|
|
- BaseClassCourse baseClassCourse = new BaseClassCourse();
|
|
|
- baseClassCourse.setClassId(classId);
|
|
|
- baseClassCourse.setCourseId(courseId);
|
|
|
- baseClassCourse.setTextbookId(textbookId);
|
|
|
- baseClassCourse.setCreateDate(new Date());
|
|
|
- baseClassCourse.setDeleteMark(0);
|
|
|
- baseClassCourse.setBaseSemesterId(baseSemesterId);
|
|
|
- baseClassCourses.add(baseClassCourse);
|
|
|
+ for (BaseClassCourseExcelVo vo : savedDataList) {
|
|
|
+ if(vo.getClassName() == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(vo.getTextbookName() != null){
|
|
|
+ String[] textbookNames = vo.getTextbookName().split(" ");
|
|
|
+ for (String textbookName : textbookNames) {
|
|
|
+ try {
|
|
|
+ Long classId = classMap.get(vo.getClassName());
|
|
|
+ Long courseId = courseSubjectMap.get(vo.getCourseName());
|
|
|
+ Long textbookId = textbookMap.get(textbookName);
|
|
|
+ Long baseSemesterId = semesterMap.get(vo.getSemester());
|
|
|
+
|
|
|
+ if (baseClassCourseService.checkExits(classId, courseId, textbookId)) {
|
|
|
+ duplicateLogs.add(String.format("[输入的信息重复添加] 班级: %s, 课程: %s, 教材: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (classId != null && courseId != null && textbookId != null && baseSemesterId != null) {
|
|
|
+ BaseClassCourse baseClassCourse = new BaseClassCourse();
|
|
|
+ baseClassCourse.setClassId(classId);
|
|
|
+ baseClassCourse.setCourseId(courseId);
|
|
|
+ baseClassCourse.setTextbookId(textbookId);
|
|
|
+ baseClassCourse.setCreateDate(new Date());
|
|
|
+ baseClassCourse.setDeleteMark(0);
|
|
|
+ baseClassCourse.setBaseSemesterId(baseSemesterId);
|
|
|
+ baseClassCourses.add(baseClassCourse);
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ errorLogs.add(String.format("[无法解析输入的信息] 班级: %s, 班级: %s, 教材: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ errorLogs.add(String.format("[意外错误(检查输入的名称是否正确且存在,输入错误可能返回 null)] 班级: %s, 课程: %s, 教材: %s - 错误信息:%s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName(), e.getMessage()));
|
|
|
}
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- errorLogs.add(String.format("[无法解析输入的信息] 班级: %s, 班级: %s, 教材: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
|
|
|
- } catch (Exception e) {
|
|
|
- errorLogs.add(String.format("[意外错误(检查输入的名称是否正确且存在,输入错误可能返回 null)] 班级: %s, 课程: %s, 教材: %s - 错误信息:%s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName(), e.getMessage()));
|
|
|
}
|
|
|
+ }else{
|
|
|
+ Long classId = classMap.get(vo.getClassName());
|
|
|
+ Long courseId = courseSubjectMap.get(vo.getCourseName());
|
|
|
+ Long baseSemesterId = semesterMap.get(vo.getSemester());
|
|
|
+
|
|
|
+ BaseClassCourse baseClassCourse = new BaseClassCourse();
|
|
|
+ baseClassCourse.setClassId(classId);
|
|
|
+ baseClassCourse.setCourseId(courseId);
|
|
|
+ baseClassCourse.setCreateDate(new Date());
|
|
|
+ baseClassCourse.setDeleteMark(0);
|
|
|
+ baseClassCourse.setBaseSemesterId(baseSemesterId);
|
|
|
+ baseClassCourses.add(baseClassCourse);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
Boolean result = baseClassCourseService.saveBatch(baseClassCourses);
|