自动化立体仓库 - WCS系统
#
Junjie
2023-11-14 dd91c85493463db1968e6e7a61c841d20f948cf6
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -25,6 +25,8 @@
import com.zy.core.model.protocol.*;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.*;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -104,6 +106,10 @@
    private WrkMastLocMapper wrkMastLocMapper;
    @Autowired
    private BasLiftOptService basLiftOptService;
    @Autowired
    private ConfigService configService;
    @Autowired
    private NavigateMapUtils navigateMapUtils;
    /**
@@ -467,116 +473,155 @@
                        continue;
                    }
                    try {
                        // 访问 WMS 获取入库库位
                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
                        SearchLocParam param = new SearchLocParam();
                        param.setWrkNo(wrkMast.getWrkNo());
                        param.setIoType(wrkMast.getIoType());
                        param.setSourceStaNo(pickSta.getStaNo());
//                        param.setLocType1(locTypeDto.getLocType1());
                        String response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath("/rpc/pakin/loc/v1")
                                .setJson(JSON.toJSONString(param))
                                .build()
                                .doPost();
                        JSONObject jsonObject = JSON.parseObject(response);
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                        Integer code = jsonObject.getInteger("code");
                        if (code.equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                    // 保存工作主档历史档
                    if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
                        throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败");
                    }
//                            // 获取目标站
//                            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
//                                    .eq("type_no", wrkMast.getIoType() - 50)
//                                    .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站
//                                    .eq("crn_no", dto.getCrnNo()); // 堆垛机号
//                            StaDesc staDesc = staDescService.selectOne(wrapper);
//                            if (Cools.isEmpty(staDesc)) {
//                                News.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
//                                continue;
//                            }
//                            // 堆垛机站点(目标站)
//                            Integer staNo = staDesc.getCrnStn();
                    String sourceLocNo = wrkMast.getSourceLocNo().trim();
                    LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站
                    if (liftStaProtocol == null) {
                        continue;
                    }
                            // 保存工作明细档历史档
//                        if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
//                            throw new CoolException("保存工作明细档历史档失败");
//                        }
                            // 保存工作主档历史档
                            if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
                                throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败");
                            }
                            String sourceLocNo = wrkMast.getSourceLocNo().trim();
                            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站
                            if (liftStaProtocol == null) {
                                continue;
                            }
                            // 更新工作档数据状态
                            wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57
                            wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走
                            wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站
                    // 更新工作档数据状态
                    wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57
                    wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走
                    wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站
//                            wrkMast.setStaNo(dto.getStaNo()); // 目标站
//                            wrkMast.setCrnNo(dto.getCrnNo());
                            wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站
                            wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位
                            wrkMast.setShuttleNo(null); // 穿梭车清空
                            wrkMast.setModiTime(new Date());
                            if (wrkMastMapper.updateById(wrkMast) == 0) {
                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
                            }
                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
                            }
                            // 修改库位状态 Q.拣料/盘点/并板再入库
                            LocMast locMast = locMastService.selectById(sourceLocNo);
                            locMast.setLocSts("Q");
                            locMast.setModiTime(new Date());
                            if (!locMastService.updateById(locMast)) {
                                throw new CoolException("修改库位状态失败");
                            }
//                            // 更新站点信息 且 下发plc命令
//                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
//                            staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
//                            devpThread.setPakMk(staProtocol.getSiteId(), false);
//                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                            if (!result) {
//                                News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
//                            }
                            barcodeThread.setBarcode("");//清理条码
                        } else if (code == 500){
                            if (ledThread != null) {
                                String errorMsg = jsonObject.getString("msg");
                                if (!Cools.isEmpty(errorMsg)) {
                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                                }
                            }
                            News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                        } else {
//                            staProtocol.setWorkNo((short) 32002);
//                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
//                            devpThread.setPakMk(staProtocol.getSiteId(), false);
//                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            // led 异常显示
                            if (ledThread != null) {
                                String errorMsg = jsonObject.getString("msg");
//                                String errorMsg = barcode + "托盘识别异常,请先进行组托!";
                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站
                    wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位
                    wrkMast.setShuttleNo(null); // 穿梭车清空
                    wrkMast.setLiftNo(null);// 提升机清空
                    wrkMast.setModiTime(new Date());
                    if (wrkMastMapper.updateById(wrkMast) == 0) {
                        throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
                    }
                    if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
                        throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
                    }
                    // 修改库位状态 Q.拣料/盘点/并板再入库
                    LocMast locMast = locMastService.selectById(sourceLocNo);
                    locMast.setLocSts("Q");
                    locMast.setModiTime(new Date());
                    if (!locMastService.updateById(locMast)) {
                        throw new CoolException("修改库位状态失败");
                    }
                    barcodeThread.setBarcode("");//清理条码
//                    try {
//                        // 访问 WMS 获取入库库位
//                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
//                        SearchLocParam param = new SearchLocParam();
//                        param.setWrkNo(wrkMast.getWrkNo());
//                        param.setIoType(wrkMast.getIoType());
//                        param.setSourceStaNo(pickSta.getStaNo());
////                        param.setLocType1(locTypeDto.getLocType1());
//                        String response = new HttpHandler.Builder()
//                                .setUri(wmsUrl)
//                                .setPath("/rpc/pakin/loc/v1")
//                                .setJson(JSON.toJSONString(param))
//                                .build()
//                                .doPost();
//                        JSONObject jsonObject = JSON.parseObject(response);
//                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
//                        Integer code = jsonObject.getInteger("code");
//                        if (code.equals(200)) {
//                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
//
////                            // 获取目标站
////                            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
////                                    .eq("type_no", wrkMast.getIoType() - 50)
////                                    .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站
////                                    .eq("crn_no", dto.getCrnNo()); // 堆垛机号
////                            StaDesc staDesc = staDescService.selectOne(wrapper);
////                            if (Cools.isEmpty(staDesc)) {
////                                News.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
////                                continue;
////                            }
////                            // 堆垛机站点(目标站)
////                            Integer staNo = staDesc.getCrnStn();
//
//                            // 保存工作明细档历史档
////                        if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
////                            throw new CoolException("保存工作明细档历史档失败");
////                        }
//                            // 保存工作主档历史档
//                            if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
//                                throw new CoolException(wrkMast.getWrkNo() + "保存工作主档历史档失败");
//                            }
//
//                            String sourceLocNo = wrkMast.getSourceLocNo().trim();
//                            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//获取回库提升机目标站
//                            if (liftStaProtocol == null) {
//                                continue;
//                            }
//
//                            // 更新工作档数据状态
//                            wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57
//                            wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走
//                            wrkMast.setSourceStaNo(pickSta.getStaNo()); // 源站
////                            wrkMast.setStaNo(dto.getStaNo()); // 目标站
////                            wrkMast.setCrnNo(dto.getCrnNo());
//                            wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站
//                            wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位
//                            wrkMast.setShuttleNo(null); // 穿梭车清空
//                            wrkMast.setLiftNo(null);// 提升机清空
//                            wrkMast.setModiTime(new Date());
//                            if (wrkMastMapper.updateById(wrkMast) == 0) {
//                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
//                            }
//                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
//                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
//                            }
//
//                            // 修改库位状态 Q.拣料/盘点/并板再入库
//                            LocMast locMast = locMastService.selectById(sourceLocNo);
//                            locMast.setLocSts("Q");
//                            locMast.setModiTime(new Date());
//                            if (!locMastService.updateById(locMast)) {
//                                throw new CoolException("修改库位状态失败");
//                            }
//
////                            // 更新站点信息 且 下发plc命令
////                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
////                            staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
////                            devpThread.setPakMk(staProtocol.getSiteId(), false);
////                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
////                            if (!result) {
////                                News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
////                            }
//
//                            barcodeThread.setBarcode("");//清理条码
//
//                        } else if (code == 500){
//                            if (ledThread != null) {
//                                String errorMsg = jsonObject.getString("msg");
//                                if (!Cools.isEmpty(errorMsg)) {
//                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
//                                }
//                            }
//                            News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
//                        } else {
////                            staProtocol.setWorkNo((short) 32002);
////                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
////                            devpThread.setPakMk(staProtocol.getSiteId(), false);
////                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//
//                            // led 异常显示
//                            if (ledThread != null) {
//                                String errorMsg = jsonObject.getString("msg");
////                                String errorMsg = barcode + "托盘识别异常,请先进行组托!";
//                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
//                            }
//                        }
//
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//                    }
                }
            }
@@ -589,7 +634,7 @@
     */
    public synchronized void initRealtimeBasMap() {
        for (int i = 1; i <= 10; i++) {//总共四层楼
            Object data = redisUtil.get("realtimeBasMap_" + i);
            Object data = redisUtil.get(RedisKeyType.MAP.key + i);
            if (data == null) {//redis地图数据为空,从数据库中获取
                BasMap basMap = basMapService.selectLatestMap(i);
                if (basMap == null) {
@@ -611,7 +656,7 @@
                }
                //将数据库地图数据存入redis
                redisUtil.set("realtimeBasMap_" + i, JSON.toJSONString(basMap));
                redisUtil.set(RedisKeyType.MAP.key + i, JSON.toJSONString(basMap));
            }
        }
    }
