InventoryLocationCheck.cs 1.2 KB

123456789101112131415161718192021222324252627282930
  1. using Admin.NET.Plugin.AiDOP.MaterialWarehouse.InventoryPosting.Inventory;
  2. namespace Admin.NET.Plugin.AiDOP.MaterialWarehouse.InventoryPosting.Receipt;
  3. public sealed class InventoryLocationCheckResult
  4. {
  5. public bool Ok { get; set; }
  6. public string Message { get; set; }
  7. public IReadOnlyList<string> OffendingItems { get; set; } = System.Array.Empty<string>();
  8. }
  9. /// <summary>
  10. /// C5 前置 CheckInventoryStatus 轻校验(复刻 pr_SFM_CheckInventoryStatus:InventoryTVP 中 Location 为空即失败)。
  11. /// **不是** C5 九道 Guard 的替代,不做库存充足性校验——仅保证每条库存命令有库位。
  12. /// </summary>
  13. public static class InventoryLocationCheck
  14. {
  15. public static InventoryLocationCheckResult Validate(IReadOnlyList<InventoryTransactionCommand> cmds)
  16. {
  17. if (cmds == null) throw new ArgumentNullException(nameof(cmds));
  18. var offenders = cmds.Where(c => string.IsNullOrEmpty(c.Location))
  19. .Select(c => c.ItemNum).Distinct(StringComparer.Ordinal).ToList();
  20. return new InventoryLocationCheckResult
  21. {
  22. Ok = offenders.Count == 0,
  23. Message = offenders.Count == 0 ? null : "存在库位为空的记录",
  24. OffendingItems = offenders,
  25. };
  26. }
  27. }