|
@@ -25,6 +25,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
import cn.com.qmth.stmms.admin.vo.ExamStudentVO;
|
|
|
+import cn.com.qmth.stmms.admin.vo.UploadStudentVO;
|
|
|
import cn.com.qmth.stmms.biz.campus.model.Campus;
|
|
|
import cn.com.qmth.stmms.biz.campus.service.CampusService;
|
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
@@ -466,6 +467,64 @@ public class StudentController extends BaseExamController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/uploadTemplate")
|
|
|
+ public String uploadTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
|
|
+ try {
|
|
|
+ String fileName = "多媒体考生上传导入模板.xlsx";
|
|
|
+ List<UploadStudentVO> list = Lists.newArrayList();
|
|
|
+ list.add(new UploadStudentVO());
|
|
|
+ new ExportExcel("多媒体考生上传", UploadStudentVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ addMessage(redirectAttributes, "导入模板下载失败!失败信息:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return "redirect:/admin/exam/student";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/uploadImport", method = RequestMethod.POST)
|
|
|
+ public String uploadImportFile(HttpServletRequest request, MultipartFile file, RedirectAttributes redirectAttributes) {
|
|
|
+ int examId = getSessionExamId(request);
|
|
|
+ // Exam exam = examService.findById(examId);
|
|
|
+ try {
|
|
|
+ int successNum = 0;
|
|
|
+ int failureNum = 0;
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+ ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
+ List<UploadStudentVO> list = ei.getDataList(UploadStudentVO.class);
|
|
|
+ for (UploadStudentVO studentVO : list) {
|
|
|
+ if (StringUtils.isBlank(studentVO.getExamNumber())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ExamStudent student = studentService.findByExamIdAndExamNumber(examId, studentVO.getExamNumber());
|
|
|
+ if (student != null) {
|
|
|
+ student.setUpload(true);
|
|
|
+ student.setAbsent(false);
|
|
|
+ student.setAnswers(null);
|
|
|
+ student.setBatchCode(null);
|
|
|
+ student.setSliceCount(0);
|
|
|
+ student.setSheetCount(0);
|
|
|
+ student.setPaperType(StringUtils.trimToNull(studentVO.getPaperType()));
|
|
|
+ // 同步更新评卷任务
|
|
|
+ if (saveUploadStudent(student)) {
|
|
|
+ successNum++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ failureMsg.append("<br/>准考证号 " + studentVO.getExamNumber() + " 不存在; ");
|
|
|
+ failureNum++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (failureNum > 0) {
|
|
|
+ failureMsg.insert(0, ",失败 " + failureNum + " 条用户");
|
|
|
+ }
|
|
|
+ addMessage(redirectAttributes, "已成功导入 " + successNum + " 条用户" + failureMsg);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("Batch import BreachStudent error!", e);
|
|
|
+ addMessage(redirectAttributes, "导入上传考生失败!失败信息:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return "redirect:/admin/exam/student";
|
|
|
+ }
|
|
|
+
|
|
|
private ExamStudent checkExamNumber(ExamStudent student, Map<String, ExamStudent> current,
|
|
|
Map<String, ExamStudent> saveMap) {
|
|
|
ExamStudent previous = saveMap.get(student.getExamNumber());
|