自动化立体仓库 - WCS系统
Junjie
2024-12-21 802c12dcbc63ee1662c15723d27c8fc1f4fd36e6
src/main/java/com/zy/asrs/controller/ShuttleController.java
@@ -2,7 +2,6 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
@@ -71,10 +70,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;
            }
@@ -82,7 +84,7 @@
            JSONObject shuttleData = JSON.parseObject(JSON.toJSONString(shuttleProtocol));
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo()==null) {
                if (shuttleData != null) {
                    list.add(shuttleData);
                    baseObj.putAll(shuttleData);
                }
                continue;
            }
@@ -90,14 +92,20 @@
            shuttleData.put("moveAdvancePath", null);//穿梭车预计路径
            if (shuttleProtocol.getTaskNo() != 0) {
                //存在任务,获取指令
                Object object = redisUtil.get("shuttle_wrk_no_" + shuttleProtocol.getTaskNo());
                Object object = redisUtil.get(RedisKeyType.SHUTTLE.key + shuttleProtocol.getTaskNo());
                if (object != null) {
                    ShuttleRedisCommand redisCommand = JSON.parseObject(object.toString(), ShuttleRedisCommand.class);
                    shuttleData.put("moveAdvancePath", redisCommand.getAssignCommand().getNodes());//穿梭车预计路径
                }
            }
            list.add(shuttleData);
            Integer chargeLine = basShuttleService.selectById(slave.getId()).getChargeLine();
            String lowerPower = "N";
            if (chargeLine != null && shuttleProtocol.getPowerPercent() != null) {
                lowerPower = shuttleProtocol.getPowerPercent() <= chargeLine ? "Y" : "N";
            }
            shuttleData.put("lowerPower", lowerPower);//是否低电量
            baseObj.putAll(shuttleData);
        }
        return R.ok().add(list);
    }
@@ -106,14 +114,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;
            }
@@ -147,8 +154,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);
    }
@@ -174,7 +184,7 @@
    @RequestMapping(value = "/command/query")
    public R shuttleCommandQuery(@RequestParam("wrkNo") Integer wrkNo) {
        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
        if (o == null) {
            return R.error();
        }
@@ -186,13 +196,13 @@
    @RequestMapping(value = "/command/rollback")
    public R shuttleCommandRollback(@RequestParam("wrkNo") Integer wrkNo
            , @RequestParam("commandStep") Integer commandStep) {
        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
        if (o == null) {
            return R.error();
        }
        ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class);
        redisCommand.setCommandStep(commandStep);
        redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand));
        redisUtil.set(RedisKeyType.SHUTTLE.key + wrkNo, JSON.toJSONString(redisCommand));
        return R.ok();
    }
@@ -201,7 +211,7 @@
    public R shuttleCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo
            , @RequestParam("commandStep") Integer commandStep
            , @RequestParam("complete") Integer complete) {
        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
        if (o == null) {
            return R.error();
        }
@@ -210,14 +220,14 @@
        List<NyShuttleHttpCommand> commands = assignCommand.getCommands();
        NyShuttleHttpCommand command = commands.get(commandStep);
        command.setComplete(complete != 0);
        redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand));
        redisUtil.set(RedisKeyType.SHUTTLE.key + wrkNo, JSON.toJSONString(redisCommand));
        return R.ok();
    }
    //重启任务(命令)
    @RequestMapping(value = "/command/restart")
    public R shuttleCommandCompleteSwitch(@RequestParam("wrkNo") Integer wrkNo) {
        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
        if (o == null) {
            return R.error();
        }
@@ -243,11 +253,11 @@
    //删除任务(命令)
    @RequestMapping(value = "/command/del")
    public R liftCommandDel(@RequestParam("wrkNo") Integer wrkNo) {
        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
        Object o = redisUtil.get(RedisKeyType.SHUTTLE.key + wrkNo);
        if (o == null) {
            return R.error();
        }
        redisUtil.del("shuttle_wrk_no_" + wrkNo);
        redisUtil.del(RedisKeyType.SHUTTLE.key + wrkNo);
        return R.ok();
    }
@@ -300,7 +310,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(), NavigationMapType.NORMAL.id);
                    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("路径计算失败");
                    }