|
@@ -16,6 +16,8 @@ import cn.com.qmth.stmms.ms.marking.config.MarkingConfig;
|
|
import cn.com.qmth.stmms.ms.marking.service.MarkingService;
|
|
import cn.com.qmth.stmms.ms.marking.service.MarkingService;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.InitializingBean;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -31,7 +33,8 @@ import java.util.*;
|
|
* @Date: 2020/1/16
|
|
* @Date: 2020/1/16
|
|
*/
|
|
*/
|
|
@Component
|
|
@Component
|
|
-public class ScheduledTask {
|
|
|
|
|
|
+@Async
|
|
|
|
+public class ScheduledTask implements InitializingBean {
|
|
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ScheduledTask.class);
|
|
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ScheduledTask.class);
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
@@ -65,11 +68,9 @@ public class ScheduledTask {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修复密号重复 30秒一次
|
|
* 修复密号重复 30秒一次
|
|
- *
|
|
|
|
- * @throws Exception
|
|
|
|
*/
|
|
*/
|
|
@Scheduled(cron = "0/30 * * * * ?")
|
|
@Scheduled(cron = "0/30 * * * * ?")
|
|
- public void repairRepeatSecretNumberTask() throws Exception {
|
|
|
|
|
|
+ public void repairRepeatSecretNumberTask() {
|
|
if (Objects.nonNull(randomUtil.getRandomMap()) && randomUtil.getRandomMap().size() > 0) {
|
|
if (Objects.nonNull(randomUtil.getRandomMap()) && randomUtil.getRandomMap().size() > 0) {
|
|
Work work = workRepo.findByActiveTrue();
|
|
Work work = workRepo.findByActiveTrue();
|
|
if (Objects.nonNull(work)) {
|
|
if (Objects.nonNull(work)) {
|
|
@@ -144,12 +145,11 @@ public class ScheduledTask {
|
|
* 修复试卷密号
|
|
* 修复试卷密号
|
|
*
|
|
*
|
|
* @param workId
|
|
* @param workId
|
|
- * @throws Exception
|
|
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
- public void repairRepeatPaper(Long workId) throws Exception {
|
|
|
|
|
|
+ public void repairRepeatPaper(Long workId) {
|
|
try {
|
|
try {
|
|
- String sql = "select * from (select p.random_seq, count(p.random_seq) as seq from paper p where p.work_id = ? group by p.random_seq) temp where temp.seq > 1";
|
|
|
|
|
|
+ String sql = "select * from (select p.random_seq, count(p.random_seq) as seq from paper p where p.work_id = ? group by p.random_seq) temp where temp.seq > 1 LIMIT 500";
|
|
List list = sqlUtil.execSqlForMapNative(sql, workId);
|
|
List list = sqlUtil.execSqlForMapNative(sql, workId);
|
|
Set papers = new HashSet();
|
|
Set papers = new HashSet();
|
|
if (Objects.nonNull(list) && list.size() > 0) {
|
|
if (Objects.nonNull(list) && list.size() > 0) {
|
|
@@ -184,12 +184,11 @@ public class ScheduledTask {
|
|
* 修复任务密号
|
|
* 修复任务密号
|
|
*
|
|
*
|
|
* @param workId
|
|
* @param workId
|
|
- * @throws Exception
|
|
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
- public void repairRepeatTask(Long workId) throws Exception {
|
|
|
|
|
|
+ public void repairRepeatTask(Long workId) {
|
|
try {
|
|
try {
|
|
- String sql = "select * from (select mt.random_seq_new, count(mt.random_seq_new) as seq from mark_task mt where mt.work_id = ? group by mt.random_seq_new) temp where temp.seq > 1";
|
|
|
|
|
|
+ String sql = "select * from (select mt.random_seq_new, count(mt.random_seq_new) as seq from mark_task mt where mt.work_id = ? group by mt.random_seq_new) temp where temp.seq > 1 LIMIT 500";
|
|
List list = sqlUtil.execSqlForMapNative(sql, workId);
|
|
List list = sqlUtil.execSqlForMapNative(sql, workId);
|
|
Set tasks = new HashSet();
|
|
Set tasks = new HashSet();
|
|
if (Objects.nonNull(list) && list.size() > 0) {
|
|
if (Objects.nonNull(list) && list.size() > 0) {
|
|
@@ -226,9 +225,8 @@ public class ScheduledTask {
|
|
* @param workId
|
|
* @param workId
|
|
* @param examNumber
|
|
* @param examNumber
|
|
* @return
|
|
* @return
|
|
- * @throws Exception
|
|
|
|
*/
|
|
*/
|
|
- private Long getRandomPaper(Long workId, String examNumber) throws Exception {
|
|
|
|
|
|
+ private Long getRandomPaper(Long workId, String examNumber) {
|
|
int count = 0, result = 0;
|
|
int count = 0, result = 0;
|
|
Long random = 0L;
|
|
Long random = 0L;
|
|
while (true) {
|
|
while (true) {
|
|
@@ -255,9 +253,8 @@ public class ScheduledTask {
|
|
* @param workId
|
|
* @param workId
|
|
* @param examNumber
|
|
* @param examNumber
|
|
* @return
|
|
* @return
|
|
- * @throws Exception
|
|
|
|
*/
|
|
*/
|
|
- private Long getRandomTask(Long markerId, Long paperId, Long workId, String examNumber) throws Exception {
|
|
|
|
|
|
+ private Long getRandomTask(Long markerId, Long paperId, Long workId, String examNumber) {
|
|
int count = 0, result = 0;
|
|
int count = 0, result = 0;
|
|
Long random = 0L;
|
|
Long random = 0L;
|
|
while (true) {
|
|
while (true) {
|
|
@@ -275,4 +272,10 @@ public class ScheduledTask {
|
|
}
|
|
}
|
|
return random;
|
|
return random;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void afterPropertiesSet() {
|
|
|
|
+ this.repairRepeatSecretNumberTask();
|
|
|
|
+ this.markTaskJob();
|
|
|
|
+ }
|
|
}
|
|
}
|