1
zhangc
2025-04-14 d9280b0c2ceab9db2c60c0af1a74e83f91cc74fc
1
5个文件已修改
179 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/NoLiftInServiceImpl.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/WrkMastScheduler.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java 152 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/WrkStsType.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -306,7 +306,7 @@
    }
    public synchronized void noLiftIn() {
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", WrkStsType.NEW_INBOUND.sts, WrkStsType.INBOUND_DEVICE_RUN.sts).in("source_sta_no", 1014, 1025));
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.INBOUND_DEVICE_RUN.sts).in("source_sta_no", 1014, 1025));
        for (WrkMast wrkMast : wrkMasts) {
            if (wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) {
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
@@ -324,7 +324,7 @@
                if (wrkMast.getStaNo() == 1025) {
                    locNo = "1200305";
                }
                boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttle(wrkMast.getWrkNo(), locNo, wrkMast.getLocNo(), "TRANSPORT_DEVP");
                boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleIn(wrkMast.getWrkNo(), locNo, wrkMast.getLocNo(), "TRANSPORT_DEVP",true);
                if (!dispatchShuttle) {
                    News.info("{}任务,调度小车失败", wrkMast.getWrkNo());
                    return;
@@ -348,7 +348,7 @@
        // 遍历堆垛机出库站
        Date now = new Date();
        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devpSlave.getId());
        List<WrkMast> wrkSts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.NEW_OUTBOUND.sts).in("sta_no", 1014, 1025));
        List<WrkMast> wrkSts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.NEW_OUTBOUND.sts).in("sta_no", 1013, 1024));
        for (WrkMast wrkMast : wrkSts) {
            if (devpThread == null) {
                return;
@@ -369,10 +369,10 @@
                return;
            }
            String locNo = "1200301";
            if (wrkMast.getStaNo() == 1025) {
            if (wrkMast.getStaNo() == 1024) {
                locNo = "1200305";
            }
            boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), locNo, "TRANSPORT_DEVP");
            boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleIn(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), locNo, "TRANSPORT_DEVP", false);
            if (!dispatchShuttle) {
                News.info("{}任务,调度小车失败", wrkMast.getWrkNo());
                return;
@@ -405,7 +405,7 @@
                        staProtocol = staProtocol.clone();
                    }
                    if (staProtocol.isAutoing() && !staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
                    if (staProtocol.isAutoing() && staProtocol.isLoading()) {
                        // 查询工作档
                        if (wrkMast == null) {
                            continue;
@@ -1500,10 +1500,10 @@
            Map<Integer, StaProtocol> station = devpThread.getStation();
            WrkMast wrkMast = null;
            for (StaProtocol staProtocol : station.values()) {
                if (staProtocol.getSiteId() == 1014 || staProtocol.getSiteId() == 1015) {
                if (staProtocol.getSiteId() == 1013 || staProtocol.getSiteId() == 1014) {
                    wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", staProtocol.getFinishWorkNo()).eq("wrk_sts", WrkStsType.OUTBOUND_DEVP_RUN.sts));
                    if (wrkMast != null) {
                        wrkMast.setWrkSts(WrkStsType.OUTBOUND_DEVP_RUN_COMPLETE.sts);
                        wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts);
                        wrkMast.setModiTime(new Date());
                        if (wrkMastService.updateById(wrkMast)) {
                            News.info("输送线已确认且任务完成状态。输送线号={},完结工作号={}", staProtocol.getSiteId(), staProtocol.getFinishWorkNo());
src/main/java/com/zy/asrs/service/impl/NoLiftInServiceImpl.java
@@ -119,7 +119,7 @@
    private boolean shuttleMoveExecuteTransportLiftStepCallShuttle(WrkMast wrkMast) {
        Date now = new Date();
        //小车移动至站点  301.生成小车移库任务 ==> 呼叫小车至取货点
        if (wrkMast.getWrkSts() == WrkStsType.NEW_MOVE.sts) {
        if (wrkMast != null && wrkMast.getWrkSts() == WrkStsType.NEW_MOVE.sts) {
            //获取四向穿梭车线程
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
            if (shuttleThread == null) {
@@ -134,7 +134,7 @@
                return false;
            }
            StaProtocol staProtocol = devpThread.getStation().get(Utils.getLev(wrkMast.getSourceLocNo()) == 1 ? 1015 : 1026);
            if (!staProtocol.isLoading()) {
            if (!staProtocol.isLoading() || !staProtocol.isAutoing()) {
                log.info("{}任务,{}号输送线无物", wrkMast.getWrkNo(), wrkMast.getSourceStaNo());
                News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}号输送线无物", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
                return false;
@@ -351,7 +351,6 @@
            }
            //判断提升机楼层
            if (liftProtocol.getLev() == Utils.getLev(shuttleProtocol.getCurrentLocNo())) {
                //提升机在小车楼层
@@ -462,7 +461,6 @@
                News.info("{}任务,{}号提升机,提升机内有小车,禁止派发", wrkMast.getWrkNo(), liftProtocol.getLiftNo());
                return false;//提升机内无小车
            }
            //判断提升机楼层
@@ -803,7 +801,7 @@
        Date now = new Date();
        //小车移动到目标库位中  309.小车迁出提升机完成 ==> 310.小车移动中
        if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_NO_LIFT_1.sts) {
        if (wrkMast != null && wrkMast.getWrkSts() == WrkStsType.MOVE_IN_NO_LIFT_1.sts) {
            //获取四向穿梭车线程
src/main/java/com/zy/asrs/task/WrkMastScheduler.java
@@ -208,7 +208,7 @@
                    main.setWrkSts(WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts);
                }
                main.setModiTime(new Date());
                if (wrkMastService.updateById(main)) {
                if (!wrkMastService.updateById(main)) {
                    log.info("更新主工作档[workNo={}]失败", wrkMast.getWrkNo());
                }
            }
src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
@@ -208,6 +208,158 @@
    }
    /**
     * 调度车辆
     */
    public boolean searchDispatchShuttleIn(Integer wrkNo, String sourceLocNo, String locNo, String flag, boolean in) {
        ArrayList<ShuttleThread> sameLev = new ArrayList<>();//相同楼层的穿梭车
        ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车
        for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
            //获取四向穿梭车线程
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                continue;
            }
            if (checkChargeWrk(shuttle.getId())) {
                continue;//存在充电任务,过滤小车
            }
            if (!shuttleThread.isIdle()) {
                continue;//小车忙碌中
            }
            BasShuttle basShuttle = basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttle.getId()));
            if (basShuttle != null) {
                if (basShuttle.getStatus() == 0) {
                    continue;//小车被禁用
                }
            }
            int currentLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//小车当前层高
            String currentLocNo = shuttleProtocol.getCurrentLocNo();//小车当前库位号
            if (currentLocNo.equals(locNo)) {
                //车辆当前位置已经是目标库位,调度该车
                //给工作档绑定小车号
                WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo);
                if (wrkMast1 != null) {
                    wrkMast1.setShuttleNo(shuttleProtocol.getShuttleNo());
                    wrkMastService.updateById(wrkMast1);
                    return true;
                }
                break;
            }
//            if (in) {
                if (currentLev == Utils.getLev(sourceLocNo)) {
                    //工作档楼层相同的穿梭车
                    sameLev.add(shuttleThread);
                } else {
                    //工作档不同楼层的穿梭车
                    diffLev.add(shuttleThread);
                }
//            } else {
//                if (currentLev == Utils.getLev(locNo)) {
//                    //工作档楼层相同的穿梭车
//                    sameLev.add(shuttleThread);
//                } else {
//                    //工作档不同楼层的穿梭车
//                    diffLev.add(shuttleThread);
//                }
//            }
        }
        //优先调度同楼层小车,寻找离任务最近的穿梭车
        if (!sameLev.isEmpty()) {
            Map<Integer, ShuttleThread> sameShuttles = new TreeMap<>();//自然排序小车Map
            for (ShuttleThread shuttleThread : sameLev) {
                ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
                Integer shuttleNo = shuttleProtocol.getShuttleNo();
                //当前穿梭车库位号
                String currentLocNo = shuttleProtocol.getCurrentLocNo();
                if (currentLocNo.equals(sourceLocNo)) {
                    sameShuttles.put(-1, shuttleThread);
                    continue;
                }
                //当前穿梭车线程到目标地点距离
                List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图
                if (currentShuttlePath == null) {
                    continue;
                }
                Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离
                sameShuttles.put(currentAllDistance, shuttleThread);
            }
            //尝试调度同楼层小车
            for (Map.Entry<Integer, ShuttleThread> entry : sameShuttles.entrySet()) {
                ShuttleThread shuttleThread = entry.getValue();
                ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
                Integer shuttleNo = shuttleProtocol.getShuttleNo();
                //尝试调度小车
                boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false);
                if (result) {
                    return true;//调度成功
                }
            }
        }
        //执行到此处,同楼层无调度成功小车。需要进行跨楼层调度小车
        //寻找离任务楼层最近的穿梭车(不考虑跨楼层小车移动距离)
        if (!diffLev.isEmpty()) {
            Map<Integer, ShuttleThread> diffShuttles = new TreeMap<>();//自然排序小车Map
            //获取任务
            WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo);
            if (wrkMast1 != null) {
                String targetLoc = wrkMast1.getIoType() < 100 ? wrkMast1.getLocNo() : wrkMast1.getSourceLocNo();
                int lev = Utils.getLev(targetLoc);//目标楼层
                //检测目标楼层车数量是否小于允许的最大数量
                boolean checkDispatchMaxNum = checkDispatchMaxNum(lev);
                if (!checkDispatchMaxNum) {
                    News.info("{}任务,{}层,已经达到当前楼层调度车辆最大值", wrkMast1.getWrkNo(), lev);
                    return false;
                }
                for (ShuttleThread shuttleThread : diffLev) {
                    ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
                    //当前穿梭车库位号
                    String currentLocNo = shuttleProtocol.getCurrentLocNo();
                    int currentLev = Utils.getLev(currentLocNo);
                    List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//判断当前穿梭车楼层是否有待分配车辆的任务,如果有则不分配这辆车
                    int shuttleCount = this.getShuttleCountByLev(currentLev);//获取穿梭车楼层车辆数量
                    if (!wrkMasts1.isEmpty() && shuttleCount <= 1) {
                        //存在其他任务且可用小车数量小于等于1,跳过这辆车
                        continue;
                    }
                    //ABS(目标楼层 - 当前楼层) 得到差距,取最小差值
                    int currentValue = Math.abs(lev - currentLev);
                    diffShuttles.put(currentValue, shuttleThread);
                }
                //尝试调度跨楼层小车
                for (Map.Entry<Integer, ShuttleThread> entry : diffShuttles.entrySet()) {
                    ShuttleThread shuttleThread = entry.getValue();
                    ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
                    Integer shuttleNo = shuttleProtocol.getShuttleNo();
                    //尝试调度小车
                    boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false);
                    if (result) {
                        return true;//调度成功
                    }
                }
            }
        }
        News.info("{}目标库位没有搜索到可用穿梭车", locNo);
        return false;
    }
    /**
     * 小车迁移任务生成
     */
    @Transactional
src/main/java/com/zy/core/enums/WrkStsType.java
@@ -19,7 +19,6 @@
    OUTBOUND_LIFT_RUN(104, "提升机搬运中"),
    OUTBOUND_LIFT_RUN_COMPLETE(105, "提升机搬运完成"),
    OUTBOUND_DEVP_RUN(106, "输送线搬运中"),
    OUTBOUND_DEVP_RUN_COMPLETE(107, "输送线搬运完成"),
    COMPLETE_OUTBOUND(109, "出库完成"),
    SETTLE_OUTBOUND(110, "出库库存更新"),