|
@@ -8,6 +8,7 @@ import org.hswebframework.web.service.schedule.ScheduleJobExecutor;
|
|
import org.hswebframework.web.service.schedule.ScheduleJobService;
|
|
import org.hswebframework.web.service.schedule.ScheduleJobService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -25,6 +26,7 @@ public class DefaultScriptScheduleJobExecutor implements ScheduleJobExecutor {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
public Object doExecuteJob(String jobId, Map<String, Object> parameter) {
|
|
public Object doExecuteJob(String jobId, Map<String, Object> parameter) {
|
|
try {
|
|
try {
|
|
ScheduleJobEntity jobEntity = scheduleJobService.selectByPk(jobId);
|
|
ScheduleJobEntity jobEntity = scheduleJobService.selectByPk(jobId);
|
|
@@ -35,7 +37,7 @@ public class DefaultScriptScheduleJobExecutor implements ScheduleJobExecutor {
|
|
|
|
|
|
String jobMd5 = DigestUtils.md5Hex(jobEntity.getScript());
|
|
String jobMd5 = DigestUtils.md5Hex(jobEntity.getScript());
|
|
//脚本发生变化,重新编译执行
|
|
//脚本发生变化,重新编译执行
|
|
- if (engine.getContext(jobId)==null||!jobMd5.equals(engine.getContext(jobId).getMd5())) {
|
|
|
|
|
|
+ if (engine.getContext(jobId) == null || !jobMd5.equals(engine.getContext(jobId).getMd5())) {
|
|
engine.compile(jobId, jobEntity.getScript());
|
|
engine.compile(jobId, jobEntity.getScript());
|
|
}
|
|
}
|
|
return engine.execute(jobId, parameter).getIfSuccess();
|
|
return engine.execute(jobId, parameter).getIfSuccess();
|