|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.themis.business.bean.exam.*;
|
|
@@ -1186,15 +1187,27 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
*/
|
|
|
@Override
|
|
|
public void calculateScore(Long examId, Long taskId) {
|
|
|
- int timeOutSecond = 60 * 5;
|
|
|
+ int timeOutSecond = 60 * 60 * 5;
|
|
|
String lockKey = SystemConstant.REDIS_LOCK_CALCULATE_SCORE_PREFIX + examId;
|
|
|
- Boolean lock = redisUtil.lock(lockKey, timeOutSecond);
|
|
|
- if (!lock) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ String multLockKey = SystemConstant.REDIS_LOCK_CALCULATE_SCORE_PAPER_IMPORT_PREFIX + examId;
|
|
|
+
|
|
|
TBTaskHistory task = null;
|
|
|
Long recordId = null;
|
|
|
try {
|
|
|
+ Boolean lock = redisUtil.lock(lockKey, timeOutSecond);
|
|
|
+ if (!lock) {
|
|
|
+ throw new BusinessException("该考试批次有正在进行的重新算分");
|
|
|
+ }
|
|
|
+
|
|
|
+ //重新算分和试卷导入互斥锁
|
|
|
+ Boolean multLock = redisUtil.lock(multLockKey, timeOutSecond);
|
|
|
+ if (!multLock) {
|
|
|
+ throw new BusinessException("该考试批次有正在进行的试卷导入");
|
|
|
+ }
|
|
|
+
|
|
|
+ TEExamService examService = SpringContextHolder.getBean(TEExamService.class);
|
|
|
+ teExamMapper.updateScoreStatus(ScoreStatusEnum.CALCULATING, examId);
|
|
|
+ examService.updateExamCacheBean(examId);
|
|
|
task = tbTaskHistoryService.getById(taskId);
|
|
|
task.setStatus(TaskStatusEnum.RUNNING);
|
|
|
tbTaskHistoryService.saveOrUpdate(task);
|
|
@@ -1214,12 +1227,13 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
recordId = rc.getId();
|
|
|
toeExamRecordService.calculateScore(rc.getId());
|
|
|
}
|
|
|
- redisUtil.expire(lockKey, timeOutSecond);
|
|
|
}
|
|
|
task.setProgress(getPercentage(index, total));
|
|
|
tbTaskHistoryService.saveOrUpdate(task);
|
|
|
}
|
|
|
}
|
|
|
+ teExamMapper.updateScoreStatus(ScoreStatusEnum.FINISH, examId);
|
|
|
+ examService.updateExamCacheBean(examId);
|
|
|
task.setSummary("处理成功");
|
|
|
task.setProgress(100.0);
|
|
|
task.setStatus(TaskStatusEnum.FINISH);
|
|
@@ -1229,8 +1243,15 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
task.setSummary("处理出错");
|
|
|
task.setStatus(TaskStatusEnum.FINISH);
|
|
|
task.setFinishTime(System.currentTimeMillis());
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ String reportFilePath="file/"+sdf.format(new Date()) + "/" + uuid() + SystemConstant.TXT_PREFIX;
|
|
|
+ json.put("path", reportFilePath);
|
|
|
+ json.put("type", SystemConstant.OSS);
|
|
|
+ OssUtil.ossUploadContent(systemConfig.getOssEnv(3), reportFilePath, e.getMessage());
|
|
|
+ task.setReportFilePath(json.toJSONString());
|
|
|
} finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
+ redisUtil.releaseLock(multLockKey);
|
|
|
}
|
|
|
tbTaskHistoryService.saveOrUpdate(task);
|
|
|
}
|
|
@@ -1257,4 +1278,10 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
public void updateInvigilateMonitorStatus(InvigilateMonitorStatusEnum monitorStatus, Long examId) {
|
|
|
teExamMapper.updateInvigilateMonitorStatus(monitorStatus, examId);
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void updateScoreStatus(ScoreStatusEnum scoreStatus, Long examId) {
|
|
|
+ teExamMapper.updateScoreStatus(scoreStatus, examId);
|
|
|
+ }
|
|
|
}
|