add test and outbound test

This commit is contained in:
zhougf committed 2026-06-01 23:30:36 +08:00
1 parent 38ecbf82e5
commit 7f621dd553
23 files changed
+1301 -26

No files matched your search

@@ -20,4 +20,14 @@ public interface IInventoryRepository : IBaseRepository<Inventory>
InventoryKind inventoryKind,
string? materialCode,
string? containerCode);
Task<List<Inventory>> GetAllocatableAsync(
string tenantId,
string ownerCode,
string warehouseCode,
string areaCode,
InventoryKind inventoryKind,
string? materialCode,
string? containerCode,
string? locationCode = null);
}
@@ -35,6 +35,13 @@ public interface IOutboundOrderLineRepository : IBaseRepository<OutboundOrderLin
Task<List<OutboundOrderLine>> GetByOrderIdAsync(long orderId);
}
public interface IOutboundPickTaskRepository : IBaseRepository<OutboundPickTask>
{
Task<List<OutboundPickTask>> GetByOrderIdAsync(long orderId);
Task<List<OutboundPickTask>> GetByOrderLineIdAsync(long orderLineId);
}
public interface ITransferOrderRepository : IBaseRepository<TransferOrder>
{
Task<TransferOrder?> GetByOrderNoAsync(string tenantId, string ownerCode, string orderNo);
@@ -107,4 +107,38 @@ public class InventoryRepository : BaseRepository<Inventory>, IInventoryReposito
.WhereIF(inventoryKind == InventoryKind.EmptyContainer, x => x.ContainerCode == container)
.FirstAsync();
}
public async Task<List<Inventory>> GetAllocatableAsync(
string tenantId,
string ownerCode,
string warehouseCode,
string areaCode,
InventoryKind inventoryKind,
string? materialCode,
string? containerCode,
string? locationCode = null)
{
var tenant = tenantId.Trim();
var owner = ownerCode.Trim();
var warehouse = warehouseCode.Trim();
var area = areaCode.Trim();
var material = string.IsNullOrWhiteSpace(materialCode) ? null : materialCode.Trim();
var container = string.IsNullOrWhiteSpace(containerCode) ? null : containerCode.Trim();
var location = string.IsNullOrWhiteSpace(locationCode) ? null : locationCode.Trim();
return await Db.Queryable<Inventory>()
.Where(x => !x.IsDeleted
&& x.TenantId == tenant
&& x.OwnerCode == owner
&& x.WarehouseCode == warehouse
&& x.AreaCode == area
&& x.InventoryKind == inventoryKind
&& x.Qty - x.PendingOutboundQty - x.FrozenQty > 0)
.WhereIF(inventoryKind == InventoryKind.Material, x => x.MaterialCode == material)
.WhereIF(inventoryKind == InventoryKind.EmptyContainer, x => x.ContainerCode == container)
.WhereIF(location is not null, x => x.LocationCode == location)
.OrderBy(x => x.CreateTime)
.OrderBy(x => x.Id)
.ToListAsync();
}
}
@@ -178,6 +178,27 @@ public class OutboundOrderLineRepository : OrderLineRepositoryBase<OutboundOrder
public Task<List<OutboundOrderLine>> GetByOrderIdAsync(long orderId) => GetByOrderIdCoreAsync(orderId);
}
public class OutboundPickTaskRepository : OrderLineRepositoryBase<OutboundPickTask>, IOutboundPickTaskRepository
{
public OutboundPickTaskRepository(ISqlSugarClient db, ICurrentUserContext userContext) : base(db, userContext) { }
public async Task<List<OutboundPickTask>> GetByOrderIdAsync(long orderId)
{
return await Db.Queryable<OutboundPickTask>()
.Where(x => !x.IsDeleted && x.OrderId == orderId)
.OrderBy(x => x.TaskNo)
.ToListAsync();
}
public async Task<List<OutboundPickTask>> GetByOrderLineIdAsync(long orderLineId)
{
return await Db.Queryable<OutboundPickTask>()
.Where(x => !x.IsDeleted && x.OrderLineId == orderLineId)
.OrderBy(x => x.TaskNo)
.ToListAsync();
}
}
public class TransferOrderRepository : OrderRepositoryBase<TransferOrder, TransferOrderPagedQuery>, ITransferOrderRepository
{
public TransferOrderRepository(ISqlSugarClient db, ICurrentUserContext userContext) : base(db, userContext) { }