wanshenmean
6 天以前 37acb8358f5602a9013ee29c04a45e33483c2329
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();
        }
@@ -167,6 +170,16 @@
        public async Task<Dt_LocationInfo> GetLocationInfoAsync(string locationCode)
        {
            return await BaseDal.QueryFirstAsync(x => x.LocationCode == locationCode);
        }
        /// <summary>
        /// 根据货位ID获取货位信息
        /// </summary>
        /// <param name="id">货位id</param>
        /// <returns>货位信息</returns>
        public async Task<Dt_LocationInfo> GetLocationInfoAsync(int id)
        {
            return await BaseDal.QueryFirstAsync(x => x.Id == id);
        }
        /// <summary>
@@ -494,11 +507,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,6 +527,7 @@
                EnableStatus = EnableStatusEnum.Normal.GetHashCode(),
                LocationStatus = LocationStatusEnum.Free.GetHashCode(),
                LocationType = LocationTypeEnum.Undefined.GetHashCode(),
                //LocationCode = $"{roadwayNo}-{row:D3}-{col:D3}-{layer:D3}",
                LocationCode = $"{row:D3}-{col:D3}-{layer:D3}",
                LocationName = $"{roadwayNo}巷道{row:D3}行{col:D3}列{layer:D3}层{depth:D2}深"
            };