wanshenmean
2026-03-30 1f15dd43b334e31189c4580b98f57d2cc71935d8
refactor(StockInfo): 重构 Get3DLayoutAsync 使用依赖注入服务

- 注入 ILocationInfoService 和 IWarehouseService
- 通过服务层接口查询仓库和货位信息
- 使用 QueryDataNavAsync 查询库存明细

Co-Authored-By: Claude <noreply@anthropic.com>
已修改2个文件
23 ■■■■ 文件已修改
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -2,6 +2,7 @@
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
@@ -18,11 +19,23 @@
        public IRepository<Dt_StockInfo> Repository => BaseDal;
        /// <summary>
        /// 货位信息服务接口(用于获取仓库货位信息)
        /// </summary>
        private readonly ILocationInfoService _locationInfoService;
        /// <summary>
        /// 仓库信息服务接口(用于获取仓库基本信息)
        /// </summary>
        private readonly IWarehouseService _warehouseService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="baseDal">基础数据访问对象</param>
        public StockInfoService(IRepository<Dt_StockInfo> baseDal) : base(baseDal)
        public StockInfoService(IRepository<Dt_StockInfo> baseDal, ILocationInfoService locationInfoService, IWarehouseService warehouseService) : base(baseDal)
        {
            _locationInfoService = locationInfoService;
            _warehouseService = warehouseService;
        }
        /// <summary>
@@ -88,13 +101,13 @@
        public async Task<Stock3DLayoutDTO> Get3DLayoutAsync(int warehouseId)
        {
            // 1. 查询仓库信息
            var warehouse = await Repository.Change<Dt_Warehouse>().GetFirstAsync(x => x.Id == warehouseId);
            var warehouse = await _warehouseService.Repository.QueryFirstAsync(x => x.WarehouseId == warehouseId);
            // 2. 查询该仓库所有货位
            var locations = await Repository.Change<Dt_LocationInfo>().GetListAsync(x => x.WarehouseId == warehouseId);
            var locations = await _locationInfoService.Repository.QueryDataAsync(x => x.WarehouseId == warehouseId);
            // 3. 查询该仓库所有库存信息(包含Details导航属性)
            var stockInfos = await Repository.Change<Dt_StockInfo>().Includes(x => x.Details).GetListAsync(x => x.WarehouseId == warehouseId);
            var stockInfos = await Repository.QueryDataNavAsync(x => x.WarehouseId == warehouseId);
            // 4. 提取物料编号和批次号列表(去重)
            var materielCodeList = stockInfos
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/StockInfoController.cs
@@ -29,7 +29,7 @@
        public async Task<WebResponseContent> Get3DLayout(int warehouseId)
        {
            var result = await Service.Get3DLayoutAsync(warehouseId);
            return WebResponseContent.Instance.OK(result);
            return WebResponseContent.Instance.OK(data: result);
        }
    }
}