#
Junjie
2025-01-14 900f7032f7e701efd4741c2bcabeaad969e5fd3f
#
7个文件已修改
268 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/ShuttleController.java 157 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/action/ShuttleAction.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/ShuttleTaskModeType.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/ShuttleThread.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/NyShuttleThread.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/shuttle.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/ShuttleController.java
@@ -286,84 +286,87 @@
            assignCommand.setLocNo(param.getDistLocNo());
        }
        for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) {
            if (param.getShuttleNo().equals(shuttleSlave.getId())) {
                ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleSlave.getId());
                if (shuttleThread == null) {
                    throw new CoolException("四向穿梭车不在线");
                }
                ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
                if (shuttleProtocol == null) {
                    throw new CoolException("四向穿梭车不在线");
                }
                ShuttleTaskModeType shuttleTaskModeType = ShuttleTaskModeType.get(param.getShuttleTaskMode().intValue());
                assignCommand.setShuttleNo(shuttleSlave.getId()); // 四向穿梭车编号
                assignCommand.setTaskMode(shuttleTaskModeType.id);
                assignCommand.setTaskNo(commonService.getWorkNo(99));//获取任务号
                assignCommand.setAuto(false);//手动模式
                if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) {
                    //移动到目标库位
                    Integer mapType = NavigationMapType.NORMAL.id;
                    if (shuttleProtocol.getHasLift()) {
                        mapType = NavigationMapType.DFX.id;
                    }
                    List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapType, assignCommand, shuttleThread);
                    if (commands == null) {
                        throw new CoolException("路径计算失败");
                    }
                    assignCommand.setCommands(commands);
                    //尝试锁定目标站路径
                    boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(param.getDistLocNo()), shuttleProtocol.getShuttleNo(), assignCommand.getNodesDeepCopy(), true);//所使用的路径进行锁定禁用
                    if (!result2) {
                        News.info("{}任务,{}小车,路径锁定失败,禁止派发", param.getDistLocNo(), shuttleProtocol.getShuttleNo());
                        throw new CoolException("路径锁定失败");
                    }
                } else if (shuttleTaskModeType == ShuttleTaskModeType.PALLET_LIFT) {
                    //托盘顶升
                    List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, true);
                    assignCommand.setCommands(commands);
                } else if (shuttleTaskModeType == ShuttleTaskModeType.PALLET_DOWN) {
                    //托盘下降
                    List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, false);
                    assignCommand.setCommands(commands);
                } else if (shuttleTaskModeType == ShuttleTaskModeType.CHARGE) {
                    //充电开关
                    boolean charge = false;
                    if (shuttleProtocol.getHasCharge()) {
                        //已充电,关闭充电
                        charge = false;
                    }else {
                        //开启充电
                        charge = true;
                    }
                    List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleChargeCommand(assignCommand, shuttleThread, charge);
                    assignCommand.setCommands(commands);
                } else if (shuttleTaskModeType == ShuttleTaskModeType.RESET) {
                    //复位
                    shuttleThread.setSyncTaskNo(0);//工作号清空
                    shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE);//任务状态-空闲
                    shuttleThread.setPakMk(true);//作业标记复位
                    shuttleThread.enableMoveLoc(null, false);
                    return R.ok();
                } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO_TASK) {
                    //移动到目标库位(生成移动任务)
                    shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), param.getDistLocNo(), param.getShuttleNo());
                    return R.ok();
                } else {
                    throw new CoolException("未知命令");
                }
                shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand);
                return R.ok();
            }
        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, param.getShuttleNo());
        if (shuttleThread == null) {
            throw new CoolException("四向穿梭车不在线");
        }
        return R.error();
        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
        if (shuttleProtocol == null) {
            throw new CoolException("四向穿梭车不在线");
        }
        ShuttleTaskModeType shuttleTaskModeType = ShuttleTaskModeType.get(param.getShuttleTaskMode().intValue());
        assignCommand.setShuttleNo(param.getShuttleNo()); // 四向穿梭车编号
        assignCommand.setTaskMode(shuttleTaskModeType.id);
        assignCommand.setTaskNo(commonService.getWorkNo(99));//获取任务号
        assignCommand.setAuto(false);//手动模式
        if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) {
            //移动到目标库位
            Integer mapType = NavigationMapType.NORMAL.id;
            if (shuttleProtocol.getHasLift()) {
                mapType = NavigationMapType.DFX.id;
            }
            List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapType, assignCommand, shuttleThread);
            if (commands == null) {
                throw new CoolException("路径计算失败");
            }
            assignCommand.setCommands(commands);
            //尝试锁定目标站路径
            boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(param.getDistLocNo()), shuttleProtocol.getShuttleNo(), assignCommand.getNodesDeepCopy(), true);//所使用的路径进行锁定禁用
            if (!result2) {
                News.info("{}任务,{}小车,路径锁定失败,禁止派发", param.getDistLocNo(), shuttleProtocol.getShuttleNo());
                throw new CoolException("路径锁定失败");
            }
        } else if (shuttleTaskModeType == ShuttleTaskModeType.PALLET_LIFT) {
            //托盘顶升
            List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, true);
            assignCommand.setCommands(commands);
        } else if (shuttleTaskModeType == ShuttleTaskModeType.PALLET_DOWN) {
            //托盘下降
            List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleLiftCommand(assignCommand, shuttleThread, false);
            assignCommand.setCommands(commands);
        } else if (shuttleTaskModeType == ShuttleTaskModeType.CHARGE) {
            //充电开关
            boolean charge = false;
            if (shuttleProtocol.getHasCharge()) {
                //已充电,关闭充电
                charge = false;
            }else {
                //开启充电
                charge = true;
            }
            List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleChargeCommand(assignCommand, shuttleThread, charge);
            assignCommand.setCommands(commands);
        } else if (shuttleTaskModeType == ShuttleTaskModeType.RESET) {
            //复位
            shuttleThread.setSyncTaskNo(0);//工作号清空
            shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE);//任务状态-空闲
            shuttleThread.setPakMk(true);//作业标记复位
            shuttleThread.enableMoveLoc(null, false);
            return R.ok();
        } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO_TASK) {
            //移动到目标库位(生成移动任务)
            shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), param.getDistLocNo(), param.getShuttleNo());
            return R.ok();
        } else if (shuttleTaskModeType == ShuttleTaskModeType.SHUTTLE_DEMO_OPEN) {
            //演示模式-开
            shuttleThread.enableDemo(true);
            return R.ok();
        } else if (shuttleTaskModeType == ShuttleTaskModeType.SHUTTLE_DEMO_CLOSE) {
            //演示模式-关
            shuttleThread.enableDemo(false);
            return R.ok();
        } else {
            throw new CoolException("未知命令");
        }
        shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand);
        return R.ok();
    }
    @PostMapping("/detl/update")
