From 5bb65e3489e6a9c39b535fbba889c85897925c7a Mon Sep 17 00:00:00 2001
From: wet <1034391973@qq.com>
Date: Mon, 14 Nov 2022 17:47:39 +0800
Subject: [PATCH 1/8] =?UTF-8?q?=E7=A7=9F=E6=88=B7=E5=8F=82=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/BookingStatusLog.cs | 2 +-
.../Myshipping.Application.xml | 4 +-
.../BookingOrder/BookingOrderService.cs | 2 +-
.../BookingOrder/Dto/BookingStatusLogDto.cs | 2 +-
Myshipping.Core/Enum/ErrorCode.cs | 55 +++++++
Myshipping.Core/Myshipping.Core.xml | 42 ++++-
.../DjyTenantParam/DjyTenantParamService.cs | 147 ++++++++++++++++--
.../Service/Tenant/SysTenantService.cs | 2 +-
.../Myshipping.Report.csproj.user | 2 +-
9 files changed, 238 insertions(+), 20 deletions(-)
diff --git a/Myshipping.Application/Entity/BookingStatusLog.cs b/Myshipping.Application/Entity/BookingStatusLog.cs
index 70c19dc3..f5d9d118 100644
--- a/Myshipping.Application/Entity/BookingStatusLog.cs
+++ b/Myshipping.Application/Entity/BookingStatusLog.cs
@@ -22,7 +22,7 @@ namespace Myshipping.Application.Entity
///
/// 状态时间
///
- public DateTime? OpTiem { get; set; }
+ public DateTime? OpTime { get; set; }
///
/// 类别
///
diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml
index 0e8e426f..2237f3ff 100644
--- a/Myshipping.Application/Myshipping.Application.xml
+++ b/Myshipping.Application/Myshipping.Application.xml
@@ -2426,7 +2426,7 @@
状态
-
+
状态时间
@@ -3519,7 +3519,7 @@
状态
-
+
状态时间
diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
index 34793395..1ff993d1 100644
--- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
+++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
@@ -609,7 +609,7 @@ namespace Myshipping.Application
bookingStatusLog.Gategory = "ship";
bookingStatusLog.CreatedTime = DateTime.Now;
bookingStatusLog.Status = item.Status;
- bookingStatusLog.OpTiem = item.OPTime;
+ bookingStatusLog.OpTime = item.OpTime;
bookingStatusLog.MBLNO = item.MBLNO;
var id = await _statuslog.InsertReturnSnowflakeIdAsync(bookingStatusLog);
if (item.detail != null && item.detail.Count > 0)
diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingStatusLogDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingStatusLogDto.cs
index 4204002e..4fb88455 100644
--- a/Myshipping.Application/Service/BookingOrder/Dto/BookingStatusLogDto.cs
+++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingStatusLogDto.cs
@@ -22,7 +22,7 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
///
/// 状态时间
///
- public DateTime? OPTime { get; set; }
+ public DateTime? OpTime { get; set; }
///
/// 类别
///
diff --git a/Myshipping.Core/Enum/ErrorCode.cs b/Myshipping.Core/Enum/ErrorCode.cs
index c22e553c..8f93df63 100644
--- a/Myshipping.Core/Enum/ErrorCode.cs
+++ b/Myshipping.Core/Enum/ErrorCode.cs
@@ -415,4 +415,59 @@ public enum ErrorCode
EMAIL001,
#endregion
+
+
+
+
+ #region 租户参数
+
+ ///
+ /// 主键不能为空
+ ///
+ [ErrorCodeItemMetadata("主键不能为空")]
+ Param000,
+
+ ///
+ /// 类别代码不能为空
+ ///
+ [ErrorCodeItemMetadata("类别代码不能为空")]
+ Param001,
+ ///
+ /// 类别名称不能为空
+ ///
+ [ErrorCodeItemMetadata("类别名称不能为空")]
+ Param002,
+
+ ///
+ /// 业务大类不能为空
+ ///
+ [ErrorCodeItemMetadata("业务大类不能为空")]
+ Param003,
+
+ ///
+ /// 存在相同数据
+ ///
+ [ErrorCodeItemMetadata("存在相同数据")]
+ Param004,
+
+ ///
+ /// 租户参数代码不能为空
+ ///
+ [ErrorCodeItemMetadata("租户参数代码不能为空")]
+ Param005,
+
+
+ ///
+ /// 租户参数名称不能为空
+ ///
+ [ErrorCodeItemMetadata("租户参数名称不能为空")]
+ Param006,
+
+ ///
+ /// 租户ID不能为空
+ ///
+ [ErrorCodeItemMetadata("租户ID不能为空")]
+ Param007,
+
+ #endregion
}
diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml
index 673c5660..1071a9aa 100644
--- a/Myshipping.Core/Myshipping.Core.xml
+++ b/Myshipping.Core/Myshipping.Core.xml
@@ -4035,6 +4035,46 @@
邮箱账号已存在
+
+
+ 主键不能为空
+
+
+
+
+ 类别代码不能为空
+
+
+
+
+ 类别名称不能为空
+
+
+
+
+ 业务大类不能为空
+
+
+
+
+ 存在相同数据
+
+
+
+
+ 租户参数代码不能为空
+
+
+
+
+ 租户参数名称不能为空
+
+
+
+
+ 租户ID不能为空
+
+
文件扩展枚举
@@ -9240,7 +9280,7 @@
-
+
获取参数
diff --git a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
index 95a4f459..5cc2755c 100644
--- a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
+++ b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
@@ -10,6 +10,7 @@ using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using Myshipping.Core.Entity;
using System;
+using Furion.FriendlyException;
namespace Myshipping.Core.Service
{
@@ -33,7 +34,7 @@ namespace Myshipping.Core.Service
_cache = cache;
}
-
+ #region 类别
///
/// 增加租户参数类别表
///
@@ -41,6 +42,21 @@ namespace Myshipping.Core.Service
[HttpPost("/DJYTenantParam/add")]
public async Task Add(AddDJYTenantParamInput input)
{
+ if (string.IsNullOrWhiteSpace(input.ParaCode)) {
+ throw Oops.Oh(ErrorCode.Param001);
+ }
+ if (string.IsNullOrWhiteSpace(input.ParaName)) {
+ throw Oops.Oh(ErrorCode.Param002);
+ }
+ if (string.IsNullOrWhiteSpace(input.Type))
+ {
+ throw Oops.Oh(ErrorCode.Param002);
+ }
+
+ var list=await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type);
+ if (list!=null) {
+ throw Oops.Oh(ErrorCode.Param004);
+ }
var entity = input.Adapt();
await _rep.InsertAsync(entity);
}
@@ -52,6 +68,27 @@ namespace Myshipping.Core.Service
[HttpPost("/DJYTenantParam/edit")]
public async Task Update(UpdateDJYTenantParamInput input)
{
+ if ( input.Id==0)
+ {
+ throw Oops.Oh(ErrorCode.Param000);
+ }
+ if (string.IsNullOrWhiteSpace(input.ParaCode))
+ {
+ throw Oops.Oh(ErrorCode.Param001);
+ }
+ if (string.IsNullOrWhiteSpace(input.ParaName))
+ {
+ throw Oops.Oh(ErrorCode.Param002);
+ }
+ if (string.IsNullOrWhiteSpace(input.Type))
+ {
+ throw Oops.Oh(ErrorCode.Param002);
+ }
+ var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type&&x.Id!=input.Id);
+ if (list != null)
+ {
+ throw Oops.Oh(ErrorCode.Param004);
+ }
var entity = input.Adapt();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
@@ -64,12 +101,17 @@ namespace Myshipping.Core.Service
[SqlSugarUnitOfWork]
public async Task Delete(long Id)
{
+ if (Id == 0)
+ {
+ throw Oops.Oh(ErrorCode.Param000);
+ }
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == Id);
await _itemrep.DeleteAsync(m => m.ParaCode == entity.ParaCode);
await _valuerep.DeleteAsync(m => m.ParaCode == entity.ParaCode);
await _rep.DeleteAsync(entity);
}
+
///
/// 获取租户参数类别
///
@@ -79,6 +121,9 @@ namespace Myshipping.Core.Service
{
return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type),x => x.Type == Type).OrderBy(x => x.Sort).ToListAsync();
}
+ #endregion
+
+ #region 参数
///
/// 获取租户参数
@@ -100,6 +145,23 @@ namespace Myshipping.Core.Service
[HttpPost("/DJYTenantParam/addParamItem")]
public async Task AddParamItem(DjyTenantParamItem input)
{
+ if (string.IsNullOrWhiteSpace(input.ParaCode))
+ {
+ throw Oops.Oh(ErrorCode.Param001);
+ }
+ if (string.IsNullOrWhiteSpace(input.ItemCode))
+ {
+ throw Oops.Oh(ErrorCode.Param005);
+ }
+ if (string.IsNullOrWhiteSpace(input.ItemName))
+ {
+ throw Oops.Oh(ErrorCode.Param006);
+ }
+ var list = await _itemrep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.ItemCode == input.ItemCode);
+ if (list != null)
+ {
+ throw Oops.Oh(ErrorCode.Param004);
+ }
var entity = input.Adapt();
await _itemrep.InsertAsync(entity);
}
@@ -112,6 +174,27 @@ namespace Myshipping.Core.Service
[HttpPost("/DJYTenantParam/editParamItem")]
public async Task UpdateParamItem(DjyTenantParamItem input)
{
+ if (input.Id == 0)
+ {
+ throw Oops.Oh(ErrorCode.Param000);
+ }
+ if (string.IsNullOrWhiteSpace(input.ParaCode))
+ {
+ throw Oops.Oh(ErrorCode.Param001);
+ }
+ if (string.IsNullOrWhiteSpace(input.ItemCode))
+ {
+ throw Oops.Oh(ErrorCode.Param005);
+ }
+ if (string.IsNullOrWhiteSpace(input.ItemName))
+ {
+ throw Oops.Oh(ErrorCode.Param006);
+ }
+ var list = await _itemrep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.ItemCode == input.ItemCode && x.Id != input.Id);
+ if (list != null)
+ {
+ throw Oops.Oh(ErrorCode.Param004);
+ }
var entity = input.Adapt();
await _itemrep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
@@ -125,30 +208,32 @@ namespace Myshipping.Core.Service
[SqlSugarUnitOfWork]
public async Task DeleteParamItem(long Id)
{
+ if (Id == 0)
+ {
+ throw Oops.Oh(ErrorCode.Param000);
+ }
var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
-
await _valuerep.DeleteAsync(m => m.ItemCode == entity.ItemCode && m.ParaCode == entity.ParaCode);
await _itemrep.DeleteAsync(entity);
}
+
+
+ #endregion
+
+
+ #region 值
///
/// 获取参数
///
///
[HttpGet("/DJYTenantParam/getParamValue")]
- public async Task> GetParamValue(long tenantId)
+ public async Task> GetParamValue(long tenantId, string paraCode=null)
{
- if (tenantId==0) {
- tenantId = Convert.ToInt64(UserManager.TENANT_ID);
- }
- return await _valuerep.AsQueryable().Where(x => x.TenantId == tenantId).OrderBy(x => x.Sort).ToListAsync();
+ return await _valuerep.AsQueryable().Where(x => x.TenantId == tenantId).WhereIF(paraCode!=null,x=>x.ParaCode==paraCode).OrderBy(x => x.Sort).ToListAsync();
}
-
-
-
-
///
/// 增加参数
///
@@ -157,6 +242,23 @@ namespace Myshipping.Core.Service
public async Task AddParamValue(DjyTenantParamValue input)
{
var entity = input.Adapt();
+ if (string.IsNullOrWhiteSpace(input.ParaCode))
+ {
+ throw Oops.Oh(ErrorCode.Param001);
+ }
+ if (string.IsNullOrWhiteSpace(input.ItemCode))
+ {
+ throw Oops.Oh(ErrorCode.Param005);
+ }
+ if ( input.TenantId==null)
+ {
+ throw Oops.Oh(ErrorCode.Param007);
+ }
+ var list = await _valuerep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.TenantId == input.TenantId );
+ if (list != null)
+ {
+ throw Oops.Oh(ErrorCode.Param004);
+ }
await _valuerep.InsertAsync(entity);
await CacheData();
}
@@ -170,6 +272,27 @@ namespace Myshipping.Core.Service
public async Task UpdateParamValue(DjyTenantParamValue input)
{
var entity = input.Adapt();
+ if (input.Id == 0)
+ {
+ throw Oops.Oh(ErrorCode.Param000);
+ }
+ if (string.IsNullOrWhiteSpace(input.ParaCode))
+ {
+ throw Oops.Oh(ErrorCode.Param001);
+ }
+ if (string.IsNullOrWhiteSpace(input.ItemCode))
+ {
+ throw Oops.Oh(ErrorCode.Param005);
+ }
+ if (input.TenantId == null)
+ {
+ throw Oops.Oh(ErrorCode.Param007);
+ }
+ var list = await _valuerep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.TenantId == input.TenantId&&x.Id!=input.Id);
+ if (list != null)
+ {
+ throw Oops.Oh(ErrorCode.Param004);
+ }
await _valuerep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
await CacheData();
}
@@ -185,7 +308,7 @@ namespace Myshipping.Core.Service
var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
await _valuerep.DeleteAsync(entity);
}
-
+ #endregion
public async Task CacheData()
{
diff --git a/Myshipping.Core/Service/Tenant/SysTenantService.cs b/Myshipping.Core/Service/Tenant/SysTenantService.cs
index 32adccdb..bfba0afc 100644
--- a/Myshipping.Core/Service/Tenant/SysTenantService.cs
+++ b/Myshipping.Core/Service/Tenant/SysTenantService.cs
@@ -82,7 +82,7 @@ public class SysTenantService : ISysTenantService, IDynamicApiController, ITrans
public async Task QueryTenantPageList([FromQuery] TenantInput input)
{
var tenants = await _sysTenantRep.AsQueryable()
- .Where(m => m.TenantType != TenantTypeEnum.SYSTEM)
+ //.Where(m => m.TenantType != TenantTypeEnum.SYSTEM)
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.Host), u => u.Host.Contains(input.Host.Trim()))
.Select()
diff --git a/Myshipping.Report/Myshipping.Report.csproj.user b/Myshipping.Report/Myshipping.Report.csproj.user
index 5831b7bf..c54031d1 100644
--- a/Myshipping.Report/Myshipping.Report.csproj.user
+++ b/Myshipping.Report/Myshipping.Report.csproj.user
@@ -8,7 +8,7 @@
- Debug|Any CPU
+ Release|Any CPU
From a7f0fefdf748ae7d3069ebda6edca171cbd5292c Mon Sep 17 00:00:00 2001
From: jianghaiqing
Date: Mon, 14 Nov 2022 17:50:40 +0800
Subject: [PATCH 2/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A2=E8=88=B1?=
=?UTF-8?q?=E5=92=8C=E6=88=AA=E5=8D=95EDI=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Myshipping.Application/EDI/PILEdiHelper.cs | 2531 +++++++++++++
Myshipping.Application/EDI/TSLEdiHelper.cs | 2588 +++++++++++++
Myshipping.Application/EDI/WYEdiHelper.cs | 1566 ++++++++
Myshipping.Application/EDI/YMLEdiHelper.cs | 2472 +++++++++++++
Myshipping.Application/EDI/YTEdiHelper.cs | 1776 +++++++++
.../Myshipping.Application.xml | 3285 ++++++++++++++++-
.../Dto/BookingOrClosingEDIOrderDto.cs | 53 +
.../BookingOrder/Dto/CommonWebApiResult.cs | 53 +
8 files changed, 14289 insertions(+), 35 deletions(-)
create mode 100644 Myshipping.Application/EDI/PILEdiHelper.cs
create mode 100644 Myshipping.Application/EDI/TSLEdiHelper.cs
create mode 100644 Myshipping.Application/EDI/WYEdiHelper.cs
create mode 100644 Myshipping.Application/EDI/YMLEdiHelper.cs
create mode 100644 Myshipping.Application/EDI/YTEdiHelper.cs
create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/BookingOrClosingEDIOrderDto.cs
create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/CommonWebApiResult.cs
diff --git a/Myshipping.Application/EDI/PILEdiHelper.cs b/Myshipping.Application/EDI/PILEdiHelper.cs
new file mode 100644
index 00000000..ba3fc0c7
--- /dev/null
+++ b/Myshipping.Application/EDI/PILEdiHelper.cs
@@ -0,0 +1,2531 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application.EDI.PIL
+{
+ ///
+ ///
+ ///
+ public class PILEdiHelper
+ {
+
+ public PILEdiHelper()
+ {
+ }
+
+ #region 基本函数
+
+ public static string GetDateStr(string datestr, string dateformat)
+ {
+ var result = "";
+
+ if (datestr == null || datestr == "")
+ {
+ result = "";
+ }
+ else
+ {
+ result = Convert.ToDateTime(datestr).ToString(dateformat);
+
+ }
+
+ return result;
+
+ }
+
+ #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 文本字段判断每行是否符合
+ ///
+ /// edi 文本格式处理判断(例如:1行35个字符不超过5行)
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 要处理的数据
+ /// 每行长度
+ /// 主提单号
+ /// 数据类型(例如:发货人内容、货描等)
+ /// 限制录入的行数(“0”代表不限制)
+ /// 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+ ///
+ 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 + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ else
+ {
+ if (argAGENT.Length > rowNum && rowNum != 0)
+ {
+ if (isHuoMiao)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ return error;
+ }
+ #endregion
+
+ #region 字符转义
+ ///
+ /// 各种文本转义字符
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 文本字符串
+ ///
+ public static string formatEdiStr(string fileType, string str)
+ {
+ if (fileType == "txt")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'");
+ }
+ else if (fileType == "xml")
+ {
+ return str.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
+ }
+ else if (fileType == "sitc")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("'", "?'");
+ }
+ else
+ {
+ return str;
+ }
+ }
+ #endregion
+ #region 格式化每行
+ public static List 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 DestList = new List();
+ 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
+
+ public static string GetmpStr(string str, int len)
+ {
+ var strhead = "";
+
+ if (str.IndexOf("-") >= 0)
+ {
+ strhead = "-";
+ str.Replace("-", "");
+ }
+
+ string result = str;
+
+ for (var i = 0; i <= len - str.Length - 2; i++)
+ {
+ result = "0" + result;
+ }
+
+ return result;
+ }
+
+ public static string GetSpaceStr(string str, int len, string substr = " ")
+ {
+
+ if (substr == "0")
+ {
+ if (str.IndexOf(".") >= 0)
+ str = str.Substring(0, str.IndexOf("."));
+ }
+ string result = str;
+ if (str.Length >= len)
+ {
+ result = str.Substring(0, len);
+
+ }
+ else
+ {
+ for (var i = 0; i <= len - str.Length - 1; i++)
+ {
+ if (substr == "0")
+ result = "0" + result;
+ else
+ result = result + substr;
+ }
+ }
+ return result;
+ }
+ public static string GetPILServiceStr(string str)
+ {
+ string result = "Y";
+ str = str.ToUpper();
+ char splitstr = '-';
+ if (str.IndexOf("-") > 0)
+ {
+ splitstr = '-';
+ }
+ else if (str.IndexOf("/") > 0)
+ {
+ splitstr = '/';
+ }
+ var strList = str.Split(splitstr);
+ var i = 1;
+ var strhead = "";
+ var strbotton = "";
+ foreach (var substr in strList)
+ {
+ if (i == 1)
+ {
+ if (substr == "CY") strhead = "Y";
+ else if (substr == "CFS") strhead = "F";
+ else if (substr == "FO") strhead = "O";
+ else if (substr == "DOOR") strhead = "O";
+ else if (substr == "HOOK") strhead = "K";
+ else if (substr == "TACKLE") strhead = "L";
+ }
+ if (i == 2)
+ {
+ if (substr == "CY") strbotton = "Y";
+ else if (substr == "CFS") strbotton = "F";
+ else if (substr == "FO") strbotton = "O";
+ else if (substr == "DOOR") strbotton = "O";
+ else if (substr == "HOOK") strbotton = "K";
+ else if (substr == "TACKLE") strbotton = "L";
+
+ }
+ i = i + 1;
+ }
+ if (strhead == "") strhead = "Y";
+ if (strbotton == "") strbotton = "Y";
+ result = strhead + strbotton;
+
+ return result;
+ }
+
+ #endregion
+
+ #region 检查
+ public static string IsCreatePILEDI(MsPILEdiModel InttrEdi)
+ {
+ var error = "";
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDCODE))
+ { error = error + "
发送方代码不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDNAME))
+ { error = error + "
发送方名称不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.RECEIVECODE))
+ { error = error + "
接收方代码不能为空"; }
+
+ //if (InttrEdi.filetype == "B")
+ //{
+ // if (InttrEdi.UseForWarderCode)
+ // {
+ // if (string.IsNullOrEmpty(InttrEdi.ForWarderCode))
+ // { error = error + "
货代代码不能为空"; }
+
+ // if (string.IsNullOrEmpty(InttrEdi.ForWarderName))
+ // { error = error + "
货代称呼不能为空"; }
+ // }
+ //}
+
+
+ foreach (var bill in InttrEdi.BSLIST)
+ {
+
+ if (string.IsNullOrEmpty(bill.ORDERNO))
+ { error = error + "|订舱单号不能为空"; }
+
+ if (bill.PORTLOADID == "CNTAO")
+ {
+ if (string.IsNullOrEmpty(bill.YARD) || string.IsNullOrEmpty(bill.YARDEDICODE))
+ { error = error + "|场站和场站EDI代码不能为空"; }
+ }
+
+ if (string.IsNullOrEmpty(bill.MBLNO))
+ { error = error + "|主提单号不能为空"; }
+
+ if (string.IsNullOrEmpty(bill.BLFRT))
+ { error = error + "
提单号:" + bill.MBLNO + "付费方式不能为空"; }
+
+ if (string.IsNullOrEmpty(bill.PORTLOADID))
+ { error = error + "
提单号:" + bill.MBLNO + "装货港代码不能为空"; }
+
+ if (string.IsNullOrEmpty(bill.PORTLOAD))
+ { error = error + "
提单号:" + bill.MBLNO + "装货港不能为空"; }
+
+ if (string.IsNullOrEmpty(bill.ETD))
+ {
+ error = error + "
提单号:" + bill.MBLNO + "开船日期不能为空";
+ return error;
+ }
+
+ if (string.IsNullOrEmpty(bill.ETA))
+ {
+ error = error + "
提单号:" + bill.MBLNO + "预抵日期不能为空";
+ return error;
+ }
+
+ if (string.IsNullOrEmpty(bill.GOODCLASSCODE))
+ {
+ error = error + "
提单号:" + bill.MBLNO + "货类代码不能为空";
+ return error;
+ }
+
+ if (string.IsNullOrEmpty(bill.PORTDISCHARGEID))
+ { error = error + "
提单号:" + bill.MBLNO + "卸货港代码不能为空"; }
+
+ if (string.IsNullOrEmpty(bill.PLACEDELIVERYID))
+ { error = error + "
提单号:" + bill.MBLNO + "交货代码不能为空"; }
+
+ if (bill.PLACEDELIVERY == null || bill.PLACEDELIVERY == "")
+ { error = error + "
提单号:" + bill.MBLNO + "交货地不能为空"; }
+ if (bill.DESTINATION == null || bill.DESTINATION == "")
+ { error = error + "
提单号:" + bill.MBLNO + "目的地不能为空"; }
+
+ if (bill.ISSUEPLACE == null || bill.ISSUEPLACE == "")
+ { error = error + "
提单号:" + bill.ISSUEPLACE + "签单地点不能为空"; }
+
+ if (bill.PKGS == 0)
+ { error = error + "
提单号:" + bill.MBLNO + "货物件数不能为空"; }
+
+ if (bill.KGS == 0)
+ { error = error + "
提单号:" + bill.MBLNO + "货物毛重不能为空"; }
+
+ if (bill.CBM == 0)
+ { error = error + "
提单号:" + bill.CBM + "货物尺码不能为空"; }
+
+
+ if (bill.CARGOID == null || bill.CARGOID == "")
+ { error = error + "
提单号:" + bill.MBLNO + "货物标示不能为空"; }
+
+ if (bill.CARGOID == "D")
+ {
+ if (bill.DCLASS == null || bill.DCLASS == "")
+ { error = error + "
提单号:" + bill.MBLNO + "危险品分类不能为空"; }
+
+ if (bill.DUNNO == null || bill.DUNNO == "")
+ { error = error + "
提单号:" + bill.MBLNO + "危险品编号不能为空"; }
+
+ if (bill.DUNNO.Length != 4)
+ { error = error + "
提单号:" + bill.MBLNO + "危险品编号必须是4位数字"; }
+ }
+
+ if (bill.CARGOID == "R")
+ {
+
+ if (bill.TEMPSET == null || bill.TEMPSET == "")
+ { error = error + "
提单号:" + bill.MBLNO + "设置温度不能为空"; }
+ else
+ {
+ if (bill.TEMPSET.IndexOf("+") < 0 && bill.TEMPSET.IndexOf("-") < 0 && bill.TEMPSET.IndexOf(".") < 0)
+ { error = error + "
提单号:" + bill.MBLNO + "温度格式输入不正确,请输入如此格式: -0.10 或 +0.10"; }
+
+ }
+ if (bill.TEMPMAX == null || bill.TEMPMAX == "")
+ { error = error + "
提单号:" + bill.MBLNO + "最高温度不能为空"; }
+ else
+ {
+ if (bill.TEMPMAX.IndexOf("+") < 0 && bill.TEMPMAX.IndexOf("-") < 0 && bill.TEMPMAX.IndexOf(".") < 0)
+ { error = error + "
提单号:" + bill.MBLNO + "温度格式输入不正确,请输入如此格式: -0.10 或 +0.10"; }
+
+ }
+
+ if (bill.TEMPMIN == null || bill.TEMPMIN == "")
+ { error = error + "
提单号:" + bill.MBLNO + "最低温度不能为空"; }
+ else
+ {
+ if (bill.TEMPMIN.IndexOf("+") < 0 && bill.TEMPMIN.IndexOf("-") < 0 && bill.TEMPMIN.IndexOf(".") < 0)
+ { error = error + "
提单号:" + bill.MBLNO + "温度格式输入不正确,请输入如此格式: -0.10 或 +0.10"; }
+
+ }
+
+ }
+
+ if (string.IsNullOrEmpty(bill.MARKS))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 唛头不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(bill.MARKS))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 唛头含有中文或双字节字符";
+ }
+ else
+ {
+ error += formatlengthError("txt", bill.MARKS, 35, bill.MBLNO, "唛头", 0, "", false);
+ }
+ }
+
+ if (string.IsNullOrEmpty(bill.DESCRIPTION))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 货物描述不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(bill.DESCRIPTION))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 货物描述含有中文或双字节字符";
+ }
+ else
+ {
+ //error += formatlengthError("txt", bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 0, "");
+ }
+ }
+
+
+ if (string.IsNullOrEmpty(bill.SHIPPER))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 发货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(bill.SHIPPER))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 发货人含有中文或双字节字符";
+ }
+ else error += formatlengthError("txt", bill.SHIPPER, 35, bill.MBLNO, "发货人", 6, "*", false);
+
+ }
+ //}
+
+
+
+ if (string.IsNullOrEmpty(bill.CONSIGNEE))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 收货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(bill.CONSIGNEE))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 收货人含有中文或双字节字符";
+ }
+ else error += formatlengthError("txt", bill.CONSIGNEE, 35, bill.MBLNO, "收货人", 6, "*", false);
+
+ }
+
+
+
+
+ if (string.IsNullOrEmpty(bill.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 通知人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(bill.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + bill.MBLNO + " 通知人含有中文或双字节字符";
+ }
+ else error += formatlengthError("txt", bill.NOTIFYPARTY, 35, bill.MBLNO, "通知人", 6, "*", false);
+ }
+
+
+ var ctnlist = bill.CTNLIST;
+ if (ctnlist.Count == 0) { error = error + "
提单号:" + bill.MBLNO + " 集装箱信息不能为空"; };
+
+
+ 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 + "
提单号:" + bill.MBLNO + " 集装箱箱型EDI代码不能为空"; }
+
+ if ((ctn.CTNALLCODE.IndexOf("RH") > 0 || ctn.CTNALLCODE.IndexOf("RF") > 0) && (bill.CARGOID != "R"))
+ {
+ { error = error + "
提单号:" + bill.MBLNO + " 集装箱箱型为冻柜,货类代码请选择冻柜"; }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+
+ //if (string.IsNullOrEmpty(ctn.CNTRNO))
+ //{ error = error + "
提单号:" + bill.MBLNO + " 箱号不能为空"; }
+ //if (string.IsNullOrEmpty(ctn.SEALNO))
+ //{ error = error + "
提单号:" + bill.MBLNO + " 封号不能为空"; }
+
+ if (ctn.KINDPKGS != bill.KINDPKGS)
+ { error = error + "
提单号:" + bill.MBLNO + " 中的包装类型与集装箱的包装类型不同"; }
+ dlPKGS += Convert.ToDecimal(ctn.PKGS);
+ dlKGS += Convert.ToDecimal(ctn.KGS);
+ dlCBM += Convert.ToDecimal(ctn.CBM);
+ }
+ }
+ if (InttrEdi.filetype == "E")
+ {
+ if (dlPKGS != Convert.ToDecimal(bill.PKGS))
+ { error = error + "
提单号:" + bill.MBLNO + " 集装箱件数合计数必须等于委托单总件数"; }
+ if (dlKGS != Convert.ToDecimal(bill.KGS))
+ { error = error + "
提单号:" + bill.MBLNO + " 集装箱重量合计数必须等于委托单总重量数"; }
+ if (dlCBM != Convert.ToDecimal(bill.CBM))
+ { error = error + "
提单号:" + bill.MBLNO + " 集装箱尺码合计数必须等于委托单总尺码数"; }
+ }
+ }
+ //太平新Edi接口判断
+ if (bill.HSCODE == null || bill.HSCODE == "")
+ { error = error + "
提单号:" + bill.MBLNO + "HS编码 不能为空"; }
+
+ if (bill.MasterBOLIndicator == null || bill.MasterBOLIndicator == "")
+ { error = error + "
提单号:" + bill.MBLNO + "Master BOL Indicator 不能为空"; }
+
+ if (bill.BLFRT.IndexOf("FREIGHT COLLECT") > -1)//运费到付
+ {
+ if (bill.ConsigneeEdiCode == null || bill.ConsigneeEdiCode == "")
+ { error = error + "
提单号:" + bill.MBLNO + "收货人Edi代码 不能为空"; }
+ }
+ else
+ {
+ if (bill.ShipperEdiCode == null || bill.ShipperEdiCode == "")
+ { error = error + "
提单号:" + bill.MBLNO + "发货人Edi代码 不能为空"; }
+ }
+
+ if (bill.SalesRepCode == null || bill.SalesRepCode == "")
+ { error = error + "
提单号:" + bill.MBLNO + "太平销售的Edi代码 不能为空"; }
+
+ if (bill.BYCOUNTRY == "CANADA")
+ {
+ if (bill.ACIHBL == null || bill.ACIHBL == "")
+ { error = error + "
提单号:" + bill.MBLNO + "ACI HBL 不能为空"; }
+
+ if (bill.S0CC0C == null || bill.S0CC0C == "")
+ { error = error + "
提单号:" + bill.MBLNO + "S0C C0C 不能为空"; }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+ if (bill.BYCOUNTRY == "USA")
+ {
+ if (bill.CONTRACTNO == null || bill.CONTRACTNO.ToString().Trim() == "")
+ { error = error + "
提单号:" + bill.MBLNO + "运费协议号 不能为空"; }
+ }
+ }
+
+
+ }
+ return error;
+ }
+ #endregion
+
+ #region 生成报文(订舱(filetype=="B"),截单(filetype=="E"))
+ public static string CreateEdiPIL(MsPILEdiModel InttrEdi)
+ {
+ var estr = "";
+ if (InttrEdi.filetype == "E")
+ {
+ estr = "ESI";
+ }
+ else
+ {
+ estr = "EDI";
+ }
+ var SENDCODE = "";
+ SENDCODE = InttrEdi.SENDCODE;
+ //
+ string filename = InttrEdi.filerpath + "\\" + InttrEdi.BSLIST[0].MBLNO + estr + ".pms";
+
+
+ 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 tempstr = "";
+
+ #region 00
+ //tempstr = "00DOC" + GetSpaceStr("", 22) + GetSpaceStr(SENDCODE, 8) + GetSpaceStr("", 6) + DateTime.Now.ToString("yyyyMMddHHmm") + GetSpaceStr("", 1)
+ // + portload + portload;
+ //if (filetype == "E")
+ // tempstr = tempstr + "4.01";
+ //else
+ // tempstr = tempstr + "PBK";
+ //r.WriteLine(GetSpaceStr(tempstr, 250));
+
+ tempstr = "00";//1//RECORD-ID//M//9(2)//1//2//00
+ tempstr += "DOC";//2//Data-type ID//M//X(3)//3//5//DOC=BL, BKG=Booking
+ tempstr += GetSpaceStr("", 20);//3//File Description//O//X(20)//6//25//
+ tempstr += GetSpaceStr("", 2);//4//Filler//M//X(2)//26//27//Spaces
+ tempstr += GetSpaceStr(SENDCODE, 8);//5//Sender-Code//M//X(8)//28//35//Sender/Receiver Code List
+ tempstr += GetSpaceStr("", 6);//6//Filler//M//X(6)//36//41//
+ tempstr += DateTime.Now.ToString("yyyyMMddHHmm");//7//File Send time//M//9(12)//42//53//YYYYMMDDHHMM
+ tempstr += GetSpaceStr("", 1);//8//Filler//M//X(1)//54//54//Spaces
+ tempstr += InttrEdi.BSLIST[0].PORTLOADID;//9//Sender Port Code//M//X(5)//55//59//
+ tempstr += InttrEdi.BSLIST[0].PORTLOADID;//10//Receiver Port Code//M//X(5)//60//64//
+ if (InttrEdi.filetype == "E")
+ {
+ tempstr += "4.02";//11//EDI Version//M//X(4) //65//68//Default to "PBK" / esi:4.01
+ }
+ else
+ {
+ tempstr += "PBK";//11//EDI Version//M//X(4) //65//68//Default to "PBK" / esi:4.01
+ }
+ tempstr += GetSpaceStr("", 15);//12//Sender Ver Control ID//C//X(15)//69//83//Sender's ASFS/AFMS software version; blank if not applicable
+ tempstr += GetSpaceStr("", 167);//13//Filler//M//X(167)//84//250//Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ foreach (var bill in InttrEdi.BSLIST)
+ {
+ icount = icount + 1;
+
+
+
+ #region 11
+ var eta = "";
+ if (bill.ETA == "" || bill.ETA == null)
+ {
+ eta = DateTime.Now.ToString("yyyyMMdd");
+ }
+ else { eta = bill.ETA.Replace("-", ""); }
+ var etd = "";
+ if (bill.ETD == "" || bill.ETD == null)
+ {
+ etd = GetSpaceStr("", 8);
+ }
+ else { etd = bill.ETD.Replace("-", ""); }
+
+ //tempstr = "11" + GetSpaceStr("", 1) + GetSpaceStr(bill.VESSELID, 10) + GetSpaceStr(bill.VESSEL, 20) + GetSpaceStr(bill.VOYNO, 8) + eta + etd
+ // + GetSpaceStr(bill.VESSELID + bill.VOYNO, 12) + eta;
+ //r.WriteLine(GetSpaceStr(tempstr, 250));
+
+ tempstr = "11";//1//RECORD-ID//M//9(2)//1//2//11//
+ tempstr += GetSpaceStr("", 1);//2//Filler//M//X(1)//3//3//Spaces//
+ if (bill.VOYNO.ToString().Trim().Length < 4)
+ {
+ tempstr += GetSpaceStr(bill.VOYNO.ToString().Trim(), 10);//3//Vessel Code//M//X(10)//4//13//和vessel有关的,即field 4和 field 3 都必填
+ }
+ else
+ {
+ tempstr += GetSpaceStr(bill.VOYNO.ToString().Trim().Substring(0, 4), 10);//3//Vessel Code//M//X(10)//4//13//和vessel有关的,即field 4和 field 3 都必填
+ }
+ tempstr += GetSpaceStr(bill.VESSEL, 20);//4//Vessel Name//M//X(20)//14//33//和vessel有关的,即field 4和 field 3 都必填
+ tempstr += GetSpaceStr("", 8);//5//Voyage No.//M//X(8)//34//41//Alternate Voyage Reference (Commercial voyage)//但是和voyage有关的,即field 5和field 8不用填//不用填
+ //tempstr += GetSpaceStr("", 8);//5//Voyage No.//M//X(8)//34//41//Alternate Voyage Reference (Commercial voyage)//不用填
+ tempstr += eta;//6//Arrival Date//M//9(8)//42//49//YYYYMMDD (ATA or ETA if ATA not available)//
+ tempstr += etd;//7//Sailing Date//M//9(8)//50//57//YYYYMMDD (ATD or ETD if ATD not available)//
+ tempstr += GetSpaceStr("", 12);//8//webCSM Voyage No.//O//X(12)//58//69//webCSM System Voyage Reference//但是和voyage有关的,即field 5和field 8不用填//不要填
+ tempstr += eta;//9//Berthing Date//O//9(8)//70//77//YYYYMMDD (ATB or ETB if ATB not available)//
+ if (bill.VOYNO.ToString().Trim().Length < 5)
+ {
+ tempstr += GetSpaceStr("", 12);//10//Export Local Voyage Reference//O//X(12)//78//89//Export Local Voyage in relation to Sender Port(customs/port reporting)//ENHANCEMENT,填写原field 8的内容,报关用
+ }
+ else
+ {
+ tempstr += GetSpaceStr(bill.VOYNO.ToString().Trim().Substring(4), 12);//10//Export Local Voyage Reference//O//X(12)//78//89//Export Local Voyage in relation to Sender Port(customs/port reporting)//ENHANCEMENT,填写原field 8的内容,报关用
+ }
+ tempstr += GetSpaceStr("", 12);//11//Import Local Voyage Reference//O//X(12)//90//101//Import Local Voyage in relation to Sender Port(customs/port reporting)//内部航次
+ tempstr += GetSpaceStr("", 149);//12//Filler//M//X(149)//102//250//Spaces//
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 12
+ tempstr = "12";//1 //RECORD-ID//M//9(2)//1 //2 //12
+ if (InttrEdi.filetype == "E")
+ {
+ tempstr += GetSpaceStr(bill.MBLNO, 20);//2 //webCSM Booking Reference//M//X(20)//3 //22 //webCSM System Job Reference如果需要,填写原field 3的custom ref//bill.ORDERNO
+ }
+ else
+ {
+ tempstr += GetSpaceStr("+", 20);//2 //webCSM Booking Reference//M//X(20)//3 //22 //webCSM System Job Reference如果需要,填写原field 3的custom ref
+ }
+ tempstr += GetSpaceStr(bill.MBLNO, 20);//3 //webCSM BL Number//C//X(20)//23 //42 //Pre-assigned BKG Refmandtory (PIL's bkg ref nbr),预放提单号
+ if (bill.PORTLOADID == "CNTAO")
+ {
+ tempstr += GetSpaceStr(bill.MBLNO, 20);//4 //Original Bill of Lading//C//X(20)//43 //62 //webCSM External B/L Reference, only if external BL is used
+ }
+ else
+ {
+ tempstr += GetSpaceStr("", 20);//4 //Original Bill of Lading//C//X(20)//43 //62 //webCSM External B/L Reference, only if external BL is used
+ }
+
+ tempstr += GetSpaceStr("", 5);//5 //Filler//M//X(5)//63 //67 //Spaces
+ tempstr += GetSpaceStr(bill.PORTDISCHARGEID, 5);//6 //Port of Discharge//M//X(5)//68 //72 //Next Discharge Port for the voyage generated
+ tempstr += GetSpaceStr(bill.PORTLOADID, 5);//7 //Port of Loading//M//X(5)//73 //77 //Load Port for the voyage generated
+ tempstr += "FF";//8 //BL Movement Type//M//X(2)//78 //79 //F:FCL, L:LCL, M:MTY, T:TFCL, Y:TMTY, eg. FF=FCL/FCL
+ tempstr += "PP";//9 //Movement Terms//O//X(2)//80 //81 //D:Door, P:Port, R:Ramp, eg. DD=Door/Door
+ tempstr += GetSpaceStr(GetPILServiceStr(bill.SERVICE), 2);//10 //Freight Terms//M//X(2)//82 //83 //Y:CY, F:CFS, I:FI, O:FO, D:Door, K:Hook, L:Tackle eg. YY=CY/CY
+ tempstr += GetSpaceStr("", 3);//11 //Filler//M//X(3)//84 //86 //Spaces
+ if (bill.BLFRT.IndexOf("FREIGHT COLLECT") > -1)
+ {
+ tempstr += "C";//12 //BL Prepaid/Collect//C//X(1)//87 //87 //P-Prepaid, C-Collect for BOF charge, mandatory if Rec 61 exists//mandtory,到付预付必填,第三地填C
+ }
+ else if (bill.BLFRT.IndexOf("PREPAID") > -1)//预付
+ {
+ tempstr += "P";//12 //BL Prepaid/Collect//C//X(1)//87 //87 //P-Prepaid, C-Collect for BOF charge, mandatory if Rec 61 exists//mandtory,到付预付必填,第三地填C
+ }
+ else
+ {
+ tempstr += "C";//12 //BL Prepaid/Collect//C//X(1)//87 //87 //P-Prepaid, C-Collect for BOF charge, mandatory if Rec 61 exists//mandtory,到付预付必填,第三地填C
+ }
+ tempstr += "N";//13 //BL Tranship Flag//M//X(1)//88 //88 //Y or N
+ tempstr += "N";//14 //BL All Empty CTN Flag//M//X(1)//89 //89 //Y or N
+ if (bill.CLOSINGDATE == "")
+ {
+ tempstr += GetSpaceStr("", 8);//15 //Loading Date//C//X(8)//90 //97 //YYYYMMDD, mandatory if record submitted is BL
+ }
+ else
+ {
+ tempstr += Convert.ToDateTime(bill.CLOSINGDATE).ToString("yyyyMMdd");//15 //Loading Date//C//X(8)//90 //97 //YYYYMMDD, mandatory if record submitted is BL
+ }
+ if (bill.PORTLOADID == "CNSHA" && InttrEdi.filetype != "E")
+ {
+ tempstr += GetSpaceStr("", 20);//16 //Original_reference//C//X(20)//98 //117 //webCSM Alternate Booking Reference, only if alt booking ref is used
+ }
+ else
+ {
+ tempstr += GetSpaceStr(bill.MBLNO, 20);//16 //Original_reference//C//X(20)//98 //117 //webCSM Alternate Booking Reference, only if alt booking ref is used
+ }
+ tempstr += GetSpaceStr("", 20);//17 //Bkg Pty Reference//O//X(20)//118 //137 //webCSM Bkg Party Reference
+ tempstr += "F";//18 //Booking_Party_indicator//M//X(1)//138 //138 //D-Deciding Pty, N-Notify Pty, C-Consignee, S-Shipper, F-Forwarder
+ tempstr += GetSpaceStr("", 20);//19 //Part MBL//C//X(20)//139 //158 //Not for part BL purpose
+ tempstr += GetSpaceStr("", 20);//20 //BL Paid By//C//X(20)//159 //178 //Freight Absorbed by BL Reference, only if BL's frt is paid by other BL
+ tempstr += GetSpaceStr("", 12);//21 //Customs Bill of Lading//C//X(12)//179 //190 //Customs BL Reference (12 char) - only for US/CA Customs requirement
+ if (bill.ETD == "")
+ {
+ tempstr += GetSpaceStr("", 8);//22 //Booking Date//M//X(8)//191 //198 //YYYYMMDD
+ }
+ else
+ {
+ tempstr += Convert.ToDateTime(bill.ETD).ToString("yyyyMMdd");//22 //Booking Date//M//X(8)//191 //198 //YYYYMMDD
+ }
+ //tempstr += eta;//23 //Slot Owner//M//X(3)//199 //201 //
+ tempstr += GetSpaceStr("PI", 3);//24 //Cntr Operator//M//X(3)//202 //204 //
+ tempstr += GetSpaceStr("PI", 3);//25 //Filler//M//X(46)//205 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 13
+ tempstr = "13";//1 //RECORD-ID//M//9(2)//1 //2 //13
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(bill.PORTLOADID, 5);//3 //Port of Origin//M//X(5)//6 //10 //refer Port Code (Place of receipt)
+ tempstr += GetSpaceStr(bill.PORTDISCHARGEID, 5);//4 //Port of Discharge//M//X(5)//11 //15 //refer Port code (Port of Discharge - final)
+ tempstr += GetSpaceStr("", 5);//5 //Port of Trans//C//X(5)//16 //20 //refer Port code (1st T/S port), only if Transshipment involved
+ tempstr += GetSpaceStr(bill.PLACEDELIVERYID, 5);//6 //Final Destination//M//X(5)//21 //25 //refer Port Code (Place of delivery)
+ tempstr += GetSpaceStr("", 20);//7 //Final Destination (Name)//M//X(20)//26 //45 //
+ tempstr += GetSpaceStr("", 10);//8 //Route Code//O//X(10)//46 //55 //webCSM Route Code (out from webCSM only)
+ tempstr += GetSpaceStr("", 45);//9 //Filler//M//X(45)//56 //100 //Spaces
+ tempstr += GetSpaceStr("", 5);//10 //Transhipment Port 1//C//X(5)//101 //105 //1st Transhipment Port, only if Transshipment involved
+ tempstr += GetSpaceStr("", 5);//11 //Transhipment Port 2//C//X(5)//106 //110 //2nd Transhipment Port, only if 2nd Transshipment involved
+ tempstr += GetSpaceStr("", 5);//12 //Transhipment Port 3//C//X(5)//111 //115 //3rd Transhipment Port, only if 3rd Transshipment involved
+ //eta = GetPortEDICode(bill.PORTDISCHARGEID, "PIL").Substring(2, 3);
+ //if (eta == "SSZ" || eta == "BUE" || eta == "MVD" || eta == "PNG" || eta == "NVT" || eta == "RIO")
+ //{
+ // tempstr += "U";//13 //Master BOL Indicator//M//X(1)//116 //116 //1=Carrier filing HBL, 2=Self filing HBL, 3=Not Applicable/Straight bl//mandtory,1/船公司发HBL,2/自己发,3/无HBL。美国线必填,加拿大线填在record 73
+
+ //}
+ //else
+ //{
+ // tempstr += "N";//13 //Master BOL Indicator//M//X(1)//116 //116 //1=Carrier filing HBL, 2=Self filing HBL, 3=Not Applicable/Straight bl//mandtory,1/船公司发HBL,2/自己发,3/无HBL。美国线必填,加拿大线填在record 73
+
+ //}
+ tempstr += bill.MasterBOLIndicator;//13 //Master BOL Indicator//M//X(1)//116 //116 //1=Carrier filing HBL, 2=Self filing HBL, 3=Not Applicable/Straight bl//mandtory,1/船公司发HBL,2/自己发,3/无HBL。美国线必填,加拿大线填在record 73
+
+ tempstr += GetSpaceStr("", 3);//14 //Job Status //O//X(3)//117 //119 //webCSM Job Status (out from webCSM only)
+ tempstr += GetSpaceStr("", 3);//15 //B/L Status//O//X(3)//120 //122 //webCSM B/L Status (out from webCSM only)
+ tempstr += GetSpaceStr("", 1);//16 //Export Haulage//O//X(1)//123 //123 //M:Merchant Haulage, C:Carrier Haulage
+ tempstr += GetSpaceStr("", 1);//17 //Import Haulage//O//X(1)//124 //124 //M:Merchant Haulage, C:Carrier Haulage
+ tempstr += GetSpaceStr("", 35);//18 //EDI301 Reference//C//X(35)//125 //159 //Shipping Portal's booking reference (eg. GT Nexus, INTTRA)
+ tempstr += GetSpaceStr("", 91);//19 //Filler//M//X(91)//160 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ if (InttrEdi.filetype == "E")
+ {
+ #region 15
+ tempstr = "15";//1//RECORD-ID//M//9(2)//1//2//15
+ tempstr += GetSpaceStr(bill.PLACERECEIPT, 50);//2//Origin Freeform//O//X(50)//3//52//BL location text for Port of Origin//收货地
+ tempstr += GetSpaceStr(bill.PORTLOAD, 50);//3//Load Port Freeform//O//X(50)//53//102//BL location text for Port of Load//装货港
+ tempstr += GetSpaceStr(bill.PORTDISCHARGE, 50);//4//Discharge Port Freeform//O//X(50)//103//152//BL location text for Port of Discharge//卸货港
+ tempstr += GetSpaceStr(bill.PLACEDELIVERY, 50);//5//Destination Freeform//O//X(50)//153//202//BL location text for Port of Delivery//交货地点
+ tempstr += GetSpaceStr(bill.VOYNO, 30);//6//Freeform Voyage//O//X(30)//203//232//BL voyage freeform/
+ tempstr += GetSpaceStr(bill.VOYNO, 30);//6//Freeform Voyage//O//X(30)//203//232//BL voyage freeform//航次
+ tempstr += GetSpaceStr("", 18);//7//Filler//M//X(18)//233//250//Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+ }
+
+ #region 16
+ tempstr = "16";//1//RECORD-ID//M//9(2)//1//2//16
+ tempstr += GetSpaceStr("", 3);//2//Filler//M//X(3)//3//5//Spaces
+ //if (bill.BLFRT.IndexOf("FREIGHT COLLECT") > -1)//运费到付
+ //{
+ // tempstr += GetSpaceStr("", 10);//3//Shipper Code//O//X(10)//6//15//webcsm Partner Code//mandtory for CIF shpts,预付必填
+ //}
+ //else
+ //{
+ tempstr += GetSpaceStr(bill.ShipperEdiCode, 10);//3//Shipper Code//O//X(10)//6//15//webcsm Partner Code//mandtory for CIF shpts,预付必填
+ //}
+ tempstr += GetSpaceStr("", 3);//4//Shipper Code//O//X(3)//16//18//webcsm Partner Subcode
+ tempstr += GetSpaceStr("", 4);//5//Filler//M//X(4)//19//22//Spaces
+ var Shipping = "";
+ Shipping = bill.SHIPPER;
+ List ShippingList = formatlengthStr(Shipping, 35);
+ for (var i = 0; i < ShippingList.Count; i++)
+ {
+ if (i <= 6)
+ {
+ tempstr += GetSpaceStr(ShippingList[i], 35);//6//Shipper-Item (1)//M//X(35)//23//57//Shipper Name, Address line 1
+ }
+ }
+ //6//Shipper-Item (1)//M//X(35)//23//57//Shipper Name, Address line 1
+ //7//Shipper-item (2)//M//X(35)//58//92//Shipper Name, Address line 2
+ //8//Shipper-item (3)//M//X(35)//93//127//Shipper Name, Address line 3
+ //9//Shipper-item (4)//M//X(35)//128//162//Shipper Name, Address line 4
+ //10//Shipper-item (5)//M//X(35)//163//197//Shipper Name, Address line 5
+ //11//Shipper-item (6)//M//X(35)//198//232//Shipper Name, Address line 6
+ //12//SCAC Code//O//X(4)//233//236//
+ //13//Filler//M//X(14)//237//250//Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 17
+ tempstr = "17";//1 //RECORD-ID//M//9(2)//1 //2 //17
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ //if (bill.BLFRT == "FREIGHT PREPAID")
+ //{
+ // tempstr += GetSpaceStr(agent, 10);//3 //Booking Party Code//O//X(10)//6 //15 //webcsm Partner Code
+ //}
+ //else
+ //{
+ // tempstr += GetSpaceStr(cagent, 10);//3 //Booking Party Code//O//X(10)//6 //15 //webcsm Partner Code
+ //}
+ if (bill.BLFRT.IndexOf("FREIGHT PREPAID") > -1)//运费预付
+ {
+ tempstr += GetSpaceStr(bill.ShipperEdiCode, 10);//3 //Booking Party Code//O//X(10)//6 //15 //webcsm Partner Code
+ }
+ else
+ {
+ tempstr += GetSpaceStr(bill.ConsigneeEdiCode, 10);//3//Shipper Code//O//X(10)//6//15//webcsm Partner Code//mandtory for CIF shpts,预付必填
+ }
+ if (bill.PORTLOADID == "CNTAO" && InttrEdi.filetype != "E")
+ {
+ tempstr += GetSpaceStr("", 3);//4 //Booking Party Code//O//X(3)//16 //18 //webcsm Partner Subcode//mandtory,订舱单位代码(customer code)
+ }
+ else
+ {
+ tempstr += GetSpaceStr("001", 3);//4 //Booking Party Code//O//X(3)//16 //18 //webcsm Partner Subcode//mandtory,订舱单位代码(customer code)
+ }
+ tempstr += GetSpaceStr("", 4);//5 //Filler//M//X(4)//19 //22 //Spaces
+ int iLs = InttrEdi.ForWarderName.Length / 35;
+ int iLs2 = InttrEdi.ForWarderName.Length % 35;
+ int n = 0;
+ for (int i = 0; i < iLs; i++)
+ {
+ tempstr += GetSpaceStr(InttrEdi.ForWarderName.Substring(i * 35, 35), 35);//6 //Booking Party-Item (1)//M//X(35)//23 //57 //Booking Party Name, Address line 1;
+ n = i + 1;
+ }
+ if (iLs < 6)
+ {
+ if (iLs2 > 0)
+ {
+ tempstr += GetSpaceStr(InttrEdi.ForWarderName.Substring(n * 35), 35);//6 //Booking Party-Item (1)//M//X(35)//23 //57 //Booking Party Name, Address line 1-6;
+ }
+ if ((iLs + 1) < 6)
+ {
+ for (int i = 0; i < (6 - iLs - 1); i++)
+ {
+ tempstr += GetSpaceStr("", 35);//6 //Booking Party-Item (1)//M//X(35)//23 //57 //Booking Party Name, Address line 6;
+ }
+ }
+ }
+ tempstr += GetSpaceStr("", 4);//12 //SCAC Code//O//X(4)//233 //236 //
+ tempstr += GetSpaceStr("", 14);//13 //Filler//M//X(14)//237 //250 //Spaces
+ tempstr = GetSpaceStr(tempstr, 236);
+ if (bill.BLFRT.IndexOf("FREIGHT PREPAID") > -1)//运费预付
+ {
+ tempstr += GetSpaceStr(bill.ShipperEdiCode, 10);//3 //Booking Party Code//O//X(10)//6 //15 //webcsm Partner Code
+ }
+ else
+ {
+ tempstr += GetSpaceStr(bill.ConsigneeEdiCode, 10);//3//Shipper Code//O//X(10)//6//15//webcsm Partner Code//mandtory for CIF shpts,预付必填
+ }
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 18
+
+ var contractno = bill.CONTRACTNO;
+
+ tempstr = "18";//1 //RECORD-ID//M//9(2)//1 //2 //18
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ //if (bill.CONTRACTNO == "")
+ //{
+ // if (bill.BLFRT == "FREIGHT PREPAID")
+ // {
+ // tempstr += GetSpaceStr(agent, 10);//3 //Deciding Party Code//O//X(10)//6 //15 //webcsm Partner Code//mandtory (DUM000001),填RFA;美国线的S/C或者TAA填写在record 74,美国线留空
+ // }
+ // else
+ // {
+ // tempstr += GetSpaceStr(cagent, 10);//3 //Deciding Party Code//O//X(10)//6 //15 //webcsm Partner Code//mandtory (DUM000001),填RFA;美国线的S/C或者TAA填写在record 74,美国线留空
+ // }
+ //}
+ //else
+ //{
+ // tempstr += GetSpaceStr(bill.CONTRACTNO, 10);//3 //Deciding Party Code//O//X(10)//6 //15 //webcsm Partner Code
+ //}
+ if (bill.BYCOUNTRY == "USA")
+ {
+ tempstr += GetSpaceStr("", 11);//3 //Deciding Party Code//O//X(10)//6 //15 //webcsm Partner Code//mandtory (DUM000001),填RFA;美国线的S/C或者TAA填写在record 74,美国线留空
+ }
+ else
+ {
+ if (contractno == "")
+ {
+ tempstr += GetSpaceStr("DUM000001", 11);//3 //Deciding Party Code//O//X(10)//6 //15 //webcsm Partner Code//mandtory (DUM000001),填RFA;美国线的S/C或者TAA填写在record 74,美国线留空
+ }
+ else
+ {
+ tempstr += GetSpaceStr(contractno, 11);//3 //Deciding Party Code//O//X(10)//6 //15 //webcsm Partner Code
+ }
+ }
+ if (bill.PORTLOADID == "CNTAO" && InttrEdi.filetype != "E")
+ {
+ tempstr += GetSpaceStr("", 2);//4 //Deciding Party Code//O//X(3)//16 //18 //webcsm Partner Subcode
+ }
+ else
+ {
+ tempstr += GetSpaceStr("01", 2);//4 //Deciding Party Code//O//X(3)//16 //18 //webcsm Partner Subcode
+ }
+ tempstr += GetSpaceStr("", 1);//5 //Special Rate Indicator//C//X(1)//19 //19 //Denote special account with fixed exchange rates (out from webCSM only)
+ tempstr += GetSpaceStr("", 3);//6 //Filler//M//X(3)//20 //22 //Spaces
+ Shipping = "";
+ if (bill.BLFRT == "FREIGHT PREPAID")
+ {
+ Shipping = bill.SHIPPER;
+ }
+ else
+ {
+ Shipping = bill.CONSIGNEE;
+ }
+ ShippingList = formatlengthStr(Shipping, 35);
+ for (var i = 0; i < ShippingList.Count; i++)
+ {
+ if (i <= 6)
+ {
+ tempstr += GetSpaceStr(ShippingList[i], 35);//7 //Deciding-Item (1)//M//X(35)//23 //57 //Deciding Party Name, Address line 1
+ }
+ }
+
+
+ //var iLS = ShippingList.Count - 6;
+ //if (iLS > 0)
+ //{
+ // for (var i = 0; i < iLS; i++)
+ // {
+ // tempstr += GetSpaceStr("", 35);//7 //Deciding-Item (1)//M//X(35)//23 //57 //Deciding Party Name, Address line 1
+ // }
+ //}
+ //7 //Deciding-Item (1)//M//X(35)//23 //57 //Deciding Party Name, Address line 1
+ //8 //Deciding-item (2)//M//X(35)//58 //92 //Deciding Party Name, Address line 2
+ //9 //Deciding-item (3)//M//X(35)//93 //127 //Deciding Party Name, Address line 3
+ //10 //Deciding-Item (4)//M//X(35)//128 //162 //Deciding Party Name, Address line 4
+ //11 //Deciding-item (5)//M//X(35)//163 //197 //Deciding Party Name, Address line 5
+ //12 //Deciding-item (6)//M//X(35)//198 //232 //Deciding Party Name, Address line 6
+ tempstr = GetSpaceStr(tempstr, 232);
+ tempstr += GetSpaceStr("", 4);//12 //SCAC Code//O//X(4)//233 //236 //
+ tempstr += GetSpaceStr(bill.SalesRepCode, 14);//13 //Filler//M//X(14)//237 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 21
+ tempstr = "21";//1 //RECORD-ID//M//9(2)//1 //2 //21
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ if (bill.BLFRT.IndexOf("FREIGHT COLLECT") > -1)//运费到付
+ {
+ tempstr += GetSpaceStr(bill.ConsigneeEdiCode, 10);//3 //Consignee Code//O//X(10)//6 //15 //webcsm Partner Code//mandtory for FOB shpts,收货人代码,到付必填。跟客服要
+ }
+ else
+ {
+ tempstr += GetSpaceStr("", 10);//3 //Consignee Code//O//X(10)//6 //15 //webcsm Partner Code//mandtory for FOB shpts,收货人代码,到付必填
+ }
+ tempstr += GetSpaceStr("", 3);//4 //Consignee Code//O//X(3)//16 //18 //webcsm Partner Subcode
+ tempstr += GetSpaceStr("", 4);//5 //Filler//M//X(4)//19 //22 //Spaces
+ Shipping = "";
+ Shipping = bill.CONSIGNEE;
+ ShippingList = formatlengthStr(Shipping, 35);
+ for (var i = 0; i < ShippingList.Count; i++)
+ {
+ if (i <= 6)
+ {
+ tempstr += GetSpaceStr(ShippingList[i], 35);//6 //Consignee item - (1)//M//X(35)//23 //57 //Consignee Name, Address line 1
+ }
+ }
+ //6 //Consignee item - (1)//M//X(35)//23 //57 //Consignee Name, Address line 1
+ //7 //Consignee item - (2)//M//X(35)//58 //92 //Consignee Name, Address line 2
+ //8 //Consignee item - (3)//M//X(35)//93 //127 //Consignee Name, Address line 3
+ //9 //Consignee item - (4)//M//X(35)//128 //162 //Consignee Name, Address line 4
+ //10 //Consignee item - (5)//M//X(35)//163 //197 //Consignee Name, Address line 5
+ //11 //Consignee item - (6)//M//X(35)//198 //232 //Consignee Name, Address line 6
+ //12 //SCAC Code//O//X(4)//233 //236 //
+ //13 //Filler//M//X(14)//237 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 26
+ tempstr = "26";//1 //RECORD-ID//M//9(2)//1 //2 //26
+ tempstr += GetSpaceStr("", 2);//2 //Filler//M//X(2)//3 //4 //Spaces
+ tempstr += "1";//3 //Notify Party Count//M//9(1)//5 //5 //I = 1 to 3 notify party
+ tempstr += GetSpaceStr("", 10);//4 //Notify Code//O//X(10)//6 //15 //webcsm Partner Code
+ tempstr += GetSpaceStr("", 3);//5 //Notify Code//O//X(3)//16 //18 //webcsm Partner Subcode
+ tempstr += GetSpaceStr("", 4);//6 //Filler//M//X(4)//19 //22 //Spaces
+ Shipping = "";
+ Shipping = bill.NOTIFYPARTY;
+ ShippingList = formatlengthStr(Shipping, 35);
+ for (var i = 0; i < ShippingList.Count; i++)
+ {
+ if (i <= 6)
+ {
+ tempstr += GetSpaceStr(ShippingList[i], 35);//7 //Notify Field-(1)//M//X(35)//23 //57 //Notify Party Name, Address line 1
+ }
+ }
+ //7 //Notify Field-(1)//M//X(35)//23 //57 //Notify Party Name, Address line 1
+ //8 //Notify Field-(2)//M//X(35)//58 //92 //Notify Party Name, Address line 2
+ //9 //Notify Field-(3)//M//X(35)//93 //127 //Notify Party Name, Address line 3
+ //10 //Notify Field-(4)//M//X(35)//128 //162 //Notify Party Name, Address line 4
+ //11 //Notify Field-(5)//M//X(35)//163 //197 //Notify Party Name, Address line 5
+ //12 //Notify Field-(6)//M//X(35)//198 //232 //Notify Party Name, Address line 6
+ //12 //SCAC Code//O//X(4)//233 //236 //
+ //13 //Filler//M//X(14)//237 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ var soc = "N";
+ if (bill.ISCONTAINERSOC)
+ {
+ soc = "S";
+ }
+ var ctnsumlist = new List();
+ foreach (var ctn in bill.CTNLIST)
+ {
+ var isfind = false;
+ ctnsumlist.ForEach(i =>
+ {
+ if (i.CTNALLCODE == ctn.CTNALLCODE)
+ {
+ i.CTNNUM = i.CTNNUM + ctn.CTNNUM;
+ i.KGS = i.KGS + ctn.KGS;
+ if (ctn.CTNALLCODE.IndexOf("40") > 0)
+ i.TEU = i.TEU + ctn.CTNNUM * 2;
+ else
+ i.TEU = i.TEU + ctn.CTNNUM * 1;
+ i.PKGS = i.PKGS + ctn.PKGS;
+ i.CBM = i.CBM + ctn.CBM;
+ i.CTNNUM = i.CTNNUM + ctn.CTNNUM;
+ isfind = true;
+ }
+ });
+ if (!isfind)
+ {
+ var ctnnum = new MsOpSeaeCtnEdiModel();
+ ctnnum.CTNALLCODE = ctn.CTNALLCODE;
+ ctnnum.KGS = ctn.KGS;
+ if (ctn.CTNALLCODE.IndexOf("40") > 0)
+ ctnnum.TEU = ctn.CTNNUM * 2;
+ else
+ ctnnum.TEU = ctn.CTNNUM * 1;
+ ctnnum.PKGS = ctn.PKGS;
+ ctnnum.CBM = ctn.CBM;
+ ctnnum.CTNNUM = ctn.CTNNUM;
+ ctnsumlist.Add(ctnnum);
+ }
+ }
+
+ var ctnline = 1;
+ foreach (var ctn in ctnsumlist)
+ {
+ if (InttrEdi.filetype == "E")
+ {
+ #region ESI
+ #region 41
+ tempstr = "41";//1 //RECORD-ID//M//9(2)//1 //2 //41
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence#//M//9(3)//6 //8 //001 to 999 (line-items)
+ if (bill.HSCODE.ToString().Length > 6)
+ {
+ tempstr += GetSpaceStr(bill.HSCODE.ToString().Substring(0, 6), 9);//4 //Commodity Code//M//X(9)//9 //17 //6 Digits HS CODE//mandtory,Hscode,必填,商品编码前6位
+ }
+ else
+ {
+ tempstr += GetSpaceStr(bill.HSCODE.ToString(), 9);//4 //Commodity Code//M//X(9)//9 //17 //6 Digits HS CODE//mandtory,Hscode,必填,商品编码前6位
+ }
+ tempstr += "Y";//5 //BL Override//M//X(1)//18 //18 //Y or N, Y=lumpsum weights used, (out from webCSM only)
+ tempstr += GetSpaceStr(ctn.CTNNUM.ToString(), 6, "0");//6 //No of packages/Containers//M//9(6)//19 //24 //Number of Containers for the cargo line
+ tempstr += GetSpaceStr(ctn.TEU.ToString(), 4, "0");//7 //TEU Utilisation//C//9(4)//25 //28 //Actual TEU utilised, eg. OOG's slot kill or Flatrack bundled units
+ tempstr += GetSpaceStr((ctn.KGS * 1000).ToString(), 11, "0");//8 //Cargo Gross Weight//C//9(8)v999//29 //39 //Mandatory, except for Empties
+ tempstr += GetSpaceStr("", 11, "0");//9 //Cargo Nett Weight//C//9(8)v999//40 //50 //Mandatory, except for Empties
+ tempstr += GetSpaceStr((ctn.CBM * 1000).ToString(), 10, "0");//10 //Cargo Gross Measurement//C//9(7)v999//51 //60 //Mandatory, except for Empties
+ tempstr += GetSpaceStr("", 10, "0");//11 //Cargo Nett Measurement//C//9(7)v999//61 //70 //Mandatory, except for Empties
+ tempstr += GetSpaceStr(bill.GOODSNAME, 48);//12 //Commodity Name//O//X(48)//71 //118 //
+ //tempstr += GetSpaceStr(GetGOODEDICode(bill.GOODSNAME), 4);//13 //webcsm Commodity Code//O//X(4)//119 //122 //webCSM Standard Commodity Code
+ tempstr += GetSpaceStr("", 4);//13 //webcsm Commodity Code//O//X(4)//119 //122 //webCSM Standard Commodity Code
+ tempstr += GetSpaceStr(ctn.CTNALLCODE, 4);//14 //webcsm Package Code//M//X(4)//123 //126 //eg 20GP, 40GP etc.
+ tempstr += "KGM";//15 //UOM Weight//M//X(3)//127 //129 //Default to METRIC = KGM
+ tempstr += "MTQ";//16 //UOM Measurement//M//X(3)//130 //132 //Default to METRIC = MTQ
+ tempstr += soc;//17 //Equipment Flag //M//X(1)//133 //133 //Y:COC cntr required, N:cntr not required, S:SOC//mandtory,只要有SOC箱子就要填S
+ tempstr += GetSpaceStr("", 117);//18 //Filler//M//X(117)//134 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 44
+ if (ctnline == 1)
+ {
+ Shipping = bill.MARKS;
+ ShippingList = formatlengthStr(Shipping, 20);
+ for (var i = 0; i < Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(ShippingList.Count) / Convert.ToDecimal(12))); i++)
+ {
+ tempstr = "44";//1 //RECORD-ID//M//9(2)//1 //2 //44
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence No#//M//9(3)//6 //8 //001 to 999 (line-items)
+ for (var z = 0; z < 12; z++)
+ {
+ if ((i * 12 + z) < ShippingList.Count)
+ {
+ tempstr += GetSpaceStr(ShippingList[i * 12 + z], 20);//4 //Mark-no-(1)//O//X(20)//9 //28
+ }
+ }
+ //4 //Mark-no-(1)//O//X(20)//9 //28 //
+ //5 //Mark-no-(2)//O//X(20)//29 //48 //
+ //6 //Mark-no-(3)//O//X(20)//49 //68 //
+ //7 //Mark-no-(4)//O//X(20)//69 //88 //
+ //8 //Mark-no-(5)//O//X(20)//89 //108 //
+ //9 //Mark-no-(6)//O//X(20)//109 //128 //
+ //10 //Mark-no-(7)//O//X(20)//129 //148 //
+ //11 //Mark-no-(8)//O//X(20)//149 //168 //
+ //12 //Mark-no-(9)//O//X(20)//169 //188 //
+ //13 //Mark-no-(10)//O//X(20)//189 //208 //
+ //14 //Mark-no-(11)//O//X(20)//209 //228 //
+ //15 //Mark-no-(12)//O//X(20)//229 //248 //
+ //16 //Filler//M//X(2)//249 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+ }
+ #endregion
+
+ #region 47
+ if (ctnline == 1)
+ {
+ Shipping = bill.DESCRIPTION;
+ ShippingList = formatlengthStr(Shipping, 30);
+ for (var i = 0; i < Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(ShippingList.Count) / Convert.ToDecimal(8))); i++)
+ {
+ tempstr = "47";//1 //RECORD-ID//M//9(2)//1 //2 //47
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence No#//M//9(3)//6 //8 //001 to 999 (line-items)
+ for (var z = 0; z < 8; z++)
+ {
+ if ((i * 8 + z) < ShippingList.Count)
+ {
+ tempstr += GetSpaceStr(ShippingList[i * 8 + z], 30);//4 //Cargo Description- (1)//O//X(30)//9 //38 //
+ }
+ }
+ //4 //Cargo Description- (1)//O//X(30)//9 //38 //
+ //5 //Cargo Description- (2)//O//X(30)//39 //68 //
+ //6 //Cargo Description- (3)//O//X(30)//69 //98 //
+ //7 //Cargo Description- (4)//O//X(30)//99 //128 //
+ //8 //Cargo Description- (5)//O//X(30)//129 //158 //
+ //9 //Cargo Description- (6)//O//X(30)//159 //188 //
+ //10 //Cargo Description- (7)//O//X(30)//189 //218 //
+ //11 //Cargo Description- (8)//O//X(30)//219 //248 //
+ //12 //Filler//M//X(2)//249 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+ }
+ #endregion
+
+
+ var m = 1;
+ foreach (var ctndetail in bill.CTNLIST)
+ {
+ if (ctndetail.CTNALLCODE == ctn.CTNALLCODE)
+ {
+ if (ctndetail.CTNSTATUS == "") ctndetail.CTNSTATUS = "F";
+
+ if (ctndetail.CNTRNO != "")
+ {
+ #region 51
+ tempstr = "51";//1//RECORD-ID//M//9(2)//1//2//51
+ tempstr += GetSpaceStr("", 3);//2//Filler//M//X(3)//3//5//Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3//Cargo Sequence No#//M//9(3)//6//8//001 to 999 (line-items)
+ tempstr += GetSpaceStr(m.ToString(), 3, "0");//4//Equipment Sequence No//M//9(3)//9//11//001 to 999
+ tempstr += GetSpaceStr(ctndetail.CNTRNO, 11);//5//Container No//M//X(11)//12//22//Container Number
+ if (bill.ISCONTAINERSOC)
+ {
+ tempstr += "Y";//6//Container SOC//M//X(1)//23//23//Y or N
+ }
+ else
+ {
+ tempstr += "N";//6//Container SOC//M//X(1)//23//23//Y or N
+ }
+ tempstr += ctn.CTNALLCODE;//7//Cntr Size/type code//M//X(4)//24//27//ISO Size/type eg 2200
+ tempstr += ctndetail.CTNSTATUS;//8//Cntr Loading Status//M//X(1)//28//28//F-Full, P-Part, E-Empty
+ tempstr += GetSpaceStr("", 3);//9//Cntr Operator//O//X(3)//29//31//
+ tempstr += GetSpaceStr("", 3);//10//UOM Weight//M//X(3)//32//34//Default to METRIC = KGM
+ tempstr += GetSpaceStr("", 3);//11//UOM Measurement//M//X(3)//35//37//Default to METRIC = MTQ
+ tempstr += GetSpaceStr("", 9);//12//Filler//M//X(9)//38//46//Spaces
+ tempstr += GetSpaceStr(ctndetail.PKGS.ToString(), 6, "0");//13//Cntr No of Packages//O//9(6)//47//52//Number of Packages in the Container
+ //tempstr += GetSpaceStr(ctndetail.KINDPKGS, 8);//14//Cntr Kind of Packages//O//X(8)//53//60//Package Description (limited to 8 characters)
+ tempstr += GetSpaceStr(ctndetail.KINDPKGS_EDI_CODE, 8);//14//Cntr Kind of Packages//O//X(8)//53//60//Package Description (limited to 8 characters)
+ tempstr += GetSpaceStr((ctndetail.KGS * 1000).ToString(), 9, "0");//15//Cntr Cargo Gross Weight//O//9(6)v999//61//69//Cargo Gross Weight per the container unit
+ tempstr += GetSpaceStr("", 9, "0");//16//Cntr Tare Weight//O//9(6)v999//70//78//Container Tare Weight
+ tempstr += GetSpaceStr((ctndetail.CBM * 1000).ToString(), 9, "0");//17//Cntr Cargo Measurement//O//9(6)v999//79//87//Measurement per the container unit
+ tempstr += GetSpaceStr("", 9, "0");//18//Cntr Cargo Net Weight//O//9(6)v999//88//96//Cargo Net Weight per the container unit
+ tempstr += GetSpaceStr(ctndetail.KINDPKGS_EDI_CODE, 5);//19//webCSM Package Code//O//X(5)//97//101//Package code within the container eg BX (boxes)
+ tempstr += GetSpaceStr("", 20);//20//Seal No (Shipper)//O//X(20)//102//121//Shipper's Seal Number
+ tempstr += GetSpaceStr(ctndetail.SEALNO, 20);//21//Seal No (Carrier)//O//X(20)//122//141//Carrier's Seal Number
+ tempstr += GetSpaceStr("", 20);//22//Seal No (Customs)//O//X(20)//142//161//Customs' Seal Number
+ tempstr += GetSpaceStr("", 20);//23//Seal No (Others)//O//X(20)//162//181//4th Seal Number
+ tempstr += GetSpaceStr("", 1);//24//Shortship Flag//C//X(1)//182//182//Y:Shortship, S:Shortland, O:Overland, else leave blank
+ tempstr += GetSpaceStr("", 20);//25//Part BL Cross-reference (Their Ref)//C//X(20)//183//202//Cross-ref to Main/Sub OBL of Part containers, only applicable to Part BLs
+ tempstr += GetSpaceStr("", 48);//26//Filler//M//X(48)//203//250//Spaces
+
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+ }
+
+ if (bill.CARGOID == "R")
+ {
+ #region 54 冻柜
+ var tmpset = "";
+ if (bill.TEMPSET.IndexOf("-") >= 0)
+ {
+ tmpset = "-";
+ }
+ else
+ {
+ tmpset = "0";
+ }
+ bill.TEMPSET = bill.TEMPSET.Replace("+", "").Replace("-", "");
+
+ tempstr = "54";//1 //RECORD-ID//M//9(2)//1 //2 //54
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence No#//货物的序列号//M//9(3)//6 //8 //001 to 999 (line-items)
+ tempstr += GetSpaceStr(m.ToString(), 3, "0");//4 //Equipment Sequence No设备序列号//M//9(3)//9 //11 //001 to 999
+ tempstr += "C";//5 //Reefer Temperature UOM冷藏温度计量单位//M//X(1)//12 //12 //C or F (C=Celsius, F=Fahrenheit)
+ tempstr += GetSpaceStr("", 5);//6 //Reefer Min Temperature//C//9(3)v99//13 //17 //If MAX exists, MIN should exists
+ tempstr += GetSpaceStr("", 5);//7 //Reefer Max Temperature//C//9(3)v99//18 //22 //If MIN exists, MAX should exists
+ tempstr += tmpset + GetSpaceStr((Convert.ToDecimal(bill.TEMPSET) * 100).ToString(), 4, "0");//8 //Reefer Preset Temperature冷藏温度设定//C//9(3)v99//23 //27 //Blank if no Preset required
+ tempstr += "N";//9 //Reefer Gensets Required冷藏机组的要求//M//X(1)//28 //28 //Y or N
+ if (bill.REEFERF != "")
+ {
+ tempstr += GetSpaceStr((Convert.ToDecimal(bill.REEFERF) * 100).ToString(), 5, "0");//10 //Reefer Vent Open Value冷藏等开放价值//C//9(3)v99//29 //33 //Blank if Vent Status = 'Closed', else value in relation to Vent UOM如果等待空白状态=“闭合”,其他的值等计量单位
+ }
+ else
+ {
+ tempstr += GetSpaceStr("", 5);//10 //Reefer Vent Open Value冷藏等开放价值//C//9(3)v99//29 //33 //Blank if Vent Status = 'Closed', else value in relation to Vent UOM如果等待空白状态=“闭合”,其他的值等计量单位
+ }
+ tempstr += "Y";//11 //Pretrip Flag//M//X(1)//34 //34 //Y or N
+ tempstr += tmpset + GetSpaceStr((Convert.ToDecimal(bill.TEMPSET) * 100).ToString(), 4, "0");//12 //Carriage Temperature运输温度//C//9(3)v99//35 //39 //For operating reefers, at least one temperature field must not be blank
+ if (bill.REEFERF != "")
+ {
+ tempstr += "H";//13 //Reefer Vent Status冷藏通风状况/UOM//C//X(1)//40 //40 //C:Closed, F:CFM, H:M3/H, P:Percentage, O:Open
+ }
+ else
+ {
+ tempstr += "C";//13 //Reefer Vent Status冷藏通风状况/UOM//C//X(1)//40 //40 //C:Closed, F:CFM, H:M3/H, P:Percentage, O:Open
+ }
+ tempstr += GetSpaceStr("", 210);//14 //Filler//M//X(210)//41 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+ }
+ else if (bill.CARGOID == "D")
+ {
+ #region 55 危险品紧急联系信息
+ tempstr = "55";//1//RECORD-ID//M//9(2)//1//2//55//record-id
+ tempstr += GetSpaceStr("", 1);//2//Filler//M//X(1)//3//3//Spaces//填料
+ tempstr += "01";//3//DG Sequence No//M//9(2)//4//5//Default to "01", Rec 55 is needed only once for each equipment seq//DG的序列号
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//4//Cargo Sequence No#//M//9(3)//6//8//001 to 999 (line-items)//货物没有#序列
+ tempstr += GetSpaceStr(m.ToString(), 3, "0");//5//Equipment Sequence No//M//9(3)//9//11//001 to 999//设备序列号
+ tempstr += GetSpaceStr(bill.EDIATTN, 35);//6//Emergency Contact//O//X(35)//12//46////急救联系
+ tempstr += GetSpaceStr("", 35);//7//Emergency Tel//O//X(35)//47//81////急救电话
+ tempstr += GetSpaceStr("", 100);//8//Emergency Email//O//X(100)//82//181////急救的电子邮件
+ tempstr += GetSpaceStr("", 20);//9//Emergency Reference//O//X(20)//182//201////急救参考
+ tempstr += GetSpaceStr("", 49);//10//Filler//M//X(49)//202//250//Spaces//填料
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 56 危险品//56 01001001//2556//a//4.1 //2 //KGM//008220000//009516000//N
+ tempstr = "56";//1//RECORD-ID M 9(2) 1//2//56
+ tempstr += GetSpaceStr("", 1);//2//Filler M X(1) 3//3//Spaces 填料
+ tempstr += GetSpaceStr("01", 2);//3//DG Sequence No M 9(2) 4//5//01 to 99, to denote multiple DG items in each equipment seq (cntr) DG的序列号
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//4//Cargo Sequence No# M 9(3) 6//8//001 to 999 (line-items)//货物没有#序列
+ tempstr += GetSpaceStr(m.ToString(), 3, "0");//5//Equipment Sequence No M 9(3) 9//11//001 to 999 设备序列号
+ tempstr += GetSpaceStr(bill.DUNNO, 4);//6//UN Number M X(4) 12//15// 联合国编号
+ tempstr += GetSpaceStr("", 1);//7//UN Variant M X(1) 16//16// 联合国的变体
+ tempstr += GetSpaceStr(bill.DCLASS, 4);//8//IMO Class M X(4) 17//20// 国际海事组织类
+ tempstr += GetSpaceStr("", 3);//9//PSA Class O X(3) 21//23// PSA类
+ tempstr += "KGM";//10//UOM M X(3) 24//26//Default to METRIC, eg. KGM 计量单位
+ tempstr += GetSpaceStr(((ctn.KGS - ctn.TAREWEIGHT) * 1000).ToString(), 9, "0");//11//Net Weight C 9(6)v999 27//35//Weight of DG item 净重量
+ tempstr += GetSpaceStr((ctn.KGS * 1000).ToString(), 9, "0");//12//Gross Weight C 9(6)v999 36//44//Weight of DG item 总重量
+ tempstr += "N";//13//Marine Pollutant M X(1) 45//45//Y or N 海洋污染物
+ tempstr += GetSpaceStr(bill.DPAGE, 10);//14//IMDG Page O X(10) 46//55// 危规页码
+ tempstr += GetSpaceStr("", 4);//15//DOT Packaging Group O X(4) 56//59// 点包装集团
+ tempstr += GetSpaceStr("", 10);//16//Filler M X(10) 60//69//Spaces 填料
+ tempstr += GetSpaceStr("", 25);//17//Flashpoint O X(25) 70//94// 闪点
+ tempstr += GetSpaceStr("", 3);//18//Packing Group O X(3) 95//97// 包装组
+ tempstr += GetSpaceStr(ctndetail.KINDPKGS_EDI_CODE, 5);//19//Outer Package Code O X(5) 98//102//webCSM Package Code 外包装编码
+ tempstr += GetSpaceStr(ctndetail.PKGS.ToString(), 9, "0");//20//Outer Quantity O 9(9) 103//111// 外量
+ tempstr += GetSpaceStr("", 5);//21//Inner Package Code O X(5) 112//116//webCSM Package Code 内包装代码
+ tempstr += GetSpaceStr("", 9);//22//Inner Quantity O 9(9) 117//125// 内部变量
+ tempstr += GetSpaceStr("", 5);//23//Next Inner Package Code O X(5) 126//130//webCSM Package Code 下一个内部包代码
+ tempstr += GetSpaceStr("", 9);//24//Next Inner Quantity O 9(9) 131//139// 下一个内部变量
+ tempstr += GetSpaceStr("", 50);//25//Chemical Name O X(50) 140//189// 化学名称
+ tempstr += GetSpaceStr("", 20);//26//Our Reference O X(20) 190//209// 我们的参考
+ tempstr += GetSpaceStr("", 21);//28//Filler M X(21) 230//250//Spaces 填料
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+ }
+ m = m + 1;
+ }
+ }
+ #endregion
+ }
+ else
+ {
+ #region EDI
+ #region 41
+ tempstr = "41";//1 //RECORD-ID//M//9(2)//1 //2 //41
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence#//M//9(3)//6 //8 //001 to 999 (line-items)
+ //tempstr += GetSpaceStr(GetGOODEDICode(bill.GOODSNAME), 9);//4 //Commodity Code//M//X(9)//9 //17 //6 Digits HS CODE
+ if (bill.HSCODE.ToString().Length > 6)
+ {
+ tempstr += GetSpaceStr(bill.HSCODE.ToString().Substring(0, 6), 9);//4 //Commodity Code//M//X(9)//9 //17 //6 Digits HS CODE
+ }
+ else
+ {
+ tempstr += GetSpaceStr(bill.HSCODE.ToString(), 9);//4 //Commodity Code//M//X(9)//9 //17 //6 Digits HS CODE
+ }
+ tempstr += "Y";//5 //BL Override//M//X(1)//18 //18 //Y or N, Y=lumpsum weights used, (out from webCSM only)
+ tempstr += GetSpaceStr(ctn.CTNNUM.ToString(), 6, "0");//6 //No of packages/Containers//M//9(6)//19 //24 //Number of Containers for the cargo line
+ tempstr += GetSpaceStr(ctn.TEU.ToString(), 4, "0");//7 //TEU Utilisation//C//9(4)//25 //28 //Actual TEU utilised, eg. OOG's slot kill or Flatrack bundled units
+ tempstr += GetSpaceStr((ctn.KGS * 1000).ToString(), 11, "0");//8 //Cargo Gross Weight//C//9(8)v999//29 //39 //Mandatory, except for Empties
+ tempstr += GetSpaceStr("", 11, "0");//9 //Cargo Nett Weight//C//9(8)v999//40 //50 //Mandatory, except for Empties
+ tempstr += GetSpaceStr((ctn.CBM * 1000).ToString(), 10, "0");//10 //Cargo Gross Measurement//C//9(7)v999//51 //60 //Mandatory, except for Empties
+ tempstr += GetSpaceStr("", 10, "0");//11 //Cargo Nett Measurement//C//9(7)v999//61 //70 //Mandatory, except for Empties
+ tempstr += GetSpaceStr(bill.GOODSNAME, 48);//12 //Commodity Name//O//X(48)//71 //118 //
+ //tempstr += GetSpaceStr(GetGOODEDICode(bill.GOODSNAME), 4);//13 //webcsm Commodity Code//O//X(4)//119 //122 //webCSM Standard Commodity Code
+ tempstr += GetSpaceStr("", 4);//13 //webcsm Commodity Code//O//X(4)//119 //122 //webCSM Standard Commodity Code
+ tempstr += GetSpaceStr(ctn.CTNALLCODE, 4);//14 //webcsm Package Code//M//X(4)//123 //126 //eg 20GP, 40GP etc.
+ tempstr += "MTQ";//15 //UOM Weight//M//X(3)//127 //129 //Default to METRIC = KGM
+ tempstr += "MTQ";//16 //UOM Measurement//M//X(3)//130 //132 //Default to METRIC = MTQ
+ tempstr += soc;//17 //Equipment Flag //M//X(1)//133 //133 //Y:COC cntr required, N:cntr not required, S:SOC
+ tempstr += GetSpaceStr("", 117);//18 //Filler//M//X(117)//134 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 44
+ Shipping = bill.MARKS;
+ ShippingList = formatlengthStr(Shipping, 20);
+ for (var i = 0; i < Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(ShippingList.Count) / Convert.ToDecimal(12))); i++)
+ {
+ tempstr = "44";//1 //RECORD-ID//M//9(2)//1 //2 //44
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence No#//M//9(3)//6 //8 //001 to 999 (line-items)
+ for (var z = 0; z < 12; z++)
+ {
+ if ((i * 12 + z) < ShippingList.Count)
+ {
+ tempstr += GetSpaceStr(ShippingList[i * 12 + z], 20);//4 //Mark-no-(1)//O//X(20)//9 //28
+ }
+ }
+ //4 //Mark-no-(1)//O//X(20)//9 //28 //
+ //5 //Mark-no-(2)//O//X(20)//29 //48 //
+ //6 //Mark-no-(3)//O//X(20)//49 //68 //
+ //7 //Mark-no-(4)//O//X(20)//69 //88 //
+ //8 //Mark-no-(5)//O//X(20)//89 //108 //
+ //9 //Mark-no-(6)//O//X(20)//109 //128 //
+ //10 //Mark-no-(7)//O//X(20)//129 //148 //
+ //11 //Mark-no-(8)//O//X(20)//149 //168 //
+ //12 //Mark-no-(9)//O//X(20)//169 //188 //
+ //13 //Mark-no-(10)//O//X(20)//189 //208 //
+ //14 //Mark-no-(11)//O//X(20)//209 //228 //
+ //15 //Mark-no-(12)//O//X(20)//229 //248 //
+ //16 //Filler//M//X(2)//249 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+ #endregion
+
+ if (ctnline == 1)
+ {
+ #region 47
+ tempstr = "47";//1 //RECORD-ID//M//9(2)//1 //2 //47
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence No#//M//9(3)//6 //8 //001 to 999 (line-items)
+ tempstr += bill.PKGS.ToString() + bill.KINDPKGS;//4 //Cargo Description- (1)//O//X(30)//9 //38 //
+ //5 //Cargo Description- (2)//O//X(30)//39 //68 //
+ //6 //Cargo Description- (3)//O//X(30)//69 //98 //
+ //7 //Cargo Description- (4)//O//X(30)//99 //128 //
+ //8 //Cargo Description- (5)//O//X(30)//129 //158 //
+ //9 //Cargo Description- (6)//O//X(30)//159 //188 //
+ //10 //Cargo Description- (7)//O//X(30)//189 //218 //
+ //11 //Cargo Description- (8)//O//X(30)//219 //248 //
+ //12 //Filler//M//X(2)//249 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+ }
+
+ #region 47 description
+ Shipping = bill.DESCRIPTION;
+ ShippingList = formatlengthStr(Shipping, 30);
+ for (var i = 0; i < Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(ShippingList.Count) / Convert.ToDecimal(8))); i++)
+ {
+ tempstr = "47";//1 //RECORD-ID//M//9(2)//1 //2 //47
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence No#//M//9(3)//6 //8 //001 to 999 (line-items)
+ for (var z = 0; z < 8; z++)
+ {
+ if ((i * 8 + z) < ShippingList.Count)
+ {
+ tempstr += GetSpaceStr(ShippingList[i * 8 + z], 30);//4 //Cargo Description- (1)//O//X(30)//9 //38 //
+ }
+ }
+ //4 //Cargo Description- (1)//O//X(30)//9 //38 //
+ //5 //Cargo Description- (2)//O//X(30)//39 //68 //
+ //6 //Cargo Description- (3)//O//X(30)//69 //98 //
+ //7 //Cargo Description- (4)//O//X(30)//99 //128 //
+ //8 //Cargo Description- (5)//O//X(30)//129 //158 //
+ //9 //Cargo Description- (6)//O//X(30)//159 //188 //
+ //10 //Cargo Description- (7)//O//X(30)//189 //218 //
+ //11 //Cargo Description- (8)//O//X(30)//219 //248 //
+ //12 //Filler//M//X(2)//249 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+ #endregion
+
+ for (var m = 1; m <= ctn.CTNNUM; ++m)
+ {
+ if (bill.CARGOID == "R")
+ {
+ #region 54 冻柜
+ var tmpset = "";
+ if (bill.TEMPSET.IndexOf("-") >= 0)
+ tmpset = "-";
+ else
+ tmpset = "0";
+ bill.TEMPSET = bill.TEMPSET.Replace("+", "").Replace("-", "");
+
+ tempstr = "54";//1 //RECORD-ID//M//9(2)//1 //2 //54
+ tempstr += GetSpaceStr("", 3);//2 //Filler//M//X(3)//3 //5 //Spaces
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//3 //Cargo Sequence No#//货物的序列号//M//9(3)//6 //8 //001 to 999 (line-items)
+ tempstr += GetSpaceStr(m.ToString(), 3, "0");//4 //Equipment Sequence No设备序列号//M//9(3)//9 //11 //001 to 999
+ tempstr += "C";//5 //Reefer Temperature UOM冷藏温度计量单位//M//X(1)//12 //12 //C or F (C=Celsius, F=Fahrenheit)
+ tempstr += GetSpaceStr("", 5);//6 //Reefer Min Temperature//C//9(3)v99//13 //17 //If MAX exists, MIN should exists
+ tempstr += GetSpaceStr("", 5);//7 //Reefer Max Temperature//C//9(3)v99//18 //22 //If MIN exists, MAX should exists
+ tempstr += tmpset + GetSpaceStr((Convert.ToDecimal(bill.TEMPSET) * 100).ToString(), 4, "0");//8 //Reefer Preset Temperature冷藏温度设定//C//9(3)v99//23 //27 //Blank if no Preset required
+ tempstr += "N";//9 //Reefer Gensets Required冷藏机组的要求//M//X(1)//28 //28 //Y or N
+ if (bill.REEFERF != "")
+ {
+ tempstr += GetSpaceStr((Convert.ToDecimal(bill.REEFERF) * 100).ToString(), 5, "0");//10 //Reefer Vent Open Value冷藏等开放价值//C//9(3)v99//29 //33 //Blank if Vent Status = 'Closed', else value in relation to Vent UOM如果等待空白状态=“闭合”,其他的值等计量单位
+ }
+ else
+ {
+ tempstr += GetSpaceStr("", 5);//10 //Reefer Vent Open Value冷藏等开放价值//C//9(3)v99//29 //33 //Blank if Vent Status = 'Closed', else value in relation to Vent UOM如果等待空白状态=“闭合”,其他的值等计量单位
+ }
+ tempstr += "Y";//11 //Pretrip Flag//M//X(1)//34 //34 //Y or N
+ tempstr += tmpset + GetSpaceStr((Convert.ToDecimal(bill.TEMPSET) * 100).ToString(), 4, "0");//12 //Carriage Temperature运输温度//C//9(3)v99//35 //39 //For operating reefers, at least one temperature field must not be blank
+ if (bill.REEFERF != "")
+ {
+ tempstr += "H";//13 //Reefer Vent Status冷藏通风状况/UOM//C//X(1)//40 //40 //C:Closed, F:CFM, H:M3/H, P:Percentage, O:Open
+ }
+ else
+ {
+ tempstr += "C";//13 //Reefer Vent Status冷藏通风状况/UOM//C//X(1)//40 //40 //C:Closed, F:CFM, H:M3/H, P:Percentage, O:Open
+ }
+ tempstr += GetSpaceStr("", 210);//14 //Filler//M//X(210)//41 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+ }
+ else if (bill.CARGOID == "D")
+ {
+ #region 55 危险品紧急联系信息
+ tempstr = "55";//1//RECORD-ID//M//9(2)//1//2//55//record-id
+ tempstr += GetSpaceStr("", 1);//2//Filler//M//X(1)//3//3//Spaces//填料
+ tempstr += "01";//3//DG Sequence No//M//9(2)//4//5//Default to "01", Rec 55 is needed only once for each equipment seq//DG的序列号
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//4//Cargo Sequence No#//M//9(3)//6//8//001 to 999 (line-items)//货物没有#序列
+ tempstr += GetSpaceStr(m.ToString(), 3, "0");//5//Equipment Sequence No//M//9(3)//9//11//001 to 999//设备序列号
+ tempstr += GetSpaceStr(bill.EDIATTN, 35);//6//Emergency Contact//O//X(35)//12//46////急救联系
+ tempstr += GetSpaceStr("", 35);//7//Emergency Tel//O//X(35)//47//81////急救电话
+ tempstr += GetSpaceStr("", 100);//8//Emergency Email//O//X(100)//82//181////急救的电子邮件
+ tempstr += GetSpaceStr("", 20);//9//Emergency Reference//O//X(20)//182//201////急救参考
+ tempstr += GetSpaceStr("", 49);//10//Filler//M//X(49)//202//250//Spaces//填料
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ #region 56 危险品//56 01001001//2556//a//4.1 //2 //KGM//008220000//009516000//N
+ tempstr = "56";//1//RECORD-ID M 9(2) 1//2//56
+ tempstr += GetSpaceStr("", 1);//2//Filler M X(1) 3//3//Spaces 填料
+ tempstr += GetSpaceStr("01", 2);//3//DG Sequence No M 9(2) 4//5//01 to 99, to denote multiple DG items in each equipment seq (cntr) DG的序列号
+ tempstr += GetSpaceStr(ctnline.ToString(), 3, "0");//4//Cargo Sequence No# M 9(3) 6//8//001 to 999 (line-items)//货物没有#序列
+ tempstr += GetSpaceStr(m.ToString(), 3, "0");//5//Equipment Sequence No M 9(3) 9//11//001 to 999 设备序列号
+ tempstr += GetSpaceStr(bill.DUNNO, 4);//6//UN Number M X(4) 12//15// 联合国编号
+ tempstr += GetSpaceStr("", 1);//7//UN Variant M X(1) 16//16// 联合国的变体
+ tempstr += GetSpaceStr(bill.DCLASS, 4);//8//IMO Class M X(4) 17//20// 国际海事组织类
+ tempstr += GetSpaceStr("", 3);//9//PSA Class O X(3) 21//23// PSA类
+ tempstr += "KGM";//10//UOM M X(3) 24//26//Default to METRIC, eg. KGM 计量单位
+ tempstr += GetSpaceStr(((ctn.KGS - ctn.TAREWEIGHT) * 1000).ToString(), 9, "0");//11//Net Weight C 9(6)v999 27//35//Weight of DG item 净重量
+ tempstr += GetSpaceStr((ctn.KGS * 1000).ToString(), 9, "0");//12//Gross Weight C 9(6)v999 36//44//Weight of DG item 总重量
+ tempstr += "N";//13//Marine Pollutant M X(1) 45//45//Y or N 海洋污染物
+ tempstr += GetSpaceStr(bill.DPAGE, 10);//14//IMDG Page O X(10) 46//55// 危规页码
+ tempstr += GetSpaceStr("", 4);//15//DOT Packaging Group O X(4) 56//59// 点包装集团
+ tempstr += GetSpaceStr("", 10);//16//Filler M X(10) 60//69//Spaces 填料
+ tempstr += GetSpaceStr("", 25);//17//Flashpoint O X(25) 70//94// 闪点
+ tempstr += GetSpaceStr("", 3);//18//Packing Group O X(3) 95//97// 包装组
+ tempstr += GetSpaceStr(ctn.KINDPKGS_EDI_CODE, 5);//19//Outer Package Code O X(5) 98//102//webCSM Package Code 外包装编码
+ tempstr += GetSpaceStr(ctn.PKGS.ToString(), 9, "0");//20//Outer Quantity O 9(9) 103//111// 外量
+ tempstr += GetSpaceStr("", 5);//21//Inner Package Code O X(5) 112//116//webCSM Package Code 内包装代码
+ tempstr += GetSpaceStr("", 9);//22//Inner Quantity O 9(9) 117//125// 内部变量
+ tempstr += GetSpaceStr("", 5);//23//Next Inner Package Code O X(5) 126//130//webCSM Package Code 下一个内部包代码
+ tempstr += GetSpaceStr("", 9);//24//Next Inner Quantity O 9(9) 131//139// 下一个内部变量
+ tempstr += GetSpaceStr("", 50);//25//Chemical Name O X(50) 140//189// 化学名称
+ tempstr += GetSpaceStr("", 20);//26//Our Reference O X(20) 190//209// 我们的参考
+ tempstr += GetSpaceStr("", 21);//28//Filler M X(21) 230//250//Spaces 填料
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+ }
+ }
+ #endregion
+ }
+ ctnline = ctnline + 1;
+ }
+
+ #region 73
+ tempstr = "73";//1 //RECORD_ID//M//9(2)//1 //2 //73
+ tempstr += "B";//2 //Remarks_indicator//M//X(1)//3 //3 //O-Onhold, B-Booking, C-Customs, M-Manifest, X-Special, A-Additional, G-General, T-Transhipment, E-EDI //"73B,必填内容:1)SALES REP CODE;2)ACI HBL (1,2,3);加拿大线的HBL3) 货物混装描述 (S0C+C0C)"//分三行
+ //3 //Remarks Text//O//X(120)//4 //123 //RemarksGetCustEdi(bill.YARD,120)
+ //4 //Filler//M//X(127)//124 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+
+ if (bill.ACIHBL != "")
+ {
+ tempstr = "73";//1 //RECORD_ID//M//9(2)//1 //2 //73
+ tempstr += "B";//2 //Remarks_indicator//M//X(1)//3 //3 //O-Onhold, B-Booking, C-Customs, M-Manifest, X-Special, A-Additional, G-General, T-Transhipment, E-EDI //"73B,必填内容:1)SALES REP CODE;2)ACI HBL (1,2,3);加拿大线的HBL3) 货物混装描述 (S0C+C0C)"//分三行
+ tempstr += GetSpaceStr(bill.ACIHBL, 120);//3 //Remarks Text//O//X(120)//4 //123 //RemarksGetCustEdi(bill.YARD,120)
+ //4 //Filler//M//X(127)//124 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+
+ if (bill.S0CC0C != "")
+ {
+ tempstr = "73";//1 //RECORD_ID//M//9(2)//1 //2 //73
+ tempstr += "B";//2 //Remarks_indicator//M//X(1)//3 //3 //O-Onhold, B-Booking, C-Customs, M-Manifest, X-Special, A-Additional, G-General, T-Transhipment, E-EDI //"73B,必填内容:1)SALES REP CODE;2)ACI HBL (1,2,3);加拿大线的HBL3) 货物混装描述 (S0C+C0C)"//分三行
+ tempstr += GetSpaceStr(bill.S0CC0C, 120);//3 //Remarks Text//O//X(120)//4 //123 //RemarksGetCustEdi(bill.YARD,120)
+ //4 //Filler//M//X(127)//124 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+ //欧盟港口、伊朗港口、KHI
+ if (bill.cKHI != "")
+ {
+ Shipping = bill.cKHI;
+ List ShippingListLs = formatlengthStr(Shipping, 120);
+ for (var i = 0; i < ShippingListLs.Count; i++)
+ {
+ tempstr = "73";//1 //RECORD_ID//M//9(2)//1 //2 //73
+ tempstr += "C";//2 //Remarks_indicator//M//X(1)//3 //3 //O-Onhold, B-Booking, C-Customs, M-Manifest, X-Special, A-Additional, G-General, T-Transhipment, E-EDI //"73B,必填内容:1)SALES REP CODE;2)ACI HBL (1,2,3);加拿大线的HBL3) 货物混装描述 (S0C+C0C)"//分三行
+ tempstr += GetSpaceStr(ShippingListLs[i], 120);//3 //Remarks Text//O//X(120)//4 //123 //RemarksGetCustEdi(bill.YARD,120)
+ //4 //Filler//M//X(127)//124 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+ }
+
+ //南美东
+ if (bill.cNCM != "")
+ {
+ Shipping = bill.cNCM;
+ List ShippingListLs = formatlengthStr(Shipping, 120);
+ for (var i = 0; i < ShippingListLs.Count; i++)
+ {
+ tempstr = "73";//1 //RECORD_ID//M//9(2)//1 //2 //73
+ tempstr += "C";//2 //Remarks_indicator//M//X(1)//3 //3 //O-Onhold, B-Booking, C-Customs, M-Manifest, X-Special, A-Additional, G-General, T-Transhipment, E-EDI //"73B,必填内容:1)SALES REP CODE;2)ACI HBL (1,2,3);加拿大线的HBL3) 货物混装描述 (S0C+C0C)"//分三行
+ tempstr += GetSpaceStr(ShippingListLs[i], 120);//3 //Remarks Text//O//X(120)//4 //123 //RemarksGetCustEdi(bill.YARD,120)
+ //4 //Filler//M//X(127)//124 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+ }
+
+ //巴西线的木质包装情况
+ if (bill.wNCM != "")
+ {
+ Shipping = bill.wNCM;
+ List ShippingListLs = formatlengthStr(Shipping, 120);
+ for (var i = 0; i < ShippingListLs.Count; i++)
+ {
+ tempstr = "73";//1 //RECORD_ID//M//9(2)//1 //2 //73
+ tempstr += "W";//2 //Remarks_indicator//M//X(1)//3 //3 //O-Onhold, B-Booking, C-Customs, M-Manifest, X-Special, A-Additional, G-General, T-Transhipment, E-EDI //"73B,必填内容:1)SALES REP CODE;2)ACI HBL (1,2,3);加拿大线的HBL3) 货物混装描述 (S0C+C0C)"//分三行
+ tempstr += GetSpaceStr(ShippingListLs[i], 120);//3 //Remarks Text//O//X(120)//4 //123 //RemarksGetCustEdi(bill.YARD,120)
+ //4 //Filler//M//X(127)//124 //250 //Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ }
+ }
+ }
+
+ #endregion
+
+ #region 74
+ tempstr = "74";//1//RECORD-ID//M//9(2)//1//2//74//
+ tempstr += GetSpaceStr("", 3);//2//Filler//O//X(3)//3//5//Spaces//
+ tempstr += GetSpaceStr(bill.ISSUEPLACEID, 5);//3//Place of BL issue//M//X(5)//6//10//webCSM Port code (Port of BL Issuance)//提单签发地//webcsm港口代码(BL发行端口)
+ if (bill.ISSUEDATE.ToString().Trim() == "")
+ {
+ tempstr += GetSpaceStr("", 8);//4//Date of BL issue//M//X(8)//11//18//YYYYMMDD//提单签发日期//年月日
+ }
+ else
+ {
+ tempstr += GetDateStr(bill.ISSUEDATE, "yyyyMMdd");//4//Date of BL issue//M//X(8)//11//18//YYYYMMDD//提单签发日期//年月日
+ }
+ tempstr += GetSpaceStr("", 4);//5//Department Code//M//X(4)//19//22//webCSM Department Code (eg SG00) (out from webCSM only)//部门代码//webcsm部门代码(如sg00)(从webcsm只)
+ tempstr += GetSpaceStr("", 3);//6//Booking Agent Code//M//X(3)//23//25//webCSM Booking Agent Code (eg SIN)//订舱代理代码//webcsm订舱代理代码(如犯罪)
+ if (bill.ISSUETYPE.ToString().Trim().ToUpper() == "WAYBILL")
+ {
+ tempstr += GetSpaceStr("W", 1);//7//BOL Type//M//X(1)//26//26//N-Nominal, G-Negotiable, S-Switch, W-Waybill, M-Memo//公司类型//n-nominal,g-negotiable,S-开关,w-waybill,m-memo
+ }
+ else
+ {
+ tempstr += GetSpaceStr("N", 1);//7//BOL Type//M//X(1)//26//26//N-Nominal, G-Negotiable, S-Switch, W-Waybill, M-Memo//公司类型//n-nominal,g-negotiable,S-开关,w-waybill,m-memo
+ }
+ //tempstr += GetSpaceStr(GetBillNum(bill.NOBILL.ToString().Trim()), 2, "0");//8//No. of Original BLs//O//9(2)//27//28//号原BLS//
+ //tempstr += GetSpaceStr(GetBillNum(bill.COPYNOBILL.ToString().Trim()), 2, "0");//9//No. of Copy BLs//O//9(2)//29//30//不复制BLS//
+ tempstr += GetSpaceStr("", 2);//8//No. of Original BLs//O//9(2)//27//28//号原BLS//太平要求去掉
+ tempstr += GetSpaceStr("", 2);//9//No. of Copy BLs//O//9(2)//29//30//不复制BLS//太平要求去掉
+ if (bill.BYCOUNTRY == "USA")
+ {
+ tempstr += GetSpaceStr(bill.CONTRACTNO, 10);//10//Service Contract #//C//X(10)//31//40//Applicable to US shipments only//"mandtory for US shpts---Service Contract Nbr/TAA Nbr"//美国线的S/C,TAA//服务合同#//只适用于美国装运
+ }
+ else
+ {
+ tempstr += GetSpaceStr("", 10);//10//Service Contract #//C//X(10)//31//40//Applicable to US shipments only//"mandtory for US shpts---Service Contract Nbr/TAA Nbr"//美国线的S/C,TAA//服务合同#//只适用于美国装运
+ }
+ tempstr += GetSpaceStr("", 5);//11//Prepaid at (Port code)//M//X(5)//41//45//Ocean Freight Payment Location//预付(港码)//海运付款地点
+ tempstr += GetSpaceStr("", 5);//12//Payable at (Port Code)//M//X(5)//46//50//1st Collect Charge Payment Location//按(港口代码)支付//第一收取缴费地点
+ tempstr += GetSpaceStr(bill.PKGS.ToString().Trim(), 8, "0");//13//BL's total No of Packages//O//9(8)//51//58//提单总包数//
+ tempstr += GetSpaceStr(bill.KINDPKGS_EDI_CODE, 8);//14//BL's Packages_type in total//O//X(8)//59//66//Default as 'PACKAGE'//BL的packages_type总//默认为“包”
+
+
+ tempstr += GetSpaceStr("", 12);//15//Filler//M//X(12)//67//78//Spaces//填料//空间
+ tempstr += GetSpaceStr("", 1);//16//Roundtrip Indicator//O//X(1)//79//79//Y:Round trip, else leave Blank//往返指示器//往返,否则留下空白
+ tempstr += GetSpaceStr("", 1);//17//Received for Shipment//O//X(1)//80//80//Y:Received for Shipment, else leave Blank//收到的货物//收到装运,否则留空
+ tempstr += GetSpaceStr("", 8);//18//Shipped on Board Date//O//X(8)//81//88//YYYYMMDD (SOB Date)//装船日期//YYYYMMDD(SOB日期)
+ tempstr += GetSpaceStr("", 8);//19//Date of Surrender//O//X(8)//89//96//YYYYMMDD (Surrender Date)//日投降//YYYYMMDD(投降日)
+ tempstr += GetSpaceStr("", 5);//20//Point of BL Surrender//O//X(5)//97//101//webCSM Port code (Point of BL Surrender)//提单退保点//webcsm港口代码(BL屈服点)
+ tempstr += GetSpaceStr("", 5);//21//Point of BL Switch//O//X(5)//102//106//webCSM Port code (Point of BL Switch)//BL开关点//webcsm港口代码(BL开关点)
+ tempstr += GetSpaceStr("", 8);//22//Date of Switch Issuance//O//X(8)//107//114//YYYYMMDD (Switch Issuance Date)//开关签发日期//YYYYMMDD(开关发行日期)
+ tempstr += GetSpaceStr("", 5);//23//Point of BL Switch Issuance//O//X(5)//115//119//webCSM Port code (Point of BL Switch Issuance)//提单开关点//webcsm港口代码(BL开关发行点)
+ tempstr += GetSpaceStr("", 5);//24//Final Delivered Point//O//X(5)//120//124//webCSM Port code (Final Released Point of cargo)//最后交付点//webcsm港口代码(最终发布点的货物)
+ tempstr += GetSpaceStr("", 126);//25//Filler//M//X(126)//125//250//Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+ }
+
+ #region 99
+ tempstr = "99";//1 RECORD-ID M 9(2) 1 2 99
+ tempstr += GetSpaceStr("", 3);//2 Filler M X(3) 3 5 Spaces
+ tempstr += GetSpaceStr(icount.ToString(), 6, "0");//3 Total No of B/Ls M 9(6) 6 11 Total number of b/ls generated in EDI file
+ //4 Filler M X(239) 12 250 Spaces
+ r.WriteLine(GetSpaceStr(tempstr, 250));
+ #endregion
+
+ r.Close();
+ f.Close();
+
+ return filename;
+ }
+ #endregion
+
+
+
+ }
+
+
+ public class MsPILEdiModel
+ {
+
+ ///
+ /// 发送方代码 M
+ ///
+ public string SENDCODE { get; set; }
+
+ ///
+ /// 发送方名称 M
+ ///
+ public string SENDNAME { get; set; }
+
+ ///
+ /// 接收方代码 M
+ ///
+ public string RECEIVECODE { get; set; }
+
+ ///
+ /// 文件类型 (B订舱,E SI确认)M
+ ///
+ public string filetype { get; set; }
+
+ ///
+ /// 文件功能 (9原始,1 更新,5 退舱 )M
+ ///
+ public string filerole { get; set; }
+
+ ///
+ /// 文件路径 M
+ ///
+ public string filerpath { get; set; }
+
+ ///
+ /// 是否使用货代代码。 M
+ ///
+ public bool UseForWarderCode { get; set; }
+ ///
+ /// 货代代码。 O
+ ///
+ public string ForWarderCode { get; set; }
+
+ ///
+ /// 货代名称 O
+ ///
+ public string ForWarderName { get; set; }
+
+ ///
+ /// 业务信息列表 M
+ ///
+ public List BSLIST { get; set; }
+
+
+ }
+
+
+ public class MsOpSeaeEdiModel
+ {
+
+
+ ///
+ /// 委托方
+ ///
+ public string WEITUO { get; set; }
+
+ ///
+ /// 操作英文名称 M
+ ///
+ public string OpEName { get; set; }
+
+ ///
+ /// 操作电话 M
+ ///
+ public string OpTel { get; set; }
+ ///
+ /// 操作邮箱 M
+ ///
+ public string OpEmail { get; set; }
+
+ ///
+ /// EDI联系人名称 O
+ ///
+ public string EDIATTN { get; set; }
+
+ ///
+ /// EDI联系人电话 O
+ ///
+ public string EDIATTNTEL { get; set; }
+ ///
+ /// EDI联系人邮箱 O
+ ///
+ public string EDIATTNEMAIL { get; set; }
+ ///
+ /// 订舱编号 O
+ ///
+ public string ORDERNO { get; set; }
+
+ ///
+ /// 场站 M
+ ///
+ public string YARD { get; set; }
+
+ ///
+ /// 场站代码 M
+ ///
+ public string YARDEDICODE { get; set; }
+
+
+ ///
+ /// 主提单号 M
+ ///
+ public string MBLNO { get; set; }
+
+ ///
+ /// 付费方式代码 M
+ ///
+ public string BLFRTEDICODE { get; set; }
+
+
+ ///
+ /// 付费方式 M
+ ///
+ public string BLFRT { get; set; }
+
+ ///
+ /// 船名 O
+ ///
+ public string VESSEL { get; set; }
+
+ ///
+ /// 船舶呼号 O
+ ///
+ public string VESSELID { get; set; }
+
+
+ ///
+ /// 航次 O
+ ///
+ public string VOYNO { get; set; }
+
+
+ ///
+ /// 内部航次 O
+ ///
+ public string NVOYNO { get; set; }
+
+ ///
+ /// 开船日期 M
+ ///
+ public string ETD { get; set; }
+
+ ///
+ /// 预抵日期 M
+ ///
+ public string ETA { get; set; }
+
+ ///
+ /// 截港日期 O
+ ///
+ public string CLOSINGDATE { get; set; }
+
+ ///
+ /// EDI备注
+ ///
+ public string EDIREMARK { get; set; }
+
+ ///
+ /// SI备注
+ ///
+ public string SIREMARK { get; set; }
+
+ ///
+ /// NVO NO
+ ///
+ public string NVONO { get; set; }
+
+ ///
+ /// 船公司名称 M
+ ///
+ public string CARRIER { get; set; }
+ ///
+ /// 船公司EDI代码 M
+ ///
+ public string CARRIEREDICODE { get; set; }
+
+ ///
+ /// 发货人 M
+ ///
+ public string SHIPPER { get; set; }
+
+ ///
+ /// 收货人 M
+ ///
+ public string CONSIGNEE { get; set; }
+
+ ///
+ /// 通知人 M
+ ///
+ public string NOTIFYPARTY { get; set; }
+
+ ///
+ /// 第二通知人
+ ///
+ public string NOTIFYPARTY2 { get; set; }
+
+ ///
+ /// AMS收货人
+ ///
+ public string AMSCONSIGNEE { get; set; }
+
+ ///
+ /// AMS通知人
+ ///
+ public string AMSNOTIFYPARTY { get; set; }
+
+
+ ///
+ /// 收货地所在国家 O
+ ///
+ public string BYCOUNTRY { get; set; }
+
+ /////
+ ///// AMS发货人 O
+ /////
+ //public string AMSSHIPPER { get; set; }
+
+ /////
+ ///// AMS收货人 O
+ /////
+ //public string AMSCONSIGNEE { get; set; }
+
+ /////
+ ///// AMS通知人 O
+ /////
+ //public string AMSNOTIFYPARTY { get; set; }
+
+ ///
+ /// HS编码
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// MasterBOLIndicator
+ ///
+ public string MasterBOLIndicator { get; set; }
+
+
+
+
+ ///
+ /// 商品名称
+ ///
+ public string GOODSNAME { get; set; }
+
+
+ ///
+ /// 货类代码
+ ///
+ public string GOODCLASSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+
+
+
+
+ ///
+ /// 收货地代码(每船公司可能不同)
+ ///
+ public string PLACERECEIPTID { get; set; }
+ ///
+ /// 收货地
+ ///
+ public string PLACERECEIPT { get; set; }
+
+
+ ///
+ /// 起运港代码(每船公司可能不同) M
+ ///
+ public string PORTLOADID { get; set; }
+ ///
+ /// 起运港 M
+ ///
+ public string PORTLOAD { get; set; }
+
+
+ ///
+ ///卸货港代码(每船公司可能不同) M
+ ///
+ public string PORTDISCHARGEID { get; set; }
+ ///
+ /// 卸货港 M
+ ///
+ public string PORTDISCHARGE { get; set; }
+
+
+ ///
+ ///中转港代码
+ ///
+ public string TRANSPORTID { get; set; }
+ ///
+ /// 中转港
+ ///
+ public string TRANSPORT { get; set; }
+
+
+ ///
+ ///交货地代码M
+ ///
+ public string PLACEDELIVERYID { get; set; }
+ ///
+ /// 交货地 M
+ ///
+ public string PLACEDELIVERY { get; set; }
+
+ ///
+ ///目的地代码(每船公司可能不同)
+ ///
+ public string DESTINATIONID { get; set; }
+ ///
+ /// 目的地
+ ///
+ public string DESTINATION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ ///
+ /// 货物标识 M
+ ///
+ public string CARGOID { get; set; }
+
+ ///
+ /// 第一层包装皮重 O
+ ///
+ public decimal KINGTAREWEIGHT { get; set; }
+
+
+ ///
+ /// 危险品类别 O
+ ///
+ public string DCLASS { get; set; }
+
+ ///
+ /// 危险品编号 O
+ ///
+ public string DUNNO { get; set; }
+
+ ///
+ /// 危险品页号 C
+ ///
+ public string DPAGE { get; set; }
+
+ ///
+ /// 危险品标签 C
+ ///
+ public string DLABEL { get; set; }
+
+ ///
+ /// 设置温度 O
+ ///
+ public string TEMPSET { get; set; }
+
+
+ ///
+ /// 设置最低温度 C
+ ///
+ public string TEMPMIN { get; set; }
+
+ ///
+ /// 设置最高温度 C
+ ///
+ public string TEMPMAX { get; set; }
+
+
+ ///
+ /// 通风度 O
+ ///
+ public string REEFERF { get; set; }
+
+
+ ///
+ /// 湿度
+ ///
+ public string HUMIDITY { get; set; }
+
+ ///
+ /// 预付地点 O
+ ///
+ public string PREPARDAT { get; set; }
+
+ ///
+ /// 到付地点 O
+ ///
+ public string PAYABLEAT { get; set; }
+
+ ///
+ /// 预付地点EDI代码 O
+ ///
+ public string PREPARDATID { get; set; }
+
+ ///
+ /// 到付地点EDI代码 O
+ ///
+ public string PAYABLEATID { get; set; }
+
+
+ ///
+ /// 签单方式 M(SI)
+ ///
+ public string ISSUETYPE { get; set; }
+
+ ///
+ /// 提单份数 M(SI)
+ ///
+ public string NOBILL { get; set; }
+
+ ///
+ /// 签单地点 M(SI)
+ ///
+ public string ISSUEPLACE { get; set; }
+
+
+ ///
+ /// 签单地点
+ ///
+ public string ISSUEDATE { get; set; }
+
+ ///
+ /// 提单副本份数 M(SI)
+ ///
+ public string COPYNOBILL { get; set; }
+ ///
+ /// 签单地点EDI代码 M(SI)
+ ///
+ public string ISSUEPLACEID { get; set; }
+
+
+ ///
+ /// 运输条款 M
+ ///
+ public string SERVICE { get; set; }
+
+
+ ///
+ /// 运费协议号 M
+ ///
+ public string CONTRACTNO { get; set; }
+
+ ///
+ /// 服务合同号
+ ///
+ public string SERVICECONTRACTNO { get; set; }
+
+ ///
+ /// ESL航线代码 M
+ ///
+ public string ESLLINECODE { get; set; }
+
+ ///
+ /// 收货人邮编 O
+ ///
+ public string CONSIGNEEPOSTCODE { get; set; }
+
+ ///
+ /// 收货人国家 O
+ ///
+ public string CONSIGNEECOUNTRY { get; set; }
+
+ ///
+ /// 收货人税号 O
+ ///
+ public string CONSIGNEETAXNO { get; set; }
+
+ ///
+ /// 通知人邮编 O
+ ///
+ public string NOTIFYPARTYPOSTCODE { get; set; }
+
+ ///
+ /// 通知人国家 O
+ ///
+ public string NOTIFYPARTYCOUNTRY { get; set; }
+
+ ///
+ /// 通知人税号 O
+ ///
+ public string NOTIFYPARTYTAXNO { get; set; }
+
+ ///
+ /// 货物NCM编号 O
+ ///
+ public string GOODSNCM { get; set; }
+
+
+ ///
+ /// 收货人DOOR地址 O
+ ///
+ public string CONSIGNEEDOORADDR { get; set; }
+
+ ///
+ /// 发货人DOOR地址 O
+ ///
+ public string SHIPPERDOORADDR { get; set; }
+
+
+ ///
+ /// SCAC代码 O
+ ///
+ public string SCACCODE { get; set; }
+
+ ///
+ /// ITN编号 O
+ ///
+ public string ITNCODE { get; set; }
+ ///
+ /// 付费方 O
+ ///
+ public string FREIGHTPAYER { get; set; }
+
+ ///
+ /// AMS代码 O
+ ///
+ public string AMSCODE { get; set; }
+ ///
+ /// 是否SOC箱 O
+ ///
+ public bool ISCONTAINERSOC { get; set; }
+
+ ///
+ /// 拆并单列表 O
+ ///
+ public string BSNOLIST { get; set; }
+
+
+
+ ///
+ /// 集装箱明细 M
+ ///
+ public List CTNLIST { get; set; }
+
+ ///
+ /// 集装箱多品名明细 M
+ ///
+ public List CTNGOODSLIST { get; set; }
+
+ ///
+ /// 收货人EDI代码 O
+ ///
+ public string ConsigneeEdiCode { get; set; }
+
+
+
+ ///
+ /// 发货人EDI代码 O
+ ///
+ public string ShipperEdiCode { get; set; }
+
+ ///
+ /// 太平销售的代码 M
+ ///
+ public string SalesRepCode { get; set; }
+
+
+ ///
+ /// ACI HBL O(加拿大)
+ ///
+ public string ACIHBL { get; set; }
+ ///
+ /// S0C C0C O(加拿大)
+ ///
+ public string S0CC0C { get; set; }
+
+ ///
+ /// '欧盟港口、伊朗港口、KHI'
+ ///
+ public string cKHI { get; set; }
+
+ ///
+ /// '南美东'
+ ///
+ public string cNCM { get; set; }
+
+ ///
+ /// '巴西线的木质包装情况'
+ ///
+ public string wNCM { get; set; }
+
+ }
+
+ public class MsOpSeaeCtnEdiModel
+ {
+
+ ///
+ /// 箱型EDI代码 M
+ ///
+ public string CTNALLCODE { get; set; }
+
+ public Int32 CTNNUM { get; set; }
+
+ public Int32 TEU { get; set; }
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// 箱状态
+ ///
+ public string CTNSTATUS { get; set; }
+
+
+
+ ///
+ /// 封号 M
+ ///
+ public string SEALNO { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+ ///
+ /// 箱皮重
+ ///
+ public decimal TAREWEIGHT { get; set; }
+
+ ///
+ /// 称重重量
+ ///
+ public string WEIGHKGS { get; set; }
+
+ ///
+ /// 称重方式 (累加、总重)
+ ///
+ public string WEIGHTYPE { get; set; }
+
+ ///
+ /// 称重签名
+ ///
+ public string WEIGHSIGN { get; set; }
+
+
+ }
+ public class MsOpSeaeCtnDetailEdiModel
+ {
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// HS编码 M
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+
+
+
+ }
+
+}
diff --git a/Myshipping.Application/EDI/TSLEdiHelper.cs b/Myshipping.Application/EDI/TSLEdiHelper.cs
new file mode 100644
index 00000000..c9db29b3
--- /dev/null
+++ b/Myshipping.Application/EDI/TSLEdiHelper.cs
@@ -0,0 +1,2588 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application.EDI.TSL
+{
+ public class TSLEdiHelper
+ {
+
+ public TSLEdiHelper()
+ {
+ }
+
+ #region 基本函数
+ public static string GetCarrierName(string str)
+ {
+ if (str == "MAEU") return "MAERSK LINE";
+ if (str == "MCCQ") return "MCC TRANSPORT SINGAPORE";
+ if (str == "ANNU") return "ANL CONTAINER LINE";
+ if (str == "CMDU") return "CMA CGM";
+ if (str == "CHNL") return "CNC";
+ if (str == "HLCU") return "HAPAG-LLOYD";
+ if (str == "SUDU") return "HAMBURG";
+ if (str == "MSCU") return "MSC";
+ if (str == "DAAE") return "DELMAS";
+ if (str == "UASC") return "UASC";
+ if (str == "COSU") return "COSCO";
+ 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 文本字段判断每行是否符合
+ ///
+ /// edi 文本格式处理判断(例如:1行35个字符不超过5行)
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 要处理的数据
+ /// 每行长度
+ /// 主提单号
+ /// 数据类型(例如:发货人内容、货描等)
+ /// 限制录入的行数(“0”代表不限制)
+ /// 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+ ///
+ 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 + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ else
+ {
+ if (argAGENT.Length > rowNum && rowNum != 0)
+ {
+ if (isHuoMiao)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ return error;
+ }
+ #endregion
+
+ #region 字符转义
+ ///
+ /// 各种文本转义字符
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 文本字符串
+ ///
+ public static string formatEdiStr(string fileType, string str)
+ {
+ if (fileType == "txt")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'");
+ }
+ else if (fileType == "xml")
+ {
+ return str.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
+ }
+ else if (fileType == "sitc")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("'", "?'");
+ }
+ else
+ {
+ return str;
+ }
+ }
+ #endregion
+ #region 格式化每行
+ public static List 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 DestList = new List();
+ 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 IsCreateTSL(MsTSLEdiModel InttrEdi)
+ {
+ var error = "";
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDCODE))
+ { error = error + "
发送方代码不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDNAME))
+ { error = error + "
发送方名称不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.RECEIVECODE))
+ { error = error + "
接收方代码不能为空"; }
+
+ if (InttrEdi.filetype == "B")
+ {
+ if (InttrEdi.UseForWarderCode)
+ {
+ if (string.IsNullOrEmpty(InttrEdi.ForWarderCode))
+ { error = error + "
货代代码不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.ForWarderName))
+ { error = error + "
货代称呼不能为空"; }
+ }
+ }
+
+
+ foreach (var headData in InttrEdi.BSLIST)
+ {
+
+ if (InttrEdi.filetype == "B")
+ {
+ if (InttrEdi.UseForWarderCode)
+ {
+ if (string.IsNullOrEmpty(headData.ORDERNO))
+ { error = error + "
订舱编号不能为空"; }
+ }
+ }
+
+ if (string.IsNullOrEmpty(headData.OpEName))
+ { error = error + "
操作的英文名不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.OpTel))
+ { error = error + "
操作的电话不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.OpEmail))
+ { error = error + "
操作的邮箱不能为空"; }
+ if (string.IsNullOrEmpty(headData.MBLNO))
+ { error = error + "
主提单号不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.BLFRT))
+ { error = error + "
提单号:" + headData.MBLNO + " 付费方式不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.SERVICE))
+ { error = error + "
提单号:" + headData.MBLNO + " 运输条款不能为空"; }
+
+ //if (string.IsNullOrEmpty(headData.CONTRACTNO))
+ //{ error = error + "
提单号:" + headData.MBLNO + " 运费协议号不能为空"; }
+ if (string.IsNullOrEmpty(headData.CARGOID))
+ { error = error + "
提单号:" + 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 + "
EDI信息联系人不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.EDIATTNTEL))
+ { error = error + "
EDI信息联系人电话不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.EDIATTNEMAIL))
+ { error = error + "
EDI信息联系人邮箱不能为空"; }
+ }
+ }
+
+
+ if (InttrEdi.filetype == "E")
+ {
+ if (string.IsNullOrEmpty(headData.VESSEL))
+ { error = error + "
提单号:" + headData.MBLNO + " 船名不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.VOYNO))
+ { error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 请在SI备注中输入:COSCO 销售的营销代码(此代码船公司会直接提供)";
+ }
+ else
+ {
+ //if (carrier != "YML")
+ //error = error + "
提单号:" + bill.MBLNO + " EDI备注中不能为空";
+ }
+ }
+ else
+ {
+ if (StringIsChinese(headData.SIREMARK))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " SI备注中含有中文或双字节字符";
+ }
+
+ }
+ }
+ else
+ {
+ if (headData.EDIREMARK.IndexOf("PLEASE BOOK OCEAN CARRIER") > -1 || headData.EDIREMARK.ToString().Trim() == "")
+ {
+ if (headData.CARRIEREDICODE == "COSU")
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 请在EDI备注中输入:COSCO 销售的营销代码(此代码船公司会直接提供)";
+ }
+ else
+ {
+ //if (carrier != "YML")
+ //error = error + "
提单号:" + bill.MBLNO + " EDI备注中不能为空";
+ }
+ }
+ else
+ {
+ if (StringIsChinese(headData.EDIREMARK))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " EDI备注中含有中文或双字节字符";
+ }
+ }
+ }
+ //if (string.IsNullOrEmpty(headData.CARRIER))
+ //{ error = error + "
提单号:" + headData.MBLNO + " 船公司不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.CARRIEREDICODE))
+ { error = error + "
提单号:" + headData.MBLNO + " 船公司EDI代码不能为空"; }
+
+
+ if (string.IsNullOrEmpty(headData.SHIPPER))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 发货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.SHIPPER))
+ {
+ error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 收货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.CONSIGNEE))
+ {
+ error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 运输条款为:CY-DOOR,EDI信息中的DOOR地址不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.CONSIGNEEDOORADDR))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " DOOR地址含有中文或双字节字符";
+ }
+ }
+ }
+ if (headData.SERVICE == "DOOR-CY")
+ {
+ if (string.IsNullOrEmpty(headData.SHIPPERDOORADDR))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 运输条款为:DOOR-CY,EDI信息中的联系人地址不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.SHIPPERDOORADDR))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 联系人地址含有中文或双字节字符";
+ }
+ }
+ }
+
+
+ if (string.IsNullOrEmpty(headData.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 通知人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 唛头不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.MARKS))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 唛头含有中文或双字节字符";
+ }
+ else
+ {
+ error += formatlengthError("txt", headData.MARKS, 35, headData.MBLNO, "唛头", 0, "", false);
+ }
+ }
+
+ if (string.IsNullOrEmpty(headData.DESCRIPTION))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 货物描述不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.DESCRIPTION))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 货物描述含有中文或双字节字符";
+ }
+ else
+ {
+ //error += formatlengthError("txt", bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 0, "");
+ }
+ }
+ if (string.IsNullOrEmpty(headData.PORTLOADID) || headData.PORTLOADID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 装货港代码不能为空或录入不正确(必须是5位代码)"; }
+
+ if (string.IsNullOrEmpty(headData.PORTLOAD))
+ { error = error + "
提单号:" + headData.MBLNO + " 装货港不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.ETD))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 开船日期不能为空";
+ return error;
+ }
+ if (string.IsNullOrEmpty(headData.PORTDISCHARGEID) || headData.PORTDISCHARGEID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 卸货港代码不能为空或录入不正确(必须是5位代码)"; }
+ if (string.IsNullOrEmpty(headData.PORTDISCHARGE))
+ { error = error + "
提单号:" + headData.MBLNO + " 卸货港不能为空"; }
+ if (string.IsNullOrEmpty(headData.DESTINATION))
+ {
+ if (string.IsNullOrEmpty(headData.DESTINATIONID) || headData.DESTINATIONID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 目的地代码不能为空或录入不正确(必须是5位代码)"; }
+ }
+ if (string.IsNullOrEmpty(headData.KINDPKGS_EDI_CODE))
+ { error = error + "
提单号:" + headData.MBLNO + " 包装EDI代码不能为空"; }
+ if (headData.PKGS == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 件数不能为0"; }
+ if (headData.KGS == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 毛重不能为0"; }
+ if (headData.CBM == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 尺码不能为0"; }
+
+ if (headData.CARGOID == "D")
+ {
+ if (string.IsNullOrEmpty(headData.DCLASS))
+ { error = error + "
提单号:" + headData.MBLNO + " 危险品分类不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.DUNNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 危险品编号不能为空"; }
+ }
+ if (headData.CARGOID == "R")
+ {
+ if (headData.TEMPSET == null || headData.TEMPSET == "")
+ { error = error + "
提单号:" + headData.MBLNO + " 设置温度不能为空"; }
+ if (headData.REEFERF == null || headData.REEFERF == "")
+ { error = error + "
提单号:" + headData.MBLNO + " 通风度不能为空"; }
+ }
+
+ if (headData.BLFRT != null && headData.BLFRT.IndexOf("PREPAID") >= 0)
+ {
+ if (string.IsNullOrEmpty(headData.PREPARDAT))
+ { error = error + "
提单号:" + headData.MBLNO + " 预付地点不能为空"; }
+ if (string.IsNullOrEmpty(headData.PREPARDATID))
+ { error = error + "
提单号:" + headData.MBLNO + " 预付地点EDI代码不能为空"; }
+ }
+ else if (headData.BLFRT != null && headData.BLFRT.IndexOf("COLLECT") >= 0)
+ {
+ if (string.IsNullOrEmpty(headData.PAYABLEAT))
+ { error = error + "
提单号:" + headData.MBLNO + " 到付地点不能为空"; }
+ if (string.IsNullOrEmpty(headData.PAYABLEATID))
+ { error = error + "
提单号:" + headData.MBLNO + " 到付地点EDI代码不能为空"; }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+ if (string.IsNullOrEmpty(headData.ISSUEPLACEID))
+ { error = error + "
提单号:" + headData.MBLNO + " 签单地点或到签单地点EDI代码不能为空"; }
+ }
+ var ctnlist = headData.CTNLIST;
+ if (ctnlist.Count == 0) { error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 集装箱箱型EDI代码不能为空"; }
+ if (string.IsNullOrEmpty(ctn.CNTRNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 箱号不能为空"; }
+ if (string.IsNullOrEmpty(ctn.SEALNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 封号不能为空"; }
+ if (headData.BYCOUNTRY == "BRAZIL")
+ {
+ if (string.IsNullOrEmpty(ctn.TAREWEIGHT) || Convert.ToDecimal(ctn.TAREWEIGHT) == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 箱皮重不能为空"; }
+ }
+ if (ctn.KINDPKGS != headData.KINDPKGS)
+ { error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 集装箱件数合计数必须等于委托单总件数"; }
+ if (dlKGS != Convert.ToDecimal(headData.KGS))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱重量合计数必须等于委托单总重量数"; }
+ if (dlCBM != Convert.ToDecimal(headData.CBM))
+ { error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + "的“" + ctn.CNTRNO + "”未添加分箱明细!";
+ }
+ else
+ {
+ if (ctngoodssumpkgs != Convert.ToDecimal(ctn.PKGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细件数合计数不等于集装箱件数"; }
+ if (ctngoodssumkgs != Convert.ToDecimal(ctn.KGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细毛重合计数不等于集装箱毛重"; }
+ if (ctngoodssumcbm != Convert.ToDecimal(ctn.CBM))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细尺码合计数不等于集装箱毛重"; }
+
+ }
+
+ }
+
+ foreach (var ctngood in headData.CTNGOODSLIST)
+ {
+ if (string.IsNullOrEmpty(ctngood.KINDPKGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型不能为空"; }
+ if (string.IsNullOrEmpty(ctngood.DESCRIPTION))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱货物描述不能为空"; }
+ else
+ {
+ error += formatlengthError("txt", ctngood.DESCRIPTION, 70, headData.MBLNO, "的“" + ctngood.CNTRNO + "”箱号的分箱货物描述", 0, "", false);
+ }
+ //if (string.IsNullOrEmpty(ctngood.HSCODE))
+ //{ error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱HS编码不能为空"; }
+ if (string.IsNullOrEmpty(ctngood.KINDPKGS_EDI_CODE))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型代码不能为空"; }
+
+ }
+
+ }
+
+ #endregion
+
+
+ }
+
+ }
+ return error;
+ }
+ #endregion
+
+ #region 订舱
+ public static string CreateEdiTSL(MsTSLEdiModel InttrEdi)
+ {
+ string filename = InttrEdi.filerpath + "\\" + 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 + "SO:ZZZ+" + InttrEdi.RECEIVECODE + ":UN+" + DateTime.Now.ToString("yyMMdd:HHmm") + "+" + bill.ORDERNO + "'");
+ r.WriteLine("UNH+" + bill.ORDERNO + "+IFTMBF:D:99B:UN'");
+ icount = icount + 2;
+
+ 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'");
+
+
+ r.WriteLine("DTM+137:" + DateTime.Now.ToString("yyyyMMddHHmm") + ":203'");
+ icount = icount + 2;
+
+ 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++)
+ {
+ r.WriteLine("FTX+AAI+++" + EdiRemarkList[i] + "'");
+ icount = icount + 1;
+
+ }
+ }
+ r.WriteLine("RFF+FF:" + bill.ORDERNO.Trim() + "'");
+ icount = icount + 1;
+ if (!string.IsNullOrEmpty(bill.CONTRACTNO))
+ {
+ r.WriteLine("RFF+CT:" + bill.CONTRACTNO.Trim() + "'");
+ 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.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'");
+ }
+
+ icount = icount + 1;
+
+ var copynum = GetBillNum(bill.COPYNOBILL);
+
+ if (bill.ISSUETYPE == "正本")
+ {
+ r.WriteLine("DOC+706+++" + 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+706+++" + GetBillNum(bill.NOBILL) + "'");
+ icount = icount + 1;
+ if (copynum != "")
+ {
+ r.WriteLine("DOC+707+++" + copynum + "'");
+ icount = icount + 1;
+ }
+
+ }
+ else if (bill.ISSUETYPE == "正副本")
+ {
+ r.WriteLine("DOC+706+++" + 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.BLFRT.ToUpper().IndexOf("PREPAID") > 0)
+ {
+ r.WriteLine("CPI+4++P'");
+ icount = icount + 1;
+ }
+ else if (bill.BLFRT.ToUpper().IndexOf("COLLECT") > 0)
+ {
+ r.WriteLine("CPI+4++C'");
+ icount = icount + 1;
+ }
+ else
+ {
+ r.WriteLine("CPI+4++B'");
+ 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;
+
+ }
+
+
+ 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);
+
+
+ r.WriteLine("TDT+20+" + voyno + "+1++" + bill.CARRIEREDICODE + "+++:::" + bill.VESSEL + "'");
+ 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+9+" + 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;
+ }
+ r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'");
+ icount = icount + 1;
+
+ if (InttrEdi.SENDNAME.Length > 35)
+ r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'");
+ else
+ r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'");
+
+ //r.WriteLine("CTA+IC+:" +billams.ATTN+ "'");
+ //r.WriteLine("COM+" +billams.ATTNTEL+ ":TE'");
+ //r.WriteLine("COM+" + billams.ATTNEMAIL + ":EM'");
+
+
+ r.WriteLine("CTA+IC+:" + bill.OpEName + "'");
+ r.WriteLine("COM+" + bill.OpTel + ":TE'");
+ r.WriteLine("COM+" + bill.OpEmail + ":EM'");
+
+ r.WriteLine("NAD+MR+++" + InttrEdi.SENDNAME + "'");
+ //r.WriteLine("CTA+NT+:" +billams.ATTN+ "'");
+ //r.WriteLine("COM+" + billams.ATTNEMAIL + ":EM'");
+ r.WriteLine("CTA+NT+:" + bill.OpEName + "'");
+ r.WriteLine("COM+" + bill.OpEmail + ":EM'");
+
+ icount = icount + 7;
+
+ 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) + "'");
+ icount = icount + 1;
+
+ }
+ 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 = icount + 1;
+
+ }
+ }
+
+ if (InttrEdi.UseForWarderCode)
+ {
+ r.WriteLine("NAD+BA+" + InttrEdi.ForWarderCode + ":160:86++" + InttrEdi.ForWarderName + "'");
+ icount++;
+ r.WriteLine("CTA+IC+:" + bill.OpEName + "'");
+ r.WriteLine("COM+" + bill.OpTel + ":TE'");
+ r.WriteLine("COM+" + bill.OpEmail + ":EM'");
+ icount = icount + 3;
+ }
+
+
+
+
+ Shipping = "";
+ var DescriptionShipper = "";
+ Shipping = formatEdiStr("txt", bill.SHIPPER);
+
+ List 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];
+ 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 (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;
+
+
+
+
+ r.WriteLine("GID+1+" + bill.PKGS.ToString() + ":" + bill.KINDPKGS_EDI_CODE + "::6:" + bill.KINDPKGS + "'");
+
+ icount = icount + 1;
+ if (bill.CARGOID == "R")
+ {
+ r.WriteLine("GDS+14'");
+ icount = icount + 1;
+ }
+ else if (bill.CARGOID == "D")
+ {
+ r.WriteLine("GDS+11'");
+ icount = icount + 1;
+
+ }
+ else
+ if (bill.CARGOID == "O")
+ {
+ r.WriteLine("GDS+5'");
+ 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++)
+ {
+ 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + "'");
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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();
+ 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.CTNALLCODE + "+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 CreateEdiTSLSI(MsTSLEdiModel InttrEdi)
+ {
+ string filename = InttrEdi.filerpath + "\\" + 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 + ":ZZZ+" + InttrEdi.RECEIVECODE + ":UN+" + 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'");
+
+ icount = icount + 3;
+
+ 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+AAI+++" + EdiRemarkList[i] + "'");
+ icount = icount + 1;
+
+ }
+ }
+
+ r.WriteLine("RFF+BN:" + bill.MBLNO + "'");
+ icount = icount + 1;
+
+ r.WriteLine("RFF+BM:" + bill.MBLNO + "'");
+ icount = icount + 1;
+ r.WriteLine("RFF+SI:" + bill.MBLNO + "'");
+ icount = icount + 1;
+
+ if (!string.IsNullOrEmpty(bill.CONTRACTNO))
+ {
+ r.WriteLine("RFF+CT:" + bill.CONTRACTNO + "'");
+ 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.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'");
+ }
+ icount = icount + 1;
+
+ var copynum = GetBillNum(bill.COPYNOBILL);
+
+ if (bill.ISSUETYPE == "正本")
+ {
+ r.WriteLine("DOC+706+++" + 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+706+++" + GetBillNum(bill.NOBILL) + "'");
+ icount = icount + 1;
+ if (copynum != "")
+ {
+ r.WriteLine("DOC+707+++" + copynum + "'");
+ icount = icount + 1;
+ }
+
+ }
+ else if (bill.ISSUETYPE == "正副本")
+ {
+ r.WriteLine("DOC+706+++" + 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.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;
+
+
+ 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 (billams.ORDERNO != "")
+ // r.WriteLine("RFF+BN:" + billams.ORDERNO + "'");
+ //else
+
+ if (bill.BYCOUNTRY == "USA")
+ {
+ r.WriteLine("REF+TN:" + bill.ITNCODE + "'");
+ 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;
+ }
+ r.WriteLine("TDT+20+" + voyno + "+1++" + bill.CARRIEREDICODE + "+++:::" + bill.VESSEL + "'");
+ 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+9+" + 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;
+
+ }
+ r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'");
+ icount = icount + 1;
+
+ if (InttrEdi.SENDNAME.Length > 35)
+ r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'");
+ else
+ r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'");
+
+ //r.WriteLine("CTA+IC+:" +billams.ATTN+ "'");
+ //r.WriteLine("COM+" +billams.ATTNTEL+ ":TE'");
+ //r.WriteLine("COM+" + billams.ATTNEMAIL + ":EM'");
+
+
+ r.WriteLine("CTA+IC+:" + bill.OpEName + "'");
+ r.WriteLine("COM+" + bill.OpTel + ":TE'");
+ r.WriteLine("COM+" + bill.OpEmail + ":EM'");
+
+ r.WriteLine("NAD+MR+++" + InttrEdi.SENDNAME + "'");
+ //r.WriteLine("CTA+NT+:" +billams.ATTN+ "'");
+ //r.WriteLine("COM+" + billams.ATTNEMAIL + ":EM'");
+ r.WriteLine("CTA+NT+:" + bill.OpEName + "'");
+ r.WriteLine("COM+" + bill.OpEmail + ":EM'");
+
+ icount = icount + 7;
+
+
+ var DescriptionShipper = "";
+ Shipping = formatEdiStr("txt", bill.SHIPPER);
+
+ List 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];
+ 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];
+ }
+ }
+ 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 (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];
+ }
+ }
+
+ 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+N1+++" + 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.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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + "'");
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctn.KGS), 3) + "'");
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'");
+ icount++;
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'");
+ //MEA+AAE+AAW+MTQ:50.11'
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(ctngood.CBM), 3) + "'");
+ icount = icount + 3;
+ i = i + 1;
+ }
+ }
+ }
+ #endregion
+
+ }
+ else
+ {
+
+ #region 取集装箱分箱_货描、唛头信息
+
+
+ var ctngoodssumlist = new List();
+ 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngoodsum.KGS), 3) + "'");
+ icount++;
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(i.KGS), 3) + "'");
+ //MEA+AAE+AAW+MTQ:50.11'
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctn.KGS), 3) + "'");
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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
+
+
+
+ }
+
+
+ public class MsTSLEdiModel
+ {
+
+ ///
+ /// 发送方代码 M
+ ///
+ public string SENDCODE { get; set; }
+
+ ///
+ /// 发送方名称 M
+ ///
+ public string SENDNAME { get; set; }
+
+ ///
+ /// 接收方代码 M
+ ///
+ public string RECEIVECODE { get; set; }
+
+ ///
+ /// 文件类型 (B订舱,E SI确认)M
+ ///
+ public string filetype { get; set; }
+
+ ///
+ /// 文件功能 (9原始,1 更新,5 退舱 )M
+ ///
+ public string filerole { get; set; }
+
+ ///
+ /// 文件路径 M
+ ///
+ public string filerpath { get; set; }
+
+ ///
+ /// 是否使用货代代码。 M
+ ///
+ public bool UseForWarderCode { get; set; }
+ ///
+ /// 货代代码。 O
+ ///
+ public string ForWarderCode { get; set; }
+
+ ///
+ /// 货代名称 O
+ ///
+ public string ForWarderName { get; set; }
+
+ ///
+ /// 业务信息列表 M
+ ///
+ public List BSLIST { get; set; }
+
+
+ }
+
+
+ public class MsOpSeaeEdiModel
+ {
+
+
+ ///
+ /// 委托方
+ ///
+ public string WEITUO { get; set; }
+
+ ///
+ /// 操作英文名称 M
+ ///
+ public string OpEName { get; set; }
+
+ ///
+ /// 操作电话 M
+ ///
+ public string OpTel { get; set; }
+ ///
+ /// 操作邮箱 M
+ ///
+ public string OpEmail { get; set; }
+
+ ///
+ /// EDI联系人名称 O
+ ///
+ public string EDIATTN { get; set; }
+
+ ///
+ /// EDI联系人电话 O
+ ///
+ public string EDIATTNTEL { get; set; }
+ ///
+ /// EDI联系人邮箱 O
+ ///
+ public string EDIATTNEMAIL { get; set; }
+ ///
+ /// 订舱编号 O
+ ///
+ public string ORDERNO { get; set; }
+
+ ///
+ /// 主提单号 M
+ ///
+ public string MBLNO { get; set; }
+
+ ///
+ /// 付费方式 M
+ ///
+ public string BLFRT { get; set; }
+
+ ///
+ /// 船名 O
+ ///
+ public string VESSEL { get; set; }
+
+
+
+ ///
+ /// 航次 O
+ ///
+ public string VOYNO { get; set; }
+
+
+ ///
+ /// 内部航次 O
+ ///
+ public string NVOYNO { get; set; }
+
+ ///
+ /// 开船日期 M
+ ///
+ public string ETD { get; set; }
+
+ ///
+ /// EDI备注
+ ///
+ public string EDIREMARK { get; set; }
+
+ ///
+ /// SI备注
+ ///
+ public string SIREMARK { get; set; }
+
+ ///
+ /// 船公司名称 M
+ ///
+ public string CARRIER { get; set; }
+ ///
+ /// 船公司EDI代码 M
+ ///
+ public string CARRIEREDICODE { get; set; }
+
+ ///
+ /// 发货人 M
+ ///
+ public string SHIPPER { get; set; }
+
+ ///
+ /// 收货人 M
+ ///
+ public string CONSIGNEE { get; set; }
+
+ ///
+ /// 通知人 M
+ ///
+ public string NOTIFYPARTY { get; set; }
+
+ ///
+ /// 第二通知人
+ ///
+ public string NOTIFYPARTY2 { get; set; }
+
+
+ ///
+ /// 收货地所在国家 O
+ ///
+ public string BYCOUNTRY { get; set; }
+
+ /////
+ ///// AMS发货人 O
+ /////
+ //public string AMSSHIPPER { get; set; }
+
+ /////
+ ///// AMS收货人 O
+ /////
+ //public string AMSCONSIGNEE { get; set; }
+
+ /////
+ ///// AMS通知人 O
+ /////
+ //public string AMSNOTIFYPARTY { get; set; }
+
+ ///
+ /// HS编码
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+ ///
+ /// 起运港代码(每船公司可能不同) M
+ ///
+ public string PORTLOADID { get; set; }
+ ///
+ /// 起运港 M
+ ///
+ public string PORTLOAD { get; set; }
+
+
+ ///
+ ///卸货港代码(每船公司可能不同) M
+ ///
+ public string PORTDISCHARGEID { get; set; }
+ ///
+ /// 卸货港 M
+ ///
+ public string PORTDISCHARGE { get; set; }
+
+ ///
+ ///目的地代码(每船公司可能不同)
+ ///
+ public string DESTINATIONID { get; set; }
+ ///
+ /// 目的地
+ ///
+ public string DESTINATION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ ///
+ /// 货物标识 M
+ ///
+ public string CARGOID { get; set; }
+
+ ///
+ /// 危险品类别 O
+ ///
+ public string DCLASS { get; set; }
+
+ ///
+ /// 危险品编号 O
+ ///
+ public string DUNNO { get; set; }
+
+ ///
+ /// 设置温度 O
+ ///
+ public string TEMPSET { get; set; }
+
+ ///
+ /// 通风度 O
+ ///
+ public string REEFERF { get; set; }
+
+
+ ///
+ /// 湿度
+ ///
+ public string HUMIDITY { get; set; }
+
+ ///
+ /// 预付地点 O
+ ///
+ public string PREPARDAT { get; set; }
+
+ ///
+ /// 到付地点 O
+ ///
+ public string PAYABLEAT { get; set; }
+
+ ///
+ /// 预付地点EDI代码 O
+ ///
+ public string PREPARDATID { get; set; }
+
+ ///
+ /// 到付地点EDI代码 O
+ ///
+ public string PAYABLEATID { get; set; }
+
+
+ ///
+ /// 签单方式 M(SI)
+ ///
+ public string ISSUETYPE { get; set; }
+
+ ///
+ /// 提单份数 M(SI)
+ ///
+ public string NOBILL { get; set; }
+
+ ///
+ /// 签单地点 M(SI)
+ ///
+ public string ISSUEPLACE { get; set; }
+
+ ///
+ /// 提单副本份数 M(SI)
+ ///
+ public string COPYNOBILL { get; set; }
+ ///
+ /// 签单地点EDI代码 M(SI)
+ ///
+ public string ISSUEPLACEID { get; set; }
+
+
+ ///
+ /// 运输条款 M
+ ///
+ public string SERVICE { get; set; }
+
+
+ ///
+ /// 运费协议号 M
+ ///
+ public string CONTRACTNO { get; set; }
+
+ ///
+ /// 收货人邮编 O
+ ///
+ public string CONSIGNEEPOSTCODE { get; set; }
+
+ ///
+ /// 收货人国家 O
+ ///
+ public string CONSIGNEECOUNTRY { get; set; }
+
+ ///
+ /// 收货人税号 O
+ ///
+ public string CONSIGNEETAXNO { get; set; }
+
+ ///
+ /// 通知人邮编 O
+ ///
+ public string NOTIFYPARTYPOSTCODE { get; set; }
+
+ ///
+ /// 通知人国家 O
+ ///
+ public string NOTIFYPARTYCOUNTRY { get; set; }
+
+ ///
+ /// 通知人税号 O
+ ///
+ public string NOTIFYPARTYTAXNO { get; set; }
+
+ ///
+ /// 货物NCM编号 O
+ ///
+ public string GOODSNCM { get; set; }
+
+
+ ///
+ /// 收货人DOOR地址 O
+ ///
+ public string CONSIGNEEDOORADDR { get; set; }
+
+ ///
+ /// 发货人DOOR地址 O
+ ///
+ public string SHIPPERDOORADDR { get; set; }
+
+
+ ///
+ /// SCAC代码 O
+ ///
+ public string SCACCODE { get; set; }
+
+ ///
+ /// ITN编号 O
+ ///
+ public string ITNCODE { get; set; }
+
+
+ ///
+ /// 是否SOC箱 O
+ ///
+ public bool ISCONTAINERSOC { get; set; }
+
+ ///
+ /// 拆并单列表 O
+ ///
+ public string BSNOLIST { get; set; }
+
+
+
+ ///
+ /// 集装箱明细 M
+ ///
+ public List CTNLIST { get; set; }
+
+ ///
+ /// 集装箱多品名明细 M
+ ///
+ public List CTNGOODSLIST { get; set; }
+ }
+
+ public class MsOpSeaeCtnEdiModel
+ {
+
+ ///
+ /// 箱型EDI代码 M
+ ///
+ public string CTNALLCODE { get; set; }
+
+ public Int32 CTNNUM { get; set; }
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// 封号 M
+ ///
+ public string SEALNO { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ public string TAREWEIGHT { get; set; }
+
+ }
+ public class MsOpSeaeCtnDetailEdiModel
+ {
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// HS编码 M
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ }
+
+}
diff --git a/Myshipping.Application/EDI/WYEdiHelper.cs b/Myshipping.Application/EDI/WYEdiHelper.cs
new file mode 100644
index 00000000..62b54c19
--- /dev/null
+++ b/Myshipping.Application/EDI/WYEdiHelper.cs
@@ -0,0 +1,1566 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application.EDI.WY
+{
+ ///
+ ///
+ ///
+ public class WYEdiHelper
+ {
+
+ public WYEdiHelper()
+ {
+ }
+
+ #region 基本函数
+
+ 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 "";
+ }
+
+
+ public static string GetDateStr(string datestr, string dateformat)
+ {
+ var result = "";
+
+ if (datestr == null || datestr == "")
+ {
+ result = "";
+ }
+ else
+ {
+ result = Convert.ToDateTime(datestr).ToString(dateformat);
+
+ }
+
+ return result;
+
+ }
+
+ #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
+
+ public static string formatListStr(List DestList, int lineCount, bool isformat = false)
+ {
+ var result = "";
+ for (var i = 0; i < lineCount; i++)
+ {
+ if (DestList.Count > i)
+ {
+ if (isformat)
+ result = result + formatEdiStr("txt", DestList[i]);
+ else
+ result = result + DestList[i];
+ }
+ if (i != (lineCount - 1))
+ result = result + ":";
+
+
+ }
+ return result;
+ }
+
+
+ #region 文本字段判断每行是否符合
+ ///
+ /// edi 文本格式处理判断(例如:1行35个字符不超过5行)
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 要处理的数据
+ /// 每行长度
+ /// 主提单号
+ /// 数据类型(例如:发货人内容、货描等)
+ /// 限制录入的行数(“0”代表不限制)
+ /// 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+ ///
+ 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 + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ else
+ {
+ if (argAGENT.Length > rowNum && rowNum != 0)
+ {
+ if (isHuoMiao)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ return error;
+ }
+ #endregion
+
+ #region 字符转义
+ ///
+ /// 各种文本转义字符
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 文本字符串
+ ///
+ public static string formatEdiStr(string fileType, string str)
+ {
+ if (fileType == "txt")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'");
+ }
+ else if (fileType == "xml")
+ {
+ return str.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
+ }
+ else if (fileType == "sitc")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("'", "?'");
+ }
+ else
+ {
+ return str;
+ }
+ }
+ #endregion
+ #region 格式化每行
+ public static List 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 DestList = new List();
+ 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 IsCreateWYEDI(MsWYEdiModel InttrEdi)
+ {
+ var error = "";
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDCODE))
+ { error = error + "
发送方代码不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDNAME))
+ { error = error + "
发送方名称不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.RECEIVECODE))
+ { error = error + "
接收方代码不能为空"; }
+
+ //if (InttrEdi.filetype == "B")
+ //{
+ // if (InttrEdi.UseForWarderCode)
+ // {
+ // if (string.IsNullOrEmpty(InttrEdi.ForWarderCode))
+ // { error = error + "
货代代码不能为空"; }
+
+ // if (string.IsNullOrEmpty(InttrEdi.ForWarderName))
+ // { error = error + "
货代称呼不能为空"; }
+ // }
+ //}
+
+
+ foreach (var headData in InttrEdi.BSLIST)
+ {
+
+ if (string.IsNullOrEmpty(headData.MBLNO))
+ { error = error + "
主提单号不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.BLFRT))
+ { error = error + "
提单号:" + headData.MBLNO + " 付费方式不能为空"; }
+
+
+
+ if (string.IsNullOrEmpty(headData.ETD))
+ {
+ if (string.IsNullOrEmpty(headData.VESSEL))
+ { error = error + "
提单号:" + headData.MBLNO + " 船名不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.VOYNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 航次不能为空"; }
+
+ }
+
+
+
+
+ if (string.IsNullOrEmpty(headData.PORTLOADID) || headData.PORTLOADID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 装货港代码不能为空或录入不正确(必须是5位代码)"; }
+
+ if (string.IsNullOrEmpty(headData.PORTLOAD))
+ { error = error + "
提单号:" + headData.MBLNO + " 装货港不能为空"; }
+
+
+ if (string.IsNullOrEmpty(headData.PORTDISCHARGEID) || headData.PORTDISCHARGEID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 卸货港代码不能为空或录入不正确(必须是5位代码)"; }
+ if (string.IsNullOrEmpty(headData.PORTDISCHARGE))
+ { error = error + "
提单号:" + headData.MBLNO + " 卸货港不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.PLACEDELIVERY) || headData.PLACEDELIVERYID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 交货地代码不能为空或录入不正确(必须是5位代码)"; }
+ if (string.IsNullOrEmpty(headData.PLACEDELIVERY))
+ { error = error + "
提单号:" + headData.MBLNO + " 交货地不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.DESTINATION))
+ {
+ if (string.IsNullOrEmpty(headData.DESTINATIONID) || headData.DESTINATIONID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 目的地代码不能为空或录入不正确(必须是5位代码)"; }
+ }
+
+ if (string.IsNullOrEmpty(headData.KINDPKGS_EDI_CODE))
+ { error = error + "
提单号:" + headData.MBLNO + " 包装EDI代码不能为空"; }
+ if (headData.PKGS == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 件数不能为0"; }
+ if (headData.KGS == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 毛重不能为0"; }
+ if (headData.CBM == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 尺码不能为0"; }
+
+ if (string.IsNullOrEmpty(headData.CARGOID))
+ { error = error + "
提单号:" + headData.MBLNO + " 货物标识不能为空"; }
+
+ if (headData.CARGOID == "D")
+ {
+ if (string.IsNullOrEmpty(headData.DCLASS))
+ { error = error + "
提单号:" + headData.MBLNO + " 危险品分类不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.DUNNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 危险品编号不能为空"; }
+ }
+ if (headData.CARGOID == "R")
+ {
+ if (headData.TEMPSET == null || headData.TEMPSET == "")
+ { error = error + "
提单号:" + headData.MBLNO + " 设置温度不能为空"; }
+ if (headData.REEFERF == null || headData.REEFERF == "")
+ { error = error + "
提单号:" + headData.MBLNO + " 通风度不能为空"; }
+ }
+ if (headData.ISSUEPLACE == null || headData.ISSUEPLACE == "")
+ { error = error + "
提单号:" + headData.MBLNO + "签单地点不能为空"; }
+
+ if (headData.CARRIEREDICODE == "APL")
+ if (headData.ISSUETYPE == null || headData.ISSUETYPE == "")
+ { error = error + "
提单号:" + headData.MBLNO + "签单方式不能为空"; }
+ if (headData.SERVICE == "" || headData.SERVICE == null)
+ { error = error + "
提单号:" + headData.MBLNO + "运输条款不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.MARKS))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 唛头不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.MARKS))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 唛头含有中文或双字节字符";
+ }
+ else
+ {
+ error += formatlengthError("txt", headData.MARKS, 35, headData.MBLNO, "唛头", 0, "", false);
+ }
+ }
+
+ if (string.IsNullOrEmpty(headData.DESCRIPTION))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 货物描述不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.DESCRIPTION))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 货物描述含有中文或双字节字符";
+ }
+ else
+ {
+ //error += formatlengthError("txt", bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 0, "");
+ }
+ }
+
+
+ if (string.IsNullOrEmpty(headData.SHIPPER))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 发货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.SHIPPER))
+ {
+ error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 收货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.CONSIGNEE))
+ {
+ error = error + "
提单号:" + 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 (string.IsNullOrEmpty(headData.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 通知人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + 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);
+ }
+
+ var ctnlist = headData.CTNLIST;
+ if (ctnlist.Count == 0) { error = error + "
提单号:" + headData.MBLNO + " 集装箱信息不能为空"; };
+
+ #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 + "
提单号:" + headData.MBLNO + " 集装箱箱型EDI代码不能为空"; }
+ if ((ctn.CTNALLCODE.IndexOf("RH") > 0 || ctn.CTNALLCODE.IndexOf("RF") > 0) && (headData.CARGOID != "R"))
+ {
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱箱型为冻柜,货类代码请选择冻柜"; }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+
+ if (string.IsNullOrEmpty(ctn.CNTRNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 箱号不能为空"; }
+ if (string.IsNullOrEmpty(ctn.SEALNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 封号不能为空"; }
+
+ if (ctn.KINDPKGS != headData.KINDPKGS)
+ { error = error + "
提单号:" + headData.MBLNO + " 中的包装类型与集装箱的包装类型不同"; }
+ dlPKGS += Convert.ToDecimal(ctn.PKGS);
+ dlKGS += Convert.ToDecimal(ctn.KGS);
+ dlCBM += Convert.ToDecimal(ctn.CBM);
+ }
+ }
+ if (InttrEdi.filetype == "E")
+ {
+ if (dlPKGS != Convert.ToDecimal(headData.PKGS))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱件数合计数必须等于委托单总件数"; }
+ if (dlKGS != Convert.ToDecimal(headData.KGS))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱重量合计数必须等于委托单总重量数"; }
+ if (dlCBM != Convert.ToDecimal(headData.CBM))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱尺码合计数必须等于委托单总尺码数"; }
+ }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+ 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 + "
提单号:" + headData.MBLNO + "的“" + ctn.CNTRNO + "”未添加分箱明细!";
+ }
+ else
+ {
+ if (ctngoodssumpkgs != Convert.ToDecimal(ctn.PKGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细件数合计数不等于集装箱件数"; }
+ if (ctngoodssumkgs != Convert.ToDecimal(ctn.KGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细毛重合计数不等于集装箱毛重"; }
+ if (ctngoodssumcbm != Convert.ToDecimal(ctn.CBM))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细尺码合计数不等于集装箱毛重"; }
+
+ }
+
+ }
+
+ foreach (var ctngood in headData.CTNGOODSLIST)
+ {
+ if (string.IsNullOrEmpty(ctngood.KINDPKGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型不能为空"; }
+ if (string.IsNullOrEmpty(ctngood.DESCRIPTION))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱货物描述不能为空"; }
+ else
+ {
+ error += formatlengthError("txt", ctngood.DESCRIPTION, 70, headData.MBLNO, "的“" + ctngood.CNTRNO + "”箱号的分箱货物描述", 0, "", false);
+ }
+ //if (string.IsNullOrEmpty(ctngood.HSCODE))
+ //{ error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱HS编码不能为空"; }
+ if (string.IsNullOrEmpty(ctngood.KINDPKGS_EDI_CODE))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型代码不能为空"; }
+
+ }
+
+ }
+
+ #endregion
+
+
+ }
+
+ }
+ return error;
+ }
+ #endregion
+
+ #region 生成报文(订舱(filetype=="B"),截单(filetype=="E"))
+ public static string CreateEdiWY(MsWYEdiModel InttrEdi)
+ {
+ var filetype = "IFTMBF";
+
+ string filename = InttrEdi.filerpath + "\\" + filetype + "_" + 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 = "";
+ var isfirst = true;
+ foreach (var bill in InttrEdi.BSLIST)
+ {
+ if (isfirst)
+ {
+ if (InttrEdi.filetype == "E")
+ r.WriteLine("00:IFTMBF:SI:" + InttrEdi.filerole + ":" + InttrEdi.SENDCODE + ":" + InttrEdi.RECEIVECODE + ":" + DateTime.Now.ToString("yyyyMMddHHmm") + ":2.1'");
+ else
+ r.WriteLine("00:IFTMBF:BK:" + InttrEdi.filerole + ":" + InttrEdi.SENDCODE + ":" + InttrEdi.RECEIVECODE + ":" + DateTime.Now.ToString("yyyyMMddHHmm") + ":2.1'");
+ isfirst = false;
+ icount++;
+
+ }
+
+ r.WriteLine("02"
+ + ":" + bill.ORDERNO//2 REFERENCE NO. 运编号 X(35) 一般为流水号 M
+ + ":" + bill.MBLNO//3 B\L NO. 提单号 X(20) 船公司的提单号 C
+ + ":" + bill.SERVICE//4 DELIVERY TERM 交货条款 X(9) CY-CY(pier-pier/port):30CY-CFS(pier/port-door):29CFS-CY(door-pier/port):28CFS-CFS(door-door):27 M
+ + ":" + formatEdiStr("txt", InttrEdi.ForWarderName.Replace("\n", " ").Replace("\r", " "))//5 BOOKING PARTY 订舱人说明 X(70) 货代方企业名称或代码 C
+ + ":" + InttrEdi.RECEIVECODE//6 ISSUE PARTY CODE 签单人代码 X(13) 即接受订舱的人的代码 M
+ + ":"//7 ISSUE PARTY 签单人说明 X(35) C
+ + ":"//8 APPLICANT 询价单位 X(13) 向船公司询价的单位代码 C
+ + ":"//9 FOB BK PARTY 国外订舱单位 X(13) 国外FOB货订舱单位的代码 C
+ + ":"//10 B/L TRANSHIP ID 转船标识 X(1) Y/N C
+ + ":"//11 BATCH ID 分批 X(1) Y/N C
+ + ":"//12 SHIPMENT DATE 装期 9(8) CCYYMMDD C
+ + ":"//13 EXPIRY DATE 效期 9(8) CCYYMMDD C
+ + ":" + bill.CONTRACTNO//14 QUOTATION NO. 运费协议号 X(30) MAERSK为必选 C
+ + ":"//15 CHARGE TYPE 费率本代码 X(1) C
+ + ":" //16 S/C NO. 合约号 X(30) C
+ + "'");
+
+ icount++;
+
+ var ISSUETYPE = "";
+ if (bill.ISSUETYPE == "正本")
+ {
+ ISSUETYPE = "ORI";
+ }
+ else if (bill.ISSUETYPE == "电放")
+ {
+ ISSUETYPE = "TER";
+ }
+ else ISSUETYPE = "EXP";
+
+
+
+ r.WriteLine("03:" + ISSUETYPE + ":" + bill.ISSUEPLACEID.Trim() + ":" + bill.ISSUEPLACE.Trim() + ":" + GetDateStr(bill.ISSUEDATE, "yyyyMMdd") + ":" + GetBillNum2(bill.NOBILL) + ":" + bill.PREPARDAT + ":" + bill.PAYABLEAT + "'");
+ icount++;
+
+
+ r.WriteLine("11:" + bill.VESSELID + ":" + bill.VESSEL + ":" + bill.VOYNO + "::" + bill.CARRIEREDICODE + ":" + bill.CARRIER + ":::::::'");
+ icount++;
+
+ var DESTINATIONID = bill.DESTINATIONID;
+ var DESTINATION = bill.DESTINATION;
+ if (bill.CARRIEREDICODE == "ONEY" || bill.CARRIEREDICODE == "ZIM")
+ {
+ DESTINATIONID = "";
+ DESTINATION = "";
+ }
+
+ r.WriteLine("12"
+ + ":" + bill.PLACERECEIPTID//2 PLACE CODE OF RECEIPT 收货地代码 X(5) OOCL、HLC的订舱要求必选 O
+ + ":" + bill.PLACERECEIPT//3 PLACE OF RECEIPT 收货地 X(35) C
+ + ":" + bill.PORTLOADID//4 LOAD PORT CODE 装货港代码 X(5) OOCL的订舱要求必选 O
+ + ":" + bill.PORTLOAD//5 LOAD PORT 装货港 X(35) C
+ + ":" + bill.PORTDISCHARGEID//6 DISCHARGE PORT CODE 卸货港代码 X(5) OOCL的订舱要求必选 M
+ + ":" + bill.PORTDISCHARGE//7 DISCHARGE PORT 卸货港 X(35) C
+ + ":" + bill.TRANSPORTID //8 TRANSFER PORT CODE 中转港代码 X(5) C
+ + ":" + bill.TRANSPORT//9 TRANSFER PORT 中转港 X(35) C
+ + ":" + bill.PLACEDELIVERYID//10 PLACE OF DELIVERY CODE 交货地代码 X(5) OOCL的订舱要求必选 O
+ + ":" + bill.PLACEDELIVERY//11 PLACE OF DELIVERY 交货地 X(35) C
+ + ":" + DESTINATIONID//12 FINAL DESTINATION CODE 目的地代码 X(5) C
+ + ":" + DESTINATION//13 FINAL DESTINATION CODE 目的地 X(35) C
+ + ":" + bill.YARDEDICODE//14 FINAL DESTINATION CODE 目的地 X(35) C
+ + "'");
+
+ icount = icount + 1;
+
+ r.WriteLine("14:" + bill.BLFRTEDICODE + ":" + bill.BLFRT + "'");
+ if (InttrEdi.filetype == "E")
+ r.WriteLine("15:::" + bill.BLFRTEDICODE + ":" + bill.PAYABLEATID + ":::::'");
+ else
+ r.WriteLine("15:::" + bill.BLFRTEDICODE + "::::::'");
+ icount = icount + 2;
+
+
+ var Shipping = "";
+ if (InttrEdi.filetype == "E")
+ Shipping = formatEdiStr("txt", bill.SIREMARK);
+ else
+ Shipping = formatEdiStr("txt", bill.EDIREMARK);
+
+ List ShippingList = formatlengthStr(Shipping, 70);
+
+ if (Shipping != "")
+ {
+ r.WriteLine("17:" + formatListStr(ShippingList, 5) + "'");
+ icount++;
+ }
+
+
+
+ Shipping = formatEdiStr("txt", bill.SHIPPER);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ r.WriteLine("18::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+ }
+
+
+
+ Shipping = formatEdiStr("txt", bill.CONSIGNEE);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ r.WriteLine("19::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+ }
+
+
+ Shipping = formatEdiStr("txt", bill.NOTIFYPARTY);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ r.WriteLine("20::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+ }
+
+
+ Shipping = formatEdiStr("txt", InttrEdi.ForWarderName);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (Shipping != "")
+ {
+
+ r.WriteLine("23::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+
+
+ }
+
+ var ctnsumlist = new List();
+ 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 ctnsum in ctnsumlist)
+ {
+ r.WriteLine("40:" + ctnsum.CTNALLCODE + ":" + ctnsum.CTNNUM + ":F:::::N'");
+ icount++;
+ }
+
+
+ var cargoid = bill.CARGOID;
+ if (cargoid == "" || cargoid == " ") cargoid = "S";
+
+ var kingweight = bill.KINGTAREWEIGHT;
+ if (kingweight == 0)
+ kingweight = 100;
+
+ r.WriteLine("41:1:" + bill.HSCODE + ":" + cargoid + ":" + bill.PKGS.ToString() + ":" + bill.KINDPKGS_EDI_CODE + ":" + bill.KINDPKGS + ":" + kingweight.ToString() + ":"
+ + bill.CBM.ToString() + "::::::" + bill.KGS.ToString() + ":::'");
+
+ icount = icount + 1;
+ if (cargoid == "R")
+ r.WriteLine("43::::::::::" + bill.REEFERF + ":C:" + bill.TEMPSET + ":" + bill.TEMPMIN + ":" + bill.TEMPMAX + ":::::'");
+ else if (cargoid == "D")
+ r.WriteLine("43:" + bill.DCLASS + ":" + bill.DPAGE + ":" + bill.DUNNO + ":" + bill.DLABEL + "::::::::::::'");
+
+ icount = icount + 1;
+
+
+ Shipping = formatEdiStr("txt", bill.MARKS);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ for (var i = 0; i < Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(ShippingList.Count) / Convert.ToDecimal(10))); i++)
+ {
+ var tempstr = "44:";
+ for (var z = 0; z < 10; z++)
+ {
+ if ((i * 10 + z) < ShippingList.Count)
+ tempstr = tempstr + ShippingList[i * 10 + z];
+ if (z < 9) tempstr = tempstr + ":";
+ }
+ if (tempstr != "44:")
+ {
+ r.WriteLine(tempstr + "'");
+ icount++;
+ }
+ }
+
+ Shipping = formatEdiStr("txt", bill.DESCRIPTION);
+ ShippingList = formatlengthStr(Shipping, 70);
+
+ var m = 1;
+ var strtemp = "";
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+
+ for (var i = 0; i < ShippingList.Count; i++)
+ {
+ if (ShippingList[i] != "")
+ {
+ if (m <= 5)
+ {
+ if (m == 1) strtemp = "47:" + ShippingList[i] + ":";
+ else
+ {
+ if (m == 5)
+ strtemp = strtemp + ShippingList[i];
+ else
+ strtemp = strtemp + ShippingList[i] + ":";
+ }
+ }
+ else
+ {
+ m = 1;
+ r.WriteLine(strtemp + "'");
+ strtemp = "47:" + ShippingList[i] + ":";
+ icount = icount + 1;
+ }
+ m = m + 1;
+ }
+ }
+ }
+ if (strtemp != "")
+ {
+ r.WriteLine(strtemp + "'");
+ icount = icount + 1;
+ }
+
+ var ISSOC = "N";
+ if (bill.ISCONTAINERSOC) ISSOC = "Y";
+ foreach (var ctn in bill.CTNLIST)
+ {
+ r.WriteLine("51:" + ctn.CNTRNO + ":" + ctn.CTNALLCODE + ":" + ctn.SEALNO + ":::" + ctn.CTNSTATUS + ":" + ctn.PKGS.ToString() + ":" + ctn.KGS.ToString() + ":" + ctn.TAREWEIGHT + ":" + ctn.CBM + "'");
+ icount = icount + 1;
+ }
+ }
+ icount = icount + 1;
+ r.WriteLine("99:" + icount.ToString() + "'");
+ r.Close();
+ f.Close();
+
+ return filename;
+ }
+ #endregion
+ }
+
+ public class MsWYEdiModel
+ {
+
+ ///
+ /// 发送方代码 M
+ ///
+ public string SENDCODE { get; set; }
+
+ ///
+ /// 发送方名称 M
+ ///
+ public string SENDNAME { get; set; }
+
+ ///
+ /// 接收方代码 M
+ ///
+ public string RECEIVECODE { get; set; }
+
+ ///
+ /// 文件类型 (B订舱,E SI确认)M
+ ///
+ public string filetype { get; set; }
+
+ ///
+ /// 文件功能 (9原始,1 更新,5 退舱 )M
+ ///
+ public string filerole { get; set; }
+
+ ///
+ /// 文件路径 M
+ ///
+ public string filerpath { get; set; }
+
+ ///
+ /// 是否使用货代代码。 M
+ ///
+ public bool UseForWarderCode { get; set; }
+ ///
+ /// 货代代码。 O
+ ///
+ public string ForWarderCode { get; set; }
+
+ ///
+ /// 货代名称 O
+ ///
+ public string ForWarderName { get; set; }
+
+ ///
+ /// 业务信息列表 M
+ ///
+ public List BSLIST { get; set; }
+
+
+ }
+
+
+ public class MsOpSeaeEdiModel
+ {
+
+
+ ///
+ /// 委托方
+ ///
+ public string WEITUO { get; set; }
+
+ ///
+ /// 操作英文名称 M
+ ///
+ public string OpEName { get; set; }
+
+ ///
+ /// 操作电话 M
+ ///
+ public string OpTel { get; set; }
+ ///
+ /// 操作邮箱 M
+ ///
+ public string OpEmail { get; set; }
+
+ ///
+ /// EDI联系人名称 O
+ ///
+ public string EDIATTN { get; set; }
+
+ ///
+ /// EDI联系人电话 O
+ ///
+ public string EDIATTNTEL { get; set; }
+ ///
+ /// EDI联系人邮箱 O
+ ///
+ public string EDIATTNEMAIL { get; set; }
+ ///
+ /// 订舱编号 O
+ ///
+ public string ORDERNO { get; set; }
+
+ ///
+ /// 主提单号 M
+ ///
+ public string MBLNO { get; set; }
+
+ ///
+ /// 付费方式代码 M
+ ///
+ public string BLFRTEDICODE { get; set; }
+
+
+ ///
+ /// 付费方式 M
+ ///
+ public string BLFRT { get; set; }
+
+ ///
+ /// 船名 O
+ ///
+ public string VESSEL { get; set; }
+
+ ///
+ /// 船舶呼号 O
+ ///
+ public string VESSELID { get; set; }
+
+
+ ///
+ /// 航次 O
+ ///
+ public string VOYNO { get; set; }
+
+
+ ///
+ /// 内部航次 O
+ ///
+ public string NVOYNO { get; set; }
+
+ ///
+ /// 开船日期 M
+ ///
+ public string ETD { get; set; }
+
+ ///
+ /// EDI备注
+ ///
+ public string EDIREMARK { get; set; }
+
+ ///
+ /// SI备注
+ ///
+ public string SIREMARK { get; set; }
+
+ ///
+ /// NVO NO
+ ///
+ public string NVONO { get; set; }
+
+ ///
+ /// 船公司名称 M
+ ///
+ public string CARRIER { get; set; }
+ ///
+ /// 船公司EDI代码 M
+ ///
+ public string CARRIEREDICODE { get; set; }
+
+ ///
+ /// 发货人 M
+ ///
+ public string SHIPPER { get; set; }
+
+ ///
+ /// 收货人 M
+ ///
+ public string CONSIGNEE { get; set; }
+
+ ///
+ /// 通知人 M
+ ///
+ public string NOTIFYPARTY { get; set; }
+
+ ///
+ /// 第二通知人
+ ///
+ public string NOTIFYPARTY2 { get; set; }
+
+ ///
+ /// AMS收货人
+ ///
+ public string AMSCONSIGNEE { get; set; }
+
+ ///
+ /// AMS通知人
+ ///
+ public string AMSNOTIFYPARTY { get; set; }
+
+
+ ///
+ /// 收货地所在国家 O
+ ///
+ public string BYCOUNTRY { get; set; }
+
+ /////
+ ///// AMS发货人 O
+ /////
+ //public string AMSSHIPPER { get; set; }
+
+ /////
+ ///// AMS收货人 O
+ /////
+ //public string AMSCONSIGNEE { get; set; }
+
+ /////
+ ///// AMS通知人 O
+ /////
+ //public string AMSNOTIFYPARTY { get; set; }
+
+ ///
+ /// HS编码
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+
+
+
+
+ ///
+ /// 收货地代码(每船公司可能不同)
+ ///
+ public string PLACERECEIPTID { get; set; }
+ ///
+ /// 收货地
+ ///
+ public string PLACERECEIPT { get; set; }
+
+
+ ///
+ /// 起运港代码(每船公司可能不同) M
+ ///
+ public string PORTLOADID { get; set; }
+ ///
+ /// 起运港 M
+ ///
+ public string PORTLOAD { get; set; }
+
+
+ ///
+ ///卸货港代码(每船公司可能不同) M
+ ///
+ public string PORTDISCHARGEID { get; set; }
+ ///
+ /// 卸货港 M
+ ///
+ public string PORTDISCHARGE { get; set; }
+
+
+ ///
+ ///中转港代码
+ ///
+ public string TRANSPORTID { get; set; }
+ ///
+ /// 中转港
+ ///
+ public string TRANSPORT { get; set; }
+
+
+ ///
+ ///交货地代码M
+ ///
+ public string PLACEDELIVERYID { get; set; }
+ ///
+ /// 交货地 M
+ ///
+ public string PLACEDELIVERY { get; set; }
+
+ ///
+ ///目的地代码(每船公司可能不同)
+ ///
+ public string DESTINATIONID { get; set; }
+ ///
+ /// 目的地
+ ///
+ public string DESTINATION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ ///
+ /// 货物标识 M
+ ///
+ public string CARGOID { get; set; }
+
+ ///
+ /// 第一层包装皮重 O
+ ///
+ public decimal KINGTAREWEIGHT { get; set; }
+
+
+ ///
+ /// 危险品类别 O
+ ///
+ public string DCLASS { get; set; }
+
+ ///
+ /// 危险品编号 O
+ ///
+ public string DUNNO { get; set; }
+
+ ///
+ /// 危险品页号 C
+ ///
+ public string DPAGE { get; set; }
+
+ ///
+ /// 危险品标签 C
+ ///
+ public string DLABEL { get; set; }
+
+ ///
+ /// 设置温度 O
+ ///
+ public string TEMPSET { get; set; }
+
+
+ ///
+ /// 设置最低温度 C
+ ///
+ public string TEMPMIN { get; set; }
+
+ ///
+ /// 设置最高温度 C
+ ///
+ public string TEMPMAX { get; set; }
+
+
+ ///
+ /// 通风度 O
+ ///
+ public string REEFERF { get; set; }
+
+
+ ///
+ /// 湿度
+ ///
+ public string HUMIDITY { get; set; }
+
+ ///
+ /// 预付地点 O
+ ///
+ public string PREPARDAT { get; set; }
+
+ ///
+ /// 到付地点 O
+ ///
+ public string PAYABLEAT { get; set; }
+
+ ///
+ /// 预付地点EDI代码 O
+ ///
+ public string PREPARDATID { get; set; }
+
+ ///
+ /// 到付地点EDI代码 O
+ ///
+ public string PAYABLEATID { get; set; }
+
+
+ ///
+ /// 签单方式 M(SI)
+ ///
+ public string ISSUETYPE { get; set; }
+
+ ///
+ /// 提单份数 M(SI)
+ ///
+ public string NOBILL { get; set; }
+
+ ///
+ /// 签单地点 M(SI)
+ ///
+ public string ISSUEPLACE { get; set; }
+
+
+ ///
+ /// 签单地点
+ ///
+ public string ISSUEDATE { get; set; }
+
+ ///
+ /// 提单副本份数 M(SI)
+ ///
+ public string COPYNOBILL { get; set; }
+ ///
+ /// 签单地点EDI代码 M(SI)
+ ///
+ public string ISSUEPLACEID { get; set; }
+
+
+ ///
+ /// 运输条款 M
+ ///
+ public string SERVICE { get; set; }
+ ///
+ /// 场站EDI代码
+ ///
+ public string YARDEDICODE { get; set; }
+ ///
+ /// 运费协议号 M
+ ///
+ public string CONTRACTNO { get; set; }
+
+ ///
+ /// 服务合同号
+ ///
+ public string SERVICECONTRACTNO { get; set; }
+
+ ///
+ /// ESL航线代码 M
+ ///
+ public string ESLLINECODE { get; set; }
+
+ ///
+ /// 收货人邮编 O
+ ///
+ public string CONSIGNEEPOSTCODE { get; set; }
+
+ ///
+ /// 收货人国家 O
+ ///
+ public string CONSIGNEECOUNTRY { get; set; }
+
+ ///
+ /// 收货人税号 O
+ ///
+ public string CONSIGNEETAXNO { get; set; }
+
+ ///
+ /// 通知人邮编 O
+ ///
+ public string NOTIFYPARTYPOSTCODE { get; set; }
+
+ ///
+ /// 通知人国家 O
+ ///
+ public string NOTIFYPARTYCOUNTRY { get; set; }
+
+ ///
+ /// 通知人税号 O
+ ///
+ public string NOTIFYPARTYTAXNO { get; set; }
+
+ ///
+ /// 货物NCM编号 O
+ ///
+ public string GOODSNCM { get; set; }
+
+
+ ///
+ /// 收货人DOOR地址 O
+ ///
+ public string CONSIGNEEDOORADDR { get; set; }
+
+ ///
+ /// 发货人DOOR地址 O
+ ///
+ public string SHIPPERDOORADDR { get; set; }
+
+
+ ///
+ /// SCAC代码 O
+ ///
+ public string SCACCODE { get; set; }
+
+ ///
+ /// ITN编号 O
+ ///
+ public string ITNCODE { get; set; }
+ ///
+ /// 付费方 O
+ ///
+ public string FREIGHTPAYER { get; set; }
+
+ ///
+ /// AMS代码 O
+ ///
+ public string AMSCODE { get; set; }
+ ///
+ /// 是否SOC箱 O
+ ///
+ public bool ISCONTAINERSOC { get; set; }
+
+ ///
+ /// 拆并单列表 O
+ ///
+ public string BSNOLIST { get; set; }
+
+
+
+ ///
+ /// 集装箱明细 M
+ ///
+ public List CTNLIST { get; set; }
+
+ ///
+ /// 集装箱多品名明细 M
+ ///
+ public List CTNGOODSLIST { get; set; }
+ }
+
+ public class MsOpSeaeCtnEdiModel
+ {
+
+ ///
+ /// 箱型EDI代码 M
+ ///
+ public string CTNALLCODE { get; set; }
+
+ public Int32 CTNNUM { get; set; }
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// 封号 M
+ ///
+ public string SEALNO { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+ ///
+ /// 箱皮重
+ ///
+ public string TAREWEIGHT { get; set; }
+
+ ///
+ /// 称重重量
+ ///
+ public string WEIGHKGS { get; set; }
+
+ ///
+ /// 称重方式 (累加、总重)
+ ///
+ public string WEIGHTYPE { get; set; }
+
+ ///
+ /// 称重签名
+ ///
+ public string WEIGHSIGN { get; set; }
+
+ ///
+ /// 箱动态
+ ///
+ public string CTNSTATUS { get; set; }
+
+
+
+ }
+ public class MsOpSeaeCtnDetailEdiModel
+ {
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// HS编码 M
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ }
+}
diff --git a/Myshipping.Application/EDI/YMLEdiHelper.cs b/Myshipping.Application/EDI/YMLEdiHelper.cs
new file mode 100644
index 00000000..f65b8387
--- /dev/null
+++ b/Myshipping.Application/EDI/YMLEdiHelper.cs
@@ -0,0 +1,2472 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application.EDI.YML
+{
+ public class YMLEdiHelper
+ {
+
+ public YMLEdiHelper()
+ {
+ }
+
+ #region 基本函数
+ 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 "";
+ }
+
+
+ public static string GetDateStr(string datestr, string dateformat)
+ {
+ var result = "";
+
+ if (datestr == null || datestr == "")
+ {
+ result = "";
+ }
+ else
+ {
+ result = Convert.ToDateTime(datestr).ToString(dateformat);
+
+ }
+
+ return result;
+
+ }
+
+ #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
+
+ public static string formatListStr(List DestList, int lineCount, bool isformat = false)
+ {
+ var result = "";
+ for (var i = 0; i < lineCount; i++)
+ {
+ if (DestList.Count > i)
+ {
+ if (isformat)
+ result = result + formatEdiStr("txt", DestList[i]);
+ else
+ result = result + DestList[i];
+ }
+ if (i != (lineCount - 1))
+ result = result + ":";
+
+
+ }
+ return result;
+ }
+
+
+ #region 文本字段判断每行是否符合
+ ///
+ /// edi 文本格式处理判断(例如:1行35个字符不超过5行)
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 要处理的数据
+ /// 每行长度
+ /// 主提单号
+ /// 数据类型(例如:发货人内容、货描等)
+ /// 限制录入的行数(“0”代表不限制)
+ /// 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+ ///
+ 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 + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ else
+ {
+ if (argAGENT.Length > rowNum && rowNum != 0)
+ {
+ if (isHuoMiao)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ return error;
+ }
+ #endregion
+
+ #region 字符转义
+ ///
+ /// 各种文本转义字符
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 文本字符串
+ ///
+ public static string formatEdiStr(string fileType, string str)
+ {
+ if (fileType == "txt")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'");
+ }
+ else if (fileType == "xml")
+ {
+ return str.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
+ }
+ else if (fileType == "sitc")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("'", "?'");
+ }
+ else
+ {
+ return str;
+ }
+ }
+ #endregion
+ #region 格式化每行
+ public static List 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 DestList = new List();
+ 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 IsCreateYMLEDI(MsYMLEdiModel InttrEdi)
+ {
+ var error = "";
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDCODE))
+ { error = error + "
发送方代码不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDNAME))
+ { error = error + "
发送方名称不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.RECEIVECODE))
+ { error = error + "
接收方代码不能为空"; }
+
+ //if (InttrEdi.filetype == "B")
+ //{
+ // if (InttrEdi.UseForWarderCode)
+ // {
+ // if (string.IsNullOrEmpty(InttrEdi.ForWarderCode))
+ // { error = error + "
货代代码不能为空"; }
+
+ // if (string.IsNullOrEmpty(InttrEdi.ForWarderName))
+ // { error = error + "
货代称呼不能为空"; }
+ // }
+ //}
+
+
+ foreach (var headData in InttrEdi.BSLIST)
+ {
+ if (InttrEdi.filetype != "B")
+ if (string.IsNullOrEmpty(headData.MBLNO))
+ { error = error + "
主提单号不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.BLFRT))
+ { error = error + "
提单号:" + headData.MBLNO + " 付费方式不能为空"; }
+ if (string.IsNullOrEmpty(headData.EDIATTN))
+ { error = error + "
提单号:" + headData.MBLNO + " EDI联系人不能为空"; }
+ if (string.IsNullOrEmpty(headData.EDIATTNTEL))
+ { error = error + "
提单号:" + headData.MBLNO + " EDI联系人电话不能为空"; }
+ if (string.IsNullOrEmpty(headData.EDIATTNEMAIL))
+ { error = error + "
提单号:" + headData.MBLNO + " EDI联系人邮编不能为空"; }
+
+
+ if (InttrEdi.filetype == "E")
+ {
+ if (string.IsNullOrEmpty(headData.VESSELID))
+ { error = error + "
提单号:" + headData.MBLNO + " 船舶呼号不能为空"; }
+
+
+ if (InttrEdi.filetype != "B" || headData.CARRIEREDICODE == "YML")
+ {
+ if (string.IsNullOrEmpty(headData.ETD))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 开船日期不能为空";
+ return error;
+ }
+ }
+ }
+
+ if (string.IsNullOrEmpty(headData.PLACERECEIPTID) || headData.PLACERECEIPTID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 收货地代码不能为空或录入不正确(必须是5位代码)"; }
+
+ if (string.IsNullOrEmpty(headData.PLACERECEIPT))
+ { error = error + "
提单号:" + headData.MBLNO + " 收货地不能为空"; }
+
+
+ if (string.IsNullOrEmpty(headData.PORTLOADID) || headData.PORTLOADID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 装货港代码不能为空或录入不正确(必须是5位代码)"; }
+
+ if (string.IsNullOrEmpty(headData.PORTLOAD))
+ { error = error + "
提单号:" + headData.MBLNO + " 装货港不能为空"; }
+
+
+ if (string.IsNullOrEmpty(headData.PORTDISCHARGEID) || headData.PORTDISCHARGEID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 卸货港代码不能为空或录入不正确(必须是5位代码)"; }
+ if (string.IsNullOrEmpty(headData.PORTDISCHARGE))
+ { error = error + "
提单号:" + headData.MBLNO + " 卸货港不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.PLACEDELIVERY) || headData.PLACEDELIVERYID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 交货地代码不能为空或录入不正确(必须是5位代码)"; }
+ if (string.IsNullOrEmpty(headData.PLACEDELIVERY))
+ { error = error + "
提单号:" + headData.MBLNO + " 交货地不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.DESTINATION))
+ {
+ if (string.IsNullOrEmpty(headData.DESTINATIONID) || headData.DESTINATIONID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 目的地代码不能为空或录入不正确(必须是5位代码)"; }
+ }
+
+ if (string.IsNullOrEmpty(headData.KINDPKGS_EDI_CODE))
+ { error = error + "
提单号:" + headData.MBLNO + " 包装EDI代码不能为空"; }
+ if (headData.PKGS == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 件数不能为0"; }
+ if (headData.KGS == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 毛重不能为0"; }
+ if (headData.CBM == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 尺码不能为0"; }
+
+ if (string.IsNullOrEmpty(headData.CARGOID))
+ { error = error + "
提单号:" + headData.MBLNO + " 货物标识不能为空"; }
+
+ if (headData.CARGOID == "D")
+ {
+ if (string.IsNullOrEmpty(headData.DCLASS))
+ { error = error + "
提单号:" + headData.MBLNO + " 危险品分类不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.DUNNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 危险品编号不能为空"; }
+ }
+ if (headData.CARGOID == "R")
+ {
+ if (headData.TEMPSET == null || headData.TEMPSET == "")
+ { error = error + "
提单号:" + headData.MBLNO + " 设置温度不能为空"; }
+ if (headData.REEFERF == null || headData.REEFERF == "")
+ { error = error + "
提单号:" + headData.MBLNO + " 通风度不能为空"; }
+ }
+ if (headData.ISSUEPLACE == null || headData.ISSUEPLACE == "")
+ { error = error + "
提单号:" + headData.MBLNO + "签单地点不能为空"; }
+
+ if (headData.CARRIEREDICODE == "APL")
+ if (headData.ISSUETYPE == null || headData.ISSUETYPE == "")
+ { error = error + "
提单号:" + headData.MBLNO + "签单方式不能为空"; }
+ if (headData.SERVICE == "" || headData.SERVICE == null)
+ { error = error + "
提单号:" + headData.MBLNO + "运输条款不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.MARKS))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 唛头不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.MARKS))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 唛头含有中文或双字节字符";
+ }
+ else
+ {
+ error += formatlengthError("txt", headData.MARKS, 35, headData.MBLNO, "唛头", 0, "", false);
+ }
+ }
+
+ if (string.IsNullOrEmpty(headData.DESCRIPTION))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 货物描述不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.DESCRIPTION))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 货物描述含有中文或双字节字符";
+ }
+ else
+ {
+ //error += formatlengthError("txt", bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 0, "");
+ }
+ }
+
+
+ if (string.IsNullOrEmpty(headData.SHIPPER))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 发货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.SHIPPER))
+ {
+ error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 收货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.CONSIGNEE))
+ {
+ error = error + "
提单号:" + 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 (string.IsNullOrEmpty(headData.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 通知人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + 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);
+ }
+
+ var ctnlist = headData.CTNLIST;
+ if (ctnlist.Count == 0) { error = error + "
提单号:" + headData.MBLNO + " 集装箱信息不能为空"; };
+
+ #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 + "
提单号:" + headData.MBLNO + " 集装箱箱型EDI代码不能为空"; }
+ if ((ctn.CTNALLCODE.IndexOf("RH") > 0 || ctn.CTNALLCODE.IndexOf("RF") > 0) && (headData.CARGOID != "R"))
+ {
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱箱型为冻柜,货类代码请选择冻柜"; }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+
+ if (string.IsNullOrEmpty(ctn.CNTRNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 箱号不能为空"; }
+ if (string.IsNullOrEmpty(ctn.SEALNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 封号不能为空"; }
+
+ if (ctn.KINDPKGS != headData.KINDPKGS)
+ { error = error + "
提单号:" + headData.MBLNO + " 中的包装类型与集装箱的包装类型不同"; }
+ dlPKGS += Convert.ToDecimal(ctn.PKGS);
+ dlKGS += Convert.ToDecimal(ctn.KGS);
+ dlCBM += Convert.ToDecimal(ctn.CBM);
+ }
+ }
+ if (InttrEdi.filetype == "E")
+ {
+ if (dlPKGS != Convert.ToDecimal(headData.PKGS))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱件数合计数必须等于委托单总件数"; }
+ if (dlKGS != Convert.ToDecimal(headData.KGS))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱重量合计数必须等于委托单总重量数"; }
+ if (dlCBM != Convert.ToDecimal(headData.CBM))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱尺码合计数必须等于委托单总尺码数"; }
+ }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+ 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 + "
提单号:" + headData.MBLNO + "的“" + ctn.CNTRNO + "”未添加分箱明细!";
+ }
+ else
+ {
+ if (ctngoodssumpkgs != Convert.ToDecimal(ctn.PKGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细件数合计数不等于集装箱件数"; }
+ if (ctngoodssumkgs != Convert.ToDecimal(ctn.KGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细毛重合计数不等于集装箱毛重"; }
+ if (ctngoodssumcbm != Convert.ToDecimal(ctn.CBM))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细尺码合计数不等于集装箱毛重"; }
+
+ }
+
+ }
+
+ foreach (var ctngood in headData.CTNGOODSLIST)
+ {
+ if (string.IsNullOrEmpty(ctngood.KINDPKGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型不能为空"; }
+ if (string.IsNullOrEmpty(ctngood.DESCRIPTION))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱货物描述不能为空"; }
+ else
+ {
+ error += formatlengthError("txt", ctngood.DESCRIPTION, 70, headData.MBLNO, "的“" + ctngood.CNTRNO + "”箱号的分箱货物描述", 0, "", false);
+ }
+ //if (string.IsNullOrEmpty(ctngood.HSCODE))
+ //{ error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱HS编码不能为空"; }
+ if (string.IsNullOrEmpty(ctngood.KINDPKGS_EDI_CODE))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型代码不能为空"; }
+
+ }
+
+ }
+
+ #endregion
+
+
+ }
+
+ }
+ return error;
+ }
+ #endregion
+
+ #region 生成报文(订舱)
+ public static string CreateEdiYML(MsYMLEdiModel InttrEdi)
+ {
+ var filetype = "IFTMBF";
+ string filename = InttrEdi.filerpath + "\\" + filetype + "_" + 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 = "";
+ var isfirst = true;
+ foreach (var bill in InttrEdi.BSLIST)
+ {
+ if (isfirst)
+ {
+ r.WriteLine("00:IFTMBF:BOOKING:" + InttrEdi.filerole + ":" + InttrEdi.SENDCODE + ":" + InttrEdi.RECEIVECODE + ":" + DateTime.Now.ToString("yyyyMMddHHmm") + "'");
+ isfirst = false;
+ icount++;
+
+ }
+
+
+ r.WriteLine("02"
+ + ":" + bill.ORDERNO//2 REFERENCE NO. 运编号 X(35) 一般为流水号 M
+ + ":" + bill.MBLNO//3 B\L NO. 提单号 X(20) 船公司的提单号 C
+ + ":" + bill.SERVICE//4 DELIVERY TERM 交货条款 X(9) CY-CY(pier-pier/port):30CY-CFS(pier/port-door):29CFS-CY(door-pier/port):28CFS-CFS(door-door):27 M
+ + ":" + InttrEdi.SENDNAME//5 BOOKING PARTY 订舱人说明 X(70) 货代方企业名称或代码 C
+ + ":" + InttrEdi.RECEIVECODE//6 ISSUE PARTY CODE 签单人代码 X(13) 即接受订舱的人的代码 M
+ + ":"//7 ISSUE PARTY 签单人说明 X(35) C
+ + ":"//8 APPLICANT 询价单位 X(13) 向船公司询价的单位代码 C
+ + ":"//9 FOB BK PARTY 国外订舱单位 X(13) 国外FOB货订舱单位的代码 C
+ + ":"//10 B/L TRANSHIP ID 转船标识 X(1) Y/N C
+ + ":"//11 BATCH ID 分批 X(1) Y/N C
+ + ":"//12 SHIPMENT DATE 装期 9(8) CCYYMMDD C
+ + ":"//13 EXPIRY DATE 效期 9(8) CCYYMMDD C
+ + ":" + bill.CONTRACTNO//14 QUOTATION NO. 运费协议号 X(30) MAERSK为必选 C
+ + ":"//15 CHARGE TYPE 费率本代码 X(1) C
+ + "'");
+
+ icount++;
+
+ var ISSUETYPE = "";
+ if (bill.ISSUETYPE == "正本")
+ {
+ ISSUETYPE = "ORI";
+ }
+ else if (bill.ISSUETYPE == "电放")
+ {
+ ISSUETYPE = "TER";
+ }
+ else ISSUETYPE = "EXP";
+
+
+
+ r.WriteLine("03:" + ISSUETYPE + ":" + bill.ISSUEPLACEID.Trim() + ":" + bill.ISSUEPLACE.Trim() + ":" + GetDateStr(bill.ISSUEDATE, "yyyyMMdd") + ":" + GetBillNum2(bill.NOBILL) + ":" + bill.PREPARDAT + ":" + bill.PAYABLEAT + "'");
+ icount++;
+
+
+ r.WriteLine("11:" + bill.VESSELID + ":" + bill.VESSEL + ":" + bill.VOYNO + ":::::" + GetDateStr(bill.ETD, "yyyyMMdd") + ":::::'");
+ icount++;
+
+ var DESTINATIONID = bill.DESTINATIONID;
+ var DESTINATION = bill.DESTINATION;
+
+ r.WriteLine("12"
+ + ":" + bill.PLACERECEIPTID//2 PLACE CODE OF RECEIPT 收货地代码 X(5) OOCL、HLC的订舱要求必选 O
+ + ":" + bill.PLACERECEIPT//3 PLACE OF RECEIPT 收货地 X(35) C
+ + ":" + bill.PORTLOADID//4 LOAD PORT CODE 装货港代码 X(5) OOCL的订舱要求必选 O
+ + ":" + bill.PORTLOAD//5 LOAD PORT 装货港 X(35) C
+ + ":" + bill.PORTDISCHARGEID//6 DISCHARGE PORT CODE 卸货港代码 X(5) OOCL的订舱要求必选 M
+ + ":" + bill.PORTDISCHARGE//7 DISCHARGE PORT 卸货港 X(35) C
+ + ":" + bill.TRANSPORTID //8 TRANSFER PORT CODE 中转港代码 X(5) C
+ + ":" + bill.TRANSPORT//9 TRANSFER PORT 中转港 X(35) C
+ + ":" + bill.PLACEDELIVERYID//10 PLACE OF DELIVERY CODE 交货地代码 X(5) OOCL的订舱要求必选 O
+ + ":" + bill.PLACEDELIVERY//11 PLACE OF DELIVERY 交货地 X(35) C
+ + ":" + DESTINATIONID//12 FINAL DESTINATION CODE 目的地代码 X(5) C
+ + ":" + DESTINATION//13 FINAL DESTINATION CODE 目的地 X(35) C
+ + "'");
+
+ icount = icount + 1;
+
+ r.WriteLine("14:" + bill.BLFRTEDICODE + ":" + bill.BLFRT + "'");
+ if (InttrEdi.filetype == "E")
+ r.WriteLine("15:::" + bill.BLFRTEDICODE + ":" + bill.PAYABLEATID + ":::::'");
+ else
+ r.WriteLine("15:::" + bill.BLFRTEDICODE + "::::::'");
+ icount = icount + 2;
+
+
+ var Shipping = "";
+ Shipping = formatEdiStr("txt", bill.EDIREMARK);
+
+ List ShippingList = formatlengthStr(Shipping, 70);
+
+ if (Shipping != "")
+ {
+ r.WriteLine("17:" + formatListStr(ShippingList, 5) + "'");
+ icount++;
+ }
+
+
+ Shipping = formatEdiStr("txt", bill.SHIPPER);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ if (!string.IsNullOrEmpty(bill.ERNCODE) || !string.IsNullOrEmpty(bill.VAECODE) || !string.IsNullOrEmpty(bill.FECCODE))
+ {
+ r.WriteLine("20::" + formatListStr(ShippingList, 9) + ":" + bill.ERNCODE + ":" + bill.VAECODE + ":" + bill.FECCODE + "'");
+ }
+ else
+ r.WriteLine("20::" + formatListStr(ShippingList, 9) + "'");
+ icount = icount + 1;
+
+ }
+
+
+
+ Shipping = formatEdiStr("txt", bill.CONSIGNEE);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ if (!string.IsNullOrEmpty(bill.TACCODE))
+ {
+ r.WriteLine("21::" + formatListStr(ShippingList, 9) + ":" + bill.TACCODE + "'");
+ }
+ else
+ r.WriteLine("21::" + formatListStr(ShippingList, 9) + "'");
+ icount = icount + 1;
+
+ }
+
+
+ Shipping = formatEdiStr("txt", bill.NOTIFYPARTY);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ r.WriteLine("22::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+ }
+
+
+ Shipping = formatEdiStr("txt", bill.NOTIFYPARTY2);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (Shipping != "")
+ {
+
+ r.WriteLine("23::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+
+
+ }
+
+ r.WriteLine("24"
+ + ":" + bill.EDIATTN// 2 BOOKING ISSUER 訂艙聯絡人 X(60) C
+ + ":" + bill.EDIATTNEMAIL//3 EMAIL ADDRESS 訂艙聯絡人e-mail X(80) 若有給e-mail address, 在收到客戶 EDI 後, 系統會發回擲信給該 e-mail 做為確認. C
+ + ":" + bill.EDIATTNTEL//4 TEL NO 訂艙聯絡人電話 X(80) C
+ + "'");
+ icount++;
+
+
+ var cargoid = bill.CARGOID;
+ if (cargoid == "" || cargoid == " ") cargoid = "S";
+
+ var kingweight = bill.KINGTAREWEIGHT;
+ if (kingweight == 0)
+ kingweight = 100;
+
+ r.WriteLine("41:1:" + bill.HSCODE + ":" + cargoid + ":" + bill.PKGS.ToString() + ":" + bill.KINDPKGS_EDI_CODE + ":" + bill.KINDPKGS + ":" + kingweight.ToString() + ":"
+ + bill.CBM.ToString() + "::::::" + bill.KGS.ToString() + ":::'");
+
+ icount = icount + 1;
+ if (cargoid == "R")
+ r.WriteLine("43::::::::::" + bill.REEFERF + ":C:" + bill.TEMPSET + ":" + bill.TEMPMIN + ":" + bill.TEMPMAX + ":::::'");
+ else if (cargoid == "D")
+ r.WriteLine("43:" + bill.DCLASS + ":" + bill.DPAGE + ":" + bill.DUNNO + ":" + bill.DLABEL + "::::::::::::'");
+
+ icount = icount + 1;
+
+
+ Shipping = formatEdiStr("txt", bill.MARKS);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ for (var i = 0; i < Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(ShippingList.Count) / Convert.ToDecimal(10))); i++)
+ {
+ var tempstr = "44:";
+ for (var z = 0; z < 10; z++)
+ {
+ if ((i * 10 + z) < ShippingList.Count)
+ tempstr = tempstr + ShippingList[i * 10 + z];
+ if (z < 9) tempstr = tempstr + ":";
+ }
+ if (tempstr != "44:")
+ {
+ r.WriteLine(tempstr + "'");
+ icount++;
+ }
+ }
+
+ Shipping = formatEdiStr("txt", bill.DESCRIPTION);
+ ShippingList = formatlengthStr(Shipping, 70);
+
+ var m = 1;
+ var strtemp = "";
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+
+ for (var i = 0; i < ShippingList.Count; i++)
+ {
+ if (ShippingList[i] != "")
+ {
+ if (m <= 5)
+ {
+ if (m == 1) strtemp = "47:" + ShippingList[i] + ":";
+ else
+ {
+ if (m == 5)
+ strtemp = strtemp + ShippingList[i];
+ else
+ strtemp = strtemp + ShippingList[i] + ":";
+ }
+ }
+ else
+ {
+ m = 1;
+ r.WriteLine(strtemp + "'");
+ strtemp = "47:" + ShippingList[i] + ":";
+ icount = icount + 1;
+ }
+ m = m + 1;
+ }
+ }
+ }
+ if (strtemp != "")
+ {
+ r.WriteLine(strtemp + "'");
+ icount = icount + 1;
+ }
+
+ var ISSOC = "N";
+ if (bill.ISCONTAINERSOC) ISSOC = "Y";
+
+ var ctnsumlist = new List();
+
+ foreach (var ctn in bill.CTNLIST)
+ {
+ var newctnsum = ctnsumlist.Find(x => x.CTNALLCODE == ctn.CTNALLCODE);
+ if (newctnsum == null)
+ {
+ var ctnsum = new MsOpSeaeCtnEdiModel();
+ ctnsum.CTNALLCODE = ctn.CTNALLCODE;
+ ctnsum.CTNNUM = ctn.CTNNUM;
+ if (bill.ISCONTAINERSOC && !string.IsNullOrEmpty(ctn.CNTRNO))
+ {
+ if (!string.IsNullOrEmpty(ctnsum.CNTRNO))
+ {
+ ctnsum.CNTRNO = ctn.CNTRNO;
+ }
+ else
+ {
+ ctnsum.CNTRNO = ctnsum.CNTRNO + "," + ctn.CNTRNO;
+
+ }
+ }
+ ctnsumlist.Add(ctnsum);
+
+ }
+ else
+ {
+ newctnsum.CTNNUM = newctnsum.CTNNUM + ctn.CTNNUM;
+ if (bill.ISCONTAINERSOC && !string.IsNullOrEmpty(ctn.CNTRNO))
+ {
+ if (!string.IsNullOrEmpty(newctnsum.CNTRNO))
+ {
+ newctnsum.CNTRNO = ctn.CNTRNO;
+ }
+ else
+ {
+ newctnsum.CNTRNO = newctnsum.CNTRNO + "," + ctn.CNTRNO;
+
+ }
+ }
+
+ }
+ }
+ foreach (var ctnsum in ctnsumlist)
+ {
+ if (InttrEdi.filetype == "E")
+ {
+ r.WriteLine("48:" + ctnsum.CTNALLCODE + ":" + ctnsum.CTNNUM + ":F:::::" + ISSOC + "'");
+ icount = icount + 1;
+ }
+ else
+ {
+ var cntrnostr = "";
+ var isrstr = "N";
+ if (cargoid == "R") isrstr = "Y";
+ r.WriteLine("48:" + ctnsum.CTNALLCODE + ":" + ctnsum.CTNNUM + ":F:::::" + ISSOC + ":" + cntrnostr + ":::" + isrstr + "'");
+ icount = icount + 1;
+
+ }
+
+ }
+
+
+ }
+
+ icount = icount + 1;
+ r.WriteLine("99:" + icount.ToString() + "'");
+ r.Close();
+ f.Close();
+
+ return filename;
+ }
+ #endregion
+
+ #region 生成报文(确认)
+ public static string CreateEdiYMLSI(MsYMLEdiModel InttrEdi)
+ {
+ string filename = InttrEdi.filerpath + "\\" + 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:1+" + InttrEdi.SENDCODE + ":ZZZ+" + InttrEdi.RECEIVECODE + ":ZZZ+" + DateTime.Now.ToString("yyMMdd:HHmm") + "+" + bill.ORDERNO + "'");
+ r.WriteLine("UNH+" + bill.ORDERNO + "+IFTMIN:D:99B:UN'");
+ var BGMSTR = "";
+ if (bill.ISSUETYPE == "正本")
+ {
+ BGMSTR = "705";
+
+ }
+ else
+ {
+ BGMSTR = "712";
+
+ }
+
+
+ if (InttrEdi.filerole == "9")
+ r.WriteLine("BGM+" + BGMSTR + "+" + bill.MBLNO + "+9'");
+ else
+ r.WriteLine("BGM+" + BGMSTR + "+" + 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+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + bill.SERVICE + " "
+ // + bill.PKGS.ToString() + bill.KINDPKGS + "'");
+ icount = icount + 4;
+
+ 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+AAI+++" + 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("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;
+ }
+ 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 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];
+ 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+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;
+
+ 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+N1+++" + 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 + "'");
+ }
+
+
+ r.WriteLine("NAD+CA+YMLU:160:86++YML'");
+
+ if (InttrEdi.SENDNAME.Length > 35)
+ r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'");
+ else
+ r.WriteLine("NAD+HI+" + 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+706+++" + 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+706+++" + GetBillNum(bill.NOBILL) + "'");
+ icount = icount + 1;
+ if (copynum != "")
+ {
+ r.WriteLine("DOC+707+++" + copynum + "'");
+ icount = icount + 1;
+ }
+
+ }
+ else if (bill.ISSUETYPE == "正副本")
+ {
+ r.WriteLine("DOC+706+++" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + "'");
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctn.KGS), 3) + "'");
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'");
+ icount++;
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'");
+ //MEA+AAE+AAW+MTQ:50.11'
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(ctngood.CBM), 3) + "'");
+ icount = icount + 3;
+ i = i + 1;
+ }
+ }
+ }
+ #endregion
+
+ }
+ else
+ {
+
+ #region 取集装箱分箱_货描、唛头信息
+
+
+ var ctngoodssumlist = new List();
+ 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngoodsum.KGS), 3) + "'");
+ icount++;
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(i.KGS), 3) + "'");
+ //MEA+AAE+AAW+MTQ:50.11'
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctn.KGS), 3) + "'");
+ r.WriteLine("MEA+AAE+AAW+MTQ:" + 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
+
+ }
+
+
+ public class MsYMLEdiModel
+ {
+
+ ///
+ /// 发送方代码 M
+ ///
+ public string SENDCODE { get; set; }
+
+ ///
+ /// 发送方名称 M
+ ///
+ public string SENDNAME { get; set; }
+
+ ///
+ /// 接收方代码 M
+ ///
+ public string RECEIVECODE { get; set; }
+
+ ///
+ /// 文件类型 (B订舱,E SI确认)M
+ ///
+ public string filetype { get; set; }
+
+ ///
+ /// 文件功能 (9原始,1 更新,5 退舱 )M
+ ///
+ public string filerole { get; set; }
+
+ ///
+ /// 文件路径 M
+ ///
+ public string filerpath { get; set; }
+
+ ///
+ /// 是否使用货代代码。 M
+ ///
+ public bool UseForWarderCode { get; set; }
+ ///
+ /// 货代代码。 O
+ ///
+ public string ForWarderCode { get; set; }
+
+ ///
+ /// 货代名称 O
+ ///
+ public string ForWarderName { get; set; }
+
+ ///
+ /// 业务信息列表 M
+ ///
+ public List BSLIST { get; set; }
+
+
+ }
+
+
+ public class MsOpSeaeEdiModel
+ {
+
+
+ ///
+ /// 委托方
+ ///
+ public string WEITUO { get; set; }
+
+ ///
+ /// 操作英文名称 M
+ ///
+ public string OpEName { get; set; }
+
+ ///
+ /// 操作电话 M
+ ///
+ public string OpTel { get; set; }
+ ///
+ /// 操作邮箱 M
+ ///
+ public string OpEmail { get; set; }
+
+ ///
+ /// EDI联系人名称 O
+ ///
+ public string EDIATTN { get; set; }
+
+ ///
+ /// EDI联系人电话 O
+ ///
+ public string EDIATTNTEL { get; set; }
+ ///
+ /// EDI联系人邮箱 O
+ ///
+ public string EDIATTNEMAIL { get; set; }
+ ///
+ /// 订舱编号 O
+ ///
+ public string ORDERNO { get; set; }
+
+ ///
+ /// 主提单号 M
+ ///
+ public string MBLNO { get; set; }
+
+ ///
+ /// 付费方式代码 M
+ ///
+ public string BLFRTEDICODE { get; set; }
+
+
+ ///
+ /// 付费方式 M
+ ///
+ public string BLFRT { get; set; }
+
+ ///
+ /// 船名 O
+ ///
+ public string VESSEL { get; set; }
+
+ ///
+ /// 船舶呼号 O
+ ///
+ public string VESSELID { get; set; }
+
+
+ ///
+ /// 航次 O
+ ///
+ public string VOYNO { get; set; }
+
+
+ ///
+ /// 内部航次 O
+ ///
+ public string NVOYNO { get; set; }
+
+ ///
+ /// 开船日期 M
+ ///
+ public string ETD { get; set; }
+
+ ///
+ /// EDI备注
+ ///
+ public string EDIREMARK { get; set; }
+
+ ///
+ /// SI备注
+ ///
+ public string SIREMARK { get; set; }
+
+ ///
+ /// NVO NO
+ ///
+ public string NVONO { get; set; }
+
+ ///
+ /// ERN CODE
+ ///
+ public string ERNCODE { get; set; }
+
+ ///
+ /// TAC CODE
+ ///
+ public string TACCODE { get; set; }
+
+ ///
+ /// VAE CODE
+ ///
+ public string VAECODE { get; set; }
+
+ ///
+ /// FEC CODE
+ ///
+ public string FECCODE { get; set; }
+
+ ///
+ /// 船公司名称 M
+ ///
+ public string CARRIER { get; set; }
+ ///
+ /// 船公司EDI代码 M
+ ///
+ public string CARRIEREDICODE { get; set; }
+
+ ///
+ /// 发货人 M
+ ///
+ public string SHIPPER { get; set; }
+
+ ///
+ /// 收货人 M
+ ///
+ public string CONSIGNEE { get; set; }
+
+ ///
+ /// 通知人 M
+ ///
+ public string NOTIFYPARTY { get; set; }
+
+ ///
+ /// 第二通知人
+ ///
+ public string NOTIFYPARTY2 { get; set; }
+
+ ///
+ /// AMS收货人
+ ///
+ public string AMSCONSIGNEE { get; set; }
+
+ ///
+ /// AMS通知人
+ ///
+ public string AMSNOTIFYPARTY { get; set; }
+
+
+ ///
+ /// 收货地所在国家 O
+ ///
+ public string BYCOUNTRY { get; set; }
+
+ /////
+ ///// AMS发货人 O
+ /////
+ //public string AMSSHIPPER { get; set; }
+
+ /////
+ ///// AMS收货人 O
+ /////
+ //public string AMSCONSIGNEE { get; set; }
+
+ /////
+ ///// AMS通知人 O
+ /////
+ //public string AMSNOTIFYPARTY { get; set; }
+
+ ///
+ /// HS编码
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+
+
+
+
+ ///
+ /// 收货地代码(每船公司可能不同)
+ ///
+ public string PLACERECEIPTID { get; set; }
+ ///
+ /// 收货地
+ ///
+ public string PLACERECEIPT { get; set; }
+
+
+ ///
+ /// 起运港代码(每船公司可能不同) M
+ ///
+ public string PORTLOADID { get; set; }
+ ///
+ /// 起运港 M
+ ///
+ public string PORTLOAD { get; set; }
+
+
+ ///
+ ///卸货港代码(每船公司可能不同) M
+ ///
+ public string PORTDISCHARGEID { get; set; }
+ ///
+ /// 卸货港 M
+ ///
+ public string PORTDISCHARGE { get; set; }
+
+
+ ///
+ ///中转港代码
+ ///
+ public string TRANSPORTID { get; set; }
+ ///
+ /// 中转港
+ ///
+ public string TRANSPORT { get; set; }
+
+
+ ///
+ ///交货地代码M
+ ///
+ public string PLACEDELIVERYID { get; set; }
+ ///
+ /// 交货地 M
+ ///
+ public string PLACEDELIVERY { get; set; }
+
+ ///
+ ///目的地代码(每船公司可能不同)
+ ///
+ public string DESTINATIONID { get; set; }
+ ///
+ /// 目的地
+ ///
+ public string DESTINATION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ ///
+ /// 货物标识 M
+ ///
+ public string CARGOID { get; set; }
+
+ ///
+ /// 第一层包装皮重 O
+ ///
+ public decimal KINGTAREWEIGHT { get; set; }
+
+
+ ///
+ /// 危险品类别 O
+ ///
+ public string DCLASS { get; set; }
+
+ ///
+ /// 危险品编号 O
+ ///
+ public string DUNNO { get; set; }
+
+ ///
+ /// 危险品页号 C
+ ///
+ public string DPAGE { get; set; }
+
+ ///
+ /// 危险品标签 C
+ ///
+ public string DLABEL { get; set; }
+
+ ///
+ /// 设置温度 O
+ ///
+ public string TEMPSET { get; set; }
+
+
+ ///
+ /// 设置最低温度 C
+ ///
+ public string TEMPMIN { get; set; }
+
+ ///
+ /// 设置最高温度 C
+ ///
+ public string TEMPMAX { get; set; }
+
+
+ ///
+ /// 通风度 O
+ ///
+ public string REEFERF { get; set; }
+
+
+ ///
+ /// 湿度
+ ///
+ public string HUMIDITY { get; set; }
+
+ ///
+ /// 预付地点 O
+ ///
+ public string PREPARDAT { get; set; }
+
+ ///
+ /// 到付地点 O
+ ///
+ public string PAYABLEAT { get; set; }
+
+ ///
+ /// 预付地点EDI代码 O
+ ///
+ public string PREPARDATID { get; set; }
+
+ ///
+ /// 到付地点EDI代码 O
+ ///
+ public string PAYABLEATID { get; set; }
+
+
+ ///
+ /// 签单方式 M(SI)
+ ///
+ public string ISSUETYPE { get; set; }
+
+ ///
+ /// 提单份数 M(SI)
+ ///
+ public string NOBILL { get; set; }
+
+ ///
+ /// 签单地点 M(SI)
+ ///
+ public string ISSUEPLACE { get; set; }
+
+
+ ///
+ /// 签单地点
+ ///
+ public string ISSUEDATE { get; set; }
+
+ ///
+ /// 提单副本份数 M(SI)
+ ///
+ public string COPYNOBILL { get; set; }
+ ///
+ /// 签单地点EDI代码 M(SI)
+ ///
+ public string ISSUEPLACEID { get; set; }
+
+
+ ///
+ /// 运输条款 M
+ ///
+ public string SERVICE { get; set; }
+
+
+ ///
+ /// 运费协议号 M
+ ///
+ public string CONTRACTNO { get; set; }
+
+ ///
+ /// 服务合同号
+ ///
+ public string SERVICECONTRACTNO { get; set; }
+
+ ///
+ /// ESL航线代码 M
+ ///
+ public string ESLLINECODE { get; set; }
+
+ ///
+ /// 收货人邮编 O
+ ///
+ public string CONSIGNEEPOSTCODE { get; set; }
+
+ ///
+ /// 收货人国家 O
+ ///
+ public string CONSIGNEECOUNTRY { get; set; }
+
+ ///
+ /// 收货人税号 O
+ ///
+ public string CONSIGNEETAXNO { get; set; }
+
+ ///
+ /// 通知人邮编 O
+ ///
+ public string NOTIFYPARTYPOSTCODE { get; set; }
+
+ ///
+ /// 通知人国家 O
+ ///
+ public string NOTIFYPARTYCOUNTRY { get; set; }
+
+ ///
+ /// 通知人税号 O
+ ///
+ public string NOTIFYPARTYTAXNO { get; set; }
+
+ ///
+ /// 货物NCM编号 O
+ ///
+ public string GOODSNCM { get; set; }
+
+
+ ///
+ /// 收货人DOOR地址 O
+ ///
+ public string CONSIGNEEDOORADDR { get; set; }
+
+ ///
+ /// 发货人DOOR地址 O
+ ///
+ public string SHIPPERDOORADDR { get; set; }
+
+
+ ///
+ /// SCAC代码 O
+ ///
+ public string SCACCODE { get; set; }
+
+ ///
+ /// ITN编号 O
+ ///
+ public string ITNCODE { get; set; }
+ ///
+ /// 付费方 O
+ ///
+ public string FREIGHTPAYER { get; set; }
+
+ ///
+ /// AMS代码 O
+ ///
+ public string AMSCODE { get; set; }
+ ///
+ /// 是否SOC箱 O
+ ///
+ public bool ISCONTAINERSOC { get; set; }
+
+ ///
+ /// 拆并单列表 O
+ ///
+ public string BSNOLIST { get; set; }
+
+
+
+ ///
+ /// 集装箱明细 M
+ ///
+ public List CTNLIST { get; set; }
+
+ ///
+ /// 集装箱多品名明细 M
+ ///
+ public List CTNGOODSLIST { get; set; }
+ }
+
+ public class MsOpSeaeCtnEdiModel
+ {
+
+ ///
+ /// 箱型EDI代码 M
+ ///
+ public string CTNALLCODE { get; set; }
+
+ public Int32 CTNNUM { get; set; }
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// 封号 M
+ ///
+ public string SEALNO { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+ ///
+ /// 箱皮重
+ ///
+ public string TAREWEIGHT { get; set; }
+
+ ///
+ /// 称重重量
+ ///
+ public string WEIGHKGS { get; set; }
+
+ ///
+ /// 称重方式 (累加、总重)
+ ///
+ public string WEIGHTYPE { get; set; }
+
+ ///
+ /// 称重签名
+ ///
+ public string WEIGHSIGN { get; set; }
+
+
+ }
+ public class MsOpSeaeCtnDetailEdiModel
+ {
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// HS编码 M
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ }
+
+}
diff --git a/Myshipping.Application/EDI/YTEdiHelper.cs b/Myshipping.Application/EDI/YTEdiHelper.cs
new file mode 100644
index 00000000..8ae9c9f5
--- /dev/null
+++ b/Myshipping.Application/EDI/YTEdiHelper.cs
@@ -0,0 +1,1776 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application.EDI.YT
+{
+ public class YTEdiHelper
+ {
+
+ public YTEdiHelper()
+ {
+ }
+
+ #region 基本函数
+
+ 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 "";
+ }
+
+
+ public static string GetDateStr(string datestr, string dateformat)
+ {
+ var result = "";
+
+ if (datestr == null || datestr == "")
+ {
+ result = "";
+ }
+ else
+ {
+ result = Convert.ToDateTime(datestr).ToString(dateformat);
+
+ }
+
+ return result;
+
+ }
+
+ #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
+
+ public static string formatListStr(List DestList, int lineCount, bool isformat = false)
+ {
+ var result = "";
+ for (var i = 0; i < lineCount; i++)
+ {
+ if (DestList.Count > i)
+ {
+ if (isformat)
+ result = result + formatEdiStr("txt", DestList[i]);
+ else
+ result = result + DestList[i];
+ }
+ if (i != (lineCount - 1))
+ result = result + ":";
+
+
+ }
+ return result;
+ }
+
+
+ #region 文本字段判断每行是否符合
+ ///
+ /// edi 文本格式处理判断(例如:1行35个字符不超过5行)
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 要处理的数据
+ /// 每行长度
+ /// 主提单号
+ /// 数据类型(例如:发货人内容、货描等)
+ /// 限制录入的行数(“0”代表不限制)
+ /// 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+ ///
+ 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 + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ else
+ {
+ if (argAGENT.Length > rowNum && rowNum != 0)
+ {
+ if (isHuoMiao)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!";
+ }
+ else
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)";
+ }
+ }
+ for (int j = 0; j < argAGENT.Length; j++)
+ {
+ //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35);
+ if (argAGENT[j].ToString().Length > length)
+ {
+ error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符";
+ }
+ }
+ }
+ }
+ return error;
+ }
+ #endregion
+
+ #region 字符转义
+ ///
+ /// 各种文本转义字符
+ ///
+ /// 文件类型(例如:txt、xml)
+ /// 文本字符串
+ ///
+ public static string formatEdiStr(string fileType, string str)
+ {
+ if (fileType == "txt")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'");
+ }
+ else if (fileType == "xml")
+ {
+ return str.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'");
+ }
+ else if (fileType == "sitc")
+ {
+ return str.Replace("?", "??").Replace(":", "?:").Replace("'", "?'");
+ }
+ else
+ {
+ return str;
+ }
+ }
+ #endregion
+ #region 格式化每行
+ public static List 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 DestList = new List();
+ 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 IsCreateYTEDI(MsYTEdiModel InttrEdi)
+ {
+ var error = "";
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDCODE))
+ { error = error + "
发送方代码不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.SENDNAME))
+ { error = error + "
发送方名称不能为空"; }
+
+ if (string.IsNullOrEmpty(InttrEdi.RECEIVECODE))
+ { error = error + "
接收方代码不能为空"; }
+
+ //if (InttrEdi.filetype == "B")
+ //{
+ // if (InttrEdi.UseForWarderCode)
+ // {
+ // if (string.IsNullOrEmpty(InttrEdi.ForWarderCode))
+ // { error = error + "
货代代码不能为空"; }
+
+ // if (string.IsNullOrEmpty(InttrEdi.ForWarderName))
+ // { error = error + "
货代称呼不能为空"; }
+ // }
+ //}
+
+
+ foreach (var headData in InttrEdi.BSLIST)
+ {
+
+ if (string.IsNullOrEmpty(headData.MBLNO))
+ { error = error + "
主提单号不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.BLFRT))
+ { error = error + "
提单号:" + headData.MBLNO + " 付费方式不能为空"; }
+
+
+
+ if (InttrEdi.filetype == "E")
+ {
+ if (string.IsNullOrEmpty(headData.VESSEL))
+ { error = error + "
提单号:" + headData.MBLNO + " 船名不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.VOYNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 航次不能为空"; }
+
+ if (InttrEdi.filetype != "B" || headData.CARRIEREDICODE == "YML")
+ {
+ if (string.IsNullOrEmpty(headData.ETD))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 开船日期不能为空";
+ return error;
+ }
+ }
+ }
+
+ if (headData.CARRIEREDICODE != "ZIM")
+ {
+ if (string.IsNullOrEmpty(headData.PLACERECEIPTID) || headData.PLACERECEIPTID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 收货地代码不能为空或录入不正确(必须是5位代码)"; }
+
+ if (string.IsNullOrEmpty(headData.PLACERECEIPT))
+ { error = error + "
提单号:" + headData.MBLNO + " 收货地不能为空"; }
+
+ }
+
+
+ if (string.IsNullOrEmpty(headData.PORTLOADID) || headData.PORTLOADID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 装货港代码不能为空或录入不正确(必须是5位代码)"; }
+
+ if (string.IsNullOrEmpty(headData.PORTLOAD))
+ { error = error + "
提单号:" + headData.MBLNO + " 装货港不能为空"; }
+
+
+ if (string.IsNullOrEmpty(headData.PORTDISCHARGEID) || headData.PORTDISCHARGEID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 卸货港代码不能为空或录入不正确(必须是5位代码)"; }
+ if (string.IsNullOrEmpty(headData.PORTDISCHARGE))
+ { error = error + "
提单号:" + headData.MBLNO + " 卸货港不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.PLACEDELIVERY) || headData.PLACEDELIVERYID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 交货地代码不能为空或录入不正确(必须是5位代码)"; }
+ if (string.IsNullOrEmpty(headData.PLACEDELIVERY))
+ { error = error + "
提单号:" + headData.MBLNO + " 交货地不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.DESTINATION))
+ {
+ if (string.IsNullOrEmpty(headData.DESTINATIONID) || headData.DESTINATIONID.Length != 5)
+ { error = error + "
提单号:" + headData.MBLNO + " 目的地代码不能为空或录入不正确(必须是5位代码)"; }
+ }
+
+ if (string.IsNullOrEmpty(headData.KINDPKGS_EDI_CODE))
+ { error = error + "
提单号:" + headData.MBLNO + " 包装EDI代码不能为空"; }
+ if (headData.PKGS == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 件数不能为0"; }
+ if (headData.KGS == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 毛重不能为0"; }
+ if (headData.CBM == 0)
+ { error = error + "
提单号:" + headData.MBLNO + " 尺码不能为0"; }
+
+ if (string.IsNullOrEmpty(headData.CARGOID))
+ { error = error + "
提单号:" + headData.MBLNO + " 货物标识不能为空"; }
+
+ if (headData.CARGOID == "D")
+ {
+ if (string.IsNullOrEmpty(headData.DCLASS))
+ { error = error + "
提单号:" + headData.MBLNO + " 危险品分类不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.DUNNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 危险品编号不能为空"; }
+ }
+ if (headData.CARGOID == "R")
+ {
+ if (headData.TEMPSET == null || headData.TEMPSET == "")
+ { error = error + "
提单号:" + headData.MBLNO + " 设置温度不能为空"; }
+ if (headData.REEFERF == null || headData.REEFERF == "")
+ { error = error + "
提单号:" + headData.MBLNO + " 通风度不能为空"; }
+ }
+ if (headData.ISSUEPLACE == null || headData.ISSUEPLACE == "")
+ { error = error + "
提单号:" + headData.MBLNO + "签单地点不能为空"; }
+
+ if (headData.CARRIEREDICODE == "APL")
+ if (headData.ISSUETYPE == null || headData.ISSUETYPE == "")
+ { error = error + "
提单号:" + headData.MBLNO + "签单方式不能为空"; }
+ if (headData.SERVICE == "" || headData.SERVICE == null)
+ { error = error + "
提单号:" + headData.MBLNO + "运输条款不能为空"; }
+
+ if (string.IsNullOrEmpty(headData.MARKS))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 唛头不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.MARKS))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 唛头含有中文或双字节字符";
+ }
+ else
+ {
+ error += formatlengthError("txt", headData.MARKS, 35, headData.MBLNO, "唛头", 0, "", false);
+ }
+ }
+
+ if (string.IsNullOrEmpty(headData.DESCRIPTION))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 货物描述不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.DESCRIPTION))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 货物描述含有中文或双字节字符";
+ }
+ else
+ {
+ //error += formatlengthError("txt", bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 0, "");
+ }
+ }
+
+
+ if (string.IsNullOrEmpty(headData.SHIPPER))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 发货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.SHIPPER))
+ {
+ error = error + "
提单号:" + 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 + "
提单号:" + headData.MBLNO + " 收货人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.CONSIGNEE))
+ {
+ error = error + "
提单号:" + 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 (string.IsNullOrEmpty(headData.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + headData.MBLNO + " 通知人不能为空";
+ }
+ else
+ {
+ if (StringIsChinese(headData.NOTIFYPARTY))
+ {
+ error = error + "
提单号:" + 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);
+ }
+
+ var ctnlist = headData.CTNLIST;
+ if (ctnlist.Count == 0) { error = error + "
提单号:" + headData.MBLNO + " 集装箱信息不能为空"; };
+
+ #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 + "
提单号:" + headData.MBLNO + " 集装箱箱型EDI代码不能为空"; }
+ if ((ctn.CTNALLCODE.IndexOf("RH") > 0 || ctn.CTNALLCODE.IndexOf("RF") > 0) && (headData.CARGOID != "R"))
+ {
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱箱型为冻柜,货类代码请选择冻柜"; }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+
+ if (string.IsNullOrEmpty(ctn.CNTRNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 箱号不能为空"; }
+ if (string.IsNullOrEmpty(ctn.SEALNO))
+ { error = error + "
提单号:" + headData.MBLNO + " 封号不能为空"; }
+
+ if (ctn.KINDPKGS != headData.KINDPKGS)
+ { error = error + "
提单号:" + headData.MBLNO + " 中的包装类型与集装箱的包装类型不同"; }
+ dlPKGS += Convert.ToDecimal(ctn.PKGS);
+ dlKGS += Convert.ToDecimal(ctn.KGS);
+ dlCBM += Convert.ToDecimal(ctn.CBM);
+ }
+ }
+ if (InttrEdi.filetype == "E")
+ {
+ if (dlPKGS != Convert.ToDecimal(headData.PKGS))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱件数合计数必须等于委托单总件数"; }
+ if (dlKGS != Convert.ToDecimal(headData.KGS))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱重量合计数必须等于委托单总重量数"; }
+ if (dlCBM != Convert.ToDecimal(headData.CBM))
+ { error = error + "
提单号:" + headData.MBLNO + " 集装箱尺码合计数必须等于委托单总尺码数"; }
+ }
+ }
+
+ if (InttrEdi.filetype == "E")
+ {
+ 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 + "
提单号:" + headData.MBLNO + "的“" + ctn.CNTRNO + "”未添加分箱明细!";
+ }
+ else
+ {
+ if (ctngoodssumpkgs != Convert.ToDecimal(ctn.PKGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细件数合计数不等于集装箱件数"; }
+ if (ctngoodssumkgs != Convert.ToDecimal(ctn.KGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细毛重合计数不等于集装箱毛重"; }
+ if (ctngoodssumcbm != Convert.ToDecimal(ctn.CBM))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细尺码合计数不等于集装箱毛重"; }
+
+ }
+
+ }
+
+ foreach (var ctngood in headData.CTNGOODSLIST)
+ {
+ if (string.IsNullOrEmpty(ctngood.KINDPKGS))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型不能为空"; }
+ if (string.IsNullOrEmpty(ctngood.DESCRIPTION))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱货物描述不能为空"; }
+ else
+ {
+ error += formatlengthError("txt", ctngood.DESCRIPTION, 70, headData.MBLNO, "的“" + ctngood.CNTRNO + "”箱号的分箱货物描述", 0, "", false);
+ }
+ //if (string.IsNullOrEmpty(ctngood.HSCODE))
+ //{ error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱HS编码不能为空"; }
+ if (string.IsNullOrEmpty(ctngood.KINDPKGS_EDI_CODE))
+ { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型代码不能为空"; }
+
+ }
+
+ }
+
+ #endregion
+
+
+ }
+
+ }
+ return error;
+ }
+ #endregion
+
+ #region 生成报文(订舱(filetype=="B"),截单(filetype=="E"))
+ public static string CreateEdiYT(MsYTEdiModel InttrEdi)
+ {
+ var filetype = "IFTMIN";
+ if (InttrEdi.filetype != "E") filetype = "IFTMBF";
+
+ string filename = InttrEdi.filerpath + "\\" + filetype + "_" + 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 = "";
+ var isfirst = true;
+ foreach (var bill in InttrEdi.BSLIST)
+ {
+ if (isfirst)
+ {
+ if (InttrEdi.filetype == "E")
+ r.WriteLine("00:IFTMIN:BOOKING:" + InttrEdi.filerole + ":" + InttrEdi.SENDCODE + ":" + InttrEdi.RECEIVECODE + ":" + DateTime.Now.ToString("yyyyMMddHHmm") + "'");
+ else
+ r.WriteLine("00:IFTMBF:BOOKING:" + InttrEdi.filerole + ":" + InttrEdi.SENDCODE + ":" + InttrEdi.RECEIVECODE + ":" + DateTime.Now.ToString("yyyyMMddHHmm") + "'");
+ isfirst = false;
+ icount++;
+
+ }
+
+ if (bill.CARRIEREDICODE == "ONEY")
+ {
+ var sendno = bill.EDIATTNEMAIL;
+
+ if (filetype == "E") sendno = bill.AMSCODE;
+ var MBLNO = bill.MBLNO;
+ if (MBLNO.Substring(0, 4) == "ONEY")
+ {
+ MBLNO = MBLNO.Substring(4, MBLNO.Length - 4);
+ }
+
+ r.WriteLine("02"
+ + ":" + MBLNO//2 REFERENCE NO. 运编号 X(35) 一般为流水号 M
+ + ":" + MBLNO//3 B\L NO. 提单号 X(20) 船公司的提单号 C
+ + ":" + bill.SERVICE//4 DELIVERY TERM 交货条款 X(9) CY-CY(pier-pier/port):30CY-CFS(pier/port-door):29CFS-CY(door-pier/port):28CFS-CFS(door-door):27 M
+ + ":" + InttrEdi.SENDNAME//5 BOOKING PARTY 订舱人说明 X(70) 货代方企业名称或代码 C
+ + ":ONEY" //6 ISSUE PARTY CODE 签单人代码 X(13) 即接受订舱的人的代码 M
+ + ":"//7 ISSUE PARTY 签单人说明 X(35) C
+ + ":"//8 APPLICANT 询价单位 X(13) 向船公司询价的单位代码 C
+ + ":"//9 FOB BK PARTY 国外订舱单位 X(13) 国外FOB货订舱单位的代码 C
+ + ":"//10 B/L TRANSHIP ID 转船标识 X(1) Y/N C
+ + ":"//11 BATCH ID 分批 X(1) Y/N C
+ + ":"//12 SHIPMENT DATE 装期 9(8) CCYYMMDD C
+ + ":"//13 EXPIRY DATE 效期 9(8) CCYYMMDD C
+ + ":" + bill.CONTRACTNO//14 QUOTATION NO. 运费协议号 X(30) MAERSK为必选 C
+ + ":"//15 CHARGE TYPE 费率本代码 X(1) C
+ + ":" + bill.CONTRACTNO//16 S/C NO. 合约号 X(30) C
+ + ":"//17 BOOKING NO. 船公司订舱编号 X(20) 船公司系统内部订舱编号 C
+ + ":"//18 SLOT CHARTER ID 舱位互用标识 X(1) C
+ + ":" + sendno//19 AMS CODE AMS代码 X(15) C
+ //注:QUOTATION NO.项填本票订舱货的运价是通过向中集询价后定下的特殊运价编号。
+ + "'");
+
+ }
+ else
+ if (InttrEdi.filetype == "E")
+ {
+ r.WriteLine("02"
+ + ":" + bill.ORDERNO//2 REFERENCE NO. 运编号 X(35) 一般为流水号 M
+ + ":" + bill.MBLNO//3 B\L NO. 提单号 X(20) 船公司的提单号 C
+ + ":" + bill.SERVICE//4 DELIVERY TERM 交货条款 X(9) CY-CY(pier-pier/port):30CY-CFS(pier/port-door):29CFS-CY(door-pier/port):28CFS-CFS(door-door):27 M
+ + ":" + formatEdiStr("txt", InttrEdi.ForWarderName.Replace("\n", " ").Replace("\r", " "))//5 BOOKING PARTY 订舱人说明 X(70) 货代方企业名称或代码 C
+ + ":" + InttrEdi.RECEIVECODE//6 ISSUE PARTY CODE 签单人代码 X(13) 即接受订舱的人的代码 M
+ + ":"//7 ISSUE PARTY 签单人说明 X(35) C
+ + ":"//8 APPLICANT 询价单位 X(13) 向船公司询价的单位代码 C
+ + ":"//9 FOB BK PARTY 国外订舱单位 X(13) 国外FOB货订舱单位的代码 C
+ + ":"//10 B/L TRANSHIP ID 转船标识 X(1) Y/N C
+ + ":"//11 BATCH ID 分批 X(1) Y/N C
+ + ":"//12 SHIPMENT DATE 装期 9(8) CCYYMMDD C
+ + ":"//13 EXPIRY DATE 效期 9(8) CCYYMMDD C
+ + ":" + bill.CONTRACTNO//14 QUOTATION NO. 运费协议号 X(30) MAERSK为必选 C
+ + ":"//15 CHARGE TYPE 费率本代码 X(1) C
+ + ":" + bill.SERVICECONTRACTNO//16 S/C NO. 合约号 X(30) C
+ + ":" + bill.ORDERNO//17 BOOKING NO. 船公司订舱编号 X(20) 船公司系统内部订舱编号 C
+ + ":::"//18 SLOT CHARTER ID 舱位互用标识 X(1) C
+ + ":" + bill.EDIATTNEMAIL//21 AMS CODE AMS代码 X(15) C
+ + ":" + bill.EDIATTN//22 AMS CODE AMS代码 X(15) C
+ + ":" + bill.EDIATTNTEL//23 AMS CODE AMS代码 X(15) C
+ //注:QUOTATION NO.项填本票订舱货的运价是通过向中集询价后定下的特殊运价编号。
+ + "'");
+
+ }
+ else
+ {
+ r.WriteLine("02"
+ + ":" + bill.ORDERNO//2 REFERENCE NO. 运编号 X(35) 一般为流水号 M
+ + ":" + bill.MBLNO//3 B\L NO. 提单号 X(20) 船公司的提单号 C
+ + ":" + bill.SERVICE//4 DELIVERY TERM 交货条款 X(9) CY-CY(pier-pier/port):30CY-CFS(pier/port-door):29CFS-CY(door-pier/port):28CFS-CFS(door-door):27 M
+ + ":" + formatEdiStr("txt", InttrEdi.ForWarderName.Replace("\n", " ").Replace("\r", " "))//5 BOOKING PARTY 订舱人说明 X(70) 货代方企业名称或代码 C
+ + ":" + InttrEdi.RECEIVECODE//6 ISSUE PARTY CODE 签单人代码 X(13) 即接受订舱的人的代码 M
+ + ":"//7 ISSUE PARTY 签单人说明 X(35) C
+ + ":"//8 APPLICANT 询价单位 X(13) 向船公司询价的单位代码 C
+ + ":"//9 FOB BK PARTY 国外订舱单位 X(13) 国外FOB货订舱单位的代码 C
+ + ":"//10 B/L TRANSHIP ID 转船标识 X(1) Y/N C
+ + ":"//11 BATCH ID 分批 X(1) Y/N C
+ + ":"//12 SHIPMENT DATE 装期 9(8) CCYYMMDD C
+ + ":"//13 EXPIRY DATE 效期 9(8) CCYYMMDD C
+ + ":" + bill.CONTRACTNO//14 QUOTATION NO. 运费协议号 X(30) MAERSK为必选 C
+ + ":"//15 CHARGE TYPE 费率本代码 X(1) C
+ + ":" + bill.SERVICECONTRACTNO//16 S/C NO. 合约号 X(30) C
+ + ":" + bill.ORDERNO//17 BOOKING NO. 船公司订舱编号 X(20) 船公司系统内部订舱编号 C
+ + ":"//18 SLOT CHARTER ID 舱位互用标识 X(1) C
+ + ":" + bill.EDIATTNEMAIL//21 AMS CODE AMS代码 X(15) C
+ + ":" + bill.EDIATTN//22 AMS CODE AMS代码 X(15) C
+ + ":" + bill.EDIATTNTEL//23 AMS CODE AMS代码 X(15) C
+ //注:QUOTATION NO.项填本票订舱货的运价是通过向中集询价后定下的特殊运价编号。
+ + "'");
+ }
+ icount++;
+
+ var ISSUETYPE = "";
+ if (bill.ISSUETYPE == "正本")
+ {
+ ISSUETYPE = "ORI";
+ }
+ else if (bill.ISSUETYPE == "电放")
+ {
+ ISSUETYPE = "TER";
+ }
+ else ISSUETYPE = "EXP";
+
+
+
+ r.WriteLine("03:" + ISSUETYPE + ":" + bill.ISSUEPLACEID.Trim() + ":" + bill.ISSUEPLACE.Trim() + ":" + GetDateStr(bill.ISSUEDATE, "yyyyMMdd") + ":" + GetBillNum2(bill.NOBILL) + ":" + bill.PREPARDAT + ":" + bill.PAYABLEAT + "'");
+ icount++;
+
+
+ r.WriteLine("11:" + bill.VESSELID + ":" + bill.VESSEL + ":" + bill.VOYNO + ":::::" + GetDateStr(bill.ETD, "yyyyMMdd") + ":::::'");
+ icount++;
+
+ var DESTINATIONID = bill.DESTINATIONID;
+ var DESTINATION = bill.DESTINATION;
+ if (bill.CARRIEREDICODE == "ONEY" || bill.CARRIEREDICODE == "ZIM")
+ {
+ DESTINATIONID = "";
+ DESTINATION = "";
+ }
+
+ r.WriteLine("12"
+ + ":" + bill.PLACERECEIPTID//2 PLACE CODE OF RECEIPT 收货地代码 X(5) OOCL、HLC的订舱要求必选 O
+ + ":" + bill.PLACERECEIPT//3 PLACE OF RECEIPT 收货地 X(35) C
+ + ":" + bill.PORTLOADID//4 LOAD PORT CODE 装货港代码 X(5) OOCL的订舱要求必选 O
+ + ":" + bill.PORTLOAD//5 LOAD PORT 装货港 X(35) C
+ + ":" + bill.PORTDISCHARGEID//6 DISCHARGE PORT CODE 卸货港代码 X(5) OOCL的订舱要求必选 M
+ + ":" + bill.PORTDISCHARGE//7 DISCHARGE PORT 卸货港 X(35) C
+ + ":" + bill.TRANSPORTID //8 TRANSFER PORT CODE 中转港代码 X(5) C
+ + ":" + bill.TRANSPORT//9 TRANSFER PORT 中转港 X(35) C
+ + ":" + bill.PLACEDELIVERYID//10 PLACE OF DELIVERY CODE 交货地代码 X(5) OOCL的订舱要求必选 O
+ + ":" + bill.PLACEDELIVERY//11 PLACE OF DELIVERY 交货地 X(35) C
+ + ":" + DESTINATIONID//12 FINAL DESTINATION CODE 目的地代码 X(5) C
+ + ":" + DESTINATION//13 FINAL DESTINATION CODE 目的地 X(35) C
+ + "'");
+
+ icount = icount + 1;
+
+ r.WriteLine("14:" + bill.BLFRTEDICODE + ":" + bill.BLFRT + "'");
+ if (InttrEdi.filetype == "E")
+ r.WriteLine("15:::" + bill.BLFRTEDICODE + ":" + bill.PAYABLEATID + ":::::'");
+ else
+ r.WriteLine("15:::" + bill.BLFRTEDICODE + "::::::'");
+ icount = icount + 2;
+
+
+ var Shipping = "";
+ if (InttrEdi.filetype == "E")
+ Shipping = formatEdiStr("txt", bill.SIREMARK);
+ else
+ Shipping = formatEdiStr("txt", bill.EDIREMARK);
+
+ List ShippingList = formatlengthStr(Shipping, 70);
+
+ if (Shipping != "")
+ {
+ r.WriteLine("17:" + formatListStr(ShippingList, 5) + "'");
+ icount++;
+ }
+
+ if (InttrEdi.filetype != "E" && !string.IsNullOrEmpty(bill.NVONO))
+ {
+ r.WriteLine("18:NVO:" + bill.NVONO + "'");
+
+ }
+
+
+ Shipping = formatEdiStr("txt", bill.SHIPPER);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ r.WriteLine("20::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+ }
+
+
+
+ Shipping = formatEdiStr("txt", bill.CONSIGNEE);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ r.WriteLine("21::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+ }
+
+
+ Shipping = formatEdiStr("txt", bill.NOTIFYPARTY);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+ r.WriteLine("22::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+ }
+
+
+ Shipping = formatEdiStr("txt", bill.NOTIFYPARTY2);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (Shipping != "")
+ {
+
+ r.WriteLine("23::" + formatListStr(ShippingList, 6) + "'");
+ icount = icount + 1;
+
+
+
+ }
+
+ Shipping = bill.AMSCONSIGNEE;
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (Shipping != "")
+ {
+ r.WriteLine("24::" + formatListStr(ShippingList, 6, true) + "'");
+ icount = icount + 1;
+
+ }
+
+
+ Shipping = bill.AMSNOTIFYPARTY;
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ if (Shipping != "")
+ {
+ r.WriteLine("25::" + formatListStr(ShippingList, 6, true) + "'");
+ icount = icount + 1;
+
+ }
+
+
+
+ var cargoid = bill.CARGOID;
+ if (cargoid == "" || cargoid == " ") cargoid = "S";
+
+ var kingweight = bill.KINGTAREWEIGHT;
+ if (kingweight == 0)
+ kingweight = 100;
+
+ r.WriteLine("41:1:" + bill.HSCODE + ":" + cargoid + ":" + bill.PKGS.ToString() + ":" + bill.KINDPKGS_EDI_CODE + ":" + bill.KINDPKGS + ":" + kingweight.ToString() + ":"
+ + bill.CBM.ToString() + "::::::" + bill.KGS.ToString() + ":::'");
+
+ icount = icount + 1;
+ if (cargoid == "R")
+ r.WriteLine("43::::::::::" + bill.REEFERF + ":C:" + bill.TEMPSET + ":" + bill.TEMPMIN + ":" + bill.TEMPMAX + ":::::'");
+ else if (cargoid == "D")
+ r.WriteLine("43:" + bill.DCLASS + ":" + bill.DPAGE + ":" + bill.DUNNO + ":" + bill.DLABEL + "::::::::::::'");
+
+ icount = icount + 1;
+
+
+ Shipping = formatEdiStr("txt", bill.MARKS);
+ ShippingList = formatlengthStr(Shipping, 35);
+
+ for (var i = 0; i < Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(ShippingList.Count) / Convert.ToDecimal(10))); i++)
+ {
+ var tempstr = "44:";
+ for (var z = 0; z < 10; z++)
+ {
+ if ((i * 10 + z) < ShippingList.Count)
+ tempstr = tempstr + ShippingList[i * 10 + z];
+ if (z < 9) tempstr = tempstr + ":";
+ }
+ if (tempstr != "44:")
+ {
+ r.WriteLine(tempstr + "'");
+ icount++;
+ }
+ }
+
+ Shipping = formatEdiStr("txt", bill.DESCRIPTION);
+ ShippingList = formatlengthStr(Shipping, 70);
+
+ var m = 1;
+ var strtemp = "";
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+
+ for (var i = 0; i < ShippingList.Count; i++)
+ {
+ if (ShippingList[i] != "")
+ {
+ if (m <= 5)
+ {
+ if (m == 1) strtemp = "47:" + ShippingList[i] + ":";
+ else
+ {
+ if (m == 5)
+ strtemp = strtemp + ShippingList[i];
+ else
+ strtemp = strtemp + ShippingList[i] + ":";
+ }
+ }
+ else
+ {
+ m = 1;
+ r.WriteLine(strtemp + "'");
+ strtemp = "47:" + ShippingList[i] + ":";
+ icount = icount + 1;
+ }
+ m = m + 1;
+ }
+ }
+ }
+ if (strtemp != "")
+ {
+ r.WriteLine(strtemp + "'");
+ icount = icount + 1;
+ }
+
+ var ISSOC = "N";
+ if (bill.ISCONTAINERSOC) ISSOC = "Y";
+
+ var ctnsumlist = new List();
+
+ foreach (var ctn in bill.CTNLIST)
+ {
+ var newctnsum = ctnsumlist.Find(x => x.CTNALLCODE == ctn.CTNALLCODE);
+ if (newctnsum == null)
+ {
+ var ctnsum = new MsOpSeaeCtnEdiModel();
+ ctnsum.CTNALLCODE = ctn.CTNALLCODE;
+ ctnsum.CTNNUM = ctn.CTNNUM;
+ if (bill.ISCONTAINERSOC && !string.IsNullOrEmpty(ctn.CNTRNO))
+ {
+ if (!string.IsNullOrEmpty(ctnsum.CNTRNO))
+ {
+ ctnsum.CNTRNO = ctn.CNTRNO;
+ }
+ else
+ {
+ ctnsum.CNTRNO = ctnsum.CNTRNO + "," + ctn.CNTRNO;
+
+ }
+ }
+ ctnsumlist.Add(ctnsum);
+
+ }
+ else
+ {
+ newctnsum.CTNNUM = newctnsum.CTNNUM + ctn.CTNNUM;
+ if (bill.ISCONTAINERSOC && !string.IsNullOrEmpty(ctn.CNTRNO))
+ {
+ if (!string.IsNullOrEmpty(newctnsum.CNTRNO))
+ {
+ newctnsum.CNTRNO = ctn.CNTRNO;
+ }
+ else
+ {
+ newctnsum.CNTRNO = newctnsum.CNTRNO + "," + ctn.CNTRNO;
+
+ }
+ }
+
+ }
+ }
+ foreach (var ctnsum in ctnsumlist)
+ {
+ if (InttrEdi.filetype == "E")
+ {
+ r.WriteLine("48:" + ctnsum.CTNALLCODE + ":" + ctnsum.CTNNUM + ":F:::::" + ISSOC + "'");
+ icount = icount + 1;
+ }
+ else
+ {
+ var cntrnostr = "";
+ var isrstr = "N";
+ if (cargoid == "R") isrstr = "Y";
+ r.WriteLine("48:" + ctnsum.CTNALLCODE + ":" + ctnsum.CTNNUM + ":F:::::" + ISSOC + ":" + cntrnostr + ":::" + isrstr + "'");
+ icount = icount + 1;
+
+ }
+
+ }
+
+ foreach (var ctn in bill.CTNLIST)
+ {
+
+ if (InttrEdi.filetype == "E")
+ {
+ r.WriteLine("51:" + ctn.CNTRNO + ":" + ctn.CTNALLCODE + ":"
+ + ctn.SEALNO + ":" + ctn.PKGS.ToString() + ":" + ctn.KGS.ToString() + "::" + ctn.CBM.ToString() + ":" + bill.EDIATTNEMAIL + "'");
+ icount = icount + 1;
+
+ if (bill.CTNGOODSLIST != null && bill.CTNGOODSLIST.Count != 0)
+ {
+ foreach (var ctnhs in bill.CTNGOODSLIST)
+ {
+ r.WriteLine("53:" + ctnhs.HSCODE + ":" + ctnhs.PKGS.ToString() + ":"
+ + ctnhs.KGS.ToString() + ":" + ctnhs.CBM.ToString() + ":" + ctnhs.KINDPKGS_EDI_CODE + ":" + ctnhs.KINDPKGS + "'");
+ icount = icount + 1;
+ Shipping = formatEdiStr("txt", ctnhs.DESCRIPTION);
+ ShippingList = formatlengthStr(Shipping, 70);
+ m = 1;
+ strtemp = "";
+ if (ShippingList.Count != 0 && Shipping.Length > 0)
+ {
+
+ for (var i = 0; i < ShippingList.Count; i++)
+ {
+ if (ShippingList[i] != "")
+ {
+ if (m <= 5)
+ {
+ if (m == 1) strtemp = "54:" + ShippingList[i] + ":";
+ else
+ {
+ if (m == 5)
+ strtemp = strtemp + ShippingList[i];
+ else
+ strtemp = strtemp + ShippingList[i] + ":";
+ }
+ }
+ else
+ {
+ m = 1;
+ r.WriteLine(strtemp + "'");
+ strtemp = "54:" + ShippingList[i] + ":";
+ icount = icount + 1;
+ }
+ m = m + 1;
+ }
+ }
+ }
+ if (strtemp != "")
+ {
+ r.WriteLine(strtemp + "'");
+ icount = icount + 1;
+ }
+
+
+ }
+ }
+ }
+ else
+ {
+ if (!string.IsNullOrEmpty(ctn.CNTRNO))
+ {
+ r.WriteLine("51:" + ctn.CNTRNO + ":" + ctn.CTNALLCODE + ":"
+ + ctn.SEALNO + ":" + ctn.PKGS.ToString() + ":" + ctn.KGS.ToString() + ":'");
+ icount = icount + 1;
+ }
+ }
+ //}
+ }
+
+ }
+
+ icount = icount + 1;
+ r.WriteLine("99:" + icount.ToString() + "'");
+ r.Close();
+ f.Close();
+
+ return filename;
+ }
+ #endregion
+
+
+
+ }
+
+
+ public class MsYTEdiModel
+ {
+
+ ///
+ /// 发送方代码 M
+ ///
+ public string SENDCODE { get; set; }
+
+ ///
+ /// 发送方名称 M
+ ///
+ public string SENDNAME { get; set; }
+
+ ///
+ /// 接收方代码 M
+ ///
+ public string RECEIVECODE { get; set; }
+
+ ///
+ /// 文件类型 (B订舱,E SI确认)M
+ ///
+ public string filetype { get; set; }
+
+ ///
+ /// 文件功能 (9原始,1 更新,5 退舱 )M
+ ///
+ public string filerole { get; set; }
+
+ ///
+ /// 文件路径 M
+ ///
+ public string filerpath { get; set; }
+
+ ///
+ /// 是否使用货代代码。 M
+ ///
+ public bool UseForWarderCode { get; set; }
+ ///
+ /// 货代代码。 O
+ ///
+ public string ForWarderCode { get; set; }
+
+ ///
+ /// 货代名称 O
+ ///
+ public string ForWarderName { get; set; }
+
+ ///
+ /// 业务信息列表 M
+ ///
+ public List BSLIST { get; set; }
+
+
+ }
+
+
+ public class MsOpSeaeEdiModel
+ {
+
+
+ ///
+ /// 委托方
+ ///
+ public string WEITUO { get; set; }
+
+ ///
+ /// 操作英文名称 M
+ ///
+ public string OpEName { get; set; }
+
+ ///
+ /// 操作电话 M
+ ///
+ public string OpTel { get; set; }
+ ///
+ /// 操作邮箱 M
+ ///
+ public string OpEmail { get; set; }
+
+ ///
+ /// EDI联系人名称 O
+ ///
+ public string EDIATTN { get; set; }
+
+ ///
+ /// EDI联系人电话 O
+ ///
+ public string EDIATTNTEL { get; set; }
+ ///
+ /// EDI联系人邮箱 O
+ ///
+ public string EDIATTNEMAIL { get; set; }
+ ///
+ /// 订舱编号 O
+ ///
+ public string ORDERNO { get; set; }
+
+ ///
+ /// 主提单号 M
+ ///
+ public string MBLNO { get; set; }
+
+ ///
+ /// 付费方式代码 M
+ ///
+ public string BLFRTEDICODE { get; set; }
+
+
+ ///
+ /// 付费方式 M
+ ///
+ public string BLFRT { get; set; }
+
+ ///
+ /// 船名 O
+ ///
+ public string VESSEL { get; set; }
+
+ ///
+ /// 船舶呼号 O
+ ///
+ public string VESSELID { get; set; }
+
+
+ ///
+ /// 航次 O
+ ///
+ public string VOYNO { get; set; }
+
+
+ ///
+ /// 内部航次 O
+ ///
+ public string NVOYNO { get; set; }
+
+ ///
+ /// 开船日期 M
+ ///
+ public string ETD { get; set; }
+
+ ///
+ /// EDI备注
+ ///
+ public string EDIREMARK { get; set; }
+
+ ///
+ /// SI备注
+ ///
+ public string SIREMARK { get; set; }
+
+ ///
+ /// NVO NO
+ ///
+ public string NVONO { get; set; }
+
+ ///
+ /// 船公司名称 M
+ ///
+ public string CARRIER { get; set; }
+ ///
+ /// 船公司EDI代码 M
+ ///
+ public string CARRIEREDICODE { get; set; }
+
+ ///
+ /// 发货人 M
+ ///
+ public string SHIPPER { get; set; }
+
+ ///
+ /// 收货人 M
+ ///
+ public string CONSIGNEE { get; set; }
+
+ ///
+ /// 通知人 M
+ ///
+ public string NOTIFYPARTY { get; set; }
+
+ ///
+ /// 第二通知人
+ ///
+ public string NOTIFYPARTY2 { get; set; }
+
+ ///
+ /// AMS收货人
+ ///
+ public string AMSCONSIGNEE { get; set; }
+
+ ///
+ /// AMS通知人
+ ///
+ public string AMSNOTIFYPARTY { get; set; }
+
+
+ ///
+ /// 收货地所在国家 O
+ ///
+ public string BYCOUNTRY { get; set; }
+
+ /////
+ ///// AMS发货人 O
+ /////
+ //public string AMSSHIPPER { get; set; }
+
+ /////
+ ///// AMS收货人 O
+ /////
+ //public string AMSCONSIGNEE { get; set; }
+
+ /////
+ ///// AMS通知人 O
+ /////
+ //public string AMSNOTIFYPARTY { get; set; }
+
+ ///
+ /// HS编码
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+
+
+
+
+ ///
+ /// 收货地代码(每船公司可能不同)
+ ///
+ public string PLACERECEIPTID { get; set; }
+ ///
+ /// 收货地
+ ///
+ public string PLACERECEIPT { get; set; }
+
+
+ ///
+ /// 起运港代码(每船公司可能不同) M
+ ///
+ public string PORTLOADID { get; set; }
+ ///
+ /// 起运港 M
+ ///
+ public string PORTLOAD { get; set; }
+
+
+ ///
+ ///卸货港代码(每船公司可能不同) M
+ ///
+ public string PORTDISCHARGEID { get; set; }
+ ///
+ /// 卸货港 M
+ ///
+ public string PORTDISCHARGE { get; set; }
+
+
+ ///
+ ///中转港代码
+ ///
+ public string TRANSPORTID { get; set; }
+ ///
+ /// 中转港
+ ///
+ public string TRANSPORT { get; set; }
+
+
+ ///
+ ///交货地代码M
+ ///
+ public string PLACEDELIVERYID { get; set; }
+ ///
+ /// 交货地 M
+ ///
+ public string PLACEDELIVERY { get; set; }
+
+ ///
+ ///目的地代码(每船公司可能不同)
+ ///
+ public string DESTINATIONID { get; set; }
+ ///
+ /// 目的地
+ ///
+ public string DESTINATION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ ///
+ /// 货物标识 M
+ ///
+ public string CARGOID { get; set; }
+
+ ///
+ /// 第一层包装皮重 O
+ ///
+ public decimal KINGTAREWEIGHT { get; set; }
+
+
+ ///
+ /// 危险品类别 O
+ ///
+ public string DCLASS { get; set; }
+
+ ///
+ /// 危险品编号 O
+ ///
+ public string DUNNO { get; set; }
+
+ ///
+ /// 危险品页号 C
+ ///
+ public string DPAGE { get; set; }
+
+ ///
+ /// 危险品标签 C
+ ///
+ public string DLABEL { get; set; }
+
+ ///
+ /// 设置温度 O
+ ///
+ public string TEMPSET { get; set; }
+
+
+ ///
+ /// 设置最低温度 C
+ ///
+ public string TEMPMIN { get; set; }
+
+ ///
+ /// 设置最高温度 C
+ ///
+ public string TEMPMAX { get; set; }
+
+
+ ///
+ /// 通风度 O
+ ///
+ public string REEFERF { get; set; }
+
+
+ ///
+ /// 湿度
+ ///
+ public string HUMIDITY { get; set; }
+
+ ///
+ /// 预付地点 O
+ ///
+ public string PREPARDAT { get; set; }
+
+ ///
+ /// 到付地点 O
+ ///
+ public string PAYABLEAT { get; set; }
+
+ ///
+ /// 预付地点EDI代码 O
+ ///
+ public string PREPARDATID { get; set; }
+
+ ///
+ /// 到付地点EDI代码 O
+ ///
+ public string PAYABLEATID { get; set; }
+
+
+ ///
+ /// 签单方式 M(SI)
+ ///
+ public string ISSUETYPE { get; set; }
+
+ ///
+ /// 提单份数 M(SI)
+ ///
+ public string NOBILL { get; set; }
+
+ ///
+ /// 签单地点 M(SI)
+ ///
+ public string ISSUEPLACE { get; set; }
+
+
+ ///
+ /// 签单地点
+ ///
+ public string ISSUEDATE { get; set; }
+
+ ///
+ /// 提单副本份数 M(SI)
+ ///
+ public string COPYNOBILL { get; set; }
+ ///
+ /// 签单地点EDI代码 M(SI)
+ ///
+ public string ISSUEPLACEID { get; set; }
+
+
+ ///
+ /// 运输条款 M
+ ///
+ public string SERVICE { get; set; }
+
+
+ ///
+ /// 运费协议号 M
+ ///
+ public string CONTRACTNO { get; set; }
+
+ ///
+ /// 服务合同号
+ ///
+ public string SERVICECONTRACTNO { get; set; }
+
+ ///
+ /// ESL航线代码 M
+ ///
+ public string ESLLINECODE { get; set; }
+
+ ///
+ /// 收货人邮编 O
+ ///
+ public string CONSIGNEEPOSTCODE { get; set; }
+
+ ///
+ /// 收货人国家 O
+ ///
+ public string CONSIGNEECOUNTRY { get; set; }
+
+ ///
+ /// 收货人税号 O
+ ///
+ public string CONSIGNEETAXNO { get; set; }
+
+ ///
+ /// 通知人邮编 O
+ ///
+ public string NOTIFYPARTYPOSTCODE { get; set; }
+
+ ///
+ /// 通知人国家 O
+ ///
+ public string NOTIFYPARTYCOUNTRY { get; set; }
+
+ ///
+ /// 通知人税号 O
+ ///
+ public string NOTIFYPARTYTAXNO { get; set; }
+
+ ///
+ /// 货物NCM编号 O
+ ///
+ public string GOODSNCM { get; set; }
+
+
+ ///
+ /// 收货人DOOR地址 O
+ ///
+ public string CONSIGNEEDOORADDR { get; set; }
+
+ ///
+ /// 发货人DOOR地址 O
+ ///
+ public string SHIPPERDOORADDR { get; set; }
+
+
+ ///
+ /// SCAC代码 O
+ ///
+ public string SCACCODE { get; set; }
+
+ ///
+ /// ITN编号 O
+ ///
+ public string ITNCODE { get; set; }
+ ///
+ /// 付费方 O
+ ///
+ public string FREIGHTPAYER { get; set; }
+
+ ///
+ /// AMS代码 O
+ ///
+ public string AMSCODE { get; set; }
+ ///
+ /// 是否SOC箱 O
+ ///
+ public bool ISCONTAINERSOC { get; set; }
+
+ ///
+ /// 拆并单列表 O
+ ///
+ public string BSNOLIST { get; set; }
+
+
+
+ ///
+ /// 集装箱明细 M
+ ///
+ public List CTNLIST { get; set; }
+
+ ///
+ /// 集装箱多品名明细 M
+ ///
+ public List CTNGOODSLIST { get; set; }
+ }
+
+ public class MsOpSeaeCtnEdiModel
+ {
+
+ ///
+ /// 箱型EDI代码 M
+ ///
+ public string CTNALLCODE { get; set; }
+
+ public Int32 CTNNUM { get; set; }
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// 封号 M
+ ///
+ public string SEALNO { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+ ///
+ /// 箱皮重
+ ///
+ public string TAREWEIGHT { get; set; }
+
+ ///
+ /// 称重重量
+ ///
+ public string WEIGHKGS { get; set; }
+
+ ///
+ /// 称重方式 (累加、总重)
+ ///
+ public string WEIGHTYPE { get; set; }
+
+ ///
+ /// 称重签名
+ ///
+ public string WEIGHSIGN { get; set; }
+
+
+ }
+ public class MsOpSeaeCtnDetailEdiModel
+ {
+
+ ///
+ /// 箱号 M
+ ///
+ public string CNTRNO { get; set; }
+
+ ///
+ /// HS编码 M
+ ///
+ public string HSCODE { get; set; }
+
+ ///
+ /// 唛头 M
+ ///
+ public string MARKS { get; set; }
+
+ ///
+ /// 货物描述 M
+ ///
+ public string DESCRIPTION { get; set; }
+
+ ///
+ /// 件数 M
+ ///
+ public Int32 PKGS { get; set; }
+
+ ///
+ /// 包装 M
+ ///
+ public string KINDPKGS { get; set; }
+
+ ///
+ /// 包装代码 M
+ ///
+ public string KINDPKGS_EDI_CODE { get; set; }
+
+ ///
+ /// 重量 M
+ ///
+ public decimal KGS { get; set; }
+ ///
+ /// 体积 M
+ ///
+ public decimal CBM { get; set; }
+
+ }
+
+}
diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml
index 00b2b228..221856f6 100644
--- a/Myshipping.Application/Myshipping.Application.xml
+++ b/Myshipping.Application/Myshipping.Application.xml
@@ -1166,74 +1166,3199 @@
体积 M
+
+
+
+
+
+
+
+ edi 文本格式处理判断(例如:1行35个字符不超过5行)
+
+ 文件类型(例如:txt、xml)
+ 要处理的数据
+ 每行长度
+ 主提单号
+ 数据类型(例如:发货人内容、货描等)
+ 限制录入的行数(“0”代表不限制)
+ 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+
+
+
+
+ 各种文本转义字符
+
+ 文件类型(例如:txt、xml)
+ 文本字符串
+
+
+
+
+ 发送方代码 M
+
+
+
+
+ 发送方名称 M
+
+
+
+
+ 接收方代码 M
+
+
+
+
+ 文件类型 (B订舱,E SI确认)M
+
+
+
+
+ 文件功能 (9原始,1 更新,5 退舱 )M
+
+
+
+
+ 文件路径 M
+
+
+
+
+ 是否使用货代代码。 M
+
+
+
+
+ 货代代码。 O
+
+
+
+
+ 货代名称 O
+
+
+
+
+ 业务信息列表 M
+
+
+
+
+ 委托方
+
+
+
+
+ 操作英文名称 M
+
+
+
+
+ 操作电话 M
+
+
+
+
+ 操作邮箱 M
+
+
+
+
+ EDI联系人名称 O
+
+
+
+
+ EDI联系人电话 O
+
+
+
+
+ EDI联系人邮箱 O
+
+
+
+
+ 订舱编号 O
+
+
+
+
+ 场站 M
+
+
+
+
+ 场站代码 M
+
+
+
+
+ 主提单号 M
+
+
+
+
+ 付费方式代码 M
+
+
+
+
+ 付费方式 M
+
+
+
+
+ 船名 O
+
+
+
+
+ 船舶呼号 O
+
+
+
+
+ 航次 O
+
+
+
+
+ 内部航次 O
+
+
+
+
+ 开船日期 M
+
+
+
+
+ 预抵日期 M
+
+
+
+
+ 截港日期 O
+
+
+
+
+ EDI备注
+
+
+
+
+ SI备注
+
+
+
+
+ NVO NO
+
+
+
+
+ 船公司名称 M
+
+
+
+
+ 船公司EDI代码 M
+
+
+
+
+ 发货人 M
+
+
+
+
+ 收货人 M
+
+
+
+
+ 通知人 M
+
+
+
+
+ 第二通知人
+
+
+
+
+ AMS收货人
+
+
+
+
+ AMS通知人
+
+
+
+
+ 收货地所在国家 O
+
+
+
+
+ HS编码
+
+
+
+
+ MasterBOLIndicator
+
+
+
+
+ 商品名称
+
+
+
+
+ 货类代码
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 收货地代码(每船公司可能不同)
+
+
+
+
+ 收货地
+
+
+
+
+ 起运港代码(每船公司可能不同) M
+
+
+
+
+ 起运港 M
+
+
+
+
+ 卸货港代码(每船公司可能不同) M
+
+
+
+
+ 卸货港 M
+
+
+
+
+ 中转港代码
+
+
+
+
+ 中转港
+
+
+
+
+ 交货地代码M
+
+
+
+
+ 交货地 M
+
+
+
+
+ 目的地代码(每船公司可能不同)
+
+
+
+
+ 目的地
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 货物标识 M
+
+
+
+
+ 第一层包装皮重 O
+
+
+
+
+ 危险品类别 O
+
+
+
+
+ 危险品编号 O
+
+
+
+
+ 危险品页号 C
+
+
+
+
+ 危险品标签 C
+
+
+
+
+ 设置温度 O
+
+
+
+
+ 设置最低温度 C
+
+
+
+
+ 设置最高温度 C
+
+
+
+
+ 通风度 O
+
+
+
+
+ 湿度
+
+
+
+
+ 预付地点 O
+
+
+
+
+ 到付地点 O
+
+
+
+
+ 预付地点EDI代码 O
+
+
+
+
+ 到付地点EDI代码 O
+
+
+
+
+ 签单方式 M(SI)
+
+
+
+
+ 提单份数 M(SI)
+
+
+
+
+ 签单地点 M(SI)
+
+
+
+
+ 签单地点
+
+
+
+
+ 提单副本份数 M(SI)
+
+
+
+
+ 签单地点EDI代码 M(SI)
+
+
+
+
+ 运输条款 M
+
+
+
+
+ 运费协议号 M
+
+
+
+
+ 服务合同号
+
+
+
+
+ ESL航线代码 M
+
+
+
+
+ 收货人邮编 O
+
+
+
+
+ 收货人国家 O
+
+
+
+
+ 收货人税号 O
+
+
+
+
+ 通知人邮编 O
+
+
+
+
+ 通知人国家 O
+
+
+
+
+ 通知人税号 O
+
+
+
+
+ 货物NCM编号 O
+
+
+
+
+ 收货人DOOR地址 O
+
+
+
+
+ 发货人DOOR地址 O
+
+
+
+
+ SCAC代码 O
+
+
+
+
+ ITN编号 O
+
+
+
+
+ 付费方 O
+
+
+
+
+ AMS代码 O
+
+
+
+
+ 是否SOC箱 O
+
+
+
+
+ 拆并单列表 O
+
+
+
+
+ 集装箱明细 M
+
+
+
+
+ 集装箱多品名明细 M
+
+
+
+
+ 收货人EDI代码 O
+
+
+
+
+ 发货人EDI代码 O
+
+
+
+
+ 太平销售的代码 M
+
+
+
+
+ ACI HBL O(加拿大)
+
+
+
+
+ S0C C0C O(加拿大)
+
+
+
+
+ '欧盟港口、伊朗港口、KHI'
+
+
+
+
+ '南美东'
+
+
+
+
+ '巴西线的木质包装情况'
+
+
+
+
+ 箱型EDI代码 M
+
+
+
+
+ 箱号 M
+
+
+
+
+ 箱状态
+
+
+
+
+ 封号 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 箱皮重
+
+
+
+
+ 称重重量
+
+
+
+
+ 称重方式 (累加、总重)
+
+
+
+
+ 称重签名
+
+
+
+
+ 箱号 M
+
+
+
+
+ HS编码 M
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ edi 文本格式处理判断(例如:1行35个字符不超过5行)
+
+ 文件类型(例如:txt、xml)
+ 要处理的数据
+ 每行长度
+ 主提单号
+ 数据类型(例如:发货人内容、货描等)
+ 限制录入的行数(“0”代表不限制)
+ 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+
+
+
+
+ 各种文本转义字符
+
+ 文件类型(例如:txt、xml)
+ 文本字符串
+
+
+
+
+ 发送方代码 M
+
+
+
+
+ 发送方名称 M
+
+
+
+
+ 接收方代码 M
+
+
+
+
+ 文件类型 (B订舱,E SI确认)M
+
+
+
+
+ 文件功能 (9原始,1 更新,5 退舱 )M
+
+
+
+
+ 文件路径 M
+
+
+
+
+ 是否使用货代代码。 M
+
+
+
+
+ 货代代码。 O
+
+
+
+
+ 货代名称 O
+
+
+
+
+ 业务信息列表 M
+
+
+
+
+ 委托方
+
+
+
+
+ 操作英文名称 M
+
+
+
+
+ 操作电话 M
+
+
+
+
+ 操作邮箱 M
+
+
+
+
+ EDI联系人名称 O
+
+
+
+
+ EDI联系人电话 O
+
+
+
+
+ EDI联系人邮箱 O
+
+
+
+
+ 订舱编号 O
+
+
+
+
+ 主提单号 M
+
+
+
+
+ 付费方式 M
+
+
+
+
+ 船名 O
+
+
+
+
+ 航次 O
+
+
+
+
+ 内部航次 O
+
+
+
+
+ 开船日期 M
+
+
+
+
+ EDI备注
+
+
+
+
+ SI备注
+
+
+
+
+ 船公司名称 M
+
+
+
+
+ 船公司EDI代码 M
+
+
+
+
+ 发货人 M
+
+
+
+
+ 收货人 M
+
+
+
+
+ 通知人 M
+
+
+
+
+ 第二通知人
+
+
+
+
+ 收货地所在国家 O
+
+
+
+
+ HS编码
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 起运港代码(每船公司可能不同) M
+
+
+
+
+ 起运港 M
+
+
+
+
+ 卸货港代码(每船公司可能不同) M
+
+
+
+
+ 卸货港 M
+
+
+
+
+ 目的地代码(每船公司可能不同)
+
+
+
+
+ 目的地
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 货物标识 M
+
+
+
+
+ 危险品类别 O
+
+
+
+
+ 危险品编号 O
+
+
+
+
+ 设置温度 O
+
+
+
+
+ 通风度 O
+
+
+
+
+ 湿度
+
+
+
+
+ 预付地点 O
+
+
+
+
+ 到付地点 O
+
+
+
+
+ 预付地点EDI代码 O
+
+
+
+
+ 到付地点EDI代码 O
+
+
+
+
+ 签单方式 M(SI)
+
+
+
+
+ 提单份数 M(SI)
+
+
+
+
+ 签单地点 M(SI)
+
+
+
+
+ 提单副本份数 M(SI)
+
+
+
+
+ 签单地点EDI代码 M(SI)
+
+
+
+
+ 运输条款 M
+
+
+
+
+ 运费协议号 M
+
+
+
+
+ 收货人邮编 O
+
+
+
+
+ 收货人国家 O
+
+
+
+
+ 收货人税号 O
+
+
+
+
+ 通知人邮编 O
+
+
+
+
+ 通知人国家 O
+
+
+
+
+ 通知人税号 O
+
+
+
+
+ 货物NCM编号 O
+
+
+
+
+ 收货人DOOR地址 O
+
+
+
+
+ 发货人DOOR地址 O
+
+
+
+
+ SCAC代码 O
+
+
+
+
+ ITN编号 O
+
+
+
+
+ 是否SOC箱 O
+
+
+
+
+ 拆并单列表 O
+
+
+
+
+ 集装箱明细 M
+
+
+
+
+ 集装箱多品名明细 M
+
+
+
+
+ 箱型EDI代码 M
+
+
+
+
+ 箱号 M
+
+
+
+
+ 封号 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 箱号 M
+
+
+
+
+ HS编码 M
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+
+
+
+
+
+ edi 文本格式处理判断(例如:1行35个字符不超过5行)
+
+ 文件类型(例如:txt、xml)
+ 要处理的数据
+ 每行长度
+ 主提单号
+ 数据类型(例如:发货人内容、货描等)
+ 限制录入的行数(“0”代表不限制)
+ 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+
+
+
+
+ 各种文本转义字符
+
+ 文件类型(例如:txt、xml)
+ 文本字符串
+
+
+
+
+ 发送方代码 M
+
+
+
+
+ 发送方名称 M
+
+
+
+
+ 接收方代码 M
+
+
+
+
+ 文件类型 (B订舱,E SI确认)M
+
+
+
+
+ 文件功能 (9原始,1 更新,5 退舱 )M
+
+
+
+
+ 文件路径 M
+
+
+
+
+ 是否使用货代代码。 M
+
+
+
+
+ 货代代码。 O
+
+
+
+
+ 货代名称 O
+
+
+
+
+ 业务信息列表 M
+
+
+
+
+ 委托方
+
+
+
+
+ 操作英文名称 M
+
+
+
+
+ 操作电话 M
+
+
+
+
+ 操作邮箱 M
+
+
+
+
+ EDI联系人名称 O
+
+
+
+
+ EDI联系人电话 O
+
+
+
+
+ EDI联系人邮箱 O
+
+
+
+
+ 订舱编号 O
+
+
+
+
+ 主提单号 M
+
+
+
+
+ 付费方式代码 M
+
+
+
+
+ 付费方式 M
+
+
+
+
+ 船名 O
+
+
+
+
+ 船舶呼号 O
+
+
+
+
+ 航次 O
+
+
+
+
+ 内部航次 O
+
+
+
+
+ 开船日期 M
+
+
+
+
+ EDI备注
+
+
+
+
+ SI备注
+
+
+
+
+ NVO NO
+
+
+
+
+ 船公司名称 M
+
+
+
+
+ 船公司EDI代码 M
+
+
+
+
+ 发货人 M
+
+
+
+
+ 收货人 M
+
+
+
+
+ 通知人 M
+
+
+
+
+ 第二通知人
+
+
+
+
+ AMS收货人
+
+
+
+
+ AMS通知人
+
+
+
+
+ 收货地所在国家 O
+
+
+
+
+ HS编码
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 收货地代码(每船公司可能不同)
+
+
+
+
+ 收货地
+
+
+
+
+ 起运港代码(每船公司可能不同) M
+
+
+
+
+ 起运港 M
+
+
+
+
+ 卸货港代码(每船公司可能不同) M
+
+
+
+
+ 卸货港 M
+
+
+
+
+ 中转港代码
+
+
+
+
+ 中转港
+
+
+
+
+ 交货地代码M
+
+
+
+
+ 交货地 M
+
+
+
+
+ 目的地代码(每船公司可能不同)
+
+
+
+
+ 目的地
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 货物标识 M
+
+
+
+
+ 第一层包装皮重 O
+
+
+
+
+ 危险品类别 O
+
+
+
+
+ 危险品编号 O
+
+
+
+
+ 危险品页号 C
+
+
+
+
+ 危险品标签 C
+
+
+
+
+ 设置温度 O
+
+
+
+
+ 设置最低温度 C
+
+
+
+
+ 设置最高温度 C
+
+
+
+
+ 通风度 O
+
+
+
+
+ 湿度
+
+
+
+
+ 预付地点 O
+
+
+
+
+ 到付地点 O
+
+
+
+
+ 预付地点EDI代码 O
+
+
+
+
+ 到付地点EDI代码 O
+
+
+
+
+ 签单方式 M(SI)
+
+
+
+
+ 提单份数 M(SI)
+
+
+
+
+ 签单地点 M(SI)
+
+
+
+
+ 签单地点
+
+
+
+
+ 提单副本份数 M(SI)
+
+
+
+
+ 签单地点EDI代码 M(SI)
+
+
+
+
+ 运输条款 M
+
+
+
+
+ 场站EDI代码
+
+
+
+
+ 运费协议号 M
+
+
+
+
+ 服务合同号
+
+
+
+
+ ESL航线代码 M
+
+
+
+
+ 收货人邮编 O
+
+
+
+
+ 收货人国家 O
+
+
+
+
+ 收货人税号 O
+
+
+
+
+ 通知人邮编 O
+
+
+
+
+ 通知人国家 O
+
+
+
+
+ 通知人税号 O
+
+
+
+
+ 货物NCM编号 O
+
+
+
+
+ 收货人DOOR地址 O
+
+
+
+
+ 发货人DOOR地址 O
+
+
+
+
+ SCAC代码 O
+
+
+
+
+ ITN编号 O
+
+
+
+
+ 付费方 O
+
+
+
+
+ AMS代码 O
+
+
+
+
+ 是否SOC箱 O
+
+
+
+
+ 拆并单列表 O
+
+
+
+
+ 集装箱明细 M
+
+
+
+
+ 集装箱多品名明细 M
+
+
+
+
+ 箱型EDI代码 M
+
+
+
+
+ 箱号 M
+
+
+
+
+ 封号 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 箱皮重
+
+
+
+
+ 称重重量
+
+
+
+
+ 称重方式 (累加、总重)
+
+
+
+
+ 称重签名
+
+
+
+
+ 箱动态
+
+
+
+
+ 箱号 M
+
+
+
+
+ HS编码 M
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
- 下货纸辅助类
+ 下货纸辅助类
+
+
+
+
+ 各种文本转义字符(东胜7移植)
+
+ 文件类型(例如:txt、xml)
+ 文本字符串
+
+
+
+
+ 获取箱型的EDI代码
+
+
+
+
+
+
+
+ 获取所有箱型(使用缓存)
+
+
+
+
+
+ 获取所有船司(使用缓存)
+
+
+
+
+
+ 获取所有箱型映射(使用缓存)
+
+
+
+
+
+ 获取所有船司映射(使用缓存)
+
+
+
+
+
+ 获取所有付费方式(使用缓存)
+
+
+
+
+
+ 获取所有付费方式映射(使用缓存)
+
+
+
+
+
+ 获取所有船名(使用缓存)
+
+
+
+
+
+ 获取所有船名映射(使用缓存)
+
+
+
+
+
+ edi 文本格式处理判断(例如:1行35个字符不超过5行)
+
+ 文件类型(例如:txt、xml)
+ 要处理的数据
+ 每行长度
+ 主提单号
+ 数据类型(例如:发货人内容、货描等)
+ 限制录入的行数(“0”代表不限制)
+ 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+
+
+
+
+ 各种文本转义字符
+
+ 文件类型(例如:txt、xml)
+ 文本字符串
+
+
+
+
+ 发送方代码 M
+
+
+
+
+ 发送方名称 M
+
+
+
+
+ 接收方代码 M
+
+
+
+
+ 文件类型 (B订舱,E SI确认)M
+
+
+
+
+ 文件功能 (9原始,1 更新,5 退舱 )M
+
+
+
+
+ 文件路径 M
+
+
+
+
+ 是否使用货代代码。 M
+
+
+
+
+ 货代代码。 O
+
+
+
+
+ 货代名称 O
+
+
+
+
+ 业务信息列表 M
+
+
+
+
+ 委托方
+
+
+
+
+ 操作英文名称 M
+
+
+
+
+ 操作电话 M
+
+
+
+
+ 操作邮箱 M
+
+
+
+
+ EDI联系人名称 O
+
+
+
+
+ EDI联系人电话 O
+
+
+
+
+ EDI联系人邮箱 O
+
+
+
+
+ 订舱编号 O
+
+
+
+
+ 主提单号 M
+
+
+
+
+ 付费方式代码 M
+
+
+
+
+ 付费方式 M
+
+
+
+
+ 船名 O
+
+
+
+
+ 船舶呼号 O
+
+
+
+
+ 航次 O
+
+
+
+
+ 内部航次 O
+
+
+
+
+ 开船日期 M
+
+
+
+
+ EDI备注
+
+
+
+
+ SI备注
+
+
+
+
+ NVO NO
+
+
+
+
+ ERN CODE
+
+
+
+
+ TAC CODE
+
+
+
+
+ VAE CODE
+
+
+
+
+ FEC CODE
+
+
+
+
+ 船公司名称 M
+
+
+
+
+ 船公司EDI代码 M
+
+
+
+
+ 发货人 M
+
+
+
+
+ 收货人 M
+
+
+
+
+ 通知人 M
+
+
+
+
+ 第二通知人
+
+
+
+
+ AMS收货人
+
+
+
+
+ AMS通知人
+
+
+
+
+ 收货地所在国家 O
+
+
+
+
+ HS编码
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 收货地代码(每船公司可能不同)
+
+
+
+
+ 收货地
+
+
+
+
+ 起运港代码(每船公司可能不同) M
+
+
+
+
+ 起运港 M
+
+
+
+
+ 卸货港代码(每船公司可能不同) M
+
+
+
+
+ 卸货港 M
+
+
+
+
+ 中转港代码
+
+
+
+
+ 中转港
+
+
+
+
+ 交货地代码M
+
+
+
+
+ 交货地 M
+
+
+
+
+ 目的地代码(每船公司可能不同)
+
+
+
+
+ 目的地
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 货物标识 M
+
+
+
+
+ 第一层包装皮重 O
+
+
+
+
+ 危险品类别 O
+
+
+
+
+ 危险品编号 O
+
+
+
+
+ 危险品页号 C
+
+
+
+
+ 危险品标签 C
+
+
+
+
+ 设置温度 O
+
+
+
+
+ 设置最低温度 C
+
+
+
+
+ 设置最高温度 C
+
+
+
+
+ 通风度 O
+
+
+
+
+ 湿度
+
+
+
+
+ 预付地点 O
+
+
+
+
+ 到付地点 O
+
+
+
+
+ 预付地点EDI代码 O
+
+
+
+
+ 到付地点EDI代码 O
+
+
+
+
+ 签单方式 M(SI)
+
+
+
+
+ 提单份数 M(SI)
+
+
+
+
+ 签单地点 M(SI)
+
+
+
+
+ 签单地点
+
+
+
+
+ 提单副本份数 M(SI)
+
+
+
+
+ 签单地点EDI代码 M(SI)
+
+
+
+
+ 运输条款 M
+
+
+
+
+ 运费协议号 M
+
+
+
+
+ 服务合同号
+
+
+
+
+ ESL航线代码 M
+
+
+
+
+ 收货人邮编 O
+
+
+
+
+ 收货人国家 O
+
+
+
+
+ 收货人税号 O
+
+
+
+
+ 通知人邮编 O
+
+
+
+
+ 通知人国家 O
+
+
+
+
+ 通知人税号 O
+
+
+
+
+ 货物NCM编号 O
+
+
+
+
+ 收货人DOOR地址 O
+
+
+
+
+ 发货人DOOR地址 O
+
+
+
+
+ SCAC代码 O
+
+
+
+
+ ITN编号 O
+
+
+
+
+ 付费方 O
+
+
+
+
+ AMS代码 O
+
+
+
+
+ 是否SOC箱 O
+
+
+
+
+ 拆并单列表 O
+
+
+
+
+ 集装箱明细 M
+
+
+
+
+ 集装箱多品名明细 M
+
+
+
+
+ 箱型EDI代码 M
+
+
+
+
+ 箱号 M
+
+
+
+
+ 封号 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 箱皮重
+
+
+
+
+ 称重重量
+
+
+
+
+ 称重方式 (累加、总重)
+
+
+
+
+ 称重签名
+
+
+
+
+ 箱号 M
+
+
+
+
+ HS编码 M
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ edi 文本格式处理判断(例如:1行35个字符不超过5行)
+
+ 文件类型(例如:txt、xml)
+ 要处理的数据
+ 每行长度
+ 主提单号
+ 数据类型(例如:发货人内容、货描等)
+ 限制录入的行数(“0”代表不限制)
+ 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等)
+
+
+
+
+ 各种文本转义字符
+
+ 文件类型(例如:txt、xml)
+ 文本字符串
+
+
+
+
+ 发送方代码 M
+
+
+
+
+ 发送方名称 M
+
+
+
+
+ 接收方代码 M
+
+
+
+
+ 文件类型 (B订舱,E SI确认)M
+
+
+
+
+ 文件功能 (9原始,1 更新,5 退舱 )M
+
+
+
+
+ 文件路径 M
+
+
+
+
+ 是否使用货代代码。 M
+
+
+
+
+ 货代代码。 O
+
+
+
+
+ 货代名称 O
+
+
+
+
+ 业务信息列表 M
+
+
+
+
+ 委托方
+
+
+
+
+ 操作英文名称 M
+
+
+
+
+ 操作电话 M
+
+
+
+
+ 操作邮箱 M
+
+
+
+
+ EDI联系人名称 O
+
+
+
+
+ EDI联系人电话 O
+
+
+
+
+ EDI联系人邮箱 O
+
+
+
+
+ 订舱编号 O
+
+
+
+
+ 主提单号 M
+
+
+
+
+ 付费方式代码 M
+
+
+
+
+ 付费方式 M
+
+
+
+
+ 船名 O
+
+
+
+
+ 船舶呼号 O
+
+
+
+
+ 航次 O
+
+
+
+
+ 内部航次 O
+
+
+
+
+ 开船日期 M
+
+
+
+
+ EDI备注
+
+
+
+
+ SI备注
+
+
+
+
+ NVO NO
+
+
+
+
+ 船公司名称 M
+
+
+
+
+ 船公司EDI代码 M
+
+
+
+
+ 发货人 M
+
+
+
+
+ 收货人 M
+
+
+
+
+ 通知人 M
+
+
+
+
+ 第二通知人
+
+
+
+
+ AMS收货人
+
+
+
+
+ AMS通知人
+
+
+
+
+ 收货地所在国家 O
+
+
+
+
+ HS编码
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 收货地代码(每船公司可能不同)
+
+
+
+
+ 收货地
+
+
+
+
+ 起运港代码(每船公司可能不同) M
+
+
+
+
+ 起运港 M
+
+
+
+
+ 卸货港代码(每船公司可能不同) M
+
+
+
+
+ 卸货港 M
+
+
+
+
+ 中转港代码
+
+
+
+
+ 中转港
+
+
+
+
+ 交货地代码M
+
+
+
+
+ 交货地 M
+
+
+
+
+ 目的地代码(每船公司可能不同)
+
+
+
+
+ 目的地
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 货物标识 M
+
+
+
+
+ 第一层包装皮重 O
+
+
+
+
+ 危险品类别 O
+
+
+
+
+ 危险品编号 O
+
+
+
+
+ 危险品页号 C
+
+
+
+
+ 危险品标签 C
+
+
+
+
+ 设置温度 O
+
+
+
+
+ 设置最低温度 C
+
+
+
+
+ 设置最高温度 C
+
+
+
+
+ 通风度 O
+
+
+
+
+ 湿度
+
+
+
+
+ 预付地点 O
+
+
+
+
+ 到付地点 O
+
+
+
+
+ 预付地点EDI代码 O
+
+
+
+
+ 到付地点EDI代码 O
+
+
+
+
+ 签单方式 M(SI)
-
+
- 各种文本转义字符(东胜7移植)
+ 提单份数 M(SI)
- 文件类型(例如:txt、xml)
- 文本字符串
-
-
+
- 获取箱型的EDI代码
+ 签单地点 M(SI)
-
-
-
-
+
- 获取所有箱型(使用缓存)
+ 签单地点
-
-
+
- 获取所有船司(使用缓存)
+ 提单副本份数 M(SI)
-
-
+
- 获取所有箱型映射(使用缓存)
+ 签单地点EDI代码 M(SI)
-
-
+
- 获取所有船司映射(使用缓存)
+ 运输条款 M
-
-
+
- 获取所有付费方式(使用缓存)
+ 运费协议号 M
-
-
+
- 获取所有付费方式映射(使用缓存)
+ 服务合同号
-
-
+
- 获取所有船名(使用缓存)
+ ESL航线代码 M
-
-
+
- 获取所有船名映射(使用缓存)
+ 收货人邮编 O
+
+
+
+
+ 收货人国家 O
+
+
+
+
+ 收货人税号 O
+
+
+
+
+ 通知人邮编 O
+
+
+
+
+ 通知人国家 O
+
+
+
+
+ 通知人税号 O
+
+
+
+
+ 货物NCM编号 O
+
+
+
+
+ 收货人DOOR地址 O
+
+
+
+
+ 发货人DOOR地址 O
+
+
+
+
+ SCAC代码 O
+
+
+
+
+ ITN编号 O
+
+
+
+
+ 付费方 O
+
+
+
+
+ AMS代码 O
+
+
+
+
+ 是否SOC箱 O
+
+
+
+
+ 拆并单列表 O
+
+
+
+
+ 集装箱明细 M
+
+
+
+
+ 集装箱多品名明细 M
+
+
+
+
+ 箱型EDI代码 M
+
+
+
+
+ 箱号 M
+
+
+
+
+ 封号 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
+
+
+
+
+ 箱皮重
+
+
+
+
+ 称重重量
+
+
+
+
+ 称重方式 (累加、总重)
+
+
+
+
+ 称重签名
+
+
+
+
+ 箱号 M
+
+
+
+
+ HS编码 M
+
+
+
+
+ 唛头 M
+
+
+
+
+ 货物描述 M
+
+
+
+
+ 件数 M
+
+
+
+
+ 包装 M
+
+
+
+
+ 包装代码 M
+
+
+
+
+ 重量 M
+
+
+
+
+ 体积 M
-
@@ -3721,6 +6846,51 @@
+
+
+ 海运订舱或截单EDI请求
+
+
+
+
+ 订单主键
+
+
+
+
+ 订单号
+
+
+
+
+ 是否使用货代代码
+
+
+
+
+ 货代代码
+
+
+
+
+ 货代名称
+
+
+
+
+
+
+
+
+
+ 发送类型
+
+
+
+
+ 是否直接发送 (默认false)
+
+
订舱主表输出参数
@@ -5212,6 +8382,51 @@
+
+
+ 通用WebApi返回回执
+
+
+
+
+ 是否成功 true=成功 false=失败
+
+
+
+
+ 状态 0-成功
+
+
+
+
+ 返回消息
+
+
+
+
+ 总记录数
+
+
+
+
+ 当前页列表数据
+
+
+
+
+ 合计信息
+
+
+
+
+ 扩展信息
+
+
+
+
+ 扩展信息2
+
+
订舱打印模板服务
diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrClosingEDIOrderDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrClosingEDIOrderDto.cs
new file mode 100644
index 00000000..0032ef59
--- /dev/null
+++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrClosingEDIOrderDto.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application
+{
+ ///
+ /// 海运订舱或截单EDI请求
+ ///
+ public class BookingOrClosingEDIOrderDto
+ {
+ ///
+ /// 订单主键
+ ///
+ public long Id { get; set; }
+ ///
+ /// 订单号
+ ///
+ public string orderNo { get; set; }
+
+ ///
+ /// 是否使用货代代码
+ ///
+ public bool useForwarderCode { get; set; }
+
+ ///
+ /// 货代代码
+ ///
+ public string forwarderCode { get; set; }
+
+ ///
+ /// 货代名称
+ ///
+ public string forwarderName { get; set; }
+
+ ///
+ ///
+ ///
+ public string fileRole { get; set; }
+
+ ///
+ /// 发送类型
+ ///
+ public string sendType { get; set; } = "B";
+
+ ///
+ /// 是否直接发送 (默认false)
+ ///
+ public bool send { get; set; } = false;
+ }
+}
diff --git a/Myshipping.Application/Service/BookingOrder/Dto/CommonWebApiResult.cs b/Myshipping.Application/Service/BookingOrder/Dto/CommonWebApiResult.cs
new file mode 100644
index 00000000..7669af95
--- /dev/null
+++ b/Myshipping.Application/Service/BookingOrder/Dto/CommonWebApiResult.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application
+{
+ ///
+ /// 通用WebApi返回回执
+ ///
+ public class CommonWebApiResult
+ {
+ ///
+ /// 是否成功 true=成功 false=失败
+ ///
+ public bool succ { get; set; } = false;
+ ///
+ /// 状态 0-成功
+ ///
+ public int status { get; set; } = 0;
+
+ ///
+ /// 返回消息
+ ///
+ public string msg { get; set; }
+
+ ///
+ /// 总记录数
+ ///
+ public int total { get; set; }
+
+ ///
+ /// 当前页列表数据
+ ///
+ public object rows { get; set; }
+
+ ///
+ /// 合计信息
+ ///
+ public object summary { get; set; }
+
+ ///
+ /// 扩展信息
+ ///
+ public object extra { get; set; }
+
+ ///
+ /// 扩展信息2
+ ///
+ public object extra2 { get; set; }
+ }
+}
From 8eca47f20a1d188e29264d71f4419fcf2bad1231 Mon Sep 17 00:00:00 2001
From: wet <1034391973@qq.com>
Date: Mon, 14 Nov 2022 18:00:35 +0800
Subject: [PATCH 3/8] =?UTF-8?q?=E7=A7=9F=E6=88=B7=E5=8F=82=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
index 5cc2755c..b100bab1 100644
--- a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
+++ b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
@@ -232,7 +232,7 @@ namespace Myshipping.Core.Service
[HttpGet("/DJYTenantParam/getParamValue")]
public async Task> GetParamValue(long tenantId, string paraCode=null)
{
- return await _valuerep.AsQueryable().Where(x => x.TenantId == tenantId).WhereIF(paraCode!=null,x=>x.ParaCode==paraCode).OrderBy(x => x.Sort).ToListAsync();
+ return await _valuerep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantId).WhereIF(paraCode!=null,x=>x.ParaCode==paraCode).OrderBy(x => x.Sort).ToListAsync();
}
///
/// 增加参数
From 3884cdec3d1c4bbd6400661b85e4b2655fb0d357 Mon Sep 17 00:00:00 2001
From: jianghaiqing
Date: Tue, 15 Nov 2022 08:43:29 +0800
Subject: [PATCH 4/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A2=E8=88=B1?=
=?UTF-8?q?=E5=92=8C=E6=88=AA=E5=8D=95EDI=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Myshipping.Application.xml | 14 ++++++++++++++
.../BookingOrder/BookingOrderService.cs | 19 +++++++++++++++++++
.../BookingOrder/IBookingOrderService.cs | 7 +++++++
3 files changed, 40 insertions(+)
diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml
index f3a0d3d3..8550907f 100644
--- a/Myshipping.Application/Myshipping.Application.xml
+++ b/Myshipping.Application/Myshipping.Application.xml
@@ -6631,6 +6631,13 @@
+
+
+ 发送订舱、截单EDI
+
+ 订舱、截单EDI请求
+ 返回回执
+
获取用户报表的json
@@ -8427,6 +8434,13 @@
扩展信息2
+
+
+ 发送订舱、截单EDI
+
+ 订舱、截单EDI请求
+ 返回回执
+
订舱打印模板服务
diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
index f608d3e3..8f1a5761 100644
--- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
+++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
@@ -1104,7 +1104,26 @@ namespace Myshipping.Application
#endregion
#region 订舱、截单EDI
+ ///
+ /// 发送订舱、截单EDI
+ ///
+ /// 订舱、截单EDI请求
+ /// 返回回执
+ public async Task SendBookingOrClosingEDI(BookingOrClosingEDIOrderDto model)
+ {
+ CommonWebApiResult result = new CommonWebApiResult();
+
+ try
+ {
+ }
+ catch (Exception ex)
+ {
+ result.succ = false;
+ result.msg = ex.Message;
+ }
+ return result;
+ }
#endregion
#region 其他
diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs
index 0c7dd029..d5b08140 100644
--- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs
+++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs
@@ -35,5 +35,12 @@ namespace Myshipping.Application
Task AddBookingStatusLog(List all);
+
+ ///
+ /// 发送订舱、截单EDI
+ ///
+ /// 订舱、截单EDI请求
+ /// 返回回执
+ Task SendBookingOrClosingEDI (BookingOrClosingEDIOrderDto model);
}
}
\ No newline at end of file
From 74ac6b401983f3711f332287c84fd15c234753fc Mon Sep 17 00:00:00 2001
From: wet <1034391973@qq.com>
Date: Tue, 15 Nov 2022 09:33:58 +0800
Subject: [PATCH 5/8] =?UTF-8?q?=E7=A7=9F=E6=88=B7=E5=8F=82=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Myshipping.Core/Myshipping.Core.xml | 8 ++++----
.../DjyTenantParam/DjyTenantParamService.cs | 15 ++++-----------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml
index 1071a9aa..3385005e 100644
--- a/Myshipping.Core/Myshipping.Core.xml
+++ b/Myshipping.Core/Myshipping.Core.xml
@@ -9299,10 +9299,10 @@
-
- 删除租户参数类别表
-
-
+
+ 删除租户参数
+
+
diff --git a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
index b100bab1..5ebd4290 100644
--- a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
+++ b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
@@ -48,10 +48,7 @@ namespace Myshipping.Core.Service
if (string.IsNullOrWhiteSpace(input.ParaName)) {
throw Oops.Oh(ErrorCode.Param002);
}
- if (string.IsNullOrWhiteSpace(input.Type))
- {
- throw Oops.Oh(ErrorCode.Param002);
- }
+
var list=await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type);
if (list!=null) {
@@ -80,10 +77,7 @@ namespace Myshipping.Core.Service
{
throw Oops.Oh(ErrorCode.Param002);
}
- if (string.IsNullOrWhiteSpace(input.Type))
- {
- throw Oops.Oh(ErrorCode.Param002);
- }
+
var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type&&x.Id!=input.Id);
if (list != null)
{
@@ -298,15 +292,14 @@ namespace Myshipping.Core.Service
}
///
- /// 删除租户参数类别表
+ ///删除租户参数
///
///
[HttpPost("/DJYTenantParam/deleteParamValue")]
[SqlSugarUnitOfWork]
public async Task DeleteParamValue(long Id)
{
- var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
- await _valuerep.DeleteAsync(entity);
+ await _valuerep.DeleteAsync(u => u.Id == Id);
}
#endregion
From 654cd9769ee39943df46536ab611ec2ad1b38a7a Mon Sep 17 00:00:00 2001
From: wet <1034391973@qq.com>
Date: Tue, 15 Nov 2022 10:59:58 +0800
Subject: [PATCH 6/8] =?UTF-8?q?=E5=8F=82=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Myshipping.Core/Enum/ErrorCode.cs | 6 ++-
.../DjyTenantParam/DjyTenantParamService.cs | 53 +++++++++++--------
.../DjyTenantParam/IDjyTenantParamService.cs | 2 +-
3 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/Myshipping.Core/Enum/ErrorCode.cs b/Myshipping.Core/Enum/ErrorCode.cs
index 8f93df63..05cb3c44 100644
--- a/Myshipping.Core/Enum/ErrorCode.cs
+++ b/Myshipping.Core/Enum/ErrorCode.cs
@@ -468,6 +468,10 @@ public enum ErrorCode
///
[ErrorCodeItemMetadata("租户ID不能为空")]
Param007,
-
+ ///
+ /// 业务大类不能为空
+ ///
+ [ErrorCodeItemMetadata("业务大类不能为空")]
+ Param008,
#endregion
}
diff --git a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
index 5ebd4290..b80f2560 100644
--- a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
+++ b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
@@ -31,7 +31,7 @@ namespace Myshipping.Core.Service
_logger = logger;
_itemrep = itemrep;
_valuerep = valuerep;
- _cache = cache;
+ _cache = cache;
}
#region 类别
@@ -42,16 +42,23 @@ namespace Myshipping.Core.Service
[HttpPost("/DJYTenantParam/add")]
public async Task Add(AddDJYTenantParamInput input)
{
- if (string.IsNullOrWhiteSpace(input.ParaCode)) {
+ if (string.IsNullOrWhiteSpace(input.ParaCode))
+ {
throw Oops.Oh(ErrorCode.Param001);
}
- if (string.IsNullOrWhiteSpace(input.ParaName)) {
+ if (string.IsNullOrWhiteSpace(input.ParaName))
+ {
throw Oops.Oh(ErrorCode.Param002);
}
-
-
- var list=await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type);
- if (list!=null) {
+ if (string.IsNullOrWhiteSpace(input.Type))
+ {
+ throw Oops.Oh(ErrorCode.Param008);
+ }
+
+
+ var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type);
+ if (list != null)
+ {
throw Oops.Oh(ErrorCode.Param004);
}
var entity = input.Adapt();
@@ -65,7 +72,7 @@ namespace Myshipping.Core.Service
[HttpPost("/DJYTenantParam/edit")]
public async Task Update(UpdateDJYTenantParamInput input)
{
- if ( input.Id==0)
+ if (input.Id == 0)
{
throw Oops.Oh(ErrorCode.Param000);
}
@@ -77,8 +84,12 @@ namespace Myshipping.Core.Service
{
throw Oops.Oh(ErrorCode.Param002);
}
-
- var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type&&x.Id!=input.Id);
+ if (string.IsNullOrWhiteSpace(input.Type))
+ {
+ throw Oops.Oh(ErrorCode.Param008);
+ }
+
+ var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type && x.Id != input.Id);
if (list != null)
{
throw Oops.Oh(ErrorCode.Param004);
@@ -105,15 +116,15 @@ namespace Myshipping.Core.Service
await _rep.DeleteAsync(entity);
}
-
+
///
/// 获取租户参数类别
///
///
[HttpGet("/DJYTenantParam/list")]
- public async Task> List(string Type)
+ public async Task> List(string Type, string ParaCode)
{
- return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type),x => x.Type == Type).OrderBy(x => x.Sort).ToListAsync();
+ return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type), x => x.Type == Type).WhereIF(!string.IsNullOrEmpty(ParaCode), x => x.ParaCode == ParaCode).OrderBy(x => x.Sort).ToListAsync();
}
#endregion
@@ -209,7 +220,7 @@ namespace Myshipping.Core.Service
var entity = await _itemrep.FirstOrDefaultAsync(u => u.Id == Id);
await _valuerep.DeleteAsync(m => m.ItemCode == entity.ItemCode && m.ParaCode == entity.ParaCode);
await _itemrep.DeleteAsync(entity);
-
+
}
@@ -224,9 +235,9 @@ namespace Myshipping.Core.Service
///
///
[HttpGet("/DJYTenantParam/getParamValue")]
- public async Task> GetParamValue(long tenantId, string paraCode=null)
+ public async Task> GetParamValue(long tenantId, string paraCode = null)
{
- return await _valuerep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantId).WhereIF(paraCode!=null,x=>x.ParaCode==paraCode).OrderBy(x => x.Sort).ToListAsync();
+ return await _valuerep.AsQueryable().Filter(null, true).Where(x => x.TenantId == tenantId).WhereIF(paraCode != null, x => x.ParaCode == paraCode).OrderBy(x => x.Sort).ToListAsync();
}
///
/// 增加参数
@@ -244,11 +255,11 @@ namespace Myshipping.Core.Service
{
throw Oops.Oh(ErrorCode.Param005);
}
- if ( input.TenantId==null)
+ if (input.TenantId == null)
{
throw Oops.Oh(ErrorCode.Param007);
}
- var list = await _valuerep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.TenantId == input.TenantId );
+ var list = await _valuerep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.TenantId == input.TenantId);
if (list != null)
{
throw Oops.Oh(ErrorCode.Param004);
@@ -282,7 +293,7 @@ namespace Myshipping.Core.Service
{
throw Oops.Oh(ErrorCode.Param007);
}
- var list = await _valuerep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.TenantId == input.TenantId&&x.Id!=input.Id);
+ var list = await _valuerep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.TenantId == input.TenantId && x.Id != input.Id);
if (list != null)
{
throw Oops.Oh(ErrorCode.Param004);
@@ -292,7 +303,7 @@ namespace Myshipping.Core.Service
}
///
- ///删除租户参数
+ ///删除参数
///
///
[HttpPost("/DJYTenantParam/deleteParamValue")]
@@ -306,7 +317,7 @@ namespace Myshipping.Core.Service
public async Task CacheData()
{
var list = await _valuerep.AsQueryable().Filter(null, true).ToListAsync();
-
+
await _cache.SetAllTenantParam(list);
}
}
diff --git a/Myshipping.Core/Service/DjyTenantParam/IDjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/IDjyTenantParamService.cs
index 467e192d..40c6cb89 100644
--- a/Myshipping.Core/Service/DjyTenantParam/IDjyTenantParamService.cs
+++ b/Myshipping.Core/Service/DjyTenantParam/IDjyTenantParamService.cs
@@ -11,7 +11,7 @@ namespace Myshipping.Core.Service
Task Add(AddDJYTenantParamInput input);
Task Update(UpdateDJYTenantParamInput input);
Task Delete(long Id);
- Task> List(string Type);
+ Task> List(string Type,string ParaCode);
Task> GetParamItem(string ParaCode);
Task AddParamItem(DjyTenantParamItem input);
From ba25ef47e7525a4f565ace2ba6c91d9cf47dea7f Mon Sep 17 00:00:00 2001
From: wet <1034391973@qq.com>
Date: Tue, 15 Nov 2022 11:03:10 +0800
Subject: [PATCH 7/8] =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=A4=A7=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Service/DjyTenantParam/DjyTenantParamService.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
index b80f2560..542c3505 100644
--- a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
+++ b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
@@ -56,7 +56,7 @@ namespace Myshipping.Core.Service
}
- var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type);
+ var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode);
if (list != null)
{
throw Oops.Oh(ErrorCode.Param004);
@@ -89,7 +89,7 @@ namespace Myshipping.Core.Service
throw Oops.Oh(ErrorCode.Param008);
}
- var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Type == input.Type && x.Id != input.Id);
+ var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Id != input.Id);
if (list != null)
{
throw Oops.Oh(ErrorCode.Param004);
From 2c8b92d4fbca534908c20a08295bc94c078bb5ab Mon Sep 17 00:00:00 2001
From: wet <1034391973@qq.com>
Date: Tue, 15 Nov 2022 11:23:48 +0800
Subject: [PATCH 8/8] =?UTF-8?q?=E7=A7=9F=E6=88=B7=E5=8F=82=E6=95=B0?=
=?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E6=9B=B4=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Myshipping.Core/Myshipping.Core.xml | 9 +++++++--
.../Service/DjyTenantParam/DjyTenantParamService.cs | 4 ++--
.../Service/DjyTenantParam/IDjyTenantParamService.cs | 2 +-
Myshipping.Report/Myshipping.Report.csproj.user | 2 +-
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml
index 3385005e..f21d276f 100644
--- a/Myshipping.Core/Myshipping.Core.xml
+++ b/Myshipping.Core/Myshipping.Core.xml
@@ -4075,6 +4075,11 @@
租户ID不能为空
+
+
+ 业务大类不能为空
+
+
文件扩展枚举
@@ -9250,7 +9255,7 @@
-
+
获取租户参数类别
@@ -9300,7 +9305,7 @@
- 删除租户参数
+ 删除参数
diff --git a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
index 542c3505..b0439dde 100644
--- a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
+++ b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs
@@ -122,9 +122,9 @@ namespace Myshipping.Core.Service
///
///
[HttpGet("/DJYTenantParam/list")]
- public async Task> List(string Type, string ParaCode)
+ public async Task> List(string Type, string ParaName)
{
- return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type), x => x.Type == Type).WhereIF(!string.IsNullOrEmpty(ParaCode), x => x.ParaCode == ParaCode).OrderBy(x => x.Sort).ToListAsync();
+ return await _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(Type), x => x.Type == Type).WhereIF(!string.IsNullOrEmpty(ParaName), x => x.ParaName.Contains(ParaName)).OrderBy(x => x.Sort).ToListAsync();
}
#endregion
diff --git a/Myshipping.Core/Service/DjyTenantParam/IDjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/IDjyTenantParamService.cs
index 40c6cb89..9f0bd264 100644
--- a/Myshipping.Core/Service/DjyTenantParam/IDjyTenantParamService.cs
+++ b/Myshipping.Core/Service/DjyTenantParam/IDjyTenantParamService.cs
@@ -11,7 +11,7 @@ namespace Myshipping.Core.Service
Task Add(AddDJYTenantParamInput input);
Task Update(UpdateDJYTenantParamInput input);
Task Delete(long Id);
- Task> List(string Type,string ParaCode);
+ Task> List(string Type,string ParaName);
Task> GetParamItem(string ParaCode);
Task AddParamItem(DjyTenantParamItem input);
diff --git a/Myshipping.Report/Myshipping.Report.csproj.user b/Myshipping.Report/Myshipping.Report.csproj.user
index c54031d1..5831b7bf 100644
--- a/Myshipping.Report/Myshipping.Report.csproj.user
+++ b/Myshipping.Report/Myshipping.Report.csproj.user
@@ -8,7 +8,7 @@
- Release|Any CPU
+ Debug|Any CPU