|
@@ -1,29 +1,6 @@
|
|
|
package cn.com.qmth.stmms.api.controller;
|
|
|
|
|
|
-import java.text.DecimalFormat;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
-import net.sf.json.JSONArray;
|
|
|
-import net.sf.json.JSONObject;
|
|
|
-
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
-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.utils.AESUtil;
|
|
|
-import cn.com.qmth.stmms.api.utils.MenualAbsentDTO;
|
|
|
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;
|
|
@@ -38,14 +15,24 @@ import cn.com.qmth.stmms.biz.mark.service.MarkLibraryService;
|
|
|
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.ScoreItem;
|
|
|
-import cn.com.qmth.stmms.common.annotation.Logging;
|
|
|
import cn.com.qmth.stmms.common.annotation.RoleRequire;
|
|
|
import cn.com.qmth.stmms.common.domain.ApiUser;
|
|
|
-import cn.com.qmth.stmms.common.enums.LogType;
|
|
|
import cn.com.qmth.stmms.common.enums.Role;
|
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
|
-
|
|
|
import com.google.common.base.Strings;
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+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;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Controller("examStudentApiController")
|
|
|
@RequestMapping("/api")
|
|
@@ -71,115 +58,14 @@ public class ExamStudentController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
|
- @Logging(menu = "扫描端-上传人工指定缺考", type = LogType.UPDATE)
|
|
|
- @RoleRequire({ Role.SCHOOL_ADMIN })
|
|
|
- @RequestMapping(value = "/student/manualAbsent/{examId}", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
- public Object updateManualAbsent(HttpServletRequest request, @PathVariable Integer examId,
|
|
|
- @RequestBody MenualAbsentDTO[] datas) {
|
|
|
- ApiUser user = RequestUtils.getApiUser(request);
|
|
|
- Exam exam = examService.findById(examId);
|
|
|
- if (exam != null && exam.getSchoolId().equals(user.getSchoolId())) {
|
|
|
- for (MenualAbsentDTO dto : datas) {
|
|
|
- studentService.updateManualAbsent(examId, dto.getExamNumber(), dto.isAbsent());
|
|
|
- }
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Logging(menu = "扫描端-清除人工指定缺考", type = LogType.UPDATE)
|
|
|
- @RoleRequire({ Role.SCHOOL_ADMIN })
|
|
|
- @RequestMapping(value = "/student/manualAbsent/clear", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
- public Object clearManualAbsent(HttpServletRequest request, @RequestParam Integer examId) {
|
|
|
- ApiUser user = RequestUtils.getApiUser(request);
|
|
|
- Exam exam = examService.findById(examId);
|
|
|
- if (exam != null && exam.getSchoolId().equals(user.getSchoolId())) {
|
|
|
- studentService.clearManualAbsent(examId);
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER })
|
|
|
- @RequestMapping(value = "/exam/students/{examId}", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public JSONArray getExamStudents(HttpServletRequest request, @PathVariable Integer examId) {
|
|
|
- JSONArray array = new JSONArray();
|
|
|
- List<ExamStudent> esList = new LinkedList<ExamStudent>();
|
|
|
- Exam exam = examService.findById(examId);
|
|
|
- if (exam != null) {
|
|
|
- esList = studentService.findByExamId(examId);
|
|
|
- }
|
|
|
- for (ExamStudent student : esList) {
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.accumulate("examNumber", student.getExamNumber());
|
|
|
- obj.accumulate("campusName", student.getCampusName());
|
|
|
- obj.accumulate("subjectCode", student.getSubjectCode());
|
|
|
- obj.accumulate("subjectName", student.getSubjectName());
|
|
|
- obj.accumulate("name", student.getName());
|
|
|
- obj.accumulate("studentId", String.valueOf(student.getId()));
|
|
|
- obj.accumulate("barcode", student.getExamNumber());
|
|
|
-
|
|
|
- Campus campus = campusService.findBySchoolAndName(exam.getSchoolId(), student.getCampusName());
|
|
|
- obj.accumulate("campusCode", campus != null ? campus.getId().toString() : "");
|
|
|
- array.add(obj);
|
|
|
- }
|
|
|
- return array;
|
|
|
- }
|
|
|
-
|
|
|
- @RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER })
|
|
|
- @RequestMapping(value = "/students/{examId}", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public JSONArray getStudent(HttpServletRequest request, @PathVariable Integer examId,
|
|
|
- @RequestParam(required = false) Boolean upload, @RequestParam(required = false) Boolean absent,
|
|
|
- @RequestParam(required = false) Integer pageNumber, @RequestParam(required = false) Integer pageSize) {
|
|
|
- JSONArray array = new JSONArray();
|
|
|
- Exam exam = examService.findById(examId);
|
|
|
- if (exam == null) {
|
|
|
- return array;
|
|
|
- }
|
|
|
-
|
|
|
- ExamStudentSearchQuery query = new ExamStudentSearchQuery();
|
|
|
- query.setExamId(examId);
|
|
|
- query.setUpload(upload);
|
|
|
- query.setAbsent(absent);
|
|
|
- if (pageNumber != null && pageSize != null) {
|
|
|
- query.setPageNumber(pageNumber);
|
|
|
- query.setPageSize(pageSize);
|
|
|
- } else {
|
|
|
- query.setPageNumber(1);
|
|
|
- query.setPageSize(Integer.MAX_VALUE);
|
|
|
- }
|
|
|
- studentService.findByQuery(query);
|
|
|
- for (ExamStudent student : query.getResult()) {
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.accumulate("id", student.getId());
|
|
|
- obj.accumulate("examNumber", student.getExamNumber());
|
|
|
- obj.accumulate("campusName", student.getCampusName());
|
|
|
- obj.accumulate("subjectCode", student.getSubjectCode());
|
|
|
- obj.accumulate("subjectName", student.getSubjectName());
|
|
|
- obj.accumulate("name", student.getName());
|
|
|
- obj.accumulate("studentCode", student.getStudentCode());
|
|
|
-
|
|
|
- Campus campus = campusService.findBySchoolAndName(exam.getSchoolId(), student.getCampusName());
|
|
|
- obj.accumulate("campusCode", campus != null ? campus.getId().toString() : "");
|
|
|
- array.add(obj);
|
|
|
- }
|
|
|
- return array;
|
|
|
- }
|
|
|
-
|
|
|
@RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER })
|
|
|
@RequestMapping(value = "/student/check", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public JSONObject checkStudent(HttpServletRequest request, @RequestBody ExamStudent examStudent) {
|
|
|
JSONObject obj = new JSONObject();
|
|
|
Exam exam = examService.findById(examStudent.getExamId());
|
|
|
- ExamStudent student = studentService.findByExamIdAndExamNumber(examStudent.getExamId(),
|
|
|
- examStudent.getExamNumber());
|
|
|
+ ExamStudent student = studentService
|
|
|
+ .findByExamIdAndExamNumber(examStudent.getExamId(), examStudent.getExamNumber());
|
|
|
if (student != null) {
|
|
|
obj.accumulate("examId", examStudent.getExamId());
|
|
|
obj.accumulate("campusName", student.getCampusName());
|
|
@@ -247,7 +133,8 @@ public class ExamStudentController extends BaseApiController {
|
|
|
obj.accumulate("name", student.getName());
|
|
|
obj.accumulate("studentCode", student.getStudentCode());
|
|
|
obj.accumulate("packageCode", student.getPackageCode());
|
|
|
- obj.accumulate("batchCode", student.getBatchCode() == null ? "" : student.getBatchCode());
|
|
|
+ obj.accumulate("paperType", StringUtils.trimToEmpty(student.getPaperType()));
|
|
|
+ obj.accumulate("batchCode", StringUtils.trimToEmpty(student.getBatchCode()));
|
|
|
obj.accumulate("sheetCount", student.getSheetCount() != null ? student.getSheetCount() : 0);
|
|
|
obj.accumulate("sliceCount", student.getSliceCount() != null ? student.getSliceCount() : 0);
|
|
|
obj.accumulate("answers", StringUtils.trimToEmpty(student.getAnswers()));
|
|
@@ -270,8 +157,9 @@ public class ExamStudentController extends BaseApiController {
|
|
|
// 构造客观题得分明细
|
|
|
JSONArray objective = new JSONArray();
|
|
|
List<ScoreItem> scoreList = student.getScoreList(true);
|
|
|
- List<ExamQuestion> questionList = questionService.findByExamAndSubjectAndObjectiveAndPaperType(
|
|
|
- student.getExamId(), student.getSubjectCode(), true, student.getPaperType());
|
|
|
+ List<ExamQuestion> questionList = questionService
|
|
|
+ .findByExamAndSubjectAndObjectiveAndPaperType(student.getExamId(),
|
|
|
+ student.getSubjectCode(), true, student.getPaperType());
|
|
|
int i = 0;
|
|
|
for (ScoreItem item : scoreList) {
|
|
|
i++;
|
|
@@ -294,8 +182,8 @@ public class ExamStudentController extends BaseApiController {
|
|
|
// 构造主观题得分明细
|
|
|
JSONArray subjective = new JSONArray();
|
|
|
scoreList = student.getScoreList(false);
|
|
|
- questionList = questionService.findByExamAndSubjectAndObjective(student.getExamId(),
|
|
|
- student.getSubjectCode(), false);
|
|
|
+ questionList = questionService
|
|
|
+ .findByExamAndSubjectAndObjective(student.getExamId(), student.getSubjectCode(), false);
|
|
|
i = 0;
|
|
|
for (ScoreItem item : scoreList) {
|
|
|
i++;
|
|
@@ -359,59 +247,6 @@ public class ExamStudentController extends BaseApiController {
|
|
|
return StringUtils.join(headerNames, ",");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param s
|
|
|
- * 需要转换的字符串
|
|
|
- * @param convert
|
|
|
- * 是否正向转换
|
|
|
- * @return
|
|
|
- */
|
|
|
- @SuppressWarnings("unused")
|
|
|
- private String convert(String s, String[] diploma, String[] bachelorDegree, boolean convert) {
|
|
|
- if (diploma == null || bachelorDegree == null) {
|
|
|
- return s;
|
|
|
- }
|
|
|
-
|
|
|
- char[] ss = s.toCharArray();
|
|
|
- String[] str = new String[ss.length];
|
|
|
- for (int i = 0; i < str.length; i++) {
|
|
|
- str[i] = String.valueOf(ss[i]);
|
|
|
- }
|
|
|
-
|
|
|
- if (convert) {
|
|
|
- if (str[Integer.parseInt(diploma[2]) - 1].equals(diploma[1])) {
|
|
|
- str[Integer.parseInt(diploma[2]) - 1] = diploma[0];
|
|
|
- }
|
|
|
- if (str[Integer.parseInt(diploma[3]) - 1].equals(diploma[1])) {
|
|
|
- str[Integer.parseInt(diploma[3]) - 1] = diploma[0];
|
|
|
- }
|
|
|
- if (str[Integer.parseInt(bachelorDegree[2]) - 1].equals(bachelorDegree[1])) {
|
|
|
- str[Integer.parseInt(bachelorDegree[2]) - 1] = bachelorDegree[0];
|
|
|
- }
|
|
|
- if (str[Integer.parseInt(bachelorDegree[3]) - 1].equals(bachelorDegree[1])) {
|
|
|
- str[Integer.parseInt(bachelorDegree[3]) - 1] = bachelorDegree[0];
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (str[Integer.parseInt(diploma[2]) - 1].equals(diploma[0])) {
|
|
|
- str[Integer.parseInt(diploma[2]) - 1] = diploma[1];
|
|
|
- }
|
|
|
- if (str[Integer.parseInt(diploma[3]) - 1].equals(diploma[0])) {
|
|
|
- str[Integer.parseInt(diploma[3]) - 1] = diploma[1];
|
|
|
- }
|
|
|
- if (str[Integer.parseInt(bachelorDegree[2]) - 1].equals(bachelorDegree[0])) {
|
|
|
- str[Integer.parseInt(bachelorDegree[2]) - 1] = bachelorDegree[1];
|
|
|
- }
|
|
|
- if (str[Integer.parseInt(bachelorDegree[3]) - 1].equals(bachelorDegree[0])) {
|
|
|
- str[Integer.parseInt(bachelorDegree[3]) - 1] = bachelorDegree[1];
|
|
|
- }
|
|
|
- }
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- for (String i : str) {
|
|
|
- sb.append(i);
|
|
|
- }
|
|
|
- return sb.toString();
|
|
|
- }
|
|
|
-
|
|
|
@RequestMapping(value = "/score/school/{schoolId}", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String getScore(@PathVariable Integer schoolId, @RequestParam String studentCode,
|
|
@@ -423,8 +258,9 @@ public class ExamStudentController extends BaseApiController {
|
|
|
if (Strings.isNullOrEmpty(examSeqCode)) {
|
|
|
student = studentService.findBySchoolIdAndSubjectCodeAndStudentCode(schoolId, subjectCode, studentCode);
|
|
|
} else {
|
|
|
- student = studentService.findBySchoolIdAndSubjectCodeAndStudentCodeAndRemark(schoolId, subjectCode,
|
|
|
- studentCode, examSeqCode);
|
|
|
+ student = studentService
|
|
|
+ .findBySchoolIdAndSubjectCodeAndStudentCodeAndRemark(schoolId, subjectCode, studentCode,
|
|
|
+ examSeqCode);
|
|
|
}
|
|
|
if (student != null) {
|
|
|
DecimalFormat df = new DecimalFormat("####.###");
|