src/main/java/com/zy/core/action/ShuttleAction.java
@@ -2,19 +2,25 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zy.asrs.entity.BasShuttleOpt;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.BasShuttleOptService;
import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.ExecuteSupport;
import com.zy.common.model.NavigateNode;
import com.zy.common.utils.NavigateMapUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.common.utils.ShuttleOperaUtils;
import com.zy.core.News;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.dispatcher.ShuttleDispatchUtils;
import com.zy.core.enums.*;
import com.zy.core.model.CommandResponse;
import com.zy.core.model.command.ShuttleAssignCommand;
@@ -27,6 +33,7 @@
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -47,6 +54,10 @@
    private ConfigService configService;
    @Autowired
    private BasShuttleOptService basShuttleOptService;
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
    private ShuttleDispatchUtils shuttleDispatchUtils;
    public synchronized boolean assignWork(Integer shuttleNo, ShuttleAssignCommand assignCommand) {
        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
@@ -268,6 +279,76 @@
        return true;
    }
    //演示模式
    public synchronized void demo(Integer shuttleNo) {
        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
        if (shuttleThread == null) {
            return;
        }
        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
        if (shuttleProtocol == null) {
            return;
        }
        if (!shuttleProtocol.getDemo()) {
            return;
        }
        WrkMast moveWorking = wrkMastService.selectShuttleHasMoveWorking(shuttleNo);
        if (moveWorking != null) {
            return;
        }
        WrkMast shuttleWorking = wrkMastService.selectShuttleWorking(shuttleNo);
        if(shuttleWorking != null) {
            return;
        }
        WrkMast chargeWorking = wrkMastService.selectChargeWorking(shuttleNo);
        if (chargeWorking != null) {
            return;
        }
        if (shuttleThread.isRequireCharge()) {
            return;
        }
        if (!shuttleThread.isIdle()) {
            return;
        }
        String currentLocNo = shuttleProtocol.getCurrentLocNo();
        int lev = Utils.getLev(currentLocNo);
        LocMast targetLoc = null;
        EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
        wrapper.eq("lev1", lev);
        wrapper.eq("loc_sts", "O");
        wrapper.last("ORDER BY RAND() LIMIT 1");
        for (int i = 0; i < 3; i++) {
            LocMast locMast = locMastService.selectOne(wrapper);
            if(locMast == null) {
                continue;
            }
            ArrayList<String> locs = new ArrayList<>();
            locs.add(locMast.getLocNo());
            Integer shuttle = Utils.checkGroupLocHasShuttle(locs);
            if(shuttle != null) {
                continue;
            }
            targetLoc = locMast;
        }
        if(targetLoc == null) {
            return;
        }
        shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleNo);
    }
