1
zhang
2026-04-17 471faf9943b3c2f29ccf2dc8e27ac09b8b97423c
1
3个文件已修改
26 ■■■■ 已修改文件
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/operation/ConveyorBackgroundService.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/operation/ConveyorOperationExecutor.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/service/Snap7Service.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/operation/ConveyorBackgroundService.java
@@ -49,18 +49,18 @@
        });
        // 启动定时任务
        executorService.scheduleAtFixedRate(this::processConveyorTasks,
        executorService.scheduleWithFixedDelay(this::processConveyorTasks,
                properties.getInitialDelay(),
                properties.getInterval(),
                TimeUnit.MILLISECONDS);
        running.set(true);
        log.info("输送线后台服务线程初始化完成");
        News.info("输送线后台服务线程初始化完成");
    }
    private void processConveyorTasks() {
        // 系统运行状态判断
        if (!SystemProperties.WCS_RUNNING_STATUS.get() || !running.get()) {
            log.debug("系统未运行或服务已停止,跳过输送线任务处理");
            News.info("系统未运行或服务已停止,跳过输送线任务处理");
            return;
        }
        long currentTime = System.currentTimeMillis();
@@ -74,7 +74,7 @@
                operationExecutor.execute(config);
            }
        } catch (Exception e) {
            log.error("输送线任务处理异常", e);
            News.error("输送线任务处理异常,{}", e.getMessage());
        }
    }
@@ -82,7 +82,7 @@
    public void shutDown() {
        running.set(false);
        if (executorService != null && !executorService.isShutdown()) {
            log.info("正在关闭输送线后台服务线程...");
            News.info("正在关闭输送线后台服务线程...");
            executorService.shutdown();
            try {
                if (!executorService.awaitTermination(5, TimeUnit.SECONDS)) {
@@ -92,7 +92,7 @@
                executorService.shutdownNow();
                Thread.currentThread().interrupt();
            }
            log.info("输送线后台服务线程已关闭");
            News.info("输送线后台服务线程已关闭");
        }
    }
}
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/operation/ConveyorOperationExecutor.java
@@ -1,5 +1,6 @@
package com.zy.acs.conveyor.core.operation;
import com.zy.acs.common.utils.News;
import com.zy.acs.conveyor.core.enums.ConveyorStateType;
import com.zy.acs.conveyor.core.properties.CtuOperationConfig;
import lombok.extern.slf4j.Slf4j;
@@ -21,14 +22,14 @@
        // 自动注册所有操作处理器
        for (OperationHandler handler : handlers) {
            handlerMap.put(handler.getType(), handler);
            log.info("注册输送线操作处理器: {}", handler.getType());
            News.info("注册输送线操作处理器: {}", handler.getType());
        }
    }
    public void execute(CtuOperationConfig config) {
        OperationHandler handler = handlerMap.get(config.getType());
        if (handler == null) {
            log.warn("未找到操作处理器: {}", config.getType());
            News.warn("未找到操作处理器: {}", config.getType());
            return;
        }
@@ -40,15 +41,15 @@
            } catch (Exception e) {
                retryCount++;
                if (retryCount >= config.getMaxRetries()) {
                    log.error("操作执行失败,已达到最大重试次数: {}", config.getType(), e);
                    News.error("操作执行失败,已达到最大重试次数: {}", config.getType(), e);
                } else {
                    log.warn("操作执行失败,正在重试({}/{})",
                    News.warn("操作执行失败,正在重试({}/{})",
                            retryCount, config.getMaxRetries(), e);
                    try {
                        Thread.sleep(config.getRetryDelay());
                    } catch (InterruptedException ie) {
                        Thread.currentThread().interrupt();
                        log.error("重试休眠被中断", ie);
                        News.error("重试休眠被中断", ie);
                        return;
                    }
                }
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/service/Snap7Service.java
@@ -36,9 +36,6 @@
    private static final int WRITE_RETRY_INTERVAL_MS = 200;
    public void read(StaProtocol staProtocol, SiemensS7Net siemensS7Net) {
    }
    public void writeSafe(StaProtocol staProtocol) throws InterruptedException {
        if (staProtocol == null) {