自动化立体仓库 - WCS系统
*
lsh
6 天以前 44be6da8fc2740a7e81d5b878a894e318b6a5f8c
src/main/java/com/zy/asrs/controller/CrnController.java
@@ -130,9 +130,9 @@
            vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 货叉位置
            vo.setLiftPos(crnProtocol.getLiftPosType().desc);
            vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位");
            vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1()));
            if (crnProtocol.getAlarm1() > 0) {
                BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
            vo.setWarnCode(String.valueOf(crnProtocol.getAlarm()));
            if (crnProtocol.getAlarm() > 0) {
                BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
                vo.setAlarm(crnError==null?"未知异常":crnError.getErrName());
            }
        }
@@ -165,9 +165,9 @@
        vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 货叉位置
        vo.setLiftPos(crnProtocol.getLiftPosType().desc);
        vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位");
        vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1()));
        if (crnProtocol.getAlarm1() > 0) {
            BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
        vo.setWarnCode(String.valueOf(crnProtocol.getAlarm()));
        if (crnProtocol.getAlarm() > 0) {
            BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
            vo.setAlarm(crnError==null?"未知异常":crnError.getErrName());
        }
        return R.ok().add(vo);
@@ -288,7 +288,11 @@
                    vo.setLocNo(wrkMast.getLocNo());    //  目标库位
                }
            } else {
                vo.setDeviceStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态
                if (Cools.isEmpty(crnProtocol.modeType)){
                    vo.setDeviceStatus(CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态
                } else {
                    vo.setDeviceStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO.getDesc(): CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态
                }
            }
            vo.setXspeed(crnProtocol.getXSpeed());  //  走行速度(m/min)
            vo.setYspeed(crnProtocol.getYSpeed());  //  升降速度(m/min)
@@ -297,8 +301,11 @@
            vo.setYdistance(crnProtocol.getYDistance());  //  升降距离(Km)
            vo.setXduration(crnProtocol.getXDuration());    //  走行时长(H)
            vo.setYduration(crnProtocol.getYDuration());    //  升降时长(H)
            vo.setStatusType(crnProtocol.modeType.desc);   //  模式状态
            if (Cools.isEmpty(crnProtocol.modeType)){
                vo.setStatusType(CrnStatusType.MACHINE_UN_AUTO.getDesc());   //  模式状态
            } else {
                vo.setStatusType(crnProtocol.modeType.desc);   //  模式状态
            }
            vo.setWrkStatus(crnProtocol.getStatusType().id);     //  任务状态
            vo.setLoading((crnProtocol.getLoaded() != null && crnProtocol.getLoaded() == 1) ? "有物" : "无物");  //  有物
            vo.setBay(crnProtocol.getBay());    //  列
@@ -307,9 +314,9 @@
            vo.setForkOffset(crnProtocol.getForkPosType().desc);    // 货叉位置
            vo.setLiftPos(crnProtocol.getLiftPosType().desc);
            vo.setWalkPos(crnProtocol.getWalkPos()==1?"不在定位":"在定位");
            vo.setWarnCode(String.valueOf(crnProtocol.getAlarm1()));
            if (crnProtocol.getAlarm1() > 0) {
                BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm1());
            vo.setWarnCode(String.valueOf(crnProtocol.getAlarm()));
            if (crnProtocol.getAlarm() > 0) {
                BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
                vo.setAlarm(crnError==null?"未知异常":crnError.getErrName());
            }
            vo.setInEnable(basCrnp.getInEnable());
@@ -376,6 +383,10 @@
    @ManagerAuth(memo = "入库")
    @PostMapping("/crn/operator/put")
    public R crnPut(CrnOperatorParam param){
//        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
        command.setTaskNo((short) 0); // 工作号
@@ -387,40 +398,51 @@
        command.setDestinationPosX(param.getRow());     // 目标库位排
        command.setDestinationPosY(param.getBay());     // 目标库位列
        command.setDestinationPosZ(param.getLev());     // 目标库位层
        command.setCommand((short)1);
        return crnControl(command)?R.ok():R.error();
    }
    @ManagerAuth(memo = "出库")
    @PostMapping("/crn/operator/take")
    public R crnTake(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
        command.setTaskNo((short) 0); // 工作号
        command.setAckFinish((short) 0);  // 任务完成确认位
        command.setTaskMode(CrnTaskModeType.PAKOUT); // 任务模式
        command.setTaskMode(CrnTaskModeType.PAKIN); // 任务模式
        command.setSourcePosX(param.getSourceRow());     // 源库位排
        command.setSourcePosY(param.getSourceBay());     // 源库位列
        command.setSourcePosZ(param.getSourceLev());     // 源库位层
        command.setDestinationPosX(param.getRow());     // 目标库位排
        command.setDestinationPosY(param.getBay());     // 目标库位列
        command.setDestinationPosZ(param.getLev());     // 目标库位层
        command.setCommand((short)1);
        return crnControl(command)?R.ok():R.error();
    }
    @ManagerAuth(memo = "库位转移")
    @PostMapping("/crn/operator/stockMove")
    public R crnStockMove(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
        command.setTaskNo((short) 0); // 工作号
        command.setAckFinish((short) 0);  // 任务完成确认位
        command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式
        command.setSourcePosX(param.getSourceRow());     // 源库位排
        command.setSourcePosY(param.getSourceBay());     // 源库位列
        command.setSourcePosZ(param.getSourceLev());     // 源库位层
        command.setDestinationPosX(param.getRow());     // 目标库位排
        command.setDestinationPosY(param.getBay());     // 目标库位列
        command.setDestinationPosZ(param.getLev());     // 目标库位层
        command.setSourcePosZ(param.getSourceRow());     // 源库位排
        command.setSourcePosX(param.getSourceBay());     // 源库位列
        command.setSourcePosY(param.getSourceLev());     // 源库位层
        command.setDestinationPosZ(param.getRow());     // 目标库位排
        command.setDestinationPosX(param.getBay());     // 目标库位列
        command.setDestinationPosY(param.getLev());     // 目标库位层
        command.setCommand((short)1);
        LocMast sourceLoc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getSourcePosX())
                .eq("bay1", command.getSourcePosY()).eq("lev1", command.getSourcePosZ()));
        LocMast loc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("row1", command.getDestinationPosX())