@@ -622,7 +667,7 @@
    public synchronized void restartTaskFromRedis() {
        HashMap<Object, Object> map = redisUtil.getRedis();
        for (Object key : map.keySet()) {
            if (key.toString().contains("lift_wrk_no_")) {//提升机任务
            if (key.toString().contains(RedisKeyType.LIFT.key)) {//提升机任务
                LiftRedisCommand redisCommand = JSON.parseObject(map.get(key).toString(), LiftRedisCommand.class);
                if (redisCommand == null) {
                    continue;
@@ -645,7 +690,7 @@
                liftProtocol.setTaskNo(redisCommand.getWrkNo());//将提升机线程分配任务号
                liftProtocol.setProtocolStatus(LiftProtocolStatusType.WORKING);//工作状态
            }else if(key.toString().contains("shuttle_wrk_no_")){//四向穿梭车任务
            }else if(key.toString().contains(RedisKeyType.SHUTTLE.key)){//四向穿梭车任务
                ShuttleRedisCommand redisCommand = JSON.parseObject(map.get(key).toString(), ShuttleRedisCommand.class);
                if (redisCommand == null) {
                    continue;
@@ -854,6 +899,12 @@
            if (!basDevp.getOutEnable().equals("Y")) {
                return false;//出库站点不可出
            }
            Integer liftNo = basDevp.getLiftNo();//搜索出库提升机是否存在入库任务,如存在禁止出库
            List<WrkMast> liftWrkMasts = wrkMastMapper.selectInWrkMastByLiftNo(liftNo);
            if (!liftWrkMasts.isEmpty()) {
                return false;//存在入库任务,禁止出库
            }
            //获取源站
@@ -1102,6 +1153,18 @@
                return false;//站点不可入
            }
            //判断提升机整个三楼是否都处于入库模式
            Integer outInModel1 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 1);
            Integer outInModel2 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 5);
            Integer outInModel3 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 8);
            if (outInModel1 == null || outInModel2 == null || outInModel3 == null) {
                return false;//不存在出入库模式
            }
            if (outInModel1 == 2 || outInModel2 == 2 && outInModel3 == 2) {
                return false;//只要有一个处于出库模式,禁止入库
            }
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, sourceBasDevp.getLiftNo());
            if (liftThread == null) {
                return false;
@@ -1150,7 +1213,7 @@
            //获取提升机命令
            NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
            if (wrkMast.getIoType() == 53) {
            if (wrkMast.getIoType() == 53 || wrkMast.getIoType() == 57) {
                //拣料再回库,重新分配设备工作号
                Random random = new Random();
                int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//获取设备工作号
@@ -1323,6 +1386,8 @@
                                if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) {
                                    //不需要用到机械臂,直接转29.出库完成
                                    wrkMast.setWrkSts(29L);
                                    wrkMast.setShuttleNo(null);//释放小车
                                    wrkMast.setLiftNo(null);//释放提升机
                                }
                            }
@@ -1497,7 +1562,7 @@
            }
            //获取穿梭车最近且空闲的提升机输送站点
            LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId());
            LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId(), Utils.getLev(wrkMast.getLocNo()));
            if (liftSta == null) {
                return false;//没有可用且空闲的输送站点
            }
