|
@@ -40,7 +40,6 @@ import cn.com.qmth.examcloud.common.dto.core.Course;
|
|
|
import cn.com.qmth.examcloud.common.dto.examwork.CommonExamStudent;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
|
|
|
-import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.examwork.base.util.ExportUtils;
|
|
|
import cn.com.qmth.examcloud.core.examwork.base.util.ImportUtils;
|
|
@@ -55,354 +54,367 @@ import cn.com.qmth.examcloud.core.examwork.service.impl.ExamStudentService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
|
- * 考生服务API
|
|
|
- * Created by songyue on 17/1/13.
|
|
|
+ * 考生服务API Created by songyue on 17/1/13.
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("${$rmp.ctr.examwork}/exam_student")
|
|
|
-public class ExamStudentController extends ControllerSupport{
|
|
|
-
|
|
|
- private static final Logger log = LoggerFactory.getLogger(ExamStudentController.class);
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamStudentRepo examStudentRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamStudentService examStudentService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamStudentAssembler examStudentAssembler;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamRepo examRepo;
|
|
|
-
|
|
|
- @GetMapping("/query")
|
|
|
- public List<ExamStudent> find(@RequestParam(value = "student_id", required = false) Long studentId) {
|
|
|
-
|
|
|
- return examStudentRepo.findAll((root, query, cb) -> {
|
|
|
-
|
|
|
- List<Predicate> predicates = new ArrayList<Predicate>();
|
|
|
-
|
|
|
- if (studentId != null) {
|
|
|
- predicates.add(cb.equal(root.get("studentId"), studentId));
|
|
|
- }
|
|
|
-
|
|
|
- Predicate[] pre = new Predicate[predicates.size()];
|
|
|
- return query.where(predicates.toArray(pre)).getRestriction();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "查询考试学生带条件和分页", notes = "带条件带分页")
|
|
|
- @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getAllExamStudent(HttpServletRequest request,
|
|
|
- @ModelAttribute ExamStudentDTO examStudent,
|
|
|
- @PathVariable Integer curPage,
|
|
|
- @PathVariable Integer pageSize) {
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
- if (accessUser != null) {
|
|
|
- if (accessUser.getRootOrgId().longValue() == accessUser.getOrgId().longValue()
|
|
|
- || examStudent.getStudentId() != null) {
|
|
|
- examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
- } else {
|
|
|
- examStudent.setOrgId(accessUser.getOrgId());
|
|
|
- }
|
|
|
- } else {
|
|
|
- return new ResponseEntity(new ErrorMsg("无访问权限"),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- return new ResponseEntity(examStudentService.getAllExamStudent(examStudent,
|
|
|
- new PageRequest(curPage, pageSize,new Sort(Direction.DESC,"id"))), HttpStatus.OK);
|
|
|
- }
|
|
|
- /**
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "查询重考考生", notes = "查询重考考生")
|
|
|
- @PostMapping("/reexamineStudents/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getReexamineStudents(@RequestBody CommonExamStudent examStudentSpecification,
|
|
|
- @PathVariable Integer curPage,
|
|
|
- @PathVariable Integer pageSize){
|
|
|
- try{
|
|
|
- Page<ExamStudent> pageExamStudents = examStudentService.getReexamineStudent(examStudentSpecification, curPage, pageSize);
|
|
|
- if(pageExamStudents == null
|
|
|
- || pageExamStudents.getContent() == null
|
|
|
- || pageExamStudents.getContent().size() == 0){
|
|
|
- return new ResponseEntity(new ErrorMsg("无数据"), HttpStatus.OK);
|
|
|
- }
|
|
|
- return new ResponseEntity(pageExamStudents,HttpStatus.OK);
|
|
|
- }catch(Exception e){
|
|
|
- log.error("调用失败:",e);
|
|
|
- return new ResponseEntity(new ErrorMsg("调用失败"),HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "查询所有考试学生带条件", notes = "带条件不分页")
|
|
|
- @GetMapping("/all")
|
|
|
- public ResponseEntity getAllExamStudent(HttpServletRequest request,
|
|
|
- @ModelAttribute ExamStudentDTO examStudent) {
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
- if (accessUser != null) {
|
|
|
- if (accessUser.getRootOrgId().longValue() == accessUser.getOrgId().longValue()
|
|
|
- || examStudent.getStudentId() != null) {
|
|
|
- examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
- } else {
|
|
|
- examStudent.setOrgId(accessUser.getOrgId());
|
|
|
- }
|
|
|
- }
|
|
|
- return new ResponseEntity(examStudentService.getAllExamStudent(examStudent), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "查询所有考试学生带条件", notes = "带条件按照限制查询")
|
|
|
- @GetMapping("/limit/{examId}/{startLimit}/{endLimit}")
|
|
|
- public ResponseEntity getExamStudentByLimit(@PathVariable("examId") Long examId,
|
|
|
- @PathVariable("startLimit") Integer startLimit,
|
|
|
- @PathVariable("endLimit") Integer endLimit){
|
|
|
- List<ExamStudent> examStudents = examStudentService.getExamStudentByLimit(examId,startLimit,endLimit);
|
|
|
- return new ResponseEntity(examStudents,HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "按ID查询考试学生", notes = "ID查询")
|
|
|
- @GetMapping("/{id}")
|
|
|
- public ResponseEntity getExamStudentById(@PathVariable Long id) {
|
|
|
- return new ResponseEntity(examStudentService.findById(id), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "新增考试学生", notes = "新增")
|
|
|
- @PostMapping()
|
|
|
- public ResponseEntity addExamStudent(HttpServletRequest request,
|
|
|
- @RequestBody ExamStudent examStudent) {
|
|
|
- try {
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
- if (accessUser != null) {
|
|
|
- examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
- }
|
|
|
- Exam exam = examRepo.findOne(examStudent.getExam().getId());
|
|
|
- examStudent.setExam(exam);
|
|
|
- if (StringUtils.isEmpty(examStudent.getPaperType())) {
|
|
|
- examStudent.setPaperType("O");
|
|
|
- }
|
|
|
- ExamStudent saveExamStu = examStudentService.saveExamStudent(accessUser.getUserToken(),examStudent);
|
|
|
- return new ResponseEntity(saveExamStu, HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("新增失败:",e);
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "更新考试学生", notes = "更新")
|
|
|
- @PutMapping()
|
|
|
- public ResponseEntity updateExamStudent(@RequestBody ExamStudent examStudent) {
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
- try {
|
|
|
- Exam exam = examRepo.findOne(examStudent.getExam().getId());
|
|
|
- examStudent.setExam(exam);
|
|
|
- if (StringUtils.isEmpty(examStudent.getPaperType())) {
|
|
|
- examStudent.setPaperType("O");
|
|
|
- }
|
|
|
- ExamStudent saveExamStu = examStudentService.saveExamStudent(accessUser.getUserToken(),examStudent);
|
|
|
- return new ResponseEntity(saveExamStu, HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("更新失败:",e);
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "更新考试学生缺考状态", notes = "更新缺考")
|
|
|
- @PutMapping("/{id}")
|
|
|
- public ResponseEntity<ExamStudent> getExamStudentById(@PathVariable Long id,
|
|
|
- @RequestParam boolean finished) {
|
|
|
- ExamStudent examStudent = examStudentRepo.findOne(id);
|
|
|
- examStudent.setFinished(finished);
|
|
|
- //进入考试时,判断考试次数是否小于考试信息(ecs_exam)中的考试次数,如果是,考试次数加一
|
|
|
- long examTimes = examStudent.getExam().getExamTimes();
|
|
|
- if(examTimes > examStudent.getNormalExamTimes()){
|
|
|
- examStudent.setNormalExamTimes(examStudent.getNormalExamTimes()+1);
|
|
|
- }
|
|
|
- return new ResponseEntity<ExamStudent>(examStudentRepo.save(examStudent), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "按ID删除考试学生", notes = "删除")
|
|
|
- @DeleteMapping("/{id}")
|
|
|
- public ResponseEntity deleteExamStudent(@PathVariable String id) {
|
|
|
- List<Long> examStuIds = Stream.of(id.split(","))
|
|
|
- .map(s -> Long.parseLong(s.trim()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- try {
|
|
|
- examStudentService.deleteExamStudent(examStuIds);
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("删除失败:",e);
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "按考试删除考试学生", notes = "按考试删除")
|
|
|
- @DeleteMapping("/exam/{examId}")
|
|
|
- public ResponseEntity deleteExamStudents(@PathVariable Long examId) {
|
|
|
- try {
|
|
|
- examStudentService.deleteExamStudents(examId);
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("删除失败:",e);
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "导入考试学生", notes = "导入")
|
|
|
- @PostMapping("/import")
|
|
|
- public ResponseEntity importExamStudent(@RequestParam Long examId, @RequestParam CommonsMultipartFile file) {
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
- try {
|
|
|
- File tempFile = ImportUtils.getUploadFile(file);
|
|
|
- List<ExcelError> excelErrors = examStudentService.importExamStudent(accessUser.getUserToken(),examId, new FileInputStream(tempFile));
|
|
|
- return new ResponseEntity(excelErrors, HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("导入失败:",e);
|
|
|
- return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "下载导入模板", notes = "下载导入模板")
|
|
|
- @GetMapping("/download")
|
|
|
- public void importFileTemplate(HttpServletResponse response) {
|
|
|
- List<ExamStudentDTO> list = new ArrayList<ExamStudentDTO>();
|
|
|
- ExportUtils.exportEXCEL("考生导入模板", ExamStudentDTO.class, list, response);
|
|
|
- }
|
|
|
-
|
|
|
-// @ApiOperation(value="导入学生照片",notes = "导入")
|
|
|
-// @PostMapping("/exam_student/import_photo")
|
|
|
-// public ResponseEntity importPhoto(@RequestParam Long examId,@RequestParam MultipartFile file){
|
|
|
-// try {
|
|
|
-// List<ErrorMsg> errorMsgs = examStudentService.importPhoto(examId,file.getInputStream());
|
|
|
-// return new ResponseEntity(errorMsgs,HttpStatus.OK);
|
|
|
-// } catch (IOException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
- @ApiOperation(value = "照片检验", notes = "检验")
|
|
|
- @PostMapping("/photo_check")
|
|
|
- public ResponseEntity photoCheck(@RequestParam Long examId) {
|
|
|
- try {
|
|
|
- List<ErrorMsg> errorMsgs = examStudentService.photoCheck(examId);
|
|
|
- return new ResponseEntity(errorMsgs, HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "导出考试学生带条件", notes = "导出")
|
|
|
- @GetMapping("/export")
|
|
|
- public void exportExamStudent(@ModelAttribute ExamStudentDTO examCriteria, HttpServletResponse response) {
|
|
|
- List<ExamStudentDTO> list = new ArrayList<ExamStudentDTO>();
|
|
|
- examStudentService.getAllExamStudent(examCriteria).forEach(c -> {
|
|
|
- list.add(examStudentAssembler.toDTO(c));
|
|
|
- });
|
|
|
- ExportUtils.exportEXCEL("课程列表", ExamStudentDTO.class, list, response);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "复制考试学生", notes = "复制")
|
|
|
- @PostMapping("/copy/{sourceExamId}/{targetExamId}")
|
|
|
- public ResponseEntity copyExamStudent(@PathVariable Long sourceExamId, @PathVariable Long targetExamId) {
|
|
|
- try {
|
|
|
- examStudentService.copyExamStudent(sourceExamId, targetExamId);
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("复制失败:",e);
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "考生完成数量", notes = "考生完成数量")
|
|
|
- @GetMapping("/count-by-finished")
|
|
|
- public Map<String, Integer> countByFinished(@RequestParam Long examId) {
|
|
|
-
|
|
|
- int finished = examStudentRepo.countByExamIdAndFinished(examId, true);
|
|
|
- int unFinished = examStudentRepo.countByExamIdAndFinished(examId, false);
|
|
|
- Map<String, Integer> result = new HashMap<>();
|
|
|
- result.put("finished", finished);
|
|
|
- result.put("unFinished", unFinished);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "按学习中心统计完成数量", notes = "按学习中心统计完成数量")
|
|
|
- @GetMapping("/count-by-campus")
|
|
|
- public List<Map<String, Object>> countByCampus(@RequestParam Long examId) {
|
|
|
-
|
|
|
- List<Object[]> resultList = examStudentRepo.countByCampusAndFinished(examId);
|
|
|
- List<Map<String, Object>> returnList = new ArrayList<>();
|
|
|
- for (Object[] objects : resultList) {
|
|
|
- Long orgId = ((BigInteger) objects[0]).longValue();
|
|
|
- String orgName = (String) objects[1];
|
|
|
- Boolean finished = (Boolean) objects[2];
|
|
|
- Integer count = ((BigInteger) objects[3]).intValue();
|
|
|
-
|
|
|
-
|
|
|
- boolean found = false;
|
|
|
- for (Map<String, Object> m : returnList) {
|
|
|
- if (m.get("orgId").equals(orgId)) {
|
|
|
- found = true;
|
|
|
-
|
|
|
- if (finished) {
|
|
|
- m.put("finished", count);
|
|
|
- } else {
|
|
|
- m.put("unFinished", count);
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!found) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- map.put("orgId", orgId);
|
|
|
- map.put("orgName", orgName);
|
|
|
- if (finished) {
|
|
|
- map.put("finished", count);
|
|
|
- } else {
|
|
|
- map.put("unFinished", count);
|
|
|
- }
|
|
|
-
|
|
|
- returnList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return returnList;
|
|
|
-
|
|
|
- }
|
|
|
- @ApiOperation(value = "学习中心考试进度信息", notes = "学习中心考试进度信息")
|
|
|
- @GetMapping("/findOrgExamInfos")
|
|
|
- public ResponseEntity<Object> findOrgExamInfos(String examId,String orgCode){
|
|
|
- try{
|
|
|
- List<OrgExamInfoDTO> orgExamInfoDTOs = examStudentService.findOrgExamInfos(examId, orgCode);
|
|
|
- return new ResponseEntity<Object>(orgExamInfoDTOs,HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "从考试表中查询课程", notes = "从考试表中查询课程")
|
|
|
- @GetMapping("/findCoursesFromExamStudent")
|
|
|
- public ResponseEntity<Object> findCoursesFromExamStudent(String examId,String orgId){
|
|
|
- try{
|
|
|
- List<Course> courses = examStudentService.findCoursesFromExamStudent(examId, orgId);
|
|
|
- return new ResponseEntity<Object>(courses,HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "设置考生为重考状态", notes = "设置考生为重考状态")
|
|
|
- @PostMapping("/setExamStudentReexamine")
|
|
|
- public ResponseEntity<Object> setExamStudentIsReexamine(@RequestBody CommonExamStudent commonExamStudent){
|
|
|
- if(commonExamStudent.getId() == null){
|
|
|
- return new ResponseEntity<Object>(new ErrorMsg("考生ID不能为空"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- examStudentService.setExamStudentIsReexamine(commonExamStudent);
|
|
|
- return new ResponseEntity<Object>(HttpStatus.OK);
|
|
|
- }
|
|
|
+public class ExamStudentController extends ControllerSupport {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ExamStudentController.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamStudentRepo examStudentRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamStudentService examStudentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamStudentAssembler examStudentAssembler;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamRepo examRepo;
|
|
|
+
|
|
|
+ @GetMapping("/query")
|
|
|
+ public List<ExamStudent> find(
|
|
|
+ @RequestParam(value = "student_id", required = false) Long studentId) {
|
|
|
+
|
|
|
+ return examStudentRepo.findAll((root, query, cb) -> {
|
|
|
+
|
|
|
+ List<Predicate> predicates = new ArrayList<Predicate>();
|
|
|
+
|
|
|
+ if (studentId != null) {
|
|
|
+ predicates.add(cb.equal(root.get("studentId"), studentId));
|
|
|
+ }
|
|
|
+
|
|
|
+ Predicate[] pre = new Predicate[predicates.size()];
|
|
|
+ return query.where(predicates.toArray(pre)).getRestriction();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询考试学生带条件和分页", notes = "带条件带分页")
|
|
|
+ @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
+ public ResponseEntity getAllExamStudent(HttpServletRequest request,
|
|
|
+ @ModelAttribute ExamStudentDTO examStudent, @PathVariable Integer curPage,
|
|
|
+ @PathVariable Integer pageSize) {
|
|
|
+ cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
+ if (accessUser != null) {
|
|
|
+ if (accessUser.getRootOrgId().longValue() == accessUser.getOrgId().longValue()
|
|
|
+ || examStudent.getStudentId() != null) {
|
|
|
+ examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+ } else {
|
|
|
+ examStudent.setOrgId(accessUser.getOrgId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return new ResponseEntity(new ErrorMsg("无访问权限"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ return new ResponseEntity(
|
|
|
+ examStudentService.getAllExamStudent(examStudent,
|
|
|
+ new PageRequest(curPage, pageSize, new Sort(Direction.DESC, "id"))),
|
|
|
+ HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "查询重考考生", notes = "查询重考考生")
|
|
|
+ @PostMapping("/reexamineStudents/{curPage}/{pageSize}")
|
|
|
+ public ResponseEntity getReexamineStudents(
|
|
|
+ @RequestBody CommonExamStudent examStudentSpecification, @PathVariable Integer curPage,
|
|
|
+ @PathVariable Integer pageSize) {
|
|
|
+ try {
|
|
|
+ Page<ExamStudent> pageExamStudents = examStudentService
|
|
|
+ .getReexamineStudent(examStudentSpecification, curPage, pageSize);
|
|
|
+ if (pageExamStudents == null || pageExamStudents.getContent() == null
|
|
|
+ || pageExamStudents.getContent().size() == 0) {
|
|
|
+ return new ResponseEntity(new ErrorMsg("无数据"), HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity(pageExamStudents, HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("调用失败:", e);
|
|
|
+ return new ResponseEntity(new ErrorMsg("调用失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询所有考试学生带条件", notes = "带条件不分页")
|
|
|
+ @GetMapping("/all")
|
|
|
+ public ResponseEntity getAllExamStudent(HttpServletRequest request,
|
|
|
+ @ModelAttribute ExamStudentDTO examStudent) {
|
|
|
+ cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
+ if (accessUser != null) {
|
|
|
+ if (accessUser.getRootOrgId().longValue() == accessUser.getOrgId().longValue()
|
|
|
+ || examStudent.getStudentId() != null) {
|
|
|
+ examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+ } else {
|
|
|
+ examStudent.setOrgId(accessUser.getOrgId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ResponseEntity(examStudentService.getAllExamStudent(examStudent), HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询所有考试学生带条件", notes = "带条件按照限制查询")
|
|
|
+ @GetMapping("/limit/{examId}/{startLimit}/{endLimit}")
|
|
|
+ public ResponseEntity getExamStudentByLimit(@PathVariable("examId") Long examId,
|
|
|
+ @PathVariable("startLimit") Integer startLimit,
|
|
|
+ @PathVariable("endLimit") Integer endLimit) {
|
|
|
+ List<ExamStudent> examStudents = examStudentService.getExamStudentByLimit(examId,
|
|
|
+ startLimit, endLimit);
|
|
|
+ return new ResponseEntity(examStudents, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "按ID查询考试学生", notes = "ID查询")
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public ResponseEntity getExamStudentById(@PathVariable Long id) {
|
|
|
+ return new ResponseEntity(examStudentService.findById(id), HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增考试学生", notes = "新增")
|
|
|
+ @PostMapping()
|
|
|
+ public ExamStudent addExamStudent(HttpServletRequest request,
|
|
|
+ @RequestBody ExamStudent examStudent) {
|
|
|
+
|
|
|
+ cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
+ if (accessUser != null) {
|
|
|
+ examStudent.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+ }
|
|
|
+ Exam exam = examRepo.findOne(examStudent.getExam().getId());
|
|
|
+ examStudent.setExam(exam);
|
|
|
+ if (StringUtils.isEmpty(examStudent.getPaperType())) {
|
|
|
+ examStudent.setPaperType("O");
|
|
|
+ }
|
|
|
+ if (null == examStudent.getFinished()) {
|
|
|
+ examStudent.setFinished(false);
|
|
|
+ }
|
|
|
+ ExamStudent saveExamStu = examStudentService.saveExamStudent(accessUser.getUserToken(),
|
|
|
+ examStudent);
|
|
|
+ return saveExamStu;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "更新考试学生", notes = "更新")
|
|
|
+ @PutMapping()
|
|
|
+ public ExamStudent updateExamStudent(@RequestBody ExamStudent examStudent) {
|
|
|
+ cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
+
|
|
|
+ Exam exam = examRepo.findOne(examStudent.getExam().getId());
|
|
|
+ examStudent.setExam(exam);
|
|
|
+ if (StringUtils.isEmpty(examStudent.getPaperType())) {
|
|
|
+ examStudent.setPaperType("O");
|
|
|
+ }
|
|
|
+ ExamStudent saveExamStu = examStudentService.saveExamStudent(accessUser.getUserToken(),
|
|
|
+ examStudent);
|
|
|
+ return saveExamStu;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "更新考试学生缺考状态", notes = "更新缺考")
|
|
|
+ @PutMapping("/{id}")
|
|
|
+ public ResponseEntity<ExamStudent> getExamStudentById(@PathVariable Long id,
|
|
|
+ @RequestParam boolean finished) {
|
|
|
+ ExamStudent examStudent = examStudentRepo.findOne(id);
|
|
|
+ examStudent.setFinished(finished);
|
|
|
+ // 进入考试时,判断考试次数是否小于考试信息(ecs_exam)中的考试次数,如果是,考试次数加一
|
|
|
+ long examTimes = examStudent.getExam().getExamTimes();
|
|
|
+ if (examTimes > examStudent.getNormalExamTimes()) {
|
|
|
+ examStudent.setNormalExamTimes(examStudent.getNormalExamTimes() + 1);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<ExamStudent>(examStudentRepo.save(examStudent), HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "按ID删除考试学生", notes = "删除")
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ public ResponseEntity deleteExamStudent(@PathVariable String id) {
|
|
|
+ List<Long> examStuIds = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ try {
|
|
|
+ examStudentService.deleteExamStudent(examStuIds);
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除失败:", e);
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()),
|
|
|
+ HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "按考试删除考试学生", notes = "按考试删除")
|
|
|
+ @DeleteMapping("/exam/{examId}")
|
|
|
+ public ResponseEntity deleteExamStudents(@PathVariable Long examId) {
|
|
|
+ try {
|
|
|
+ examStudentService.deleteExamStudents(examId);
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除失败:", e);
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()),
|
|
|
+ HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "导入考试学生", notes = "导入")
|
|
|
+ @PostMapping("/import")
|
|
|
+ public ResponseEntity importExamStudent(@RequestParam Long examId,
|
|
|
+ @RequestParam CommonsMultipartFile file) {
|
|
|
+ cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
+ try {
|
|
|
+ File tempFile = ImportUtils.getUploadFile(file);
|
|
|
+ List<ExcelError> excelErrors = examStudentService.importExamStudent(
|
|
|
+ accessUser.getUserToken(), examId, new FileInputStream(tempFile));
|
|
|
+ return new ResponseEntity(excelErrors, HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("导入失败:", e);
|
|
|
+ return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "下载导入模板", notes = "下载导入模板")
|
|
|
+ @GetMapping("/download")
|
|
|
+ public void importFileTemplate(HttpServletResponse response) {
|
|
|
+ List<ExamStudentDTO> list = new ArrayList<ExamStudentDTO>();
|
|
|
+ ExportUtils.exportEXCEL("考生导入模板", ExamStudentDTO.class, list, response);
|
|
|
+ }
|
|
|
+
|
|
|
+ // @ApiOperation(value="导入学生照片",notes = "导入")
|
|
|
+ // @PostMapping("/exam_student/import_photo")
|
|
|
+ // public ResponseEntity importPhoto(@RequestParam Long examId,@RequestParam
|
|
|
+ // MultipartFile file){
|
|
|
+ // try {
|
|
|
+ // List<ErrorMsg> errorMsgs =
|
|
|
+ // examStudentService.importPhoto(examId,file.getInputStream());
|
|
|
+ // return new ResponseEntity(errorMsgs,HttpStatus.OK);
|
|
|
+ // } catch (IOException e) {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ @ApiOperation(value = "照片检验", notes = "检验")
|
|
|
+ @PostMapping("/photo_check")
|
|
|
+ public ResponseEntity photoCheck(@RequestParam Long examId) {
|
|
|
+ try {
|
|
|
+ List<ErrorMsg> errorMsgs = examStudentService.photoCheck(examId);
|
|
|
+ return new ResponseEntity(errorMsgs, HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "导出考试学生带条件", notes = "导出")
|
|
|
+ @GetMapping("/export")
|
|
|
+ public void exportExamStudent(@ModelAttribute ExamStudentDTO examCriteria,
|
|
|
+ HttpServletResponse response) {
|
|
|
+ List<ExamStudentDTO> list = new ArrayList<ExamStudentDTO>();
|
|
|
+ examStudentService.getAllExamStudent(examCriteria).forEach(c -> {
|
|
|
+ list.add(examStudentAssembler.toDTO(c));
|
|
|
+ });
|
|
|
+ ExportUtils.exportEXCEL("课程列表", ExamStudentDTO.class, list, response);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "复制考试学生", notes = "复制")
|
|
|
+ @PostMapping("/copy/{sourceExamId}/{targetExamId}")
|
|
|
+ public ResponseEntity copyExamStudent(@PathVariable Long sourceExamId,
|
|
|
+ @PathVariable Long targetExamId) {
|
|
|
+ try {
|
|
|
+ examStudentService.copyExamStudent(sourceExamId, targetExamId);
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("复制失败:", e);
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()),
|
|
|
+ HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "考生完成数量", notes = "考生完成数量")
|
|
|
+ @GetMapping("/count-by-finished")
|
|
|
+ public Map<String, Integer> countByFinished(@RequestParam Long examId) {
|
|
|
+
|
|
|
+ int finished = examStudentRepo.countByExamIdAndFinished(examId, true);
|
|
|
+ int unFinished = examStudentRepo.countByExamIdAndFinished(examId, false);
|
|
|
+ Map<String, Integer> result = new HashMap<>();
|
|
|
+ result.put("finished", finished);
|
|
|
+ result.put("unFinished", unFinished);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "按学习中心统计完成数量", notes = "按学习中心统计完成数量")
|
|
|
+ @GetMapping("/count-by-campus")
|
|
|
+ public List<Map<String, Object>> countByCampus(@RequestParam Long examId) {
|
|
|
+
|
|
|
+ List<Object[]> resultList = examStudentRepo.countByCampusAndFinished(examId);
|
|
|
+ List<Map<String, Object>> returnList = new ArrayList<>();
|
|
|
+ for (Object[] objects : resultList) {
|
|
|
+ Long orgId = ((BigInteger) objects[0]).longValue();
|
|
|
+ String orgName = (String) objects[1];
|
|
|
+ Boolean finished = (Boolean) objects[2];
|
|
|
+ Integer count = ((BigInteger) objects[3]).intValue();
|
|
|
+
|
|
|
+ boolean found = false;
|
|
|
+ for (Map<String, Object> m : returnList) {
|
|
|
+ if (m.get("orgId").equals(orgId)) {
|
|
|
+ found = true;
|
|
|
+
|
|
|
+ if (finished) {
|
|
|
+ m.put("finished", count);
|
|
|
+ } else {
|
|
|
+ m.put("unFinished", count);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!found) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ map.put("orgId", orgId);
|
|
|
+ map.put("orgName", orgName);
|
|
|
+ if (finished) {
|
|
|
+ map.put("finished", count);
|
|
|
+ } else {
|
|
|
+ map.put("unFinished", count);
|
|
|
+ }
|
|
|
+
|
|
|
+ returnList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return returnList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "学习中心考试进度信息", notes = "学习中心考试进度信息")
|
|
|
+ @GetMapping("/findOrgExamInfos")
|
|
|
+ public ResponseEntity<Object> findOrgExamInfos(String examId, String orgCode) {
|
|
|
+ try {
|
|
|
+ List<OrgExamInfoDTO> orgExamInfoDTOs = examStudentService.findOrgExamInfos(examId,
|
|
|
+ orgCode);
|
|
|
+ return new ResponseEntity<Object>(orgExamInfoDTOs, HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()),
|
|
|
+ HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "从考试表中查询课程", notes = "从考试表中查询课程")
|
|
|
+ @GetMapping("/findCoursesFromExamStudent")
|
|
|
+ public ResponseEntity<Object> findCoursesFromExamStudent(String examId, String orgId) {
|
|
|
+ try {
|
|
|
+ List<Course> courses = examStudentService.findCoursesFromExamStudent(examId, orgId);
|
|
|
+ return new ResponseEntity<Object>(courses, HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new ResponseEntity(new ErrorMsg(e.getMessage()),
|
|
|
+ HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "设置考生为重考状态", notes = "设置考生为重考状态")
|
|
|
+ @PostMapping("/setExamStudentReexamine")
|
|
|
+ public ResponseEntity<Object> setExamStudentIsReexamine(
|
|
|
+ @RequestBody CommonExamStudent commonExamStudent) {
|
|
|
+ if (commonExamStudent.getId() == null) {
|
|
|
+ return new ResponseEntity<Object>(new ErrorMsg("考生ID不能为空"),
|
|
|
+ HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ examStudentService.setExamStudentIsReexamine(commonExamStudent);
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.OK);
|
|
|
+ }
|
|
|
}
|