修改INTTRA订舱功能

usertest
jianghaiqing 4 months ago
parent ef6176e897
commit 3a25a72d17

@ -125,5 +125,22 @@ namespace DS.WMS.Core.Op.Interface
/// <param name="ctnList"></param>
/// <returns></returns>
public SeaExport UpdateSeaExportCtnInfo(SeaExport entity, List<OpCtnReq> ctnList);
/// <summary>
/// 获取港口详情
/// </summary>
/// <param name="Id"></param>
/// <param name="tenantDb"></param>
/// <returns></returns>
Task<DataResult<CodePort>> GetPortInfo(long Id, SqlSugarScopeProvider tenantDb);
/// <summary>
/// 根据订舱中的港口代码查找映射EDI代码
/// </summary>
/// <param name="Id">港口ID</param>
/// <param name="module">模块代码</param>
/// <returns></returns>
string GetDischargePortEDICode(long Id, string module = "");
}
}

@ -1,20 +1,24 @@
using Amazon.Runtime.Internal.Util;
using Autofac.Core;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Map.Entity;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.EDI;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using LanguageExt;
using LanguageExt.Common;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using NPOI.OpenXmlFormats.Dml.Diagram;
using NPOI.SS.UserModel;
using Org.BouncyCastle.Ocsp;
using System.Collections.Specialized;
@ -1023,18 +1027,18 @@ namespace DS.WMS.Core.Op.Method
if (ediRouteEnum == EDIRouteEnum.VOL)
return DataResult<string>.Failed($"当前船公司VOL不能执行标准发送");
//集装箱型
var ediCtnList = tenantDb.Queryable<MappingCtn>()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
&& t.CarrierId == order.CarrierId).ToList();
////集装箱型
//var ediCtnList = tenantDb.Queryable<MappingCtn>()
// .Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
// && t.CarrierId == order.CarrierId).ToList();
//包装
var ediPkgsList = tenantDb.Queryable<MappingPackage>()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
&& t.CarrierId == order.CarrierId).ToList();
////包装
//var ediPkgsList = tenantDb.Queryable<MappingPackage>()
// .Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
// && t.CarrierId == order.CarrierId).ToList();
//包装基础数据
var basePkgsList = tenantDb.Queryable<CodePackage>().Where(x => x.Status == StatusEnum.Enable).ToList();
////包装基础数据
//var basePkgsList = tenantDb.Queryable<CodePackage>().Where(x => x.Status == StatusEnum.Enable).ToList();
//EDI SO\SI代码
var ediSOSICfg = tenantDb.Queryable<MappingCarrier>().First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
@ -1102,7 +1106,7 @@ namespace DS.WMS.Core.Op.Method
{
var opt = AppSetting.app(new string[] { "TempFile", "Path" });
filePath = $"{Path.Combine(_environment.WebRootPath, opt)}\\{order.CustomerNo}";//服务器路径
filePath = $"{Path.Combine(_environment.WebRootPath ?? "", opt)}\\{order.CustomerNo}";//服务器路径
}
else
{
@ -1150,204 +1154,108 @@ namespace DS.WMS.Core.Op.Method
primaryModel.ESLLINECODE = order.Lane;
//起始港映射
var ediLoadPortList = tenantDb.Queryable<MappingPort>()
.Where(a => a.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && a.CarrierId == order.CarrierId).ToList();
var mapPortList = new List<MappingPort>();
var receivePortCode = seaComService.GetPortCode(order.ReceiptPlaceId, tenantDb);
primaryModel.PLACERECEIPTID = receivePortCode;
var portList = new List<CodePort>();
#region 收货地
//收货地
if (!string.IsNullOrWhiteSpace(primaryModel.PLACERECEIPTID))
if (order.ReceiptPlaceId > 0)
{
var currPortInfo = ediLoadPortList.FirstOrDefault(a =>
a.Code.Equals(primaryModel.PLACERECEIPTID, StringComparison.OrdinalIgnoreCase));
var portRlt = GetPortEDICode(order.ReceiptPlaceId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.ReceiptPlace, "收货地");
if (currPortInfo == null)
return DataResult<string>.Failed($"收货地{primaryModel.PLACERECEIPTID}的EDI代码未找到");
primaryModel.PLACERECEIPTID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.PLACERECEIPTID = portRlt.Data;
}
var loadPortCode = seaComService.GetPortCode(order.LoadPortId, tenantDb);
primaryModel.PORTLOADID = loadPortCode;
#endregion
#region 装货港
//装货港
if (!string.IsNullOrWhiteSpace(primaryModel.PORTLOADID))
if (order.LoadPortId > 0)
{
var currPortInfo = ediLoadPortList.FirstOrDefault(a =>
a.Code.Equals(primaryModel.PORTLOADID, StringComparison.OrdinalIgnoreCase));
if (currPortInfo == null)
return DataResult<string>.Failed($"装货港{primaryModel.PORTLOADID}的EDI代码未找到");
var portRlt = GetPortEDICode(order.LoadPortId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.LoadPort, "装货港");
primaryModel.PORTLOADID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.PORTLOADID = portRlt.Data;
}
var issueCode = seaComService.GetPortCode(order.IssuePlaceId, tenantDb);
primaryModel.ISSUEPLACEID = issueCode;
#endregion
#region 签单地点
//签单地点
if (!string.IsNullOrWhiteSpace(primaryModel.ISSUEPLACEID))
if (order.IssuePlaceId > 0)
{
var currPortInfo = ediLoadPortList.FirstOrDefault(a =>
a.Code.Equals(primaryModel.ISSUEPLACEID, StringComparison.OrdinalIgnoreCase));
if (currPortInfo == null)
return DataResult<string>.Failed($"签单地点{primaryModel.ISSUEPLACEID}的EDI代码未找到");
var portRlt = GetPortEDICode(order.IssuePlaceId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.IssuePlace, "签单地点");
primaryModel.ISSUEPLACEID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.ISSUEPLACEID = portRlt.Data;
}
var prepareCode = seaComService.GetPortCode(order.PrepareAtId, tenantDb);
primaryModel.PREPARDATID = prepareCode;
#endregion
#region 预付地点
//预付地点
if (!string.IsNullOrWhiteSpace(primaryModel.PREPARDATID))
if (order.PrepareAtId > 0)
{
var currPortInfo = ediLoadPortList.FirstOrDefault(a =>
a.Code.Equals(primaryModel.PREPARDATID, StringComparison.OrdinalIgnoreCase));
var portRlt = GetPortEDICode(order.PrepareAtId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.PrepareAt, "预付地点");
if (currPortInfo == null)
return DataResult<string>.Failed($"预付地点{primaryModel.PREPARDATID}的EDI代码未找到");
primaryModel.PREPARDATID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.PREPARDATID = portRlt.Data;
}
#endregion
//目的港基础
var portList = tenantDb.Queryable<CodePort>().Where(x => x.Status == StatusEnum.Enable).ToList();
//目的港映射
var ediPortList = tenantDb.Queryable<MappingPort>()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && t.CarrierId == order.CarrierId).ToList();
var dischargeCode = seaComService.GetPortCode(order.DischargePortId, tenantDb);
primaryModel.PORTDISCHARGEID = dischargeCode;
#region 卸货港
//卸货港
if (!string.IsNullOrWhiteSpace(primaryModel.PORTDISCHARGEID))
if (order.DischargePortId > 0)
{
var sameList = portList.Where(a =>
!string.IsNullOrWhiteSpace(a.EdiCode)
&& a.EdiCode.Equals(primaryModel.PORTDISCHARGEID, StringComparison.OrdinalIgnoreCase))
.Select(a => a.PortName).ToList();
if (sameList == null || sameList.Count == 0)
return DataResult<string>.Failed($"卸货港{primaryModel.PORTDISCHARGEID}基础港口代码未找到");
var currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code) && a.CarrierId == order.CarrierId);
if (currPortInfo == null)
{
currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code));
}
if (currPortInfo == null)
return DataResult<string>.Failed($"卸货港{primaryModel.PORTDISCHARGEID}的EDI代码未找到");
var portRlt = GetPortEDICode(order.DischargePortId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DischargePort, "卸货港");
primaryModel.PORTDISCHARGEID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.PORTDISCHARGEID = portRlt.Data;
}
var transPortCode = seaComService.GetPortCode(order.TransPortId, tenantDb);
primaryModel.TRANSPORTID = transPortCode;
#endregion
#region 中转港
//中转港
if (!string.IsNullOrWhiteSpace(primaryModel.TRANSPORTID))
if (order.TransPortId > 0)
{
var sameList = portList.Where(a =>
!string.IsNullOrWhiteSpace(a.EdiCode)
&& a.EdiCode.Equals(primaryModel.TRANSPORTID, StringComparison.OrdinalIgnoreCase))
.Select(a => a.PortName).ToList();
if (sameList == null || sameList.Count == 0)
return DataResult<string>.Failed($"中转港{primaryModel.TRANSPORTID}基础港口代码未找到");
var currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code) && a.CarrierId == order.CarrierId);
if (currPortInfo == null)
{
currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code));
}
var portRlt = GetPortEDICode(order.TransPortId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.TransPort, "中转港");
if (currPortInfo == null)
return DataResult<string>.Failed($"中转港{primaryModel.TRANSPORTID}的EDI代码未找到");
primaryModel.TRANSPORTID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.TRANSPORTID = portRlt.Data;
}
var destinationCode = seaComService.GetPortCode(order.DestinationId, tenantDb);
primaryModel.DESTINATIONID = destinationCode;
#endregion
#region 目的地
//目的地
if (!string.IsNullOrWhiteSpace(primaryModel.DESTINATIONID))
if (order.DischargePortId > 0)
{
var sameList = portList.Where(a =>
!string.IsNullOrWhiteSpace(a.EdiCode)
&& a.EdiCode.Equals(primaryModel.DESTINATIONID, StringComparison.OrdinalIgnoreCase))
.Select(a => a.PortName?.Trim()).ToList();
if (sameList == null || sameList.Count == 0)
return DataResult<string>.Failed($"目的地{primaryModel.DESTINATIONID}基础港口代码未找到");
var currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code) && a.CarrierId == order.CarrierId);
if (currPortInfo == null)
{
currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code));
}
var portRlt = GetPortEDICode(order.DestinationId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DischargePort, "目的地");
if (currPortInfo == null)
return DataResult<string>.Failed($"目的地{primaryModel.DESTINATIONID}的EDI代码未找到");
primaryModel.DESTINATIONID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.DESTINATIONID = portRlt.Data;
}
var deliveryCode = seaComService.GetPortCode(order.DeliveryPlaceId, tenantDb);
primaryModel.PLACEDELIVERYID = deliveryCode;
#endregion
#region 交货地
//交货地
if (!string.IsNullOrWhiteSpace(primaryModel.PLACEDELIVERYID))
if (order.DeliveryPlaceId > 0)
{
var sameList = portList.Where(a =>
!string.IsNullOrWhiteSpace(a.EdiCode)
&& a.EdiCode.Equals(primaryModel.PLACEDELIVERYID, StringComparison.OrdinalIgnoreCase))
.Select(a => a.PortName).ToList();
if (sameList == null || sameList.Count == 0)
return DataResult<string>.Failed($"交货地{primaryModel.PLACEDELIVERYID}基础港口代码未找到");
var currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code) && a.CarrierId == order.CarrierId);
if (currPortInfo == null)
{
currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code));
}
if (currPortInfo == null)
return DataResult<string>.Failed($"交货地{primaryModel.PLACEDELIVERYID}的EDI代码未找到");
var portRlt = GetPortEDICode(order.DeliveryPlaceId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DeliveryPlace, "交货地");
primaryModel.PLACEDELIVERYID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.PLACEDELIVERYID = portRlt.Data;
}
var payableCode = seaComService.GetPortCode(order.PayableAtId, tenantDb);
primaryModel.PAYABLEATID = payableCode;
#endregion
#region 到付地点
//到付地点
if (!string.IsNullOrWhiteSpace(primaryModel.PAYABLEATID))
if (order.PayableAtId > 0)
{
var sameList = portList.Where(a =>
!string.IsNullOrWhiteSpace(a.EdiCode)
&& a.EdiCode.Equals(primaryModel.PAYABLEATID, StringComparison.OrdinalIgnoreCase))
.Select(a => a.PortName).ToList();
if (sameList == null || sameList.Count == 0)
return DataResult<string>.Failed($"到付地点{primaryModel.PAYABLEATID}基础港口代码未找到");
var currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code) && a.CarrierId == order.CarrierId);
if (currPortInfo == null)
{
currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code));
}
var portRlt = GetPortEDICode(order.PayableAtId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.PayableAt, "到付地点");
if (currPortInfo == null)
return DataResult<string>.Failed($"到付地点{primaryModel.PAYABLEATID}的EDI代码未找到");
primaryModel.PAYABLEATID = currPortInfo.MapCode?.Trim();
if (portRlt.Succeeded)
primaryModel.PAYABLEATID = portRlt.Data;
}
#endregion
//起运港是CNTAO并且船公司是太平需要判断场站EDI
if (ediRouteEnum == EDIRouteEnum.WY)
@ -1373,84 +1281,99 @@ namespace DS.WMS.Core.Op.Method
if (ediRouteEnum == EDIRouteEnum.ESL || ediRouteEnum == EDIRouteEnum.PIL || ediRouteEnum == EDIRouteEnum.WY
|| ediRouteEnum == EDIRouteEnum.YML || ediRouteEnum == EDIRouteEnum.YT || ediRouteEnum == EDIRouteEnum.INTTRA)
{
//付费方式基础数据
var baseFrtList = tenantDb.Queryable<CodeFrt>().Where(x => x.Status == StatusEnum.Enable).ToList();
var baseFrtInfo = baseFrtList.FirstOrDefault(t =>
t.EdiCode.Equals(order.MBLFrt, StringComparison.OrdinalIgnoreCase));
if (baseFrtInfo == null)
return DataResult<string>.Failed($"付费方式{order.MBLFrt}的基础代码未找到");
//付费方式映射
var ediFrtList = tenantDb.Queryable<MappingFrt>()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && t.CarrierId == order.CarrierId).ToList();
/*
1EdiCode
*/
if (!string.IsNullOrWhiteSpace(order.MBLFrt))
{
var currFrtInfo = ediFrtList.FirstOrDefault(t => t.Code.Equals(baseFrtInfo.EdiCode, StringComparison.OrdinalIgnoreCase));
long mblFrt = long.Parse(order.MBLFrt);
var mapInfo = tenantDb.Queryable<MappingFrt>().First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
&& t.CarrierId == order.CarrierId && t.LinkId == mblFrt);
if (currFrtInfo == null)
return DataResult<string>.Failed($"付费方式{order.MBLFrt}的EDI代码未找到");
if (mapInfo != null)
{
primaryModel.BLFRTEDICODE = mapInfo.MapCode?.Trim();
}
else
{
var codeInfo = tenantDb.Queryable<CodeFrt>().First(x => x.Status == StatusEnum.Enable && x.Id == mblFrt);
primaryModel.BLFRTEDICODE = currFrtInfo.MapCode?.Trim();
if (codeInfo != null && !string.IsNullOrWhiteSpace(codeInfo.EdiCode))
{
primaryModel.BLFRTEDICODE = codeInfo.EdiCode;
}
else
{
return DataResult<string>.Failed($"付费方式{order.MBLFrt}的基础代码未找到");
}
}
}
else
{
return DataResult<string>.Failed($"付费方式{order.MBLFrt}不能为空");
}
}
#region 运输条款EDI
//运输条款EDI
if (!string.IsNullOrWhiteSpace(order.Service))
{
//运输条款EDI
var baseServiceList = tenantDb.Queryable<CodeService>().Where(x => x.Status == StatusEnum.Enable).ToList();
var baseServiceInfo = baseServiceList.FirstOrDefault(t =>
t.EdiCode.Equals(order.Service, StringComparison.OrdinalIgnoreCase));
long serviceId = long.Parse(order.Service);
if (baseServiceInfo == null)
return DataResult<string>.Failed($"运输条款{order.Service}的基础代码未找到");
var mapInfo = tenantDb.Queryable<MappingService>()
.First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && t.CarrierId == order.CarrierId && t.Id == serviceId);
//运输条款映射
var ediServiceList = tenantDb.Queryable<MappingService>()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && t.CarrierId == order.CarrierId).ToList();
var currServiceInfo = ediServiceList.FirstOrDefault(t => t.Code.Equals(baseServiceInfo.EdiCode, StringComparison.OrdinalIgnoreCase));
if (currServiceInfo == null)
return DataResult<string>.Failed($"运输条款{order.Service}的EDI代码未找到");
if(mapInfo != null)
{
primaryModel.SERVICEEDICODE = mapInfo.MapCode;
}
else
{
//运输条款EDI
var codeService = tenantDb.Queryable<CodeService>().First(x => x.Status == StatusEnum.Enable && x.Id == serviceId);
primaryModel.SERVICEEDICODE = currServiceInfo.MapCode?.Trim();
if (codeService != null && !string.IsNullOrWhiteSpace(codeService.EdiCode))
{
primaryModel.SERVICEEDICODE = codeService.EdiCode;
}
else
{
return DataResult<string>.Failed($"运输条款{order.Service}的基础代码未找到");
}
}
}
#endregion
#region 签单方式EDI
////签单方式EDI
if (!string.IsNullOrWhiteSpace(order.IssueType))
{
//签单方式EDI
var baseIssueTypeList = tenantDb.Queryable<CodeIssueType>().Where(x => x.Status == StatusEnum.Enable).ToList();
var baseIssueTypeInfo = baseIssueTypeList.FirstOrDefault(t =>
t.EnName.Equals(order.IssueType, StringComparison.OrdinalIgnoreCase));
if (baseIssueTypeInfo == null)
return DataResult<string>.Failed($"签单方式{order.IssueType}的基础代码未找到");
//签单方式映射
var ediIssueTypeList = tenantDb.Queryable<MappingIssueType>()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
).ToList();
long issueTypeId = long.Parse(order.IssueType);
var currIssueTypeInfo = ediIssueTypeList.FirstOrDefault(t => t.CarrierId == order.CarrierId
&& t.Code.Equals(baseIssueTypeInfo.EdiCode, StringComparison.OrdinalIgnoreCase));
var mapInfo = tenantDb.Queryable<MappingIssueType>()
.First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && t.CarrierId == order.CarrierId && t.Id == issueTypeId);
if (currIssueTypeInfo == null)
if (mapInfo != null)
{
//如果没有对应的船司记录,则取默认的第一个代码对应的记录
currIssueTypeInfo = ediIssueTypeList.FirstOrDefault(t => t.Code.Equals(baseIssueTypeInfo.EdiCode, StringComparison.OrdinalIgnoreCase));
primaryModel.ISSUETYPE = mapInfo.MapCode;
}
else
{
//签单方式EDI
var codeService = tenantDb.Queryable<CodeIssueType>().First(x => x.Status == StatusEnum.Enable && x.Id == issueTypeId);
if (currIssueTypeInfo == null)
return DataResult<string>.Failed($"签单方式{order.IssueType}的EDI代码未找到");
primaryModel.ISSUETYPE = currIssueTypeInfo.MapCode?.Trim().ToUpper();
if (codeService != null && !string.IsNullOrWhiteSpace(codeService.EdiCode))
{
primaryModel.ISSUETYPE = codeService.EdiCode;
}
else
{
return DataResult<string>.Failed($"签单方式{order.Service}的基础代码未找到");
}
}
}
#endregion
primaryModel.CARRIEREDICODE = ediSOSICfg.MapCode;
@ -1480,17 +1403,33 @@ namespace DS.WMS.Core.Op.Method
}
}
var curBasePkgs = basePkgsList.FirstOrDefault(p => p.PackageName.Equals(order.KindPkgs, StringComparison.OrdinalIgnoreCase));
List<CodeCtn> codeCtnList = new List<CodeCtn>();
List<MappingCtn> mapCtnList = new List<MappingCtn>();
if (curBasePkgs == null)
return DataResult<string>.Failed($"包装{order.KindPkgs}的基础数据代码未找到");
List<CodePackage> codePackageList = new List<CodePackage>();
List<MappingPackage> mapPackageList = new List<MappingPackage>();
var ediPkgs = ediPkgsList.FirstOrDefault(x => x.Code.Equals(curBasePkgs.EdiCode, StringComparison.OrdinalIgnoreCase));
#region 包装方式EDI
if (!string.IsNullOrWhiteSpace(order.KindPkgs))
{
long packageId = long.Parse(order.KindPkgs);
if (ediPkgs == null || string.IsNullOrWhiteSpace(ediPkgs.MapCode))
return DataResult<string>.Failed($"包装{order.KindPkgs}的EDI代码未找到");
var portRlt = GetPackageEDICode(packageId, codePackageList, mapPackageList, order.CarrierId, CONST_MAPPING_MODULE);
primaryModel.KINDPKGS_EDI_CODE = ediPkgs.MapCode?.Trim();
if (portRlt.Succeeded)
{
primaryModel.KINDPKGS_EDI_CODE = portRlt.Data;
}
else
{
return DataResult<string>.Failed($"包装{order.KindPkgs}的映射数据代码未找到");
}
}
else
{
return DataResult<string>.Failed($"包装不能为空");
}
#endregion
//这里是订舱时,默认取SOREMARK赋值到EDIREMARK
if (req.SendType == "B")
@ -1591,6 +1530,7 @@ namespace DS.WMS.Core.Op.Method
primaryModel.CTNLIST = new List<SeaExportCtnEDIBaseModel>();
//集装箱
foreach (var conta in contaList)
@ -1598,29 +1538,32 @@ namespace DS.WMS.Core.Op.Method
//TODO 转换
var contaModel = conta.Adapt<SeaExportCtnEDIBaseModel>();
//EDI箱型
var currConta = ediCtnList.FirstOrDefault(x => x.Code.Equals(conta.CtnCode, StringComparison.OrdinalIgnoreCase));
if (currConta == null)
return DataResult<string>.Failed($"箱型{conta.CtnCode}的EDI代码未找到!");
var mapCtnRlt = GetCtnEDICode(conta.CtnCode, codeCtnList, mapCtnList, order.CarrierId, CONST_MAPPING_MODULE, conta.CtnAll);
contaModel.CTNALLCODE = currConta.MapCode;
if (mapCtnRlt.Succeeded)
{
contaModel.CTNALLCODE = mapCtnRlt.Data;
}
else
{
return DataResult<string>.Failed($"箱型{conta.CtnAll}的映射数据代码未找到");
}
if (string.IsNullOrWhiteSpace(conta.KindPkgs))
return DataResult<string>.Failed($"集装箱包装不能为空!");
var curContaBasePkgs = basePkgsList.FirstOrDefault(p => p.PackageName.Equals(conta.KindPkgs, StringComparison.OrdinalIgnoreCase));
long packageId = long.Parse(conta.KindPkgs);
if (curContaBasePkgs == null)
return DataResult<string>.Failed($"包装{conta.KindPkgs}的基础数据代码未找到!");
var mapRlt = GetPackageEDICode(packageId, codePackageList, mapPackageList, order.CarrierId, CONST_MAPPING_MODULE);
//EDI包装
var ediContaPkgs = ediPkgsList.FirstOrDefault(x => x.Code.Equals(curContaBasePkgs.EdiCode, StringComparison.OrdinalIgnoreCase));
if (currConta == null)
return DataResult<string>.Failed($"包装{conta.KindPkgs}的EDI代码未找到!");
contaModel.KINDPKGS_EDI_CODE = ediContaPkgs.MapCode?.Trim();
if (mapRlt.Succeeded)
{
primaryModel.KINDPKGS_EDI_CODE = mapRlt.Data;
}
else
{
return DataResult<string>.Failed($"包装{order.KindPkgs}的映射数据代码未找到");
}
primaryModel.CTNLIST.Add(contaModel);
}
@ -1642,17 +1585,18 @@ namespace DS.WMS.Core.Op.Method
if (string.IsNullOrWhiteSpace(cargo.KindPkgs))
return DataResult<string>.Failed($"多品名包装不能为空!");
var curCargoBasePkgs = basePkgsList.FirstOrDefault(p => p.PackageName.Equals(cargo.KindPkgs, StringComparison.OrdinalIgnoreCase));
long packageId = long.Parse(cargo.KindPkgs);
if (curCargoBasePkgs == null)
return DataResult<string>.Failed($"包装{cargo.KindPkgs}的基础数据代码未找到");
var mapRlt = GetPackageEDICode(packageId, codePackageList, mapPackageList, order.CarrierId, CONST_MAPPING_MODULE);
var ediDetailPkgs = ediPkgsList.FirstOrDefault(x => x.Code.Equals(curCargoBasePkgs.EdiCode, StringComparison.OrdinalIgnoreCase));
if (ediDetailPkgs == null)
return DataResult<string>.Failed($"货明细的包装{cargo.KindPkgs}的EDI代码未找到");
cargoModel.KINDPKGS_EDI_CODE = ediDetailPkgs.MapCode?.Trim();
if (mapRlt.Succeeded)
{
cargoModel.KINDPKGS_EDI_CODE = mapRlt.Data;
}
else
{
return DataResult<string>.Failed($"货明细的包装{order.KindPkgs}的映射数据代码未找到");
}
primaryModel.CTNGOODSLIST.Add(cargoModel);
}
@ -2430,5 +2374,183 @@ namespace DS.WMS.Core.Op.Method
return result;
}
#endregion
#region 检索港口的EDI代码
/// <summary>
/// 检索港口的EDI代码
/// </summary>
/// <param name="portId">港口ID</param>
/// <param name="codePortList">港口基础表</param>
/// <param name="mapPortList">港口映射表</param>
/// <param name="carrierId">船公司ID</param>
/// <param name="moduleName">模块代码</param>
/// <param name="portName">港口名称</param>
/// <param name="portCategory">港口分类(装货港、卸货港、交货地等)</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
private DataResult<string> GetPortEDICode(long portId,List<CodePort> codePortList,List<MappingPort> mapPortList, long carrierId, string moduleName,string portName,string portCategory)
{
//如果历史港口映射有记录直接返回
if (mapPortList.Any(a => a.LinkId == portId))
{
var edi = mapPortList.FirstOrDefault(a => a.LinkId == portId).MapCode;
if (!string.IsNullOrWhiteSpace(edi))
return DataResult<string>.Success(edi);
return DataResult<string>.FailedData(edi);
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var mapPortInfo = tenantDb.Queryable<MappingPort>()
.First(a => a.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && a.CarrierId == carrierId && a.LinkId == portId);
if (mapPortInfo != null)
{
mapPortList.Add(mapPortInfo);
if (!string.IsNullOrWhiteSpace(mapPortInfo.MapCode))
return DataResult<string>.Success(mapPortInfo.MapCode);
return DataResult<string>.FailedData(mapPortInfo.MapCode);
}
if (codePortList.Any(a => a.Id == portId))
{
var edi = codePortList.FirstOrDefault(a => a.Id == portId).EdiCode;
if (!string.IsNullOrWhiteSpace(edi))
return DataResult<string>.Success(edi);
return DataResult<string>.FailedData(edi);
}
var loadPortCodeRlt = seaComService.GetPortInfo(portId, tenantDb).GetAwaiter().GetResult();
if (!loadPortCodeRlt.Succeeded)
{
throw new Exception($"{portCategory} {portName}的港口基础代码未找到");
}
codePortList.Add(loadPortCodeRlt.Data);
if (!string.IsNullOrWhiteSpace(loadPortCodeRlt.Data?.EdiCode))
return DataResult<string>.Success(loadPortCodeRlt.Data?.EdiCode);
return DataResult<string>.FailedData(loadPortCodeRlt.Data?.EdiCode);
}
#endregion
#region 检索集装箱型EDI代码
/// <summary>
/// 检索集装箱型EDI代码
/// </summary>
/// <param name="ctnCodeId">集装箱型ID</param>
/// <param name="codeCtnList">集装箱基础表</param>
/// <param name="mapCtnList">集装箱映射表</param>
/// <param name="carrierId">船公司ID</param>
/// <param name="moduleName">模块代码</param>
/// <param name="ctnName">集装箱名称</param>
/// <returns></returns>
private DataResult<string> GetCtnEDICode(string ctnCode, List<CodeCtn> codeCtnList, List<MappingCtn> mapCtnList, long carrierId, string moduleName, string ctnName)
{
CodeCtn codeCtnInfo = null;
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (codeCtnList.Any(a => a.EdiCode == ctnCode))
{
codeCtnInfo = codeCtnList.FirstOrDefault(a => a.EdiCode == ctnCode);
}
if (codeCtnInfo == null)
{
codeCtnInfo = tenantDb.Queryable<CodeCtn>().First(a => a.EdiCode == ctnCode && a.Status == StatusEnum.Enable);
if (codeCtnInfo != null)
{
codeCtnList.Add(codeCtnInfo);
}
else
{
throw new Exception($"集装箱 {ctnName} 基础代码未找到");
}
}
//如果历史港口映射有记录直接返回
if (mapCtnList.Any(a => a.LinkId == codeCtnInfo.Id))
{
var edi = mapCtnList.FirstOrDefault(a => a.LinkId == codeCtnInfo.Id).MapCode;
if (!string.IsNullOrWhiteSpace(edi))
return DataResult<string>.Success(edi);
return DataResult<string>.FailedData(edi);
}
var mapCtnInfo = tenantDb.Queryable<MappingCtn>()
.First(a => a.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && a.CarrierId == carrierId && a.LinkId == codeCtnInfo.Id);
if (mapCtnInfo != null)
{
mapCtnList.Add(mapCtnInfo);
if (!string.IsNullOrWhiteSpace(mapCtnInfo.MapCode))
return DataResult<string>.Success(mapCtnInfo.MapCode);
return DataResult<string>.FailedData(mapCtnInfo.MapCode);
}
else
{
throw new Exception($"集装箱型 {ctnName}的映射代码未找到");
}
}
#endregion
#region 检索包装EDI代码
/// <summary>
/// 检索包装EDI代码
/// </summary>
/// <param name="packageCodeId">包装ID</param>
/// <param name="codePackageList">包装基础表</param>
/// <param name="mapPackageList">包装映射表</param>
/// <param name="carrierId">船公司ID</param>
/// <param name="moduleName">模块代码</param>
/// <param name="packageName">包装名称</param>
/// <returns></returns>
private DataResult<string> GetPackageEDICode(long packageCodeId, List<CodePackage> codePackageList, List<MappingPackage> mapPackageList, long carrierId, string moduleName)
{
//如果历史港口映射有记录直接返回
if (mapPackageList.Any(a => a.LinkId == packageCodeId))
{
var edi = mapPackageList.FirstOrDefault(a => a.LinkId == packageCodeId).MapCode;
if (!string.IsNullOrWhiteSpace(edi))
return DataResult<string>.Success(edi);
return DataResult<string>.FailedData(edi);
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var mapPackageInfo = tenantDb.Queryable<MappingPackage>()
.First(a => a.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && a.CarrierId == carrierId && a.LinkId == packageCodeId);
if (mapPackageInfo != null)
{
mapPackageList.Add(mapPackageInfo);
if (!string.IsNullOrWhiteSpace(mapPackageInfo.MapCode))
return DataResult<string>.Success(mapPackageInfo.MapCode);
return DataResult<string>.FailedData(mapPackageInfo.MapCode);
}
else
{
throw new Exception($"包装的映射代码未找到");
}
}
#endregion
}
}

@ -505,6 +505,29 @@ namespace DS.WMS.Core.Op.Method
}
return port.EdiCode.IsNull() ? port.PortName : port.EdiCode;
}
#region 获取港口详情
/// <summary>
/// 获取港口详情
/// </summary>
/// <param name="Id"></param>
/// <param name="tenantDb"></param>
/// <returns></returns>
public async Task<DataResult<CodePort>> GetPortInfo(long Id, SqlSugarScopeProvider tenantDb)
{
if (Id == 0)
return DataResult<CodePort>.FailedData(null);
var port = await tenantDb.Queryable<CodePort>().FirstAsync(v => v.Id == Id && v.Status == StatusEnum.Enable);
if (port.IsNull())
{
return DataResult<CodePort>.FailedData(port);
}
return DataResult<CodePort>.Success(port);
}
#endregion
/// <summary>
/// 获取船名EDI代码
/// </summary>

Loading…
Cancel
Save