| | |
| | | public synchronized int[][] getStePositionNearby(Integer siteNo) { |
| | | try { |
| | | List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position", true)); |
| | | if (basDevpPositions.isEmpty()) { |
| | | if (basDevpPositions == null || basDevpPositions.isEmpty()) { |
| | | log.error("获取所有站点信息异常"); |
| | | return null; |
| | | } |
| | |
| | | List<List<Long>> rgvPositionList = new ArrayList<>(); |
| | | for (RgvSlave rgvSlave : slaveProperties.getRgv()) { |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvSlave.getId()); |
| | | if (rgvThread == null) { |
| | | continue; |
| | | } |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | if (rgvProtocol == null || rgvProtocol.getRgvNo() == null || rgvProtocol.getRgvPos() == null) { |
| | | continue; |
| | | } |
| | | List<Long> rgvPosition = new ArrayList<>(); |
| | |
| | | rgvPosition.add(rgvProtocol.getRgvPos()); |
| | | rgvPositionList.add(rgvPosition); |
| | | } |
| | | if (rgvPositionList.isEmpty()) { |
| | | return null; |
| | | } |
| | | Integer rgvNo = SortTheExecutionOfTheCarUtil.LatelyAndGreaterThan(rgvPositionList, sitePosition, perimeter); |
| | | if (rgvNo == -1) { |
| | | log.info("更新小车排序信息异常={}", rgvNo); |
| | | return null; |
| | | } |
| | | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().eq("status", 0).orderBy("rgv_id", true)); |
| | | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true)); |
| | | if (basCircularShuttleList == null || basCircularShuttleList.isEmpty()) { |
| | | return null; |
| | | } |
| | | int[][] ints = new int[basCircularShuttleList.size()][2]; |
| | | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList) { |
| | | if (basCircularShuttle == null || basCircularShuttle.getRgvNo() == null || basCircularShuttle.getRgvId() == null) { |
| | | continue; |
| | | } |
| | | if (basCircularShuttle.getRgvNo() < 1 || basCircularShuttle.getRgvNo() > basCircularShuttleList.size()) { |
| | | continue; |
| | | } |
| | | ints[basCircularShuttle.getRgvNo() - 1] = new int[]{basCircularShuttle.getRgvNo(), basCircularShuttle.getRgvId()}; |
| | | } |
| | | if (basCircularShuttleList.get(0).getRgvNo().equals(rgvNo)) { |
| | | if (basCircularShuttleList.get(0) != null |
| | | && basCircularShuttleList.get(0).getRgvNo() != null |
| | | && basCircularShuttleList.get(0).getRgvNo().equals(rgvNo)) { |
| | | return ints; |
| | | } |
| | | // String[] oldList = new String[ints.length]; |
| | |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | log.error("自动更新小车排序信息失败,异常:" + e); |
| | | log.error("自动更新小车排序信息失败(getStePositionNearby), siteNo={}", siteNo, e); |
| | | } |
| | | return null; |
| | | |
| | |
| | | boolean sign = false; |
| | | Integer rgvNo = 0; |
| | | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true)); |
| | | if (basCircularShuttleList == null || basCircularShuttleList.isEmpty()) { |
| | | return; |
| | | } |
| | | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList) { |
| | | if (basCircularShuttle == null || basCircularShuttle.getRgvNo() == null) { |
| | | sign = true; |
| | | continue; |
| | | } |
| | | if (basCircularShuttle.getStatus() != 0){ |
| | | sign = true; |
| | | continue; |
| | | } |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | if (rgvThread == null) { |
| | | sign = true; |
| | | continue; |
| | | } |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | sign = true; |
| | |
| | | if (sign && rgvNo != 0) { |
| | | int[][] ints = new int[basCircularShuttleList.size()][2]; |
| | | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList) { |
| | | if (basCircularShuttle == null || basCircularShuttle.getRgvNo() == null || basCircularShuttle.getRgvId() == null) { |
| | | continue; |
| | | } |
| | | if (basCircularShuttle.getRgvNo() < 1 || basCircularShuttle.getRgvNo() > basCircularShuttleList.size()) { |
| | | continue; |
| | | } |
| | | ints[basCircularShuttle.getRgvNo() - 1] = new int[]{basCircularShuttle.getRgvNo(), basCircularShuttle.getRgvId()}; |
| | | } |
| | | // String[] oldList = new String[ints.length]; |
| | |
| | | |
| | | // log.info("更新小车排序信息:原始小车号rgvNo={},小车重新排序信息={},小车原始排序信息={}",rgvNo,Arrays.toString(newList),Arrays.toString(oldList)); |
| | | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList) { |
| | | if (basCircularShuttle == null || basCircularShuttle.getRgvNo() == null) { |
| | | continue; |
| | | } |
| | | if (basCircularShuttle.getRgvNo() < 1 || basCircularShuttle.getRgvNo() > rgvList.length) { |
| | | continue; |
| | | } |
| | | int[] rgv = rgvList[basCircularShuttle.getRgvNo() - 1]; |
| | | if (rgv == null || rgv.length < 2) { |
| | | continue; |
| | | } |
| | | basCircularShuttle.setRgvId(rgv[1]); |
| | | basCircularShuttleService.updateById(basCircularShuttle); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("自动更新小车排序信息失败,异常:" + e); |
| | | log.error("自动更新小车排序信息失败(updateStePosition)", e); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", 1)); |
| | | if (basCircularShuttle == null || basCircularShuttle.getRgvNo() == null) { |
| | | return; |
| | | } |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | if (rgvThread == null) { |
| | | return; |
| | | } |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | if (rgvProtocol == null || rgvProtocol.getRgvPos() == null) { |
| | | return; |
| | | } |
| | | List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position", true)); |
| | | List<BasDevpPosition> basDevpPositionDevRegion = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("dev_region", true)); |
| | | if (basDevpPositions == null || basDevpPositions.isEmpty() || basDevpPositionDevRegion == null || basDevpPositionDevRegion.isEmpty()) { |
| | | return; |
| | | } |
| | | Integer devNo = SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPositions, rgvProtocol.getRgvPos(), perimeter); |
| | | BasDevpPosition[] basDevpPositionsList = SortTheExecutionOfTheCarUtil.devpNoSort(basDevpPositions, devNo); |
| | | BasDevpPosition[] basDevpPositionsListUN = SortTheExecutionOfTheCarUtil.devpNoSortUN(basDevpPositionsList); |
| | |
| | | // taskDown(wrkMastLists); |
| | | taskDown(wrkMastListAll); |
| | | } catch (Exception e) { |
| | | log.error("自动下发小车取放任务失败,异常:" + e); |
| | | log.error("自动下发小车任务失败,异常:" + e); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_no", rgvNo)); |
| | | if (basCircularShuttle == null) { |
| | | continue; |
| | | } |
| | | if (basCircularShuttle.getStatus() != 0){ |
| | | continue ; |
| | | } |
| | | long rgvId = basCircularShuttle.getRgvId(); |
| | | |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | if (rgvThread == null) { |
| | | continue; |
| | | } |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | if (rgvProtocol == null || rgvProtocol.getRgvNo() == null || rgvProtocol.getRgvPos() == null) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | && rgvProtocol.modeType == RgvModeType.AUTO |
| | | && (rgvProtocol.getStatusType() == RgvStatusType.IDLE || rgvProtocol.getStatusType() == RgvStatusType.ROAM) |
| | | && rgvProtocol.getTaskNo1() == 0 |
| | | && rgvProtocol.getRgvPosInt() != 0 |
| | | && rgvProtocol.getAlarm() == 0) { |
| | | BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("dev_no", wrkMast.getSourceStaNo())); |
| | | if (basDevpPosition == null || basDevpPosition.getPlcPosition() == null) { |
| | | continue; |
| | | } |
| | | if (basDevpPosition.getPlcPosition()>rgvProtocol.getRgvPos()){ |
| | | if (basDevpPosition.getPlcPosition()-rgvProtocol.getRgvPos()>taskRunPerimeter){ |
| | | if (!rgvNoM.contains(rgvProtocol.getRgvNo())){ |
| | |
| | | } |
| | | |
| | | } catch (Exception e){ |
| | | log.error("RGV漫游启动命令下发失败,任务数据===> "+JSON.toJSON(wrkMastListAll)); |
| | | log.error("RGV取放货启动命令下发失败,任务数据===> "+JSON.toJSON(wrkMastListAll)); |
| | | return; |
| | | } |
| | | try{ |
| | |
| | | continue; |
| | | } |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo); |
| | | if (rgvThread == null) { |
| | | continue; |
| | | } |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | continue; |
| | |
| | | |
| | | //任务完成 |
| | | public synchronized void rgvCompleteWrkMastSta(int[] autoZ) { |
| | | try { |
| | | for (RgvSlave rgvSlave : slaveProperties.getRgv()) { |
| | | for (RgvSlave rgvSlave : slaveProperties.getRgv()) { |
| | | try { |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvSlave.getId()); |
| | | if (rgvThread == null) { |
| | | continue; |
| | | } |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | continue; |
| | |
| | | log.error("{}号RGV尚未在数据库进行维护!", rgvSlave.getId()); |
| | | continue; |
| | | } |
| | | if (rgvProtocol.getStatusType() == RgvStatusType.WAITING) { |
| | | if (rgvProtocol.getStatusType() == RgvStatusType.WAITING || rgvProtocol.getStatusType() == RgvStatusType.WAITING101) { |
| | | log.info("{}号小车等待wcs确认,状态{},参数{}", rgvProtocol.getRgvNo(), rgvProtocol.getStatusType(), rgvProtocol); |
| | | } |
| | | // 只有当RGV等待WCS确认、自动 |
| | |
| | | && rgvProtocol.getTaskNo1() != 0 |
| | | ) { |
| | | // log.info("{}号小车等待wcs确认,状态{},参数{}",rgvProtocol.getRgvNo(),rgvProtocol.getStatusType(),rgvProtocol); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", rgvProtocol.getTaskNo1().longValue())); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", rgvProtocol.getTaskNo1().longValue()).eq("rgv_no",rgvProtocol.getRgvNo())); |
| | | if (Cools.isEmpty(wrkMast) || !wrkMast.getWrkSts().equals(2L)) { |
| | | log.error("未查到小车执行任务或者执行任务状态不符合!" + wrkMast); |
| | | continue; |
| | |
| | | } |
| | | } catch (Exception e){} |
| | | wrkMastService.updateById(wrkMast); |
| | | } else if (rgvProtocol.getStatusType() == RgvStatusType.WAITING101 |
| | | && rgvProtocol.getModeType() == RgvModeType.AUTO |
| | | && rgvProtocol.getTaskNo1() != 0 |
| | | ){ |
| | | boolean rgvComplete = rgvComplete(rgvProtocol.getRgvNo()); |
| | | if (!rgvComplete) { |
| | | log.error("小车复位失败,小车号{}!", rgvProtocol.getRgvNo()); |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("小车复位线程报错!" + e); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("小车复位线程报错!" + e); |
| | | } |
| | | } |
| | | public synchronized void rgvCancelWrkMastSta() { |
| | | for (RgvSlave rgvSlave : slaveProperties.getRgv()) { |
| | | try { |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvSlave.getId()); |
| | | if (rgvThread == null) { |
| | | continue; |
| | | } |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | continue; |
| | | } |
| | | if (rgvProtocol.getStatusType() == RgvStatusType.CANCEL) { |
| | | log.info("{}号小车等待wcs取消,状态{},参数{}", rgvProtocol.getRgvNo(), rgvProtocol.getStatusType(), rgvProtocol); |
| | | } |
| | | // 只有当RGV等待WCS确认、自动 |
| | | if (rgvProtocol.getStatusType() == RgvStatusType.CANCEL |
| | | && rgvProtocol.getModeType() == RgvModeType.AUTO |
| | | && rgvProtocol.getTaskNo1() != 0 |
| | | ) { |
| | | |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | | rgvCommand.setRgvNo(rgvProtocol.getRgvNo()); |
| | | rgvCommand.setAckFinish1((short) 0); // 工位1任务完成确认位 |
| | | rgvCommand.setTaskNo1(rgvProtocol.getTaskNo1()); |
| | | rgvCommand.setTaskMode1(RgvTaskModeType.CANCEL); // 工位1任务模式: 取消 |
| | | rgvCommand.setSourceStaNo1((short)-1); //工位1起点 |
| | | rgvCommand.setDestinationStaNo1((short)-1); //工位1目标站点 |
| | | // rgvCommand.setCommand((short) 1); //工位1任务确认 |
| | | // rgvCommand.setRgvSome((short) 1); |
| | | if (!MessageQueue.offer(SlaveType.Rgv, rgvProtocol.getRgvNo(), new Task(4, rgvCommand))) { |
| | | // |
| | | log.error("RGV取消命令下发失败,RGV号={},任务数据={}", rgvProtocol.getRgvNo(), JSON.toJSON(rgvCommand)); |
| | | // wrkMast.setLogErrTime(new Date()); |
| | | // wrkMast.setLogErrMemo("RGV取消命令下发失败,RGV号={"+rgvProtocol.getRgvNo()+"}===>跳过"); |
| | | // wrkMastService.updateById(wrkMast); |
| | | continue; |
| | | } |
| | | log.info("RGV取消命令下发成功,RGV号={},任务数据={}", rgvProtocol.getRgvNo(), JSON.toJSON(rgvCommand)); |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", rgvCommand.getTaskNo1().longValue()).eq("rgv_no",rgvCommand.getRgvNo())); |
| | | if (Cools.isEmpty(wrkMast) || !wrkMast.getWrkSts().equals(2L)) { |
| | | log.error("未查到小车执行任务或者执行任务状态不符合!" + wrkMast); |
| | | continue; |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(1L); |
| | | wrkMast.setRgvNo(0); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setLogErrTime(now); |
| | | |
| | | wrkMast.setLogErrMemo("RGV申请取消任务,RGV号={"+rgvProtocol.getRgvNo()+"},取消时间:"+now); |
| | | |
| | | wrkMastService.updateById(wrkMast); |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("小车取消线程报错!" + e); |
| | | } |
| | | } |
| | | } |
| | | |