diff --git a/WebApiService/Win_in.Sfs.Scp.WebApi.sln b/WebApiService/Win_in.Sfs.Scp.WebApi.sln index 14a2a0f..1b99ce9 100644 --- a/WebApiService/Win_in.Sfs.Scp.WebApi.sln +++ b/WebApiService/Win_in.Sfs.Scp.WebApi.sln @@ -49,6 +49,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scp", "scp", "{925EA68F-25D EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "webApi", "webApi", "{A79A01B2-9532-4C6B-880F-193251F3B9F3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win_in.Sfs.Scp.WebApi.Console", "src\Win_in.Sfs.Scp.WebApi.Console\Win_in.Sfs.Scp.WebApi.Console.csproj", "{FAC4C418-08A2-48C5-A966-A832FB091C78}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -127,6 +129,10 @@ Global {98CDED94-F046-4010-88F4-700B7481169E}.Debug|Any CPU.Build.0 = Debug|Any CPU {98CDED94-F046-4010-88F4-700B7481169E}.Release|Any CPU.ActiveCfg = Release|Any CPU {98CDED94-F046-4010-88F4-700B7481169E}.Release|Any CPU.Build.0 = Release|Any CPU + {FAC4C418-08A2-48C5-A966-A832FB091C78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAC4C418-08A2-48C5-A966-A832FB091C78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAC4C418-08A2-48C5-A966-A832FB091C78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAC4C418-08A2-48C5-A966-A832FB091C78}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -152,6 +158,7 @@ Global {98CDED94-F046-4010-88F4-700B7481169E} = {44A92E7C-E2FC-4F37-AF3D-6B7213EF54FE} {925EA68F-25D1-444F-A79B-EB9BF754EC3C} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {A79A01B2-9532-4C6B-880F-193251F3B9F3} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} + {FAC4C418-08A2-48C5-A966-A832FB091C78} = {A79A01B2-9532-4C6B-880F-193251F3B9F3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} diff --git a/WebApiService/Win_in.Sfs.Scp.WebApi.sln.DotSettings b/WebApiService/Win_in.Sfs.Scp.WebApi.sln.DotSettings index cb0b2c9..d8f37d2 100644 --- a/WebApiService/Win_in.Sfs.Scp.WebApi.sln.DotSettings +++ b/WebApiService/Win_in.Sfs.Scp.WebApi.sln.DotSettings @@ -20,4 +20,5 @@ False False SQL + True \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/AsnFactory.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/AsnFactory.cs new file mode 100644 index 0000000..b818653 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/AsnFactory.cs @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Win_in.Sfs.Scp.v1.Domain.Asns; +using Win_in.Sfs.Scp.WebApi.Asns; + +namespace Win_in.Sfs.Scp.WebApi.Console +{ + public class AsnFactory + { + public ASN_X12_856_3060 CreateAsnX128563060(TB_ASN scpAsn,List barcodes) + { + + var asnCode = scpAsn.AsnBillNum; + var senderId = scpAsn.VendId; + var receiverId = "receiver"; + var shipTime = scpAsn.ShipTime ?? DateTime.Now; + + var envType = ISA.EnvType.P; + var authorization = " "; + var security = " "; + //初始化ASN单 + var asn = InitAsn(asnCode,senderId,receiverId,shipTime,envType,authorization,security); + + var functionalGroupCode = "0000000000"; + //初始化功能组 + var functionalGroup = InitFunctionalGroup(senderId,receiverId,shipTime,functionalGroupCode); + + var shipNoticeCode = "0001"; + var datetimeType = "011"; + //初始化发货单 + var shipNotice = InitShipNotice(shipNoticeCode,functionalGroupCode,shipTime,datetimeType); + + var gValue = 0; + var gUom = "KG"; + var nValue = 0; + var nUom = "KG"; + var routeSequenceCode = "B"; + var identificationCode = "PSTV"; + var mode = "LT"; + var equipmentCode = "TL"; + var equipmentNumber = "123456";//车牌号 + //初始化发货明细 + var shipment = InitShipment(gValue,gUom,nValue,nUom,routeSequenceCode,identificationCode,mode, + equipmentCode,equipmentNumber,functionalGroupCode,functionalGroupCode,senderId,receiverId); + + + //计算与添加托盘和尾箱 + var palletCodes = barcodes.Select(p => p.Extend2).Distinct().ToList(); + foreach (var palletCode in palletCodes) + { + var palletBarcodes = barcodes.Where(p => p.Extend2==palletCode).ToList(); + + var items = new List(); + var group = palletBarcodes + .GroupBy(p => new { p.PartCode, p.Qty, p.Batch, p.PoUnit, p.PoBillNum,p.PackQty}) + .Select(p => new + { + p.Key.PartCode, + p.Key.Qty, + p.Key.Batch, + p.Key.PoUnit, + p.Key.PoBillNum, + p.Key.PackQty, + Labels = p.Select(p=>p.BarCode).ToList() + }) + .ToList(); + + foreach (var b in group) + { + var accumQty = 0;//TODO 如何计算 + var loadQty = b.Labels.Count; + var unitQty = b.PackQty; + var item = CreateItem(b.PartCode, loadQty * unitQty, b.PoUnit, accumQty, b.PoBillNum, loadQty, unitQty,b.Labels); + items.Add(item); + } + + //如果托标签为空,当作尾箱处理 + if (string.IsNullOrEmpty(palletCode)) + { + foreach (var item in items) + { + shipment.AddOrphanItem(shipNotice,item); + } + } + //添加托盘 + else + { + var tare = CreateTare(palletCode); + shipment.AddTare(shipNotice,tare); + foreach (var item in items) + { + tare.AddItem(shipNotice, item); + } + } + + } + + //TODO 如何获取包装代码,或者规则是什么? + var packagingCode = "PLT90"; + //装载量需要在添加托盘和尾箱后再计算 + var loadingQty = shipment.Tares.Count+shipment.OrphanItems.Count; + shipment.SetTD1(packagingCode, loadingQty); + //添加发货明细 + shipNotice.AddShipment(shipment); + //设置发货单汇总 + shipNotice.SetCTT(); + //添加发货单 + functionalGroup.AddShipNotice(shipNotice); + functionalGroup.SetGE(functionalGroupCode); + //添加功能组 + asn.AddFunctionGroup(functionalGroup); + + 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 = " ") + { + var asn = new ASN_X12_856_3060(); + asn.SetISA(asnCode, senderId, receiverId, datetime, envType, authorization, security) + .SetIEA(asnCode); + return asn; + } + + private FunctionalGroup InitFunctionalGroup(string senderId, string receiverId, DateTime datetime, + string functionalGroupCode) + { + var functionGroup = new FunctionalGroup(); + functionGroup + .SetGS(senderId, receiverId, datetime, functionalGroupCode); + return functionGroup; + } + + private ShipNotice InitShipNotice(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); + return shipNotice; + } + + private Shipment InitShipment(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) + { + var shipment = new Shipment(); + shipment + .SetHL() + .SetMEA_G(gValue, gUom) + .SetMEA_N(nValue, nUom) + .SetTD5(routeSequenceCode, identificationCode, mode) + .SetTD3(equipmentCode, equipmentNumber) + .SetREF_BM(bmRefValue) + .SetREF_PK(pkRefValue) + .SetN1_SF(senderId) + .SetN1_ST(receiverId) + ; + + return shipment; + } + + private Tare CreateTare(string tareLabelCode) + { + var tare = new Tare(); + tare.SetHL() + .SetREF_LS(tareLabelCode); + + return tare; + } + + private Item CreateItem(string itemCode, decimal qty, string uom, int accumQty, + string poNumber, int loadQty, decimal unitQty, List itemLabelCodes) + { + + var item = new Item(); + item.SetHL() + .SetLIN(itemCode) + .SetSN1(qty, uom, accumQty) + .SetPRF(poNumber) + .SetCLD(loadQty, unitQty) + .SetREF_LSs(itemLabelCodes); + return item; + } + + + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs new file mode 100644 index 0000000..c3094b1 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using Win_in.Sfs.Scp.v1.Domain.Asns; + +namespace Win_in.Sfs.Scp.WebApi.Console +{ + internal class Program + { + static void Main(string[] args) + { + + var asnFactory = new AsnFactory(); + var scpAsn = InitTbAsn(); + var barcodes = InitTsBarcodes(); + var asn = asnFactory.CreateAsnX128563060(scpAsn, barcodes); + var ediString = asn.ToString(); + System.Console.WriteLine(ediString); + System.Console.Read(); + } + + private static List InitTsBarcodes() + { + var barcodes = new List() + { + new TS_BARCODE() + { + BarCode = "A01", + PartCode = "AAAAA", + Qty=20, + Batch="20220404", + PoUnit = "EA", + PoBillNum = "PO1111", + PackQty = 20, + Extend2 = "PALLET01" + }, + new TS_BARCODE() + { + BarCode = "A02", + PartCode = "AAAAA", + Qty=20, + Batch="20220404", + PoUnit = "EA", + PoBillNum = "PO1111", + PackQty = 20, + Extend2 = "PALLET01" + }, + new TS_BARCODE() + { + BarCode = "B01", + PartCode = "BBBBB", + Qty=15, + Batch="20220404", + PoUnit = "EA", + PoBillNum = "PO2222", + PackQty = 15, + Extend2 = "PALLET01" + }, + new TS_BARCODE() + { + BarCode = "B02", + PartCode = "BBBBB", + Qty=15, + Batch="20220404", + PoUnit = "EA", + PoBillNum = "PO2222", + PackQty = 15, + Extend2 = "PALLET01" + }, + new TS_BARCODE() + { + BarCode = "C01", + PartCode = "CCCCC", + Qty=40, + Batch="20220404", + PoUnit = "KG", + PoBillNum = "PO3333", + PackQty = 40, + Extend2 = "PALLET02" + }, + new TS_BARCODE() + { + BarCode = "C02", + PartCode = "CCCCC", + Qty=40, + Batch="20220404", + PoUnit = "KG", + PoBillNum = "PO3333", + PackQty = 40, + Extend2 = "PALLET02" + }, + new TS_BARCODE() + { + BarCode = "C03", + PartCode = "CCCCC", + Qty=40, + Batch="20220404", + PoUnit = "KG", + PoBillNum = "PO3333", + PackQty = 23, + Extend2 = "" + }, + }; + return barcodes; + } + + private static TB_ASN InitTbAsn() + { + var scpAsn = new TB_ASN() + { + AsnBillNum = "ASNBILLNUM", + VendId = "VENDID", + ShipTime = DateTime.Now, + + }; + return scpAsn; + } + } +} diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Win_in.Sfs.Scp.WebApi.Console.csproj b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Win_in.Sfs.Scp.WebApi.Console.csproj new file mode 100644 index 0000000..58740eb --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Win_in.Sfs.Scp.WebApi.Console.csproj @@ -0,0 +1,13 @@ + + + + Exe + net5.0 + + + + + + + + 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 0675464..a318081 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 @@ -19,7 +19,7 @@ public class ASN_X12_856_3060 /// Functional Group /// 功能组列表 /// - public List FunctionalGroups { get; set; } + public List FunctionalGroups { get; set; } = new List(); /// /// Interchange Control Trailer @@ -54,6 +54,6 @@ public class ASN_X12_856_3060 sb.AppendLine(functionalGroup.ToString()); } sb.AppendLine(IEA.ToString()); - return sb.ToString(); + return sb.ToString().Trim(); } } \ 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 index 1663bff..c64c323 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 @@ -4,14 +4,23 @@ 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, + 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 = " ") { asn.ISA = new ISA(asnCode,senderId,receiverId,datetime,envType,authorization,security); + return asn; } - public static void SetIEA(this ASN_X12_856_3060 asn,string asnCode) + public static ASN_X12_856_3060 SetIEA(this ASN_X12_856_3060 asn,string asnCode) { asn.IEA = new IEA(asnCode, asn.FunctionalGroups.Count); + return asn; } + + public static ASN_X12_856_3060 AddFunctionGroup(this ASN_X12_856_3060 asn, FunctionalGroup functionalGroup) + { + asn.FunctionalGroups.Add(functionalGroup); + return asn; + } + } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/DTM.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/DTM.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/DTM.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/DTM.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/HL.cs similarity index 93% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/HL.cs index 4719a40..8b26466 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/HL.cs @@ -8,7 +8,7 @@ namespace Win_in.Sfs.Scp.WebApi.Asns; /// Hierarchical Level /// 层级结构 /// -public abstract class HL +public class HL { /// /// Hierarchical Id Number @@ -35,7 +35,7 @@ public abstract class HL public string HL03 { get;} public string HL04 { get;} - public HL(LevelType hl03,string code,string parentCode="") + public HL(LevelType hl03,string code="",string parentCode="") { HL01 = code; HL02 = parentCode; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/REF.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/REF.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/REF.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Commons/REF.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroup.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/FunctionalGroup.cs similarity index 76% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroup.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/FunctionalGroup.cs index 5fbd175..4a2e222 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroup.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/FunctionalGroup.cs @@ -19,7 +19,7 @@ public class FunctionalGroup /// Transaction Set /// 事务集合列表 /// - public List TransactionSets { get; set; } + public List ShipNotices { get; set; } = new List(); /// /// Function Group Trailer @@ -31,11 +31,11 @@ public class FunctionalGroup { var sb = new StringBuilder(); sb.AppendLine(GS.ToString()); - foreach (var transactionSet in TransactionSets) + foreach (var shipNotice in ShipNotices) { - sb.AppendLine(transactionSet.ToString()); + sb.AppendLine(shipNotice.ToString()); } sb.AppendLine(GE.ToString()); - return sb.ToString(); + return sb.ToString().Trim(); } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/FunctionalGroupExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/FunctionalGroupExtensions.cs new file mode 100644 index 0000000..19cb0d9 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/FunctionalGroupExtensions.cs @@ -0,0 +1,25 @@ +using System; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class FunctionalGroupExtensions +{ + public static FunctionalGroup SetGS(this FunctionalGroup functionalGroup,string senderId, string receiverId, DateTime datetime, string functionalGroupCode) + { + functionalGroup.GS = new GS(senderId, receiverId, datetime, functionalGroupCode); + return functionalGroup; + } + + public static FunctionalGroup SetGE(this FunctionalGroup functionalGroup,string functionalGroupCode) + { + functionalGroup.GE = new GE(functionalGroupCode, functionalGroup.ShipNotices.Count); + return functionalGroup; + } + + public static FunctionalGroup AddShipNotice(this FunctionalGroup functionalGroup, ShipNotice shipNotice) + { + functionalGroup.ShipNotices.Add(shipNotice); + return functionalGroup; + } + +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/GE.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/GE.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/GE.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/GE.cs 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/FunctionGroups/GS.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/GS.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionGroups/GS.cs 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 deleted file mode 100644 index fa1ca0c..0000000 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroupExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -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_IExtentions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_IExtentions.cs deleted file mode 100644 index 84b3572..0000000 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_IExtentions.cs +++ /dev/null @@ -1,36 +0,0 @@ -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_SExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_SExtensions.cs deleted file mode 100644 index a1c83e1..0000000 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_SExtensions.cs +++ /dev/null @@ -1,68 +0,0 @@ -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_TExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_TExtensions.cs deleted file mode 100644 index 17357c9..0000000 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_TExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -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/IEA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IEA.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/IEA.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IEA.cs 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/ISA.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/ISA.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CLD.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/CLD.cs similarity index 95% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CLD.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/CLD.cs index f15b1a5..e43c0c3 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CLD.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/CLD.cs @@ -34,7 +34,7 @@ public class CLD public string CLD05 { get;} - public CLD(int loadQty,int unitQty) + public CLD(int loadQty,decimal unitQty) { CLD01 = loadQty.ToString(); CLD02 = unitQty.ToString(); 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/Items/Item.cs similarity index 78% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_I.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/Item.cs index 62469c2..3bd2905 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_I.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/Item.cs @@ -3,8 +3,15 @@ using System.Text; namespace Win_in.Sfs.Scp.WebApi.Asns; -public class HL_I:HL +public class Item { + /// + /// Hierarchical Level + /// 层级结构 + /// + public HL HL { get; set; } + + /// /// LINE ITEM DETAIL /// 零件号 @@ -35,19 +42,10 @@ public class HL_I:HL /// public List REF_LSs { get; set; } - /// - /// - /// - /// 层级代码 - /// 父级代码 - 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(HL.ToString()); sb.AppendLine(LIN.ToString()); sb.AppendLine(SN1.ToString()); sb.AppendLine(PRF.ToString()); @@ -56,6 +54,6 @@ public class HL_I:HL { sb.AppendLine(refLS.ToString()); } - return sb.ToString(); + return sb.ToString().Trim(); } } \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/ItemExtentions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/ItemExtentions.cs new file mode 100644 index 0000000..60f7f99 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/ItemExtentions.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class ItemExtentions +{ + public static Item SetHL(this Item item) + { + item.HL = new HL(HL.LevelType.I); + return item; + } + + public static Item SetLIN(this Item item, string itemCode) + { + item.LIN = new LIN(itemCode); + return item; + } + + public static Item SetSN1(this Item item, decimal qty, string uom, int accumQty) + { + item.SN1 = new SN1(qty, uom, accumQty); + return item; + } + + public static Item SetPRF(this Item item, string poNumber) + { + item.PRF = new PRF(poNumber); + return item; + } + + public static Item SetCLD(this Item item, int loadQty, decimal unitQty) + { + item.CLD = new CLD(loadQty, unitQty); + return item; + } + + public static Item SetREF_LSs(this Item item, List itemLabelCodes) + { + item.REF_LSs = new List(); + foreach (var refLs in itemLabelCodes.Select(labelCode => new REF(REF.RefType.LS, labelCode))) + { + item.REF_LSs.Add(refLs); + } + return item; + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/LIN.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/LIN.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/LIN.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/LIN.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/PRF.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/PRF.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/PRF.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/PRF.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs similarity index 89% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs index 6b03646..49be11c 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs @@ -16,7 +16,7 @@ public class SN1 /// 发货数量 /// [StringLength(10, MinimumLength = 1)] - public string SN102 { get; set; } + public string SN102 => Qty.ToString(); /// @@ -43,9 +43,11 @@ public class SN1 public string SN107 { get;} public string SN108 { get;} - public SN1(int qty,string uom,int accumQty) + public decimal Qty { get; set; } + + public SN1(decimal qty,string uom,int accumQty) { - SN102 = qty.ToString(); + Qty = qty; SN103 = uom; SN104 = accumQty.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 deleted file mode 100644 index c67510e..0000000 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotice.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Text; - -namespace Win_in.Sfs.Scp.WebApi.Asns; - -/// -/// Ship Notice -/// 发货单 -/// -public class ShipNotice -{ - /// - /// Beginning Segment - /// 事务头 - /// - public BSN BSN { get; set; } - - /// - /// Shipped Date And Time - /// 发货日期时间 - /// - public DTM DTM { get; set; } - - /// - /// Hierarchical Level of Shipment - /// 发货单层级 - /// - public HL_S HL_S { get; set; } - - /// - /// Transaction Totals - /// 事务汇总 - /// - 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 deleted file mode 100644 index 1b932cc..0000000 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNoticeExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -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/BSN.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/BSN.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/BSN.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/BSN.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/CTT.cs similarity index 74% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/CTT.cs index 5b5b271..333c017 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/CTT.cs @@ -13,14 +13,14 @@ public class CTT /// 层级总数 /// [StringLength(6, MinimumLength = 1)] - public string CTT01 => hlCount.ToString(); + public string CTT01 => _hlCount.ToString(); /// /// Hash Totals /// 零件总数 /// [StringLength(10, MinimumLength = 1)] - public string CTT02 => hashTotal.ToString(); + public string CTT02 => _hashTotal.ToString(); public string CTT03 { get;} public string CTT04 { get;} @@ -28,15 +28,13 @@ public class CTT public string CTT06 { get;} public string CTT07 { get;} - private int hlCount = 0; - private int hashTotal = 0; - + private int _hlCount = 0; + private decimal _hashTotal = 0; - public int AddHL(int itemCount=0) + public CTT(int hlCount,decimal hashTotal) { - hlCount++; - hashTotal += itemCount; - return hlCount; + _hlCount = hlCount; + _hashTotal = hashTotal; } public override string ToString() diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FOB.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/FOB.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FOB.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/FOB.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SE.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/SE.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SE.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/SE.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ST.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ST.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ST.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ST.cs 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 new file mode 100644 index 0000000..35b168f --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs @@ -0,0 +1,88 @@ +using System.Text; +using Microsoft.AspNetCore.SignalR; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +/// +/// Ship Notice +/// 发货单 +/// +public class ShipNotice +{ + /// + /// Transaction Set Header + /// 事务集合头 + /// + public ST ST { get; set; } + + + /// + /// Beginning Segment + /// 事务头 + /// + public BSN BSN { get; set; } + + /// + /// Shipped Date And Time + /// 发货日期时间 + /// + public DTM DTM { get; set; } + + /// + /// Hierarchical Level of Shipment + /// 发货单层级 + /// + public Shipment Shipment { get; set; } + + /// + /// Transaction Totals + /// 事务汇总 + /// + public CTT CTT { get; set; } + + /// + /// Transaction Set Trailer + /// 事务集合尾 + /// + public SE SE { get; set; } + + + /// + /// Count of Included Segments + /// + public int SegmentCount { get;private set; } + + /// + /// Count of Included Line Items + /// + public int HlCount { get; private set; } = 1; + + /// + /// Hash Totals + /// + public decimal HashTotal { get; private set; } + + public override string ToString() + { + var sb = new StringBuilder(); + sb.AppendLine(ST.ToString()); + sb.AppendLine(BSN.ToString()); + sb.AppendLine(DTM.ToString()); + sb.AppendLine(Shipment.ToString()); + sb.AppendLine(CTT.ToString()); + sb.AppendLine(SE.ToString()); + return sb.ToString().Trim(); + } + + public string GetNextHl(decimal itemCount=0) + { + HlCount++; + HashTotal += itemCount; + return HlCount.ToString(); + } + + public void AddSegment() + { + SegmentCount++; + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNoticeExtensions.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNoticeExtensions.cs new file mode 100644 index 0000000..5cc2dea --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNoticeExtensions.cs @@ -0,0 +1,39 @@ +using System; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class ShipNoticeExtensions +{ + public static ShipNotice SetST(this ShipNotice shipNotice,string shipNoticeCode) + { + shipNotice.ST = new ST(shipNoticeCode); + return shipNotice; + } + + public static ShipNotice SetBSN(this ShipNotice shipNotice,string noticeNumber, DateTime datetime, string purpose = "00") + { + shipNotice.BSN = new BSN(noticeNumber, datetime, purpose); + return shipNotice; } + + public static ShipNotice SetDTM(this ShipNotice shipNotice, DateTime dateTime,string datetimeType="011") + { + shipNotice.DTM = new DTM(dateTime, datetimeType); + return shipNotice;} + + public static ShipNotice AddShipment(this ShipNotice shipNotice,Shipment shipment) + { + shipNotice.Shipment = shipment; + return shipNotice;} + + public static ShipNotice SetCTT(this ShipNotice shipNotice) + { + shipNotice.CTT = new CTT(shipNotice.HlCount,shipNotice.HashTotal); + return shipNotice; + } + + public static ShipNotice SetSE(this ShipNotice shipNotice, string shipNoticeCode) + { + shipNotice.SE = new SE(shipNoticeCode,shipNotice.SegmentCount); + return shipNotice; } + +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/MEA.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/MEA.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/MEA.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/MEA.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/N1.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/N1.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/N1.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/N1.cs 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/Shipments/Shipment.cs similarity index 76% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_S.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/Shipment.cs index ca2c408..6ba1509 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_S.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/Shipment.cs @@ -3,8 +3,17 @@ using System.Text; namespace Win_in.Sfs.Scp.WebApi.Asns; -public class HL_S:HL +/// +/// 发货明细 +/// +public class Shipment { + /// + /// Hierarchical Level + /// 层级结构 + /// + public HL HL { get; set; } + /// /// Gross weight /// 毛重 @@ -63,26 +72,26 @@ public class HL_S:HL /// HIERARCHICAL LEVEL (TARE) /// 托盘列表 /// - public List HL_Ts { get; set; } = new List(); + public List Tares { get; set; } = new List(); /// /// HIERARCHICAL LEVEL (ITEM) /// 单箱列表 /// - public List HL_Is { get; set; } = new List(); + public List OrphanItems { get; set; } = new List(); /// /// /// - /// 层级代码 - public HL_S(string code) : base(LevelType.S,code) + public Shipment() { + HL = new HL(HL.LevelType.S); } public override string ToString() { var sb = new StringBuilder(); - sb.AppendLine(base.ToString()); + sb.AppendLine(HL.ToString()); sb.AppendLine(MEA_G.ToString()); sb.AppendLine(MEA_N.ToString()); sb.AppendLine(TD1.ToString()); @@ -92,14 +101,14 @@ public class HL_S:HL sb.AppendLine(REF_PK.ToString()); sb.AppendLine(N1_SF.ToString()); sb.AppendLine(N1_ST.ToString()); - foreach (var hlt in HL_Ts) + foreach (var tare in Tares) { - sb.AppendLine(hlt.ToString()); + sb.AppendLine(tare.ToString()); } - foreach (var hli in HL_Is) + foreach (var item in OrphanItems) { - sb.AppendLine(hli.ToString()); + sb.AppendLine(item.ToString()); } - return sb.ToString(); + return sb.ToString().Trim(); } } \ 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 new file mode 100644 index 0000000..86f662e --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/ShipmentExtensions.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.SignalR; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class ShipmentExtensions +{ + public static Shipment SetHL(this Shipment shipment) + { + shipment.HL = new HL(HL.LevelType.S,"1",""); + return shipment; + } + + public static Shipment SetMEA_G(this Shipment shipment,decimal meaValue,string uom) + { + shipment.MEA_G = new MEA(MEA.MeaType.G, meaValue, uom); + return shipment; + } + + public static Shipment SetMEA_N(this Shipment shipment,decimal meaValue,string uom) + { + shipment.MEA_N = new MEA(MEA.MeaType.N, meaValue, uom); + return shipment; + } + + public static Shipment SetTD1(this Shipment shipment,string packagingCode,int loadingQty) + { + shipment.TD1 = new TD1(packagingCode, loadingQty); + return shipment; + } + + public static Shipment SetTD5(this Shipment shipment,string routeSequenceCode,string identificationCode,string mode) + { + shipment.TD5 = new TD5(routeSequenceCode, identificationCode, mode); + return shipment; + } + + public static Shipment SetTD3(this Shipment shipment,string equipmentCode,string equipmentNumber) + { + shipment.TD3 = new TD3(equipmentCode,equipmentNumber); + return shipment; + } + + public static Shipment SetREF_BM(this Shipment shipment,string refValue) + { + shipment.REF_BM = new REF(REF.RefType.BM, refValue); + return shipment; + } + + public static Shipment SetREF_PK(this Shipment shipment,string refValue) + { + shipment.REF_PK = new REF(REF.RefType.PK, refValue); + return shipment; + } + + public static Shipment SetN1_SF(this Shipment shipment, string senderId) + { + shipment.N1_SF = new N1(N1.NameType.SF, senderId); + return shipment; + } + + public static Shipment SetN1_ST(this Shipment shipment, string receiverId) + { + shipment.N1_ST = new N1(N1.NameType.ST, receiverId); + return shipment; + } + + public static Shipment AddTare(this Shipment shipment,ShipNotice shipNotice, Tare tare) + { + tare.HL.HL01 = shipNotice.GetNextHl(); + tare.HL.HL02 = shipment.HL.HL01; + shipment.Tares.Add(tare); + return shipment; + } + + public static Shipment AddOrphanItem(this Shipment shipment,ShipNotice shipNotice,Item orphanItem) + { + orphanItem.HL.HL01 = shipNotice.GetNextHl(orphanItem.SN1.Qty); + orphanItem.HL.HL02 = shipment.HL.HL01; + shipment.OrphanItems.Add(orphanItem); + return shipment; + } + +} \ 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/Shipments/TD1.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD1.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/TD1.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD3.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/TD3.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD3.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/TD3.cs diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD5.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/TD5.cs similarity index 100% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD5.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/TD5.cs 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/Tares/Tare.cs similarity index 54% rename from WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_T.cs rename to WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/Tare.cs index 46d4b6d..783d37b 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_T.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/Tare.cs @@ -3,9 +3,16 @@ using System.Text; namespace Win_in.Sfs.Scp.WebApi.Asns; -public class HL_T:HL +public class Tare { + /// + /// Hierarchical Level + /// 层级结构 + /// + public HL HL { get; set; } + + /// /// label serial number /// 器具标签号 @@ -16,26 +23,17 @@ public class HL_T:HL /// HIERARCHICAL LEVEL (ITEM) /// 单箱列表 /// - public List HL_Is { get; set; } - - /// - /// - /// - /// 层级代码 - /// 父级代码 - public HL_T(string code,string parentCode) : base(LevelType.T,code,parentCode) - { - } + public List Items { get; set; } = new List(); public override string ToString() { var sb = new StringBuilder(); - sb.AppendLine(base.ToString()); + sb.AppendLine(HL.ToString()); sb.AppendLine(REF_LS.ToString()); - foreach (var hli in HL_Is) + foreach (var item in Items) { - sb.AppendLine(hli.ToString()); + sb.AppendLine(item.ToString()); } - return sb.ToString(); + return sb.ToString().Trim(); } } \ No newline at end of file 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 new file mode 100644 index 0000000..43bc49f --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/TareExtensions.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace Win_in.Sfs.Scp.WebApi.Asns; + +public static class TareExtensions +{ + public static Tare SetHL(this Tare tare) + { + tare.HL = new HL(HL.LevelType.T); + return tare; + } + + + public static Tare SetREF_LS(this Tare tare, string tareLabelCode) + { + tare.REF_LS = new REF(REF.RefType.LS, tareLabelCode); + return tare; + } + + public static Tare AddItem(this Tare tare, ShipNotice shipNotice, Item item) + { + item.HL.HL01 = shipNotice.GetNextHl(item.SN1.Qty); + item.HL.HL02 = tare.HL.HL01; + tare.Items.Add(item); + return tare; + } + +} \ No newline at end of file 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 deleted file mode 100644 index 9d3d70e..0000000 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSet.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections.Generic; -using System.Text; - -namespace Win_in.Sfs.Scp.WebApi.Asns; - -/// -/// Transaction Set -/// 事务集合 -/// -public class TransactionSet -{ - /// - /// Transaction Set Header - /// 事务集合头 - /// - public ST ST { get; set; } - - /// - /// Ship Notice - /// 发货单列表 - /// - public List ShipNotices { get; set; } - - /// - /// Transaction Set Trailer - /// 事务集合尾 - /// - 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 deleted file mode 100644 index e8006d2..0000000 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSetExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -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 diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_ASN.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_ASN.cs new file mode 100644 index 0000000..235c840 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_ASN.cs @@ -0,0 +1,50 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System; + +namespace Win_in.Sfs.Scp.v1.Domain.Asns +{ + + public class TB_ASN + { + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long UID { get; set; } + [StringLength(50)] + [Key] + public string AsnBillNum { get; set; }//发货单号 + [StringLength(50)] + public string AskBillNum { get; set; }//要货看板号 + [StringLength(50)] + public string PoBillNum { get; set; }//订单编号 + [StringLength(50)] + public string VendId { get; set; }//供应商编号 + [StringLength(50)] + public string Site { get; set; }//地点 + public int State { get; set; }//状态(3为已发货状态) + [StringLength(50)] + public string Remark { get; set; } + + public DateTime? ShipTime { get; set; }//发货时间 + [StringLength(50)] + public string ShipUser { get; set; }//发货人 + public DateTime? ReceiveTime { get; set; }//承诺到货日期 + [StringLength(50)] + public string ReceiveUser { get; set; } + + public decimal? Price { get; set; } + [StringLength(50)] + public string Currency { get; set; } + [StringLength(50)] + public string PlateNumber { get; set; } + [StringLength(50)] + public string ReceivedPort { get; set; }//时间窗口,有为空的信息 + public string Extend1 { get; set; } + public string Extend2 { get; set; } + public string Extend3 { get; set; } + + public string SubSite { get; set; } + + + + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_ASN_DETAIL.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_ASN_DETAIL.cs new file mode 100644 index 0000000..e6e6104 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_ASN_DETAIL.cs @@ -0,0 +1,50 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Win_in.Sfs.Scp.v1.Domain.Asns +{ + public partial class TB_ASN_DETAIL + { + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Key] + public long UID { get; set; } + [StringLength(50)] + public string AsnBillNum { get; set; }//发货单号 + public decimal Price { get; set; } + [StringLength(50)] + public string PoBillNum { get; set; }//订单号 + public int PoLine { get; set; }//订单行号,无订单号自动取0 + [StringLength(50)] + public string PartCode { get; set; }//零件号 + [StringLength(50)] + public string Batch { get; set; }//批次 + public DateTime? ProduceDate { get; set; }//生产日期 + [StringLength(50)] + public string VendBatch { get; set; }//供应商批次 + public decimal Qty { get; set; }//发货数 + [StringLength(50)] + public string PoUnit { get; set; }//零件单位 + [StringLength(50)] + public string LocUnit { get; set; }//零件单位 + public decimal PackQty { get; set; }//标包数 + public decimal UnConv { get; set; } + [StringLength(50)] + public string DockCode { get; set; } + public int? State { get; set; } //状态(3为已发货状态) + [StringLength(50)] + public string Remark { get; set; } + + [StringLength(50)] + public string Currency { get; set; } + + public DateTime? EndTime { get; set; } + [StringLength(50)] + public string ReceivedPort { get; set; } + public string Extend1 { get; set; } + public string Extend2 { get; set; } + public string Extend3 { get; set; } + public string SubSite { get; set; } + public string Site { get; set; } + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_PALLETS.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_PALLETS.cs new file mode 100644 index 0000000..d2d055b --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TB_PALLETS.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Win_in.Sfs.Scp.v1.Domain.Asns +{ + public partial class TB_PALLETS + { + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Key] + public long UID { get; set; } + [StringLength(50)] + public string AsnBillNum { get; set; }//发货单号 + public string PalletNum { get; set; }//发货时间(只有年月日的字符串串) + public string BarCode { get; set; }//P+零件号+;+Q+数量 + public string FullBarCode { get; set; }//箱码 + public string PartCode { get; set; }//零件号(多零件号用;分割) + public string Batch { get; set; }//每种零件多少箱用;分割 + public string VendId { get; set; }//供应商编号 + public int Box { get; set; }//总箱数 + public decimal Qty { get; set; } + //--新添加 + public string VendBatch { get; set; }//供应商中文名 + + public string PoBillNum { get; set; }//托盘序号 + public int PoBillLine { get; set; } + [Column(TypeName = "datetime2")] + public DateTime ProduceDate { get; set; }//发货时间 + } +} \ No newline at end of file diff --git a/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TS_BARCODE.cs b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TS_BARCODE.cs new file mode 100644 index 0000000..029a202 --- /dev/null +++ b/WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Asns/TS_BARCODE.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Win_in.Sfs.Scp.v1.Domain.Asns +{ + public partial class TS_BARCODE + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long UID { get; set; } + + + [StringLength(50)] + public string BarCode { get; set; }//箱码(条码的部分信息) + + [Required] + [StringLength(500)] + public string FullBarCode { get; set; }//箱码(条码的全部信息) + + [Required] + [StringLength(50)] + public string PartCode { get; set; }//零件号 + + [StringLength(50)] + public string VendPartCode { get; set; }//供应商零件号(存在NULL) + + [Required] + [StringLength(50)] + public string Batch { get; set; }//批次 + + [Column(TypeName = "datetime2")] + public DateTime ProduceDate { get; set; }//生产日期 + + public int ManageType { get; set; } + + [Required] + [StringLength(50)] + public string SerialNum { get; set; }//六位流水号,以单个asn单号计数 + + [Column(TypeName = "money")] + public decimal Qty { get; set; }//条码零件数量 + + public int BarCodeType { get; set; } + + [Required] + [StringLength(50)] + public string BillNum { get; set; }//发货单号 + + public int PoBillLine { get; set; }//订单行号(无订单号取0) + + [StringLength(50)] + public string VendId { get; set; }//供应商编号 + + [StringLength(50)] + public string VendBatch { get; set; }//供应商批次 + + [Column(TypeName = "money")] + public decimal PackQty { get; set; }//标包数 + + [Required] + [StringLength(50)] + public string CreateOper { get; set; }//条码创建者中文名 + + public DateTime CreateTime { get; set; }//(创建时间) + + public int State { get; set; } + + [StringLength(500)] + public string Remark { get; set; } + + public string PoUnit { get; set; }//零件单位 + public string LocUnit { get; set; } + + + public string Site { get; set; }//地点 + public string Qlevel { get; set; } + public string QMark { get; set; } + public string ProjectId { get; set; }//项目号 + + public string PoBillNum { get; set; }//订单号 + + public string Extend1 { get; set; }//零件名称 + public string Extend2 { get; set; }//包装序号 + public string Extend3 { get; set; } + [DisplayName("是否扫描")] + public bool IsScanned { get; set; } + + } +} \ No newline at end of file