cpT
2025-06-19 c1ef2d1fc4c0dae2bc8452924dcd77a0ff3a1ef5
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -51,6 +51,7 @@
        add(1016);add(1017);add(1018);add(1019);add(1020);add(1021);add(1022);add(1023);
    }};
    private boolean connectDev = false;
    public Long currentTimeMilliConnectDev= 0L;
    /**
@@ -84,6 +85,12 @@
    @Override
    @SuppressWarnings("InfiniteLoopStatement")
    public void run() {
        initSite();
        try{
            Thread.sleep(2000);
        } catch (Exception e){
        }
        connectDev = connect();
        while(!connectDev){
            try {
@@ -172,8 +179,22 @@
        } else {
            OutputQueue.DEVP.offer(MessageFormat.format( "【{0}】输送线plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            log.error("输送线plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
//            DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
//            deviceErrorService.addDeviceError("devp", slave.getId(), "输送线plc连接失败");
            if (System.currentTimeMillis()-currentTimeMilliConnectDev>1000*60*10){
                try{
                    DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
                    deviceErrorService.addDeviceError("devp", slave.getId(), "输送线plc连接失败");
                } catch (Exception e2){
//                log.error("e2:"+e2.getMessage());
                }
                if (currentTimeMilliConnectDev == 0){
                    currentTimeMilliConnectDev = System.currentTimeMillis()-1000*60*10-1;
                } else {
                    currentTimeMilliConnectDev = System.currentTimeMillis();
                }
            }
            initSite();
        }
        siemensS7Net.ConnectClose();
@@ -185,6 +206,14 @@
    private void writeStatusDev() {
        while (true) {
            try {
                if(!connectDev){
                    try {
                        Thread.sleep(1000L);
                    } catch (Exception e){
                    }
                    continue;
                }
                int step = 1;
                Task task = MessageQueue.poll(SlaveType.Devp, slave.getId());
                if (task != null) {
@@ -214,12 +243,22 @@
    private void readStatusDev() {
        while (true) {
            try {
                if(!connectDev){
                    try {
                        Thread.sleep(1000L);
                    } catch (Exception e){
                    }
                    initSite();
                    continue;
                }
                Thread.sleep(50);
//                System.out.println("读线程"+ slave.getId());
                read();
            } catch (Exception e) {
                connectDev = false;
                log.error("RGV数据读取线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
                try{
                    DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);