@@ -432,6 +454,10 @@
    @ManagerAuth(memo = "站到站")
    @PostMapping("/crn/operator/siteMove")
    public R crnSiteMove(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
        command.setTaskNo((short) 0); // 工作号
@@ -449,6 +475,10 @@
    @ManagerAuth(memo = "回原点")
    @PostMapping("/crn/operator/bacOrigin")
    public R crnBacOrigin(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
        command.setTaskNo((short) 0); // 工作号
@@ -466,6 +496,10 @@
    @ManagerAuth(memo = "反原点")
    @PostMapping("/crn/operator/reverseOrigin")
    public R reverseOrigin(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
        command.setTaskNo((short) 0); // 工作号
@@ -475,8 +509,8 @@
        command.setSourcePosY((short) 0);     // 源库位列
        command.setSourcePosZ((short) 0);     // 源库位层
        command.setDestinationPosX((short) 0);     // 目标库位排
        command.setDestinationPosY((short) 34);     // 目标库位列
        command.setDestinationPosZ((short) 5);     // 目标库位层
        command.setDestinationPosY((short) 22);     // 目标库位列
        command.setDestinationPosZ((short) 1);     // 目标库位层
        return crnControl(command)?R.ok():R.error();
    }
@@ -501,6 +535,10 @@
    @ManagerAuth(memo = "任务完成")
    @PostMapping("/crn/operator/taskComplete")
    public R crnTaskComplete(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
        command.setTaskNo((short) 0); // 工作号
@@ -512,6 +550,7 @@
        command.setDestinationPosX((short) 0);     // 目标库位排
        command.setDestinationPosY((short) 0);     // 目标库位列
        command.setDestinationPosZ((short) 0);     // 目标库位层
        command.setCommand((short)0);
        return crnControl(command)?R.ok():R.error();
    }
@@ -530,6 +569,10 @@
    @ManagerAuth(memo = "清除命令")
    @PostMapping("/crn/operator/clearCommand")
    public R crnClearCommand(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        if (param.getCrnNo() == null) {
            throw new CoolException("请选择堆垛机");
        }
@@ -550,6 +593,10 @@
    @ManagerAuth(memo = "手动复位")
    @PostMapping("/crn/operator/handleReset")
    public R handleReset(CrnOperatorParam param) throws Exception {
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        if (param.getCrnNo() == null) {
            throw new CoolException("请选择堆垛机");
        }
@@ -572,7 +619,7 @@
                crnCommand.setCommand((short) 0);  // 任务完成确认位
                // 延时发送
                Thread.sleep(1000L);
                if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(2, crnCommand), false)) {
                if (CommandUtils.offer(SlaveType.Crn, crn.getId(), new Task(5, crnCommand), false)) {
                    return R.ok();
                } else {
                    throw new CoolException("命令下发失败");
@@ -588,6 +635,10 @@
    @ManagerAuth(memo = "切换联机模式")
    @PostMapping("/crn/operator/auto")
    public R crnAuto(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        short[] array = new short[9];
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
@@ -599,6 +650,10 @@
    @ManagerAuth(memo = "切换半手动模式")
    @PostMapping("/crn/operator/semiAutomatic")
    public R crnsemiAutomatic(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        short[] array = new short[9];
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
@@ -610,6 +665,10 @@
    @ManagerAuth(memo = "切换手动模式")
    @PostMapping("/crn/operator/hand")
    public R onlineWrk1(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        short[] array = new short[9];
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
@@ -621,6 +680,10 @@
    @ManagerAuth(memo = "申请完成任务")
    @PostMapping("/crn/operator/onlineWrk1")
    public R onlineWrk2(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        short[] array = new short[9];
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
@@ -632,6 +695,10 @@
    @ManagerAuth(memo = "申请取消任务")
    @PostMapping("/crn/operator/onlineWrk2")
    public R onlineWrk3(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        short[] array = new short[9];
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
@@ -643,6 +710,10 @@
    @ManagerAuth(memo = "清除联机任务")
    @PostMapping("/crn/operator/onlineWrk3")
    public R onlineWrk4(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        short[] array = new short[9];
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
@@ -654,6 +725,10 @@
    @ManagerAuth(memo = "恢复联机任务")
    @PostMapping("/crn/operator/onlineWrk4")
    public R crnHand(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        short[] array = new short[9];
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
@@ -663,6 +738,22 @@
        return crnControl2(command)?R.ok():R.error();
    }
    @ManagerAuth(memo = "复位")
    @PostMapping("/crn/operator/reset")
    public R crnReset(CrnOperatorParam param){
        // 系统运行状态判断
//        if (SystemProperties.WCS_RUNNING_STATUS.get()) {
//            return R.error("wcs系统状态为开启");
//        }
        short[] array = new short[9];
        CrnCommand command = new CrnCommand();
        command.setCrnNo(param.getCrnNo()); // 堆垛机编号
        command.setTaskNo((short) 0); // 工作号
        command.setReset((short)1);
        return crnControl2(command)?R.ok():R.error();
    }
    private boolean crnControl2(CrnCommand command){