贾荣国Home
3 years ago
50 changed files with 942 additions and 329 deletions
@ -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<TS_BARCODE> 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<Item>(); |
|||
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<string> itemLabelCodes) |
|||
{ |
|||
|
|||
var item = new Item(); |
|||
item.SetHL() |
|||
.SetLIN(itemCode) |
|||
.SetSN1(qty, uom, accumQty) |
|||
.SetPRF(poNumber) |
|||
.SetCLD(loadQty, unitQty) |
|||
.SetREF_LSs(itemLabelCodes); |
|||
return item; |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
@ -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<TS_BARCODE> InitTsBarcodes() |
|||
{ |
|||
var barcodes = new List<TS_BARCODE>() |
|||
{ |
|||
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; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Win_in.Sfs.Scp.v1.Domain\Win_in.Sfs.Scp.v1.Domain.csproj" /> |
|||
<ProjectReference Include="..\Win_in.Sfs.Scp.WebApi.Domain\Win_in.Sfs.Scp.WebApi.Domain.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
@ -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; |
|||
} |
|||
|
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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<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); |
|||
} |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
|
|||
} |
@ -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); |
|||
} |
|||
|
|||
} |
@ -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<string> itemLabelCodes) |
|||
{ |
|||
item.REF_LSs = new List<REF>(); |
|||
foreach (var refLs in itemLabelCodes.Select(labelCode => new REF(REF.RefType.LS, labelCode))) |
|||
{ |
|||
item.REF_LSs.Add(refLs); |
|||
} |
|||
return item; |
|||
} |
|||
} |
@ -1,50 +0,0 @@ |
|||
using System.Text; |
|||
|
|||
namespace Win_in.Sfs.Scp.WebApi.Asns; |
|||
|
|||
/// <summary>
|
|||
/// Ship Notice
|
|||
/// 发货单
|
|||
/// </summary>
|
|||
public class ShipNotice |
|||
{ |
|||
/// <summary>
|
|||
/// Beginning Segment
|
|||
/// 事务头
|
|||
/// </summary>
|
|||
public BSN BSN { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Shipped Date And Time
|
|||
/// 发货日期时间
|
|||
/// </summary>
|
|||
public DTM DTM { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Hierarchical Level of Shipment
|
|||
/// 发货单层级
|
|||
/// </summary>
|
|||
public HL_S HL_S { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Transaction Totals
|
|||
/// 事务汇总
|
|||
/// </summary>
|
|||
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(); |
|||
} |
|||
} |
@ -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()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,88 @@ |
|||
using System.Text; |
|||
using Microsoft.AspNetCore.SignalR; |
|||
|
|||
namespace Win_in.Sfs.Scp.WebApi.Asns; |
|||
|
|||
/// <summary>
|
|||
/// Ship Notice
|
|||
/// 发货单
|
|||
/// </summary>
|
|||
public class ShipNotice |
|||
{ |
|||
/// <summary>
|
|||
/// Transaction Set Header
|
|||
/// 事务集合头
|
|||
/// </summary>
|
|||
public ST ST { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// Beginning Segment
|
|||
/// 事务头
|
|||
/// </summary>
|
|||
public BSN BSN { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Shipped Date And Time
|
|||
/// 发货日期时间
|
|||
/// </summary>
|
|||
public DTM DTM { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Hierarchical Level of Shipment
|
|||
/// 发货单层级
|
|||
/// </summary>
|
|||
public Shipment Shipment { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Transaction Totals
|
|||
/// 事务汇总
|
|||
/// </summary>
|
|||
public CTT CTT { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Transaction Set Trailer
|
|||
/// 事务集合尾
|
|||
/// </summary>
|
|||
public SE SE { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// Count of Included Segments
|
|||
/// </summary>
|
|||
public int SegmentCount { get;private set; } |
|||
|
|||
/// <summary>
|
|||
/// Count of Included Line Items
|
|||
/// </summary>
|
|||
public int HlCount { get; private set; } = 1; |
|||
|
|||
/// <summary>
|
|||
/// Hash Totals
|
|||
/// </summary>
|
|||
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++; |
|||
} |
|||
} |
@ -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; } |
|||
|
|||
} |
@ -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; |
|||
} |
|||
|
|||
} |
@ -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; |
|||
} |
|||
|
|||
} |
@ -1,42 +0,0 @@ |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Win_in.Sfs.Scp.WebApi.Asns; |
|||
|
|||
/// <summary>
|
|||
/// Transaction Set
|
|||
/// 事务集合
|
|||
/// </summary>
|
|||
public class TransactionSet |
|||
{ |
|||
/// <summary>
|
|||
/// Transaction Set Header
|
|||
/// 事务集合头
|
|||
/// </summary>
|
|||
public ST ST { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Ship Notice
|
|||
/// 发货单列表
|
|||
/// </summary>
|
|||
public List<ShipNotice> ShipNotices { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Transaction Set Trailer
|
|||
/// 事务集合尾
|
|||
/// </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(); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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; } |
|||
|
|||
|
|||
|
|||
} |
|||
} |
@ -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; } |
|||
} |
|||
} |
@ -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; }//发货时间
|
|||
} |
|||
} |
@ -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; } |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue