Browse Source

[fix]X12 Bug修复

master
贾荣国Home 3 years ago
parent
commit
75b55e0c1d
  1. 58
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/AsnFactory.cs
  2. 44
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs
  3. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ASN_X12_856_3060Extensions.cs
  4. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/IEA.cs
  5. 12
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs
  6. 15
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs
  7. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs
  8. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/ShipmentExtensions.cs
  9. 1
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/TareExtensions.cs

58
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 asnCode = scpAsn.AsnBillNum;
var senderId = scpAsn.VendId; var senderId = scpAsn.VendId;
var receiverId = "receiver"; var receiverId = "IACNA_ID";
var shipTime = scpAsn.ShipTime ?? DateTime.Now; var shipTime = scpAsn.ShipTime ?? DateTime.Now;
var envType = ISA.EnvType.P; var envType = ISA.EnvType.P;
var authorization = " "; var authorization = "";
var security = " "; var security = "";
//初始化ASN单 //初始化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 shipNoticeCode = "0001";
var datetimeType = "011"; var datetimeType = "011";
//初始化发货单 //初始化发货单
var shipNotice = InitShipNotice(shipNoticeCode,functionalGroupCode,shipTime,datetimeType); var shipNotice = CreateShipNotice(shipNoticeCode,functionalGroupCode,shipTime,datetimeType);
var gValue = 0; var gValue = 0;
var gUom = "KG"; var gUom = "KG";
@ -39,9 +39,9 @@ namespace Win_in.Sfs.Scp.WebApi.Console
var identificationCode = "PSTV"; var identificationCode = "PSTV";
var mode = "LT"; var mode = "LT";
var equipmentCode = "TL"; 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); 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; var loadingQty = shipment.Tares.Count+shipment.OrphanItems.Count;
shipment.SetTD1(packagingCode, loadingQty); shipment.SetTD1(packagingCode, loadingQty);
//添加发货明细
shipNotice.AddShipment(shipment); shipNotice
//设置发货单汇总 .AddShipment(shipment) //添加发货明细
shipNotice.SetCTT(); .SetCTT() //设置发货单汇总
.SetSE(shipNoticeCode); //设置发货明细结尾
//添加发货单 //添加发货单
functionalGroup.AddShipNotice(shipNotice); functionalGroup
functionalGroup.SetGE(functionalGroupCode); .AddShipNotice(shipNotice)
.SetGE(functionalGroupCode);
//添加功能组 //添加功能组
asn.AddFunctionGroup(functionalGroup); asn
.AddFunctionGroup(functionalGroup)
.SetIEA(asnCode);
return asn; return asn;
} }
private ASN_X12_856_3060 InitAsn(string asnCode, string senderId, string receiverId, DateTime datetime, private ASN_X12_856_3060 CreateAsn(string asnCode, string senderId, string receiverId, DateTime datetime,
ISA.EnvType envType = ISA.EnvType.P, string authorization = " ", string security = " ") ISA.EnvType envType = ISA.EnvType.P, string authorization = "", string security = "")
{ {
var asn = new ASN_X12_856_3060(); var asn = new ASN_X12_856_3060();
asn.SetISA(asnCode, senderId, receiverId, datetime, envType, authorization, security) asn.SetISA(asnCode, senderId, receiverId, datetime, envType, authorization, security);
.SetIEA(asnCode);
return asn; return asn;
} }
private FunctionalGroup InitFunctionalGroup(string senderId, string receiverId, DateTime datetime, private FunctionalGroup CreateFunctionalGroup(string senderId, string receiverId, DateTime datetime,
string functionalGroupCode) string functionalGroupCode)
{ {
var functionGroup = new FunctionalGroup(); var functionGroup = new FunctionalGroup();
functionGroup functionGroup.SetGS(senderId, receiverId, datetime, functionalGroupCode);
.SetGS(senderId, receiverId, datetime, functionalGroupCode);
return functionGroup; 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") string datetimeType="011", string purpose = "00")
{ {
var shipNotice = new ShipNotice(); var shipNotice = new ShipNotice();
shipNotice shipNotice
.SetST(shipNoticeCode) .SetST(shipNoticeCode)
.SetBSN(noticeNumber, datetime, purpose) .SetBSN(noticeNumber, datetime, purpose)
.SetDTM(datetime, datetimeType) .SetDTM(datetime, datetimeType);
.SetSE(shipNoticeCode); shipNotice.AddSegment(4);
return shipNotice; 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 routeSequenceCode, string identificationCode, string mode, string equipmentCode,
string equipmentNumber, string bmRefValue, string pkRefValue, string senderId, string receiverId) 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_SF(senderId)
.SetN1_ST(receiverId) .SetN1_ST(receiverId)
; ;
shipNotice.AddSegment(10);
return shipment; return shipment;
} }

44
WebApiService/src/Win_in.Sfs.Scp.WebApi.Console/Program.cs

@ -24,74 +24,74 @@ namespace Win_in.Sfs.Scp.WebApi.Console
{ {
new TS_BARCODE() new TS_BARCODE()
{ {
BarCode = "A01", BarCode = "BARCODE_01",
PartCode = "AAAAA", PartCode = "PART_A",
Qty=20, Qty=20,
Batch="20220404", Batch="20220404",
PoUnit = "EA", PoUnit = "EA",
PoBillNum = "PO1111", PoBillNum = "PO1111",
PackQty = 20, PackQty = 20,
Extend2 = "PALLET01" Extend2 = "PALLET_01"
}, },
new TS_BARCODE() new TS_BARCODE()
{ {
BarCode = "A02", BarCode = "BARCODE_02",
PartCode = "AAAAA", PartCode = "PART_A",
Qty=20, Qty=20,
Batch="20220404", Batch="20220404",
PoUnit = "EA", PoUnit = "EA",
PoBillNum = "PO1111", PoBillNum = "PO1111",
PackQty = 20, PackQty = 20,
Extend2 = "PALLET01" Extend2 = "PALLET_01"
}, },
new TS_BARCODE() new TS_BARCODE()
{ {
BarCode = "B01", BarCode = "BARCODE_03",
PartCode = "BBBBB", PartCode = "PART_B",
Qty=15, Qty=15,
Batch="20220404", Batch="20220404",
PoUnit = "EA", PoUnit = "EA",
PoBillNum = "PO2222", PoBillNum = "PO2222",
PackQty = 15, PackQty = 15,
Extend2 = "PALLET01" Extend2 = "PALLET_01"
}, },
new TS_BARCODE() new TS_BARCODE()
{ {
BarCode = "B02", BarCode = "BARCODE_04",
PartCode = "BBBBB", PartCode = "PART_B",
Qty=15, Qty=15,
Batch="20220404", Batch="20220404",
PoUnit = "EA", PoUnit = "EA",
PoBillNum = "PO2222", PoBillNum = "PO2222",
PackQty = 15, PackQty = 15,
Extend2 = "PALLET01" Extend2 = "PALLET_01"
}, },
new TS_BARCODE() new TS_BARCODE()
{ {
BarCode = "C01", BarCode = "BARCODE_05",
PartCode = "CCCCC", PartCode = "PART_C",
Qty=40, Qty=40,
Batch="20220404", Batch="20220404",
PoUnit = "KG", PoUnit = "KG",
PoBillNum = "PO3333", PoBillNum = "PO3333",
PackQty = 40, PackQty = 40,
Extend2 = "PALLET02" Extend2 = "PALLET_02"
}, },
new TS_BARCODE() new TS_BARCODE()
{ {
BarCode = "C02", BarCode = "BARCODE_06",
PartCode = "CCCCC", PartCode = "PART_C",
Qty=40, Qty=40,
Batch="20220404", Batch="20220404",
PoUnit = "KG", PoUnit = "KG",
PoBillNum = "PO3333", PoBillNum = "PO3333",
PackQty = 40, PackQty = 40,
Extend2 = "PALLET02" Extend2 = "PALLET_02"
}, },
new TS_BARCODE() new TS_BARCODE()
{ {
BarCode = "C03", BarCode = "BARCODE_07",
PartCode = "CCCCC", PartCode = "PART_C",
Qty=40, Qty=40,
Batch="20220404", Batch="20220404",
PoUnit = "KG", PoUnit = "KG",
@ -107,8 +107,8 @@ namespace Win_in.Sfs.Scp.WebApi.Console
{ {
var scpAsn = new TB_ASN() var scpAsn = new TB_ASN()
{ {
AsnBillNum = "ASNBILLNUM", AsnBillNum = "ASN123456",
VendId = "VENDID", VendId = "VENDOR_ID",
ShipTime = DateTime.Now, ShipTime = DateTime.Now,
}; };

2
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 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, 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); asn.ISA = new ISA(asnCode,senderId,receiverId,datetime,envType,authorization,security);
return asn; return asn;

2
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) public IEA(string asnCode, int count = 1)
{ {
IEA01 = count.ToString(); IEA01 = count.ToString();
IEA02 = asnCode; IEA02 = asnCode.PadRight(9);
} }
public override string ToString() public override string ToString()

12
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs

@ -142,16 +142,16 @@ public class ISA
public string ISA16 { get; set; } = "|"; public string ISA16 { get; set; } = "|";
public ISA(string asnCode,string senderId, string receiverId, DateTime datetime, EnvType envType = EnvType.P, public ISA(string asnCode,string senderId, string receiverId, DateTime datetime, EnvType envType = EnvType.P,
string authorization = " ", string security = " ") string authorization = "", string security = "")
{ {
ISA06 = senderId; ISA06 = senderId.PadRight(15);
ISA08 = receiverId; ISA08 = receiverId.PadRight(15);
ISA09 = datetime.ToString(X12Const.DateFormat); ISA09 = datetime.ToString(X12Const.DateFormat);
ISA09 = datetime.ToString(X12Const.TimeFormat); ISA09 = datetime.ToString(X12Const.TimeFormat);
ISA10 = asnCode; ISA10 = asnCode.PadRight(9);
ISA15 = envType.ToString(); ISA15 = envType.ToString();
ISA02 = authorization; ISA02 = authorization.PadRight(10);
ISA04 = security; ISA04 = security.PadRight(10);
} }
public override string ToString() public override string ToString()

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

@ -38,25 +38,26 @@ public class SN1
[StringLength(9, MinimumLength = 1)] [StringLength(9, MinimumLength = 1)]
public string SN104 { get; set; } public string SN104 { get; set; }
public string SN105 { get;} public string SN105 { get; }
public string SN106 { get;} public string SN106 { get; }
public string SN107 { get;} public string SN107 { get; }
public string SN108 { get;} public string SN108 { get; }
public decimal Qty { get; set; } public decimal Qty { get; set; }
public SN1(decimal qty,string uom,int accumQty) public SN1(decimal qty, string uom, int accumQty)
{ {
Qty = qty; Qty = qty;
SN103 = uom; SN103 = uom;
SN104 = accumQty.ToString(); SN104 = accumQty.ToString();
} }
public override string ToString() public override string ToString()
{ {
return "SN1" return "SN1"
+ X12Const.ElementSeparator + SN101 + X12Const.ElementSeparator + SN101
+ X12Const.ElementSeparator + SN102 + X12Const.ElementSeparator + SN102
+ X12Const.ElementSeparator + SN103; + X12Const.ElementSeparator + SN103
+ X12Const.ElementSeparator + SN104;
} }
} }

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs

@ -81,8 +81,8 @@ public class ShipNotice
return HlCount.ToString(); return HlCount.ToString();
} }
public void AddSegment() public void AddSegment(int count)
{ {
SegmentCount++; SegmentCount+=count;
} }
} }

