|
|
@@ -2,6 +2,7 @@ package com.xjrsoft.module.base.controller;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.xjrsoft.common.handler.FormContentStyleStrategy;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
@@ -11,6 +12,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.xjrsoft.module.base.entity.ClassCourseTextbook;
|
|
|
import com.xjrsoft.module.base.entity.CourseBookInfo;
|
|
|
+import com.xjrsoft.module.base.entity.ExportBaseClassCourseVo;
|
|
|
import com.xjrsoft.module.base.service.impl.BaseCourseSubjectServiceImpl;
|
|
|
import com.xjrsoft.module.textbook.service.impl.TextbookServiceImpl;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
@@ -21,7 +23,7 @@ import java.io.IOException;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import com.xjrsoft.module.base.dto.BaseClassCoursePageDto;
|
|
|
import com.xjrsoft.module.base.entity.BaseClassCourse;
|
|
|
@@ -35,9 +37,7 @@ import lombok.AllArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @title: 班级课程
|
|
|
@@ -156,7 +156,7 @@ public class BaseClassCourseController {
|
|
|
@PostMapping("/import")
|
|
|
@ApiOperation(value = "导入")
|
|
|
public RT<Boolean> importData(@RequestParam MultipartFile file) throws IOException {
|
|
|
- List<BaseClassCoursePageVo> savedDataList = EasyExcel.read(file.getInputStream()).head(BaseClassCoursePageVo.class).sheet().doReadSync();
|
|
|
+ List<BaseClassCoursePageVo> savedDataList = EasyExcel.read(file.getInputStream()).headRowNumber(3).head(BaseClassCoursePageVo.class).sheet().doReadSync();
|
|
|
|
|
|
List<BaseClassCourse> baseClassCourses = new ArrayList<>();
|
|
|
List<String> duplicateLogs = new ArrayList<>();
|
|
|
@@ -169,7 +169,7 @@ public class BaseClassCourseController {
|
|
|
Long textbookId = Long.parseLong(baseClassCourseService.GetTextbookIdByName(vo.getTextbookName()).toString());
|
|
|
|
|
|
if (baseClassCourseService.checkExits(classId, courseId, textbookId)) {
|
|
|
- duplicateLogs.add(String.format("输入的信息重复添加: %s, Course: %s, Textbook: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
|
|
|
+ duplicateLogs.add(String.format("[输入的信息重复添加] 班级: %s, 课程: %s, 教材: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
@@ -183,16 +183,16 @@ public class BaseClassCourseController {
|
|
|
baseClassCourses.add(baseClassCourse);
|
|
|
}
|
|
|
} catch (NumberFormatException e) {
|
|
|
- errorLogs.add(String.format("无法解析输入的信息: %s, Course: %s, Textbook: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
|
|
|
+ errorLogs.add(String.format("[无法解析输入的信息] 班级: %s, 班级: %s, 教材: %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName()));
|
|
|
} catch (Exception e) {
|
|
|
- errorLogs.add(String.format("Unexpected error for Class: %s, Course: %s, Textbook: %s - %s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName(), e.getMessage()));
|
|
|
+ errorLogs.add(String.format("[意外错误(检查输入的名称是否正确且存在,输入错误可能返回 null)] 班级: %s, 课程: %s, 教材: %s - 错误信息:%s", vo.getClassName(), vo.getCourseName(), vo.getTextbookName(), e.getMessage()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Boolean result = baseClassCourseService.saveBatch(baseClassCourses);
|
|
|
|
|
|
if (!duplicateLogs.isEmpty() || !errorLogs.isEmpty()) {
|
|
|
- String detailedMessage = String.format("导入完成但存在问题. Duplicates: %s. Errors: %s", String.join("; ", duplicateLogs), String.join("; ", errorLogs));
|
|
|
+ String detailedMessage = String.format("[导入完成但存在问题] 问题: %s. 其他错误: %s", String.join("; ", duplicateLogs), String.join("; ", errorLogs));
|
|
|
return RT.error(400, detailedMessage);
|
|
|
}
|
|
|
|