diff --git a/Myshipping.Application/EDI/Dtos/MsOpSeaeEDIBaseModel.cs b/Myshipping.Application/EDI/Dtos/MsOpSeaeEDIBaseModel.cs
index 128254c1..9f014938 100644
--- a/Myshipping.Application/EDI/Dtos/MsOpSeaeEDIBaseModel.cs
+++ b/Myshipping.Application/EDI/Dtos/MsOpSeaeEDIBaseModel.cs
@@ -595,5 +595,10 @@ namespace Myshipping.Application
/// CNPTNo
///
public string CNPTNo { get; set; }
+
+ ///
+ /// CUSTNAME
+ ///
+ public string CUSTNAME { get; set; }
}
}
diff --git a/Myshipping.Application/EDI/SITCEdiHelper.cs b/Myshipping.Application/EDI/SITCEdiHelper.cs
new file mode 100644
index 00000000..59de1993
--- /dev/null
+++ b/Myshipping.Application/EDI/SITCEdiHelper.cs
@@ -0,0 +1,584 @@
+using DocumentFormat.OpenXml.ExtendedProperties;
+using Google.Protobuf.WellKnownTypes;
+using Myshipping.Application.EDI.ESL;
+using MySqlX.XDevAPI.Common;
+using Newtonsoft.Json;
+using NPOI.Util;
+using StackExchange.Profiling.Internal;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application.EDI.SITC
+{
+ public class SITCEdiHelper
+ {
+
+ public SITCEdiHelper()
+ {
+ }
+
+ #region 基本函数
+
+ #endregion
+
+ #region 检查
+ public static string IsCreateSITCEDI(EDIBaseModel InttrEdi)
+ {
+ var error = "";
+
+ if (InttrEdi.filerole == "E")
+ {
+ error = error + "
SITC接口只支持订舱,不能截单";
+ }
+
+ foreach (var bill in InttrEdi.BSLIST)
+ {
+
+ }
+ return error;
+ }
+ #endregion
+
+ #region 生成报文(订舱(filetype=="B"),截单(filetype=="E"))
+ public static CommonWebApiResult CreateEdiSITC(EDIBaseModel InttrEdi)
+ {
+ CommonWebApiResult result = new CommonWebApiResult { succ = false };
+
+ string dir = InttrEdi.filerpath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "\\";
+
+ //如果是部署linux需要修改路径
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ dir = dir.Replace("\\", "/");
+
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+
+ string filename = dir + InttrEdi.BSLIST[0].ORDERNO + ".json";
+
+ FileStream f = new FileStream(filename, FileMode.Create);
+ StreamWriter r = new StreamWriter(f, Encoding.Default);
+
+ SitcApiPostModel postModel = new SitcApiPostModel();
+ postModel.consignorCustName = InttrEdi.BSLIST[0].CUSTNAME;
+ postModel.polId = InttrEdi.BSLIST[0].PORTLOADID;
+ postModel.polName = InttrEdi.BSLIST[0].PORTLOAD;
+ postModel.podId = InttrEdi.BSLIST[0].PORTDISCHARGEID;
+ postModel.podName = InttrEdi.BSLIST[0].PORTDISCHARGE;
+ postModel.deliveryId = InttrEdi.BSLIST[0].PLACEDELIVERYID;
+ postModel.deliveryName = InttrEdi.BSLIST[0].PLACEDELIVERY;
+ postModel.porId = InttrEdi.BSLIST[0].PLACERECEIPTID;
+ postModel.porName = InttrEdi.BSLIST[0].PLACERECEIPT;
+ postModel.vesselName = InttrEdi.BSLIST[0].VESSEL;
+ postModel.line = InttrEdi.BSLIST[0].ESLLINECODE;
+ postModel.voyNo = InttrEdi.BSLIST[0].VOYNO;
+ postModel.etd = InttrEdi.BSLIST[0].ETD;
+ postModel.eta = InttrEdi.BSLIST[0].ETA;
+ postModel.consigneeName = InttrEdi.BSLIST[0].CONSIGNEE;
+ //postModel.consigneeAddr = InttrEdi.BSLIST[0].CONSIGNEEADDR;
+ //postModel.consigneeFax = InttrEdi.BSLIST[0].CONSIGNEEFAX;
+ //postModel.consigneeTel = InttrEdi.BSLIST[0].CONSIGNEETEL;
+ //postModel.consigneeBsCode = InttrEdi.BSLIST[0].CONSIGNEEBSCODE;
+ //postModel.consigneeEmail = InttrEdi.BSLIST[0].CONSIGNEEEMAIL;
+ postModel.consignorName = InttrEdi.BSLIST[0].SHIPPER;
+ //postModel.consignorAddr = InttrEdi.BSLIST[0].CONSIGNORADDR;
+ //postModel.consignorFax = InttrEdi.BSLIST[0].CONSIGNORFAX;
+ //postModel.consignorTel = InttrEdi.BSLIST[0].CONSIGNORTEL;
+ //postModel.consignorBsCode = InttrEdi.BSLIST[0].CONSIGNORBSCODE;
+ //postModel.consignorEmail = InttrEdi.BSLIST[0].CONSIGNOREMAIL;
+ postModel.notifyName = InttrEdi.BSLIST[0].NOTIFYPARTY;
+ //postModel.notifyAddr = InttrEdi.BSLIST[0].NOTIFYADDR;
+ //postModel.notifyFax = InttrEdi.BSLIST[0].NOTIFYFAX;
+ //postModel.notifyTel = InttrEdi.BSLIST[0].NOTIFYTEL;
+ //postModel.notifyBsCode = InttrEdi.BSLIST[0].NOTIFYBSCODE;
+ //postModel.notifyEmail = InttrEdi.BSLIST[0].NOTIFYEMAIL;
+ postModel.movementType = InttrEdi.BSLIST[0].SERVICE;
+ postModel.weight = InttrEdi.BSLIST[0].KGS;
+ postModel.cube = InttrEdi.BSLIST[0].CBM;
+ postModel.packages = InttrEdi.BSLIST[0].PKGS;
+ postModel.packageDesc = InttrEdi.BSLIST[0].KINDPKGS;
+ postModel.marks = InttrEdi.BSLIST[0].MARKS;
+ postModel.cargoDesc = InttrEdi.BSLIST[0].DESCRIPTION;
+ postModel.cargoType = InttrEdi.BSLIST[0].CARGOID;
+ postModel.isDanger = InttrEdi.BSLIST[0].CARGOID == "D" ? true : false;
+ postModel.isRf = InttrEdi.BSLIST[0].CARGOID == "R" ? true : false;
+ postModel.contactInfo = InttrEdi.BSLIST[0].OpEmail;
+ postModel.remark = InttrEdi.BSLIST[0].EDIREMARK;
+ postModel.payTerm = InttrEdi.BSLIST[0].BLFRT;
+
+
+
+ postModel.containers = new List();
+ foreach (var container in InttrEdi.BSLIST[0].CTNLIST)
+ {
+ SitcApiPostModelContainer c = new SitcApiPostModelContainer();
+ c.ctnSize = container.CTNALLCODE.Substring(0, 2);
+ c.ctnType = container.CTNALLCODE.Substring(2, 2);
+ c.ctnNum = container.CTNNUM;
+ postModel.containers.Add(c);
+ }
+
+ if (InttrEdi.BSLIST[0].CARGOID == "R")
+ {
+ postModel.extras = new List();
+ SitcApiPostModelExtra e = new SitcApiPostModelExtra();
+ e.tempMin = InttrEdi.BSLIST[0].TEMPMIN;
+ e.tempMax = InttrEdi.BSLIST[0].TEMPMAX;
+ e.tempSetting = InttrEdi.BSLIST[0].TEMPSET;
+ e.unit = "C";
+ e.humdity = InttrEdi.BSLIST[0].HUMIDITY;
+ e.vent = InttrEdi.BSLIST[0].REEFERF;
+ postModel.extras.Add(e);
+ }
+
+ if (InttrEdi.BSLIST[0].CARGOID == "D")
+ {
+ postModel.dangerInfo = new List();
+ SitcApiPostModelDangerInfo d = new SitcApiPostModelDangerInfo();
+ d.classNo = InttrEdi.BSLIST[0].DCLASS;
+ //d.commodityChem = danger.COMMODITYCHEM;
+ //d.commodityTran = danger.COMMODITYTRAN;
+ //d.emergencyContact = danger.EMERGENCYCONTACT;
+ //d.emsNo = danger.EMSNO;
+ //d.flashPoint = danger.FLASHPOINT;
+ //d.flashUnit = danger.FLASHUNIT;
+ //d.grossWeight = danger.GROSSWEIGHT;
+ //d.isMpt = danger.ISMPT;
+ //d.labels = danger.LABELS;
+ //d.netWeight = danger.NETWEIGHT;
+ //d.nums = danger.NUMS;
+ //d.packageClass = danger.PACKAGECLASS;
+ //d.packageType = danger.PACKAGETYPE;
+ //d.packageName = danger.PACKAGENAME;
+ d.page = InttrEdi.BSLIST[0].DPAGE;
+ d.undgNo = InttrEdi.BSLIST[0].DUNNO;
+ //d.contactName = InttrEdi.BSLIST[0].;
+ //d.contactNum = InttrEdi.BSLIST[0].;
+ //d.packagingCode = danger.PACKAGINGCODE;
+ postModel.dangerInfo.Add(d);
+ }
+
+ string json = JsonConvert.SerializeObject(postModel);
+ r.Write(json);
+ r.Flush();
+ r.Close();
+ f.Close();
+
+ result.succ = true;
+ result.extra = filename;
+ result.extra2 = postModel;
+ return result;
+ }
+ #endregion
+
+ }
+
+ public class SitcApiPostModel
+ {
+ ///
+ /// 客户名称
+ ///
+ public string consignorCustName { get; set; }
+
+ ///
+ /// 启运港代码
+ ///
+ public string polId { get; set; }
+
+ ///
+ /// 启运港名称
+ ///
+ public string polName { get; set; }
+
+ ///
+ /// 目的港代码
+ ///
+ public string podId { get; set; }
+
+ ///
+ /// 目的港名称
+ ///
+ public string podName { get; set; }
+
+ ///
+ /// 交货地代码
+ ///
+ public string deliveryId { get; set; }
+
+ ///
+ /// 交货地名称
+ ///
+ public string deliveryName { get; set; }
+
+ ///
+ /// 收货地代码
+ ///
+ public string porId { get; set; }
+
+ ///
+ /// 收货地名称
+ ///
+ public string porName { get; set; }
+
+ ///
+ /// 船名
+ ///
+ public string vesselName { get; set; }
+
+ ///
+ /// 航线
+ ///
+ public string line { get; set; }
+
+ ///
+ /// 航次
+ ///
+ public string voyNo { get; set; }
+
+ ///
+ /// 离港时间
+ ///
+ public string etd { get; set; }
+
+ ///
+ /// 到港时间
+ ///
+ public string eta { get; set; }
+
+ ///
+ /// 收货人名称
+ ///
+ public string consigneeName { get; set; }
+
+ /////
+ ///// 收货人地址
+ /////
+ //public string consigneeAddr { get; set; }
+
+ /////
+ ///// 传真
+ /////
+ //public string consigneeFax { get; set; }
+
+ /////
+ ///// 电话
+ /////
+ //public string consigneeTel { get; set; }
+
+ /////
+ ///// 企业代码
+ /////
+ //public string consigneeBsCode { get; set; }
+
+ /////
+ ///// 邮件
+ /////
+ //public string consigneeEmail { get; set; }
+
+ ///
+ /// 发货人名称
+ ///
+ public string consignorName { get; set; }
+
+ /////
+ ///// 发货人地址
+ /////
+ //public string consignorAddr { get; set; }
+
+ /////
+ ///// 传真
+ /////
+ //public string consignorFax { get; set; }
+
+ /////
+ ///// 电话
+ /////
+ //public string consignorTel { get; set; }
+
+ /////
+ ///// 企业代码
+ /////
+ //public string consignorBsCode { get; set; }
+
+ /////
+ ///// 邮件
+ /////
+ //public string consignorEmail { get; set; }
+
+ ///
+ /// 通知人名称
+ ///
+ public string notifyName { get; set; }
+
+ /////
+ ///// 通知人地址
+ /////
+ //public string notifyAddr { get; set; }
+
+ /////
+ ///// 传真
+ /////
+ //public string notifyFax { get; set; }
+
+ /////
+ ///// 电话
+ /////
+ //public string notifyTel { get; set; }
+
+ /////
+ ///// 企业代码
+ /////
+ //public string notifyBsCode { get; set; }
+
+ /////
+ ///// 邮件
+ /////
+ //public string notifyEmail { get; set; }
+
+ ///
+ /// 运输条款
+ ///
+ public string movementType { get; set; }
+
+ ///
+ /// 毛重
+ ///
+ public decimal weight { get; set; }
+
+ ///
+ /// 体积
+ ///
+ public decimal cube { get; set; }
+
+ ///
+ /// 件数
+ ///
+ public int packages { get; set; }
+
+ ///
+ /// 包装类型
+ ///
+ public string packageDesc { get; set; }
+
+ ///
+ /// 唛头
+ ///
+ public string marks { get; set; }
+
+ ///
+ /// 货物描述
+ ///
+ public string cargoDesc { get; set; }
+
+ ///
+ /// 货物类型
+ ///
+ public string cargoType { get; set; }
+
+ ///
+ /// 是否危险品
+ ///
+ public bool isDanger { get; set; }
+
+ ///
+ /// 是否冻柜
+ ///
+ public bool isRf { get; set; }
+
+ ///
+ /// 是否特种箱
+ ///
+ public bool isSpec { get; set; }
+
+ ///
+ /// 是否挂衣箱
+ ///
+ public bool isGoh { get; set; }
+
+ ///
+ /// 是否SOC
+ ///
+ public bool isSoc { get; set; }
+
+ ///
+ /// 联系信息
+ ///
+ public string contactInfo { get; set; }
+
+ ///
+ /// 委托备注
+ ///
+ public string remark { get; set; }
+
+ ///
+ /// 支付方式
+ ///
+ public string payTerm { get; set; }
+
+ ///
+ /// 委托类型
+ ///
+ public string blType { get; set; }
+
+ ///
+ /// 放单方式
+ ///
+ public string releaseModeMbl { get; set; }
+
+
+ ///
+ /// 箱信息
+ ///
+ public List containers { get; set; }
+ ///
+ /// 其它特殊货物信息
+ ///
+ public List extras { get; set; }
+ ///
+ /// 危险品信息
+ ///
+ public List dangerInfo { get; set; }
+
+ }
+
+
+ public class SitcApiPostModelContainer
+ {
+ ///
+ /// 尺寸
+ ///
+ public string ctnSize { get; set; }
+ ///
+ /// 类型
+ ///
+ public string ctnType { get; set; }
+ ///
+ /// 数量
+ ///
+ public int ctnNum { get; set; }
+ }
+
+ public class SitcApiPostModelExtra
+ {
+ ///
+ /// 最高温度
+ ///
+ public string tempMax { get; set; }
+
+ ///
+ /// 最低温度
+ ///
+ public string tempMin { get; set; }
+ ///
+ /// 温度设置
+ ///
+ public string tempSetting { get; set; }
+ ///
+ /// 温度单位
+ ///
+ public string unit { get; set; }
+ ///
+ /// 湿度
+ ///
+ public string humdity { get; set; }
+ ///
+ /// 通风口
+ ///
+ public string vent { get; set; }
+ ///
+ /// 类型
+ ///
+ public string ctype { get; set; }
+ }
+
+ public class SitcApiPostModelDangerInfo
+ {
+ ///
+ /// 危险品等级
+ ///
+ public string classNo { get; set; }
+ ///
+ /// 化学品名
+ ///
+ public string commodityChem { get; set; }
+ ///
+ /// 运输品名
+ ///
+ public string commodityTran { get; set; }
+ ///
+ ///
+ ///
+ public string emergencyContact { get; set; }
+ ///
+ /// 应急措施号
+ ///
+ public string emsNo { get; set; }
+ ///
+ /// 闪点
+ ///
+ public string flashPoint { get; set; }
+ ///
+ /// 闪电单位
+ ///
+ public string flashUnit { get; set; }
+ ///
+ /// 毛重
+ ///
+ public int grossWeight { get; set; }
+ ///
+ /// 是否海污
+ ///
+ public string isMpt { get; set; }
+ ///
+ /// 危险品标签
+ ///
+ public string labels { get; set; }
+ ///
+ /// 净重
+ ///
+ public int netWeight { get; set; }
+ ///
+ /// 件数
+ ///
+ public int nums { get; set; }
+ ///
+ /// 包装等级
+ ///
+ public string packageClass { get; set; }
+ ///
+ /// 包装类型
+ ///
+ public string packageType { get; set; }
+ ///
+ /// 包装名称
+ ///
+ public string packageName { get; set; }
+ ///
+ /// 危险品页号
+ ///
+ public string page { get; set; }
+ ///
+ /// 联合国编号
+ ///
+ public string undgNo { get; set; }
+ ///
+ /// 紧急联系人
+ ///
+ public string contactName { get; set; }
+ ///
+ /// 联系号码
+ ///
+ public string contactNum { get; set; }
+ ///
+ ///
+ ///
+ public string packagingCode { get; set; }
+ }
+
+}
diff --git a/Myshipping.Application/Enum/EDIRouteEnum.cs b/Myshipping.Application/Enum/EDIRouteEnum.cs
index e3a9638f..3328c7cd 100644
--- a/Myshipping.Application/Enum/EDIRouteEnum.cs
+++ b/Myshipping.Application/Enum/EDIRouteEnum.cs
@@ -51,6 +51,10 @@ namespace Myshipping.Application
///
/// INTTRA
///
- INTTRA
+ INTTRA,
+ ///
+ /// SITC
+ ///
+ SITC
}
}
diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
index 194c5836..ddd43ab8 100644
--- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
+++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
@@ -86,6 +86,7 @@ using Myshipping.Application.Service.BookingSlot.Dto;
using Myshipping.Application.Service.BookingOrder.Dto.MSKAPI;
using Microsoft.AspNetCore.Routing.Template;
using Myshipping.Application.EDI.SeaLead;
+using Myshipping.Application.EDI.SITC;
namespace Myshipping.Application
{
@@ -7152,6 +7153,9 @@ namespace Myshipping.Application
//航线信息直接取的航司航线(ESL用)
primaryModel.ESLLINECODE = order.LANENAME;
+ //客户名
+ primaryModel.CUSTNAME = order.CUSTOMERNAME;
+
//起始港映射
var ediLoadPortList = _cache.GetAllMappingPortLoad().GetAwaiter().GetResult()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
@@ -7752,6 +7756,78 @@ namespace Myshipping.Application
{
sendStatus = await InnerSendBookingOrClosingEDIToPOST(result.extra.ToString(), postSpiderUrl, userWebAccountConfig);
}
+ else if (ediRouteEnum == EDIRouteEnum.SITC) //SITC走接口
+ {
+ sendStatus = new CommonWebApiResult();
+ var sysConfigs = await _cache.GetAllSysConfig();
+ var cfgAuthUrl = sysConfigs.FirstOrDefault(x => x.Code == "SITC_BOOK_API_AUTH_URL");
+ var cfgSendUrl = sysConfigs.FirstOrDefault(x => x.Code == "SITC_BOOK_API_SEND_URL");
+ var cfgAuthHeader = sysConfigs.FirstOrDefault(x => x.Code == "SITC_BOOK_API_AUTH_HEADER");
+ if (cfgAuthUrl == null || cfgSendUrl == null || cfgAuthHeader == null)
+ {
+ throw Oops.Bah($"SITC接口未配置");
+ }
+
+ //SITCBookApi
+ var webAcc = await _webAccountConfig.GetAccountConfig("SITCBookApi", UserManager.UserId);
+ if (webAcc == null)
+ {
+ throw Oops.Bah($"SITC接口账号密码未配置");
+ }
+
+ var dicAuth = new Dictionary {
+ { "username", webAcc.Account },
+ { "password", webAcc.Password },
+ { "grant_type", "password" }
+ };
+
+ _logger.LogInformation($"SITC接口调用:{cfgAuthUrl.Value} {dicAuth.ToJson()},头信息:{cfgAuthHeader.Value}");
+
+ var rtn = await cfgAuthUrl.Value
+ .SetHeaders(new { Authorization = cfgAuthHeader.Value })
+ .SetBody(dicAuth, "application/x-www-form-urlencoded")
+ .PostAsStringAsync();
+
+ _logger.LogInformation($"SITC接口返回:{rtn}");
+
+ var jRtn = JObject.Parse(rtn);
+ _logger.LogInformation($"SITC接口返回:{rtn}");
+ if (jRtn.GetIntValue("code") == 200)
+ {
+ var token = jRtn.GetJObjectValue("data").GetStringValue("accessToken");
+ _logger.LogInformation($"调用SITC接口获取token:{token}");
+
+ _logger.LogInformation($"SITC接口调用:{cfgSendUrl.Value} {result.extra2.ToJson()}");
+ rtn = await cfgSendUrl.Value
+ .SetHeaders(new Dictionary { { "Authorization", $"Bearer {token}" } })
+ .SetBody(result.extra2, "application/json")
+ .PostAsStringAsync();
+ jRtn = JObject.Parse(rtn);
+ _logger.LogInformation($"SITC接口返回:{rtn}");
+ if (jRtn.GetIntValue("code") == 200)
+ {
+ var bkNO = jRtn.GetJObjectValue("data").GetStringValue("bkNo");
+ _logger.LogInformation($"SITC接口返回订舱编号:{bkNO}");
+
+ order.CUSTNO = bkNO;
+ await _rep.AsUpdateable(order).UpdateColumns(x => new { x.CUSTNO }).ExecuteCommandAsync();
+ _logger.LogInformation($"更新订舱订单{order.Id}的CUSTNO={bkNO}");
+
+ sendStatus.succ = true;
+ sendStatus.msg = $"订舱成功";
+ }
+ else
+ {
+ sendStatus.succ = false;
+ sendStatus.msg = $"SITC接口调用失败:{jRtn.GetJObjectValue("message")}";
+ }
+ }
+ else
+ {
+ sendStatus.succ = false;
+ sendStatus.msg = $"获取token失败:{jRtn.GetJObjectValue("message")}";
+ }
+ }
else
{
//是订舱并且FTP配置了订舱接收邮箱则触发邮箱发送
@@ -9117,6 +9193,30 @@ namespace Myshipping.Application
result.succ = currRlt.succ;
result.extra = currRlt.succ ? currRlt.extra.ToString() : "";
}
+ else if (ediRouteEnum == EDIRouteEnum.SITC)
+ {
+ #region SITC
+ string strCheck = SITCEdiHelper.IsCreateSITCEDI(ediModel);
+
+ _logger.LogInformation($"调用SO(SI),校验:{strCheck},数据对象:{JsonConvert.SerializeObject(ediModel)}");
+
+ if (!string.IsNullOrWhiteSpace(strCheck))
+ {
+ if (Regex.IsMatch(strCheck, "\\
"))
+ {
+ strCheck = Regex.Replace(strCheck, "\\
", "\n");
+ }
+
+ throw Oops.Bah($"发送{EDIRouteEnum.SITC.ToString()}校验失败,{strCheck}");
+ }
+
+
+ var currRlt = SITCEdiHelper.CreateEdiSITC(ediModel);
+ #endregion
+ result.succ = currRlt.succ;
+ result.extra = currRlt.succ ? currRlt.extra : null;
+ result.extra2 = currRlt.succ ? currRlt.extra2 : null;
+ }
}
catch (Exception ex)
{