using System.Globalization; using Oms.Domain.OperationsAggregate.Entities; namespace Oms.Application.Labeling; /// /// 出库大包标签 PrintData(camelCase,与 hiprint 字段对齐)。 /// public static class ShipBagLabelPrintDataBuilder { public static IReadOnlyDictionary Build( ShipBag bag, string? warehouseName = null, string? operatorName = null, DateTime? printTime = null, int pageIndex = 1, int pageCount = 1) { return new Dictionary(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 BuildMock() => new Dictionary(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}"; } }