| | |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.CollectionUtils; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.common.utils.RgvUtils; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | private BasRgvErrLogService basRgvErrLogService; |
| | | @Autowired |
| | | private BasRgvPathService basRgvPathService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | continue; |
| | | } |
| | | |
| | | //判断行走路径是否被占用 |
| | | Integer staNo = wrkMast.getSourceStaNo(); |
| | | BasDevp basDevp = basDevpService.selectById(staNo); |
| | | if (basDevp == null) { |
| | | continue;//目标站不存在 |
| | | } |
| | | //起始路径 |
| | | int startPath = rgvProtocol.getRgvPos().intValue(); |
| | | //目标路径值 |
| | | int endPath = basDevp.getLocType3().intValue(); |
| | | boolean pathUsed = RgvUtils.isPathUsed(startPath, endPath);//判断行走路径是否被占用 |
| | | if (pathUsed) { |
| | | //行走路径被占用,禁止下发命令 |
| | | continue; |
| | | } |
| | | //行走路径空闲,锁定路径 |
| | | RgvUtils.lockPath(startPath, endPath, rgvProtocol.getRgvNo(), wrkMast.getWrkNo(), true); |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | | rgvCommand.setRgvNo(wrkMast.getRgvNo()); // RGV编号 |
| | |
| | | continue; |
| | | } |
| | | |
| | | //判断行走路径是否被占用 |
| | | Integer staNo = wrkMast.getStaNo(); |
| | | BasDevp basDevp = basDevpService.selectById(staNo); |
| | | if (basDevp == null) { |
| | | continue;//目标站不存在 |
| | | } |
| | | //起始路径 |
| | | int startPath = rgvProtocol.getRgvPos().intValue(); |
| | | //目标路径值 |
| | | int endPath = basDevp.getLocType3().intValue(); |
| | | boolean pathUsed = RgvUtils.isPathUsed(startPath, endPath);//判断行走路径是否被占用 |
| | | if (pathUsed) { |
| | | //行走路径被占用,禁止下发命令 |
| | | continue; |
| | | } |
| | | //行走路径空闲,锁定路径 |
| | | RgvUtils.lockPath(startPath, endPath, rgvProtocol.getRgvNo(), wrkMast.getWrkNo(), true); |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | | rgvCommand.setRgvNo(wrkMast.getRgvNo()); // RGV编号 |
| | |
| | | if (rgvProtocol.getTaskNo1() != 0 || rgvProtocol.getLoaded1() != 0) {//RGV是否无任务、RGV是否无货 |
| | | continue; |
| | | } |
| | | |
| | | //判断行走路径是否被占用 |
| | | Integer staNo = wrkMast.getSourceStaNo(); |
| | | BasDevp basDevp = basDevpService.selectById(staNo); |
| | | if (basDevp == null) { |
| | | continue;//目标站不存在 |
| | | } |
| | | //起始路径 |
| | | int startPath = rgvProtocol.getRgvPos().intValue(); |
| | | //目标路径值 |
| | | int endPath = basDevp.getLocType3().intValue(); |
| | | boolean pathUsed = RgvUtils.isPathUsed(startPath, endPath);//判断行走路径是否被占用 |
| | | if (pathUsed) { |
| | | //行走路径被占用,禁止下发命令 |
| | | continue; |
| | | } |
| | | //行走路径空闲,锁定路径 |
| | | RgvUtils.lockPath(startPath, endPath, rgvProtocol.getRgvNo(), wrkMast.getWrkNo(), true); |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | |
| | | if (rgvProtocol.getLoaded1() == 0) {//RGV必须有物 |
| | | continue; |
| | | } |
| | | |
| | | //判断行走路径是否被占用 |
| | | Integer staNo = wrkMast.getStaNo(); |
| | | BasDevp basDevp = basDevpService.selectById(staNo); |
| | | if (basDevp == null) { |
| | | continue;//目标站不存在 |
| | | } |
| | | //起始路径 |
| | | int startPath = rgvProtocol.getRgvPos().intValue(); |
| | | //目标路径值 |
| | | int endPath = basDevp.getLocType3().intValue(); |
| | | boolean pathUsed = RgvUtils.isPathUsed(startPath, endPath);//判断行走路径是否被占用 |
| | | if (pathUsed) { |
| | | //行走路径被占用,禁止下发命令 |
| | | continue; |
| | | } |
| | | //行走路径空闲,锁定路径 |
| | | RgvUtils.lockPath(startPath, endPath, rgvProtocol.getRgvNo(), wrkMast.getWrkNo(), true); |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | |
| | | wrkMast1.setWrkSts(27L);//27.RGV放货完成 |
| | | } |
| | | |
| | | //解锁路径 |
| | | RgvUtils.unLockPath(wrkMast1.getRgvNo()); |
| | | |
| | | wrkMast1.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast1) == 0) { |
| | | log.error("工位1修改工作档状态失败!!,工作号={}", wrkMast1.getWrkNo()); |
| | | } |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | | rgvCommand.setRgvNo(rgv.getId()); // RGV编号 |
| | | rgvCommand.setAckFinish1((short) 1); // 工位1任务完成确认位 |
| | | rgvCommand.setTaskNo1(wrkMast1.getWrkNo().shortValue()); // 工位1工作号 |
| | | rgvCommand.setTaskMode1(RgvTaskModeType.NONE); // 工位1任务模式: 无 |
| | | rgvCommand.setCommand((short) 1); //工位1任务确认 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast1.getRgvNo(), new Task(4, rgvCommand))) { |
| | | //step=2,工位1、2任务确认; step=4,工位1确认; step=5,工位2任务确认 |
| | | log.error("RGV命令下发失败,RGV号={},任务数据={}", rgv.getId(), JSON.toJSON(rgvCommand)); |
| | | } |
| | | |
| | | // //工位1取货完成后,工位2是无货空闲状态时,准备给工位2发任务,确认是否有待执行RGV任务 |
| | |
| | | * 初始化RGV地图 |
| | | */ |
| | | public synchronized void initRgvMap() { |
| | | |
| | | Object data = redisUtil.get("rgv_map"); |
| | | if (data == null) { |
| | | //重新获取全路径地图 |
| | | BasRgvPath basRgvPath = basRgvPathService.selectByRgvNo(0);//获取默认路径 |
| | | if (basRgvPath != null) { |
| | | ArrayList<RgvNode> rgvNodes = new ArrayList<>(); |
| | | List<Integer> rgvPath = JSON.parseArray(basRgvPath.getPath(), Integer.class); |
| | | for (Integer integer : rgvPath) { |
| | | RgvNode rgvNode = new RgvNode(integer); |
| | | rgvNodes.add(rgvNode); |
| | | } |
| | | //将数据库地图数据存入redis |
| | | redisUtil.set("rgv_map", JSON.toJSONString(rgvNodes)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |