自动化立体仓库 - WCS系统
#
vincent
2020-08-18 227c4f1fc845080a70f230a2929fe76c204a9d9f
src/main/java/com/zy/asrs/controller/CrnController.java
@@ -327,6 +327,47 @@
        return R.ok("清除命令成功");
    }
    @ManagerAuth(memo = "手动复位")
    @PostMapping("/operator/handleReset")
    public R handleReset(CrnOperatorParam param) throws Exception {
        if (param.getCrnNo() == null) {
            throw new CoolException("请选择堆垛机");
        }
        // 获取堆垛机缓存
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
            if (param.getCrnNo().equals(crn.getId())) {
                CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
                if (crnThread == null) {
                    throw new CoolException("堆垛机不在线");
                }
                CrnProtocol crnProtocol = crnThread.getCrnProtocol();
                if (crnProtocol == null) {
                    throw new CoolException("堆垛机不在线");
                }
                // 只有出现指定异常才进行复位
                if (crnProtocol.getCrnError2().leftTakeNoneErr
                        || crnProtocol.getCrnError2().rightTakeNoneErr
                        || crnProtocol.getCrnError2().leftPutLoadErr
                        || crnProtocol.getCrnError2().rightPutLoadErr) {
                    CrnCommand command = new CrnCommand();
                    command.setCrnNo(param.getCrnNo()); // 堆垛机编号
                    command.setAckFinish((short) 1);  // 任务完成确认位
                    command.setTaskMode(CrnTaskModeType.NONE); // 任务模式
                    // 延时发送
                    Thread.sleep(3000L);
                    if (MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, command))) {
                        return R.ok();
                    } else {
                        throw new CoolException("命令下发失败");
                    }
                }
            }
        }
        return R.error();
    }
    private boolean crnControl(CrnCommand command){
        if (command.getCrnNo() == null) {
            throw new CoolException("请选择堆垛机");