|
@@ -2,11 +2,19 @@ package cn.com.qmth.task.service.job;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
|
|
|
+import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.DateFormat;
|
|
|
+import cn.com.qmth.examcloud.core.oe.api.CleanExamRecordService;
|
|
|
import cn.com.qmth.task.base.AbstractTask;
|
|
|
import cn.com.qmth.task.base.ScheduleJob;
|
|
|
+import cn.com.qmth.task.base.enums.JobStatus;
|
|
|
+import cn.com.qmth.task.entity.ScheduleJobEntity;
|
|
|
+import cn.com.qmth.task.service.ScheduleJobEntityService;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -17,11 +25,30 @@ import cn.com.qmth.task.base.ScheduleJob;
|
|
|
*/
|
|
|
@Component("oeCleanExamRecordTask")
|
|
|
public class OeCleanExamRecordTask extends AbstractTask{
|
|
|
-
|
|
|
+
|
|
|
+ private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog("EXAMCLOUD_TASK");
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("cleanExamRecordClient")
|
|
|
+ private CleanExamRecordService cleanExamRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ScheduleJobEntityService scheduleJobEntityService;
|
|
|
+
|
|
|
@Override
|
|
|
- public void run(ScheduleJob scheduleJob)
|
|
|
- throws Exception {
|
|
|
- String now = DateFormat.dateFormat(new Date());
|
|
|
- System.out.println(now+"oeCleanExamRecordTask Run");
|
|
|
+ public void run(ScheduleJob scheduleJob){
|
|
|
+ LOG.info(DateFormat.dateFormat(new Date())+"oeCleanExamRecordTask Run");
|
|
|
+ ScheduleJobEntity scheduleJobEntity = scheduleJobEntityService.findByJobName(scheduleJob.getJobName());
|
|
|
+ try{
|
|
|
+ cleanExamRecordService.cleanExamExpiredExamRecord();
|
|
|
+ scheduleJobEntity.setOperateResult("execute success");
|
|
|
+ scheduleJobEntity.setJobStatus(JobStatus.RUNNING.name());
|
|
|
+ scheduleJobEntityService.saveScheduleJobEntity(scheduleJobEntity);
|
|
|
+ }catch(Exception e){
|
|
|
+ scheduleJobEntity.setOperateResult("execute failed");
|
|
|
+ scheduleJobEntityService.saveScheduleJobEntity(scheduleJobEntity);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|