|
@@ -31,96 +31,58 @@ public class CreateTaskThread implements InitializingBean {
|
|
|
|
|
|
@Override
|
|
|
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.taskQueueAddTask(Arrays.asList(doingTaskIds.get(0)));
|
|
|
-// taskIds.removeAll(doingTaskIds);
|
|
|
-// }
|
|
|
-// pantentQueueService.taskQueueAddTask(taskIds);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //生产者线程
|
|
|
-// Thread threadProducer = new Thread(pantentQueueService::addPatnetToQueue);
|
|
|
-// threadProducer.start();
|
|
|
-//
|
|
|
-// //装载专利著录线程
|
|
|
-// Thread threadSetPatentZhuLu = new Thread(pantentQueueService::setPatentZhuLu);
|
|
|
-// threadSetPatentZhuLu.start();
|
|
|
-// //装载权要线程
|
|
|
-// Thread threadSetPatentClaim = new Thread(pantentQueueService::setPatentRight);
|
|
|
-// threadSetPatentClaim.start();
|
|
|
-// //装载说明书文本线程
|
|
|
-// Thread threadSetPatentInstructionText = new Thread(pantentQueueService::setPatentInstructionText);
|
|
|
-// threadSetPatentInstructionText.start();
|
|
|
-// //装载说明书pdf线程
|
|
|
-// Thread threadSetPatentInstructionPDF = new Thread(pantentQueueService::setPatentInstructionPDF);
|
|
|
-// threadSetPatentInstructionPDF.start();
|
|
|
-// //装载摘要附图线程
|
|
|
-// Thread threadSetPatentPicture = new Thread(pantentQueueService::setPatentImage);
|
|
|
-// threadSetPatentPicture.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线程(说明书pdf消费者)
|
|
|
-// Thread threadConsumer5 = new Thread(() -> {
|
|
|
-// try {
|
|
|
-// pantentQueueService.pushPatentInstructionPDFToDB();
|
|
|
-// } 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();
|
|
|
+
|
|
|
+ //装载专利著录线程
|
|
|
+ Thread threadSetPatentZhuLu = new Thread(pantentQueueService::setPatentZhuLu);
|
|
|
+ threadSetPatentZhuLu.start();
|
|
|
+ //装载权要线程
|
|
|
+ Thread threadSetPatentClaim = new Thread(pantentQueueService::setPatentRight);
|
|
|
+ threadSetPatentClaim.start();
|
|
|
+ //装载说明书文本线程
|
|
|
+ Thread threadSetPatentInstructionText = new Thread(pantentQueueService::setPatentInstructionText);
|
|
|
+ threadSetPatentInstructionText.start();
|
|
|
+ //装载说明书pdf线程
|
|
|
+ Thread threadSetPatentInstructionPDF = new Thread(pantentQueueService::setPatentInstructionPDF);
|
|
|
+ threadSetPatentInstructionPDF.start();
|
|
|
+ //装载摘要附图线程
|
|
|
+ Thread threadSetPatentPicture = new Thread(pantentQueueService::setPatentImage);
|
|
|
+ threadSetPatentPicture.start();
|
|
|
+
|
|
|
+ //消费者1线程(摘要附图)
|
|
|
+ Thread threadConsumer1 = new Thread(pantentQueueService::pushPatentImageToDB);
|
|
|
+ threadConsumer1.start();
|
|
|
+ //消费者2线程(著录项目)
|
|
|
+ Thread threadConsumer2 = new Thread(pantentQueueService::pushPatentZhuLuToDB);
|
|
|
+ threadConsumer2.start();
|
|
|
+ //消费者3线程(权利要求)
|
|
|
+ Thread threadConsumer3 = new Thread(pantentQueueService::pushPatentRightToDB);
|
|
|
+ threadConsumer3.start();
|
|
|
+ //消费者4线程(说明书文本消费者)
|
|
|
+ Thread threadConsumer4 = new Thread(pantentQueueService::pushPatentInstructionTextToDB);
|
|
|
+ threadConsumer4.start();
|
|
|
+ //消费者5线程(说明书pdf消费者)
|
|
|
+ Thread threadConsumer5 = new Thread(pantentQueueService::pushPatentInstructionPDFToDB);
|
|
|
+ threadConsumer5.start();
|
|
|
|
|
|
}
|
|
|
|