Junjie
2023-07-14 d9248408fbaf28f25dfcf8e5ec3a5372e7a7c5a3
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -21,6 +21,8 @@
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;
@@ -89,6 +91,8 @@
    private BasRgvErrLogService basRgvErrLogService;
    @Autowired
    private BasRgvPathService basRgvPathService;
    @Autowired
    private RedisUtil redisUtil;
    @Value("${wms.url}")
    private String wmsUrl;
@@ -627,6 +631,24 @@
                            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(), true);
                        //  命令下发区 --------------------------------------------------------------------------
                        RgvCommand rgvCommand = new RgvCommand();
                        rgvCommand.setRgvNo(wrkMast.getRgvNo()); // RGV编号
@@ -655,6 +677,24 @@
                            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(), true);
                        //  命令下发区 --------------------------------------------------------------------------
                        RgvCommand rgvCommand = new RgvCommand();
                        rgvCommand.setRgvNo(wrkMast.getRgvNo()); // RGV编号
@@ -679,6 +719,24 @@
                        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(), true);
                        //  命令下发区 --------------------------------------------------------------------------
                        RgvCommand rgvCommand = new RgvCommand();
@@ -707,6 +765,24 @@
                        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(), true);
                        //  命令下发区 --------------------------------------------------------------------------
                        RgvCommand rgvCommand = new RgvCommand();
@@ -1717,6 +1793,9 @@
                    rgvProtocol.setTaskNo1((short) 0);//出库任务完成,清空任务号
                    wrkMast1.setWrkSts(27L);//27.RGV放货完成
                }
                //解锁路径
                RgvUtils.unLockPath(wrkMast1.getRgvNo());
                wrkMast1.setModiTime(now);
                if (wrkMastMapper.updateById(wrkMast1) == 0) {
@@ -2841,7 +2920,21 @@
     * 初始化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));
            }
        }
    }
    /**