diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/AsnFactory.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/AsnFactory.cs index b818653..7cfeeee 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/AsnFactory.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/AsnFactory.cs @@ -13,23 +13,23 @@ namespace Win_in.Sfs.Scp.WebApi.Console var asnCode = scpAsn.AsnBillNum; var senderId = scpAsn.VendId; - var receiverId = "receiver"; + var receiverId = "IACNA_ID"; var shipTime = scpAsn.ShipTime ?? DateTime.Now; var envType = ISA.EnvType.P; - var authorization = " "; - var security = " "; + var authorization = ""; + var security = ""; //初始化ASN单 - var asn = InitAsn(asnCode,senderId,receiverId,shipTime,envType,authorization,security); + var asn = CreateAsn(asnCode,senderId,receiverId,shipTime,envType,authorization,security); - var functionalGroupCode = "0000000000"; + var functionalGroupCode = "123456789"; //初始化功能组 - var functionalGroup = InitFunctionalGroup(senderId,receiverId,shipTime,functionalGroupCode); + var functionalGroup = CreateFunctionalGroup(senderId,receiverId,shipTime,functionalGroupCode); var shipNoticeCode = "0001"; var datetimeType = "011"; //初始化发货单 - var shipNotice = InitShipNotice(shipNoticeCode,functionalGroupCode,shipTime,datetimeType); + var shipNotice = CreateShipNotice(shipNoticeCode,functionalGroupCode,shipTime,datetimeType); var gValue = 0; var gUom = "KG"; @@ -39,9 +39,9 @@ namespace Win_in.Sfs.Scp.WebApi.Console var identificationCode = "PSTV"; var mode = "LT"; var equipmentCode = "TL"; - var equipmentNumber = "123456";//车牌号 + var equipmentNumber = "123456";//TODO 车牌号 //初始化发货明细 - var shipment = InitShipment(gValue,gUom,nValue,nUom,routeSequenceCode,identificationCode,mode, + var shipment = CreateShipment(shipNotice,gValue,gUom,nValue,nUom,routeSequenceCode,identificationCode,mode, equipmentCode,equipmentNumber,functionalGroupCode,functionalGroupCode,senderId,receiverId); @@ -101,50 +101,51 @@ namespace Win_in.Sfs.Scp.WebApi.Console //装载量需要在添加托盘和尾箱后再计算 var loadingQty = shipment.Tares.Count+shipment.OrphanItems.Count; shipment.SetTD1(packagingCode, loadingQty); - //添加发货明细 - shipNotice.AddShipment(shipment); - //设置发货单汇总 - shipNotice.SetCTT(); + + shipNotice + .AddShipment(shipment) //添加发货明细 + .SetCTT() //设置发货单汇总 + .SetSE(shipNoticeCode); //设置发货明细结尾 //添加发货单 - functionalGroup.AddShipNotice(shipNotice); - functionalGroup.SetGE(functionalGroupCode); + functionalGroup + .AddShipNotice(shipNotice) + .SetGE(functionalGroupCode); //添加功能组 - asn.AddFunctionGroup(functionalGroup); - + asn + .AddFunctionGroup(functionalGroup) + .SetIEA(asnCode); return asn; } - private ASN_X12_856_3060 InitAsn(string asnCode, string senderId, string receiverId, DateTime datetime, - ISA.EnvType envType = ISA.EnvType.P, string authorization = " ", string security = " ") + private ASN_X12_856_3060 CreateAsn(string asnCode, string senderId, string receiverId, DateTime datetime, + ISA.EnvType envType = ISA.EnvType.P, string authorization = "", string security = "") { var asn = new ASN_X12_856_3060(); - asn.SetISA(asnCode, senderId, receiverId, datetime, envType, authorization, security) - .SetIEA(asnCode); + asn.SetISA(asnCode, senderId, receiverId, datetime, envType, authorization, security); return asn; } - private FunctionalGroup InitFunctionalGroup(string senderId, string receiverId, DateTime datetime, + private FunctionalGroup CreateFunctionalGroup(string senderId, string receiverId, DateTime datetime, string functionalGroupCode) { var functionGroup = new FunctionalGroup(); - functionGroup - .SetGS(senderId, receiverId, datetime, functionalGroupCode); + functionGroup.SetGS(senderId, receiverId, datetime, functionalGroupCode); return functionGroup; } - private ShipNotice InitShipNotice(string shipNoticeCode, string noticeNumber, DateTime datetime, + private ShipNotice CreateShipNotice(string shipNoticeCode, string noticeNumber, DateTime datetime, string datetimeType="011", string purpose = "00") { var shipNotice = new ShipNotice(); shipNotice .SetST(shipNoticeCode) .SetBSN(noticeNumber, datetime, purpose) - .SetDTM(datetime, datetimeType) - .SetSE(shipNoticeCode); + .SetDTM(datetime, datetimeType); + shipNotice.AddSegment(4); return shipNotice; } - private Shipment InitShipment(decimal gValue, string gUom, decimal nValue, string nUom, + private Shipment CreateShipment(ShipNotice shipNotice, decimal gValue, string gUom, decimal nValue, string nUom, string routeSequenceCode, string identificationCode, string mode, string equipmentCode, string equipmentNumber, string bmRefValue, string pkRefValue, string senderId, string receiverId) { @@ -160,6 +161,7 @@ namespace Win_in.Sfs.Scp.WebApi.Console .SetN1_SF(senderId) .SetN1_ST(receiverId) ; + shipNotice.AddSegment(10); return shipment; } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs index c3094b1..37ed14c 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs @@ -24,74 +24,74 @@ namespace Win_in.Sfs.Scp.WebApi.Console { new TS_BARCODE() { - BarCode = "A01", - PartCode = "AAAAA", + BarCode = "BARCODE_01", + PartCode = "PART_A", Qty=20, Batch="20220404", PoUnit = "EA", PoBillNum = "PO1111", PackQty = 20, - Extend2 = "PALLET01" + Extend2 = "PALLET_01" }, new TS_BARCODE() { - BarCode = "A02", - PartCode = "AAAAA", + BarCode = "BARCODE_02", + PartCode = "PART_A", Qty=20, Batch="20220404", PoUnit = "EA", PoBillNum = "PO1111", PackQty = 20, - Extend2 = "PALLET01" + Extend2 = "PALLET_01" }, new TS_BARCODE() { - BarCode = "B01", - PartCode = "BBBBB", + BarCode = "BARCODE_03", + PartCode = "PART_B", Qty=15, Batch="20220404", PoUnit = "EA", PoBillNum = "PO2222", PackQty = 15, - Extend2 = "PALLET01" + Extend2 = "PALLET_01" }, new TS_BARCODE() { - BarCode = "B02", - PartCode = "BBBBB", + BarCode = "BARCODE_04", + PartCode = "PART_B", Qty=15, Batch="20220404", PoUnit = "EA", PoBillNum = "PO2222", PackQty = 15, - Extend2 = "PALLET01" + Extend2 = "PALLET_01" }, new TS_BARCODE() { - BarCode = "C01", - PartCode = "CCCCC", + BarCode = "BARCODE_05", + PartCode = "PART_C", Qty=40, Batch="20220404", PoUnit = "KG", PoBillNum = "PO3333", PackQty = 40, - Extend2 = "PALLET02" + Extend2 = "PALLET_02" }, new TS_BARCODE() { - BarCode = "C02", - PartCode = "CCCCC", + BarCode = "BARCODE_06", + PartCode = "PART_C", Qty=40, Batch="20220404", PoUnit = "KG", PoBillNum = "PO3333", PackQty = 40, - Extend2 = "PALLET02" + Extend2 = "PALLET_02" }, new TS_BARCODE() { - BarCode = "C03", - PartCode = "CCCCC", + BarCode = "BARCODE_07", + PartCode = "PART_C", Qty=40, Batch="20220404", PoUnit = "KG", @@ -107,8 +107,8 @@ namespace Win_in.Sfs.Scp.WebApi.Console { var scpAsn = new TB_ASN() { - AsnBillNum = "ASNBILLNUM", - VendId = "VENDID", + AsnBillNum = "ASN123456", + VendId = "VENDOR_ID", ShipTime = DateTime.Now, }; 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 index c64c323..b9fe6e2 100644 --- 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 @@ -5,7 +5,7 @@ namespace Win_in.Sfs.Scp.WebApi.Asns; public static class ASN_X12_856_3060Extensions { public static ASN_X12_856_3060 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 = " ") + string authorization = "", string security = "") { asn.ISA = new ISA(asnCode,senderId,receiverId,datetime,envType,authorization,security); return asn; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IEA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IEA.cs index b50e77a..7794ede 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IEA.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IEA.cs @@ -26,7 +26,7 @@ public class IEA public IEA(string asnCode, int count = 1) { IEA01 = count.ToString(); - IEA02 = asnCode; + IEA02 = asnCode.PadRight(9); } public override string ToString() diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs index 4a3a2b3..71ce489 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs @@ -142,16 +142,16 @@ public class ISA public string ISA16 { get; set; } = "|"; public ISA(string asnCode,string senderId, string receiverId, DateTime datetime, EnvType envType = EnvType.P, - string authorization = " ", string security = " ") + string authorization = "", string security = "") { - ISA06 = senderId; - ISA08 = receiverId; + ISA06 = senderId.PadRight(15); + ISA08 = receiverId.PadRight(15); ISA09 = datetime.ToString(X12Const.DateFormat); ISA09 = datetime.ToString(X12Const.TimeFormat); - ISA10 = asnCode; + ISA10 = asnCode.PadRight(9); ISA15 = envType.ToString(); - ISA02 = authorization; - ISA04 = security; + ISA02 = authorization.PadRight(10); + ISA04 = security.PadRight(10); } public override string ToString() diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs index 49be11c..f66d9c6 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs @@ -38,25 +38,26 @@ public class SN1 [StringLength(9, MinimumLength = 1)] public string SN104 { get; set; } - public string SN105 { get;} - public string SN106 { get;} - public string SN107 { get;} - public string SN108 { get;} + public string SN105 { get; } + public string SN106 { get; } + public string SN107 { get; } + public string SN108 { get; } public decimal Qty { get; set; } - public SN1(decimal qty,string uom,int accumQty) + public SN1(decimal qty, string uom, int accumQty) { Qty = qty; SN103 = uom; SN104 = accumQty.ToString(); } - + public override string ToString() { return "SN1" + X12Const.ElementSeparator + SN101 + X12Const.ElementSeparator + SN102 - + X12Const.ElementSeparator + SN103; + + X12Const.ElementSeparator + SN103 + + X12Const.ElementSeparator + SN104; } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs index 35b168f..43fb34c 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs @@ -81,8 +81,8 @@ public class ShipNotice return HlCount.ToString(); } - public void AddSegment() + public void AddSegment(int count) { - SegmentCount++; + SegmentCount+=count; } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/ShipmentExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/ShipmentExtensions.cs index 86f662e..93aad11 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/ShipmentExtensions.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/ShipmentExtensions.cs @@ -71,6 +71,7 @@ public static class ShipmentExtensions tare.HL.HL01 = shipNotice.GetNextHl(); tare.HL.HL02 = shipment.HL.HL01; shipment.Tares.Add(tare); + shipNotice.AddSegment(2); return shipment; } @@ -79,6 +80,7 @@ public static class ShipmentExtensions orphanItem.HL.HL01 = shipNotice.GetNextHl(orphanItem.SN1.Qty); orphanItem.HL.HL02 = shipment.HL.HL01; shipment.OrphanItems.Add(orphanItem); + shipNotice.AddSegment(5+orphanItem.REF_LSs.Count); return shipment; } diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/TareExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/TareExtensions.cs index 43bc49f..4dfbc85 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/TareExtensions.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/TareExtensions.cs @@ -23,6 +23,7 @@ public static class TareExtensions item.HL.HL01 = shipNotice.GetNextHl(item.SN1.Qty); item.HL.HL02 = tare.HL.HL01; tare.Items.Add(item); + shipNotice.AddSegment(5+item.REF_LSs.Count); return tare; }