#
Junjie
2024-04-07 08c96e4b797573fd64b42a52a2f9b9805d59d3e3
#
2个文件已修改
71 ■■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
@@ -9,6 +9,7 @@
import com.zy.asrs.wcs.core.model.enums.MotionStsType;
import com.zy.asrs.wcs.core.model.enums.TaskStsType;
import com.zy.asrs.wcs.core.service.*;
import com.zy.asrs.wcs.core.utils.ShuttleDispatcher;
import com.zy.asrs.wcs.core.utils.Utils;
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
@@ -62,6 +63,8 @@
    private TaskCtgService taskCtgService;
    @Autowired
    private DictService dictService;
    @Autowired
    private ShuttleDispatcher shuttleDispatcher;
    /**
     * 组托
@@ -356,6 +359,9 @@
                continue;
            }
            //获取避让位置
            String standByLocNo = shuttleDispatcher.searchStandByLocNo(Integer.valueOf(device.getDeviceNo()), device.getHostId(), shuttleThread.getStatus().getCurrentLocNo());
            Task task = new Task();
            task.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
            task.setTaskNo(String.valueOf(Utils.getTaskNo("MOVE")));
@@ -365,7 +371,7 @@
            task.setOriginSite(null);
            task.setOriginLoc(null);
            task.setDestSite(null);
            task.setDestLoc("1-1-1"); // 暂时未定
            task.setDestLoc(standByLocNo); // 避让位置
            task.setIoTime(new Date());
            task.setStartTime(new Date());
            task.setHostId(device.getHostId());
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
@@ -1,13 +1,18 @@
package com.zy.asrs.wcs.core.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SnowflakeIdWorker;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.entity.BasShuttle;
import com.zy.asrs.wcs.core.entity.Task;
import com.zy.asrs.wcs.core.kernel.AnalyzeService;
import com.zy.asrs.wcs.core.model.NavigateNode;
import com.zy.asrs.wcs.core.model.enums.LiftCodeType;
import com.zy.asrs.wcs.core.model.enums.NavigationMapType;
import com.zy.asrs.wcs.core.service.BasShuttleService;
import com.zy.asrs.wcs.core.service.TaskService;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.rcs.entity.Device;
@@ -48,6 +53,8 @@
    private DeviceService deviceService;
    @Autowired
    private DeviceTypeService deviceTypeService;
    @Autowired
    private BasShuttleService basShuttleService;
    public ShuttleThread queryShuttleWhichConvenient(Task task, Integer liftNo) {
        String locNo = taskService.judgeInbound(task) ? task.getDestLoc() : task.getOriginLoc();
@@ -169,5 +176,61 @@
//        return wrkCharge;
//    }
    /**
     * 搜索避让库位,通过小车号和目标库位
     */
    public String searchStandByLocNo(Integer shuttleNo, Long hostId, String locNo) {
        BasShuttle basShuttle = basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>()
                .eq(BasShuttle::getShuttleNo, shuttleNo)
                .eq(BasShuttle::getHostId, hostId));
        if (basShuttle == null) {
            throw new CoolException("小车基础数据不存在");
        }
        String idleLoc = basShuttle.getIdleLoc();
        if (Cools.isEmpty(idleLoc)) {
            throw new CoolException("小车避让数据不存在");
        }
        int lev = Utils.getLev(locNo);//当前楼层
        JSONArray standbyLoc = JSON.parseArray(idleLoc);
        if (lev > standbyLoc.size()) {
            throw new CoolException("避让数据异常");
        }
        Object object = standbyLoc.get(lev - 1);
        List<String> locs = JSON.parseArray(object.toString(), String.class);
        if (locs.isEmpty()) {
            throw new CoolException("避让数据为空");
        }
        Integer finalDistance = ShuttleDispatcher.INF;
        String recentLoc = null;
        for (String loc : locs) {
            //当前穿梭车到避让位计算
            List<NavigateNode> currentShuttlePath = NavigateUtils.calc(
                    locNo
                    , loc
                    , NavigationMapType.NORMAL.id
                    , Utils.getShuttlePoints(shuttleNo, lev)
            );//使用正常通道地图
            if (currentShuttlePath == null) {
                continue;
            }
            Integer currDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离
            if (currDistance < finalDistance) {
                finalDistance = currDistance;
                recentLoc = loc;
            }
        }
        if (recentLoc == null) {
            throw new CoolException("搜索避让位置失败");
        }
        return recentLoc;
    }
}