|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.qmth.stmms.admin.exam;
|
|
|
|
|
|
+import cn.com.qmth.stmms.admin.thread.MarkerResetThread;
|
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
|
import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
|
|
@@ -27,6 +28,8 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.core.task.AsyncTaskExecutor;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -78,6 +81,10 @@ public class MarkerController extends BaseExamController {
|
|
|
@Autowired
|
|
|
private MarkLibraryService libraryService;
|
|
|
|
|
|
+ @Qualifier("task-executor")
|
|
|
+ @Autowired
|
|
|
+ private AsyncTaskExecutor taskExecutor;
|
|
|
+
|
|
|
@Logging(menu = "评卷员查询", type = LogType.QUERY)
|
|
|
@RequestMapping
|
|
|
public String list(Model model, HttpServletRequest request, MarkerSearchQuery query) {
|
|
@@ -101,6 +108,7 @@ public class MarkerController extends BaseExamController {
|
|
|
marker.setMarkedCount(markService.markedCount(marker));
|
|
|
marker.setCurrentCount(markService.applyCount(marker));
|
|
|
marker.setUser(userService.findById(marker.getUserId()));
|
|
|
+ marker.setReseting(lockService.isLocked(LockType.MARKER_RESET, marker.getId()));
|
|
|
}
|
|
|
model.addAttribute("query", query);
|
|
|
model.addAttribute("subjectList", getExamSubject(examId, wu));
|
|
@@ -198,24 +206,32 @@ public class MarkerController extends BaseExamController {
|
|
|
Marker marker = markerService.findById(id);
|
|
|
JSONObject obj = new JSONObject();
|
|
|
if (marker != null) {
|
|
|
- try {
|
|
|
- lockService.waitlock(LockType.EXAM_SUBJECT, marker.getExamId(), marker.getSubjectCode());
|
|
|
- lockService
|
|
|
- .waitlock(LockType.GROUP, marker.getExamId(), marker.getSubjectCode(), marker.getGroupNumber());
|
|
|
- lockService.waitlock(LockType.MARKER, marker.getId());
|
|
|
-
|
|
|
- markService.resetMarker(marker);
|
|
|
+ if (lockService.trylock(LockType.MARKER_RESET, marker.getId())) {
|
|
|
+ taskExecutor.submit(new MarkerResetThread(marker, markService, lockService));
|
|
|
obj.accumulate("success", true);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("reset marker error", e);
|
|
|
+ } else {
|
|
|
obj.accumulate("success", false);
|
|
|
- obj.accumulate("message", "重置评卷员失败");
|
|
|
- } finally {
|
|
|
- lockService.unlock(LockType.MARKER, marker.getId());
|
|
|
- lockService
|
|
|
- .unlock(LockType.GROUP, marker.getExamId(), marker.getSubjectCode(), marker.getGroupNumber());
|
|
|
- lockService.unlock(LockType.EXAM_SUBJECT, marker.getExamId(), marker.getSubjectCode());
|
|
|
+ obj.accumulate("message", "评卷员正在重置");
|
|
|
}
|
|
|
+
|
|
|
+ // try {
|
|
|
+ // lockService.waitlock(LockType.EXAM_SUBJECT, marker.getExamId(), marker.getSubjectCode());
|
|
|
+ // lockService
|
|
|
+ // .waitlock(LockType.GROUP, marker.getExamId(), marker.getSubjectCode(), marker.getGroupNumber());
|
|
|
+ // lockService.waitlock(LockType.MARKER, marker.getId());
|
|
|
+ //
|
|
|
+ // markService.resetMarker(marker);
|
|
|
+ // obj.accumulate("success", true);
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // log.error("reset marker error", e);
|
|
|
+ // obj.accumulate("success", false);
|
|
|
+ // obj.accumulate("message", "重置评卷员失败");
|
|
|
+ // } finally {
|
|
|
+ // lockService.unlock(LockType.MARKER, marker.getId());
|
|
|
+ // lockService
|
|
|
+ // .unlock(LockType.GROUP, marker.getExamId(), marker.getSubjectCode(), marker.getGroupNumber());
|
|
|
+ // lockService.unlock(LockType.EXAM_SUBJECT, marker.getExamId(), marker.getSubjectCode());
|
|
|
+ // }
|
|
|
} else {
|
|
|
obj.accumulate("success", false);
|
|
|
obj.accumulate("message", "该评卷员不存在");
|