王佳豪
2021-06-19 fbe04d16ac7027bc794f2196108be7080ed57d90
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -327,30 +327,35 @@
        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 {
            // 源站点状态检测
@@ -474,6 +479,13 @@
        if (Cools.isEmpty(param.getOutSite())) {
            throw new CoolException("站点不存在");
        }
        // 目标站点状态检测
        BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite());
        int agvSite = 0;
        if (!Cools.isEmpty(staNo.getFronting()) && staNo.getFronting().equals("Y")) {
            agvSite = staNo.getDevNo();
            staNo = basDevpService.checkSiteStatus(201);
        }
        for (String locNo : param.getLocNos()) {
            // 获取工作号
            int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
@@ -485,7 +497,7 @@
            // 获取源站
            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                    .eq("type_no", 110)
                    .eq("stn_no", param.getOutSite())
                    .eq("stn_no", staNo.getDevNo())
                    .eq("crn_no", locMast.getCrnNo());
            StaDesc staDesc = staDescService.selectOne(wrapper);
            Integer sourceStaNo = staDesc.getCrnStn();
@@ -500,7 +512,7 @@
            wrkMast.setIoType(110); // 入出库状态: 110.空板出库
            wrkMast.setIoPri(10D);
            wrkMast.setSourceStaNo(sourceStaNo); // 源站
            wrkMast.setStaNo(param.getOutSite()); // 目标站
            wrkMast.setStaNo(staNo.getDevNo()); // 目标站
            wrkMast.setCrnNo(locMast.getCrnNo());
            wrkMast.setSourceLocNo(locNo); // 源库位
            wrkMast.setFullPlt("N"); // 满板:Y
@@ -508,6 +520,8 @@
            wrkMast.setExitMk("N"); // 退出
            wrkMast.setEmptyMk("Y"); // 空板
            wrkMast.setLinkMis("N");
            wrkMast.setCtnKind(agvSite); // 出库下的小车工作区站好
            wrkMast.setExitMk("N"); // 小车是否搬运
            wrkMast.setAppeUser(userId);
            wrkMast.setAppeTime(new Date());
            wrkMast.setModiUser(userId);