| | |
| | | @Autowired |
| | | private BasSteErrLogService basSteErrLogService; |
| | | @Autowired |
| | | private BasShuttleErrLogService basShuttleErrLogService; |
| | | @Autowired |
| | | private BasShuttleErrService basShuttleErrService; |
| | | @Autowired |
| | | private BasCrnErrorMapper basCrnErrorMapper; |
| | | @Autowired |
| | | private BasSteService basSteService; |
| | |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 入库 ===>> 四向穿梭车入库作业下发 |
| | | // */ |
| | | // public synchronized void shuttleIoInExecute() { |
| | | // // 根据输送线plc遍历 |
| | | // for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // // 遍历入库站 |
| | | // for (DevpSlave.StaRack rackInStn : devp.getRackInStn()) { |
| | | // // 获取入库站信息 |
| | | // DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | // |
| | | // StaProtocol staProtocol = devpThread.getStation().get(rackInStn.getStaNo()); |
| | | // StaProtocol staProtocol105 = devpThread.getStation().get(105); |
| | | // staProtocol105.setWorkNo((short) 752); |
| | | // staProtocol105.setStaNo((short) 100); |
| | | // |
| | | // StaProtocol staProtocol106 = devpThread.getStation().get(106); |
| | | // staProtocol106.setWorkNo((short) 753); |
| | | // staProtocol106.setStaNo((short) 100); |
| | | // |
| | | // if (staProtocol == null) { |
| | | // continue; |
| | | // } else { |
| | | // staProtocol = staProtocol.clone(); |
| | | // } |
| | | // Short workNo = staProtocol.getWorkNo(); |
| | | // |
| | | // // 判断是否满足入库条件 |
| | | // if (true || staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()) { |
| | | // WrkMast wrkMast = wrkMastMapper.selectRackInStep48(workNo, staProtocol.getSiteId()); |
| | | // if (wrkMast != null) { |
| | | // if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 8) { |
| | | // ShuttleThread shuttleThread = null; |
| | | // HashMap<String, Object> searchIdleShuttle = null; |
| | | // if (wrkMast.getWrkSts() == 4) { |
| | | // //寻找最近且空闲的四向穿梭车 |
| | | // searchIdleShuttle = this.searchIdleShuttle(wrkMast); |
| | | // shuttleThread = (ShuttleThread) searchIdleShuttle.get("result"); |
| | | // }else { |
| | | // //状态8,四向穿梭车已在提升机口,等待命令进行入库搬运动作 |
| | | // Integer shuttleNo = wrkMast.getShuttleNo();//四向穿梭车号 |
| | | // shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); |
| | | // } |
| | | // |
| | | // if (shuttleThread == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | // if (!shuttleProtocol.isIdle()) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // wrkMast.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());//给工作档分配四向穿梭车号 |
| | | // |
| | | // //分配任务号 |
| | | // shuttleProtocol.setTaskNo(wrkMast.getWrkNo().shortValue()); |
| | | // //分配源库位 |
| | | // shuttleProtocol.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | | // |
| | | // ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); |
| | | // //四向穿梭车号 |
| | | // assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); |
| | | // //任务号 |
| | | // assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); |
| | | // //入出库模式 |
| | | // assignCommand.setTaskMode(ShuttleTaskModeType.PAK_IN.id.shortValue()); |
| | | // //源库位(小车当前位置) |
| | | // String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | // assignCommand.setSourceLocNo(currentLocNo); |
| | | // |
| | | // if (wrkMast.getWrkSts() == 8 || Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) { |
| | | // //同一层 |
| | | // //分配目标库位 |
| | | // shuttleProtocol.setLocNo(wrkMast.getLocNo()); |
| | | // //目标库位 |
| | | // assignCommand.setLocNo(wrkMast.getLocNo()); |
| | | // wrkMast.setWrkSts(9L);//小车入库中 |
| | | // |
| | | // //获取从小车 |
| | | // }else { |
| | | // //不同层,将目标库位分配成提升机库位号 |
| | | // |
| | | // //小车当前层高 |
| | | // Integer currentLev = Integer.parseInt(currentLocNo.substring(currentLocNo.length() - 2, currentLocNo.length())); |
| | | // |
| | | // //获取提升机 |
| | | // LiftSlave liftSlave = slaveProperties.getLift().get(0); |
| | | // //提升机库位号 |
| | | // String liftLocNo = liftSlave.getLiftLocNo(currentLev); |
| | | // shuttleProtocol.setLocNo(liftLocNo); |
| | | // //目标库位 |
| | | // assignCommand.setLocNo(liftLocNo); |
| | | // wrkMast.setWrkSts(5L);//小车迁移状态 |
| | | // } |
| | | // |
| | | // if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | // //下发任务 |
| | | // MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | /** |
| | | * 入库 ===>> 四向穿梭车入库作业下发 |
| | |
| | | //同一层直接取货无需经过提升机 |
| | | //直接计算车到提升机取货再到库位路径指令 |
| | | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, locNo); |
| | | if (wrkMast.getWrkSts() == 8) { |
| | | //此时车在提升机内部,需要多下达一步指令让车移动到提升机口 |
| | | BasDevp basDevp = basDevpService.selectById(109);//获取提升机信息 |
| | | ShuttleCommand moveCommand = new ShuttleCommand(); |
| | | moveCommand.setCommandWord((short) 1); |
| | | moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//提升机内部二维码 |
| | | moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum());//提升机口二维码 |
| | | moveCommand.setStartToDistDistance(1300); |
| | | moveCommand.setMiddleToDistDistance(0); |
| | | moveCommand.setRunDirection(commands.get(0).getRunDirection()); |
| | | moveCommand.setCommandEnd((short) 1); |
| | | commands.add(0, moveCommand);//将该指令添加到队头 |
| | | } |
| | | assignCommand.setCommands(commands); |
| | | //分配目标库位 |
| | | shuttleProtocol.setLocNo(wrkMast.getLocNo()); |
| | |
| | | |
| | | ShuttleCommand command = new ShuttleCommand(); |
| | | command.setCommandWord((short) 1); |
| | | command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY())); |
| | | command.setMiddleCodeNum((short) 0); |
| | | command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY())); |
| | | |
| | | //通过xy坐标小车二维码 |
| | | Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); |
| | | command.setStartCodeNum(startCodeNum); |
| | | |
| | | command.setMiddleCodeNum((short) 1); |
| | | |
| | | //通过xy坐标小车二维码 |
| | | Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); |
| | | command.setDistCodeNum(distCodeNum); |
| | | |
| | | command.setStartToDistDistance(allDistance); |
| | | command.setMiddleToDistDistance(1000); |
| | | command.setMiddleToDistDistance(0); |
| | | command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); |
| | | command.setPalletLift((short) 1); |
| | | command.setForceMoveDistance(1000); |
| | | command.setForceMoveDistance(0); |
| | | command.setChargeSwitch((short) 2); |
| | | command.setIOControl((short) 0); |
| | | command.setRunSpeed((short) 1000); |
| | | command.setRadarTmp((short) 0); |
| | | command.setCommandEnd((short) 1); |
| | | commands.add(command); |
| | |
| | | |
| | | ShuttleCommand command = new ShuttleCommand(); |
| | | command.setCommandWord((short) 1); |
| | | command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY())); |
| | | command.setMiddleCodeNum((short) 0); |
| | | command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY())); |
| | | |
| | | //通过xy坐标小车二维码 |
| | | Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); |
| | | command.setStartCodeNum(startCodeNum); |
| | | |
| | | command.setMiddleCodeNum((short) 1); |
| | | |
| | | //通过xy坐标小车二维码 |
| | | Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); |
| | | command.setDistCodeNum(distCodeNum); |
| | | |
| | | command.setStartToDistDistance(allDistance); |
| | | command.setMiddleToDistDistance(1000); |
| | | command.setMiddleToDistDistance(0); |
| | | command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); |
| | | command.setPalletLift((short) 1); |
| | | command.setForceMoveDistance(1000); |
| | | command.setForceMoveDistance(0); |
| | | command.setChargeSwitch((short) 2); |
| | | command.setIOControl((short) 0); |
| | | command.setRunSpeed((short) 1000); |
| | | command.setRadarTmp((short) 0); |
| | | command.setCommandEnd((short) 1); |
| | | commands.add(command); |
| | |
| | | |
| | | command = new ShuttleCommand(); |
| | | command.setCommandWord((short) 1); |
| | | command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY())); |
| | | command.setMiddleCodeNum((short) 0); |
| | | command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY())); |
| | | |
| | | //通过xy坐标小车二维码 |
| | | Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); |
| | | command.setStartCodeNum(startCodeNum); |
| | | |
| | | command.setMiddleCodeNum((short) 1); |
| | | |
| | | //通过xy坐标小车二维码 |
| | | Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); |
| | | command.setDistCodeNum(distCodeNum); |
| | | |
| | | command.setStartToDistDistance(allDistance); |
| | | command.setMiddleToDistDistance(1000); |
| | | command.setMiddleToDistDistance(0); |
| | | command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); |
| | | command.setPalletLift((short) 1); |
| | | command.setForceMoveDistance(1000); |
| | | command.setForceMoveDistance(0); |
| | | command.setChargeSwitch((short) 2); |
| | | command.setIOControl((short) 0); |
| | | command.setRunSpeed((short) 1000); |
| | | command.setRadarTmp((short) 0); |
| | | command.setCommandEnd((short) 1); |
| | | commands.add(command); |
| | |
| | | } |
| | | } else if (wrkMast.getWrkSts() == 25) { |
| | | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo); |
| | | //此时车在提升机内部,需要多下达一步指令让车移动到提升机口 |
| | | BasDevp basDevp = basDevpService.selectById(109);//获取提升机信息 |
| | | ShuttleCommand moveCommand = new ShuttleCommand(); |
| | | moveCommand.setCommandWord((short) 1);//小车移动指令字 |
| | | moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//提升机二维码 |
| | | moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum()); |
| | | moveCommand.setStartToDistDistance(1300); |
| | | moveCommand.setMiddleToDistDistance(0); |
| | | moveCommand.setRunDirection(commands.get(0).getRunDirection()); |
| | | moveCommand.setCommandEnd((short) 1); |
| | | commands.add(0, moveCommand);//将该指令添加到队头 |
| | | |
| | | //分配目标库位 |
| | | shuttleProtocol.setLocNo(wrkMast.getSourceLocNo()); |
| | | //目标库位 |
| | |
| | | */ |
| | | public void recErr() { |
| | | try { |
| | | this.recShuttleErr(); |
| | | this.recCrnErr(); |
| | | this.recSteErr(); |
| | | } catch (Exception e) { |
| | | News.error("recErr fail", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 四向穿梭车异常信息记录 |
| | | */ |
| | | private void recShuttleErr() { |
| | | Date now = new Date(); |
| | | for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) { |
| | | // 获取堆垛机信息 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleSlave.getId()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | if (shuttleProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (shuttleProtocol.getTaskNo() != 0) { |
| | | //有任务 |
| | | BasShuttleErrLog latest = basShuttleErrLogService.findLatestByTaskNo(shuttleSlave.getId(), shuttleProtocol.getTaskNo().intValue()); |
| | | // 有异常 |
| | | if (latest == null) { |
| | | if (shuttleProtocol.getStatusErrorCode() != null && shuttleProtocol.getStatusErrorCode() > 0) { |
| | | WrkMast wrkMast = wrkMastMapper.selectById(shuttleProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | continue; |
| | | } |
| | | BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getStatusErrorCode().intValue()); |
| | | String errName = basShuttleErr==null? "未知异常":basShuttleErr.getErrName(); |
| | | BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | wrkMast.getWrkSts(), // 工作状态 |
| | | wrkMast.getIoType(), // 入出库类型 |
| | | shuttleSlave.getId(), // 四向穿梭车 |
| | | null, // plc |
| | | wrkMast.getLocNo(), // 目标库位 |
| | | wrkMast.getStaNo(), // 目标站 |
| | | wrkMast.getSourceStaNo(), // 源站 |
| | | wrkMast.getSourceLocNo(), // 源库位 |
| | | wrkMast.getBarcode(), // 条码 |
| | | (int) shuttleProtocol.getStatusErrorCode(), // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | "任务中异常" // 备注 |
| | | ); |
| | | if (!basShuttleErrLogService.insert(basShuttleErrLog)) { |
| | | News.error("四向穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName); |
| | | } |
| | | } |
| | | } else { |
| | | // 异常修复 |
| | | if (shuttleProtocol.getStatusErrorCode() == null || shuttleProtocol.getStatusErrorCode() == 0) { |
| | | latest.setEndTime(now); |
| | | latest.setUpdateTime(now); |
| | | latest.setStatus(2); |
| | | if (!basShuttleErrLogService.updateById(latest)) { |
| | | News.error("四向穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId()); |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | //无任务 |
| | | BasShuttleErrLog latest = basShuttleErrLogService.findLatest(shuttleSlave.getId()); |
| | | // 有异常 |
| | | if (shuttleProtocol.getStatusErrorCode() != null && shuttleProtocol.getStatusErrorCode() > 0) { |
| | | // 记录新异常 |
| | | if (latest == null || (latest.getErrCode() != shuttleProtocol.getStatusErrorCode().intValue())) { |
| | | BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getStatusErrorCode().intValue()); |
| | | String errName = basShuttleErr==null? "未知异常":basShuttleErr.getErrName(); |
| | | BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog( |
| | | null, // 编号 |
| | | null, // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | null, // 工作状态 |
| | | null, // 入出库类型 |
| | | shuttleSlave.getId(), // 四向穿梭车 |
| | | null, // plc |
| | | null, // 目标库位 |
| | | null, // 目标站 |
| | | null, // 源站 |
| | | null, // 源库位 |
| | | null, // 条码 |
| | | (int)shuttleProtocol.getStatusErrorCode(), // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | "无任务异常" // 备注 |
| | | ); |
| | | if (!basShuttleErrLogService.insert(basShuttleErrLog)) { |
| | | News.error("四向穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName); |
| | | } |
| | | } |
| | | // 无异常 |
| | | } else { |
| | | // 异常修复 |
| | | if (latest != null && latest.getStatus() == 1) { |
| | | latest.setEndTime(now); |
| | | latest.setUpdateTime(now); |
| | | latest.setStatus(2); |
| | | if (!basShuttleErrLogService.updateById(latest)) { |
| | | News.error("四向穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | } else if (wrkCharge.getWrkSts() == 56) { |
| | | //充电中 |
| | | //判断小车是否充满电量 |
| | | if (shuttleProtocol.getBatteryPower() == 1000) { |
| | | //判断小车是否充满电量,满电1000或电压54V以上 |
| | | if (shuttleProtocol.getBatteryPower() >= 1000 || shuttleProtocol.getCurrentVoltage() >= 540) { |
| | | //充满,断开充电 |
| | | List<ShuttleCommand> commands = new ArrayList<>(); |
| | | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); |