@@ -2006,10 +2071,10 @@
    }
    /**
     * AGV补货 => 机械臂拣料
     * AGV补货 => 生成入库通知档
     */
    public void agvRestockByRobot() {
        //检测300站是否自动、有物、工作号
    public void robotGenerateAgvTask() {
//检测300站是否自动、有物、工作号
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 获取入库站信息
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
@@ -2039,7 +2104,7 @@
                    } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading()) {
                        //自动、无物
                        targetSta = (short) 317;
                    }else {
                    } else {
                        continue;//没有空闲站点
                    }
@@ -2060,6 +2125,7 @@
                                //覆盖工作档目标站
                                wrkMast.setStaNo(targetSta.intValue());
                                wrkMast.setShuttleNo(null);//释放小车
                                wrkMast.setLiftNo(null);//释放提升机
                                if (wrkMastMapper.updateById(wrkMast) > 0) {
                                    //向300站写入目标站
                                    staProtocol = staProtocol.clone();
@@ -2081,6 +2147,7 @@
//                        //覆盖工作档目标站
//                        wrkMast.setStaNo(targetSta.intValue());
//                        wrkMast.setShuttleNo(null);//释放小车
//                        wrkMast.setLiftNo(null);//释放提升机
//                        if (wrkMastMapper.updateById(wrkMast) > 0) {
//                            //向300站写入目标站
//                            staProtocol = staProtocol.clone();
@@ -2096,9 +2163,23 @@
                    }
                }
            }
        }
    }
    /**
     * AGV补货 => 机械臂拣料
     */
    public void agvRestockByRobot() {
        //检测300站是否自动、有物、工作号
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 获取入库站信息
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            StaProtocol staProtocol303 = devpThread.getStation().get(303);
            StaProtocol staProtocol317 = devpThread.getStation().get(317);
            if (staProtocol303 == null || staProtocol317 == null) {
                continue;
            }
            if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) {
                //调度机械臂
                //查询是否有工作档
@@ -2152,27 +2233,31 @@
                continue;
            }
            if (staProtocol309.isAutoing() && staProtocol309.isLoading()) {
            if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) {
                // 获取条码扫描仪信息
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 11);//308站条码器
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308站条码器
                if (barcodeThread == null) {
                    continue;
                }
                String barcode = barcodeThread.getBarcode();
                if(!Cools.isEmpty(barcode)) {
                    //通知AGV取货
                    agvRestockCall("CS-301-001-01@3", barcode);
                    agvRestockCall("301-1", barcode);
                    log.info("通知AGV取货,条码号:" + barcode);
                }
            } else if (staProtocol312.isAutoing() && staProtocol312.isLoading()) {
            }
            if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) {
                // 获取条码扫描仪信息
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 12);//311站条码器
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311站条码器
                if (barcodeThread == null) {
                    continue;
                }
                String barcode = barcodeThread.getBarcode();
                if(!Cools.isEmpty(barcode)) {
                    //通知AGV取货
                    agvRestockCall("CS-302-001-01@3", barcode);
                    agvRestockCall("302-1", barcode);
                    log.info("通知AGV取货,条码号:" + barcode);
                }
            }
        }
