Browse Source

[fix]添加X12 领域逻辑

master
贾荣国Home 3 years ago
parent
commit
d76ccc469f
  1. 35
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060.cs
  2. 17
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060Extensions.cs
  3. 23
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs
  4. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/DTM.cs
  5. 13
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroup.cs
  6. 16
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/FunctionalGroupExtensions.cs
  7. 16
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_I.cs
  8. 36
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_IExtentions.cs
  9. 29
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_S.cs
  10. 68
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_SExtensions.cs
  11. 13
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_T.cs
  12. 19
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HL_TExtensions.cs
  13. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/GS.cs
  14. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/IEA.cs
  15. 10
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/HeadAndTrailers/ISA.cs
  16. 6
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/MEA.cs
  17. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/REF.cs
  18. 6
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs
  19. 24
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotice.cs
  20. 23
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNoticeExtensions.cs
  21. 6
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD1.cs
  22. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TD3.cs
  23. 19
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSet.cs
  24. 14
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/TransactionSetExtensions.cs

35
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
/// 功能组列表
/// </summary>
public List<FunctionalGroup> SegmentGroups { get; set; }
public List<FunctionalGroup> FunctionalGroups { get; set; }
/// <summary>
/// Interchange Control Trailer
/// 报文尾
/// </summary>
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();
}
}

17
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);
}
}

23
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/CTT.cs

@ -12,16 +12,15 @@ public class CTT
/// Number Of Line Items
/// 层级总数
/// </summary>
[StringLength(6,MinimumLength = 1)]
public string CTT01 { get; set; }
[StringLength(6, MinimumLength = 1)]
public string CTT01 => hlCount.ToString();
/// <summary>
/// Hash Totals
/// 零件总数
/// </summary>
[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"

4
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);
}

13
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
/// 功能组尾
/// </summary>
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();
}
}

16
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);
}
}

16
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();
}
}

36
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<string> itemLabelCodes)
{
hli.REF_LSs = new List<REF>();
foreach (var refLs in itemLabelCodes.Select(labelCode => new REF(REF.RefType.LS, labelCode)))
{
hli.REF_LSs.Add(refLs);
}
}
}

29
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)
/// 托盘列表
/// </summary>
public List<HL_T> HL_Ts { get; set; }
public List<HL_T> HL_Ts { get; set; } = new List<HL_T>();
/// <summary>
/// HIERARCHICAL LEVEL (ITEM)
/// 单箱列表
/// </summary>
public List<HL_I> HL_Is { get; set; }
public List<HL_I> HL_Is { get; set; } = new List<HL_I>();
/// <summary>
///
@ -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();
}
}

68
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);
}
}

13
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();
}
}

19
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);
}
}

4
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()

4
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()

10
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;
}

6
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;
}

4
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;
}

6
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/SN1.cs

@ -32,7 +32,7 @@ public class SN1
public string SN103 { get; set; }
/// <summary>
/// Quantity Shipped To Date
/// Accum quantity of preceding LIN's part number
/// 累计已发数量
/// </summary>
[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()

24
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;
/// <summary>
/// Ship Notice
@ -22,11 +24,27 @@ public class ShipNotice
/// Hierarchical Level of Shipment
/// 发货单层级
/// </summary>
public HL HL_S { get; set; }
public HL_S HL_S { get; set; }
/// <summary>
/// Transaction Totals
/// 事务汇总
/// </summary>
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();
}
}

23
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());
}
}

6
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();
}

5
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()

19
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;
/// <summary>
/// Transaction Set
@ -16,7 +19,7 @@ public class TransactionSet
/// Ship Notice
/// 发货单列表
/// </summary>
public ShipNotice ShipNotice { get; set; }
public List<ShipNotice> ShipNotices { get; set; }
/// <summary>
/// Transaction Set Trailer
@ -24,4 +27,16 @@ public class TransactionSet
/// </summary>
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();
}
}

14
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);
}
}
Loading…
Cancel
Save