自动化立体仓库 - WMS系统
skyouc
2 天以前 644b6194f8e5bfbe8d4c431eb53e6b3d36026351
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -1540,7 +1540,7 @@
            station.setModiTime(new Date());
            station.setModiUser(userId);
            if (!basStationService.updateById(station)) {
                throw new CoolException("更新目标库位状态失败");
                throw new CoolException("更新目标站点状态失败");
            }
        } else {
            throw new CoolException("移转失败,目标库位状态:" + station.getLocSts());
@@ -1741,6 +1741,7 @@
                    throw new CoolException("数据错误,站点不存在!!");
                }
                station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
                station.setBarcode(null);
                if (!basStationService.updateById(station)) {
                    throw new CoolException("站点状态更新失败!!");
                }
@@ -1785,6 +1786,7 @@
        }
        station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
        station.setBarcode(null);
        if (!basStationService.updateById(station)) {
            throw new CoolException("站点状态修改失败!");
        }
@@ -1806,6 +1808,13 @@
        generateCrnInTask(waitPakins, station, param.getLocType1(), userId);
    }
    /**
     * SO/EO 区组托
     * @author Ryan
     * @date 2025/12/18 15:19
     * @param params
     * @return com.core.common.R
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R collectionPakin(CollectionPakinParams params, Long userId) {
@@ -2230,7 +2239,8 @@
                wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站
                wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位
                //小松项目,缓存出库AGV站点,用于清空缓存区库存
                wrkMast.setAvgSta(station.getDevNo());
                wrkMast.setPauseMk(station.getDevNo());
//                wrkMast.setAvgSta(station.getDevNo());;
                wrkMast.setFullPlt("Y"); // 满板:Y
                wrkMast.setPicking("N"); // 拣料
                wrkMast.setExitMk("N"); // 退出
@@ -2455,7 +2465,7 @@
        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
            station.setLocSts("R"); // S.入库预约
            station.setBarcode(barcode);
//            station.setBarcode(barcode);
            station.setModiTime(new Date());
            station.setModiUser(userId);
            if (!basStationService.updateById(station)) {
@@ -2519,4 +2529,69 @@
        }
        return result;
    }
    /**
     * 呼叫AGV返回
     * @author Ryan
     * @date 2025/9/24
     * @param callAgvBackParam
     * @return com.core.common.R
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R agvCallback(AgvCallParams callAgvBackParam, Long userId) {
        if (Objects.isNull(callAgvBackParam.getOrgSite())) {
            return R.error("参数不能为空!!");
        }
        // 按当前查找库位顺序,查到一个后,不再往下查询
        LocCache locCache = findPriorityLocCache();
        if (Objects.isNull(locCache)) {
            return R.error("未查询到可用库位");
        }
        try {
            generateAgvTask("agv", locCache, callAgvBackParam.getOrgSite(), callAgvBackParam.getBarcode(), userId);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error(e.getMessage());
        }
        return R.ok(locCache);
    }
    /**
     * 按优先级查找可用库位
     * 顺序:入库缓存区 -> SO区 -> EO区
     */
    private LocCache findPriorityLocCache() {
        // 1. Try Inbound Cache Area
        LocCache loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_IN_CACHE);
        if (loc != null) return loc;
        // 2. Try SO Area
        loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_SO);
        if (loc != null) return loc;
        // 3. Try EO Area
        loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_EO);
        return loc;
    }
    /**
     * 根据区域类型查找可用库位
     */
    private LocCache findAvailableLocByAreaType(LocAreaType areaType) {
        BasAreas area = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", areaType.type));
        if (area == null) {
            return null;
        }
        return locCacheService.selectOne(new EntityWrapper<LocCache>()
                .eq("area_id", area.getId())
                .eq("frozen", 0)
                .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
                .orderAsc(Arrays.asList("loc_no"))
                .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
    }
}