All checks were successful
Build and Deploy / deploy (push) Successful in 1m16s
支持按模板批量出签,并补齐件重尺等字段与设计器预览字段。 Co-authored-by: Cursor <cursoragent@cursor.com>
81 lines
3.1 KiB
C#
81 lines
3.1 KiB
C#
using System.Globalization;
|
||
using Oms.Domain.OperationsAggregate.Entities;
|
||
|
||
namespace Oms.Application.Labeling;
|
||
|
||
/// <summary>
|
||
/// 出库大包标签 PrintData(camelCase,与 hiprint 字段对齐)。
|
||
/// </summary>
|
||
public static class ShipBagLabelPrintDataBuilder
|
||
{
|
||
public static IReadOnlyDictionary<string, object?> Build(
|
||
ShipBag bag,
|
||
string? warehouseName = null,
|
||
string? operatorName = null,
|
||
DateTime? printTime = null,
|
||
int pageIndex = 1,
|
||
int pageCount = 1)
|
||
{
|
||
return new Dictionary<string, object?>(StringComparer.OrdinalIgnoreCase)
|
||
{
|
||
["bagNo"] = bag.BagNo,
|
||
["bagType"] = bag.BagType,
|
||
["bagTypeName"] = string.Equals(bag.BagType, "box", StringComparison.OrdinalIgnoreCase) ? "箱子" : "麻袋",
|
||
["status"] = bag.Status,
|
||
["barcode"] = bag.BagNo,
|
||
["destinationCountry"] = bag.DestinationCountry,
|
||
["destinationPort"] = bag.DestinationPort,
|
||
["channelCode"] = bag.ChannelCode,
|
||
["parcelCount"] = bag.ParcelCount,
|
||
["weight"] = bag.Weight,
|
||
["length"] = bag.Length,
|
||
["width"] = bag.Width,
|
||
["height"] = bag.Height,
|
||
["weightUnit"] = "KG",
|
||
["dimUnit"] = "CM",
|
||
["dimensions"] = FormatDims(bag.Length, bag.Width, bag.Height),
|
||
["remark"] = bag.Remark,
|
||
["warehouseName"] = warehouseName,
|
||
["sealTime"] = bag.SealTime?.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||
["pageIndex"] = pageIndex,
|
||
["pageCount"] = pageCount,
|
||
["printTime"] = (printTime ?? DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||
["operatorName"] = operatorName
|
||
};
|
||
}
|
||
|
||
public static IReadOnlyDictionary<string, object?> BuildMock() =>
|
||
new Dictionary<string, object?>(StringComparer.OrdinalIgnoreCase)
|
||
{
|
||
["bagNo"] = "BAG2511071200001234",
|
||
["bagType"] = "sack",
|
||
["bagTypeName"] = "麻袋",
|
||
["status"] = "sealed",
|
||
["barcode"] = "BAG2511071200001234",
|
||
["destinationCountry"] = "US",
|
||
["destinationPort"] = "LAX",
|
||
["channelCode"] = "DEMO",
|
||
["parcelCount"] = 12,
|
||
["weight"] = 18.5m,
|
||
["length"] = 60m,
|
||
["width"] = 40m,
|
||
["height"] = 40m,
|
||
["weightUnit"] = "KG",
|
||
["dimUnit"] = "CM",
|
||
["dimensions"] = "60×40×40",
|
||
["remark"] = null,
|
||
["warehouseName"] = "深圳仓库",
|
||
["sealTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||
["pageIndex"] = 1,
|
||
["pageCount"] = 1,
|
||
["printTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
|
||
["operatorName"] = "demo"
|
||
};
|
||
|
||
private static string? FormatDims(decimal? length, decimal? width, decimal? height)
|
||
{
|
||
if (length is null && width is null && height is null) return null;
|
||
return $"{length ?? 0}×{width ?? 0}×{height ?? 0}";
|
||
}
|
||
}
|