|
@@ -8,6 +8,10 @@ import java.util.Map;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.*;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.impl.ExamStudentServiceImpl;
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -18,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
@@ -26,10 +31,6 @@ import com.google.common.collect.Lists;
|
|
|
|
|
|
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;
|
|
|
-import cn.com.qmth.stmms.biz.exam.model.ExamPackage;
|
|
|
-import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
|
-import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
|
import cn.com.qmth.stmms.biz.exam.query.ExamStudentSearchQuery;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamPackageService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
@@ -293,6 +294,70 @@ public class ExamStudentController extends BaseParameterController {
|
|
|
}
|
|
|
return "redirect:" + "/admin/exam-param/student";
|
|
|
}
|
|
|
+ @RequestMapping(value = "/breachTemplate")
|
|
|
+ public String breachTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
|
|
+ try {
|
|
|
+ String fileName = "违纪考生导入模板.xlsx";
|
|
|
+ List<ExamStudentVO> list = Lists.newArrayList();
|
|
|
+ list.add(new ExamStudentVO());
|
|
|
+ new ExportExcel("", ExamStudentVO.class, 2).setDataList(list).write(response, fileName).dispose();
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ addMessage(redirectAttributes, "导入模板下载失败!失败信息:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return "redirect:" + "/admin/exam-param/student";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/breachImport", method = RequestMethod.POST)
|
|
|
+ public String breachImportFile(HttpServletRequest request, MultipartFile file, RedirectAttributes redirectAttributes) {
|
|
|
+ int examId = getSessionExamId(request);
|
|
|
+ Exam exam = examService.findById(examId);
|
|
|
+ try {
|
|
|
+ int successNum = 0;
|
|
|
+ ImportExcel ei = new ImportExcel(file, 0, 0);
|
|
|
+ List<ExamStudentVO> list = ei.getDataList(ExamStudentVO.class);
|
|
|
+ for (ExamStudentVO studentVO : list) {
|
|
|
+ if ( StringUtils.isBlank(studentVO.getExamNumber())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ExamStudent student = studentService.findByExamIdAndExamNumber(examId,studentVO.getExamNumber());
|
|
|
+ student.setBreach(true);
|
|
|
+ studentService.save(student);
|
|
|
+ saveMarkLibrary(student);
|
|
|
+ successNum ++;
|
|
|
+ }
|
|
|
+ addMessage(redirectAttributes, "已成功导入 " + successNum + " 条用户");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("Batch import BreachStudent error!", e);
|
|
|
+ addMessage(redirectAttributes, "导入考生失败!失败信息:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return "redirect:" + "/admin/exam-param/student";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "/updateBreach",method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public JSONObject updateBreach(HttpServletRequest request, Integer id) {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ ExamStudent student = studentService.findById(id);
|
|
|
+ student.setBreach(false);
|
|
|
+ try {
|
|
|
+ student = studentService.save(student);
|
|
|
+ saveMarkLibrary(student);
|
|
|
+ if (student != null) {
|
|
|
+ result.accumulate("message", "重置成功!");
|
|
|
+ result.accumulate("success", true);
|
|
|
+ } else {
|
|
|
+ result.accumulate("message", "将违纪考生信息重置为正常时出错!");
|
|
|
+ result.accumulate("success", false);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("将违纪考生信息重置为正常时出错!", e);
|
|
|
+ result.accumulate("message", "将违纪考生信息重置为正常时抛异常!");
|
|
|
+ result.accumulate("success", false);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
@RequestMapping(value = "/export", method = RequestMethod.POST)
|
|
|
public String exportFile(ExamStudentSearchQuery query, HttpServletRequest request, HttpServletResponse response,
|
|
@@ -344,6 +409,7 @@ public class ExamStudentController extends BaseParameterController {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void buildSheetUrl(ExamStudent student) {
|
|
|
Campus campus = campusService.findBySchoolAndName(student.getSchoolId(), student.getCampusName());
|
|
|
student.setSheetUrls(PictureUrlBuilder.getSheetUrls(student.getExamId(), campus.getId(),
|