|
@@ -1,5 +1,23 @@
|
|
package cn.com.qmth.stmms.api.controller;
|
|
package cn.com.qmth.stmms.api.controller;
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+
|
|
|
|
+import net.sf.json.JSONArray;
|
|
|
|
+import net.sf.json.JSONObject;
|
|
|
|
+
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+
|
|
import cn.com.qmth.stmms.api.exception.ApiException;
|
|
import cn.com.qmth.stmms.api.exception.ApiException;
|
|
import cn.com.qmth.stmms.api.utils.ScanStudentParameter;
|
|
import cn.com.qmth.stmms.api.utils.ScanStudentParameter;
|
|
import cn.com.qmth.stmms.biz.exam.model.CheckStudent;
|
|
import cn.com.qmth.stmms.biz.exam.model.CheckStudent;
|
|
@@ -8,22 +26,17 @@ import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
import cn.com.qmth.stmms.biz.exam.service.CheckStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.CheckStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
|
|
+import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
import cn.com.qmth.stmms.common.annotation.Logging;
|
|
import cn.com.qmth.stmms.common.annotation.Logging;
|
|
import cn.com.qmth.stmms.common.annotation.RoleRequire;
|
|
import cn.com.qmth.stmms.common.annotation.RoleRequire;
|
|
import cn.com.qmth.stmms.common.domain.ApiUser;
|
|
import cn.com.qmth.stmms.common.domain.ApiUser;
|
|
-import cn.com.qmth.stmms.common.enums.*;
|
|
|
|
|
|
+import cn.com.qmth.stmms.common.enums.CheckType;
|
|
|
|
+import cn.com.qmth.stmms.common.enums.ExamStatus;
|
|
|
|
+import cn.com.qmth.stmms.common.enums.ExamType;
|
|
|
|
+import cn.com.qmth.stmms.common.enums.LogType;
|
|
|
|
+import cn.com.qmth.stmms.common.enums.Role;
|
|
import cn.com.qmth.stmms.common.utils.DateUtils;
|
|
import cn.com.qmth.stmms.common.utils.DateUtils;
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
-import net.sf.json.JSONArray;
|
|
|
|
-import net.sf.json.JSONObject;
|
|
|
|
-
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
-
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
@Controller
|
|
@Controller
|
|
@RequestMapping("/api/scan")
|
|
@RequestMapping("/api/scan")
|
|
@@ -40,6 +53,9 @@ public class ScanController extends BaseApiController {
|
|
@Autowired
|
|
@Autowired
|
|
private CheckStudentService checkStudentService;
|
|
private CheckStudentService checkStudentService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private FileService fileService;
|
|
|
|
+
|
|
private static final String PAPER_TYPES_REGEX = "[a-zA-Z#]";
|
|
private static final String PAPER_TYPES_REGEX = "[a-zA-Z#]";
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -51,7 +67,7 @@ public class ScanController extends BaseApiController {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Logging(menu = "扫描端-考生识别上传", type = LogType.UPDATE)
|
|
@Logging(menu = "扫描端-考生识别上传", type = LogType.UPDATE)
|
|
- @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER })
|
|
|
|
|
|
+ @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER, Role.SCAN_ADMIN })
|
|
@RequestMapping(value = "/student/{examId}", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/student/{examId}", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public JSONArray saveStudent(HttpServletRequest request, @PathVariable Integer examId,
|
|
public JSONArray saveStudent(HttpServletRequest request, @PathVariable Integer examId,
|
|
@@ -100,4 +116,37 @@ public class ScanController extends BaseApiController {
|
|
return array;
|
|
return array;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Logging(menu = "扫描端-考生识别上传取消", type = LogType.UPDATE)
|
|
|
|
+ @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER, Role.SCAN_ADMIN })
|
|
|
|
+ @RequestMapping(value = "/student/delete", method = RequestMethod.POST)
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JSONObject deleteStudent(HttpServletRequest request, @RequestParam Integer examId,
|
|
|
|
+ @RequestParam String examNumber) {
|
|
|
|
+ ApiUser user = RequestUtils.getApiUser(request);
|
|
|
|
+ Exam exam = examService.findById(examId);
|
|
|
|
+ // 判断上传权限
|
|
|
|
+ if (exam == null || !exam.getSchoolId().equals(user.getSchoolId())
|
|
|
|
+ || !ExamStatus.START.equals(exam.getStatus()) || !ExamType.SCAN_IMAGE.equals(exam.getType())) {
|
|
|
|
+ throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
|
|
+ }
|
|
|
|
+ examNumber = validate("examNumber", examNumber, true, 32);
|
|
|
|
+ ExamStudent student = studentService.findByExamIdAndExamNumber(examId, examNumber);
|
|
|
|
+ if (student == null) {
|
|
|
|
+ throw ApiException.QUERY_PARAM_ERROR.replaceMessage("examNumber invalid");
|
|
|
|
+ }
|
|
|
|
+ student.setUpload(false);
|
|
|
|
+ student.setAbsent(false);
|
|
|
|
+ student.setAnswers(null);
|
|
|
|
+ student.setBatchCode(null);
|
|
|
|
+ student.setSliceCount(0);
|
|
|
|
+ student.setSheetCount(0);
|
|
|
|
+ student.setPaperType(null);
|
|
|
|
+ student.setCardNumber(null);
|
|
|
|
+ student.setUploadTime(new Date());
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
|
+ if (saveUploadStudent(student)) {
|
|
|
|
+ obj.accumulate("updateTime", DateUtils.formatDateTime(student.getUploadTime()));
|
|
|
|
+ }
|
|
|
|
+ return obj;
|
|
|
|
+ }
|
|
}
|
|
}
|