#
luxiaotao1123
2024-04-12 6ea89423c9c01ecfa339cf0d83e8dd254cecf4f8
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
@@ -7,6 +7,7 @@
import com.zy.asrs.framework.common.DateUtils;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.common.ExecuteSupport;
import com.zy.asrs.wcs.core.entity.BasShuttle;
import com.zy.asrs.wcs.core.entity.Loc;
import com.zy.asrs.wcs.core.model.NavigateNode;
@@ -110,7 +111,8 @@
                shuttleProtocol.setCurrentCode(data.getString("groundCode") == null ? "0" : data.getString("groundCode"));
                //电池电量
                shuttleProtocol.setBatteryPower(data.getString("battery") == null ? "0%" : data.getString("battery"));
                //故障
                shuttleProtocol.setErrorCode(deviceStatus == 6 ? "1" : "0");
                //是否顶升
                shuttleProtocol.setHasLift(data.getInteger("palletStatus") == 1 ? true : false);
@@ -134,10 +136,10 @@
                    shuttleProtocol.setPakMk(true);
                }
//                if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == ShuttleDeviceStatusType.IDLE.id) {
//                    //小车空闲状态、小车任务状态为未知,认定曾离线过,需要复位成空闲
//                    shuttleProtocol.setProtocolStatusType(ShuttleProtocolStatusType.IDLE);
//                }
                if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == 3) {
                    //小车空闲状态、小车任务状态为未知,认定曾离线过,需要复位成空闲
                    shuttleProtocol.setProtocolStatusType(ShuttleProtocolStatusType.IDLE);
                }
                if (System.currentTimeMillis() - shuttleProtocol.getDeviceDataLog() > 1000 * 5) {
                    //采集时间超过5s,保存一次数据记录
@@ -154,6 +156,30 @@
                    //更新采集时间
                    shuttleProtocol.setDeviceDataLog(System.currentTimeMillis());
                }
                //将四向穿梭车状态保存至数据库
                BasShuttleService shuttleService = SpringUtils.getBean(BasShuttleService.class);
                BasShuttle basShuttle = shuttleService.getOne(new LambdaQueryWrapper<BasShuttle>()
                        .eq(BasShuttle::getShuttleNo, device.getDeviceNo())
                        .eq(BasShuttle::getHostId, device.getHostId()));
                if (basShuttle == null) {
                    basShuttle = new BasShuttle();
                    //四向穿梭车号
                    basShuttle.setShuttleNo(Integer.valueOf(device.getDeviceNo()));
                    basShuttle.setStatus(1);
                    basShuttle.setDeleted(0);
                    basShuttle.setHostId(device.getHostId());
                    shuttleService.save(basShuttle);
                }
                //任务号
                basShuttle.setTaskNo(shuttleProtocol.getTaskNo().intValue());
                //修改时间
                basShuttle.setUpdateTime(new Date());
                //设备状态
                basShuttle.setProtocol(JSON.toJSONString(shuttleProtocol));
                if (shuttleService.updateById(basShuttle)) {
                    OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), device.getDeviceNo()));
                }
            } else {
                OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】{1}读取四向穿梭车状态信息失败", DateUtils.convert(new Date()), device.getDeviceNo()));
@@ -346,6 +372,16 @@
    @Override
    public boolean isIdle() {
        return this.isIdle(null);
    }
    @Override
    public boolean isIdle(ExecuteSupport support) {
        if (null != support) {
            if (!support.judgement()) {
                return false;
            }
        }
        if (this.shuttleProtocol.getIdle() == null
                || this.shuttleProtocol.getPakMk() == null
                || this.shuttleProtocol.getErrorCode() == null
@@ -417,6 +453,13 @@
    @Override
    public boolean isChargingCompleted() {
        if (this.shuttleProtocol.getBatteryPower() == null) {
            return false;
        }
        if (Integer.valueOf(this.shuttleProtocol.getBatteryPower()) >= 100) {
            return true;
        }
        return false;
    }