xiazhengtongxue
2026-04-01 a9edf162ac5dd98719c2f93ab0800c98673fd220
Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/LocationInfoService.cs
@@ -25,6 +25,7 @@
        private readonly IRepository<Dt_Task> _taskRepository;
        private readonly IRepository<Dt_StockInfo> _stockInfoRepository;
        private readonly IRecordService _recordService;
        private readonly IRepository<Dt_Warehouse> _warehouseRepository;
        /// <summary>
        /// 构造函数
@@ -36,6 +37,7 @@
            IRepository<Dt_LocationInfo> baseDal,
            IRepository<Dt_Task> taskRepository,
            IRepository<Dt_StockInfo> stockInfoRepository,
            IRepository<Dt_Warehouse> warehouseRepository,
            IMapper mapper,
            IRecordService recordService) : base(baseDal)
        {
@@ -43,6 +45,7 @@
            _stockInfoRepository = stockInfoRepository;
            _mapper = mapper;
            _recordService = recordService;
            _warehouseRepository = warehouseRepository;
        }
        /// <summary>
@@ -141,10 +144,10 @@
                x.LocationStatus == LocationStatusEnum.Free.GetHashCode());
            return locations?
                .OrderBy(x => x.Layer)
                .ThenByDescending(x => x.Depth)
                .ThenBy(x => x.Column)
                .ThenBy(x => x.Row)
                .OrderByDescending(x => x.Depth)  // 1. 深度优先(从大到小)
                .ThenBy(x => x.Layer)             // 2. 层数
                .ThenBy(x => x.Column)            // 3. 列
                .ThenBy(x => x.Row)               // 4. 行
                .FirstOrDefault();
        }
@@ -494,11 +497,18 @@
        /// <param name="layer">层数</param>
        /// <param name="depth">深度</param>
        /// <returns>货位信息对象</returns>
        private static Dt_LocationInfo CreateLocationInfo(string roadwayNo, int row, int col, int layer, int depth)
        private Dt_LocationInfo CreateLocationInfo(string roadwayNo, int row, int col, int layer, int depth)
        {
            var warehouse = _warehouseRepository.QueryData(x => x.WarehouseCode == roadwayNo).FirstOrDefault();
            if (warehouse == null)
            {
                throw new InvalidOperationException($"未找到巷道编号为 {roadwayNo} 的仓库信息");
            }
            return new Dt_LocationInfo
            {
                WarehouseId = 0,
                WarehouseId = warehouse.WarehouseId,
                Row = row,
                Column = col,
                Layer = layer,
@@ -507,7 +517,7 @@
                EnableStatus = EnableStatusEnum.Normal.GetHashCode(),
                LocationStatus = LocationStatusEnum.Free.GetHashCode(),
                LocationType = LocationTypeEnum.Undefined.GetHashCode(),
                LocationCode = $"{row:D3}-{col:D3}-{layer:D3}",
                LocationCode = $"{roadwayNo}-{row:D3}-{col:D3}-{layer:D3}",
                LocationName = $"{roadwayNo}巷道{row:D3}行{col:D3}列{layer:D3}层{depth:D2}深"
            };
        }