| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | |
| | | param.setBarcode(barcode); |
| | | param.setIoType(1); |
| | | param.setSourceStaNo(inSta.getStaNo()); |
| | | // param.setLocType1(locTypeDto.getLocType1()); |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/pakin/loc/v1") |
| | |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | // // plc 处理 |
| | | // barcodeThread.setBarcode(""); |
| | | // plc 处理 |
| | | barcodeThread.setBarcode(""); |
| | | // staProtocol.setWorkNo(dto.getWorkNo().shortValue()); |
| | | // staProtocol.setStaNo(dto.getStaNo().shortValue()); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | |
| | | } |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isLoading() |
| | | && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999) |
| | | && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue()) |
| | | // && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999) |
| | | // && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue()) |
| | | && staProtocol.isPakMk()){ |
| | | |
| | | // 获取条码扫描仪信息 |
| | |
| | | } |
| | | |
| | | String sourceLocNo = wrkMast.getSourceLocNo().trim(); |
| | | LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站 |
| | | if (liftStaProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | | wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站 |
| | | wrkMast.setStaNo(dto.getStaNo()); // 目标站 |
| | | wrkMast.setCrnNo(dto.getCrnNo()); |
| | | // wrkMast.setStaNo(dto.getStaNo()); // 目标站 |
| | | // wrkMast.setCrnNo(dto.getCrnNo()); |
| | | wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站 |
| | | wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setShuttleNo(null); // 穿梭车清空 |
| | | wrkMast.setModiTime(new Date()); |
| | |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | } |
| | | // // 更新站点信息 且 下发plc命令 |
| | | // staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | // staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // if (!result) { |
| | | // News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | // } |
| | | |
| | | barcodeThread.setBarcode("");//清理条码 |
| | | |
| | | } else if (code == 500){ |
| | | if (ledThread != null) { |
| | |
| | | } |
| | | News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } else { |
| | | staProtocol.setWorkNo((short) 32002); |
| | | staProtocol.setStaNo(pickSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // staProtocol.setWorkNo((short) 32002); |
| | | // staProtocol.setStaNo(pickSta.getBackSta().shortValue()); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | |
| | | //判断小车令牌是否未被占领 |
| | | if (shuttleProtocol.getToken() != 0) { |
| | | return false;//小车已被独占,禁止再派发任务 |
| | | } |
| | | |
| | | //判断小车是否存在移动任务 |
| | | WrkMast hasMoveWorking = wrkMastMapper.selectShuttleHasMoveWorking(wrkMast.getShuttleNo()); |
| | | if (hasMoveWorking != null) { |
| | | return false;//存在移动任务,禁止执行入库任务 |
| | | } |
| | | |
| | | //判断小车是否到达输送站点库位 |
| | |
| | | |
| | | //获取提升机命令 |
| | | NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo()); |
| | | if (wrkMast.getIoType() == 53) { |
| | | //拣料再回库,重新分配设备工作号 |
| | | Random random = new Random(); |
| | | int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//获取设备工作号 |
| | | liftCommand.setTaskNo((short) deviceWrk); |
| | | } |
| | | ArrayList<NyLiftCommand> commands = new ArrayList<>(); |
| | | commands.add(liftCommand); |
| | | |
| | |
| | | } |
| | | |
| | | //调度小车避让 |
| | | boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getLocNo()), wrkMast.getShuttleNo(), shuttleThread); |
| | | boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getShuttleNo(), shuttleThread); |
| | | if (!result) { |
| | | return false; |
| | | } |
| | |
| | | case 3://3.提升机搬运中 ==> 4.提升机搬运完成 |
| | | wrkMast.setWrkSts(4L); |
| | | wrkMast.setLiftNo(null);//释放提升机 |
| | | if (liftProtocol.getToken() == wrkMast.getWrkNo()) { |
| | | if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { |
| | | //释放提升机令牌 |
| | | liftProtocol.setToken(0); |
| | | } |
| | |
| | | //释放提升机令牌 |
| | | liftProtocol.setToken(0); |
| | | } |
| | | |
| | | if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { |
| | | //不需要用到机械臂,直接转29.出库完成 |
| | | wrkMast.setWrkSts(29L); |
| | | } |
| | | |
| | | break; |
| | | case 106://106.提升机搬运中 ==> 107.提升机搬运完成 |
| | | wrkMast.setWrkSts(107L); |
| | |
| | | } |
| | | } |
| | | |
| | | if (!Cools.isEmpty(barcode)) { |
| | | WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//条码存在工作档 |
| | | if (wrkMast != null) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); |
| | | |
| | | try { |
| | |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | barcodeThread.setBarcode(""); |
| | | // // 更新站点信息 且 下发plc命令 |
| | | // staProtocol.setWorkNo(dto.getWorkNo().shortValue()); |
| | | // staProtocol.setStaNo(dto.getStaNo().shortValue()); |
| | |
| | | |
| | | targetSta = (short) 317; |
| | | |
| | | //覆盖工作档目标站 |
| | | wrkMast.setStaNo(targetSta.intValue()); |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //向300站写入目标站 |
| | | staProtocol = staProtocol.clone(); |
| | | staProtocol.setStaNo(targetSta);//移动到目标站 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | try { |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) { |
| | | //覆盖工作档目标站 |
| | | wrkMast.setStaNo(targetSta.intValue()); |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //向300站写入目标站 |
| | | staProtocol = staProtocol.clone(); |
| | | staProtocol.setStaNo(targetSta);//移动到目标站 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | try { |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | continue; |
| | | } |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | //获取小车到输送站点行走命令 |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo()); |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id); |
| | | List<NyShuttleHttpCommand> commands = result.getCommands(); |
| | | |
| | | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); |
| | |
| | | NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), sourceLiftSta.getStaNo(), wrkMast.getWrkNo()); |
| | | |
| | | Random random = new Random(); |
| | | liftCommand.setTaskNo((short) Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999))));//更换随机任务号 |
| | | int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//获取设备工作号 |
| | | liftCommand.setTaskNo((short) deviceWrk);//更换随机任务号 |
| | | |
| | | ArrayList<NyLiftCommand> commands = new ArrayList<>(); |
| | | commands.add(liftCommand); |
| | |
| | | // NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY()); |
| | | // liftNode.setZ(basLift.getPoint$().getZ()); |
| | | |
| | | //小车已经在目标库位,直接认定小车移动任务完成 |
| | | if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) { |
| | | wrkMast.setWrkSts(111L);//111.小车移动完成 |
| | | wrkMast.setLiftNo(null);//释放提升机 |
| | | wrkMast.setModiTime(now); |
| | | wrkMastMapper.updateById(wrkMast); |
| | | return false; |
| | | } |
| | | |
| | | //获取小车到目标库位命令 |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo()); |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id); |
| | | if (result == null) { |
| | | return false;//路径计算失败 |
| | | } |