fix: 入库箱唛按箱序号数值排序,避免超过 9 箱时乱序
All checks were successful
Build and Deploy / deploy (push) Successful in 1m14s
All checks were successful
Build and Deploy / deploy (push) Successful in 1m14s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
ccb9c055a5
commit
1caca3c357
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user