Browse Source

[fix]X12 Bug修复

master
贾荣国Home 3 years ago
parent
commit
75b55e0c1d
  1. 52
      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/IEA.cs
  4. 10
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ISA.cs
  5. 3
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Items/SN1.cs
  6. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/ShipNotices/ShipNotice.cs
  7. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Shipments/ShipmentExtensions.cs
  8. 1
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/Tares/TareExtensions.cs

52
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 = "";
//初始化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,
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;
}

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

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

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

@ -144,14 +144,14 @@ public class ISA
public ISA(string asnCode,string senderId, string receiverId, DateTime datetime, EnvType envType = EnvType.P,
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()

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

@ -57,6 +57,7 @@ public class SN1
return "SN1"
+ X12Const.ElementSeparator + SN101
+ 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();
}
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.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;
}

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

Loading…
Cancel
Save