库存展示修改 主数据层级联动

This commit is contained in:
zhougf committed 2026-06-01 23:49:07 +08:00
1 parent 7f621dd553
commit 3c6dfda5e5
13 files changed
+488 -42

No files matched your search

@@ -41,6 +41,8 @@ public class InventoryViewDto
public decimal Qty { get; set; }
public decimal AvailableQty { get; set; }
public decimal PendingInboundQty { get; set; }
public decimal PendingOutboundQty { get; set; }
-1
View File
@@ -7,7 +7,6 @@ namespace WmsLite.Api.Dtos.Orders;
public abstract class OrderSaveRequestBase
{
[Required]
[StringLength(128)]
public string OrderNo { get; set; } = string.Empty;
@@ -3,4 +3,6 @@ namespace WmsLite.Api.Services.Interfaces;
public interface IOrderNumberGenerator
{
Task<string> NextInboundOrderNoAsync(string tenantId, string ownerCode, CancellationToken cancellationToken = default);
Task<string> NextOutboundOrderNoAsync(string tenantId, string ownerCode, CancellationToken cancellationToken = default);
}
+1
View File
@@ -281,6 +281,7 @@ public class InventoryService : IInventoryService
LocationCode = item.LocationCode,
MaterialName = materialName,
Qty = item.Qty,
AvailableQty = item.Qty - item.PendingOutboundQty - item.FrozenQty,
PendingInboundQty = item.PendingInboundQty,
PendingOutboundQty = item.PendingOutboundQty,
FrozenQty = item.FrozenQty,
+11 -4
View File
@@ -15,10 +15,16 @@ public class OrderNumberGenerator : IOrderNumberGenerator
}
public async Task<string> NextInboundOrderNoAsync(string tenantId, string ownerCode, CancellationToken cancellationToken = default)
=> await NextOrderNoAsync<Models.InboundOrder>(tenantId, ownerCode, "IN", "入库单");
public async Task<string> NextOutboundOrderNoAsync(string tenantId, string ownerCode, CancellationToken cancellationToken = default)
=> await NextOrderNoAsync<Models.OutboundOrder>(tenantId, ownerCode, "OUT", "出库单");
private async Task<string> NextOrderNoAsync<TOrder>(string tenantId, string ownerCode, string prefix, string displayName)
where TOrder : Models.BaseEntity, new()
{
var tenant = tenantId.Trim();
var owner = ownerCode.Trim();
var prefix = "IN";
var datePart = DateTime.Now.ToString("yyyyMMdd", CultureInfo.InvariantCulture);
const int maxAttempts = 5;
@@ -26,8 +32,9 @@ public class OrderNumberGenerator : IOrderNumberGenerator
{
var seq = await AllocateSequenceAsync(tenant, owner, prefix, datePart);
var no = $"{prefix}{datePart}{seq.ToString("D5", CultureInfo.InvariantCulture)}";
var exists = await _db.Queryable<Models.InboundOrder>()
.Where(x => !x.IsDeleted && x.TenantId == tenant && x.OwnerCode == owner && x.OrderNo == no)
var exists = await _db.Queryable<TOrder>()
.Where(x => !x.IsDeleted && x.TenantId == tenant && x.OwnerCode == owner)
.Where("order_no = @orderNo", new { orderNo = no })
.AnyAsync();
if (!exists)
{
@@ -35,7 +42,7 @@ public class OrderNumberGenerator : IOrderNumberGenerator
}
}
throw new BusinessException("生成唯一入库单单号失败,请重试。");
throw new BusinessException($"生成唯一{displayName}单号失败,请重试。");
}
private async Task<int> AllocateSequenceAsync(string tenantId, string ownerCode, string prefix, string dateYyyyMmDd)
+24 -5
View File
@@ -574,6 +574,7 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
private readonly IOutboundPickTaskRepository _pickTaskRepository;
private readonly ILocationRepository _locationRepository;
private readonly IInventoryAllocationService _allocationService;
private readonly IOrderNumberGenerator _orderNumberGenerator;
private readonly ICurrentUserContext _userContext;
public OutboundOrderService(
@@ -583,6 +584,7 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
IOutboundPickTaskRepository pickTaskRepository,
ILocationRepository locationRepository,
IInventoryAllocationService allocationService,
IOrderNumberGenerator orderNumberGenerator,
IInventoryRepository inventoryRepository,
IInventoryMovementService inventoryMovementService,
ICurrentUserContext userContext) : base(inventoryRepository, inventoryMovementService)
@@ -593,6 +595,7 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
_pickTaskRepository = pickTaskRepository;
_locationRepository = locationRepository;
_allocationService = allocationService;
_orderNumberGenerator = orderNumberGenerator;
_userContext = userContext;
}
@@ -638,16 +641,22 @@ public class OutboundOrderService : OrderServiceBase, IOutboundOrderService
{
return await _tx.ExecuteAsync(async () =>
{
if (await _orderRepository.GetByOrderNoAsync(_userContext.TenantId.Trim(), _userContext.OwnerCode.Trim(), request.OrderNo) is not null)
var tenantId = _userContext.TenantId.Trim();
var ownerCode = _userContext.OwnerCode.Trim();
var orderNo = string.IsNullOrWhiteSpace(request.OrderNo)
? await _orderNumberGenerator.NextOutboundOrderNoAsync(tenantId, ownerCode)
: request.OrderNo.Trim();
if (await _orderRepository.GetByOrderNoAsync(tenantId, ownerCode, orderNo) is not null)
{
throw new BusinessException($"Outbound order '{request.OrderNo}' already exists.");
throw new BusinessException($"Outbound order '{orderNo}' already exists.");
}
var order = new OutboundOrder
{
TenantId = _userContext.TenantId.Trim(),
OwnerCode = _userContext.OwnerCode.Trim(),
OrderNo = request.OrderNo.Trim(),
TenantId = tenantId,
OwnerCode = ownerCode,
OrderNo = orderNo,
BizType = request.BizType?.Trim(),
Remark = request.Remark?.Trim(),
Attrs = request.Attrs,
@@ -891,6 +900,11 @@ public class TransferOrderService : OrderServiceBase, ITransferOrderService
{
return await _tx.ExecuteAsync(async () =>
{
if (string.IsNullOrWhiteSpace(request.OrderNo))
{
throw new BusinessException("OrderNo is required.");
}
if (await _orderRepository.GetByOrderNoAsync(_userContext.TenantId.Trim(), _userContext.OwnerCode.Trim(), request.OrderNo) is not null)
{
throw new BusinessException($"Transfer order '{request.OrderNo}' already exists.");
@@ -1066,6 +1080,11 @@ public class StocktakeOrderService : OrderServiceBase, IStocktakeOrderService
{
return await _tx.ExecuteAsync(async () =>
{
if (string.IsNullOrWhiteSpace(request.OrderNo))
{
throw new BusinessException("OrderNo is required.");
}
if (await _orderRepository.GetByOrderNoAsync(_userContext.TenantId.Trim(), _userContext.OwnerCode.Trim(), request.OrderNo) is not null)
{
throw new BusinessException($"Stocktake order '{request.OrderNo}' already exists.");