wangxinhui
2026-03-19 5f53f4af369a1c7a8a09eb1f45c20a8581d107a9
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_BasicService/Base/LocationInfoService.cs
@@ -1,4 +1,4 @@
using HslCommunication.WebSocket;
using HslCommunication.WebSocket;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SqlSugar;
@@ -32,13 +32,84 @@
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly IBasicRepository _basicRepository;
        private readonly IStockInfoRepository _stockInfoRepository;
        private readonly IProStockInfoRepository _proStockInfoRepository;
        public ILocationInfoRepository Repository => BaseDal;
        public LocationInfoService(ILocationInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository, IStockInfoRepository stockInfoRepository) : base(BaseDal)
        public LocationInfoService(ILocationInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository, IStockInfoRepository stockInfoRepository, IProStockInfoRepository proStockInfoRepository) : base(BaseDal)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _basicRepository = basicRepository;
            _stockInfoRepository = stockInfoRepository;
            _proStockInfoRepository = proStockInfoRepository;
        }
        /// <summary>
        /// æŸ¥è¯¢è´§ä½å¯¹åº”çš„RFID及库存信息
        /// </summary>
        /// <param name="locationCodes"></param>
        /// <returns></returns>
        public WebResponseContent GetRfid(string[] locationCodes, int warehouseId = 0)
        {
            try
            {
                // å‚数验证
                if (locationCodes == null || locationCodes.Length == 0)
                {
                    return WebResponseContent.Instance.Error("货位编号不能为空");
                }
                if (warehouseId == 1)
                {
                    // æŸ¥è¯¢åŽŸæ–™åº“Dt_StockInfo表,获取RFID及库存信息
                    var rawMaterialRfidList = _stockInfoRepository.QueryData()
                        .Where(x => locationCodes.Contains(x.LocationCode))
                        .Select(x => new {
                            locationCode = x.LocationCode,
                            rfidCode = x.RfidCode,
                            paperRoll = x.MaterielName, // çº¸å·åç§°
                            width = x.MaterielWide, // é—¨å¹…(幅宽)
                            barcode = x.PalletCode, // çº¸å·æ¡ç 
                            status = x.StockStatus, // çŠ¶æ€
                            inDate = x.CreateDate // å…¥åº“时间(创建时间)
                        })
                        .ToList();
                    // è¿”回结果
                    return WebResponseContent.Instance.OK(data: rawMaterialRfidList);
                }
                if (warehouseId == 2)
                {
                    // æ›¿æ¢åŽŸæœ‰çš„ .Select(x => new { ... Detail = x.proStockInfoDetails?.FirstOrDefault() ... }) ä»£ç å—
                    var finishedProductRfidList = _proStockInfoRepository.Db.Queryable<Dt_ProStockInfo>()
                        .Includes(x => x.proStockInfoDetails)
                        .Where(x => locationCodes.Contains(x.LocationCode))
                        .ToList()
                        .Select(x => new
                        {
                            locationCode = x.LocationCode,
                            rfidCode = x.PalletCode,
                            paperRoll = (x.proStockInfoDetails != null && x.proStockInfoDetails.Count > 0) ? x.proStockInfoDetails[0].ProductName : string.Empty,
                            productName = (x.proStockInfoDetails != null && x.proStockInfoDetails.Count > 0) ? x.proStockInfoDetails[0].ProductName : string.Empty,
                            width = (x.proStockInfoDetails != null && x.proStockInfoDetails.Count > 0) ? x.proStockInfoDetails[0].StockQty : 0,
                            quantity = (x.proStockInfoDetails != null && x.proStockInfoDetails.Count > 0) ? x.proStockInfoDetails[0].StockQty : 0,
                            barcode = x.PalletCode,
                            status = x.StockStatus,
                            inDate = x.CreateDate
                        })
                        .ToList();
                    // è¿”回结果
                    return WebResponseContent.Instance.OK(data: finishedProductRfidList);
                }
                // å¦‚果没有匹配的仓库ID,返回空列表
                return WebResponseContent.Instance.OK(data: new List<object>());
            }
            catch (Exception ex)
            {
                Console.WriteLine($"GetRfid å¼‚常: {ex.Message}");
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
@@ -133,7 +204,7 @@
                            Dt_LocationInfo locationInfo = new Dt_LocationInfo()
                            {
                                WarehouseId = 0,
                                Column = j + 1,
                                Columns = j + 1,
                                EnableStatus = EnableStatusEnum.Normal.ObjToInt(),
                                Layer = k + 1,
                                LocationStatus = LocationStatusEnum.Free.ObjToInt(),
@@ -142,8 +213,8 @@
                                Row = i + 1,
                                Depth = depth,
                            };
                            locationInfo.LocationCode = $"{locationInfo.RoadwayNo}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Column.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}-{locationInfo.Depth.ToString().PadLeft(2, '0')}";
                            locationInfo.LocationName = $"{locationInfo.RoadwayNo}巷道{locationInfo.Row.ToString().PadLeft(3, '0')}行{locationInfo.Column.ToString().PadLeft(3, '0')}列{locationInfo.Layer.ToString().PadLeft(3, '0')}层{locationInfo.Depth.ToString().PadLeft(2, '0')}æ·±";
                            locationInfo.LocationCode = $"{locationInfo.RoadwayNo}-{locationInfo.Row.ToString().PadLeft(3, '0')}-{locationInfo.Columns.ToString().PadLeft(3, '0')}-{locationInfo.Layer.ToString().PadLeft(3, '0')}-{locationInfo.Depth.ToString().PadLeft(2, '0')}";
                            locationInfo.LocationName = $"{locationInfo.RoadwayNo}巷道{locationInfo.Row.ToString().PadLeft(3, '0')}行{locationInfo.Columns.ToString().PadLeft(3, '0')}列{locationInfo.Layer.ToString().PadLeft(3, '0')}层{locationInfo.Depth.ToString().PadLeft(2, '0')}æ·±";
                            locationInfos.Add(locationInfo);
                        }
                    }