| | |
| | | continue; |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | int signI = 0; |
| | | while (signI<6){ |
| | | Thread.sleep(200); |
| | | signI = signI +1; |
| | | // 获取条码扫描仪信息 |
| | | if (Cools.isEmpty(barcode) || barcode.equals("000000")) { |
| | | devpThread.setErrorDev(staProtocol.getSiteId(), "循环次数:"+signI+";扫码值:"+barcode); |
| | | |
| | | BarcodeThread barcodeThreadO = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | | if (barcodeThreadO == null) { |
| | | continue; |
| | | } |
| | | barcode = barcodeThreadO.getBarcode(); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (!Cools.isEmpty(barcode) && !barcode.equals("99999999") && !barcode.equals("000000")) { |
| | | // 请求wms接口,获取工作号和目标库位 |
| | | ToWmsDTO toWmsDTO = new ToWmsDTO(staProtocol.getSiteId(),staProtocol.getGrossWt(),barcode, workNo == 9998? 0 : 1); |
| | |
| | | staProtocol.setWorkNo(9999); |
| | | staProtocol.setStaNo(inSta.getBackSta()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | devpThread.setErrorDev(staProtocol.getSiteId(), jsonObject.getString("msg")); |
| | | devpThread.setErrorDev(staProtocol.getSiteId(), jsonObject.getString("message")); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | } else { |
| | |
| | | crnCommand.setTaskNo(taskWrk.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosY(crnStn.getBay().shortValue()); // 源库位层 |
| | | crnCommand.setSourcePosZ(crnStn.getLev().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY(crnStn.getBay().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosZ(crnStn.getLev().shortValue()); // 源库位层 |
| | | crnCommand.setDestinationPosX(Utils.getRowShort(taskWrk.getTargetPoint())); // 目标库位列 |
| | | crnCommand.setDestinationPosY(Utils.getBayShort(taskWrk.getTargetPoint())); // 目标库位层 |
| | | int bay1 = Utils.getBayShort(taskWrk.getTargetPoint()) + 1; |
| | | crnCommand.setDestinationPosY((short)bay1); // 目标库位层 |
| | | crnCommand.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint())); // 目标库位排 |
| | | // crnCommand.setCommand((short) 1); |
| | | if (!MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, crnCommand))) { |
| | |
| | | command.setAckFinish((short) 0); // 任务完成确认位 |
| | | command.setTaskMode(CrnTaskModeType.PAKIN); // 任务模式 |
| | | command.setSourcePosX(Utils.getRowShort(taskWrk.getStartPoint())); // 源库位排 |
| | | command.setSourcePosY(Utils.getBayShort(taskWrk.getStartPoint())); // 源库位列 |
| | | int bayS = Utils.getBayShort(taskWrk.getStartPoint()) + 1; |
| | | command.setSourcePosY((short)bayS); // 源库位列 |
| | | command.setSourcePosZ(Utils.getLevShort(taskWrk.getStartPoint())); // 源库位层 |
| | | command.setDestinationPosX(crnStn.getRow().shortValue()); // 目标库位排 |
| | | command.setDestinationPosY(crnStn.getBay().shortValue()); // 目标库位列 |
| | | command.setDestinationPosZ(crnStn.getLev().shortValue()); // 目标库位层 |
| | | command.setCommand((short) 1); |
| | | // command.setCommand((short) 1); |
| | | if (!MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command))) { |
| | | log.error("堆垛机命令生成失败,堆垛机号={},巷道={},任务数据={}", slave.getId(), taskWrk.getCrnNo(), JSON.toJSON(command)); |
| | | devpThread.setErrorDev(staProtocol.getSiteId(), crnProtocol.getLaneNo()+"巷道堆垛机命令生成失败"); |
| | |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(Utils.getRowShort(taskWrk.getStartPoint())); // 源库位排 |
| | | crnCommand.setSourcePosY(Utils.getBayShort(taskWrk.getStartPoint())); // 源库位列 |
| | | int bayS = Utils.getBayShort(taskWrk.getStartPoint()) + 1; |
| | | crnCommand.setSourcePosY((short)bayS); // 源库位列 |
| | | crnCommand.setSourcePosZ(Utils.getLevShort(taskWrk.getStartPoint())); // 源库位层 |
| | | crnCommand.setDestinationPosX(Utils.getRowShort(taskWrk.getTargetPoint())); // 目标库位排 |
| | | crnCommand.setDestinationPosY(Utils.getBayShort(taskWrk.getTargetPoint())); // 目标库位列 |
| | | int bayE = Utils.getBayShort(taskWrk.getTargetPoint()) + 1; |
| | | crnCommand.setDestinationPosY((short)bayE); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint())); // 目标库位层 |
| | | // crnCommand.setCommand((short) 1); |
| | | if (!MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, crnCommand))) { |
| | |
| | | } |
| | | return true; |
| | | } |
| | | public boolean rgvOtherIDLEOther2(RgvSlave slave) { |
| | | RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getOtherId()); |
| | | RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getOtherId()); |
| | | |
| | | if (rgvProtocol == null || rgvTaskProtocol == null) { |
| | | return false; |
| | | } |
| | | if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) |
| | | || rgvProtocol.getRgvPos().equals(0L) |
| | | || rgvTaskProtocol.getAvoid() == -1) { |
| | | return false; |
| | | } |
| | | |
| | | if (rgvProtocol.getLoaded()!=0) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | public boolean rgvOtherIDLE(RgvSlave slave,Integer staNo) { |
| | | RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); |
| | | RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId()); |
| | | |
| | | if (rgvProtocol == null || rgvTaskProtocol == null) { |
| | | return false; |
| | | } |
| | | if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L) || rgvTaskProtocol.getAvoid() == -1 |
| | | || ((!rgvProtocol.getStatusType().equals(RgvStatusType.IDLE) || (Math.abs(rgvProtocol.getRgvPos() - rgvProtocol.getRgvPosDestination())>100)) && !rgvProtocol.getStatusType().equals(RgvStatusType.ROAM))) { |
| | | return false; |
| | | } |
| | | RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId()); |
| | | |
| | | if (rgvProtocolOther == null) { |
| | | return true; |
| | | } |
| | | if (rgvProtocolOther.statusEnable) { |
| | | BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", staNo)); |
| | | if (Math.abs(basDevpPosition.getPlcPosition()-rgvProtocol.getRgvPos()) |
| | | >= |
| | | Math.abs(basDevpPosition.getPlcPosition()-rgvProtocolOther.getRgvPos())){ |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | public boolean rgvOtherIDLE2(RgvSlave slave,Integer staNo) { |
| | | RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); |
| | | RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId()); |
| | | |
| | |
| | | if (!sign && staList.size()==1){ |
| | | if (rgvOtherIDLEOther(rgvSlave)){ |
| | | if (!rgvOtherIDLE(rgvSlave,staList.get(0))){ |
| | | System.out.println("空闲就近跳过==="+rgvSlave.getId()+"==="); |
| | | |
| | | sign=true; |
| | | } |
| | | } |
| | |
| | | Integer outStaNo = BarcodeUtils.getOutStaNo(taskWrk.getOriginTargetPoint()); |
| | | for (RgvSlave.RgvStn rgvSuper : rgvSlave.getRgvSuperSta()){ |
| | | if (rgvSuper.getStaNo().equals(outStaNo)){ |
| | | System.out.println("空闲就近跳过后因最远再次执行==="+rgvSlave.getId()+"==="); |
| | | |
| | | sign=false; |
| | | break; |
| | | } |
| | |
| | | if (taskWrk != null) { |
| | | BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", BarcodeUtils.getOutStaNo(taskWrk.getOriginTargetPoint()))); |
| | | if (RouteUtils.CheckIfItIsWithinTheRange(rangeList, basDevpPosition.getPlcPosition(), basDevpPositions, itSmall)) { |
| | | System.out.println("全范围执行==="+rgvSlave.getId()+"==="+taskWrk); |
| | | System.out.println("全范围执行==="+rgvSlave.getId()+"==="+JSON.toJSONString(belongToRange)); |
| | | |
| | | sign = taskGenerate(rgvSlave, rgvStn, 0); |
| | | } |
| | | } |
| | |
| | | Integer outStaNo = BarcodeUtils.getOutStaNo(taskWrk.getOriginTargetPoint()); |
| | | for (RgvSlave.RgvStn rgvStnOut : rgvSlave.getRgvOutSta()) { |
| | | if (rgvStnOut.getStaNo().equals(outStaNo)) { |
| | | System.out.println("筛选范围内取货任务==="+rgvSlave.getId()+"==="+taskWrk); |
| | | System.out.println("筛选范围内取货任务==="+rgvSlave.getId()+"==="+JSON.toJSONString(belongToRange)); |
| | | |
| | | sign = taskGenerate(rgvSlave, rgvStn, 0); |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if (!sign) { |
| | | if (!sign && staList.size()==1){ |
| | | if (rgvOtherIDLEOther2(rgvSlave)){ |
| | | if (!rgvOtherIDLE2(rgvSlave,staList.get(0))){ |
| | | System.out.println("运行就近跳过==="+rgvSlave.getId()+"==="); |
| | | |
| | | sign=true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!sign && staList.size()>1) { |
| | | for (Integer staNoNow : rangeList) { |
| | | for (RgvSlave.RgvStn rgvStn : rgvSlave.getRgvInSta()) { |
| | | if (rgvStn.getStaNo().equals(staNoNow)) { |
| | |
| | | if (taskWrk != null) { |
| | | BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", BarcodeUtils.getOutStaNo(taskWrk.getOriginTargetPoint()))); |
| | | if (RouteUtils.CheckIfItIsWithinTheRange(rangeList, basDevpPosition.getPlcPosition(), basDevpPositions, itSmall)) { |
| | | System.out.println("筛选半边范围内任务==="+rgvSlave.getId()+"==="+taskWrk); |
| | | System.out.println("筛选半边范围内任务==="+rgvSlave.getId()+"==="+JSON.toJSONString(belongToRange)); |
| | | |
| | | sign = taskGenerate(rgvSlave, rgvStn, 0); |
| | | } |
| | | } |
| | |
| | | Integer outStaNo = BarcodeUtils.getOutStaNo(taskWrk.getOriginTargetPoint()); |
| | | for (RgvSlave.RgvStn rgvStnOut : rgvSlave.getRgvOutSta()) { |
| | | if (rgvStnOut.getStaNo().equals(outStaNo)) { |
| | | System.out.println("筛选半边范围取货任务==="+rgvSlave.getId()+"==="+taskWrk); |
| | | System.out.println("筛选半边范围取货任务==="+rgvSlave.getId()+"==="+JSON.toJSONString(belongToRange)); |
| | | |
| | | sign = taskGenerate(rgvSlave, rgvStn, 0); |
| | | break; |
| | | } |