王佳豪
2021-06-05 b0cede2d821dddcbc519df5be14b6f5045dd4eca
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -190,6 +190,33 @@
            }
            // 小车入库搬运命令 ----------------------------------------------------
            if (!Cools.isEmpty(param.getCombMats()) && !Cools.isEmpty(param.getAgvSite())) {
                BasAgv idleAgv = basAgvService.selectIdleAgv();
                AgvCommand command = new AgvCommand();
                command.setAgvId(idleAgv.getAgvId());
                command.setInterCode(basAgvService.getAgvWorkNo());
                command.setBeginLoc(String.valueOf(param.getAgvSite()));
                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());
                }
            }
        }
@@ -268,6 +295,33 @@
            }
        }
        // 小车入库搬运命令 ----------------------------------------------------
        if (!Cools.isEmpty(param.getCombMats()) && !Cools.isEmpty(param.getAgvSite())) {
            BasAgv idleAgv = basAgvService.selectIdleAgv();
            AgvCommand command = new AgvCommand();
            command.setAgvId(idleAgv.getAgvId());
            command.setInterCode(basAgvService.getAgvWorkNo());
            command.setBeginLoc(String.valueOf(param.getAgvSite()));
            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());
            }
        }
    }