自动化立体仓库 - WCS系统
lty
2025-03-27 9540c4904147cb4baf037892447d6f85dc004646
src/main/java/com/zy/core/cache/MessageQueue.java
@@ -62,7 +62,6 @@
     * 如果发现队列已满无法添加的话,会直接返回false。
     */
    public static boolean offer(SlaveType type, Integer id, Task task) {
        CommandUtils.offer(type, id, task);
        switch (type) {
            case Crn:
                return CRN_EXCHANGE.get(id).offer(task);
@@ -151,5 +150,20 @@
                break;
        }
    }
    public static boolean offer(SlaveType type, Integer devpId, Task task, Runnable callback) {
        boolean result = offer(type, devpId, task); // 先执行原有任务逻辑
        if (result && callback != null) {
            new Thread(() -> {
                try {
                    Thread.sleep(200); // 模拟任务执行时间
                    callback.run();
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                }
            }).start();
        }
        return result;
    }
}