#
Junjie
2025-04-23 e2cbfe96c6dea03c15bbb8ea8c7af320242a5d19
src/main/java/com/zy/core/thread/impl/LfdZyForkLiftSlaveThread.java
@@ -30,10 +30,7 @@
import lombok.extern.slf4j.Slf4j;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.*;
@Slf4j
@SuppressWarnings("all")
@@ -90,7 +87,7 @@
                }
                read();
                Thread.sleep(200);
                Thread.sleep(300);
                execute();
            } catch (Exception e) {
                e.printStackTrace();
@@ -135,10 +132,6 @@
        try {
            //获取提升机数据
            OperateResultExOne<byte[]> result1 = this.masterThread.read(this.slave.getId(), "status");
            if (result1 == null) {
                OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】{1}读取货叉提升机状态信息失败", DateUtils.convert(new Date()), slave.getId()));
            }
            SiemensS7Net siemensS7Net = this.masterThread.getSiemensS7Net();
            if (result1.IsSuccess) {
                if (null == forkLiftProtocol) {
@@ -175,7 +168,7 @@
                OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】{1}读取货叉提升机状态信息失败", DateUtils.convert(new Date()), slave.getId()));
            }
            OperateResultExOne<byte[]> result2 = this.masterThread.read(this.slave.getId(), "staStatus");
            OperateResultExOne<byte[]> result2 = this.masterThread.read(this.slave.getId(), "staStatusTray");
            if (result2.IsSuccess) {
                for (int i = 0; i < this.slave.getSta().size(); i++) {
                    ForkLiftSlave.Sta sta = this.slave.getSta().get(i);
@@ -183,10 +176,23 @@
                        continue;
                    }
                    short val = siemensS7Net.getByteTransform().TransInt16(result2.Content, i * 2);
                    ForkLiftStaProtocol forkLiftStaProtocol = forkLiftStaProtocols.get(i);
                    boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result2.Content, i * 2, 2);
                    forkLiftStaProtocol.setHasTray(status1[0]);
                    forkLiftStaProtocol.setHasCar(status1[1]);
                    forkLiftStaProtocol.setHasTray(val == 1);
                }
            }
            OperateResultExOne<byte[]> result3 = this.masterThread.read(this.slave.getId(), "staStatusCar");
            if (result3.IsSuccess) {
                for (int i = 0; i < this.slave.getSta().size(); i++) {
                    ForkLiftSlave.Sta sta = this.slave.getSta().get(i);
                    if (forkLiftStaProtocols.isEmpty()) {
                        continue;
                    }
                    short val = siemensS7Net.getByteTransform().TransInt16(result3.Content, i * 2);
                    ForkLiftStaProtocol forkLiftStaProtocol = forkLiftStaProtocols.get(i);
                    forkLiftStaProtocol.setHasCar(val == 1);
                }
            }
@@ -202,6 +208,15 @@
                deviceDataLog.setCreateTime(new Date());
                deviceDataLogService.insert(deviceDataLog);
                //保存数据记录
                DeviceDataLog deviceDataLog2 = new DeviceDataLog();
                deviceDataLog2.setOriginData(Base64.getEncoder().encodeToString(result2.Content));
                deviceDataLog2.setWcsData(JSON.toJSONString(forkLiftStaProtocols));
                deviceDataLog2.setType("forkLiftStaProtocols");
                deviceDataLog2.setDeviceNo(forkLiftProtocol.getLiftNo());
                deviceDataLog2.setCreateTime(new Date());
                deviceDataLogService.insert(deviceDataLog2);
                //更新采集时间
                forkLiftProtocol.setDeviceDataLog(System.currentTimeMillis());
            }