You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
BookingHeChuan/Myshipping.Application/EDI/CargoSmartEdiHelper.cs

3044 lines
122 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Web;
using System.Linq;
using System.Text.RegularExpressions;
using Newtonsoft.Json.Linq;
namespace Myshipping.Application.EDI.CargoSmart
{
public class CargoSmartEdiHelper
{
public CargoSmartEdiHelper()
{
}
#region 基本函数
public static string GetCarrierName(string str)
{
if (str == "ANNU") return "ANL";
if (str == "CMA") return "CMACGM";
if (str == "CHNL") return "CNC";
else return "";
}
public static string GetBillNum(string str)
{
if (str == "ZERO") return "0";
if (str == "ONE") return "1";
if (str == "TWO") return "2";
if (str == "THREE") return "3";
if (str == "FOUR") return "4";
if (str == "FIVE") return "5";
if (str == "SIX") return "6";
if (str == "SERVEN") return "7";
if (str == "EIGHT") return "8";
if (str == "NINE") return "9";
if (str == "TEN") return "10";
else return "";
}
public static string GetBillNum2(string str)
{
if (str == "ZERO") return "00";
if (str == "ONE") return "01";
if (str == "TWO") return "02";
if (str == "THREE") return "03";
if (str == "FOUR") return "04";
if (str == "FIVE") return "05";
if (str == "SIX") return "06";
if (str == "SERVEN") return "07";
if (str == "EIGHT") return "08";
if (str == "NINE") return "09";
if (str == "TEN") return "10";
else return "";
}
#region 判断中文字符
public static bool IsChinese(char c)
{
return (int)c > 0x80;
}
public static bool StringIsChinese(string str)
{
var result = false;
for (int i = 1; i < str.Length; i++)
{
if (IsChinese(str[i]))
{
result = true;
return result;
}
}
for (int i = 0; i < str.Length; i++)
{
string stemp = str.Substring(i, 1);
int ilen = System.Text.Encoding.Default.GetByteCount(stemp);
if (ilen == 2)
{
result = true;
return result;
}
}
return result;
}
#endregion
#region 文本字段判断每行是否符合
/// <summary>
/// edi 文本格式处理判断例如1行35个字符不超过5行
/// </summary>
/// <param name="fileType">文件类型例如txt、xml</param>
/// <param name="str">要处理的数据</param>
/// <param name="length">每行长度</param>
/// <param name="sMBLNO">主提单号</param>
/// <param name="sType">数据类型(例如:发货人内容、货描等)</param>
/// <param name="rowNum">限制录入的行数“0”代表不限制</param>
/// <param name="sSymbol">限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)</param>
/// <returns></returns>
public static System.String formatlengthError(string fileType, string str, int length, string sMBLNO, string sType, int rowNum, string sSymbol, bool isHuoMiao)
{
string error = "";
string Shipping = str;
if (fileType == "txt")
{
Shipping = formatEdiStr("txt", str);
}
else if (fileType == "xml")
{
Shipping = formatEdiStr("txt", str);
}
string[] argAGENT = Shipping.Split(new string[] { "\r\n" }, StringSplitOptions.None);
if (argAGENT.Length > 0)
{
if (argAGENT.Length == 1)
{
argAGENT = Shipping.Split(new string[] { "\n" }, StringSplitOptions.None);
if (argAGENT.Length > 0)
{
if (argAGENT.Length > rowNum && rowNum != 0)
{
if (isHuoMiao)
{
error = error + "<br />提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
}
else
{
error = error + "<br />提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
}
}
for (int j = 0; j < argAGENT.Length; j++)
{
//List<System.String> AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
if (argAGENT[j].ToString().Length > length)
{
error = error + "<br />提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
}
}
}
}
else
{
if (argAGENT.Length > rowNum && rowNum != 0)
{
if (isHuoMiao)
{
error = error + "<br />提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
}
else
{
error = error + "<br />提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
}
}
for (int j = 0; j < argAGENT.Length; j++)
{
//List<System.String> AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
if (argAGENT[j].ToString().Length > length)
{
error = error + "<br />提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
}
}
}
}
return error;
}
#endregion
#region 字符转义
/// <summary>
/// 各种文本转义字符
/// </summary>
/// <param name="fileType">文件类型例如txt、xml</param>
/// <param name="str">文本字符串</param>
/// <returns></returns>
public static string formatEdiStr(string fileType, string str)
{
if (fileType == "txt")
{
return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'");
}
else if (fileType == "xml")
{
return str.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
}
else if (fileType == "sitc")
{
return str.Replace("?", "??").Replace(":", "?:").Replace("'", "?'");
}
else
{
return str;
}
}
#endregion
#region 格式化每行
public static List<System.String> formatlengthStr(string str, int length, bool formatstr = false, bool nodelsp = false)
{
str = str.Replace("\r\n", "\\");
str = str.Replace("\n", "\\");
str = str.Replace("\r", " ");
string[] StrList = str.Split('\\');
var strtemp = "";
var strnewline = "";
var strtempnewline = "";
char[] spstring = { ' ', ';', ',', '.', ':', '/', '(', ')', '?', '+', '-' };
List<System.String> DestList = new List<System.String>();
for (var i = 0; i <= StrList.Length - 1; i++)
{
if (StrList[i].Length <= length)
{
if (formatstr)
DestList.Add(formatEdiStr("txt", StrList[i]));
else
DestList.Add(StrList[i]);
}
else
{
strtemp = StrList[i] + " ";
strtempnewline = "";
strnewline = "";
for (var j = 0; j < strtemp.Length; j++)
{
strtempnewline = strtempnewline + strtemp[j];
if (strtemp[j] == ' ' || strtemp[j] == ':' || strtemp[j] == ',' || strtemp[j] == '.' || strtemp[j] == ':' || strtemp[j] == '/'
|| strtemp[j] == '?' || strtemp[j] == ')' || strtemp[j] == '}' || strtemp[j] == '+' || strtemp[j] == '-')
{
if ((strnewline.Length + strtempnewline.Length) <= length)
strnewline = strnewline + strtempnewline;
else
{
if (formatstr)
DestList.Add(formatEdiStr("txt", strnewline));
else
DestList.Add(strnewline);
strnewline = strtempnewline;
}
strtempnewline = "";
}
}
if (nodelsp)
{
if (formatstr)
DestList.Add(formatEdiStr("txt", strnewline));
else DestList.Add(strnewline);
}
else if (strnewline.Trim() != "")
{
if (formatstr)
DestList.Add(formatEdiStr("txt", strnewline));
else DestList.Add(strnewline);
}
}
}
return DestList;
}
#endregion
#endregion
#region 检查
public static string IsCreateCargoSmartEDI(MsCargoSmartEdiModel InttrEdi)
{
var error = "";
if (string.IsNullOrEmpty(InttrEdi.SENDCODE))
{ error = error + "<br />发送方代码不能为空"; }
if (string.IsNullOrEmpty(InttrEdi.SENDNAME))
{ error = error + "<br />发送方名称不能为空"; }
if (string.IsNullOrEmpty(InttrEdi.RECEIVECODE))
{ error = error + "<br />接收方代码不能为空"; }
if (InttrEdi.filetype == "B")
{
if (InttrEdi.UseForWarderCode)
{
if (string.IsNullOrEmpty(InttrEdi.ForWarderCode))
{ error = error + "<br />货代代码不能为空"; }
if (string.IsNullOrEmpty(InttrEdi.ForWarderName))
{ error = error + "<br />货代称呼不能为空"; }
}
}
foreach (var headData in InttrEdi.BSLIST)
{
if (InttrEdi.filetype == "B")
{
if (InttrEdi.UseForWarderCode)
{
if (string.IsNullOrEmpty(headData.ORDERNO))
{ error = error + "<br />订舱编号不能为空"; }
}
}
if (headData.CARRIER != "YML")
{
if (string.IsNullOrEmpty(headData.OpEName))
{ error = error + "<br />操作的英文名不能为空"; }
if (string.IsNullOrEmpty(headData.OpTel))
{ error = error + "<br />操作的电话不能为空"; }
if (string.IsNullOrEmpty(headData.OpEmail))
{ error = error + "<br />操作的邮箱不能为空"; }
}
if (string.IsNullOrEmpty(headData.MBLNO))
{ error = error + "<br />主提单号不能为空"; }
if (string.IsNullOrEmpty(headData.BLFRT))
{ error = error + "<br />提单号:" + headData.MBLNO + " 付费方式不能为空"; }
if (string.IsNullOrEmpty(headData.SERVICE))
{ error = error + "<br />提单号:" + headData.MBLNO + " 运输条款不能为空"; }
if (string.IsNullOrEmpty(headData.CONTRACTNO))
{ error = error + "<br />提单号:" + headData.MBLNO + " 运费协议号不能为空"; }
if (string.IsNullOrEmpty(headData.CARGOID))
{ error = error + "<br />提单号:" + headData.MBLNO + " 货物标识不能为空"; }
if (headData.CARGOID == "D" || headData.SERVICE == "DOOR-DOOR" || headData.SERVICE == "DOOR-CY" || headData.SERVICE == "CY-DOOR")
{
if (headData.CARRIER != "YML")
{
if (string.IsNullOrEmpty(headData.EDIATTN))
{ error = error + "<br />EDI信息联系人不能为空"; }
if (string.IsNullOrEmpty(headData.EDIATTNTEL))
{ error = error + "<br />EDI信息联系人电话不能为空"; }
if (string.IsNullOrEmpty(headData.EDIATTNEMAIL))
{ error = error + "<br />EDI信息联系人邮箱不能为空"; }
}
}
if (InttrEdi.filetype == "E")
{
if (string.IsNullOrEmpty(headData.VESSEL))
{ error = error + "<br />提单号:" + headData.MBLNO + " 船名不能为空"; }
if (string.IsNullOrEmpty(headData.VOYNO))
{ error = error + "<br />提单号:" + headData.MBLNO + " 航次不能为空"; }
}
if (InttrEdi.filetype == "E")
{
if (headData.SIREMARK.IndexOf("PLEASE BOOK OCEAN CARRIER") > -1 || headData.SIREMARK.ToString().Trim() == "")
{
if (headData.CARRIER == "COSU")
{
error = error + "<br />提单号:" + headData.MBLNO + " 请在SI备注中输入:COSCO 销售的营销代码(此代码船公司会直接提供)";
}
else
{
//if (carrier != "YML")
//error = error + "<br />提单号:" + bill.MBLNO + " EDI备注中不能为空";
}
}
else
{
if (StringIsChinese(headData.SIREMARK))
{
error = error + "<br />提单号:" + headData.MBLNO + " SI备注中含有中文或双字节字符";
}
}
}
else
{
if (headData.EDIREMARK.IndexOf("PLEASE BOOK OCEAN CARRIER") > -1 || headData.EDIREMARK.ToString().Trim() == "")
{
if (headData.CARRIEREDICODE == "COSU")
{
error = error + "<br />提单号:" + headData.MBLNO + " 请在EDI备注中输入:COSCO 销售的营销代码(此代码船公司会直接提供)";
}
else
{
//if (carrier != "YML")
//error = error + "<br />提单号:" + bill.MBLNO + " EDI备注中不能为空";
}
}
else
{
if (StringIsChinese(headData.EDIREMARK))
{
error = error + "<br />提单号:" + headData.MBLNO + " EDI备注中含有中文或双字节字符";
}
}
}
//if (string.IsNullOrEmpty(headData.CARRIER))
//{ error = error + "<br />提单号:" + headData.MBLNO + " 船公司不能为空"; }
if (string.IsNullOrEmpty(headData.CARRIEREDICODE))
{ error = error + "<br />提单号:" + headData.MBLNO + " 船公司EDI代码不能为空"; }
if (string.IsNullOrEmpty(headData.SHIPPER))
{
error = error + "<br />提单号:" + headData.MBLNO + " 发货人不能为空";
}
else
{
if (StringIsChinese(headData.SHIPPER))
{
error = error + "<br />提单号:" + headData.MBLNO + " 发货人含有中文或双字节字符";
}
else
{
if (headData.CARRIEREDICODE == "HLCU")
{
error += formatlengthError("txt", headData.SHIPPER, 35, headData.MBLNO, "发货人", 6, "-", false);
}
else
{
error += formatlengthError("txt", headData.SHIPPER, 35, headData.MBLNO, "发货人", 6, "*", false);
}
}
}
//}
if (string.IsNullOrEmpty(headData.CONSIGNEE))
{
error = error + "<br />提单号:" + headData.MBLNO + " 收货人不能为空";
}
else
{
if (StringIsChinese(headData.CONSIGNEE))
{
error = error + "<br />提单号:" + headData.MBLNO + " 收货人含有中文或双字节字符";
}
else
{
if (headData.CARRIEREDICODE == "HLCU")
{
error += formatlengthError("txt", headData.CONSIGNEE, 35, headData.MBLNO, "收货人", 6, "--", false);
}
else
{
error += formatlengthError("txt", headData.CONSIGNEE, 35, headData.MBLNO, "收货人", 6, "**", false);
}
}
}
if (headData.SERVICE == "CY-DOOR")
{
if (string.IsNullOrEmpty(headData.CONSIGNEEDOORADDR))
{
error = error + "<br />提单号:" + headData.MBLNO + " 运输条款为:CY-DOOREDI信息中的DOOR地址不能为空";
}
else
{
if (StringIsChinese(headData.CONSIGNEEDOORADDR))
{
error = error + "<br />提单号:" + headData.MBLNO + " DOOR地址含有中文或双字节字符";
}
}
}
if (headData.SERVICE == "DOOR-CY")
{
if (string.IsNullOrEmpty(headData.SHIPPERDOORADDR))
{
error = error + "<br />提单号:" + headData.MBLNO + " 运输条款为:DOOR-CYEDI信息中的联系人地址不能为空";
}
else
{
if (StringIsChinese(headData.SHIPPERDOORADDR))
{
error = error + "<br />提单号:" + headData.MBLNO + " 联系人地址含有中文或双字节字符";
}
}
}
if (string.IsNullOrEmpty(headData.NOTIFYPARTY))
{
error = error + "<br />提单号:" + headData.MBLNO + " 通知人不能为空";
}
else
{
if (StringIsChinese(headData.NOTIFYPARTY))
{
error = error + "<br />提单号:" + headData.MBLNO + " 通知人含有中文或双字节字符";
}
else
{
if (headData.CARRIEREDICODE == "HLCU")
{
error += formatlengthError("txt", headData.NOTIFYPARTY, 35, headData.MBLNO, "通知人", 6, "---", false);
}
else
{
error += formatlengthError("txt", headData.NOTIFYPARTY, 35, headData.MBLNO, "通知人", 6, "***", false);
}
}
}
if (!string.IsNullOrEmpty(headData.NOTIFYPARTY2))
{
error += formatlengthError("txt", headData.NOTIFYPARTY2, 35, headData.MBLNO, "第二通知人", 5, "", false);
}
if (string.IsNullOrEmpty(headData.MARKS))
{
error = error + "<br />提单号:" + headData.MBLNO + " 唛头不能为空";
}
else
{
if (StringIsChinese(headData.MARKS))
{
error = error + "<br />提单号:" + headData.MBLNO + " 唛头含有中文或双字节字符";
}
else
{
error += formatlengthError("txt", headData.MARKS, 35, headData.MBLNO, "唛头", 0, "", false);
}
}
if (string.IsNullOrEmpty(headData.DESCRIPTION))
{
error = error + "<br />提单号:" + headData.MBLNO + " 货物描述不能为空";
}
else
{
if (StringIsChinese(headData.DESCRIPTION))
{
error = error + "<br />提单号:" + headData.MBLNO + " 货物描述含有中文或双字节字符";
}
else
{
//error += formatlengthError("txt", bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 0, "");
}
}
if (string.IsNullOrEmpty(headData.PORTLOADID) || headData.PORTLOADID.Length != 5)
{ error = error + "<br />提单号:" + headData.MBLNO + " 装货港代码不能为空或录入不正确(必须是5位代码)"; }
if (string.IsNullOrEmpty(headData.PORTLOAD))
{ error = error + "<br />提单号:" + headData.MBLNO + " 装货港不能为空"; }
if (string.IsNullOrEmpty(headData.ETD))
{
error = error + "<br />提单号:" + headData.MBLNO + " 开船日期不能为空";
return error;
}
if (string.IsNullOrEmpty(headData.PORTDISCHARGEID) || headData.PORTDISCHARGEID.Length != 5)
{ error = error + "<br />提单号:" + headData.MBLNO + " 卸货港代码不能为空或录入不正确(必须是5位代码)"; }
if (string.IsNullOrEmpty(headData.PORTDISCHARGE))
{ error = error + "<br />提单号:" + headData.MBLNO + " 卸货港不能为空"; }
if (string.IsNullOrEmpty(headData.DESTINATION))
{
if (string.IsNullOrEmpty(headData.DESTINATIONID) || headData.DESTINATIONID.Length != 5)
{ error = error + "<br />提单号:" + headData.MBLNO + " 目的地代码不能为空或录入不正确(必须是5位代码)"; }
}
if (string.IsNullOrEmpty(headData.KINDPKGS_EDI_CODE))
{ error = error + "<br />提单号:" + headData.MBLNO + " 包装EDI代码不能为空"; }
if (headData.PKGS == 0)
{ error = error + "<br />提单号:" + headData.MBLNO + " 件数不能为0"; }
if (headData.KGS == 0)
{ error = error + "<br />提单号:" + headData.MBLNO + " 毛重不能为0"; }
if (headData.CBM == 0)
{ error = error + "<br />提单号:" + headData.MBLNO + " 尺码不能为0"; }
if (headData.CARGOID == "D")
{
if (string.IsNullOrEmpty(headData.DCLASS))
{ error = error + "<br />提单号:" + headData.MBLNO + " 危险品分类不能为空"; }
if (string.IsNullOrEmpty(headData.DUNNO))
{ error = error + "<br />提单号:" + headData.MBLNO + " 危险品编号不能为空"; }
}
if (headData.CARGOID == "R")
{
if (headData.TEMPSET == null || headData.TEMPSET == "")
{ error = error + "<br />提单号:" + headData.MBLNO + " 设置温度不能为空"; }
if (headData.REEFERF == null || headData.REEFERF == "")
{ error = error + "<br />提单号:" + headData.MBLNO + " 通风度不能为空"; }
}
if (headData.BLFRT != null && headData.BLFRT.IndexOf("PREPAID") >= 0)
{
if (string.IsNullOrEmpty(headData.PREPARDAT))
{ error = error + "<br />提单号:" + headData.MBLNO + " 预付地点不能为空"; }
if (string.IsNullOrEmpty(headData.PREPARDATID))
{ error = error + "<br />提单号:" + headData.MBLNO + " 预付地点EDI代码不能为空"; }
}
else if (headData.BLFRT != null && headData.BLFRT.IndexOf("COLLECT") >= 0)
{
if (string.IsNullOrEmpty(headData.PAYABLEAT))
{ error = error + "<br />提单号:" + headData.MBLNO + " 到付地点不能为空"; }
if (string.IsNullOrEmpty(headData.PAYABLEATID))
{ error = error + "<br />提单号:" + headData.MBLNO + " 到付地点EDI代码不能为空"; }
}
if (InttrEdi.filetype == "E")
{
if (string.IsNullOrEmpty(headData.ISSUEPLACEID))
{ error = error + "<br />提单号:" + headData.MBLNO + " 签单地点或到签单地点EDI代码不能为空"; }
}
var ctnlist = headData.CTNLIST;
if (ctnlist.Count == 0) { error = error + "<br />提单号:" + headData.MBLNO + " 集装箱信息不能为空"; };
if (InttrEdi.filetype == "E")
{
#region 集装箱判断检查
if (ctnlist.Count != 0)
{
Decimal dlPKGS = 0;
Decimal dlKGS = 0;
Decimal dlCBM = 0;
foreach (var ctn in ctnlist)
{
if (string.IsNullOrEmpty(ctn.CTNALLCODE))
{ error = error + "<br />提单号:" + headData.MBLNO + " 集装箱箱型EDI代码不能为空"; }
if (string.IsNullOrEmpty(ctn.CNTRNO))
{ error = error + "<br />提单号:" + headData.MBLNO + " 箱号不能为空"; }
if (string.IsNullOrEmpty(ctn.SEALNO))
{ error = error + "<br />提单号:" + headData.MBLNO + " 封号不能为空"; }
if (headData.BYCOUNTRY == "BRAZIL")
{
if (string.IsNullOrEmpty(ctn.TAREWEIGHT) || Convert.ToDecimal(ctn.TAREWEIGHT) == 0)
{ error = error + "<br />提单号:" + headData.MBLNO + " 箱皮重不能为空"; }
}
if (ctn.KINDPKGS != headData.KINDPKGS)
{ error = error + "<br />提单号:" + headData.MBLNO + " 中的包装类型与集装箱的包装类型不同"; }
dlPKGS += Convert.ToDecimal(ctn.PKGS);
dlKGS += Convert.ToDecimal(ctn.KGS);
dlCBM += Convert.ToDecimal(ctn.CBM);
}
if (dlPKGS != Convert.ToDecimal(headData.PKGS))
{ error = error + "<br />提单号:" + headData.MBLNO + " 集装箱件数合计数必须等于委托单总件数"; }
if (dlKGS != Convert.ToDecimal(headData.KGS))
{ error = error + "<br />提单号:" + headData.MBLNO + " 集装箱重量合计数必须等于委托单总重量数"; }
if (dlCBM != Convert.ToDecimal(headData.CBM))
{ error = error + "<br />提单号:" + headData.MBLNO + " 集装箱尺码合计数必须等于委托单总尺码数"; }
}
if (headData.CTNGOODSLIST != null && headData.CTNGOODSLIST.Count > 0)
{
foreach (var ctn in ctnlist)
{
var isfind = false;
Int32 ctngoodssumpkgs = 0;
decimal ctngoodssumkgs = 0;
decimal ctngoodssumcbm = 0;
headData.CTNGOODSLIST.ForEach(i =>
{
if (i.CNTRNO == ctn.CNTRNO)
{
isfind = true;
ctngoodssumpkgs = ctngoodssumpkgs + i.PKGS;
ctngoodssumkgs = ctngoodssumkgs + i.KGS;
ctngoodssumcbm = ctngoodssumcbm + i.CBM;
}
});
if (!isfind)
{
error = error + "<br />提单号:" + headData.MBLNO + "的“" + ctn.CNTRNO + "”未添加分箱明细!";
}
else
{
if (ctngoodssumpkgs != Convert.ToDecimal(ctn.PKGS))
{ error = error + "<br />提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细件数合计数不等于集装箱件数"; }
if (ctngoodssumkgs != Convert.ToDecimal(ctn.KGS))
{ error = error + "<br />提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细毛重合计数不等于集装箱毛重"; }
if (ctngoodssumcbm != Convert.ToDecimal(ctn.CBM))
{ error = error + "<br />提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细尺码合计数不等于集装箱毛重"; }
}
}
foreach (var ctngood in headData.CTNGOODSLIST)
{
if (string.IsNullOrEmpty(ctngood.KINDPKGS))
{ error = error + "<br />提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型不能为空"; }
if (string.IsNullOrEmpty(ctngood.DESCRIPTION))
{ error = error + "<br />提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱货物描述不能为空"; }
else
{
error += formatlengthError("txt", ctngood.DESCRIPTION, 70, headData.MBLNO, "的“" + ctngood.CNTRNO + "”箱号的分箱货物描述", 0, "", false);
}
//if (string.IsNullOrEmpty(ctngood.HSCODE))
//{ error = error + "<br />提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱HS编码不能为空"; }
if (string.IsNullOrEmpty(ctngood.KINDPKGS_EDI_CODE))
{ error = error + "<br />提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型代码不能为空"; }
}
}
#endregion
if (headData.BYCOUNTRY == "USA")
{
if (string.IsNullOrEmpty(headData.CONSIGNEEPOSTCODE))
{ error = error + "<br />提单号:" + headData.MBLNO + " 收货人邮编不能为空"; }
if (string.IsNullOrEmpty(headData.NOTIFYPARTYPOSTCODE))
{ error = error + "<br />提单号:" + headData.MBLNO + " 通知人邮编不能为空"; }
}
else if (headData.BYCOUNTRY == "CANADA")
{
if (string.IsNullOrEmpty(headData.CONSIGNEEPOSTCODE))
{ error = error + "<br />提单号:" + headData.MBLNO + " 收货人邮编不能为空"; }
}
else if (headData.BYCOUNTRY == "BRAZIL")
{
if (string.IsNullOrEmpty(headData.CONSIGNEECOUNTRY))
{ error = error + "<br />提单号:" + headData.MBLNO + " 收货人国家代码不能为空"; }
if (string.IsNullOrEmpty(headData.CONSIGNEETAXNO))
{ error = error + "<br />提单号:" + headData.MBLNO + " 收货人税号不能为空"; }
if (string.IsNullOrEmpty(headData.NOTIFYPARTYCOUNTRY))
{ error = error + "<br />提单号:" + headData.MBLNO + " 通知人国家代码不能为空"; }
if (string.IsNullOrEmpty(headData.NOTIFYPARTYTAXNO))
{ error = error + "<br />提单号:" + headData.MBLNO + " 通知人税号不能为空"; }
if (string.IsNullOrEmpty(headData.GOODSNCM))
{ error = error + "<br />提单号:" + headData.MBLNO + " 货物NCM编码不能为空"; }
}
}
}
return error;
}
#endregion
#region 订舱
public static string CreateEdiCargoSmart(MsCargoSmartEdiModel InttrEdi)
{
string filename = InttrEdi.filerpath + "\\IFTMINB_" + InttrEdi.BSLIST[0].MBLNO + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
FileStream f = new FileStream(filename, FileMode.Create);
StreamWriter r = new StreamWriter(f, Encoding.Default);
var icount = 0;
var bsno = "";
foreach (var bill in InttrEdi.BSLIST)
{
bsno = bill.ORDERNO;
r.WriteLine("UNB+UNOC:2+" + InttrEdi.SENDCODE + ":01+" + InttrEdi.RECEIVECODE + ":01+" + DateTime.Now.ToString("yyMMdd:HHmm") + "+" + bill.ORDERNO + "'");
r.WriteLine("UNH+" + bill.ORDERNO + "+IFTMBF:D:99B:UN'");
icount = icount + 2;
if (bill.CARRIEREDICODE == "HLCU")
{
if (InttrEdi.filerole == "9")
r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+9'");
else if (InttrEdi.filerole == "1")
r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+1'");
else
r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+5'");
}
else
{
if (InttrEdi.filerole == "9")
r.WriteLine("BGM+335+" + bill.MBLNO + "SO+9'");
else if (InttrEdi.filerole == "1")
r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+1'");
else
r.WriteLine("BGM+335+" + bill.MBLNO + "SO+5'");
}
if (bill.CARRIEREDICODE == "MSCU")
r.WriteLine("DTM+318:" + DateTime.Now.ToString("yyyyMMddHHmm") + ":203'");
else
r.WriteLine("DTM+137:" + DateTime.Now.ToString("yyyyMMddHHmm") + ":203'");
icount = icount + 2;
if (bill.SERVICE.ToUpper() == "DOOR-DOOR")
{
r.WriteLine("TSR+27+2'");
}
else if (bill.SERVICE.ToUpper() == "DOOR-CY")
{
r.WriteLine("TSR+28+2'");
}
else if (bill.SERVICE.ToUpper() == "CY-DOOR")
{
r.WriteLine("TSR+29+2'");
}
else
{
r.WriteLine("TSR+30+2'");
}
var str_pay = "";
if (bill.BLFRT.IndexOf("PREPAID") >= 0)
str_pay = bill.PREPARDAT;
if (bill.BLFRT.IndexOf("COLLECT") >= 0)
str_pay = bill.PAYABLEAT;
var Shipping = "";
Shipping = formatEdiStr("txt", bill.EDIREMARK);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] EdiRemarkList = Shipping.Split('\\');
if (EdiRemarkList.Length != 0)
{
for (var i = 0; i < EdiRemarkList.Length; i++)
{
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
r.WriteLine("FTX+AAI+++" + EdiRemarkList[i] + "'");
}
else
r.WriteLine("FTX+AAA+++" + EdiRemarkList[i] + "'");
icount = icount + 1;
}
}
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
r.WriteLine("CNT+7:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + ":KGM'");//按照四舍五入的国际标准
r.WriteLine("CNT+11:" + bill.PKGS + "'");
r.WriteLine("CNT+15:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + ":CBM'");
icount = icount + 3;
if (bill.CTNLIST.Count > 0)
{
var ctnnum = 0;
foreach (var ctn in bill.CTNLIST)
{
ctnnum = ctnnum + ctn.CTNNUM;
}
r.WriteLine("CNT+16:" + ctnnum.ToString() + "'");
icount = icount + 1;
}
}
if (bill.CARRIEREDICODE == "UASC")
{
if (bill.CTNLIST.Count > 0)
{
var ctnnum = 0;
foreach (var ctn in bill.CTNLIST)
{
ctnnum = ctnnum + ctn.CTNNUM;
}
r.WriteLine("CNT+16:" + ctnnum.ToString() + "'");
icount = icount + 1;
}
}
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
if (bill.BLFRT == "FREIGHT COLLECT")
{
if (bill.PAYABLEAT != "")
{
r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PAYABLEAT + "'");
icount = icount + 1;
}
}
else
{
r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PREPARDAT + "'");
icount = icount + 1;
}
r.WriteLine("LOC+73+" + bill.ISSUEPLACEID + "::6:" + bill.ISSUEPLACE + "'");
icount = icount + 1;
}
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
r.WriteLine("DTM+95:" + Convert.ToDateTime(bill.ISSUEDATE).ToString("yyyyMMdd") + ":102'");
icount = icount + 1;
}
if (InttrEdi.UseForWarderCode)
{
r.WriteLine("RFF+FF:" + bill.ORDERNO.Trim() + "'");
r.WriteLine("RFF+ON:" + bill.ORDERNO.Trim() + "'");
icount = icount + 2;
}
else
{
if (bill.ORDERNO.Trim() != "")
{
r.WriteLine("RFF+FF:" + bill.ORDERNO.Trim() + "'");
r.WriteLine("RFF+ON:" + bill.ORDERNO.Trim() + "'");
icount = icount + 2;
}
}
if (bill.CARRIEREDICODE != "COSU")
{
if (bill.CARRIEREDICODE == "HLCU")
{
//r.WriteLine("RFF+ON:" + bill.CUSTNO + "'");
r.WriteLine("RFF+BM:" + bill.MBLNO + "'");
}
else
{
r.WriteLine("RFF+BN:" + bill.MBLNO + "'");
r.WriteLine("RFF+BM:" + bill.MBLNO + "'");
}
icount = icount + 2;
}
r.WriteLine("RFF+CT:" + bill.CONTRACTNO + "'");
if (bill.BLFRT.IndexOf("PREPAID") >= 0)
r.WriteLine("CPI+4++P'");
else if (bill.BLFRT.IndexOf("COLLECT") >= 0)
r.WriteLine("CPI+4++C'");
else
r.WriteLine("CPI+4++B'");
icount = icount + 2;
var voyno = "";
if (!string.IsNullOrEmpty(bill.NVOYNO)) voyno = bill.NVOYNO; else voyno = bill.VOYNO;
if (voyno.IndexOf(".") >= 0)
voyno = voyno.Substring(voyno.IndexOf(".") + 1, voyno.Length - voyno.IndexOf(".") - 1);
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
var tmpcarrier = "CMDU";
if (bill.CARRIEREDICODE == "ANL2") tmpcarrier = "ANNU";
if (bill.CARRIEREDICODE == "CNC2") tmpcarrier = "CHNL";
r.WriteLine("TDT+20+" + voyno + "+1++" + tmpcarrier + "+++:::" + bill.VESSEL + "'");
}
else
r.WriteLine("TDT+20+" + voyno + "+1++" + bill.CARRIEREDICODE + "+++:::" + bill.VESSEL + "'");
r.WriteLine("LOC+9+" + bill.PORTLOADID + ":139:6:" + bill.PORTLOAD + "'");
r.WriteLine("DTM+133:" + Convert.ToDateTime(bill.ETD).ToString("yyyyMMdd") + ":102'");//yyyyMMddHHmm
r.WriteLine("LOC+88+" + bill.PORTLOADID + ":139:6:" + bill.PORTLOAD + "'");
r.WriteLine("LOC+11+" + bill.PORTDISCHARGEID + ":139:6:" + bill.PORTDISCHARGE + "'");
icount = icount + 5;
if (bill.DESTINATION != "")
{
r.WriteLine("LOC+7+" + bill.DESTINATIONID + ":139:6:" + bill.DESTINATION + "'");
icount = icount + 1;
}
Shipping = "";
var DescriptionShipper = "";
Shipping = formatEdiStr("txt", bill.SHIPPER);
List<System.String> ShippingList = formatlengthStr(Shipping, 35);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
if (i == 0) Shipping = "NAD+SH+++" + ShippingList[0] + "+";
}
else
if (i == 0) Shipping = "NAD+CZ+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i];
if (i >= 4 && ShippingList.Count > 5)
{
if (i == 4)
{
if (ShippingList[i].Length > 34)
{
Shipping = Shipping + ":" + ShippingList[i].Substring(0, 34);
DescriptionShipper = ShippingList[i].Substring(34);
}
else
Shipping = Shipping + ":" + ShippingList[i];
if (bill.CARRIEREDICODE == "HLCU")
{
Shipping = Shipping + "-";
DescriptionShipper = "-" + DescriptionShipper;
}
else
{
Shipping = Shipping + "*";
DescriptionShipper = "*" + DescriptionShipper;
}
}
else if (i > 4)
{
DescriptionShipper = DescriptionShipper + " " + ShippingList[i];
}
}
else
if (i == 4) Shipping = Shipping + ":" + ShippingList[i];
}
}
r.WriteLine(Shipping + "'");
icount = icount + 1;
Shipping = formatEdiStr("txt", bill.CONSIGNEE);
ShippingList = formatlengthStr(Shipping, 35);
var DescriptionConsignee = "";
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+CN+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i];
if (i >= 4 && ShippingList.Count > 5)
{
if (i == 4)
{
if (ShippingList[i].Length > 33)
{
Shipping = Shipping + ":" + ShippingList[i].Substring(0, 33);
DescriptionConsignee = ShippingList[i].Substring(33);
}
else
Shipping = Shipping + ":" + ShippingList[i];
if (bill.CARRIEREDICODE == "HLCU")
{
Shipping = Shipping + "--";
DescriptionConsignee = "--" + DescriptionConsignee;
}
else
{
Shipping = Shipping + "**";
DescriptionConsignee = "**" + DescriptionConsignee;
}
}
else if (i > 4)
{
DescriptionConsignee = DescriptionConsignee + " " + ShippingList[i];
}
}
else
if (i == 4) Shipping = Shipping + ":" + ShippingList[i];
}
}
if (bill.BYCOUNTRY == "USA")
{
Shipping = Shipping + "+++" + bill.CONSIGNEEPOSTCODE;
r.WriteLine(Shipping + "'");
}
else if (bill.BYCOUNTRY == "CANADA")
{
Shipping = Shipping + "+++" + bill.CONSIGNEEPOSTCODE + "+CA";
r.WriteLine(Shipping + "'");
}
else if (bill.BYCOUNTRY == "BRAZIL")
{
Shipping = Shipping + "++++" + bill.CONSIGNEECOUNTRY;
r.WriteLine(Shipping + "'");
r.WriteLine("RFF+GN:" + bill.CONSIGNEETAXNO + "'");
icount = icount + 1;
}
else r.WriteLine(Shipping + "'");
icount = icount + 1;
Shipping = formatEdiStr("txt", bill.NOTIFYPARTY);
ShippingList = formatlengthStr(Shipping, 35);
var DescriptionNotifyparty = "";
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
if (i == 0) Shipping = "NAD+NI+++" + ShippingList[0] + "+";
}
else
if (i == 0) Shipping = "NAD+NI+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i];
if (i >= 4 && ShippingList.Count > 5)
{
if (i == 4)
{
if (ShippingList[i].Length > 32)
{
Shipping = Shipping + ":" + ShippingList[i].Substring(0, 32);
DescriptionNotifyparty = ShippingList[i].Substring(32);
}
else
Shipping = Shipping + ":" + ShippingList[i];
if (bill.CARRIEREDICODE == "HLCU")
{
Shipping = Shipping + "---";
DescriptionNotifyparty = "---" + DescriptionNotifyparty;
}
else
{
Shipping = Shipping + "***";
DescriptionNotifyparty = "***" + DescriptionNotifyparty;
}
}
else if (i > 4)
{
DescriptionNotifyparty = DescriptionNotifyparty + " " + ShippingList[i];
}
}
else
if (i == 4) Shipping = Shipping + ":" + ShippingList[i];
}
}
if (bill.BYCOUNTRY == "USA")
{
Shipping = Shipping + "+++" + bill.NOTIFYPARTYPOSTCODE;
r.WriteLine(Shipping + "'");
}
else if (bill.BYCOUNTRY == "BRAZIL")
{
if (bill.NOTIFYPARTYCOUNTRY != "")
Shipping = Shipping + "++++" + bill.NOTIFYPARTYCOUNTRY;
r.WriteLine(Shipping + "'");
if (bill.NOTIFYPARTYTAXNO != "")
{
r.WriteLine("RFF+GN:" + bill.NOTIFYPARTYTAXNO + "'");
icount = icount + 1;
}
}
else r.WriteLine(Shipping + "'");
icount = icount + 1;
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
var tmpcarrier = "CMDU";
if (bill.CARRIEREDICODE == "ANL2") tmpcarrier = "ANNU";
if (bill.CARRIEREDICODE == "CNC2") tmpcarrier = "CHNL";
r.WriteLine("NAD+CA+" + tmpcarrier + "'");
}
else
r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'");
icount = icount + 1;
if (bill.SERVICE == "DOOR-DOOR")
{
Shipping = formatEdiStr("txt", bill.SHIPPER);
ShippingList = formatlengthStr(Shipping, 35);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+SF+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i >= 2) Shipping = Shipping + ":" + ShippingList[i];
}
}
r.WriteLine(Shipping + "'");
r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'");
r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'");
r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'");
icount = icount + 4;
Shipping = formatEdiStr("txt", bill.CONSIGNEE);
if (Shipping.ToUpper().IndexOf("TO ORDER") >= 0 || Shipping.ToUpper().IndexOf("SAME AS") >= 0)
Shipping = formatEdiStr("txt", bill.NOTIFYPARTY);
ShippingList = formatlengthStr(Shipping, 35);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+ST+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i >= 2) Shipping = Shipping + ":" + ShippingList[i];
}
}
r.WriteLine(Shipping + "'");
r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'");
r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'");
r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'");
icount = icount + 4;
}
if (bill.SERVICE == "DOOR-CY")
{
Shipping = formatEdiStr("txt", bill.SHIPPERDOORADDR);
ShippingList = formatlengthStr(Shipping, 35);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+SF+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i >= 2) Shipping = Shipping + ":" + ShippingList[i];
}
}
r.WriteLine(Shipping + "'");
r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'");
r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'");
r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'");
icount = icount + 4;
}
if (bill.SERVICE == "CY-DOOR")
{
Shipping = formatEdiStr("txt", bill.CONSIGNEEDOORADDR);
ShippingList = formatlengthStr(Shipping, 35);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+ST+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i >= 2) Shipping = Shipping + ":" + ShippingList[i];
}
}
r.WriteLine(Shipping + "'");
r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'");
r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'");
r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'");
icount = icount + 4;
}
if (bill.WEITUO != "")
{
if (bill.WEITUO.Length > 35)
r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO.Substring(0, 35)) + "+" + formatEdiStr("txt", bill.WEITUO.Substring(35)) + "'");
else
r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO) + "'");
}
else
{
if (InttrEdi.UseForWarderCode)
{
r.WriteLine("NAD+FW+" + InttrEdi.ForWarderCode + ":160:86++" + InttrEdi.ForWarderName + "'");
icount++;
}
else
{
if (InttrEdi.SENDNAME.Length > 35)
r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'");
else
r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'");
}
}
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
var alsendcode2 ="";
if (alsendcode2 == "") alsendcode2 = InttrEdi.SENDCODE;
//if (ftpset.SENDNAME.Length > 35)
// r.WriteLine("NAD+HI+" + alsendcode2 + ":160:86++" + ftpset.SENDNAME.Substring(0, 35) + "+" + ftpset.SENDNAME.Substring(35) + "'");
//else
r.WriteLine("NAD+HI+" + alsendcode2 + ":160:86++" + InttrEdi.SENDCODE + "'");
icount = icount + 1;
r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'");
r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'");
r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'");
var copynum = GetBillNum(bill.COPYNOBILL);
if (bill.ISSUETYPE == "正本")
{
r.WriteLine("DOC+705+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
if (copynum != "")
{
r.WriteLine("DOC+707+++" + copynum + "'");
icount = icount + 1;
}
}
else if (bill.ISSUETYPE == "海运单" || bill.ISSUETYPE == "Seaway" || bill.ISSUETYPE == "WAYBILL" || bill.ISSUETYPE == "SWB" || bill.ISSUETYPE == "SWB正本" || bill.ISSUETYPE == "SWB无正本")
{
r.WriteLine("DOC+710+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
}
else if (bill.ISSUETYPE == "BILL COPY" || bill.ISSUETYPE == "电放")
{
r.WriteLine("DOC+705+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
if (copynum != "")
{
r.WriteLine("DOC+707+++" + copynum + "'");
icount = icount + 1;
}
}
else if (bill.ISSUETYPE == "正副本")
{
r.WriteLine("DOC+705+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
if (copynum != "")
{
r.WriteLine("DOC+707+++" + copynum + "'");
icount = icount + 1;
}
}
else if (bill.ISSUETYPE == "HOUSE BILL")
{
r.WriteLine("DOC+714+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
}
}
if (bill.BLFRT.IndexOf("PREPAID") >= 0)
r.WriteLine("CPI+4++P'");
else if (bill.BLFRT.IndexOf("COLLECT") >= 0)
r.WriteLine("CPI+4++C'");
else
r.WriteLine("CPI+4++B'");
icount++;
if (InttrEdi.SENDNAME.Length > 35)
r.WriteLine("NAD+BK+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'");
else
r.WriteLine("NAD+BK+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'");
r.WriteLine("CTA+IC+:" + bill.OpEName + "'");
r.WriteLine("COM+" + bill.OpTel + ":TE'");
r.WriteLine("COM+" + bill.OpEmail + ":EM'");
r.WriteLine("GID+1+" + bill.PKGS.ToString() + ":" + bill.KINDPKGS_EDI_CODE + "::6:" + bill.KINDPKGS + "'");
icount = icount + 8;
if (bill.HSCODE != "")
{
r.WriteLine("PIA+5+" + bill.HSCODE + ":HS'");
icount = icount + 1;
}
Shipping = formatEdiStr("txt", bill.DESCRIPTION);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] DescriptionList = Shipping.Split('\\');
if (DescriptionList.Length != 0)
{
for (var i = 0; i < DescriptionList.Length; i++)
{
r.WriteLine("FTX+AAA+++" + DescriptionList[i] + "'");
icount = icount + 1;
}
}
if (DescriptionShipper != "")
{
r.WriteLine("FTX+AAA+++" + DescriptionShipper + "'");
icount = icount + 1;
}
if (DescriptionConsignee != "")
{
r.WriteLine("FTX+AAA+++" + DescriptionConsignee + "'");
icount = icount + 1;
}
if (DescriptionNotifyparty != "")
{
r.WriteLine("FTX+AAA+++" + DescriptionNotifyparty + "'");
icount = icount + 1;
}
r.WriteLine("MEA+WT+G+KGM:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + "'");
r.WriteLine("MEA+VOL+AAW+CBM:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + "'");
icount = icount + 2;
Shipping = formatEdiStr("txt", bill.MARKS);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] MarksList = Shipping.Split('\\');
if (MarksList.Length != 0)
{
for (var i = 0; i < MarksList.Length; i++)
{
r.WriteLine("PCI++" + MarksList[i] + "'");
icount = icount + 1;
}
}
if (bill.CARGOID == "D")
{
r.WriteLine("DGS+IMD+" + bill.DCLASS + "+" + bill.DUNNO + "'");
r.WriteLine("CTA+HG+:" + bill.EDIATTN + "'");
r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'");
icount = icount + 3;
}
var ctnsumlist = new List<MsOpSeaeCtnEdiModel>();
foreach (var ctn in bill.CTNLIST)
{
var isfind = false;
ctnsumlist.ForEach(i =>
{
if (i.CTNALLCODE == ctn.CTNALLCODE)
{
i.CTNNUM = i.CTNNUM + ctn.CTNNUM;
isfind = true;
}
});
if (!isfind)
{
var ctnnum = new MsOpSeaeCtnEdiModel();
ctnnum.CTNALLCODE = ctn.CTNALLCODE;
ctnnum.CTNNUM = ctn.CTNNUM;
ctnsumlist.Add(ctnnum);
}
}
foreach (var ctn in ctnsumlist)
{
if (bill.ISCONTAINERSOC)
r.WriteLine("EQD+CN++" + ctn.CTNALLCODE + "+1'");
else
r.WriteLine("EQD+CN++" + ctn.CTNNUM + "+2'");
r.WriteLine("EQN+" + ctn.CTNNUM.ToString() + "'");
icount = icount + 2;
if (bill.CARGOID == "R")
{
if (bill.REEFERF != "")
r.WriteLine("MEA+AAE+AAS+CBM:" + bill.REEFERF + "'");
if (bill.HUMIDITY != "")
r.WriteLine("MEA+AAE+AAO+HMD:" + bill.HUMIDITY + "'");
r.WriteLine("TMP+2+" + bill.TEMPSET + ":CEL'");
icount = icount + 2;
}
}
}
r.WriteLine("UNT+" + icount.ToString() + "+" + bsno + "'");
r.WriteLine("UNZ+" + InttrEdi.BSLIST.Count.ToString() + "+" + bsno + "'");
r.Close();
f.Close();
return filename;
}
#endregion
#region 确认
public static string CreateEdiCargoSmartSI(MsCargoSmartEdiModel InttrEdi)
{
string filename = InttrEdi.filerpath + "\\IFTMIN_" + InttrEdi.BSLIST[0].MBLNO + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
FileStream f = new FileStream(filename, FileMode.Create);
StreamWriter r = new StreamWriter(f, Encoding.Default);
var icount = 0;
var bsno = "";
foreach (var bill in InttrEdi.BSLIST)
{
bsno = bill.ORDERNO;
r.WriteLine("UNB+UNOC:2+" + InttrEdi.SENDCODE + ":01+" + InttrEdi.RECEIVECODE + ":01+" + DateTime.Now.ToString("yyMMdd:HHmm") + "+" + bill.ORDERNO + "'");
r.WriteLine("UNH+" + bill.ORDERNO + "+IFTMIN:D:99B:UN'");
if (InttrEdi.filerole == "9")
r.WriteLine("BGM+340+" + bill.MBLNO + "+9'");
else
r.WriteLine("BGM+340+" + bill.MBLNO + "+5'");
if (bill.SERVICE.ToUpper() == "DOOR-DOOR")
{
r.WriteLine("TSR+27+2'");
}
else if (bill.SERVICE.ToUpper() == "DOOR-CY")
{
r.WriteLine("TSR+28+2'");
}
else if (bill.SERVICE.ToUpper() == "CY-DOOR")
{
r.WriteLine("TSR+29+2'");
}
else
{
r.WriteLine("TSR+30+2'");
}
var str_pay = "";
if (bill.BLFRT.IndexOf("PREPAID") >= 0)
str_pay = bill.PREPARDAT;
if (bill.BLFRT.IndexOf("COLLECT") >= 0)
str_pay = bill.PAYABLEAT;
r.WriteLine("FTX+AAS+++" + bill.BLFRT + " Payable at " + str_pay + " " + bill.SERVICE + " "
+ bill.PKGS.ToString() + bill.KINDPKGS + "'");
icount = icount + 5;
var Shipping = "";
Shipping = formatEdiStr("txt", bill.SIREMARK);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] EdiRemarkList = Shipping.Split('\\');
if (EdiRemarkList.Length != 0)
{
for (var i = 0; i < EdiRemarkList.Length; i++)
{
r.WriteLine("FTX+AAS+++" + EdiRemarkList[i] + "'");
icount = icount + 1;
}
}
if (bill.BYCOUNTRY == "USA")
{
if (bill.SCACCODE != "")
r.WriteLine("FTX+CCI++MFS+1:US:" + bill.SCACCODE + "'");
else
r.WriteLine("FTX+CCI++MFS+5:US'");
icount = icount + 1;
}
else if (bill.BYCOUNTRY == "CANADA")
{
if (bill.SCACCODE != "")
r.WriteLine("FTX+CCI++MFS+1:CA:" + bill.SCACCODE + "'");
else
r.WriteLine("FTX+CCI++MFS+5:CA'");
icount = icount + 1;
}
r.WriteLine("CNT+7:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + ":KGM'");
r.WriteLine("CNT+11:" + bill.PKGS.ToString() + "'");
r.WriteLine("CNT+15:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + ":MTQ'");
icount = icount + 3;
if (bill.CARRIEREDICODE == "UASC")
{
if (bill.CTNLIST.Count > 0)
{
var ctnnum = 0;
foreach (var ctn in bill.CTNLIST)
{
ctnnum = ctnnum + ctn.CTNNUM;
}
r.WriteLine("CNT+16:" + ctnnum.ToString() + "'");
icount = icount + 1;
}
}
if (bill.BLFRT == "FREIGHT COLLECT")
{
if (bill.PAYABLEAT != "")
{
r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PAYABLEAT + "'");
icount = icount + 1;
}
}
else
{
r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PREPARDAT + "'");
icount = icount + 1;
}
r.WriteLine("LOC+73+" + bill.ISSUEPLACEID + "::6:" + bill.ISSUEPLACE + "'");
icount = icount + 1;
r.WriteLine("DTM+95:" + Convert.ToDateTime(bill.ISSUEDATE).ToString("yyyyMMdd") + ":102'");
icount = icount + 1;
if (bill.CARRIEREDICODE == "MASK")
{
Shipping = formatEdiStr("txt", bill.BSNOLIST);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
EdiRemarkList = Shipping.Split('\\');
if (EdiRemarkList.Length != 0)
{
for (var i = 0; i < EdiRemarkList.Length; i++)
{
r.WriteLine("RFF+BN:" + EdiRemarkList[i] + "'");
icount = icount + 1;
}
}
else
{
//if (billams.ORDERNO != "")
// r.WriteLine("RFF+BN:" + billams.ORDERNO + "'");
//else
r.WriteLine("RFF+BN:" + bill.MBLNO + "'");
icount = icount + 1;
}
}
else
{
//if (billams.ORDERNO != "")
// r.WriteLine("RFF+BN:" + billams.ORDERNO + "'");
//else
r.WriteLine("RFF+BN:" + bill.MBLNO + "'");
icount = icount + 1;
}
r.WriteLine("RFF+BM:" + bill.MBLNO + "'");
r.WriteLine("RFF+CT:" + bill.CONTRACTNO + "'");
icount = icount + 2;
if (bill.CARRIEREDICODE == "UASC")
{
r.WriteLine("RFF+SI:" + bill.ORDERNO + "'");
icount = icount + 1;
}
if (bill.BYCOUNTRY == "USA")
{
r.WriteLine("REF+TN:" + bill.ITNCODE + "'");
icount = icount + 1;
}
if (bill.BLFRT.IndexOf("PREPAID") >= 0)
r.WriteLine("CPI+4++P'");
else if (bill.BLFRT.IndexOf("COLLECT") >= 0)
r.WriteLine("CPI+4++C'");
else
r.WriteLine("CPI+4++B'");
icount = icount + 1;
var voyno = "";
if (bill.VOYNO.IndexOf(".") >= 0)
{
voyno = bill.VOYNO.Substring(bill.VOYNO.IndexOf(".") + 1, bill.VOYNO.Length - bill.VOYNO.IndexOf(".") - 1);
}
else
{
voyno = bill.VOYNO;
}
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
var tmpcarrier = "CMDU";
if (bill.CARRIEREDICODE == "ANL2") tmpcarrier = "ANNU";
if (bill.CARRIEREDICODE == "CNC2") tmpcarrier = "CHNL";
r.WriteLine("TDT+20+" + voyno + "+1++" + tmpcarrier + "+++:::" + bill.VESSEL + "'");
}
else r.WriteLine("TDT+20+" + voyno + "+1++" + bill.CARRIEREDICODE + "+++:::" + bill.VESSEL + "'");
r.WriteLine("LOC+9+" + bill.PORTLOADID + ":139:6:" + bill.PORTLOAD + "'");
r.WriteLine("LOC+88+" + bill.PORTLOADID + ":139:6:" + bill.PORTLOAD + "'");
r.WriteLine("LOC+11+" + bill.PORTDISCHARGEID + ":139:6:" + bill.PORTDISCHARGE + "'");
icount = icount + 4;
if (bill.DESTINATION != "")
{
r.WriteLine("LOC+7+" + bill.DESTINATIONID + ":139:6:" + bill.DESTINATION + "'");
icount = icount + 1;
}
var DescriptionShipper = "";
Shipping = formatEdiStr("txt", bill.SHIPPER);
List<System.String> ShippingList = formatlengthStr(Shipping, 35);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+SH+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i];
if (i >= 4 && ShippingList.Count > 5)
{
if (i == 4)
{
if (ShippingList[i].Length > 34)
{
Shipping = Shipping + ":" + ShippingList[i].Substring(0, 34);
DescriptionShipper = ShippingList[i].Substring(34);
}
else
Shipping = Shipping + ":" + ShippingList[i];
if (bill.CARRIEREDICODE == "HLCU")
{
Shipping = Shipping + "-";
DescriptionShipper = "-" + DescriptionShipper;
}
else
{
Shipping = Shipping + "*";
DescriptionShipper = "*" + DescriptionShipper;
}
}
else if (i > 4)
{
DescriptionShipper = DescriptionShipper + " " + ShippingList[i];
}
}
else
if (i == 4) Shipping = Shipping + ":" + ShippingList[i];
}
}
r.WriteLine(Shipping + "'");
icount = icount + 1;
Shipping = formatEdiStr("txt", bill.CONSIGNEE);
ShippingList = formatlengthStr(Shipping, 35);
var DescriptionConsignee = "";
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+CN+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i];
if (i >= 4 && ShippingList.Count > 5)
{
if (i == 4)
{
if (ShippingList[i].Length > 33)
{
Shipping = Shipping + ":" + ShippingList[i].Substring(0, 33);
DescriptionConsignee = ShippingList[i].Substring(33);
}
else
Shipping = Shipping + ":" + ShippingList[i];
if (bill.CARRIEREDICODE == "HLCU")
{
Shipping = Shipping + "--";
DescriptionConsignee = "--" + DescriptionConsignee;
}
else
{
Shipping = Shipping + "**";
DescriptionConsignee = "**" + DescriptionConsignee;
}
}
else if (i > 4)
{
DescriptionConsignee = DescriptionConsignee + " " + ShippingList[i];
}
}
else
if (i == 4) Shipping = Shipping + ":" + ShippingList[i];
}
}
if (bill.BYCOUNTRY == "USA")
{
Shipping = Shipping + "+++" + bill.CONSIGNEEPOSTCODE;
r.WriteLine(Shipping + "'");
}
else if (bill.BYCOUNTRY == "CANADA")
{
Shipping = Shipping + "+++" + bill.CONSIGNEEPOSTCODE + "+CA";
r.WriteLine(Shipping + "'");
}
else if (bill.BYCOUNTRY == "BRAZIL")
{
Shipping = Shipping + "++++" + bill.CONSIGNEECOUNTRY;
r.WriteLine(Shipping + "'");
r.WriteLine("RFF+GN:" + bill.CONSIGNEETAXNO + "'");
icount = icount + 1;
}
else r.WriteLine(Shipping + "'");
icount = icount + 1;
if (bill.WEITUO != "")
{
if (bill.WEITUO.Length > 35)
r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO.Substring(0, 35)) + "+" + formatEdiStr("txt", bill.WEITUO.Substring(35)) + "'");
else
r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO) + "'");
}
else
{
if (InttrEdi.UseForWarderCode)
{
r.WriteLine("NAD+FW+" + InttrEdi.ForWarderCode + ":160:86++" + InttrEdi.ForWarderName + "'");
icount++;
}
else
{
if (InttrEdi.SENDNAME.Length > 35)
r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'");
else
r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'");
}
}
icount++;
Shipping = formatEdiStr("txt", bill.NOTIFYPARTY);
ShippingList = formatlengthStr(Shipping, 35);
var DescriptionNotifyparty = "";
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+N1+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i];
if (i >= 4 && ShippingList.Count > 5)
{
if (i == 4)
{
if (ShippingList[i].Length > 32)
{
Shipping = Shipping + ":" + ShippingList[i].Substring(0, 32);
DescriptionNotifyparty = ShippingList[i].Substring(32);
}
else
Shipping = Shipping + ":" + ShippingList[i];
if (bill.CARRIEREDICODE == "HLCU")
{
Shipping = Shipping + "---";
DescriptionNotifyparty = "---" + DescriptionNotifyparty;
}
else
{
Shipping = Shipping + "***";
DescriptionNotifyparty = "***" + DescriptionNotifyparty;
}
}
else if (i > 4)
{
DescriptionNotifyparty = DescriptionNotifyparty + " " + ShippingList[i];
}
}
else
if (i == 4) Shipping = Shipping + ":" + ShippingList[i];
}
}
if (bill.BYCOUNTRY == "USA")
{
Shipping = Shipping + "+++" + bill.NOTIFYPARTYPOSTCODE;
r.WriteLine(Shipping + "'");
}
else if (bill.BYCOUNTRY == "BRAZIL")
{
if (bill.NOTIFYPARTYCOUNTRY != "")
Shipping = Shipping + "++++" + bill.NOTIFYPARTYCOUNTRY;
r.WriteLine(Shipping + "'");
if (bill.NOTIFYPARTYTAXNO != "")
{
r.WriteLine("RFF+GN:" + bill.NOTIFYPARTYTAXNO + "'");
icount = icount + 1;
}
}
else r.WriteLine(Shipping + "'");
icount = icount + 1;
Shipping = formatEdiStr("txt", bill.NOTIFYPARTY2);
ShippingList = formatlengthStr(Shipping, 35);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+N2+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i];
if (i == 4) Shipping = Shipping + ":" + ShippingList[i];
}
r.WriteLine(Shipping + "'");
}
if (bill.CARRIEREDICODE == "CMA2" || bill.CARRIEREDICODE == "ANL2" || bill.CARRIEREDICODE == "CNC2")
{
var tmpcarrier = "CMDU";
if (bill.CARRIEREDICODE == "ANL2") tmpcarrier = "ANNU";
if (bill.CARRIEREDICODE == "CNC2") tmpcarrier = "CHNL";
r.WriteLine("NAD+CA+" + tmpcarrier + "'");
}
else r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'");
if (InttrEdi.SENDNAME.Length > 35)
r.WriteLine("NAD+SI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'");
else
r.WriteLine("NAD+SI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'");
r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'");
r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'");
r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'");
icount = icount + 5;
var copynum = GetBillNum(bill.COPYNOBILL);
if (bill.ISSUETYPE == "正本")
{
r.WriteLine("DOC+705+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
if (copynum != "")
{
r.WriteLine("DOC+707+++" + copynum + "'");
icount = icount + 1;
}
}
else if (bill.ISSUETYPE == "海运单" || bill.ISSUETYPE.ToUpper() == "SEAWAY" || bill.ISSUETYPE.ToUpper() == "SEAWAY BILL" || bill.ISSUETYPE.ToUpper() == "WAYBILL" || bill.ISSUETYPE.ToUpper() == "SWB正本" || bill.ISSUETYPE.ToUpper() == "SWB无正本")
{
r.WriteLine("DOC+710+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
}
else if (bill.ISSUETYPE.ToUpper() == "BILL COPY" || bill.ISSUETYPE == "电放")
{
r.WriteLine("DOC+705+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
if (copynum != "")
{
r.WriteLine("DOC+707+++" + copynum + "'");
icount = icount + 1;
}
}
else if (bill.ISSUETYPE == "正副本")
{
r.WriteLine("DOC+705+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
if (copynum != "")
{
r.WriteLine("DOC+707+++" + copynum + "'");
icount = icount + 1;
}
}
else if (bill.ISSUETYPE.ToUpper() == "HOUSE BILL")
{
r.WriteLine("DOC+714+++" + GetBillNum(bill.NOBILL) + "'");
icount = icount + 1;
}
//判断集装箱是否包含分箱明细
if (bill.CTNGOODSLIST == null || bill.CTNGOODSLIST.Count == 0)
{
#region 取委托单货描、唛头信息
r.WriteLine("GID+1+" + bill.PKGS.ToString() + ":" + bill.KINDPKGS_EDI_CODE + "::6:" + bill.KINDPKGS + "'");
icount = icount + 1;
if (bill.HSCODE != "")
{
r.WriteLine("PIA+5+" + bill.HSCODE + ":HS'");
icount = icount + 1;
}
Shipping = formatEdiStr("txt", bill.DESCRIPTION);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] DescriptionList = Shipping.Split('\\');
if (DescriptionList.Length != 0)
{
for (var i = 0; i < DescriptionList.Length; i++)
{
//if (DescriptionList[i] != "")
//{
r.WriteLine("FTX+AAA+++" + DescriptionList[i] + "'");
icount = icount + 1;
//}
}
}
if (DescriptionShipper != "")
{
r.WriteLine("FTX+AAA+++" + DescriptionShipper + "'");
icount = icount + 1;
}
if (DescriptionConsignee != "")
{
r.WriteLine("FTX+AAA+++" + DescriptionConsignee + "'");
icount = icount + 1;
}
if (DescriptionNotifyparty != "")
{
r.WriteLine("FTX+AAA+++" + DescriptionNotifyparty + "'");
icount = icount + 1;
}
r.WriteLine("MEA+WT+G+KGM:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + "'");
r.WriteLine("MEA+VOL+AAW+CBM:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + "'");
icount = icount + 2;
if (!string.IsNullOrEmpty(bill.GOODSNCM))
{
r.WriteLine("RFF+ABT:" + bill.GOODSNCM + "'");
icount = icount + 1;
}
Shipping = formatEdiStr("txt", bill.MARKS);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] MarksList = Shipping.Split('\\');
if (MarksList.Length != 0)
{
for (var i = 0; i < MarksList.Length; i++)
{
//if (MarksList[i] != "")
//{
r.WriteLine("PCI++" + MarksList[i] + "'");
icount = icount + 1;
//}
}
}
foreach (var ctn in bill.CTNLIST)
{
r.WriteLine("SGP+" + ctn.CNTRNO + "+" + ctn.PKGS.ToString() + "'");
r.WriteLine("MEA+WT+G+KGM:" + Math.Round(Convert.ToDecimal(ctn.KGS), 3) + "'");
r.WriteLine("MEA+VOL+AAW+CBM:" + Math.Round(Convert.ToDecimal(ctn.CBM), 3) + "'");
icount = icount + 3;
}
#endregion
}
else
{
if (bill.CARRIEREDICODE == "UASC" || bill.CARRIEREDICODE == "HLCU" || bill.CARRIEREDICODE == "CMDU")
{
#region 取集装箱分箱_货描、唛头信息
if (bill.CTNGOODSLIST != null)
{
if (bill.CTNGOODSLIST.Count > 0)
{
var i = 0;
foreach (var ctngood in bill.CTNGOODSLIST)
{
//GID+1+400:CT::6:CARTONS'
r.WriteLine("GID+" + (i + 1) + "+" + ctngood.PKGS.ToString() + ":" + ctngood.KINDPKGS_EDI_CODE + "::6:" + ctngood.KINDPKGS + "'");
icount++;
//PIA+5+HS_CODE1:HS'
r.WriteLine("PIA+5+" + ctngood.HSCODE + ":HS'");
icount++;
//FTX+AAA+++MATERIAL 1'
//FTX+AAA+++HS-NO 39023012'
Shipping = formatEdiStr("txt", ctngood.DESCRIPTION);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] DescriptionList = Shipping.Split('\\');
if (DescriptionList.Length != 0)
{
for (var j = 0; j < DescriptionList.Length; j++)
{
r.WriteLine("FTX+AAA+++" + DescriptionList[j] + "'");
icount++;
}
}
//MEA+AAE+WT+KGM:3000'
//MEA+AAE+AAW+MTQ:110.11'
r.WriteLine("MEA+WT+G+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'");
icount++;
r.WriteLine("MEA+VOL+AAW+CBM:" + Math.Round(Convert.ToDecimal(ctngood.CBM), 3) + "'");
icount++;
//PCI++MARKS AND NUMBERS:FOR MATERIAL 1: OUR PONUMBER: PO_123456'
//if (isbill != 1)
//{
// Shipping = formatEdiStr("txt", bill.MARKS);
//}
//else
//{
Shipping = formatEdiStr("txt", ctngood.MARKS);
//}
if (string.IsNullOrEmpty(ctngood.MARKS)) Shipping = formatEdiStr("txt", bill.MARKS);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] MarksList = Shipping.Split('\\');
if (MarksList.Length != 0)
{
for (var j = 0; j < MarksList.Length; j++)
{
r.WriteLine("PCI++" + MarksList[j] + "'");
icount++;
}
}
if (!string.IsNullOrEmpty(bill.GOODSNCM))
{
r.WriteLine("RFF+ABT:" + bill.GOODSNCM + "'");
icount++;
}
//
//SGP+MSCU1234567+100'
r.WriteLine("SGP+" + ctngood.CNTRNO + "+" + ctngood.PKGS.ToString() + "'");
//MEA+AAE+WT+KGM:1000'
r.WriteLine("MEA+WT+G+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'");
//MEA+AAE+AAW+MTQ:50.11'
r.WriteLine("MEA+VOL+AAW+CBM:" + Math.Round(Convert.ToDecimal(ctngood.CBM), 3) + "'");
icount = icount + 3;
i = i + 1;
}
}
}
#endregion
}
else
{
#region 取集装箱分箱_货描、唛头信息
var ctngoodssumlist = new List<MsOpSeaeCtnDetailEdiModel>();
foreach (var ctn in bill.CTNGOODSLIST)
{
var isfind = false;
ctngoodssumlist.ForEach(i =>
{
if (i.HSCODE == ctn.HSCODE && i.KINDPKGS == ctn.KINDPKGS && i.DESCRIPTION == ctn.DESCRIPTION && i.MARKS == ctn.MARKS)
{
i.PKGS = i.PKGS + ctn.PKGS;
i.KGS = i.KGS + ctn.KGS;
i.CBM = i.CBM + ctn.CBM;
isfind = true;
}
});
if (!isfind)
{
var ctnnum = new MsOpSeaeCtnDetailEdiModel();
ctnnum.HSCODE = ctn.HSCODE;
ctnnum.KINDPKGS = ctn.KINDPKGS;
ctnnum.KINDPKGS_EDI_CODE = ctn.KINDPKGS_EDI_CODE;
ctnnum.DESCRIPTION = ctn.DESCRIPTION;
ctnnum.MARKS = ctn.MARKS;
ctnnum.PKGS = ctn.PKGS;
ctnnum.KGS = ctn.KGS;
ctnnum.CBM = ctn.CBM;
ctngoodssumlist.Add(ctnnum);
}
}
if (ctngoodssumlist != null)
{
if (ctngoodssumlist.Count > 0)
{
var goodct = 0;
foreach (var ctngoodsum in ctngoodssumlist)
{
//GID+1+400:CT::6:CARTONS'
r.WriteLine("GID+" + (goodct + 1) + "+" + ctngoodsum.PKGS.ToString() + ":" + ctngoodsum.KINDPKGS_EDI_CODE + "::6:" + ctngoodsum.KINDPKGS + "'");
icount++;
//PIA+5+HS_CODE1:HS'
r.WriteLine("PIA+5+" + ctngoodsum.HSCODE + ":HS'");
icount++;
//FTX+AAA+++MATERIAL 1'
//FTX+AAA+++HS-NO 39023012'
Shipping = formatEdiStr("txt", ctngoodsum.DESCRIPTION);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] DescriptionList = Shipping.Split('\\');
if (DescriptionList.Length != 0)
{
for (var j = 0; j < DescriptionList.Length; j++)
{
r.WriteLine("FTX+AAA+++" + DescriptionList[j] + "'");
icount++;
}
}
//MEA+AAE+WT+KGM:3000'
//MEA+AAE+AAW+MTQ:110.11'
r.WriteLine("MEA+WT+G+KGM:" + Math.Round(Convert.ToDecimal(ctngoodsum.KGS), 3) + "'");
icount++;
r.WriteLine("MEA+VOL+AAW+CBM:" + Math.Round(Convert.ToDecimal(ctngoodsum.CBM), 3) + "'");
icount++;
//PCI++MARKS AND NUMBERS:FOR MATERIAL 1: OUR PONUMBER: PO_123456'
//if (isbill != 1)
//{
// Shipping = formatEdiStr("txt", bill.MARKS);
//}
//else
//{
Shipping = formatEdiStr("txt", ctngoodsum.MARKS);
//}
if (ctngoodsum.MARKS == "") Shipping = formatEdiStr("txt", bill.MARKS);
Shipping = Shipping.Replace("\n", "\\");
Shipping = Shipping.Replace("\r", " ");
string[] MarksList = Shipping.Split('\\');
if (MarksList.Length != 0)
{
for (var j = 0; j < MarksList.Length; j++)
{
r.WriteLine("PCI++" + MarksList[j] + "'");
icount++;
}
}
if (!string.IsNullOrEmpty(bill.GOODSNCM))
{
r.WriteLine("RFF+ABT:" + bill.GOODSNCM + "'");
icount++;
}
goodct = goodct + 1;
bill.CTNGOODSLIST.ForEach(i =>
{
if (i.HSCODE == ctngoodsum.HSCODE && i.KINDPKGS == ctngoodsum.KINDPKGS && i.DESCRIPTION == ctngoodsum.DESCRIPTION && i.MARKS == ctngoodsum.MARKS)
{
//SGP+MSCU1234567+100'
r.WriteLine("SGP+" + i.CNTRNO + "+" + i.PKGS.ToString() + "'");
//MEA+AAE+WT+KGM:1000'
r.WriteLine("MEA+WT+G+KGM:" + Math.Round(Convert.ToDecimal(i.KGS), 3) + "'");
//MEA+AAE+AAW+MTQ:50.11'
r.WriteLine("MEA+VOL+AAW+CBM:" + Math.Round(Convert.ToDecimal(i.CBM), 3) + "'");
icount = icount + 3;
}
});
}
}
}
#endregion
}
}
if (bill.CARGOID == "D")
{
r.WriteLine("DGS+IMD+" + bill.DCLASS + "+" + bill.DUNNO + "'");
r.WriteLine("CTA+HG+:" + bill.EDIATTN + "'");
r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'");
icount = icount + 3;
}
#region 集装箱 主箱循环
foreach (var ctn in bill.CTNLIST)
{
if (bill.ISCONTAINERSOC)
r.WriteLine("EQD+CN+" + ctn.CNTRNO + "+" + ctn.CTNALLCODE + "+1'");
else
r.WriteLine("EQD+CN+" + ctn.CNTRNO + "+" + ctn.CTNALLCODE + "+2'");
r.WriteLine("MEA+WT+G+KGM:" + Math.Round(Convert.ToDecimal(ctn.KGS), 3) + "'");
r.WriteLine("MEA+VOL+AAW+CBM:" + Math.Round(Convert.ToDecimal(ctn.CBM), 3) + "'");
icount = icount + 3;
if (bill.CARGOID == "R")
{
if (bill.REEFERF != "")
{
r.WriteLine("MEA+AAE+AAS+CBM:" + bill.REEFERF + "'");
icount = icount + 1;
}
}
r.WriteLine("SEL+" + ctn.SEALNO + "+CA'");
icount = icount + 1;
if (bill.CARGOID == "R")
{
r.WriteLine("TMP+2+" + bill.TEMPSET + ":CEL'");
icount = icount + 1;
}
}
#endregion
}
r.WriteLine("UNT+" + icount.ToString() + "+" + bsno + "'");
r.WriteLine("UNZ+" + InttrEdi.BSLIST.Count.ToString() + "+" + bsno + "'");
r.Close();
f.Close();
return filename;
}
#endregion
#region VGM
public static string CreateEdiCMAVGM(MsCargoSmartEdiModel InttrEdi)
{
string filename = InttrEdi.filerpath + "\\VERMAS_" + InttrEdi.BSLIST[0].MBLNO + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
FileStream f = new FileStream(filename, FileMode.Create);
StreamWriter r = new StreamWriter(f, Encoding.Default);
var icount = 0;
var bsno = "";
foreach (var bill in InttrEdi.BSLIST)
{
bsno = bill.ORDERNO;
r.WriteLine("UNB+UNOA:2+" + InttrEdi.SENDCODE + ":ZZ+" + InttrEdi.RECEIVECODE + ":01+" + DateTime.Now.ToString("yyMMdd:HHmm") + "+" + bill.ORDERNO + "'");
r.WriteLine("UNH+" + bill.ORDERNO+ "+VERMAS:D:16A:UN'");
icount = icount + 2;
//9->首次发送 4->更改发送 1->取消
r.WriteLine("BGM+XXX+" + bill.MBLNO + "+" + InttrEdi.filerole + "'");
icount++;
r.WriteLine("DTM+137:" + DateTime.Now.ToString("yyyyMMddHHmm") + ":203'");
icount = icount + 2;
var Shipping = "";
var DescriptionShipper = "";
Shipping = formatEdiStr("txt", bill.SHIPPER);
List<System.String> ShippingList = formatlengthStr(Shipping, 35);
if (ShippingList.Count != 0 && Shipping.Length > 0)
{
for (var i = 0; i < ShippingList.Count; i++)
{
if (i == 0) Shipping = "NAD+CZ+++" + ShippingList[0] + "+";
if (i == 1) Shipping = Shipping + ShippingList[i];
if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i];
if (i >= 4 && ShippingList.Count > 5)
{
if (i == 4)
{
if (ShippingList[i].Length > 34)
{
Shipping = Shipping + ":" + ShippingList[i].Substring(0, 34);
DescriptionShipper = ShippingList[i].Substring(34);
}
else
Shipping = Shipping + ":" + ShippingList[i];
Shipping = Shipping + "*";
DescriptionShipper = "*" + DescriptionShipper;
}
else if (i > 4)
{
DescriptionShipper = DescriptionShipper + " " + ShippingList[i];
}
}
else
if (i == 4) Shipping = Shipping + ":" + ShippingList[i];
}
}
r.WriteLine(Shipping + "'");
icount = icount + 1;
r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'");
icount = icount + 1;
r.WriteLine("NAD+TB+" + bill.EDIATTN + "'");
icount++;
foreach (var ctn in bill.CTNLIST)
{
r.WriteLine("EQD+CN+" + ctn.CNTRNO + "'");
icount = icount + 1;
r.WriteLine("RFF+BM:" + bill.MBLNO + "'");
icount = icount + 1;
r.WriteLine("RFF+BN:" + bill.MBLNO + "'");
icount = icount + 1;
r.WriteLine("MEA+AAE+VGM+KGM:" + ctn.WEIGHKGS + "'");
icount = icount + 1;
var SM = "SM1";
if (ctn.WEIGHTYPE == "累加") SM = "SM2";
if (ctn.WEIGHTYPE == "总重") SM = "SM1";
r.WriteLine("DOC+"+SM+":VGM:306+'");
icount = icount + 1;
r.WriteLine("NAD+SPC+++" + InttrEdi.SENDNAME + "'");
icount = icount + 1;
r.WriteLine("NAD+WPA+++" + InttrEdi.SENDNAME + "'");
icount = icount + 1;
if (ctn.VGMCONNCOM != "")
{
r.WriteLine("NAD+WPA+++" + ctn.VGMCONNCOM + "+++++CN'");
icount++;
}
r.WriteLine("CTA+RP+:" + ctn.WEIGHSIGN + "'");
icount = icount + 1;
r.WriteLine("NAD+AM+++" + InttrEdi.SENDNAME + "'");
icount++;
r.WriteLine("CTA+RP+:" + ctn.WEIGHSIGN + "'");
icount++;
r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'");
icount++;
}
}
r.WriteLine("UNT+" + icount.ToString() + "+001'");
r.WriteLine("UNZ+" + InttrEdi.BSLIST.Count.ToString() + "+" + bsno + "'");
r.Close();
f.Close();
return filename;
}
#endregion
}
public class MsCargoSmartEdiModel
{
/// <summary>
/// 发送方代码 M
/// </summary>
public string SENDCODE { get; set; }
/// <summary>
/// 发送方名称 M
/// </summary>
public string SENDNAME { get; set; }
/// <summary>
/// 接收方代码 M
/// </summary>
public string RECEIVECODE { get; set; }
/// <summary>
/// 文件类型 (B订舱,E SI确认)M
/// </summary>
public string filetype { get; set; }
/// <summary>
/// 文件功能 (9原始,1 更新,5 退舱 )M
/// </summary>
public string filerole { get; set; }
/// <summary>
/// 文件路径 M
/// </summary>
public string filerpath { get; set; }
/// <summary>
/// 是否使用货代代码。 M
/// </summary>
public bool UseForWarderCode { get; set; }
/// <summary>
/// 货代代码。 O
/// </summary>
public string ForWarderCode { get; set; }
/// <summary>
/// 货代名称 O
/// </summary>
public string ForWarderName { get; set; }
/// <summary>
/// 业务信息列表 M
/// </summary>
public List<MsOpSeaeEdiModel> BSLIST { get; set; }
}
public class MsOpSeaeEdiModel
{
/// <summary>
/// 委托方
/// </summary>
public string WEITUO { get; set; }
/// <summary>
/// 操作英文名称 M
/// </summary>
public string OpEName { get; set; }
/// <summary>
/// 操作电话 M
/// </summary>
public string OpTel { get; set; }
/// <summary>
/// 操作邮箱 M
/// </summary>
public string OpEmail { get; set; }
/// <summary>
/// EDI联系人名称 O
/// </summary>
public string EDIATTN { get; set; }
/// <summary>
/// EDI联系人电话 O
/// </summary>
public string EDIATTNTEL { get; set; }
/// <summary>
/// EDI联系人邮箱 O
/// </summary>
public string EDIATTNEMAIL { get; set; }
/// <summary>
/// 订舱编号 O
/// </summary>
public string ORDERNO { get; set; }
/// <summary>
/// 主提单号 M
/// </summary>
public string MBLNO { get; set; }
/// <summary>
/// 付费方式 M
/// </summary>
public string BLFRT { get; set; }
/// <summary>
/// 船名 O
/// </summary>
public string VESSEL { get; set; }
/// <summary>
/// 航次 O
/// </summary>
public string VOYNO { get; set; }
/// <summary>
/// 内部航次 O
/// </summary>
public string NVOYNO { get; set; }
/// <summary>
/// 开船日期 M
/// </summary>
public string ETD { get; set; }
/// <summary>
/// EDI备注
/// </summary>
public string EDIREMARK { get; set; }
/// <summary>
/// SI备注
/// </summary>
public string SIREMARK { get; set; }
/// <summary>
/// 船公司名称 M
/// </summary>
public string CARRIER { get; set; }
/// <summary>
/// 船公司EDI代码 M
/// </summary>
public string CARRIEREDICODE { get; set; }
/// <summary>
/// 发货人 M
/// </summary>
public string SHIPPER { get; set; }
/// <summary>
/// 收货人 M
/// </summary>
public string CONSIGNEE { get; set; }
/// <summary>
/// 通知人 M
/// </summary>
public string NOTIFYPARTY { get; set; }
/// <summary>
/// 第二通知人
/// </summary>
public string NOTIFYPARTY2 { get; set; }
/// <summary>
/// 收货地所在国家 O
/// </summary>
public string BYCOUNTRY { get; set; }
///// <summary>
///// AMS发货人 O
///// </summary>
//public string AMSSHIPPER { get; set; }
///// <summary>
///// AMS收货人 O
///// </summary>
//public string AMSCONSIGNEE { get; set; }
///// <summary>
///// AMS通知人 O
///// </summary>
//public string AMSNOTIFYPARTY { get; set; }
/// <summary>
/// HS编码
/// </summary>
public string HSCODE { get; set; }
/// <summary>
/// 唛头 M
/// </summary>
public string MARKS { get; set; }
/// <summary>
/// 货物描述 M
/// </summary>
public string DESCRIPTION { get; set; }
/// <summary>
/// 起运港代码(每船公司可能不同) M
/// </summary>
public string PORTLOADID { get; set; }
/// <summary>
/// 起运港 M
/// </summary>
public string PORTLOAD { get; set; }
/// <summary>
///卸货港代码(每船公司可能不同) M
/// </summary>
public string PORTDISCHARGEID { get; set; }
/// <summary>
/// 卸货港 M
/// </summary>
public string PORTDISCHARGE { get; set; }
/// <summary>
///目的地代码(每船公司可能不同)
/// </summary>
public string DESTINATIONID { get; set; }
/// <summary>
/// 目的地
/// </summary>
public string DESTINATION { get; set; }
/// <summary>
/// 件数 M
/// </summary>
public Int32 PKGS { get; set; }
/// <summary>
/// 包装 M
/// </summary>
public string KINDPKGS { get; set; }
/// <summary>
/// 包装代码 M
/// </summary>
public string KINDPKGS_EDI_CODE { get; set; }
/// <summary>
/// 重量 M
/// </summary>
public decimal KGS { get; set; }
/// <summary>
/// 体积 M
/// </summary>
public decimal CBM { get; set; }
/// <summary>
/// 货物标识 M
/// </summary>
public string CARGOID { get; set; }
/// <summary>
/// 危险品类别 O
/// </summary>
public string DCLASS { get; set; }
/// <summary>
/// 危险品编号 O
/// </summary>
public string DUNNO { get; set; }
/// <summary>
/// 设置温度 O
/// </summary>
public string TEMPSET { get; set; }
/// <summary>
/// 通风度 O
/// </summary>
public string REEFERF { get; set; }
/// <summary>
/// 湿度
/// </summary>
public string HUMIDITY { get; set; }
/// <summary>
/// 预付地点 O
/// </summary>
public string PREPARDAT { get; set; }
/// <summary>
/// 到付地点 O
/// </summary>
public string PAYABLEAT { get; set; }
/// <summary>
/// 预付地点EDI代码 O
/// </summary>
public string PREPARDATID { get; set; }
/// <summary>
/// 到付地点EDI代码 O
/// </summary>
public string PAYABLEATID { get; set; }
/// <summary>
/// 签单方式 M(SI)
/// </summary>
public string ISSUETYPE { get; set; }
/// <summary>
/// 签单时间 O(SI/SO)
/// </summary>
public string ISSUEDATE { get; set; }
/// <summary>
/// 提单份数 M(SI)
/// </summary>
public string NOBILL { get; set; }
/// <summary>
/// 签单地点 M(SI)
/// </summary>
public string ISSUEPLACE { get; set; }
/// <summary>
/// 提单副本份数 M(SI)
/// </summary>
public string COPYNOBILL { get; set; }
/// <summary>
/// 签单地点EDI代码 M(SI)
/// </summary>
public string ISSUEPLACEID { get; set; }
/// <summary>
/// 运输条款 M
/// </summary>
public string SERVICE { get; set; }
/// <summary>
/// 运费协议号 M
/// </summary>
public string CONTRACTNO { get; set; }
/// <summary>
/// 收货人邮编 O
/// </summary>
public string CONSIGNEEPOSTCODE { get; set; }
/// <summary>
/// 收货人国家 O
/// </summary>
public string CONSIGNEECOUNTRY { get; set; }
/// <summary>
/// 收货人税号 O
/// </summary>
public string CONSIGNEETAXNO { get; set; }
/// <summary>
/// 通知人邮编 O
/// </summary>
public string NOTIFYPARTYPOSTCODE { get; set; }
/// <summary>
/// 通知人国家 O
/// </summary>
public string NOTIFYPARTYCOUNTRY { get; set; }
/// <summary>
/// 通知人税号 O
/// </summary>
public string NOTIFYPARTYTAXNO { get; set; }
/// <summary>
/// 货物NCM编号 O
/// </summary>
public string GOODSNCM { get; set; }
/// <summary>
/// 收货人DOOR地址 O
/// </summary>
public string CONSIGNEEDOORADDR { get; set; }
/// <summary>
/// 发货人DOOR地址 O
/// </summary>
public string SHIPPERDOORADDR { get; set; }
/// <summary>
/// SCAC代码 O
/// </summary>
public string SCACCODE { get; set; }
/// <summary>
/// ITN编号 O
/// </summary>
public string ITNCODE { get; set; }
/// <summary>
/// 付费方 O
/// </summary>
public string FREIGHTPAYER { get; set; }
/// <summary>
/// 是否SOC箱 O
/// </summary>
public bool ISCONTAINERSOC { get; set; }
/// <summary>
/// 拆并单列表 O
/// </summary>
public string BSNOLIST { get; set; }
/// <summary>
/// 集装箱明细 M
/// </summary>
public List<MsOpSeaeCtnEdiModel> CTNLIST { get; set; }
/// <summary>
/// 集装箱多品名明细 M
/// </summary>
public List<MsOpSeaeCtnDetailEdiModel> CTNGOODSLIST { get; set; }
}
public class MsOpSeaeCtnEdiModel
{
/// <summary>
/// 箱型EDI代码 M
/// </summary>
public string CTNALLCODE { get; set; }
public Int32 CTNNUM { get; set; }
/// <summary>
/// 箱号 M
/// </summary>
public string CNTRNO { get; set; }
/// <summary>
/// 封号 M
/// </summary>
public string SEALNO { get; set; }
/// <summary>
/// 件数 M
/// </summary>
public Int32 PKGS { get; set; }
/// <summary>
/// 包装 M
/// </summary>
public string KINDPKGS { get; set; }
/// <summary>
/// 包装代码 M
/// </summary>
public string KINDPKGS_EDI_CODE { get; set; }
/// <summary>
/// 重量 M
/// </summary>
public decimal KGS { get; set; }
/// <summary>
/// 体积 M
/// </summary>
public decimal CBM { get; set; }
/// <summary>
/// 箱皮重
/// </summary>
public string TAREWEIGHT { get; set; }
/// <summary>
/// 称重重量
/// </summary>
public string WEIGHKGS { get; set; }
/// <summary>
/// 称重方式 (累加、总重)
/// </summary>
public string WEIGHTYPE { get; set; }
/// <summary>
/// 称重签名
/// </summary>
public string WEIGHSIGN { get; set; }
/// <summary>
/// 称重公司
/// </summary>
public string VGMCONNCOM { get; set; }
}
public class MsOpSeaeCtnDetailEdiModel
{
/// <summary>
/// 箱号 M
/// </summary>
public string CNTRNO { get; set; }
/// <summary>
/// HS编码 M
/// </summary>
public string HSCODE { get; set; }
/// <summary>
/// 唛头 M
/// </summary>
public string MARKS { get; set; }
/// <summary>
/// 货物描述 M
/// </summary>
public string DESCRIPTION { get; set; }
/// <summary>
/// 件数 M
/// </summary>
public Int32 PKGS { get; set; }
/// <summary>
/// 包装 M
/// </summary>
public string KINDPKGS { get; set; }
/// <summary>
/// 包装代码 M
/// </summary>
public string KINDPKGS_EDI_CODE { get; set; }
/// <summary>
/// 重量 M
/// </summary>
public decimal KGS { get; set; }
/// <summary>
/// 体积 M
/// </summary>
public decimal CBM { get; set; }
}
}