TaskInitRunner.java
1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.viontech.fanxing.task.runner;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.model.TaskExample;
import com.viontech.fanxing.task.mapper.TaskMapper;
import com.viontech.fanxing.task.model.TaskData;
import com.viontech.fanxing.task.service.TaskDataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/9/2
*/
@Component
@Slf4j
public class TaskInitRunner implements CommandLineRunner {
@Resource
private TaskMapper taskMapper;
@Resource
private TaskDataService taskDataService;
@Override
public void run(String... args) throws Exception {
log.info("===================任务初始化开始===================");
List<Task> tasks = taskMapper.selectByExampleWithBLOBs(new TaskExample());
for (Task task : tasks) {
if (StringUtils.isNotBlank(task.getScene()) && task.getStoreConfigId() != null) {
try {
TaskData taskData = taskDataService.getRepository().getTaskDataByUnid(task.getUnid());
if (taskData == null) {
taskDataService.addTask(task);
}
} catch (Exception e) {
log.info("初始化任务失败,任务unid:{},失败信息:{}", task.getUnid(), e.getMessage());
}
}
}
log.info("===================任务初始化结束===================");
}
}