@@ -2202,6 +2287,40 @@
        return false;
    }
    /**
     * AGV补货(悬挂线通知AGV取货)
     */
    public void agvRestockIntoByHangingWire() {
        //检测350和351扫码器
        int[] barcodeStaNo = {11, 12};//11 => 350站扫码器,12 => 351站扫码器
        for (int staNo : barcodeStaNo) {
            // 获取条码扫描仪信息
            BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo);
            if (barcodeThread == null) {
                continue;
            }
            String barcode = barcodeThread.getBarcode();
            if(!Cools.isEmpty(barcode)) {
                if (barcode.contains("NoRead")) {
                    continue;
                }
                String agvStaNo = null;
                if (staNo == 11) {
                    agvStaNo = "303-1";
                }else {
                    agvStaNo = "304-1";
                }
                //通知AGV取货
                boolean result = agvRestockCall(agvStaNo, barcode);
                if (result) {
                    barcodeThread.setBarcode("");
                }
                log.info(barcodeThread.getSlave().getId() + "号扫码器,通知AGV取货,条码号:" + barcode);
            }
        }
    }
    // 300站拣料
    public void pick300() {
        //检测300站是否自动、有物、工作号
@@ -2219,7 +2338,7 @@
                    continue;
                }
                if (wrkMast.getWrkSts() != 25) {//25.提升机搬运完成
                if (wrkMast.getWrkSts() != 29) {//29.出库完成
                    continue;
                }
@@ -2229,6 +2348,7 @@
                    //覆盖工作档目标站
                    wrkMast.setStaNo(sourceStaNo);
                    wrkMast.setSourceStaNo(staNo);
                    wrkMast.setMk("N");
                    if (wrkMastMapper.updateById(wrkMast) > 0) {
                        //向300站写入目标站
                        staProtocol = staProtocol.clone();
@@ -2298,8 +2418,64 @@
                ledCommand.setLocNo(wrkMast.getLocNo());
                ledCommand.setStaNo(wrkMast.getStaNo());
                if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) {
                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs())));
                    //for (WrkDetl wrkDetl : wrkDetls) {
                    //    LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr()));
                    //
                    //    locDetls.forEach(locDetl1 -> {
                    //        //工作档中存在该物料则跳过
                    //        String suppCode = "";
                    //
                    //        if (wrkDetl.getMatnr().equals(locDetl1.getMatnr())) {
                    //            Double anfme = 0D;
                    //            if (locDetl != null) {
                    //                anfme = locDetl.getAnfme();
                    //            }
                    //            if (wrkDetl.getSuppCode() != null) {
                    //                suppCode = wrkDetl.getSuppCode();
                    //            }
                    //            ledCommand.getMatDtos()
                    //                    .add(new MatDto(wrkDetl.getMatnr()
                    //                            , wrkDetl.getMaktx()
                    //                            , wrkDetl.getAnfme()
                    //                            , (wrkDetl.getAnfme()-anfme)
                    //                            , wrkDetl.getSpecs()
                    //                            , suppCode));
                    //        } else {
                    //            if (locDetl1.getSuppCode() != null) {
                    //                suppCode = locDetl1.getSuppCode();
                    //            }
                    //            ledCommand.getMatDtos()
                    //                    .add(new MatDto(locDetl1.getMatnr()
                    //                            , locDetl1.getMaktx()
                    //                            , 0D
                    //                            , locDetl1.getAnfme()
                    //                            , locDetl1.getSpecs()
                    //                            , suppCode));
                    //        }
                    //    });
                    //    //LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr()));
                    //}
                    List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo()));
                    locDetls.forEach(locDetl -> {
                        Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no",wrkMast.getWrkNo());
                        Utils.wapperSetCondition(wrapper,"batch",locDetl.getBatch());
                        Utils.wapperSetCondition(wrapper,"three_code",locDetl.getThreeCode());
                        Utils.wapperSetCondition(wrapper,"dead_time",locDetl.getDeadTime());
                        WrkDetl detl = wrkDetlService.selectOne(wrapper);
                        if (Cools.isEmpty(detl)) {
                            String suppCode = "";
                            if (locDetl.getSuppCode() != null) {
                                suppCode = locDetl.getSuppCode();
                            }
                            ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode));
                        } else {
                            String suppCode = "";
                            if (detl.getSuppCode() != null) {
                                suppCode = detl.getSuppCode();
                            }
                            ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), detl.getAnfme(), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode));
                        }
                    });
                }
                commands.add(ledCommand);
            }
