自动化立体仓库 - WCS系统
#
Junjie
2023-10-18 d42a74a62f8bd2ad2760647e73cd6313bbcb10ed
src/main/java/com/zy/asrs/controller/ShuttleController.java
@@ -17,6 +17,7 @@
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NyShuttleOperaResult;
import com.zy.common.model.enums.NavigationMapType;
import com.zy.common.service.CommonService;
import com.zy.common.utils.NyHttpUtils;
import com.zy.common.utils.NyShuttleOperaUtils;
@@ -70,10 +71,13 @@
    @ManagerAuth(memo = "四向穿梭车信息表")
    public R shuttleStateTable(){
        ArrayList<JSONObject> list = new ArrayList<>();
        List<BasShuttle> shuttles = basShuttleService.selectList(new EntityWrapper<BasShuttle>().orderBy("shuttle_no"));
        for (BasShuttle basShuttle : shuttles) {
        for (ShuttleSlave slave : slaveProperties.getShuttle()) {
            // 表格行
            JSONObject baseObj = new JSONObject();
            baseObj.put("shuttleNo", slave.getId());
            list.add(baseObj);
            // 获取四向穿梭车信息
            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, basShuttle.getShuttleNo());
            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
            if (shuttleThread == null) {
                continue;
            }
@@ -81,7 +85,7 @@
            JSONObject shuttleData = JSON.parseObject(JSON.toJSONString(shuttleProtocol));
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo()==null) {
                if (shuttleData != null) {
                    list.add(shuttleData);
                    baseObj.putAll(shuttleData);
                }
                continue;
            }
@@ -96,7 +100,7 @@
                }
            }
            list.add(shuttleData);
            baseObj.putAll(shuttleData);
        }
        return R.ok().add(list);
    }
@@ -105,14 +109,13 @@
    @ManagerAuth(memo = "四向穿梭车数据表")
    public R steMsgTable(){
        List<ShuttleMsgTableVo> list = new ArrayList<>();
        List<BasShuttle> shuttles = basShuttleService.selectList(new EntityWrapper<BasShuttle>().orderBy("shuttle_no"));
        for (BasShuttle basShuttle : shuttles) {
        for (ShuttleSlave slave : slaveProperties.getShuttle()) {
            // 表格行
            ShuttleMsgTableVo vo = new ShuttleMsgTableVo();
            vo.setShuttleNo(basShuttle.getShuttleNo());   //  四向穿梭车号
            vo.setShuttleNo(slave.getId());   //  四向穿梭车号
            list.add(vo);
            // 获取穿梭车信息
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, basShuttle.getShuttleNo());
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
            if (shuttleThread == null) {
                continue;
            }
@@ -146,8 +149,11 @@
            vo.setPakMk(shuttleProtocol.getPakMk()?"Y" : "N");    // 作业标记
            vo.setLocNo(shuttleProtocol.getLocNo());//四向穿梭车当前库位号
            vo.setLev(shuttleProtocol.getLocNo() == null ? 0 : Utils.getLev(shuttleProtocol.getLocNo()));//四向穿梭车当前层高
//            vo.setRunSpeed(basShuttle.getRunSpeed());//四向穿梭车运行速度(设置)
            vo.setChargeLine(basShuttle.getChargeLine());//充电阈值
            BasShuttle basShuttle = basShuttleService.selectById(slave.getId());
            if (basShuttle != null) {
                vo.setChargeLine(basShuttle.getChargeLine());//充电阈值
            }
        }
        return R.ok().add(list);
    }
@@ -299,7 +305,11 @@
                    assignCommand.setNodes(result.getNodes());
                } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) {
                    //移动到目标库位
                    NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getDistLocNo());
                    Integer mapType = NavigationMapType.NORMAL.id;
                    if (shuttleProtocol.getLiftPosition() == 2) {
                        mapType = NavigationMapType.DFX.id;
                    }
                    NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapType);
                    if (result == null) {
                        throw new CoolException("路径计算失败");
                    }
@@ -338,6 +348,15 @@
                    shuttleProtocol.setToken(0);//令牌清空
                    shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);//任务状态-空闲
                    shuttleProtocol.setPakMk(false);//作业标记复位
                    shuttleProtocol.setMoveLoc(false);
                    shuttleProtocol.setMoveType(0);
                    shuttleProtocol.setXStart(0);
                    shuttleProtocol.setXTarget(0);
                    shuttleProtocol.setXCurrent(0);
                    shuttleProtocol.setYStart(0);
                    shuttleProtocol.setYTarget(0);
                    shuttleProtocol.setYCurrent(0);
                    return R.ok();
                } else if (shuttleTaskModeType == ShuttleTaskModeType.SHUTTLE_CONTROL) {
                    //小车管制
@@ -410,4 +429,40 @@
        return R.ok();
    }
    /**
     * 跑库程序
     */
    @PostMapping("/moveLoc")
    @ManagerAuth
    public R moveLoc(@RequestParam Integer shuttleNo,
                     @RequestParam Integer moveType,
                     @RequestParam Integer xStart,
                     @RequestParam Integer xTarget,
                     @RequestParam Integer yStart,
                     @RequestParam Integer yTarget) {
        NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
        if (shuttleThread == null) {
            return R.error();
        }
        NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
        if (shuttleProtocol == null) {
            return R.error();
        }
        if (!shuttleProtocol.isIdle()) {
            return R.error("小车忙碌中");
        }
        shuttleProtocol.setMoveLoc(true);//开启跑库
        shuttleProtocol.setMoveType(moveType);
        shuttleProtocol.setXStart(xStart);
        shuttleProtocol.setXTarget(xTarget);
        shuttleProtocol.setXCurrent(xStart);
        shuttleProtocol.setYStart(yStart);
        shuttleProtocol.setYTarget(yTarget);
        shuttleProtocol.setYCurrent(yStart);
        return R.ok();
    }
}