|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
|
|
import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
|
|
|
|
+import com.qmth.distributed.print.business.bean.dto.GradeBatchStudentDto;
|
|
import com.qmth.distributed.print.business.bean.params.analyze.GradeBatchParam;
|
|
import com.qmth.distributed.print.business.bean.params.analyze.GradeBatchParam;
|
|
import com.qmth.distributed.print.business.bean.result.analyze.GradeBatchResult;
|
|
import com.qmth.distributed.print.business.bean.result.analyze.GradeBatchResult;
|
|
import com.qmth.distributed.print.business.entity.GradeBatch;
|
|
import com.qmth.distributed.print.business.entity.GradeBatch;
|
|
@@ -37,10 +38,8 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Objects;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -175,29 +174,29 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
|
|
XSSFCell cell0 = row.createCell(0);
|
|
XSSFCell cell0 = row.createCell(0);
|
|
cell0.setCellValue(examStudentCourseDto.getCourseCode());
|
|
cell0.setCellValue(examStudentCourseDto.getCourseCode());
|
|
|
|
|
|
- XSSFCell cell1 = row.createCell(0);
|
|
|
|
|
|
+ XSSFCell cell1 = row.createCell(1);
|
|
cell1.setCellValue(examStudentCourseDto.getCourseName());
|
|
cell1.setCellValue(examStudentCourseDto.getCourseName());
|
|
|
|
|
|
- XSSFCell cell2 = row.createCell(0);
|
|
|
|
|
|
+ XSSFCell cell2 = row.createCell(2);
|
|
cell2.setCellValue(examStudentCourseDto.getPaperNumber());
|
|
cell2.setCellValue(examStudentCourseDto.getPaperNumber());
|
|
|
|
|
|
- XSSFCell cell3 = row.createCell(0);
|
|
|
|
|
|
+ XSSFCell cell3 = row.createCell(3);
|
|
cell3.setCellValue(examStudentCourseDto.getPaperType());
|
|
cell3.setCellValue(examStudentCourseDto.getPaperType());
|
|
|
|
|
|
- XSSFCell cell4 = row.createCell(0);
|
|
|
|
|
|
+ XSSFCell cell4 = row.createCell(4);
|
|
cell4.setCellValue(examStudentCourseDto.getStudentCode());
|
|
cell4.setCellValue(examStudentCourseDto.getStudentCode());
|
|
|
|
|
|
- XSSFCell cell5 = row.createCell(0);
|
|
|
|
|
|
+ XSSFCell cell5 = row.createCell(5);
|
|
cell5.setCellValue(examStudentCourseDto.getStudentName());
|
|
cell5.setCellValue(examStudentCourseDto.getStudentName());
|
|
|
|
|
|
- XSSFCell cell6 = row.createCell(0);
|
|
|
|
|
|
+ XSSFCell cell6 = row.createCell(6);
|
|
cell6.setCellValue(examStudentCourseDto.getTicketNumber());
|
|
cell6.setCellValue(examStudentCourseDto.getTicketNumber());
|
|
}
|
|
}
|
|
|
|
|
|
OutputStream output = response.getOutputStream();
|
|
OutputStream output = response.getOutputStream();
|
|
response.reset();
|
|
response.reset();
|
|
- response.setCharacterEncoding("UTF-8");
|
|
|
|
- response.setHeader("Content-disposition", "attachment;filename=" + fileName);
|
|
|
|
|
|
+ response.setCharacterEncoding("ISO-8859-1");
|
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
|
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
wb.write(output);
|
|
wb.write(output);
|
|
output.flush();
|
|
output.flush();
|
|
@@ -206,19 +205,20 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void uploadFile(Long batchId, MultipartFile file) throws IOException, NoSuchFieldException {
|
|
public void uploadFile(Long batchId, MultipartFile file) throws IOException, NoSuchFieldException {
|
|
- List<ExamStudentCourseDto> list = new ArrayList<>();
|
|
|
|
- List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(ExamStudentCourseDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
|
|
|
+ List<GradeBatchStudentDto> list = new ArrayList<>();
|
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradeBatchStudentDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
// 只允许导入一个sheet
|
|
// 只允许导入一个sheet
|
|
if (finalExcelList.size() > 1) {
|
|
if (finalExcelList.size() > 1) {
|
|
throw ExceptionResultEnum.ERROR.exception("excel中只允许有一个sheet");
|
|
throw ExceptionResultEnum.ERROR.exception("excel中只允许有一个sheet");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Map<String, String> teacherMap = new HashMap<>();
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
List<Object> gradeBatchStudentTempList = excelMap.get(i);
|
|
List<Object> gradeBatchStudentTempList = excelMap.get(i);
|
|
for (int y = 0; y < gradeBatchStudentTempList.size(); y++) {
|
|
for (int y = 0; y < gradeBatchStudentTempList.size(); y++) {
|
|
- ExamStudentCourseDto examStudentCourseDto = (ExamStudentCourseDto) gradeBatchStudentTempList.get(y);
|
|
|
|
|
|
+ GradeBatchStudentDto examStudentCourseDto = (GradeBatchStudentDto) gradeBatchStudentTempList.get(y);
|
|
if (StringUtils.isBlank(examStudentCourseDto.getCourseCode())) {
|
|
if (StringUtils.isBlank(examStudentCourseDto.getCourseCode())) {
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程代码]必填"));
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程代码]必填"));
|
|
}
|
|
}
|
|
@@ -240,27 +240,36 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
|
|
if (StringUtils.isBlank(examStudentCourseDto.getTicketNumber())) {
|
|
if (StringUtils.isBlank(examStudentCourseDto.getTicketNumber())) {
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[准考证号]必填"));
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[准考证号]必填"));
|
|
}
|
|
}
|
|
- if (StringUtils.isBlank(examStudentCourseDto.getTeacherName())) {
|
|
|
|
|
|
+ String teacherName = examStudentCourseDto.getTeacherName();
|
|
|
|
+ if (StringUtils.isBlank(teacherName)) {
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师]必填"));
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师]必填"));
|
|
}
|
|
}
|
|
- if (StringUtils.isBlank(examStudentCourseDto.getTeacherNumber())) {
|
|
|
|
|
|
+ String teacherNumber = examStudentCourseDto.getTeacherNumber();
|
|
|
|
+ if (StringUtils.isBlank(teacherNumber)) {
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师工号]必填"));
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师工号]必填"));
|
|
}
|
|
}
|
|
|
|
+ if(teacherMap.containsKey(teacherNumber) && !teacherName.equals(teacherMap.get(teacherNumber))){
|
|
|
|
+ excelErrorTemp.add(new ExcelError(y + 1, "excel中同一个任课老师工号有多个姓名"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ teacherMap.put(examStudentCourseDto.getTeacherNumber(), examStudentCourseDto.getTeacherName());
|
|
|
|
|
|
list.add(examStudentCourseDto);
|
|
list.add(examStudentCourseDto);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
if (excelErrorTemp.size() > 0) {
|
|
if (excelErrorTemp.size() > 0) {
|
|
List<String> errors = excelErrorTemp.stream().map(m -> m.getExcelErrorType()).collect(Collectors.toList());
|
|
List<String> errors = excelErrorTemp.stream().map(m -> m.getExcelErrorType()).collect(Collectors.toList());
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
|
|
}
|
|
}
|
|
return finalExcelList;
|
|
return finalExcelList;
|
|
});
|
|
});
|
|
|
|
+
|
|
executeImportGradeBatchStudent(batchId, list);
|
|
executeImportGradeBatchStudent(batchId, list);
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
- public void executeImportGradeBatchStudent(Long batchId, List<ExamStudentCourseDto> list) {
|
|
|
|
|
|
+ public void executeImportGradeBatchStudent(Long batchId, List<GradeBatchStudentDto> list) {
|
|
UpdateWrapper<GradeBatchStudent> updateWrapper = new UpdateWrapper<>();
|
|
UpdateWrapper<GradeBatchStudent> updateWrapper = new UpdateWrapper<>();
|
|
updateWrapper.lambda().eq(GradeBatchStudent::getBatchId, batchId);
|
|
updateWrapper.lambda().eq(GradeBatchStudent::getBatchId, batchId);
|
|
gradeBatchStudentService.remove(updateWrapper);
|
|
gradeBatchStudentService.remove(updateWrapper);
|
|
@@ -268,6 +277,7 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
|
|
List<GradeBatchStudent> gradeBatchStudents = list.stream().map(m -> {
|
|
List<GradeBatchStudent> gradeBatchStudents = list.stream().map(m -> {
|
|
GradeBatchStudent gradeBatchStudent = new GradeBatchStudent();
|
|
GradeBatchStudent gradeBatchStudent = new GradeBatchStudent();
|
|
gradeBatchStudent.setBatchId(SystemConstant.getDbUuid());
|
|
gradeBatchStudent.setBatchId(SystemConstant.getDbUuid());
|
|
|
|
+ gradeBatchStudent.setBatchId(batchId);
|
|
gradeBatchStudent.setCourseCode(m.getCourseCode());
|
|
gradeBatchStudent.setCourseCode(m.getCourseCode());
|
|
gradeBatchStudent.setCourseName(m.getCourseName());
|
|
gradeBatchStudent.setCourseName(m.getCourseName());
|
|
gradeBatchStudent.setPaperNumber(m.getPaperNumber());
|
|
gradeBatchStudent.setPaperNumber(m.getPaperNumber());
|