2
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.HL01 = shipNotice.GetNextHl();
tare.HL.HL02 = shipment.HL.HL01; tare.HL.HL02 = shipment.HL.HL01;
shipment.Tares.Add(tare); shipment.Tares.Add(tare);
shipNotice.AddSegment(2);
return shipment; return shipment;
} }
@ -79,6 +80,7 @@ public static class ShipmentExtensions
orphanItem.HL.HL01 = shipNotice.GetNextHl(orphanItem.SN1.Qty); orphanItem.HL.HL01 = shipNotice.GetNextHl(orphanItem.SN1.Qty);
orphanItem.HL.HL02 = shipment.HL.HL01; orphanItem.HL.HL02 = shipment.HL.HL01;
shipment.OrphanItems.Add(orphanItem); shipment.OrphanItems.Add(orphanItem);
shipNotice.AddSegment(5+orphanItem.REF_LSs.Count);
return shipment; return shipment;
} }

1
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.HL01 = shipNotice.GetNextHl(item.SN1.Qty);
item.HL.HL02 = tare.HL.HL01; item.HL.HL02 = tare.HL.HL01;
tare.Items.Add(item); tare.Items.Add(item);
shipNotice.AddSegment(5+item.REF_LSs.Count);
return tare; return tare;
} }

Loading…
Cancel
Save