diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
index 4314d5cc..32f2200f 100644
--- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
+++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml
@@ -3291,6 +3291,11 @@
箱Id
+
+
+ 仓位Id(序列号不存在库存的话仓位是0)
+
+
序列号
diff --git a/src/WMS.Web.Core/Dto/MaterialResponse.cs b/src/WMS.Web.Core/Dto/MaterialResponse.cs
index 126a92de..c313ddad 100644
--- a/src/WMS.Web.Core/Dto/MaterialResponse.cs
+++ b/src/WMS.Web.Core/Dto/MaterialResponse.cs
@@ -12,7 +12,11 @@ namespace WMS.Web.Core.Dto
///
/// 箱Id
///
- public int BoxId { get; set; }
+ public int BoxId { get; set; } = 0;
+ ///
+ /// 仓位Id(序列号不存在库存的话仓位是0)
+ ///
+ public int SubStockId { get; set; } = 0;
///
/// 序列号
///
diff --git a/src/WMS.Web.Repositories/SerialNumbersRepositories.cs b/src/WMS.Web.Repositories/SerialNumbersRepositories.cs
index 5c3de32d..954c59cd 100644
--- a/src/WMS.Web.Repositories/SerialNumbersRepositories.cs
+++ b/src/WMS.Web.Repositories/SerialNumbersRepositories.cs
@@ -149,14 +149,18 @@ namespace WMS.Web.Repositories
response.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, material.MaterialId);
return response;
}
- var entity = await _context.SerialNumbers.FirstOrDefaultAsync(w => serialNumber.Equals(w.SerialNumber));
- if (entity == null) return null;
- response.BoxId = entity.BoxId;
- response.SerialNumber = entity.SerialNumber;
- response.MaterialId = entity.MaterialId;
- response.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, entity.MaterialId);
- response.MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, entity.MaterialId);
- response.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, entity.MaterialId);
+ var entity = await _context.SerialNumbers
+ .GroupJoin(_context.BoxInventory, serial => serial.BoxId, box => box.BoxId, (serial, box) => new { serial, box })
+ .SelectMany(x => x.box.DefaultIfEmpty(), (p, box) => new { p.serial, box })
+ .FirstOrDefaultAsync(w => serialNumber.Equals(w.serial.SerialNumber));
+ if (entity.serial == null) return null;
+ response.BoxId = entity.serial.BoxId;
+ response.SubStockId = entity.box?.SubStockId ?? 0;
+ response.SerialNumber = entity.serial.SerialNumber;
+ response.MaterialId = entity.serial.MaterialId;
+ response.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, entity.serial.MaterialId);
+ response.MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, entity.serial.MaterialId);
+ response.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, entity.serial.MaterialId);
return response;
}
}