|
@@ -1,9 +1,12 @@
|
|
package cn.com.qmth.stmms.api.controller.admin;
|
|
package cn.com.qmth.stmms.api.controller.admin;
|
|
|
|
|
|
|
|
+import java.lang.reflect.Type;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -16,6 +19,7 @@ import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -23,6 +27,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
|
|
|
|
@@ -31,6 +37,7 @@ import cn.com.qmth.stmms.admin.vo.ExamStudentVO;
|
|
import cn.com.qmth.stmms.admin.vo.UploadStudentVO;
|
|
import cn.com.qmth.stmms.admin.vo.UploadStudentVO;
|
|
import cn.com.qmth.stmms.api.controller.BaseApiController;
|
|
import cn.com.qmth.stmms.api.controller.BaseApiController;
|
|
import cn.com.qmth.stmms.biz.exam.bean.AnswerAiCheckSaveParam;
|
|
import cn.com.qmth.stmms.biz.exam.bean.AnswerAiCheckSaveParam;
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.bean.ExamStudentExportVo;
|
|
import cn.com.qmth.stmms.biz.exam.bean.ResultMessage;
|
|
import cn.com.qmth.stmms.biz.exam.bean.ResultMessage;
|
|
import cn.com.qmth.stmms.biz.exam.model.CollationLabel;
|
|
import cn.com.qmth.stmms.biz.exam.model.CollationLabel;
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
@@ -47,6 +54,8 @@ import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkService;
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkService;
|
|
|
|
+import cn.com.qmth.stmms.biz.user.model.User;
|
|
|
|
+import cn.com.qmth.stmms.biz.user.service.UserService;
|
|
import cn.com.qmth.stmms.biz.utils.PageUtil;
|
|
import cn.com.qmth.stmms.biz.utils.PageUtil;
|
|
import cn.com.qmth.stmms.common.annotation.Logging;
|
|
import cn.com.qmth.stmms.common.annotation.Logging;
|
|
import cn.com.qmth.stmms.common.enums.ExamType;
|
|
import cn.com.qmth.stmms.common.enums.ExamType;
|
|
@@ -54,6 +63,7 @@ import cn.com.qmth.stmms.common.enums.LogType;
|
|
import cn.com.qmth.stmms.common.enums.MarkStatus;
|
|
import cn.com.qmth.stmms.common.enums.MarkStatus;
|
|
import cn.com.qmth.stmms.common.enums.SubjectiveStatus;
|
|
import cn.com.qmth.stmms.common.enums.SubjectiveStatus;
|
|
import cn.com.qmth.stmms.common.utils.ExportExcel;
|
|
import cn.com.qmth.stmms.common.utils.ExportExcel;
|
|
|
|
+import cn.com.qmth.stmms.common.utils.ExportExcelByCols;
|
|
import cn.com.qmth.stmms.common.utils.ImportExcel;
|
|
import cn.com.qmth.stmms.common.utils.ImportExcel;
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -88,6 +98,9 @@ public class StudentController extends BaseApiController {
|
|
@Autowired
|
|
@Autowired
|
|
private MarkGroupService groupService;
|
|
private MarkGroupService groupService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserService userService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private CollationLabelService collationLabelService;
|
|
private CollationLabelService collationLabelService;
|
|
|
|
|
|
@@ -290,8 +303,7 @@ public class StudentController extends BaseApiController {
|
|
list.add(new ExamStudent());
|
|
list.add(new ExamStudent());
|
|
new ExportExcel("考生数据", ExamStudent.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
new ExportExcel("考生数据", ExamStudent.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error(e.getMessage());
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -366,7 +378,6 @@ public class StudentController extends BaseApiController {
|
|
return result(message + failureMsg);
|
|
return result(message + failureMsg);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("Batch import student error!", e);
|
|
log.error("Batch import student error!", e);
|
|
- e.printStackTrace();
|
|
|
|
throw new StatusException("导入考生失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入考生失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -388,6 +399,17 @@ public class StudentController extends BaseApiController {
|
|
@Logging(menu = "导出考生", type = LogType.EXPORT)
|
|
@Logging(menu = "导出考生", type = LogType.EXPORT)
|
|
@RequestMapping(value = "/export", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/export", method = RequestMethod.POST)
|
|
public void exportFile(ExamStudentSearchQuery query, HttpServletRequest request, HttpServletResponse response) {
|
|
public void exportFile(ExamStudentSearchQuery query, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
+ User user = userService.findById(getApiUser().getId());
|
|
|
|
+ if (StringUtils.isBlank(user.getStudentExportCols())) {
|
|
|
|
+ throw new StatusException("表头配置没有勾选任何字段");
|
|
|
|
+ }
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ Type setType = new TypeToken<Set<String>>() {
|
|
|
|
+ }.getType();
|
|
|
|
+ Set<String> cols = gson.fromJson(user.getStudentExportCols(), setType);
|
|
|
|
+ if (CollectionUtils.isEmpty(cols)) {
|
|
|
|
+ throw new StatusException("表头配置没有勾选任何字段");
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
int examId = getSessionExamId(request);
|
|
int examId = getSessionExamId(request);
|
|
query.setPageNumber(1);
|
|
query.setPageNumber(1);
|
|
@@ -395,19 +417,17 @@ public class StudentController extends BaseApiController {
|
|
query.setExamId(examId);
|
|
query.setExamId(examId);
|
|
query.addSort("id", Sort.Direction.ASC);
|
|
query.addSort("id", Sort.Direction.ASC);
|
|
query = studentService.findByQuery(query);
|
|
query = studentService.findByQuery(query);
|
|
|
|
+ List<ExamStudentExportVo> ret = new ArrayList<>();
|
|
for (ExamStudent student : query.getResult()) {
|
|
for (ExamStudent student : query.getResult()) {
|
|
ExamSubject subject = subjectService.find(student.getExamId(), student.getSubjectCode());
|
|
ExamSubject subject = subjectService.find(student.getExamId(), student.getSubjectCode());
|
|
- student.setSubjectName(subject != null ? subject.getName() : "");
|
|
|
|
- student.setSubjectLevel(subject != null ? subject.getLevel() : "");
|
|
|
|
- student.setSubjectCategory(subject != null ? subject.getCategory() : "");
|
|
|
|
- student.setSubjectRemark(subject != null ? subject.getRemark() : "");
|
|
|
|
|
|
+ student.setSubject(subject);
|
|
|
|
+ ret.add(ExamStudentExportVo.of(student));
|
|
}
|
|
}
|
|
String fileName = "考生数据.xlsx";
|
|
String fileName = "考生数据.xlsx";
|
|
- new ExportExcel("考生数据", ExamStudent.class).setDataList(query.getResult()).write(response, fileName)
|
|
|
|
|
|
+ new ExportExcelByCols("考生数据", ExamStudentExportVo.class, cols).setDataList(ret).write(response, fileName)
|
|
.dispose();
|
|
.dispose();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error(e.getMessage());
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
throw new StatusException("导出考生数据失败!" + e.getMessage());
|
|
throw new StatusException("导出考生数据失败!" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -421,8 +441,7 @@ public class StudentController extends BaseApiController {
|
|
list.add(new ExamStudentVO());
|
|
list.add(new ExamStudentVO());
|
|
new ExportExcel("缺考考生", ExamStudentVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
new ExportExcel("缺考考生", ExamStudentVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error(e.getMessage());
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -462,7 +481,6 @@ public class StudentController extends BaseApiController {
|
|
return result(message + failureMsg);
|
|
return result(message + failureMsg);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("Batch import absentStudent error!", e);
|
|
log.error("Batch import absentStudent error!", e);
|
|
- e.printStackTrace();
|
|
|
|
throw new StatusException("导入缺考考生失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入缺考考生失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -476,8 +494,7 @@ public class StudentController extends BaseApiController {
|
|
list.add(new ExamStudentVO());
|
|
list.add(new ExamStudentVO());
|
|
new ExportExcel("违纪考生", ExamStudentVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
new ExportExcel("违纪考生", ExamStudentVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error(e.getMessage());
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -516,7 +533,6 @@ public class StudentController extends BaseApiController {
|
|
return result(message + failureMsg);
|
|
return result(message + failureMsg);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("Batch import BreachStudent error!", e);
|
|
log.error("Batch import BreachStudent error!", e);
|
|
- e.printStackTrace();
|
|
|
|
throw new StatusException("导入违纪考生失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入违纪考生失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -549,8 +565,7 @@ public class StudentController extends BaseApiController {
|
|
list.add(new UploadStudentVO());
|
|
list.add(new UploadStudentVO());
|
|
new ExportExcel("多媒体考生上传", UploadStudentVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
new ExportExcel("多媒体考生上传", UploadStudentVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error(e.getMessage());
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -606,7 +621,6 @@ public class StudentController extends BaseApiController {
|
|
return result("已成功导入 " + successNum + " 条用户" + failureMsg);
|
|
return result("已成功导入 " + successNum + " 条用户" + failureMsg);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("Batch import BreachStudent error!", e);
|
|
log.error("Batch import BreachStudent error!", e);
|
|
- e.printStackTrace();
|
|
|
|
throw new StatusException("导入上传考生失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入上传考生失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -620,8 +634,7 @@ public class StudentController extends BaseApiController {
|
|
list.add(new ExamStudentVO());
|
|
list.add(new ExamStudentVO());
|
|
new ExportExcel("整理异常", CollationLabelVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
new ExportExcel("整理异常", CollationLabelVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error(e.getMessage());
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -666,7 +679,6 @@ public class StudentController extends BaseApiController {
|
|
return result(message + failureMsg);
|
|
return result(message + failureMsg);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("Batch import CollationLabel error!", e);
|
|
log.error("Batch import CollationLabel error!", e);
|
|
- e.printStackTrace();
|
|
|
|
throw new StatusException("导入整理异常失败!失败信息:" + e.getMessage());
|
|
throw new StatusException("导入整理异常失败!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|