From 9a5681151c8bc9887d7392b016a79ab3deeee329 Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Mon, 6 Mar 2023 17:19:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?EDI=E8=AE=BE=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Core/Entity/DJY/DjyEdiSetting.cs | 8 ++ Myshipping.Core/Myshipping.Core.xml | 33 +++++- .../DjyEdiSetting/DjyEdiSettingService.cs | 103 ++++++++++++++++-- .../DjyEdiSetting/Dto/DjyEdiSettingInput.cs | 72 ++++++------ .../DjyEdiSetting/IDjyEdiSettingService.cs | 5 +- 5 files changed, 177 insertions(+), 44 deletions(-) diff --git a/Myshipping.Core/Entity/DJY/DjyEdiSetting.cs b/Myshipping.Core/Entity/DJY/DjyEdiSetting.cs index e0186db6..1baf217e 100644 --- a/Myshipping.Core/Entity/DJY/DjyEdiSetting.cs +++ b/Myshipping.Core/Entity/DJY/DjyEdiSetting.cs @@ -111,5 +111,13 @@ namespace Myshipping.Core.Entity /// 租户名称 /// public string TenantName { get; set; } + /// + /// 发送类型 + /// + public string SendType { get; set; } + /// + /// 启用标志 + /// + public bool EnableFlag { get; set; } = true; } } \ No newline at end of file diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index e42bc08d..f855d73c 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -2034,6 +2034,16 @@ 租户名称 + + + 发送类型 + + + + + 启用标志 + + @@ -10766,18 +10776,32 @@ - 增加EDI参数设置 + 增加EDI参数设置(准备作废,使用save接口代替) + + + + + + + 保存EDI参数设置 - 更新EDI参数设置 + 更新EDI参数设置(准备作废,使用save接口代替) + + + 设置启用(启用后,同船司、同发送类型的其他EDI通道会被取消启用) + + + + 删除EDI参数设置 @@ -15474,6 +15498,11 @@ 租户名称 + + + 发送类型 + + EDI参数设置新增输入参数 diff --git a/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs b/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs index 59bc77c1..f680df21 100644 --- a/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs +++ b/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs @@ -49,7 +49,7 @@ namespace Myshipping.Core.Service } /// - /// 增加EDI参数设置 + /// 增加EDI参数设置(准备作废,使用save接口代替) /// /// /// @@ -58,20 +58,80 @@ namespace Myshipping.Core.Service { var cc = _rep.AsQueryable() .Filter(null, true) - .Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID); + .Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.SendType == input.SendType); if (cc > 0) { - throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})相同船司({input.CARRIERID})的参数设置"); + throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})、相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置"); } var entity = input.Adapt(); await _rep.InsertAsync(entity); await CacheData(); + + + return entity.Id; } /// - /// 更新EDI参数设置 + /// 保存EDI参数设置 + /// + /// + /// + [HttpPost("/DjyEdiSetting/save")] + public async Task Save(UpdateDjyEdiSettingInput input) + { + DjyEdiSetting entity = null; + if (input.Id == 0) //新增 + { + var cc = _rep.AsQueryable() + .Filter(null, true) + .Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.SendType == input.SendType); + + if (cc > 0) + { + throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})、相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置"); + } + + entity = input.Adapt(); + await _rep.InsertAsync(entity); + + //其他同船司、同发送类型的都禁用 + var otherList = _rep.Where(x => x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.Id != entity.Id).ToList(); + foreach (var item in otherList) + { + item.EnableFlag = false; + await _rep.UpdateAsync(item); + } + } + else + { + entity = _rep.AsQueryable() + .Filter(null, true) + .First(x => x.Id == input.Id); + if (entity == null) + { + throw Oops.Bah($"未找到数据"); + } + + var cc = _rep.AsQueryable().Filter(null, true) + .Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.SendType == input.SendType && x.Id != input.Id); + if (cc > 0) + { + throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})、相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置"); + } + + entity = input.Adapt(entity); + await _rep.UpdateAsync(entity); + } + + await CacheData(); + return entity.Id; + + } + + /// + /// 更新EDI参数设置(准备作废,使用save接口代替) /// /// /// @@ -87,10 +147,10 @@ namespace Myshipping.Core.Service } var cc = _rep.AsQueryable().Filter(null, true) - .Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.Id != input.Id); + .Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId && x.CARRIERID == input.CARRIERID && x.SendType == input.SendType && x.Id != input.Id); if (cc > 0) { - throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})相同船司({input.CARRIERID})的参数设置"); + throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})、相同船司({input.CARRIERID})、相同发送类型({input.SendType})的参数设置"); } entity = input.Adapt(entity); @@ -100,6 +160,35 @@ namespace Myshipping.Core.Service return entity.Id; } + /// + /// 设置启用(启用后,同船司、同发送类型的其他EDI通道会被取消启用) + /// + /// + /// + [HttpPost("/DjyEdiSetting/SetEnable")] + public async Task SetEnable(long id) + { + var entity = _rep.AsQueryable() + .Filter(null, true) + .First(x => x.Id == id); + if (entity == null) + { + throw Oops.Bah($"未找到数据"); + } + + entity.EnableFlag = true; + await _rep.UpdateAsync(entity); + + + //其他同船司、同发送类型的都禁用 + var otherList = _rep.Where(x => x.TenantId == entity.TenantId && x.CARRIERID == entity.CARRIERID && x.Id != entity.Id).ToList(); + foreach (var item in otherList) + { + item.EnableFlag = false; + await _rep.UpdateAsync(item); + } + } + /// /// 删除EDI参数设置 /// @@ -141,7 +230,7 @@ namespace Myshipping.Core.Service { if (!_cacheService.Exists(CommonConst.CACHE_KEY_DJY_EDI_SETTING)) { - var list = _rep.AsQueryable().Filter(null, true).OrderBy(x=>x.EDINAME).ToList(); + var list = _rep.AsQueryable().Filter(null, true).OrderBy(x => x.EDINAME).ToList(); await _cacheService.SetAllEdiSetting(list); } } diff --git a/Myshipping.Core/Service/DjyEdiSetting/Dto/DjyEdiSettingInput.cs b/Myshipping.Core/Service/DjyEdiSetting/Dto/DjyEdiSettingInput.cs index 223eeaf8..9e6e964c 100644 --- a/Myshipping.Core/Service/DjyEdiSetting/Dto/DjyEdiSettingInput.cs +++ b/Myshipping.Core/Service/DjyEdiSetting/Dto/DjyEdiSettingInput.cs @@ -13,132 +13,136 @@ namespace Myshipping.Core /// EDI类型代码 /// public virtual string EDICODE { get; set; } - + /// /// EDI类型名称 /// public virtual string EDINAME { get; set; } - + /// /// 服务器IP /// public virtual string SERVERIP { get; set; } - + /// /// 文件夹 /// public virtual string FOLDERNAME { get; set; } - + /// /// 用户名 /// public virtual string USERNAME { get; set; } - + /// /// 密码 /// public virtual string PASSWORD { get; set; } - + /// /// 发送方代码 /// public virtual string SENDCODE { get; set; } - + /// /// 接收方代码 /// public virtual string RECEIVECODE { get; set; } - + /// /// 发送方名称 /// public virtual string SENDNAME { get; set; } - + /// /// 发送方联系人 /// public virtual string SENDATTN { get; set; } - + /// /// 发送方邮箱 /// public virtual string SENDTEL { get; set; } - + /// /// 发送方电话 /// public virtual string SENDEMAIL { get; set; } - + /// /// 发送方公司代码 /// public virtual string SENDCOMPANYCODE { get; set; } - + /// /// 发送方部门代码 /// public virtual string SENDSUBCOMPANYCODE { get; set; } - + /// /// 船公司代码 /// public virtual string CARRIERID { get; set; } - + /// /// 接收方邮箱 /// public virtual string RECEIVEEMAIL { get; set; } - + /// /// 接收方SI邮箱 /// public virtual string RECEIVESIEMAIL { get; set; } - + /// /// 接收方操作 /// public virtual string RECEIVEOP { get; set; } - + /// /// 接收方销售 /// public virtual string RECEIVESALE { get; set; } - + /// /// 接收方部门 /// public virtual string RECEIVEDEPT { get; set; } - + /// /// 发送人电话 /// public virtual string SHIPPERTEL { get; set; } - + /// /// 收货人电话 /// public virtual string CONSIGNEETEL { get; set; } - + /// /// 通知人电话 /// public virtual string NOTIFYPARTYTEL { get; set; } - + /// /// 是否设置TEL /// public virtual string ISUSETEL { get; set; } - + /// /// 租户ID /// public virtual long TenantId { get; set; } - + /// /// 租户名称 /// public virtual string TenantName { get; set; } - + /// + /// 发送类型 + /// + public string SendType { get; set; } = string.Empty; + } /// @@ -158,7 +162,7 @@ namespace Myshipping.Core /// [Required(ErrorMessage = "主键不能为空")] public long Id { get; set; } - + } /// @@ -171,7 +175,7 @@ namespace Myshipping.Core /// [Required(ErrorMessage = "主键不能为空")] public long Id { get; set; } - + } /// @@ -183,31 +187,31 @@ namespace Myshipping.Core /// 主键 /// public virtual long Id { get; set; } - + /// /// EDI类型代码 /// public virtual string EDICODE { get; set; } - + /// /// EDI类型名称 /// public virtual string EDINAME { get; set; } - + /// /// 船公司代码 /// public virtual string CARRIERID { get; set; } - + /// /// 租户ID /// public virtual long TenantId { get; set; } - + /// /// 租户名称 /// public virtual string TenantName { get; set; } - + } } diff --git a/Myshipping.Core/Service/DjyEdiSetting/IDjyEdiSettingService.cs b/Myshipping.Core/Service/DjyEdiSetting/IDjyEdiSettingService.cs index 0846e035..921bbb70 100644 --- a/Myshipping.Core/Service/DjyEdiSetting/IDjyEdiSettingService.cs +++ b/Myshipping.Core/Service/DjyEdiSetting/IDjyEdiSettingService.cs @@ -10,11 +10,14 @@ namespace Myshipping.Core.Service Task Page([FromQuery] QueryDjyEdiSettingInput input); Task Add(AddDjyEdiSettingInput input); Task Update(UpdateDjyEdiSettingInput input); + Task Save(UpdateDjyEdiSettingInput input); Task Delete(GetDjyEdiSettingInput input); Task Get([FromQuery] GetDjyEdiSettingInput input); //Task List([FromQuery] QueryDjyEdiSettingInput input); + Task SetEnable(long id); + Task CacheData(bool flag); - + } } \ No newline at end of file From d7b65dc325bcf4f0ad7fd787fed71dc8ef84ab0e Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 6 Mar 2023 17:46:33 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9EPIL=20MELL=20EDI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/EDI/MellEdiHelper.cs | 1391 +++++++++++++++++++ 1 file changed, 1391 insertions(+) create mode 100644 Myshipping.Application/EDI/MellEdiHelper.cs diff --git a/Myshipping.Application/EDI/MellEdiHelper.cs b/Myshipping.Application/EDI/MellEdiHelper.cs new file mode 100644 index 00000000..4e8627ae --- /dev/null +++ b/Myshipping.Application/EDI/MellEdiHelper.cs @@ -0,0 +1,1391 @@ +using NPOI.OpenXmlFormats.Spreadsheet; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Myshipping.Application.EDI +{ + /// + /// 太平玛利亚 + /// + public class MellEdiHelper + { + public MellEdiHelper() + { + } + + /* + public static string IsCreatePILMELL(EDIBaseModel InttrEdi) + { + //T_ALL_DA T_ALL_DA = new T_ALL_DA(); + + var error = ""; + foreach (var bill in InttrEdi.BSLIST) + { + //var OpBill = MsOpSeaeDAL.MsOpSeaeDAL.GetBillData("BSNO='" + bill.BSNO + "'"); + //var billams = GetAmsData("BSNO='" + bill.BSNO + "'"); + int IsNADFW = 1; + + + if (InttrEdi.filetype == "B") + { + if (InttrEdi.UseForWarderCode) + { + if (InttrEdi.ForWarderCode?.Trim() == "") + { error = error + "
货代代码不能为空"; } + + if (InttrEdi.ForWarderName.Trim() == "") + { error = error + "
货代称呼不能为空"; } + + if (bill.ORDERNO.Trim() == "") + { error = error + "
订舱编号不能为空"; } + } + } + if (bill.OpEName == null || bill.OP == "") + { error = error + "
操作不能为空"; } + else + { + if (dsUserOp != null) + { + if (dsUserOp.Tables[0].Rows.Count > 0) + { + if (carrier != "YML") + { + if (dsUserOp.Tables[0].Rows[0]["USERNAME"].ToString().Trim() == "") + { error = error + "
操作的英文名不能为空"; } + + if (dsUserOp.Tables[0].Rows[0]["OFFICEPHONE"].ToString().Trim() == "") + { error = error + "
操作的电话不能为空"; } + + //if (dsUserOp.Tables[0].Rows[0]["EMAIL1"].ToString().Trim() == "") + //{ error = error + "
操作的邮箱不能为空"; } + } + } + else + { + { error = error + "
操作的信息不能为空"; } + + } + } + else + { + { error = error + "
操作的信息不能为空"; } + + } + } + + if (bill.SERVICE == "DOOR-DOOR" || bill.SERVICE == "DOOR-CY" || bill.SERVICE == "CY-DOOR") + { + if (bill.CARRIER != "YML") + { + + if (bill.ATTN == null || bill.ATTN == "") + { error = error + "
EDI信息联系人不能为空"; } + + if (billams.ATTNTEL == null || billams.ATTNTEL == "") + { error = error + "
EDI信息联系人电话不能为空"; } + + if (billams.ATTNEMAIL == null || billams.ATTNEMAIL == "") + { error = error + "
EDI信息联系人邮箱不能为空"; } + } + } + + if (bill.CARGOID == "D") + { + if (carrier != "YML") + { + if (string.IsNullOrEmpty(billams.ATTN)) + { + } + else + { + if (billams.ATTN == null || billams.ATTN == "") + { error = error + "
EDI信息联系人不能为空"; } + + if (billams.ATTNTEL == null || billams.ATTNTEL == "") + { error = error + "
EDI信息联系人电话不能为空"; } + + if (billams.ATTNEMAIL == null || billams.ATTNEMAIL == "") + { error = error + "
EDI信息联系人邮箱不能为空"; } + } + } + } + + if (bill.MBLNO == null || bill.MBLNO == "") + { } + else + { + if (StringIsChinese(bill.MBLNO)) + { + error = error + "
提单号:" + bill.MBLNO + " 提单号含有中文或双字节字符"; + } + + } + if (isbill == 1) + { + if (OpBill.MBLNO == null || OpBill.MBLNO == "") + { error = error + "
分票提单主提单号不能为空"; } + else + { + if (StringIsChinese(OpBill.MBLNO)) + { + error = error + "
提单号:" + bill.MBLNO + " 提单号含有中文或双字节字符"; + } + + } + + } + + if ((bill.BLFRT == null || bill.BLFRT == "")) + { error = error + "
提单号:" + bill.MBLNO + " 付费方式不能为空"; } + + //if (filetype == "E") + //{ + //if (carrier != "MAEU") + //if ((bill.HSCODE == null || bill.HSCODE == "")) + //{ error = error + "
提单号:" + bill.MBLNO + " HSCODE不能为空"; } + if (carrier != "MCCQ" && carrier != "MAEU" && carrier != "SUDU") + { + if (bill.VESSEL == null || bill.VESSEL == "") + { error = error + "
提单号:" + bill.MBLNO + " 船名不能为空"; } + + if (bill.VOYNO == null || bill.VOYNO == "") + { error = error + "
提单号:" + bill.MBLNO + " 航次不能为空"; } + } + //} + if (filetype == "E") + { + if (billams.SIREMARK.IndexOf("PLEASE BOOK OCEAN CARRIER") > -1 || billams.SIREMARK.ToString().Trim() == "") + { + if (carrier == "COSU") + { + error = error + "
提单号:" + bill.MBLNO + " 请在SI备注中输入:COSCO 销售的营销代码(此代码船公司会直接提供)"; + } + else + { + //if (carrier != "YML") + //error = error + "
提单号:" + bill.MBLNO + " EDI备注中不能为空"; + } + } + else + { + if (StringIsChinese(billams.SIREMARK)) + { + error = error + "
提单号:" + bill.MBLNO + " SI备注中含有中文或双字节字符"; + } + //if (bill.EDIREMARK.ToString().Trim()!="" && BasicDataRefDAL.isHasChinese(bill.EDIREMARK)) + //{ + // error = error + "
提单号:" + bill.MBLNO + " 请在EDI备注中输入:英文(不允许录入中文)"; + //} + } + } + else + { + if (bill.EDIREMARK.IndexOf("PLEASE BOOK OCEAN CARRIER") > -1 || bill.EDIREMARK.ToString().Trim() == "") + { + if (carrier == "COSU") + { + error = error + "
提单号:" + bill.MBLNO + " 请在EDI备注中输入:COSCO 销售的营销代码(此代码船公司会直接提供)"; + } + else + { + //if (carrier != "YML") + //error = error + "
提单号:" + bill.MBLNO + " EDI备注中不能为空"; + } + } + else + { + if (StringIsChinese(bill.EDIREMARK)) + { + error = error + "
提单号:" + bill.MBLNO + " EDI备注中含有中文或双字节字符"; + } + //if (bill.EDIREMARK.ToString().Trim()!="" && BasicDataRefDAL.isHasChinese(bill.EDIREMARK)) + //{ + // error = error + "
提单号:" + bill.MBLNO + " 请在EDI备注中输入:英文(不允许录入中文)"; + //} + } + } + if (bill.CARRIER == null || bill.CARRIER == "") + { error = error + "
提单号:" + bill.MBLNO + " 船公司不能为空"; } + else + { + if (GetCustEdi(bill.CARRIER) == "") + { error = error + "
提单号:" + bill.MBLNO + " 船公司EDI代码不能为空"; } + } + + if (billams.BYCOUNTRY != "" && carrier != "OOLU") + { + if (billams.AMSSHIPPER == "") + { + error = error + "
提单号:" + bill.MBLNO + " AMS发货人不能为空"; + } + else + { + if (StringIsChinese(billams.AMSSHIPPER)) + { + error = error + "
提单号:" + bill.MBLNO + " AMS发货人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", billams.AMSSHIPPER, 35, bill.MBLNO, "AMS发货人", 6, "-", false); + //} + //else + //{ + // error += formatlengthError("txt", billams.AMSSHIPPER, 35, bill.MBLNO, "AMS发货人", 6, "*", false); + //} + } + } + } + else + { + if (bill.SHIPPER == "") + { + error = error + "
提单号:" + bill.MBLNO + " 发货人不能为空"; + } + else + { + if (StringIsChinese(bill.SHIPPER)) + { + error = error + "
提单号:" + bill.MBLNO + " 发货人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", bill.SHIPPER, 35, bill.MBLNO, "发货人", 6, "-", false); + //} + //else + //{ + // error += formatlengthError("txt", bill.SHIPPER, 35, bill.MBLNO, "发货人", 6, "*", false); + //} + } + } + } + + if (isbill == 1) + { + if (OpBill.SHIPPER == "") + { + error = error + "
提单号:" + bill.MBLNO + " 分单发货人不能为空"; + } + else + { + if (StringIsChinese(OpBill.SHIPPER)) + { + error = error + "
提单号:" + bill.MBLNO + " 分单发货人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", OpBill.SHIPPER, 35, bill.MBLNO, "分单发货人", 6, "-", false); + //} + //else + //{ + // error += formatlengthError("txt", OpBill.SHIPPER, 35, bill.MBLNO, "分单发货人", 6, "*", false); + //} + } + } + } + if (billams.BYCOUNTRY != "" && carrier != "OOLU") + { + if (billams.AMSCONSIGNEE == "") + { + error = error + "
提单号:" + bill.MBLNO + " AMS收货人不能为空"; + } + else + { + if (StringIsChinese(billams.AMSCONSIGNEE)) + { + error = error + "
提单号:" + bill.MBLNO + " AMS收货人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", billams.AMSCONSIGNEE, 35, bill.MBLNO, "AMS收货人", 6, "--", false); + //} + //else + //{ + // error += formatlengthError("txt", billams.AMSCONSIGNEE, 35, bill.MBLNO, "AMS收货人", 6, "**", false); + //} + } + } + } + else + { + + if (bill.CONSIGNEE == "") + { + error = error + "
提单号:" + bill.MBLNO + " 收货人不能为空"; + } + else + { + if (StringIsChinese(bill.CONSIGNEE)) + { + error = error + "
提单号:" + bill.MBLNO + " 收货人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", bill.CONSIGNEE, 35, bill.MBLNO, "收货人", 6, "--", false); + //} + //else + //{ + // error += formatlengthError("txt", bill.CONSIGNEE, 35, bill.MBLNO, "收货人", 6, "**", false); + //} + } + } + } + + if (isbill == 1) + { + if (OpBill.CONSIGNEE == "") + { + error = error + "
提单号:" + bill.MBLNO + " 分单收货人不能为空"; + } + else + { + if (StringIsChinese(OpBill.CONSIGNEE)) + { + error = error + "
提单号:" + bill.MBLNO + " 分单收货人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", OpBill.CONSIGNEE, 35, bill.MBLNO, "分单收货人", 6, "--", false); + //} + //else + //{ + // error += formatlengthError("txt", OpBill.CONSIGNEE, 35, bill.MBLNO, "分单收货人", 6, "**", false); + //} + } + } + } + + //if (filetype == "E") + //{ + // if (bill.AGENT == "") + // { + // error = error + "
提单号:" + bill.MBLNO + " 代理不能为空"; + // } + // else + // { + // if (StringIsChinese(bill.AGENT)) + // { + // error = error + "
提单号:" + bill.MBLNO + " 代理含有中文或双字节字符"; + // } + // else + // { + // if (carrier == "HLCU") + // { + // error += formatlengthError("txt", bill.AGENT, 35, bill.MBLNO, "代理", 5, "----"); + // } + // else + // { + // error += formatlengthError("txt", bill.AGENT, 35, bill.MBLNO, "代理", 5, "****"); + // } + // } + // } + //} + if (bill.SERVICE == "CY-DOOR") + { + if (billams.DOORADDR == "") + { + error = error + "
提单号:" + bill.MBLNO + " 运输条款为:CY-DOOR,EDI信息中的DOOR地址不能为空"; + } + else + { + if (StringIsChinese(billams.DOORADDR)) + { + error = error + "
提单号:" + bill.MBLNO + " DOOR地址含有中文或双字节字符"; + } + } + } + if (bill.SERVICE == "DOOR-CY") + { + if (billams.ATTNADDR == "") + { + error = error + "
提单号:" + bill.MBLNO + " 运输条款为:DOOR-CY,EDI信息中的联系人地址不能为空"; + } + else + { + if (StringIsChinese(billams.ATTNADDR)) + { + error = error + "
提单号:" + bill.MBLNO + " 联系人地址含有中文或双字节字符"; + } + } + } + + if (billams.BYCOUNTRY != "" && carrier != "OOLU") + { + if (billams.AMSNOTIFYPARTY == "") + { + error = error + "
提单号:" + bill.MBLNO + " AMS通知人不能为空"; + } + else + { + if (StringIsChinese(billams.AMSNOTIFYPARTY)) + { + error = error + "
提单号:" + bill.MBLNO + " AMS通知人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", billams.AMSNOTIFYPARTY, 35, bill.MBLNO, "AMS通知人", 6, "---", false); + //} + //else + //{ + // error += formatlengthError("txt", billams.AMSNOTIFYPARTY, 35, bill.MBLNO, "AMS通知人", 6, "***", false); + //} + } + } + } + else + { + if (bill.NOTIFYPARTY == "") + { + error = error + "
提单号:" + bill.MBLNO + " 通知人不能为空"; + } + else + { + if (StringIsChinese(bill.NOTIFYPARTY)) + { + error = error + "
提单号:" + bill.MBLNO + " 通知人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", bill.NOTIFYPARTY, 35, bill.MBLNO, "通知人", 6, "---", false); + //} + //else + //{ + // error += formatlengthError("txt", bill.NOTIFYPARTY, 35, bill.MBLNO, "通知人", 6, "***", false); + //} + } + } + } + + if (isbill == 1) + { + if (OpBill.NOTIFYPARTY == "") + { + error = error + "
提单号:" + bill.MBLNO + " 分单通知人不能为空"; + } + else + { + if (StringIsChinese(OpBill.NOTIFYPARTY)) + { + error = error + "
提单号:" + bill.MBLNO + " 分单通知人含有中文或双字节字符"; + } + else + { + //if (carrier == "HLCU") + //{ + // error += formatlengthError("txt", OpBill.NOTIFYPARTY, 35, bill.MBLNO, "分单通知人", 6, "---", false); + //} + //else + //{ + // error += formatlengthError("txt", OpBill.NOTIFYPARTY, 35, bill.MBLNO, "分单通知人", 6, "***", false); + //} + } + } + } + + if (isbill == 1) + { + if (OpBill.MARKS == "") + { + error = error + "
提单号:" + OpBill.MBLNO + "分票唛头不能为空"; + } + else + { + if (StringIsChinese(OpBill.MARKS)) + { + error = error + "
提单号:" + OpBill.MBLNO + "分票唛头含有中文或双字节字符"; + } + else + { + error += formatlengthError("txt", OpBill.MARKS, 35, bill.MBLNO, "分票唛头", 0, "", false); + } + } + } + else + { + if (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 (isbill == 1) + { + if (OpBill.DESCRIPTION == "") + { + error = error + "
提单号:" + bill.MBLNO + " 分票货物描述不能为空"; + } + else + { + if (StringIsChinese(OpBill.DESCRIPTION)) + { + error = error + "
提单号:" + bill.MBLNO + " 分票货物描述含有中文或双字节字符"; + } + else + { + //error += formatlengthError("txt", OpBill.DESCRIPTION, 35, bill.MBLNO, "分票货物描述", 0, ""); + } + } + } + else + { + if (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 (carrier == "YML") + { + if (GetPortEDICode(bill.PORTLOADID, "YML") == "" || GetPortEDICode(bill.PORTLOADID, "YML").Length != 5) + { error = error + "
提单号:" + bill.MBLNO + " 装货港代码不能为空或录入不正确(必须是5位代码)"; } + } + else + { + if (GetPortEDICode(bill.PORTLOADID, "PILMELL") == "" || GetPortEDICode(bill.PORTLOADID, "PILMELL").Length != 5) + { error = error + "
提单号:" + bill.MBLNO + " 装货港代码不能为空或录入不正确(必须是5位代码)"; } + } + if (bill.PORTLOAD == null || bill.PORTLOAD == "") + { error = error + "
提单号:" + bill.MBLNO + " 装货港不能为空"; } + + if (bill.ETD == null || bill.ETD == "") + { + error = error + "
提单号:" + bill.MBLNO + " 开船日期不能为空"; + return error; + } + if (carrier == "YML") + { + if (GetPortEDICode(bill.PORTDISCHARGEID, "YML") == "" || GetPortEDICode(bill.PORTDISCHARGEID, "YML").Length != 5) + { error = error + "
提单号:" + bill.MBLNO + " 卸货港代码不能为空或录入不正确(必须是5位代码)"; } + } + else + { + if (GetPortEDICode(bill.PORTDISCHARGEID, "PILMELL") == "" || GetPortEDICode(bill.PORTDISCHARGEID, "PILMELL").Length != 5) + { error = error + "
提单号:" + bill.MBLNO + " 卸货港代码不能为空或录入不正确(必须是5位代码)"; } + } + if (bill.PORTDISCHARGE == null || bill.PORTDISCHARGE == "") + { error = error + "
提单号:" + bill.MBLNO + " 卸货港不能为空"; } + + + if (GetPortEDICode(bill.DESTINATIONID, "PILMELL") == "" || GetPortEDICode(bill.DESTINATIONID, "PILMELL").Length != 5) + { error = error + "
提单号:" + bill.MBLNO + " 目的地代码不能为空或录入不正确(必须是5位代码)"; } + + string sdkj = GetPackageEDICode(bill.KINDPKGS, "PILMELL").Trim(); + if (isbill != 1) + { + if (carrier == "YML") + { + if (GetPackageEDICode(bill.KINDPKGS, "YML").Trim() == "") + { error = error + "
提单号:" + bill.MBLNO + " 包装EDI代码不能为空"; } + } + else + { + if (GetPackageEDICode(bill.KINDPKGS, "PILMELL").Trim() == "") + { error = error + "
提单号:" + bill.MBLNO + " 包装EDI代码不能为空"; } + } + } + else + { + if (carrier == "YML") + { + if (GetPackageEDICode(OpBill.KINDPKGS, "YML").Trim() == "") + { error = error + "
提单号:" + OpBill.MBLNO + "分票包装EDI代码不能为空"; } + } + else + { + if (GetPackageEDICode(OpBill.KINDPKGS, "PILMELL").Trim() == "") + { error = error + "
提单号:" + OpBill.MBLNO + "分票包装EDI代码不能为空"; } + } + } + + if (isbill != 1) + { + if (Convert.ToDecimal(bill.PKGS) == 0) + { error = error + "
提单号:" + bill.MBLNO + " 货物件数不能为空"; } + if (Convert.ToDecimal(bill.KGS) == 0) + { error = error + "
提单号:" + bill.MBLNO + " 货物重量不能为空"; } + if (Convert.ToDecimal(bill.CBM) == 0) + { error = error + "
提单号:" + bill.MBLNO + " 货物尺码不能为空"; } + } + else + { + if (OpBill.PKGS == 0) + { error = error + "
提单号:" + bill.MBLNO + " 分票货物件数不能为空"; } + if (OpBill.KGS == 0) + { error = error + "
提单号:" + bill.MBLNO + " 分票货物重量不能为空"; } + if (OpBill.CBM == 0) + { error = error + "
提单号:" + bill.MBLNO + " 分票货物尺码不能为空"; } + } + if (carrier != "MCCQ" && carrier != "MAEU" && carrier != "SUDU" && carrier != "CMDU") + { + if (bill.HSCODE == null || bill.HSCODE == "") + { error = error + "
提单号:" + bill.MBLNO + " HS编码不能为空"; } + } + + 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.CARGOID == "R") + { + if (bill.TEMPSET == null || bill.TEMPSET == "") + { error = error + "
提单号:" + bill.MBLNO + " 设置温度不能为空"; } + if (bill.REEFERF == null || bill.REEFERF == "") + { error = error + "
提单号:" + bill.MBLNO + " 通风度不能为空"; } + } + + if (bill.BLFRT.IndexOf("PREPAID") >= 0) + { + if (carrier == "YML") + { + if (bill.PREPARDATID == "") + { error = error + "
提单号:" + bill.MBLNO + " 预付地点或预付地点EDI代码不能为空"; } + } + else + { + if ((bill.PREPARDATID == "")) + { error = error + "
提单号:" + bill.MBLNO + " 预付地点或预付地点EDI代码不能为空"; } + } + } + + if (bill.BLFRT.IndexOf("COLLECT") >= 0) + { + if (carrier == "YML") + { + if (GetPortEDICodeByEname(bill.PAYABLEAT, "YML") == "") + { error = error + "
提单号:" + bill.MBLNO + " 到付地点或到付地点EDI代码不能为空"; } + } + else + { + if (bill.PAYABLEAT != "") + { + if (GetPortEDICodeByEname(bill.PAYABLEAT, "PILMELL") == "") + { error = error + "
提单号:" + bill.MBLNO + " 到付地点或到付地点EDI代码不能为空"; } + } + } + } + + if (filetype == "E") + { + if (carrier == "YML") + { + if (GetPortEDICode(bill.ISSUEPLACEID, "YML") == "") + { error = error + "
提单号:" + bill.MBLNO + " 签单地点或到签单地点EDI代码不能为空"; } + } + else + { + if (GetPortEDICode(bill.ISSUEPLACEID, "PILMELL") == "") + { error = error + "
提单号:" + bill.MBLNO + " 签单地点或到签单地点EDI代码不能为空"; } + } + } + + if ((bill.SERVICE == null || bill.SERVICE == "")) + { error = error + "
提单号:" + bill.MBLNO + " 运输条款不能为空"; } + + //if (carrier != "MCCQ" && carrier != "MAEU" && carrier != "SUDU") + //{ + + + //} + var bsno = ""; + if (isbill != 1) + { + bsno = bill.BSNO; + } + else + { + bsno = OpBill.AS_ID; + } + var ctnlist = MsOpSeaeDAL.MsOpSeaeDAL.GetBodyList("BSNO='" + bsno + "'"); + if (ctnlist.Count == 0) { error = error + "
提单号:" + bill.MBLNO + " 集装箱信息不能为空"; }; + + if (filetype == "E") + { + #region 集装箱判断检查 + string sCtnCntrno = ""; + int iCTN = 0; + int iCTNDetail = 0; + if (ctnlist.Count != 0) + { + Decimal dlPKGS = 0; + Decimal dlKGS = 0; + Decimal dlCBM = 0; + foreach (var ctn in ctnlist) + { + if (carrier == "YML") + { + if (GetCtnEDICode(ctn.CTNALL, "YML") == "") + { error = error + "
提单号:" + bill.MBLNO + " 集装箱箱型EDI代码不能为空"; } + } + else + { + if (GetCtnEDICode(ctn.CTNALL, "PILMELL") == "") + { error = error + "
提单号:" + bill.MBLNO + " 集装箱箱型EDI代码不能为空"; } + } + //if ((ctn.CTNALL.IndexOf("RH") > 0 || ctn.CTNALL.IndexOf("RF") > 0) && (bill.CARGOID != "R")) + //{ + // { error = error + "
提单号:" + bill.MBLNO + " 集装箱箱型为冻柜,货类代码请选择冻柜"; } + //} + if (ctn.CNTRNO == null || ctn.CNTRNO == "") + { error = error + "
提单号:" + bill.MBLNO + " 箱号不能为空"; } + if (ctn.SEALNO == null || ctn.SEALNO == "") + { error = error + "
提单号:" + bill.MBLNO + " 封号不能为空"; } + if (billams.BYCOUNTRY == "BRAZIL") + { + if (ctn.TAREWEIGHT == 0) + { error = error + "
提单号:" + bill.MBLNO + " 箱皮重不能为空"; } + } + if (ctn.KINDPKGS != bill.KINDPKGS) + { error = error + "
提单号:" + bill.MBLNO + " 中的包装类型与集装箱的包装类型不同"; } + //是否有分箱 + var OpCtnDetailList = MsOpSeaeDAL.MsOpSeaeDAL.GetOpCtnDetailList("[CTN_ID]='" + ctn.CTN_ID.ToString() + "'"); + if (OpCtnDetailList.Count > 0) + { + iCTNDetail++; + } + else + { + sCtnCntrno += "、" + ctn.CNTRNO; + } + iCTN++; + // + dlPKGS += ctn.PKGS; + dlKGS += ctn.KGS; + dlCBM += ctn.CBM; + } + + if (dlPKGS != Convert.ToInt32(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 + " 集装箱尺码合计数必须等于委托单总尺码数"; } + } + //有分箱 + if (iCTNDetail > 0) + { + if (iCTNDetail != iCTN) + { + error = error + "
提单号:" + bill.MBLNO + "的“" + sCtnCntrno.Substring(1) + "”等箱号未添加分箱明细!"; + } + var OpCtnDetailList = MsOpSeaeDAL.MsOpSeaeDAL.GetOpCtnDetailList("[CTN_ID] in (select [CTN_ID] from op_ctn where BSNO='" + bsno + "')"); + foreach (var ctnDetail in OpCtnDetailList) + { + if (ctnDetail.KINDPKGS == null || ctnDetail.KINDPKGS == "") + { + if (error.IndexOf(ctnDetail.CNTRNO + "”箱号的分箱包装不能为空!") < 0) + { + error = error + "
提单号:" + bill.MBLNO + "的“" + ctnDetail.CNTRNO + "”箱号的分箱包装不能为空!"; + } + } + else + { + if (GetPackageEDICode(ctnDetail.KINDPKGS, "PILMELL").Trim() == "") { error = error + "
提单号:" + bill.MBLNO + "的“" + ctnDetail.CNTRNO + "”箱号分箱包装EDI代码不能为空"; } + if (ctnDetail.KINDPKGS != bill.KINDPKGS) + { error = error + "
提单号:" + bill.MBLNO + " 中的包装类型与集装箱的分箱包装类型不同"; } + } + if (ctnDetail.DESCRIPTION == null || ctnDetail.DESCRIPTION == "") + { + error += "
提单号:" + bill.MBLNO + "的“" + ctnDetail.CNTRNO + "”箱号的分箱货描不能为空!"; + } + else + { + error += formatlengthError("txt", ctnDetail.DESCRIPTION, 70, bill.MBLNO, "的“" + ctnDetail.CNTRNO + "”箱号的分箱货物描述", 0, "", false); + } + } + // + string slSQL = "SELECT * from (SELECT c.CTN_ID,c.CNTRNO,c.PKGS,c.KGS,c.CBM,isnull(sum(d.PKGS),0) as PKGS_d,isnull(sum(d.KGS),0) as KGS_d,isnull(sum(d.CBM),0) as CBM_d from op_ctn as c INNER JOIN op_ctn_detail as d on c.CTN_ID=d.CTN_ID where c.BSNO='" + bsno + "' GROUP BY c.CTN_ID,c.CNTRNO,c.PKGS,c.KGS,c.CBM) as a where PKGS<>PKGS_d or KGS<>KGS_d or CBM<>CBM_d "; + DataSet dsOpCtnDetail = T_ALL_DA.GetAllSQL(slSQL); + if (dsOpCtnDetail != null) + { + if (dsOpCtnDetail.Tables[0].Rows.Count > 0) + { + for (int i = 0; i < dsOpCtnDetail.Tables[0].Rows.Count; i++) + { + error = error + "
提单号:" + bill.MBLNO + "的“" + dsOpCtnDetail.Tables[0].Rows[i]["CNTRNO"].ToString() + "”箱号的件(" + dsOpCtnDetail.Tables[0].Rows[i]["PKGS"].ToString() + ")、重(" + dsOpCtnDetail.Tables[0].Rows[i]["KGS"].ToString() + ")、尺(" + dsOpCtnDetail.Tables[0].Rows[i]["CBM"].ToString() + ")不等于其分箱件(" + dsOpCtnDetail.Tables[0].Rows[i]["PKGS_d"].ToString() + ")、重(" + dsOpCtnDetail.Tables[0].Rows[i]["KGS_d"].ToString() + ")、尺(" + dsOpCtnDetail.Tables[0].Rows[i]["CBM_d"].ToString() + ")的合计数!"; + } + } + } + } + #endregion + + if (bill.BYCOUNTRY == "USA") + { + if (bill.CONSIGNEEPOSTCODE == null || bill.CONSIGNEEPOSTCODE == "") + { error = error + "
提单号:" + bill.MBLNO + " 收货人邮编不能为空"; } + if (bill.NOTIFYPARTYPOSTCODE == null || bill.NOTIFYPARTYPOSTCODE == "") + { error = error + "
提单号:" + bill.MBLNO + " 通知人邮编不能为空"; } + } + else if (bill.BYCOUNTRY == "CANADA") + { + if (bill.CONSIGNEEPOSTCODE == null || bill.CONSIGNEEPOSTCODE == "") + { error = error + "
提单号:" + bill.MBLNO + " 收货人邮编不能为空"; } + } + else if (bill.BYCOUNTRY == "BRAZIL") + { + if (bill.CONSIGNEECOUNTRY == null || bill.CONSIGNEECOUNTRY == "") + { error = error + "
提单号:" + bill.MBLNO + " 收货人国家代码不能为空"; } + if (bill.CONSIGNEETAXNO == null || bill.CONSIGNEETAXNO == "") + { error = error + "
提单号:" + bill.MBLNO + " 收货人税号不能为空"; } + if (bill.NOTIFYPARTYCOUNTRY == null || bill.NOTIFYPARTYCOUNTRY == "") + { error = error + "
提单号:" + bill.MBLNO + " 通知人国家代码不能为空"; } + if (bill.NOTIFYPARTYTAXNO == null || bill.NOTIFYPARTYTAXNO == "") + { error = error + "
提单号:" + bill.MBLNO + " 通知人税号不能为空"; } + if (bill.GOODSNCM == null || bill.GOODSNCM == "") + { error = error + "
提单号:" + bill.MBLNO + " 货物NCM编码不能为空"; } + } + } + else + { + } + + if (carrier == "YML") + { + if (string.IsNullOrEmpty(billams.SHIPPERCOUNTRY)) error = error + "
提单号:" + bill.MBLNO + " 发货人国家代码不能为空"; + if (string.IsNullOrEmpty(billams.CONSIGNEECOUNTRY)) error = error + "
提单号:" + bill.MBLNO + " 收货人国家代码不能为空"; + + + } + } + return error; + } + + + public static string CreateEdiPILMELL(EDIBaseModel InttrEdi) + { + + string filename = path + "\\" + 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); + + T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); + var icount = 0; + var bsno = ""; + var OpBill = new MsOpSeaeBill(); + r.WriteLine("UNB+UNOB:1+" + ftpset.SENDCODE + "SO:ZZZ+" + ftpset.RECEIVECODE + ":ZZZ+" + DateTime.Now.ToString("yyMMdd:HHmm") + "+" + headData[0].CUSTNO + "'"); + icount = icount + 1; + foreach (var bill in headData) + { + DataSet dsUserOp = T_ALL_DA.GetAllSQL("select top 1 * from [user] as u INNER JOIN user_baseinfo as b on u.GID=b.USERID where [SHOWNAME]='" + bill.OP.ToString() + "'"); + // + bsno = bill.CUSTNO; + if (isbill == 1) + OpBill = MsOpSeaeDAL.MsOpSeaeDAL.GetBillData("BSNO='" + bill.BSNO + "'"); + r.WriteLine("UNH+" + bill.CUSTNO + "+IFTMBF:D:99B:UN'"); + icount = icount + 1; + if (isbill != 1) + { + + if (filerole == "9") + r.WriteLine("BGM+335+" + bill.MBLNO + "+9'"); + else + r.WriteLine("BGM+335+" + bill.MBLNO + "+5'"); + + + } + else + { + if (filerole == "9") + r.WriteLine("BGM+335+" + OpBill.MBLNO + "+9'"); + else + r.WriteLine("BGM+335+" + OpBill.MBLNO + "+5'"); + + } + r.WriteLine("DTM+137:" + DateTime.Now.ToString("yyyyMMddHHmm") + ":203'"); + icount = icount + 2; + + if (bill.SERVICE.ToUpper() == "DOOR-DOOR") + { + r.WriteLine("TSR+16+2'"); + } + else if (bill.SERVICE.ToUpper() == "DOOR-CY") + { + r.WriteLine("TSR+15+2'"); + } + else if (bill.SERVICE.ToUpper() == "CY-DOOR") + { + r.WriteLine("TSR+17+2'"); + } + else if (bill.SERVICE.ToUpper() == "CFS-CFS") + { + r.WriteLine("TSR+14+2'"); + } + else + { + r.WriteLine("TSR+11+2'"); + } + + var str_pay = ""; + if (bill.BLFRT.IndexOf("PREPAID") >= 0) + str_pay = bill.PREPARDAT; + if (bill.BLFRT.IndexOf("COLLECT") >= 0) + str_pay = bill.PAYABLEAT; + + //if (isbill != 1) + //{ + + + // r.WriteLine("FTX+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + bill.SERVICE + " " + // + bill.PKGS + bill.KINDPKGS + " " + formatEdiStr("txt", bill.EDIREMARK.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ")) + "'"); + //} + //else + //{ + // r.WriteLine("FTX+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + OpBill.SERVICE + " " + // + OpBill.PKGS + OpBill.KINDPKGS + " " + formatEdiStr("txt", bill.EDIREMARK.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ")) + "'"); + //} + //icount = icount + 2; + + //if (isbill != 1) + // r.WriteLine("CNT+7:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + ":KGM'");//按照四舍五入的国际标准 + //else + // r.WriteLine("CNT+7:" + Math.Round(OpBill.KGS, 3) + ":KGM'"); + + //if (isbill != 1) + // r.WriteLine("CNT+11:" + bill.PKGS + "'"); + //else + // r.WriteLine("CNT+11:" + OpBill.PKGS + "'"); + //if (isbill != 1) + // r.WriteLine("CNT+15:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + ":MTQ'"); + //else + // r.WriteLine("CNT+15:" + Math.Round(OpBill.CBM, 3) + ":MTQ'"); + //icount = icount + 3; + + //if (bill.BLFRT == "FREIGHT COLLECT") + //{ + // if (bill.PAYABLEAT != "") + // { + // r.WriteLine("LOC+57+" + GetPortEDICodeByEname(bill.PAYABLEAT, "INTTR") + "::6:" + bill.PAYABLEAT + "'"); + // icount = icount + 1; + // } + //} + //else + //{ + // r.WriteLine("LOC+57+" + GetPortEDICodeByEname(bill.PREPARDAT, "INTTR") + "::6:" + bill.PREPARDAT + "'"); + // icount = icount + 1; + + //} + + r.WriteLine("LOC+88+" + GetPortEDICode(bill.PORTLOADID, "PILMELL") + ":139:6:" + bill.PORTLOAD + "'"); + icount = icount + 1; + if (bill.DESTINATION != "") + { + r.WriteLine("LOC+7+" + GetPortEDICode(bill.DESTINATIONID, "PILMELL") + ":139:6:" + bill.DESTINATION + "'"); + icount = icount + 1; + } + r.WriteLine("DTM+95:" + GetDateStr(bill.ISSUEDATE, "yyyyMMdd") + ":102'"); + icount = icount + 1; + + if (isbill != 1) + { + r.WriteLine("RFF+BN:" + bill.MBLNO + "'"); + } + else + { + r.WriteLine("RFF+BN:" + OpBill.MBLNO + "'"); + } + if (isbill != 1) + { + r.WriteLine("RFF+BM:" + bill.MBLNO + "'"); + } + else + { + r.WriteLine("RFF+BM:" + OpBill.MBLNO + "'"); + } + + icount = icount + 2; + + if (!string.IsNullOrEmpty(bill.CONTRACTNO)) + { + r.WriteLine("RFF+CT:" + formatEdiStr("txt", bill.CONTRACTNO) + "'"); + 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++MELL:172+++:::" + bill.VESSEL + "'"); + r.WriteLine("LOC+9+" + GetPortEDICode(bill.PORTLOADID, "PILMELL") + ":139:6:" + bill.PORTLOAD + "'"); + r.WriteLine("DTM+133:" + GetDateStr(bill.ETD, "yyyyMMdd") + ":102'");//yyyyMMddHHmm + r.WriteLine("LOC+11+" + GetPortEDICode(bill.PORTDISCHARGEID, "PILMELL") + ":139:6:" + bill.PORTDISCHARGE + "'"); + icount = icount + 4; + + + var billams = GetAmsData("BSNO='" + bill.BSNO + "'"); + var Shipping = ""; + var DescriptionShipper = ""; + if (isbill != 1) + { + if (billams.BYCOUNTRY != "") + Shipping = formatEdiStr("txt", billams.AMSSHIPPER); + else + Shipping = formatEdiStr("txt", bill.SHIPPER); + + } + else Shipping = formatEdiStr("txt", OpBill.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+" + ftpset.SENDSUBCOMPANYCODE + "+" + ShippingList[0] + ":"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; + if (i >= 4 && ShippingList.Count > 5) + { + if (i == 4) + { + if (ShippingList[i].Length > 34) + { + Shipping = Shipping + ":" + ShippingList[i].Substring(0, 34); + DescriptionShipper = ShippingList[i].Substring(34); + } + else + Shipping = Shipping + ":" + ShippingList[i]; + + Shipping = Shipping + "*"; + DescriptionShipper = "*" + DescriptionShipper; + + } + else if (i > 4) + { + + DescriptionShipper = DescriptionShipper + " " + ShippingList[i]; + } + + } + else + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + } + + r.WriteLine(Shipping + "'"); + icount = icount + 1; + + if (isbill != 1) + { + if (billams.BYCOUNTRY != "") + Shipping = formatEdiStr("txt", billams.AMSCONSIGNEE); + else + Shipping = formatEdiStr("txt", bill.CONSIGNEE); + + } + else Shipping = formatEdiStr("txt", OpBill.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+" + ftpset.SENDSUBCOMPANYCODE + "+" + 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]; + + 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; + + if (isbill != 1) + { + if (billams.BYCOUNTRY != "") + Shipping = formatEdiStr("txt", billams.AMSNOTIFYPARTY); + else + Shipping = formatEdiStr("txt", bill.NOTIFYPARTY); + + } + else Shipping = formatEdiStr("txt", OpBill.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+" + ftpset.SENDSUBCOMPANYCODE + "+" + 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]; + + Shipping = Shipping + "***"; + DescriptionNotifyparty = "***" + DescriptionNotifyparty; + + } + else if (i > 4) + { + + DescriptionNotifyparty = DescriptionNotifyparty + " " + ShippingList[i]; + } + + } + else + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + } + + if (billams.BYCOUNTRY == "USA") + { + Shipping = Shipping + "+++" + billams.NOTIFYPARTYPOSTCODE; + r.WriteLine(Shipping + "'"); + } + else if (billams.BYCOUNTRY == "BRAZIL") + { + if (billams.NOTIFYPARTYCOUNTRY != "") + Shipping = Shipping + "++++" + billams.NOTIFYPARTYCOUNTRY; + r.WriteLine(Shipping + "'"); + if (billams.NOTIFYPARTYTAXNO != "") + { + r.WriteLine("RFF+GN:" + billams.NOTIFYPARTYTAXNO + "'"); + icount = icount + 1; + + } + } + else r.WriteLine(Shipping + "'"); + icount = icount + 1; + r.WriteLine("NAD+BP+" + ftpset.ALIASSENDCODE + "+" + ftpset.SENDNAME + ":160:86+'"); + icount = icount + 1; + r.WriteLine("NAD+AP+" + ftpset.SENDSUBCOMPANYCODE + "+" + ftpset.SENDNAME + ":160:86+'"); + 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 (isbill != 1) + { + r.WriteLine("GID+1+" + bill.PKGS.ToString() + ":" + GetPackageEDICode(bill.KINDPKGS, "PILMELL").Trim() + "::6:" + bill.KINDPKGS + "'"); + } + else + { + r.WriteLine("GID+1+" + OpBill.PKGS.ToString() + ":" + GetPackageEDICode(OpBill.KINDPKGS, "PILMELL").Trim() + "::6:" + OpBill.KINDPKGS + "'"); + } + icount = icount + 8; + + if (bill.HSCODE != "") + { + r.WriteLine("PIA+5+" + bill.HSCODE + ":HS'"); + icount = icount + 1; + + } + + if (isbill != 1) + { + Shipping = formatEdiStr("txt", bill.DESCRIPTION); + } + else Shipping = formatEdiStr("txt", OpBill.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 (i <= 1) + { + 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; + + //} + + if (isbill != 1) + { + r.WriteLine("MEA+AAE+G+KGM:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + "'"); + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + "'"); + } + else + { + r.WriteLine("MEA+AAE+G+KGM:" + Math.Round(OpBill.KGS, 3) + "'"); + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(OpBill.CBM, 3) + "'"); + + } + icount = icount + 2; + + //if (isbill != 1) + //{ + // Shipping = formatEdiStr("txt", bill.MARKS); + //} + //else Shipping = formatEdiStr("txt", OpBill.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+:" + billams.ATTN + "'"); + r.WriteLine("COM+" + billams.ATTNTEL + ":TE'"); + icount = icount + 3; + } + + if (isbill != 1) + { + Shipping = bill.BSNO; + } + else Shipping = OpBill.AS_ID; + var ctnsumlist = GetCtnSum("BSNO='" + Shipping + "'"); + foreach (var ctn in ctnsumlist) + { + if (ctn.CNTRSOURCE == "SOC") + r.WriteLine("EQD+CN++" + GetCtnEDICode(ctn.CTNALL, "PILMELL") + "+1'"); + else + r.WriteLine("EQD+CN++" + GetCtnEDICode(ctn.CTNALL, "PILMELL") + "+2'"); + r.WriteLine("EQN+" + ctn.CTNNUM.ToString() + "'"); + icount = icount + 2; + + if (bill.CARGOID == "R") + { + if (bill.REEFERF != "" && bill.REEFERF != "0") + 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.Replace("+", "") + ":CEL'"); + icount = icount + 2; + + + } + + } + + } + r.WriteLine("UNT+" + icount.ToString() + "+" + bsno + "'"); + r.WriteLine("UNZ+" + headData.Count.ToString() + "+" + bsno + "'"); + r.Close(); + f.Close(); + + return filename; + } + */ + + } +} From 3451819765764806b5ccb3a62378b02656a60381 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 7 Mar 2023 10:20:00 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E8=88=B1EDI=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=82=AE=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 115 +++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 81e92e24..6a930fb7 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -68,6 +68,8 @@ using NPOI.SS.Formula; using NPOI.Util; using System.Collections.Specialized; using System.Net.Http.Headers; +using MySqlX.XDevAPI.Common; +using Ubiety.Dns.Core; namespace Myshipping.Application { @@ -3208,9 +3210,14 @@ namespace Myshipping.Application var ediModel = new EDIBaseModel(); + //2023-03-06 修改读取EDI配置方法,所有提取配置必须是已启用的EnableFlag=true,并且要根据SendType匹配发送类型,SendType=""表示使用订舱和截单,SO-订舱 SI-截单 var ftpSet = _cache.GetAllEdiSetting().GetAwaiter().GetResult() .FirstOrDefault(a => a.EDICODE.Equals(ediRouteEnum.ToString(), StringComparison.OrdinalIgnoreCase) - && a.TenantId == order.TenantId && !string.IsNullOrWhiteSpace(a.CARRIERID) && a.CARRIERID.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + && a.TenantId == order.TenantId && !string.IsNullOrWhiteSpace(a.CARRIERID) + && a.CARRIERID.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase) + && a.EnableFlag + && (string.IsNullOrWhiteSpace(a.SendType) || + (!string.IsNullOrWhiteSpace(a.SendType) && ((model.sendType == "B" && a.SendType == "SO") ||(model.sendType == "E" && a.SendType == "SI"))))); if (ftpSet == null) throw Oops.Bah($"获取EDICODE={ediRouteEnum.ToString()}的EDI参数设置失败"); @@ -3500,7 +3507,22 @@ namespace Myshipping.Application DateTime bDate = DateTime.Now; //上传FTP - var sendStatus = await InnerSendBookingOrClosingEDIToFTP(result.extra.ToString(), ftpSet); + CommonWebApiResult sendStatus = null; + + //是订舱并且FTP配置了订舱接收邮箱则触发邮箱发送 + if(!string.IsNullOrWhiteSpace(ftpSet.RECEIVEEMAIL) && model.sendType == "B") + { + + } + else if (!string.IsNullOrWhiteSpace(ftpSet.RECEIVESIEMAIL) && model.sendType == "E") + { + //是截单并且FTP配置了截单接收邮箱则触发邮箱发送 + } + else + { + sendStatus = await InnerSendBookingOrClosingEDIToFTP(result.extra.ToString(), ftpSet); + } + DateTime eDate = DateTime.Now; TimeSpan ts = eDate.Subtract(bDate); @@ -3659,6 +3681,95 @@ namespace Myshipping.Application } #endregion + #region 上传邮件 + /// + /// 上传邮件 + /// + /// 订舱详情 + /// 文件路径 + /// 请求类型 + /// EDI配置 + /// 返回回执 + private async Task InnerSendBookingOrClosingEDIToEmail(BookingOrder bookingOrder,string filePath, + string sendType, DjyEdiSetting ediCfg) + { + CommonWebApiResult result = new CommonWebApiResult { succ = true }; + + var emailUrl = _cache.GetAllDictData().GetAwaiter().GetResult() + .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "email_api_url").Value; + + EmailApiDto emailApiDto = new EmailApiDto + { + SendTo = sendType == "B" ? ediCfg.RECEIVEEMAIL : ediCfg.RECEIVESIEMAIL, + Title = sendType == "B" ? (bookingOrder.VOYNO + " " + bookingOrder.MBLNO + " IBOOKING") : (bookingOrder.MBLNO + " " + "ESI"), + Attaches = new List(), + }; + + System.IO.FileStream file = new System.IO.FileStream(filePath, FileMode.Open, FileAccess.Read); + int SplitSize = 5242880;//5M分片长度 + int index = 1; //序号 第几片 + long StartPosition = 5242880 * (index - 1); + long lastLens = file.Length - StartPosition;//真不知道怎么起命了,就这样吧 + if (lastLens < 5242880) + { + SplitSize = (int)lastLens; + } + byte[] heByte = new byte[SplitSize]; + file.Seek(StartPosition, SeekOrigin.Begin); + //第一个参数是 起始位置 + file.Read(heByte, 0, SplitSize); + //第三个参数是 读取长度(剩余长度) + file.Close(); + + string base64Str = Convert.ToBase64String(heByte); + + emailApiDto.Attaches.Add(new AttachesInfo { + AttachName = Path.GetFileName(filePath), + AttachContent = base64Str + }); + + string strJoin = System.IO.File.ReadAllText(filePath); + + DateTime bDate = DateTime.Now; + + HttpResponseMessage res = null; + + try + { + res = await emailUrl.SetBody(emailApiDto, "application/json").PostAsync(); + } + catch(Exception ex) + { + _logger.LogInformation($"发送邮件异常:{ex.Message}"); + } + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation($"邮件上传完成 上传文件大小:{heByte.Length} 用时:{timeDiff}ms.,{strJoin}"); + + _logger.LogInformation($"发送邮件返回:{JSON.Serialize(res)}"); + + if (res != null && res.StatusCode == System.Net.HttpStatusCode.OK) + { + var userResult = await res.Content.ReadAsStringAsync(); + + var respObj = JsonConvert.DeserializeAnonymousType(userResult, new + { + Success = false, + Message = string.Empty, + Code = -9999, + }); + + result.succ = respObj.Success; + result.msg = respObj.Message; + } + + return result; + } + #endregion + #region /// /// 转发EDI内部方法 From 9433d26e4de76083f04f4a41d4966452c091b5f7 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 7 Mar 2023 10:20:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9EDI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingOrder/Dto/EmailApiDto.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/EmailApiDto.cs diff --git a/Myshipping.Application/Service/BookingOrder/Dto/EmailApiDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/EmailApiDto.cs new file mode 100644 index 00000000..84c60e78 --- /dev/null +++ b/Myshipping.Application/Service/BookingOrder/Dto/EmailApiDto.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class EmailApiDto + { + public string SendTo { get; set; } + + //public string CCTo { get; set; } + + public string Title { get; set; } + + public string Body { get; set; } + + //public string ShowName { get; set; } + + public string SmtpConfig { get; set; } = "SERVICE"; + + //public string Account { get; set; } + + //public string Password { get; set; } + + //public string Server { get; set; } + + //public string Port { get; set; } + + //public string UseSSL { get; set; } + + public bool isCallback { get; set; } = false; + + public List Attaches { get; set; } + } + + public class AttachesInfo + { + public string AttachName { get; set; } + + public string AttachContent { get; set; } + } +}