|
@@ -1,39 +1,41 @@
|
|
|
package cn.com.qmth.scancentral.controller.admin;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+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.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.qmth.boot.api.annotation.Aac;
|
|
|
+import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.boot.core.collection.PageResult;
|
|
|
+import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
+
|
|
|
import cn.com.qmth.scancentral.bean.ExamConfigDomain;
|
|
|
import cn.com.qmth.scancentral.bean.SubjectConfigDomain;
|
|
|
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.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.service.SubjectService;
|
|
|
-import cn.com.qmth.scancentral.task.thread.ExamDataSyncThread;
|
|
|
-import cn.com.qmth.scancentral.vo.*;
|
|
|
+import cn.com.qmth.scancentral.vo.ExamConfigVo;
|
|
|
+import cn.com.qmth.scancentral.vo.ExamUploadVo;
|
|
|
+import cn.com.qmth.scancentral.vo.ExamVo;
|
|
|
+import cn.com.qmth.scancentral.vo.SubjectConfigVo;
|
|
|
import cn.com.qmth.scancentral.vo.examinfo.ExamInfoVo;
|
|
|
import cn.com.qmth.scancentral.vo.examinfo.ExamQuery;
|
|
|
-import com.qmth.boot.api.annotation.Aac;
|
|
|
-import com.qmth.boot.api.constant.ApiConstant;
|
|
|
-import com.qmth.boot.core.collection.PageResult;
|
|
|
-import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
-import com.qmth.boot.core.exception.ReentrantException;
|
|
|
-import com.qmth.boot.mybatis.query.BaseQuery;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import net.sf.json.JSONObject;
|
|
|
-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.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@Api(tags = "考试接口")
|
|
@@ -91,21 +93,6 @@ public class ExamController extends BaseController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "未启用考试")
|
|
|
- @RequestMapping(value = "/remote/list", method = RequestMethod.POST)
|
|
|
- public PageResult<ExamRemoteVo> remote(BaseQuery<?> query) {
|
|
|
- User user = getAccessUser();
|
|
|
- return examService.listRemote(query, user);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "启用新考试")
|
|
|
- @RequestMapping(value = "/init", method = RequestMethod.POST)
|
|
|
- public ExamInitVo init(@Validated(ExamConfigDomain.ExamConfigInit.class) ExamConfigDomain domain) {
|
|
|
- User user = getAccessUser();
|
|
|
- ExamInitVo vo = examService.init(user, domain);
|
|
|
- return vo;
|
|
|
- }
|
|
|
-
|
|
|
@ApiOperation(value = "修改考试参数")
|
|
|
@RequestMapping(value = "/config", method = RequestMethod.POST)
|
|
|
public ExamConfigVo config(@Validated ExamConfigDomain domain) {
|
|
@@ -133,47 +120,6 @@ public class ExamController extends BaseController {
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "同步考务数据")
|
|
|
- @RequestMapping(value = "/data/sync", method = RequestMethod.POST)
|
|
|
- public JSONObject sync(@RequestParam Long examId) {
|
|
|
- User user = getAccessUser();
|
|
|
- ExamEntity exam = examService.getById(examId);
|
|
|
- if (exam == null) {
|
|
|
- throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
- }
|
|
|
- if (!exam.getSchoolId().equals(user.getSchoolId())) {
|
|
|
- throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
- }
|
|
|
- if (!concurrentService.isLocked(LockType.EXAM_SYNC + "-" + examId)) {
|
|
|
- taskExecutor.submit(new ExamDataSyncThread(getAccessUser(), examId, examService, concurrentService));
|
|
|
- } else {
|
|
|
- throw new ReentrantException("正在同步,请稍后再试");
|
|
|
- }
|
|
|
- JSONObject result = new JSONObject();
|
|
|
- result.put("synching", concurrentService.isLocked(LockType.EXAM_SYNC + "-" + examId));
|
|
|
- result.put("progress", examService.syncProgress(user, examId));
|
|
|
- result.put("updateTime", examService.getById(examId).getDataSyncTime());
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "考务数据同步状态")
|
|
|
- @RequestMapping(value = "/data/sync/status", method = RequestMethod.POST)
|
|
|
- public Map<String, Object> syncStatus(@RequestParam Long examId) {
|
|
|
- User user = getAccessUser();
|
|
|
- ExamEntity exam = examService.getById(examId);
|
|
|
- if (exam == null) {
|
|
|
- throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
- }
|
|
|
- if (!exam.getSchoolId().equals(user.getSchoolId())) {
|
|
|
- throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
- }
|
|
|
- Map<String, Object> result = new HashMap<String, Object>();
|
|
|
- result.put("synching", concurrentService.isLocked(LockType.EXAM_SYNC + "-" + examId));
|
|
|
- result.put("progress", examService.syncProgress(user, examId));
|
|
|
- result.put("updateTime", examService.getById(examId).getDataSyncTime());
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
@ApiOperation(value = "修改考试科目参数")
|
|
|
@RequestMapping(value = "/subject/config", method = RequestMethod.POST)
|
|
|
public SubjectConfigVo subjectConfig(@Validated SubjectConfigDomain domain) {
|