@@ -2312,20 +2488,11 @@
            }
            // 命令下发 -------------------------------------------------------------------------------
            if (!commands.isEmpty()) {
                if (led.getId()>3){
                    if (!MessageQueue.offer(SlaveType.Led, led.getId()-3, new Task(1, commands))) {
                        log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId()-3, led.getIp(), led.getPort());
                        continue;
                    }else {
                        ledThread.setLedMk(false);
                    }
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
                    log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    continue;
                }else {
                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
                        log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                        continue;
                    }else {
                        ledThread.setLedMk(false);
                    }
                    ledThread.setLedMk(false);
                }
            }
@@ -2354,35 +2521,36 @@
     * 其他  ===>> LED显示器复位,显示默认信息
     */
    public void ledReset() {
        for (LedSlave led : slaveProperties.getLed()) {
            // 获取输送线plc线程
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
            // 命令集合
            boolean reset = true;
            for (Integer staNo : led.getStaArr()) {
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                if (staProtocol == null) {
                    continue;
                }
                if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) {
                    reset = false;
                    break;
                }
            }
            // 获取led线程
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
            // led显示默认内容
            if (reset && !ledThread.isLedMk()) {
                ledThread.setLedMk(true);
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) {
                    News.error(" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                } else {
                }
            }
        }
