20261026 #14

Merged
zzh merged 4 commits from test into master 2026-10-26 12:26:56 +08:00
Showing only changes of commit 1caca3c357 - Show all commits

View File

@ -128,7 +128,7 @@ public partial class WarehouseService
var resolvedCustomerId = await ResolveListCustomerIdAsync(customerId);
var notice = await GetInboundNoticeOrThrowAsync(resolvedCustomerId, id);
var boxes = await InboundBoxRepository.GetListAsync(x => x.InboundNoticeId == notice.Id);
boxes = boxes.OrderBy(x => x.BoxSeqNo).ThenBy(x => x.Id).ToList();
boxes = OrderInboundBoxes(boxes);
var boxIds = boxes.Select(x => x.Id).ToArray();
var lines = boxIds.Length == 0
? []
@ -367,7 +367,8 @@ public partial class WarehouseService
var customerId = await ResolveListCustomerIdAsync(input.CustomerId);
var notice = await GetInboundNoticeOrThrowAsync(customerId, input.Id);
var boxes = await InboundBoxRepository.GetListAsync(x => x.InboundNoticeId == notice.Id);
boxes = boxes.OrderBy(x => x.BoxSeqNo).ThenBy(x => x.Id).ToList();
// BoxSeqNo 为字符串,必须按数值排,否则 10 会排在 2 前面导致箱唛乱序
boxes = OrderInboundBoxes(boxes);
if (boxes.Count == 0)
{
throw new BusinessException("该预报没有箱子,无法打印箱唛");
@ -549,4 +550,23 @@ public partial class WarehouseService
BinLocationId = line.BinLocationId
}).ToList()
};
/// <summary>
/// 按箱序号数值升序;无法解析的序号排最后,同序号再按 Id。
/// </summary>
private static List<CInboundBox> OrderInboundBoxes(IEnumerable<CInboundBox> boxes) =>
boxes
.OrderBy(x => ParseBoxSeqNo(x.BoxSeqNo))
.ThenBy(x => x.Id)
.ToList();
private static int ParseBoxSeqNo(string? boxSeqNo)
{
if (string.IsNullOrWhiteSpace(boxSeqNo))
{
return int.MaxValue;
}
return int.TryParse(boxSeqNo.Trim(), out var n) && n > 0 ? n : int.MaxValue;
}
}