| | |
| | | BasDevp staNo = basDevpService.checkSiteStatus(devpNo); |
| | | if (!Cools.isEmpty(staNo.getFronting()) && staNo.getFronting().equals("Y")) { |
| | | // 小车入库搬运命令 ---------------------------------------------------- |
| | | BasAgv idleAgv = basAgvService.selectIdleAgv(); |
| | | AgvCommand command = new AgvCommand(); |
| | | command.setAgvId(idleAgv.getAgvId()); |
| | | command.setInterCode(basAgvService.getEmptyAgvWorkNo()); |
| | | command.setBeginLoc(String.valueOf(devpNo)); |
| | | command.setEndLoc("1088"); |
| | | log.info(JSON.toJSONString(command)); |
| | | String result; |
| | | try { |
| | | result = new HttpHandler.Builder() |
| | | .setUri(agvUrl + "/api/interfaceTask/SendTaskByThirdParty") |
| | | .setJson(JSON.toJSONString(command)) |
| | | .build() |
| | | .doPost(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | throw new CoolException("访问AGV接口失败"); |
| | | // 判断是否有空闲小车 |
| | | if (basAgvService.haveIdleAgv()) { |
| | | AgvCommand command = new AgvCommand(); |
| | | command.setAgvId(0); |
| | | command.setInterCode(basAgvService.getEmptyAgvWorkNo()); |
| | | command.setBeginLoc(String.valueOf(devpNo)); |
| | | command.setEndLoc("1088"); |
| | | log.info(JSON.toJSONString(command)); |
| | | String result; |
| | | try { |
| | | result = new HttpHandler.Builder() |
| | | .setUri(agvUrl + "/api/interfaceTask/SendTaskByThirdParty") |
| | | .setJson(JSON.toJSONString(command)) |
| | | .build() |
| | | .doPost(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | throw new CoolException("访问AGV接口失败"); |
| | | } |
| | | AgvResult agvResult = JSON.parseObject(result, AgvResult.class); |
| | | log.info(JSON.toJSONString(agvResult)); |
| | | if (!agvResult.getResult()) { |
| | | log.error("agv命令发送失败[agvId={}],错误信息={}", command.getAgvId(), agvResult.getExplain()); |
| | | throw new CoolException("agv命令发送失败[agvId=" + command.getAgvId() + "],错误信息=" + agvResult.getExplain()); |
| | | } |
| | | } else { |
| | | throw new CoolException("没有空闲小车"); |
| | | } |
| | | AgvResult agvResult = JSON.parseObject(result, AgvResult.class); |
| | | log.info(JSON.toJSONString(agvResult)); |
| | | if (!agvResult.getResult()) { |
| | | log.error("agv命令发送失败[agvId={}],错误信息={}", command.getAgvId(), agvResult.getExplain()); |
| | | throw new CoolException("agv命令发送失败[agvId=" + command.getAgvId() + "],错误信息=" + agvResult.getExplain()); |
| | | } |
| | | |
| | | return "待定"; |
| | | } else { |
| | | // 源站点状态检测 |