|
@@ -0,0 +1,174 @@
|
|
|
+package cn.com.qmth.scancentral.controller.admin;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.task.AsyncTaskExecutor;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import com.qmth.boot.api.annotation.Aac;
|
|
|
+import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
+import com.qmth.boot.core.exception.ReentrantException;
|
|
|
+import com.qmth.boot.tools.excel.ExcelWriter;
|
|
|
+import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
|
+import com.qmth.boot.tools.iterator.PageListIterator;
|
|
|
+
|
|
|
+import cn.com.qmth.scancentral.bean.AssignedQueryDomain;
|
|
|
+import cn.com.qmth.scancentral.bean.User;
|
|
|
+import cn.com.qmth.scancentral.controller.BaseController;
|
|
|
+import cn.com.qmth.scancentral.entity.ExamEntity;
|
|
|
+import cn.com.qmth.scancentral.enums.GroupType;
|
|
|
+import cn.com.qmth.scancentral.enums.LockType;
|
|
|
+import cn.com.qmth.scancentral.exception.ParameterExceptions;
|
|
|
+import cn.com.qmth.scancentral.service.ExamService;
|
|
|
+import cn.com.qmth.scancentral.service.StudentService;
|
|
|
+import cn.com.qmth.scancentral.task.thread.CheckAssignedResetThread;
|
|
|
+import cn.com.qmth.scancentral.vo.answerquery.AnswerQueryVo;
|
|
|
+import cn.com.qmth.scancentral.vo.assginedcheck.AssginedTaskResult;
|
|
|
+import cn.com.qmth.scancentral.vo.assginedcheck.AssignedCheckExamRoomExport;
|
|
|
+import cn.com.qmth.scancentral.vo.assginedcheck.AssignedCheckExport;
|
|
|
+import cn.com.qmth.scancentral.vo.assginedcheck.AssignedTaskSaveVo;
|
|
|
+import cn.com.qmth.scancentral.vo.task.TaskStatusVo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@Api(tags = "人工绑定校验接口")
|
|
|
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/check/assigned")
|
|
|
+@Aac(strict = false, auth = true)
|
|
|
+public class CheckAssignedController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StudentService studentService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ConcurrentService concurrentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamService examService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AsyncTaskExecutor taskExecutor;
|
|
|
+
|
|
|
+// @ApiOperation(value = "列表")
|
|
|
+// @RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
|
+// public PageResult<AnswerQueryVo> list(@Validated AssignedQueryDomain query) {
|
|
|
+// if (query.getAssignedCheckCount() == null || query.getAssignedCheckCount() <= 1) {
|
|
|
+// query.setAssignedCheckCount(1);
|
|
|
+// }
|
|
|
+// query.setAssigned(true);
|
|
|
+// return studentService.queryAssignedCheckPage(query);
|
|
|
+// }
|
|
|
+
|
|
|
+ @ApiOperation(value = "导出")
|
|
|
+ @RequestMapping(value = "/export", method = RequestMethod.POST)
|
|
|
+ public void export(@RequestParam Long examId, @RequestParam String subjectCode, @RequestParam GroupType type, HttpServletResponse response) throws IOException {
|
|
|
+ String fileName = URLEncoder.encode("复核校验", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "inline; filename=" + fileName + ".xlsx");
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
|
|
|
+ if(GroupType.STUDENT_CODE.equals(type)){
|
|
|
+ AssignedQueryDomain query1 = new AssignedQueryDomain();
|
|
|
+ query1.setExamId(examId);
|
|
|
+ query1.setSubjectCode(subjectCode);
|
|
|
+ query1.setAssigned(true);
|
|
|
+ query1.setAssignedSuspect(true);
|
|
|
+ PageListIterator<AssignedCheckExport> iterator = new PageListIterator<AssignedCheckExport>(100) {
|
|
|
+ @Override
|
|
|
+ public Collection<AssignedCheckExport> getPageList(int pageNumber, int pageSize) {
|
|
|
+ query1.setPageNumber(pageNumber);
|
|
|
+ query1.setPageSize(pageSize);
|
|
|
+ return studentService.exportAssignedCheckPage(query1);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ writer.writeObjects("复核校验", null, AssignedCheckExport.class, iterator);
|
|
|
+
|
|
|
+ }else if(GroupType.EXAM_ROOM.equals(type)){
|
|
|
+ List<AssignedCheckExamRoomExport> list = studentService.exportAssignedCheck(examId,subjectCode);
|
|
|
+ writer.writeObjects("复核校验", null, AssignedCheckExamRoomExport.class, list.iterator());
|
|
|
+ }
|
|
|
+ writer.output(response.getOutputStream());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "审核员任务获取")
|
|
|
+ @RequestMapping(value = "task/get", method = RequestMethod.POST)
|
|
|
+ public AnswerQueryVo get(@RequestParam Long examId) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ return studentService.getAssignedCheckTask(examId, user.getAccount());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "审核员任务历史")
|
|
|
+ @RequestMapping(value = "task/history", method = RequestMethod.POST)
|
|
|
+ public List<AnswerQueryVo> history(@RequestParam Long id, @RequestParam Long pageSize) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ return studentService.getAssignedCheckTaskHistory(id, pageSize, user);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "审核员任务提交")
|
|
|
+ @RequestMapping(value = "task/save", method = RequestMethod.POST)
|
|
|
+ public AssignedTaskSaveVo submit(@Validated @RequestBody AssginedTaskResult result) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ return studentService.submitAssignedCheckTask(result, user);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "答题卡扫描图片检查任务状态")
|
|
|
+ @PostMapping("task/status")
|
|
|
+ public TaskStatusVo status(@RequestParam Long examId) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ return studentService.getAssignedCheckTaskStatus(examId, user);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "审核员任务释放")
|
|
|
+ @PostMapping("task/release")
|
|
|
+ public Object release(@RequestParam Long examId) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ studentService.releaseAssignedCheckTaskByUser(examId, user.getAccount());
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "重新生成")
|
|
|
+ @RequestMapping(value = "/reset", method = RequestMethod.POST)
|
|
|
+ public JSONObject reset(@RequestParam Long examId, @RequestParam String subjectCode) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ ExamEntity exam = examService.getById(examId);
|
|
|
+ if (exam == null) {
|
|
|
+ throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!concurrentService.isLocked(LockType.CHECK_ASSIGNED_RESET + "-" + examId)) {
|
|
|
+ taskExecutor.submit(new CheckAssignedResetThread(examId, subjectCode,
|
|
|
+ studentService, concurrentService));
|
|
|
+ } else {
|
|
|
+ throw new ReentrantException("正在重置,请稍后再试");
|
|
|
+ }
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("updateTime", System.currentTimeMillis());
|
|
|
+ result.put("synching", true);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "重新生成状态")
|
|
|
+ @RequestMapping(value = "/reset/status", method = RequestMethod.POST)
|
|
|
+ public Map<String, Object> resetStatus(@RequestParam Long examId, @RequestParam String subjectCode) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ ExamEntity exam = examService.getById(examId);
|
|
|
+ if (exam == null) {
|
|
|
+ throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
+ }
|
|
|
+ Map<String, Object> result = new HashMap<String, Object>();
|
|
|
+ result.put("synching",
|
|
|
+ concurrentService.isLocked(LockType.CHECK_ASSIGNED_RESET + "-" + examId));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|