提交 11bca1fd authored 作者: ljj's avatar ljj

fix:优化启动速度

上级 df86e6a8
...@@ -15,10 +15,12 @@ import com.tykj.dev.device.task.repository.TaskDao; ...@@ -15,10 +15,12 @@ import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.subject.domin.Task; import com.tykj.dev.device.task.subject.domin.Task;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.*; import java.util.*;
import java.util.concurrent.Executor;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -42,7 +44,10 @@ public class ConfirmCheckTask implements CommandLineRunner { ...@@ -42,7 +44,10 @@ public class ConfirmCheckTask implements CommandLineRunner {
public Map<Integer, List<DeviceInLibVo>> hisInLib = new HashMap<>();; public Map<Integer, List<DeviceInLibVo>> hisInLib = new HashMap<>();;
public Map<Integer, List<DeviceNotInLibVo>> hisNotInLib = new HashMap<>();; public Map<Integer, List<DeviceNotInLibVo>> hisNotInLib = new HashMap<>();
@Autowired
@Qualifier("taskExecutor")
private Executor executor;
@Override @Override
public void run(String... args) { public void run(String... args) {
...@@ -56,9 +61,9 @@ public class ConfirmCheckTask implements CommandLineRunner { ...@@ -56,9 +61,9 @@ public class ConfirmCheckTask implements CommandLineRunner {
List<Task> tasks = taskDao.findAllByBusinessTypeAndBillStatusNotIn(8, Arrays.asList(140, 160)); List<Task> tasks = taskDao.findAllByBusinessTypeAndBillStatusNotIn(8, Arrays.asList(140, 160));
for (Task task : tasks) {
extracted(task.getBillId()); for (Task task : tasks) {
executor.execute(() -> extracted(task.getBillId()));
} }
log.info("[check] 加载账单快照用时:{}ms", System.currentTimeMillis() - startTime); log.info("[check] 加载账单快照用时:{}ms", System.currentTimeMillis() - startTime);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论