//    //跑库程序
//    public synchronized void moveLoc(Integer shuttleNo) {
//        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
src/main/java/com/zy/core/enums/ShuttleTaskModeType.java
@@ -14,6 +14,8 @@
    TRANSPORT(9, "搬运任务"),
    SHUTTLE_CONTROL(10, "小车管制"),
    SHUTTLE_CANCEL_CONTROL(11, "小车取消管制"),
    SHUTTLE_DEMO_OPEN(12, "演示模式-开"),
    SHUTTLE_DEMO_CLOSE(13, "演示模式-关"),
    ;
    public Integer id;
src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java
@@ -164,6 +164,11 @@
    private Integer yCurrent = 0;
    /**
     * 演示模式
     */
    private Boolean demo = false;
    /**
     * 日志采集时间
     */
    private Long deviceDataLog = System.currentTimeMillis();
@@ -319,6 +324,14 @@
        return this.pakMk ? "Y" : "N";
    }
    public String getDemo$() {
        if (this.demo == null) {
            return "";
        }
        return this.demo ? "Y" : "N";
    }
    public HashMap<String, Object> getPoint() {
        HashMap<String, Object> map = new HashMap<>();
        if (this.currentCode == null) {
src/main/java/com/zy/core/thread/ShuttleThread.java
@@ -61,6 +61,8 @@
    boolean requestWaiting();
    boolean enableDemo(boolean enable);//演示模式
    //***************获取命令*****************
    ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes);//获取移动命令
src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
@@ -120,6 +120,9 @@
//                    //小车空闲且有跑库程序
//                    shuttleAction.moveLoc(slave.getId());
                    //演示模式
                    shuttleAction.demo(slave.getId());
                    Thread.sleep(200);
                } catch (Exception e) {
                    e.printStackTrace();
@@ -804,6 +807,12 @@
    }
    @Override
    public boolean enableDemo(boolean enable) {
        shuttleProtocol.setDemo(enable);
        return true;
    }
    @Override
    public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes) {
        NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class);
        NyShuttleHttpCommand httpStandard = getHttpStandard(slave.getId(), taskNo);
src/main/webapp/views/shuttle.html
@@ -46,6 +46,7 @@
                        <th>故障码</th>
                        <th>管制状态</th>
                        <th>低电量</th>
                        <th>演示模式</th>
                    </tr>
                    </thead>
                    <tbody>
@@ -131,6 +132,8 @@
                                        <button class="item" onclick="shuttleOperator(2)">托盘下降</button>
                                        <button class="item" onclick="shuttleOperator(6)">充电开关</button>
                                        <button class="item" onclick="shuttleOperator(3)">复位</button>
                                        <button class="item" onclick="shuttleOperator(12)">演示模式-开</button>
                                        <button class="item" onclick="shuttleOperator(13)">演示模式-关</button>
                                    </div>
                                </div>
                            </div>
@@ -344,6 +347,7 @@
                setVal(tr.children("td").eq(11), table[i-1].statusErrorCode$);
                setVal(tr.children("td").eq(12), suspendState);
                setVal(tr.children("td").eq(13), table[i-1].lowerPower);
                setVal(tr.children("td").eq(14), table[i-1].demo$);
            }
        } else if (res.code === 403){
            window.location.href = baseUrl+"/login";