|
@@ -1,11 +1,14 @@
|
|
|
package com.qmth.teachcloud.task.job;
|
|
|
|
|
|
+import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.mark.enums.LockType;
|
|
|
import com.qmth.teachcloud.task.job.service.JobService;
|
|
|
import org.quartz.DisallowConcurrentExecution;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -13,19 +16,29 @@ import javax.annotation.Resource;
|
|
|
/**
|
|
|
* 生成评卷任务
|
|
|
*/
|
|
|
-@DisallowConcurrentExecution//串行执行
|
|
|
+//@DisallowConcurrentExecution//串行执行
|
|
|
public class BuildMarkTaskJob extends QuartzJobBean {
|
|
|
private final static Logger log = LoggerFactory.getLogger(BuildMarkTaskJob.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ConcurrentService concurrentService;
|
|
|
+
|
|
|
@Resource
|
|
|
JobService jobService;
|
|
|
|
|
|
@Override
|
|
|
protected void executeInternal(JobExecutionContext jobExecutionContext) {
|
|
|
- try {
|
|
|
- jobService.updateBuildMarkTask();
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(SystemConstant.LOG_ERROR, e);
|
|
|
+ if (concurrentService.getReadWriteLock(LockType.BUILD_MARK_TASK.name()).writeLock().tryLock()) {
|
|
|
+ try {
|
|
|
+ jobService.updateBuildMarkTask();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("build-mark-task error");
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ concurrentService.getReadWriteLock(LockType.BUILD_MARK_TASK.name()).writeLock().unlock();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.info("build-mark-task is running");
|
|
|
}
|
|
|
}
|
|
|
}
|