|
@@ -36,31 +36,31 @@ public class PantentQueueService {
|
|
|
private final FileUtils fileUtils;
|
|
|
private final MessageService messageService;
|
|
|
private final TaskService taskService;
|
|
|
- private Queue<QueueData> patentImageQueue = new LinkedList<>();
|
|
|
- private Queue<QueueData> patentZhuluQueue = new LinkedList<>();
|
|
|
- private Queue<QueueData> patentRightQueue = new LinkedList<>();
|
|
|
- private Queue<QueueData> patentInstructionTextQueue = new LinkedList<>();
|
|
|
- private Queue<QueueData> patentAssoQueue = new LinkedList<>();
|
|
|
- private List<Integer> taskQueueList = new ArrayList<>();
|
|
|
+ private final Queue<QueueData> patentImageQueue = new LinkedList<>();
|
|
|
+ private final Queue<QueueData> patentZhuluQueue = new LinkedList<>();
|
|
|
+ private final Queue<QueueData> patentRightQueue = new LinkedList<>();
|
|
|
+ private final Queue<QueueData> patentInstructionTextQueue = new LinkedList<>();
|
|
|
+ private final Queue<QueueData> patentAssoQueue = new LinkedList<>();
|
|
|
+ private final List<Integer> taskQueueList = new ArrayList<>();
|
|
|
private Boolean flag = false;
|
|
|
- private Lock taskLock = new ReentrantLock();
|
|
|
- private Lock patentImageLock = new ReentrantLock();
|
|
|
- private Lock patentZhuluLock = new ReentrantLock();
|
|
|
- private Lock patentRightLock = new ReentrantLock();
|
|
|
- private Lock patentInstructionTextLock = new ReentrantLock();
|
|
|
- private Lock patentAssoLock = new ReentrantLock();
|
|
|
- Condition taskCondition = taskLock.newCondition();
|
|
|
- private Condition patentImageCondition = patentImageLock.newCondition();
|
|
|
- private Condition patentZhuluCondition = patentZhuluLock.newCondition();
|
|
|
- private Condition patentRightCondition = patentRightLock.newCondition();
|
|
|
- private Condition patentInstructionTextCondition = patentInstructionTextLock.newCondition();
|
|
|
- private Condition patentAssoCondition = patentAssoLock.newCondition();
|
|
|
- private HashMap<Integer, Integer> patentIdMap = new HashMap<>();
|
|
|
+ private final Lock taskLock = new ReentrantLock();
|
|
|
+ private final Lock patentImageLock = new ReentrantLock();
|
|
|
+ private final Lock patentZhuluLock = new ReentrantLock();
|
|
|
+ private final Lock patentRightLock = new ReentrantLock();
|
|
|
+ private final Lock patentInstructionTextLock = new ReentrantLock();
|
|
|
+ private final Lock patentAssoLock = new ReentrantLock();
|
|
|
+ private final Condition taskCondition = taskLock.newCondition();
|
|
|
+ private final Condition patentImageCondition = patentImageLock.newCondition();
|
|
|
+ private final Condition patentZhuluCondition = patentZhuluLock.newCondition();
|
|
|
+ private final Condition patentRightCondition = patentRightLock.newCondition();
|
|
|
+ private final Condition patentInstructionTextCondition = patentInstructionTextLock.newCondition();
|
|
|
+ private final Condition patentAssoCondition = patentAssoLock.newCondition();
|
|
|
+ private final HashMap<Integer, Integer> patentIdMap = new HashMap<>();
|
|
|
private Task task = null;
|
|
|
private Integer patentFinishNum = 0;
|
|
|
|
|
|
/**
|
|
|
- * 生产者:从任务队列取出任务解析成专利实体类,分配给三个消费者队列
|
|
|
+ * 生产者:从任务队列取出任务解析专利,将专利分配给消费者消费
|
|
|
*/
|
|
|
public void addPatnetToQueue() {
|
|
|
try {
|
|
@@ -168,6 +168,7 @@ public class PantentQueueService {
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -316,9 +317,7 @@ public class PantentQueueService {
|
|
|
percentage = 100L;
|
|
|
//任务表更新状态为成功
|
|
|
task.setStatus(2);
|
|
|
- task.setEndTime(DateUtils.getDateTime());
|
|
|
taskService.updateById(task);
|
|
|
- System.out.println("结束时间:" + new Date());
|
|
|
}
|
|
|
messageService.sendWebsocketMessage(task, total, patentFinishNum, percentage);
|
|
|
//任务表更新数据
|