| 123456789101112131415161718192021222324252627282930 |
- using Admin.NET.Plugin.AiDOP.MaterialWarehouse.InventoryPosting.Inventory;
- namespace Admin.NET.Plugin.AiDOP.MaterialWarehouse.InventoryPosting.Receipt;
- public sealed class InventoryLocationCheckResult
- {
- public bool Ok { get; set; }
- public string Message { get; set; }
- public IReadOnlyList<string> OffendingItems { get; set; } = System.Array.Empty<string>();
- }
- /// <summary>
- /// C5 前置 CheckInventoryStatus 轻校验(复刻 pr_SFM_CheckInventoryStatus:InventoryTVP 中 Location 为空即失败)。
- /// **不是** C5 九道 Guard 的替代,不做库存充足性校验——仅保证每条库存命令有库位。
- /// </summary>
- public static class InventoryLocationCheck
- {
- public static InventoryLocationCheckResult Validate(IReadOnlyList<InventoryTransactionCommand> cmds)
- {
- if (cmds == null) throw new ArgumentNullException(nameof(cmds));
- var offenders = cmds.Where(c => string.IsNullOrEmpty(c.Location))
- .Select(c => c.ItemNum).Distinct(StringComparer.Ordinal).ToList();
- return new InventoryLocationCheckResult
- {
- Ok = offenders.Count == 0,
- Message = offenders.Count == 0 ? null : "存在库位为空的记录",
- OffendingItems = offenders,
- };
- }
- }
|