//        for (LedSlave led : slaveProperties.getLed()) {
//
//            // 获取输送线plc线程
//            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
//            // 命令集合
//            boolean reset = true;
//            for (Integer staNo : led.getStaArr()) {
//                // 获取叉车站点
//                StaProtocol staProtocol = devpThread.getStation().get(staNo);
//                if (staProtocol == null) {
//                    continue;
//                }
//                if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) {
//                    reset = false;
//                    break;
//                }
//            }
//            // 获取led线程
//            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
//            // led显示默认内容
//            if (reset && !ledThread.isLedMk()) {
//                ledThread.setLedMk(true);
//                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) {
//                    News.error(" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
//                } else {
//                    News.error("{}号LED命令下发成功!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
//                    ledThread.setLedMk(false);
//                }
//            }
//        }
        for (LedSlave led : slaveProperties.getLed()) {
            // 获取输送线plc线程
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
@@ -2401,9 +2569,13 @@
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
            // led显示默认内容
            if (reset && !ledThread.isLedMk()) {
                ledThread.setLedMk(true);
                ledThread.setLedMk(false);
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
                    News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                }else {
//                    News.error("{}号LED命令下发成功!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()));
                    ledThread.setLedMk(false);
                }
            }
        }
@@ -2540,7 +2712,16 @@
                }
            } else if (wrkCharge.getWrkSts() == 52) {
                //检测小车是否满电
                //获取满电阈值
                int maxPower = 95;
                EntityWrapper<Config> wrapper = new EntityWrapper<>();
                wrapper.eq("code", "chargeMaxValue");
                Config config = configService.selectOne(wrapper);
                if (config != null) {
                    maxPower = Integer.parseInt(config.getValue());
                }
                if (shuttleProtocol.getPowerPercent() < maxPower) {
                    continue;
                }
@@ -2680,6 +2861,22 @@
            if (liftWrkMast != null) {
                return false;//当前提升机存在未完成任务,等待下一次轮询
            }
            //*************尝试锁定目标站路径***************
            List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(wrkMast.getStaNo());
            if (targetNodes == null) {
                return false;//未获取到节点
            }
            boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(targetNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(wrkMast.getLocNo()), null);
            if (!checkPathIsAvailable) {
                return false;//检测目标站点路径是否未被占用
            }
            //尝试锁定目标站路径
            boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, true);//所使用的路径进行锁定禁用
            if (!result2) {
                return false;//路径锁定失败
            }
            //*************尝试锁定目标站路径***************
            //获取小车到输送站点行走命令
            NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id);
@@ -3036,6 +3233,7 @@
            if (basLift.getPoint() == null) {
                return false;//没有设置提升机点位坐标
            }
            NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
            liftNode.setZ(liftSta.getLev());
@@ -3100,22 +3298,26 @@
                return false;
            }
//            //获取目标站对应的输送站点
//            BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo());
//            if (targetBasDevp == null) {
//                return false;//缺少站点信息
//            }
//            //跨楼层移动任务
//            if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) {
//                //获取目标站
//                LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
//                if (liftSta == null) {
//                    return false;//找不到站点
//                }
//
//            //获取提升机数据
//            BasLift basLift = basLiftService.selectById(targetBasDevp.getLiftNo());
//            if (basLift == null) {
//                return false;//没有提升机数据
//                //*************尝试解锁目标站路径***************
//                List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo());
//                if (targetNodes == null) {
//                    return false;//未获取到节点
//                }
//                //尝试解锁目标站路径
//                boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, false);//所使用的路径进行解锁
//                if (!result) {
//                    return false;//路径解锁失败
//                }
//                //*************尝试解锁目标站路径***************
//            }
//            if (basLift.getPoint() == null) {
//                return false;//没有设置提升机点位坐标
//            }
//            NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
//            liftNode.setZ(basLift.getPoint$().getZ());
            //小车已经在目标库位,直接认定小车移动任务完成
            if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) {
@@ -3144,8 +3346,32 @@
                return false;
            }
            //获取小车到目标库位命令
            NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id);
            NyShuttleOperaResult result = null;
            //跨楼层移动任务
            if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) {
                //需要将前两个节点作为白名单节点传入
                //获取目标站
                LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
                if (liftSta == null) {
                    return false;//找不到站点
                }
                List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo());
                if (targetNodes == null) {
                    return false;//未获取到节点
                }
                //设置计算节点的白名单
                ArrayList<int[]> whiteList = new ArrayList<>();//设置计算节点的白名单
                for (NavigateNode node : targetNodes) {
                    whiteList.add(new int[]{node.getX(), node.getY()});
                }
                result = NyShuttleOperaUtils.getStartToTargetCommandsByWhites(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, whiteList);
            }else {
                //获取小车到目标库位命令
                result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id);
            }
            if (result == null) {
                return false;//路径计算失败
            }