|
@@ -31,81 +31,70 @@ public class CreateTaskThread implements InitializingBean {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void afterPropertiesSet() throws Exception {
|
|
public void afterPropertiesSet() throws Exception {
|
|
-// //初始化任务队列
|
|
|
|
-// //查找任务状态为0(队列中)和1(进行中)的任务
|
|
|
|
-// List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getStatus, new ArrayList<>(Arrays.asList(0, 1))));
|
|
|
|
-// if (tasks.size() > 0) {
|
|
|
|
-// //过滤出任务ids
|
|
|
|
-// List<Integer> taskIds = tasks.stream().map(Task::getId).collect(Collectors.toList());
|
|
|
|
-// //过滤出进行中的任务的id
|
|
|
|
-// List<Task> doingTasks = tasks.stream().filter(item -> item.getStatus() == 1).collect(Collectors.toList());
|
|
|
|
-// List<Integer> doingTaskIds = doingTasks.stream().map(Task::getId).collect(Collectors.toList());
|
|
|
|
-// if (doingTaskIds.size() > 0) {
|
|
|
|
-// //先将进行中的任务(项目重启后进行中的任务仅会有1个)的id先存入任务队列,再将其余存入
|
|
|
|
-// pantentQueueService.queueAddTask(Arrays.asList(doingTaskIds.get(0)));
|
|
|
|
-// taskIds.removeAll(doingTaskIds);
|
|
|
|
-// }
|
|
|
|
-// pantentQueueService.queueAddTask(taskIds);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// //生产者线程
|
|
|
|
-// Thread threadProducer = new Thread(pantentQueueService::addPatnetToQueue);
|
|
|
|
-// threadProducer.start();
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// //消费者1线程(摘要附图)
|
|
|
|
-// Thread threadConsumer1 = new Thread(() -> {
|
|
|
|
-// try {
|
|
|
|
-// pantentQueueService.pushPatentImageToDB();
|
|
|
|
-// } catch (InterruptedException | IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
-// threadConsumer1.start();
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// //消费者2线程(著录项目)
|
|
|
|
-// Thread threadConsumer2 = new Thread(() -> {
|
|
|
|
-// try {
|
|
|
|
-// pantentQueueService.pushPatentZhuLuToDB();
|
|
|
|
-// } catch (InterruptedException | IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
-// threadConsumer2.start();
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// //消费者3线程(权利要求)
|
|
|
|
-// Thread threadConsumer3 = new Thread(() -> {
|
|
|
|
-// try {
|
|
|
|
-// pantentQueueService.pushPatentRightToDB();
|
|
|
|
-// } catch (InterruptedException | IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
-// threadConsumer3.start();
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// //消费者4线程(说明书文本消费者)
|
|
|
|
-// Thread threadConsumer4 = new Thread(() -> {
|
|
|
|
-// try {
|
|
|
|
-// pantentQueueService.pushPatentInstructionTextToDB();
|
|
|
|
-// } catch (InterruptedException | IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
-// threadConsumer4.start();
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// //消费者5线程(与专利关联数据消费者)
|
|
|
|
-// Thread threadConsumer5 = new Thread(() -> {
|
|
|
|
-// try {
|
|
|
|
-// pantentQueueService.pushPatentAssoToDB();
|
|
|
|
-// } catch (InterruptedException | IOException e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
-// threadConsumer5.start();
|
|
|
|
|
|
+ //初始化任务队列
|
|
|
|
+ //查找任务状态为0(队列中)和1(进行中)的任务
|
|
|
|
+ List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getStatus, new ArrayList<>(Arrays.asList(0, 1))));
|
|
|
|
+ if (tasks.size() > 0) {
|
|
|
|
+ //过滤出任务ids
|
|
|
|
+ List<Integer> taskIds = tasks.stream().map(Task::getId).collect(Collectors.toList());
|
|
|
|
+ //过滤出进行中的任务的id
|
|
|
|
+ List<Task> doingTasks = tasks.stream().filter(item -> item.getStatus() == 1).collect(Collectors.toList());
|
|
|
|
+ List<Integer> doingTaskIds = doingTasks.stream().map(Task::getId).collect(Collectors.toList());
|
|
|
|
+ if (doingTaskIds.size() > 0) {
|
|
|
|
+ //先将进行中的任务(项目重启后进行中的任务仅会有1个)的id先存入任务队列,再将其余存入
|
|
|
|
+ pantentQueueService.taskQueueAddTask(Arrays.asList(doingTaskIds.get(0)));
|
|
|
|
+ taskIds.removeAll(doingTaskIds);
|
|
|
|
+ }
|
|
|
|
+ pantentQueueService.taskQueueAddTask(taskIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //生产者线程
|
|
|
|
+ Thread threadProducer = new Thread(pantentQueueService::addPatnetToQueue);
|
|
|
|
+ threadProducer.start();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //消费者1线程(摘要附图)
|
|
|
|
+ Thread threadConsumer1 = new Thread(() -> {
|
|
|
|
+ try {
|
|
|
|
+ pantentQueueService.pushPatentImageToDB();
|
|
|
|
+ } catch (InterruptedException | IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ threadConsumer1.start();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //消费者2线程(著录项目)
|
|
|
|
+ Thread threadConsumer2 = new Thread(() -> {
|
|
|
|
+ try {
|
|
|
|
+ pantentQueueService.pushPatentZhuLuToDB();
|
|
|
|
+ } catch (InterruptedException | IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ threadConsumer2.start();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //消费者3线程(权利要求)
|
|
|
|
+ Thread threadConsumer3 = new Thread(() -> {
|
|
|
|
+ try {
|
|
|
|
+ pantentQueueService.pushPatentRightToDB();
|
|
|
|
+ } catch (InterruptedException | IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ threadConsumer3.start();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //消费者4线程(说明书文本消费者)
|
|
|
|
+ Thread threadConsumer4 = new Thread(() -> {
|
|
|
|
+ try {
|
|
|
|
+ pantentQueueService.pushPatentInstructionTextToDB();
|
|
|
|
+ } catch (InterruptedException | IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ threadConsumer4.start();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|