|
|
|
@ -138,6 +138,8 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
|
|
|
|
|
const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT";
|
|
|
|
|
const string CONST_MAPPING_MODULE_VOLTA = "BOOK_CLOSING_VOLTA";
|
|
|
|
|
|
|
|
|
|
private const string PrintRecentListTypeKey = "booking_print_recent_list";
|
|
|
|
|
|
|
|
|
|
const string CONST_TSL_EDI_URL = "tsl_edi_declare_url";
|
|
|
|
@ -5788,6 +5790,10 @@ namespace Myshipping.Application
|
|
|
|
|
if (ediRouteEnum == EDIRouteEnum.NULL)
|
|
|
|
|
throw Oops.Bah($"当前船公司没有对应的请求路由配置");
|
|
|
|
|
|
|
|
|
|
//这里船公司VOL的单子不能走此通道发送
|
|
|
|
|
if(ediRouteEnum == EDIRouteEnum.VOL)
|
|
|
|
|
throw Oops.Bah($"当前船公司VOL不能执行标准发送");
|
|
|
|
|
|
|
|
|
|
//集装箱型
|
|
|
|
|
var ediCtnList = _cache.GetAllMappingCtn().GetAwaiter().GetResult()
|
|
|
|
|
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
|
|
|
|
@ -5798,8 +5804,6 @@ namespace Myshipping.Application
|
|
|
|
|
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
&& !string.IsNullOrWhiteSpace(t.CarrierCode) && t.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//包装基础数据
|
|
|
|
|
var basePkgsList = _cache.GetAllCodePackage().GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
@ -9917,5 +9921,214 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 检查是否VOLTA并返回初始数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检查是否VOLTA并返回初始数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">请求参数</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/BookingOrder/CheckAndInitVOLTAEdi")]
|
|
|
|
|
public dynamic CheckAndInitVOLTAEdi(BookingOrClosingEDIOrderDto model)
|
|
|
|
|
{
|
|
|
|
|
CommonWebApiResult result = new CommonWebApiResult();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
判断当前单子是否满足执行VOLTA截单流程
|
|
|
|
|
1、是截单请求
|
|
|
|
|
2、船公司是VOL。
|
|
|
|
|
3、提单号开头是(VOL、FCS、REL)
|
|
|
|
|
*/
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no}获取请求VOLTA截单EDI {msg}", batchNo, JSON.Serialize(model));
|
|
|
|
|
|
|
|
|
|
if (!model.sendType.Equals("E", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("只接受发送类型截单(E)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (model.Id == 0)
|
|
|
|
|
throw Oops.Bah("订单Id不能为空");
|
|
|
|
|
|
|
|
|
|
var order = _rep.FirstOrDefault(a => a.Id == model.Id);
|
|
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
|
throw Oops.Bah($"获取订单信息失败");
|
|
|
|
|
|
|
|
|
|
if (order.ParentId.HasValue && order.ParentId.Value > 0)
|
|
|
|
|
throw Oops.Bah($"获取当前订单为分单不能生成EDI信息");
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no}提取订单信息完成", batchNo);
|
|
|
|
|
|
|
|
|
|
if (!order.CARRIERID.Equals("VOL", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("当前订单的船公司不是VOL(沃尔塔航运)不能发送VOLTA截单EDI");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(order.MBLNO))
|
|
|
|
|
throw Oops.Bah($"提单号不能为空");
|
|
|
|
|
|
|
|
|
|
if (!order.MBLNO.StartsWith("VOL") && !order.MBLNO.StartsWith("FCS") && !order.MBLNO.StartsWith("REL"))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"只支持提单号开头是(VOL、FCS、REL)发送截单");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//箱信息
|
|
|
|
|
var contaList = _repCtn.AsQueryable().Where(t => t.BILLID == order.Id).ToList();
|
|
|
|
|
|
|
|
|
|
VOLTAEDIBaseModel voltaModel = order.Adapt<VOLTAEDIBaseModel>();
|
|
|
|
|
|
|
|
|
|
#region 拆分收、发、通(名称、地址拆分)
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(voltaModel.ShpperName))
|
|
|
|
|
{
|
|
|
|
|
string name = voltaModel.ShpperName;
|
|
|
|
|
voltaModel.ShpperName = GetShipCneeNotifyDetail(name);
|
|
|
|
|
voltaModel.ShpperAddr = GetShipCneeNotifyDetail(name, "addr");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(voltaModel.ConsigneeName))
|
|
|
|
|
{
|
|
|
|
|
string name = voltaModel.ConsigneeName;
|
|
|
|
|
voltaModel.ConsigneeName = GetShipCneeNotifyDetail(name);
|
|
|
|
|
voltaModel.ConsigneeAddr = GetShipCneeNotifyDetail(name, "addr");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(voltaModel.NotifyName))
|
|
|
|
|
{
|
|
|
|
|
string name = voltaModel.NotifyName;
|
|
|
|
|
voltaModel.NotifyName = GetShipCneeNotifyDetail(name);
|
|
|
|
|
voltaModel.NotifyAddr = GetShipCneeNotifyDetail(name, "addr");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (voltaModel != null)
|
|
|
|
|
voltaModel.ContaList = contaList.Adapt<List<VOLTAEDIContaModel>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//还需要翻译箱明细的包装
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.extra = voltaModel;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 发送VOLTA截单请求
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发送VOLTA截单请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">请求截单详情</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/BookingOrder/SendVOLTAEdiSI")]
|
|
|
|
|
public async Task<dynamic> SendVOLTAEdiSI(VOLTAEDIBaseModel model)
|
|
|
|
|
{
|
|
|
|
|
CommonWebApiResult result = new CommonWebApiResult();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 下载VOLTA截单请求报文
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下载VOLTA截单请求报文
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">请求截单详情</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/BookingOrder/DownloadVOLTAEdiSI")]
|
|
|
|
|
public async Task<IActionResult> DownloadVOLTAEdiSI(VOLTAEDIBaseModel model)
|
|
|
|
|
{
|
|
|
|
|
var filePath = InnerVOLTAEDI(model).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
var fileInfo = new FileInfo(filePath);
|
|
|
|
|
|
|
|
|
|
var result = new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileInfo.Name };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 生成VOLTA报文(内部方法)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成VOLTA报文(内部方法)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model">请求截单详情</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task<dynamic> InnerVOLTAEDI(VOLTAEDIBaseModel model)
|
|
|
|
|
{
|
|
|
|
|
CommonWebApiResult result = new CommonWebApiResult();
|
|
|
|
|
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no}获取请求VOLTA截单EDI {msg}", batchNo, JSON.Serialize(model));
|
|
|
|
|
|
|
|
|
|
if (model.id == 0)
|
|
|
|
|
throw Oops.Bah("订单Id不能为空");
|
|
|
|
|
|
|
|
|
|
var order = _rep.FirstOrDefault(a => a.Id == model.id);
|
|
|
|
|
|
|
|
|
|
if (order == null)
|
|
|
|
|
throw Oops.Bah($"获取订单信息失败");
|
|
|
|
|
|
|
|
|
|
if (order.ParentId.HasValue && order.ParentId.Value > 0)
|
|
|
|
|
throw Oops.Bah($"获取当前订单为分单不能生成EDI信息");
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no}提取订单信息完成", batchNo);
|
|
|
|
|
|
|
|
|
|
//箱信息
|
|
|
|
|
var contaList = _repCtn.AsQueryable().Where(t => t.BILLID == order.Id).ToList();
|
|
|
|
|
|
|
|
|
|
EDIRouteEnum ediRouteEnum = GetEDIRoute(order.CARRIERID);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("批次={no} 获取EDI路由完成 路由={route}", batchNo, ediRouteEnum.ToString());
|
|
|
|
|
|
|
|
|
|
if (ediRouteEnum == EDIRouteEnum.NULL)
|
|
|
|
|
throw Oops.Bah($"当前船公司没有对应的请求路由配置");
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 提取收、发、通详情
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提取收、发、通详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">收、发、通信息</param>
|
|
|
|
|
/// <param name="location">内容定位(name-名称;addr-地址)</param>
|
|
|
|
|
/// <returns>返回截取字符</returns>
|
|
|
|
|
public string GetShipCneeNotifyDetail(string name,string location = "name")
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (location == "name")
|
|
|
|
|
{
|
|
|
|
|
result = Regex.Match(name, ".*(?=\\n)").Value;
|
|
|
|
|
}
|
|
|
|
|
else if (location == "addr")
|
|
|
|
|
{
|
|
|
|
|
string s = Regex.Match(name, ".*(?=\\n)").Value;
|
|
|
|
|
|
|
|
|
|
result = name.Replace(s, "");
|
|
|
|
|
|
|
|
|
|
if(Regex.IsMatch(result,"^\\n"))
|
|
|
|
|
{
|
|
|
|
|
result = Regex.Replace(result, "^\\n", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//result = Regex.Match(name, $"(?<={s}).*").Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"{nameof(GetShipCneeNotifyDetail)} 提取收、发、通详情异常,原因:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|