From d76ccc469f243db97959089504aa4a5a8e1ed275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BE=E8=8D=A3=E5=9B=BDHome?= Date: Sat, 2 Apr 2022 17:44:12 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E6=B7=BB=E5=8A=A0X12=20=E9=A2=86=E5=9F=9F?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Asns/ASN_X12_856_3060.cs | 35 +++++++++- .../Asns/ASN_X12_856_3060Extensions.cs | 17 +++++ .../Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs | 23 ++++--- .../Win_in.Sfs.Scp.WebApi.Domain/Asns/DTM.cs | 4 +- .../Asns/FunctionalGroup.cs | 13 ++++ .../Asns/FunctionalGroupExtensions.cs | 16 +++++ .../Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_I.cs | 16 +++++ .../Asns/HL_IExtentions.cs | 36 ++++++++++ .../Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_S.cs | 29 +++++++- .../Asns/HL_SExtensions.cs | 68 +++++++++++++++++++ .../Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_T.cs | 13 ++++ .../Asns/HL_TExtensions.cs | 19 ++++++ .../Asns/HeadAndTrailers/GS.cs | 4 +- .../Asns/HeadAndTrailers/IEA.cs | 4 +- .../Asns/HeadAndTrailers/ISA.cs | 10 +-- .../Win_in.Sfs.Scp.WebApi.Domain/Asns/MEA.cs | 6 +- .../Win_in.Sfs.Scp.WebApi.Domain/Asns/REF.cs | 4 +- .../Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs | 6 +- .../Asns/ShipNotice.cs | 24 ++++++- .../Asns/ShipNoticeExtensions.cs | 23 +++++++ .../Win_in.Sfs.Scp.WebApi.Domain/Asns/TD1.cs | 6 +- .../Win_in.Sfs.Scp.WebApi.Domain/Asns/TD3.cs | 5 +- .../Asns/TransactionSet.cs | 19 +++++- .../Asns/TransactionSetExtensions.cs | 14 ++++ 24 files changed, 371 insertions(+), 43 deletions(-) create mode 100644 WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060Extensions.cs create mode 100644 WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroupExtensions.cs create mode 100644 WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_IExtentions.cs create mode 100644 WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_SExtensions.cs create mode 100644 WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_TExtensions.cs create mode 100644 WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNoticeExtensions.cs create mode 100644 WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSetExtensions.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060.cs index ac31218..0675464 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text; namespace Win_in.Sfs.Scp.WebApi.Asns; @@ -18,11 +19,41 @@ public class ASN_X12_856_3060 /// Functional Group /// 功能组列表 /// - public List SegmentGroups { get; set; } + public List FunctionalGroups { get; set; } /// /// Interchange Control Trailer /// 报文尾 /// - public IEA Iea { get; set; } + public IEA IEA { get; set; } + + public string Encode() + { + var encodeString = this.ToString(); + + return encodeString; + } + + public ASN_X12_856_3060 Decode() + { + + var entity = new ASN_X12_856_3060(); + + + + return entity; + } + + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(ISA.ToString()); + foreach (var functionalGroup in FunctionalGroups) + { + sb.AppendLine(functionalGroup.ToString()); + } + sb.AppendLine(IEA.ToString()); + return sb.ToString(); + } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060Extensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060Extensions.cs new file mode 100644 index 0000000..1663bff --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060Extensions.cs @@ -0,0 +1,17 @@ +using System; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class ASN_X12_856_3060Extensions +{ + public static void SetISA(this ASN_X12_856_3060 asn,string asnCode,string senderId, string receiverId, DateTime datetime, ISA.EnvType envType = ISA.EnvType.P, + string authorization = " ", string security = " ") + { + asn.ISA = new ISA(asnCode,senderId,receiverId,datetime,envType,authorization,security); + } + + public static void SetIEA(this ASN_X12_856_3060 asn,string asnCode) + { + asn.IEA = new IEA(asnCode, asn.FunctionalGroups.Count); + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs index 2d3c990..5b5b271 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs @@ -12,16 +12,15 @@ public class CTT /// Number Of Line Items /// 层级总数 /// - [StringLength(6,MinimumLength = 1)] - public string CTT01 { get; set; } - + [StringLength(6, MinimumLength = 1)] + public string CTT01 => hlCount.ToString(); + /// /// Hash Totals /// 零件总数 /// - [StringLength(10,MinimumLength = 1)] - public string CTT02 { get; set; } - + [StringLength(10, MinimumLength = 1)] + public string CTT02 => hashTotal.ToString(); public string CTT03 { get;} public string CTT04 { get;} @@ -29,13 +28,17 @@ public class CTT public string CTT06 { get;} public string CTT07 { get;} + private int hlCount = 0; + private int hashTotal = 0; + - public CTT(int hlCount,int itemCount) + public int AddHL(int itemCount=0) { - CTT01 = hlCount.ToString(); - CTT02 = itemCount.ToString(); + hlCount++; + hashTotal += itemCount; + return hlCount; } - + public override string ToString() { return "CTT" diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/DTM.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/DTM.cs index 82c746b..38a587c 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/DTM.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/DTM.cs @@ -41,9 +41,9 @@ public class DTM public string DTM06 { get; } public string DTM07 { get; } - public DTM(DateTime datetime, string type = "011") + public DTM(DateTime datetime, string datetimeType = "011") { - DTM01 = type; + DTM01 = datetimeType; DTM02 = datetime.ToString(X12Const.DateFormat); DTM03 = datetime.ToString(X12Const.TimeFormat); } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroup.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroup.cs index 56b9f96..5fbd175 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroup.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroup.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text; namespace Win_in.Sfs.Scp.WebApi.Asns; @@ -25,4 +26,16 @@ public class FunctionalGroup /// 功能组尾 /// public GE GE { get; set; } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(GS.ToString()); + foreach (var transactionSet in TransactionSets) + { + sb.AppendLine(transactionSet.ToString()); + } + sb.AppendLine(GE.ToString()); + return sb.ToString(); + } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroupExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroupExtensions.cs new file mode 100644 index 0000000..fa1ca0c --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroupExtensions.cs @@ -0,0 +1,16 @@ +using System; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class FunctionalGroupExtensions +{ + public static void SetGS(this FunctionalGroup functionalGroup,string senderId, string receiverId, DateTime datetime, string functionalGroupCode) + { + functionalGroup.GS = new GS(senderId, receiverId, datetime, functionalGroupCode); + } + + public static void SetGE(this FunctionalGroup functionalGroup,string functionalGroupCode) + { + functionalGroup.GE = new GE(functionalGroupCode, functionalGroup.TransactionSets.Count); + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_I.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_I.cs index 23baafc..62469c2 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_I.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_I.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text; namespace Win_in.Sfs.Scp.WebApi.Asns; @@ -42,4 +43,19 @@ public class HL_I:HL public HL_I(string code,string parentCode) : base(LevelType.I,code,parentCode) { } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(base.ToString()); + sb.AppendLine(LIN.ToString()); + sb.AppendLine(SN1.ToString()); + sb.AppendLine(PRF.ToString()); + sb.AppendLine(CLD.ToString()); + foreach (var refLS in REF_LSs) + { + sb.AppendLine(refLS.ToString()); + } + return sb.ToString(); + } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_IExtentions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_IExtentions.cs new file mode 100644 index 0000000..84b3572 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_IExtentions.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class HL_IExtentions +{ + public static void SetLIN(this HL_I hli, string itemCode) + { + hli.LIN = new LIN(itemCode); + } + + public static void SetSN1(this HL_I hli, int qty, string uom, int accumQty) + { + hli.SN1 = new SN1(qty, uom, accumQty); + } + + public static void SetPRF(this HL_I hli, string poNumber) + { + hli.PRF = new PRF(poNumber); + } + + public static void SetPRF(this HL_I hli, int loadQty, int unitQty) + { + hli.CLD = new CLD(loadQty, unitQty); + } + + public static void SetREF_LSs(this HL_I hli, List itemLabelCodes) + { + hli.REF_LSs = new List(); + foreach (var refLs in itemLabelCodes.Select(labelCode => new REF(REF.RefType.LS, labelCode))) + { + hli.REF_LSs.Add(refLs); + } + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_S.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_S.cs index 4f62711..ca2c408 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_S.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_S.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text; namespace Win_in.Sfs.Scp.WebApi.Asns; @@ -62,13 +63,13 @@ public class HL_S:HL /// HIERARCHICAL LEVEL (TARE) /// 托盘列表 /// - public List HL_Ts { get; set; } + public List HL_Ts { get; set; } = new List(); /// /// HIERARCHICAL LEVEL (ITEM) /// 单箱列表 /// - public List HL_Is { get; set; } + public List HL_Is { get; set; } = new List(); /// /// @@ -77,4 +78,28 @@ public class HL_S:HL public HL_S(string code) : base(LevelType.S,code) { } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(base.ToString()); + sb.AppendLine(MEA_G.ToString()); + sb.AppendLine(MEA_N.ToString()); + sb.AppendLine(TD1.ToString()); + sb.AppendLine(TD5.ToString()); + sb.AppendLine(TD3.ToString()); + sb.AppendLine(REF_BM.ToString()); + sb.AppendLine(REF_PK.ToString()); + sb.AppendLine(N1_SF.ToString()); + sb.AppendLine(N1_ST.ToString()); + foreach (var hlt in HL_Ts) + { + sb.AppendLine(hlt.ToString()); + } + foreach (var hli in HL_Is) + { + sb.AppendLine(hli.ToString()); + } + return sb.ToString(); + } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_SExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_SExtensions.cs new file mode 100644 index 0000000..a1c83e1 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_SExtensions.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.SignalR; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class HL_SExtensions +{ + public static void SetMEA_G(this HL_S hls,decimal meaValue,string uom) + { + hls.MEA_G = new MEA(MEA.MeaType.G, meaValue, uom); + } + + public static void SetMEA_N(this HL_S hls,decimal meaValue,string uom) + { + hls.MEA_N = new MEA(MEA.MeaType.N, meaValue, uom); + } + + public static void SetTD1(this HL_S hls,string packagingCode,int loadingQty) + { + hls.TD1 = new TD1(packagingCode, loadingQty); + } + + public static void SetTD5(this HL_S hls,string routeSequenceCode,string identificationCode,string mode) + { + hls.TD5 = new TD5(routeSequenceCode, identificationCode, mode); + } + + public static void SetTD3(this HL_S hls,string equipmentCode,string equipmentNumber) + { + hls.TD3 = new TD3(equipmentCode,equipmentNumber); + } + + public static void SetREF_BM(this HL_S hls,string refValue) + { + hls.REF_BM = new REF(REF.RefType.BM, refValue); + } + + public static void SetREF_PK(this HL_S hls,string refValue) + { + hls.REF_PK = new REF(REF.RefType.PK, refValue); + } + + public static void SetN1_SF(this HL_S hls, string fromCode) + { + hls.N1_SF = new N1(N1.NameType.SF, fromCode); + } + + public static void SetN1_ST(this HL_S hls, string toCode) + { + hls.N1_ST = new N1(N1.NameType.ST, toCode); + } + + public static void CreateHL_T(this HL_S hls,ShipNotice shipNotice) + { + var hlCode = shipNotice.AddHL(); + var hlt = new HL_T(hlCode.ToString(), hls.HL01); + hls.HL_Ts.Add(hlt); + } + + public static void CreateHL_I(this HL_S hls, ShipNotice shipNotice,int itemCount) + { + var hlCode = shipNotice.AddHL(itemCount); + var hli = new HL_I(hlCode.ToString(), hls.HL01); + hls.HL_Is.Add(hli); + } + +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_T.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_T.cs index 406de41..46d4b6d 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_T.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_T.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text; namespace Win_in.Sfs.Scp.WebApi.Asns; @@ -25,4 +26,16 @@ public class HL_T:HL public HL_T(string code,string parentCode) : base(LevelType.T,code,parentCode) { } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(base.ToString()); + sb.AppendLine(REF_LS.ToString()); + foreach (var hli in HL_Is) + { + sb.AppendLine(hli.ToString()); + } + return sb.ToString(); + } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_TExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_TExtensions.cs new file mode 100644 index 0000000..17357c9 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_TExtensions.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class HL_TExtensions +{ + public static void SetREF_LS(this HL_T hlt, string tareLabelCode) + { + hlt.REF_LS = new REF(REF.RefType.LS, tareLabelCode); + } + + public static void CreateHL_I(this HL_T hlt, ShipNotice shipNotice,int itemCount) + { + var hlCode = shipNotice.AddHL(itemCount); + var hli = new HL_I(hlCode.ToString(), hlt.HL01); + hlt.HL_Is.Add(hli); + } + +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/GS.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/GS.cs index 701735e..6efb309 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/GS.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/GS.cs @@ -73,13 +73,13 @@ public class GS [StringLength(1, MinimumLength = 12)] public string GS08 { get; } = "003060"; - public GS(string senderId, string receiverId, DateTime datetime, string code) + public GS(string senderId, string receiverId, DateTime datetime, string functionalGroupCode) { GS02 = senderId; GS03 = receiverId; GS04 = datetime.ToString(X12Const.DateFormat); GS05 = datetime.ToString(X12Const.TimeFormat); - GS06 = code; + GS06 = functionalGroupCode; } public override string ToString() diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/IEA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/IEA.cs index 8175ff8..b50e77a 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/IEA.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/IEA.cs @@ -23,10 +23,10 @@ public class IEA [StringLength(9, MinimumLength = 9)] public string IEA02 { get; set; } - public IEA(string code, int count = 1) + public IEA(string asnCode, int count = 1) { IEA01 = count.ToString(); - IEA02 = code; + IEA02 = asnCode; } public override string ToString() diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/ISA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/ISA.cs index 13fbdce..4a3a2b3 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/ISA.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/ISA.cs @@ -141,15 +141,15 @@ public class ISA [StringLength(1, MinimumLength = 1)] public string ISA16 { get; set; } = "|"; - public ISA(string senderId, string receiverId, string date, DateTime datetime, EnvType type = EnvType.P, + public ISA(string asnCode,string senderId, string receiverId, DateTime datetime, EnvType envType = EnvType.P, string authorization = " ", string security = " ") { ISA06 = senderId; ISA08 = receiverId; - ISA09 = date; - ISA10 = datetime.ToString(X12Const.DateFormat); - ISA13 = datetime.ToString(X12Const.TimeFormat); - ISA15 = type.ToString(); + ISA09 = datetime.ToString(X12Const.DateFormat); + ISA09 = datetime.ToString(X12Const.TimeFormat); + ISA10 = asnCode; + ISA15 = envType.ToString(); ISA02 = authorization; ISA04 = security; } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/MEA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/MEA.cs index 7a5b0e8..934b147 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/MEA.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/MEA.cs @@ -49,10 +49,10 @@ public class MEA public string MEA09 { get;} public string MEA10 { get;} - public MEA(MeaType type,string value,string uom) + public MEA(MeaType meaType,decimal meaValue,string uom) { - MEA02 = type.ToString(); - MEA03 = value; + MEA02 = meaType.ToString(); + MEA03 = meaValue.ToString(); MEA04 = uom; } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/REF.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/REF.cs index aa68db0..a8d8056 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/REF.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/REF.cs @@ -32,9 +32,9 @@ public class REF REF01 = type.ToString(); } - public REF(RefType type,string value):this(type) + public REF(RefType type,string refValue):this(type) { - REF02 = value; + REF02 = refValue; } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs index 5800de0..6b03646 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs @@ -32,7 +32,7 @@ public class SN1 public string SN103 { get; set; } /// - /// Quantity Shipped To Date + /// Accum quantity of preceding LIN's part number /// 累计已发数量 /// [StringLength(9, MinimumLength = 1)] @@ -43,11 +43,11 @@ public class SN1 public string SN107 { get;} public string SN108 { get;} - public SN1(int qty,string uom,int totalQty) + public SN1(int qty,string uom,int accumQty) { SN102 = qty.ToString(); SN103 = uom; - SN104 = totalQty.ToString(); + SN104 = accumQty.ToString(); } public override string ToString() diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotice.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotice.cs index f40f2f6..c67510e 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotice.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotice.cs @@ -1,4 +1,6 @@ -namespace Win_in.Sfs.Scp.WebApi.Asns; +using System.Text; + +namespace Win_in.Sfs.Scp.WebApi.Asns; /// /// Ship Notice @@ -22,11 +24,27 @@ public class ShipNotice /// Hierarchical Level of Shipment /// 发货单层级 /// - public HL HL_S { get; set; } + public HL_S HL_S { get; set; } /// /// Transaction Totals /// 事务汇总 /// - public CTT CTT { get; set; } + public CTT CTT { get; } + + public int AddHL(int itemCount = 0) + { + return CTT.AddHL(itemCount); + } + + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(BSN.ToString()); + sb.AppendLine(DTM.ToString()); + sb.AppendLine(HL_S.ToString()); + sb.AppendLine(CTT.ToString()); + return sb.ToString(); + } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNoticeExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNoticeExtensions.cs new file mode 100644 index 0000000..1b932cc --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNoticeExtensions.cs @@ -0,0 +1,23 @@ +using System; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class ShipNoticeExtensions +{ + public static void SetBSN(this ShipNotice shipNotice,string noticeNumber, DateTime datetime, string purpose = "00") + { + shipNotice.BSN = new BSN(noticeNumber, datetime, purpose); + } + + public static void SetDTM(this ShipNotice shipNotice, DateTime dateTime,string datetimeType) + { + shipNotice.DTM = new DTM(dateTime, datetimeType); + } + + public static void CreateHL_S(this ShipNotice shipNotice) + { + var hlCode = shipNotice.AddHL(); + shipNotice.HL_S = new HL_S(hlCode.ToString()); + } + +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD1.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD1.cs index ffd653a..c436a66 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD1.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD1.cs @@ -32,10 +32,10 @@ public class TD1 public string TD109 { get;} public string TD110 { get;} - public TD1(string code,int qty) + public TD1(string packagingCode,int loadingQty) { - TD101 = code; - TD102 = qty.ToString(); + TD101 = packagingCode; + TD102 = loadingQty.ToString(); } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD3.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD3.cs index c83a95e..a365f3b 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD3.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD3.cs @@ -31,9 +31,10 @@ public class TD3 public string TD308 { get;} public string TD309 { get;} - public TD3() + public TD3(string equipmentCode,string equipmentNumber) { - + TD301 = equipmentCode; + TD303 = equipmentNumber; } public override string ToString() diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSet.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSet.cs index 1aa3b05..9d3d70e 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSet.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSet.cs @@ -1,4 +1,7 @@ -namespace Win_in.Sfs.Scp.WebApi.Asns; +using System.Collections.Generic; +using System.Text; + +namespace Win_in.Sfs.Scp.WebApi.Asns; /// /// Transaction Set @@ -16,7 +19,7 @@ public class TransactionSet /// Ship Notice /// 发货单列表 /// - public ShipNotice ShipNotice { get; set; } + public List ShipNotices { get; set; } /// /// Transaction Set Trailer @@ -24,4 +27,16 @@ public class TransactionSet /// public SE SE { get; set; } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(ST.ToString()); + foreach (var shipNotice in ShipNotices) + { + sb.AppendLine(shipNotice.ToString()); + } + sb.AppendLine(SE.ToString()); + return sb.ToString(); + } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSetExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSetExtensions.cs new file mode 100644 index 0000000..e8006d2 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSetExtensions.cs @@ -0,0 +1,14 @@ +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class TransactionSetExtensions +{ + public static void SetST(this TransactionSet transactionSet,string transactionCode) + { + transactionSet.ST = new ST(transactionCode); + } + + public static void SetSE(this TransactionSet transactionSet, string transactionCode) + { + transactionSet.SE = new SE(transactionCode, transactionSet.ShipNotices.Count); + } +} \ No newline at end of file