|
|
|
@ -1202,11 +1202,18 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
string needMappingModule = string.Empty;
|
|
|
|
|
|
|
|
|
|
if (ediRouteEnum == EDIRouteEnum.INTTRA)
|
|
|
|
|
{
|
|
|
|
|
needMappingModule = "INTTRA_EDI";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 卸货港
|
|
|
|
|
//卸货港
|
|
|
|
|
if (order.DischargePortId > 0)
|
|
|
|
|
{
|
|
|
|
|
var portRlt = GetPortEDICode(order.DischargePortId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DischargePort, "卸货港");
|
|
|
|
|
var portRlt = GetPortEDICode(order.DischargePortId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DischargePort, "卸货港", needMappingModule);
|
|
|
|
|
|
|
|
|
|
if (portRlt.Succeeded)
|
|
|
|
|
primaryModel.PORTDISCHARGEID = portRlt.Data;
|
|
|
|
@ -1217,7 +1224,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
//中转港
|
|
|
|
|
if (order.TransPortId > 0)
|
|
|
|
|
{
|
|
|
|
|
var portRlt = GetPortEDICode(order.TransPortId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.TransPort, "中转港");
|
|
|
|
|
var portRlt = GetPortEDICode(order.TransPortId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.TransPort, "中转港", needMappingModule);
|
|
|
|
|
|
|
|
|
|
if (portRlt.Succeeded)
|
|
|
|
|
primaryModel.TRANSPORTID = portRlt.Data;
|
|
|
|
@ -1228,7 +1235,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
//交货地
|
|
|
|
|
if (order.DeliveryPlaceId > 0)
|
|
|
|
|
{
|
|
|
|
|
var portRlt = GetPortEDICode(order.DeliveryPlaceId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DeliveryPlace, "交货地");
|
|
|
|
|
var portRlt = GetPortEDICode(order.DeliveryPlaceId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DeliveryPlace, "交货地", needMappingModule);
|
|
|
|
|
|
|
|
|
|
if (portRlt.Succeeded)
|
|
|
|
|
primaryModel.PLACEDELIVERYID = portRlt.Data;
|
|
|
|
@ -1242,7 +1249,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
//目的地
|
|
|
|
|
if (order.DeliveryPlaceId > 0)
|
|
|
|
|
{
|
|
|
|
|
var portRlt = GetPortEDICode(order.DeliveryPlaceId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DischargePort, "目的地");
|
|
|
|
|
var portRlt = GetPortEDICode(order.DeliveryPlaceId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DischargePort, "交货地", needMappingModule);
|
|
|
|
|
|
|
|
|
|
if (portRlt.Succeeded)
|
|
|
|
|
primaryModel.DESTINATIONID = portRlt.Data;
|
|
|
|
@ -1255,7 +1262,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
//目的地
|
|
|
|
|
if (order.DestinationId > 0)
|
|
|
|
|
{
|
|
|
|
|
var portRlt = GetPortEDICode(order.DestinationId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DischargePort, "目的地");
|
|
|
|
|
var portRlt = GetPortEDICode(order.DestinationId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.DischargePort, "目的地", needMappingModule);
|
|
|
|
|
|
|
|
|
|
if (portRlt.Succeeded)
|
|
|
|
|
primaryModel.DESTINATIONID = portRlt.Data;
|
|
|
|
@ -1268,7 +1275,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
//到付地点
|
|
|
|
|
if (order.PayableAtId > 0)
|
|
|
|
|
{
|
|
|
|
|
var portRlt = GetPortEDICode(order.PayableAtId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.PayableAt, "到付地点");
|
|
|
|
|
var portRlt = GetPortEDICode(order.PayableAtId, portList, mapPortList, order.CarrierId, CONST_MAPPING_MODULE, order.PayableAt, "到付地点", needMappingModule);
|
|
|
|
|
|
|
|
|
|
if (portRlt.Succeeded)
|
|
|
|
|
primaryModel.PAYABLEATID = portRlt.Data;
|
|
|
|
@ -1302,30 +1309,31 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/*
|
|
|
|
|
1、先默认取映射,如果没有映射配置,默认取基础表EdiCode
|
|
|
|
|
*/
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(order.MBLFrt))
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(order.MBLFrtCode))
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
var codeInfo = tenantDb.Queryable<CodeFrt>().First(x => x.Status == StatusEnum.Enable && x.EdiCode == order.MBLFrtCode);
|
|
|
|
|
|
|
|
|
|
if (mapInfo != null)
|
|
|
|
|
if (codeInfo != null)
|
|
|
|
|
{
|
|
|
|
|
primaryModel.BLFRTEDICODE = mapInfo.MapCode?.Trim();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var codeInfo = tenantDb.Queryable<CodeFrt>().First(x => x.Status == StatusEnum.Enable && x.Id == mblFrt);
|
|
|
|
|
//primaryModel.BLFRTEDICODE = codeInfo.EdiCode;
|
|
|
|
|
primaryModel.BLFRT = codeInfo.FrtName;
|
|
|
|
|
|
|
|
|
|
if (codeInfo != null && !string.IsNullOrWhiteSpace(codeInfo.EdiCode))
|
|
|
|
|
var mapInfo = tenantDb.Queryable<MappingFrt>().First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
&& t.CarrierId == order.CarrierId && t.LinkId == codeInfo.Id);
|
|
|
|
|
|
|
|
|
|
if (mapInfo != null)
|
|
|
|
|
{
|
|
|
|
|
primaryModel.BLFRTEDICODE = codeInfo.EdiCode;
|
|
|
|
|
primaryModel.BLFRTEDICODE = mapInfo.MapCode?.Trim();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult<string>.Failed($"付费方式{order.MBLFrt}的基础代码未找到");
|
|
|
|
|
primaryModel.BLFRTEDICODE = codeInfo.EdiCode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult<string>.Failed($"付费方式{order.MBLFrt}的基础代码未找到");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1335,31 +1343,33 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
|
|
#region 运输条款EDI
|
|
|
|
|
//运输条款EDI
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(order.Service))
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(order.ServiceCode))
|
|
|
|
|
{
|
|
|
|
|
long serviceId = long.Parse(order.Service);
|
|
|
|
|
//long serviceId = long.Parse(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 codeInfo = tenantDb.Queryable<CodeService>().First(x => x.Status == StatusEnum.Enable && x.EdiCode == order.ServiceCode);
|
|
|
|
|
|
|
|
|
|
if(mapInfo != null)
|
|
|
|
|
if (codeInfo != null)
|
|
|
|
|
{
|
|
|
|
|
primaryModel.SERVICEEDICODE = mapInfo.MapCode;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//运输条款EDI
|
|
|
|
|
var codeService = tenantDb.Queryable<CodeService>().First(x => x.Status == StatusEnum.Enable && x.Id == serviceId);
|
|
|
|
|
//primaryModel.BLFRTEDICODE = codeInfo.EdiCode;
|
|
|
|
|
primaryModel.SERVICE = codeInfo.ServiceName;
|
|
|
|
|
|
|
|
|
|
if (codeService != null && !string.IsNullOrWhiteSpace(codeService.EdiCode))
|
|
|
|
|
var mapInfo = tenantDb.Queryable<MappingService>().First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
&& t.CarrierId == order.CarrierId && t.LinkId == codeInfo.Id);
|
|
|
|
|
|
|
|
|
|
if (mapInfo != null)
|
|
|
|
|
{
|
|
|
|
|
primaryModel.SERVICEEDICODE = codeService.EdiCode;
|
|
|
|
|
primaryModel.SERVICEEDICODE = mapInfo.MapCode?.Trim();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult<string>.Failed($"运输条款{order.Service}的基础代码未找到");
|
|
|
|
|
primaryModel.SERVICEEDICODE = codeInfo.EdiCode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult<string>.Failed($"运输条款{order.MBLFrt}的基础代码未找到");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -1415,16 +1425,19 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//2023-06-15 按照沟通要求,如果主提单号为空,并且订舱编号不为空,可以去订舱编号填入主提单号
|
|
|
|
|
if (string.IsNullOrWhiteSpace(primaryModel.MBLNO))
|
|
|
|
|
if (ediRouteEnum != EDIRouteEnum.INTTRA)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(order.CustomerNo))
|
|
|
|
|
//2023-06-15 按照沟通要求,如果主提单号为空,并且订舱编号不为空,可以去订舱编号填入主提单号
|
|
|
|
|
if (string.IsNullOrWhiteSpace(primaryModel.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
_logger.Info("批次={no} 主题单号为空 MBLNO={mblno} 取订舱编号补到主提单号 custno={custno}", batchNo, primaryModel.MBLNO, order.CustomerNo);
|
|
|
|
|
|
|
|
|
|
if (req.SendType.Equals("B", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(order.CustomerNo))
|
|
|
|
|
{
|
|
|
|
|
primaryModel.MBLNO = order.CustomerNo;
|
|
|
|
|
_logger.Info("批次={no} 主题单号为空 MBLNO={mblno} 取订舱编号补到主提单号 custno={custno}", batchNo, primaryModel.MBLNO, order.CustomerNo);
|
|
|
|
|
|
|
|
|
|
if (req.SendType.Equals("B", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
primaryModel.MBLNO = order.CustomerNo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1442,6 +1455,9 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
|
|
var portRlt = GetPackageEDICode(packageId, codePackageList, mapPackageList, order.CarrierId, CONST_MAPPING_MODULE);
|
|
|
|
|
|
|
|
|
|
if (codePackageList.Any(b => b.Id == packageId))
|
|
|
|
|
primaryModel.KINDPKGS = codePackageList.FirstOrDefault(b => b.Id == packageId).PackageName;
|
|
|
|
|
|
|
|
|
|
if (portRlt.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
primaryModel.KINDPKGS_EDI_CODE = portRlt.Data;
|
|
|
|
@ -1550,6 +1566,12 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
primaryModel.ETA = primaryModel.ETD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ediRouteEnum == EDIRouteEnum.INTTRA)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(ediExtModel.CustomerName))
|
|
|
|
|
primaryModel.WEITUO = ediExtModel.CustomerName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
primaryModel.KINGTAREWEIGHT = ediExtModel.KingTareweight.HasValue ? ediExtModel.KingTareweight.Value : 0;
|
|
|
|
|
|
|
|
|
|
_logger.Info("批次={no} 提取箱完成 数量={total}", batchNo, contaList.Count);
|
|
|
|
@ -1582,9 +1604,12 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
|
|
var mapRlt = GetPackageEDICode(packageId, codePackageList, mapPackageList, order.CarrierId, CONST_MAPPING_MODULE);
|
|
|
|
|
|
|
|
|
|
if (codePackageList.Any(b => b.Id == packageId))
|
|
|
|
|
contaModel.KINDPKGS = codePackageList.FirstOrDefault(b => b.Id == packageId).PackageName;
|
|
|
|
|
|
|
|
|
|
if (mapRlt.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
primaryModel.KINDPKGS_EDI_CODE = mapRlt.Data;
|
|
|
|
|
contaModel.KINDPKGS_EDI_CODE = mapRlt.Data;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1615,6 +1640,9 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
|
|
var mapRlt = GetPackageEDICode(packageId, codePackageList, mapPackageList, order.CarrierId, CONST_MAPPING_MODULE);
|
|
|
|
|
|
|
|
|
|
if (codePackageList.Any(b => b.Id == packageId))
|
|
|
|
|
cargoModel.KINDPKGS = codePackageList.FirstOrDefault(b => b.Id == packageId).PackageName;
|
|
|
|
|
|
|
|
|
|
if (mapRlt.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
cargoModel.KINDPKGS_EDI_CODE = mapRlt.Data;
|
|
|
|
@ -2413,9 +2441,11 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// <param name="moduleName">模块代码</param>
|
|
|
|
|
/// <param name="portName">港口名称</param>
|
|
|
|
|
/// <param name="portCategory">港口分类(装货港、卸货港、交货地等)</param>
|
|
|
|
|
/// <param name="isNeedMapping">是否必需用映射</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)
|
|
|
|
|
private DataResult<string> GetPortEDICode(long portId,List<CodePort> codePortList,List<MappingPort> mapPortList, long carrierId, string moduleName,
|
|
|
|
|
string portName,string portCategory,string needMappingModule = "")
|
|
|
|
|
{
|
|
|
|
|
//如果历史港口映射有记录直接返回
|
|
|
|
|
if (mapPortList.Any(a => a.LinkId == portId))
|
|
|
|
@ -2430,8 +2460,15 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
string MappingModule = CONST_MAPPING_MODULE;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(needMappingModule))
|
|
|
|
|
{
|
|
|
|
|
MappingModule = needMappingModule;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mapPortInfo = tenantDb.Queryable<MappingPort>()
|
|
|
|
|
.First(a => a.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && a.CarrierId == carrierId && a.LinkId == portId);
|
|
|
|
|
.First(a => a.Module.Equals(MappingModule, StringComparison.OrdinalIgnoreCase) && a.CarrierId == carrierId && a.LinkId == portId);
|
|
|
|
|
|
|
|
|
|
if (mapPortInfo != null)
|
|
|
|
|
{
|
|
|
|
@ -2442,6 +2479,11 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
|
|
return DataResult<string>.FailedData(mapPortInfo.MapCode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(needMappingModule))
|
|
|
|
|
throw new Exception($"{portCategory} {portName} 未配置模块{needMappingModule} 映射");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (codePortList.Any(a => a.Id == portId))
|
|
|
|
|
{
|
|
|
|
@ -2548,6 +2590,16 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private DataResult<string> GetPackageEDICode(long packageCodeId, List<CodePackage> codePackageList, List<MappingPackage> mapPackageList, long carrierId, string moduleName)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
if (!codePackageList.Any(b => b.Id == packageCodeId))
|
|
|
|
|
{
|
|
|
|
|
var codePackage = tenantDb.Queryable<CodePackage>().First(a => a.Id == packageCodeId);
|
|
|
|
|
|
|
|
|
|
if (codePackage != null)
|
|
|
|
|
codePackageList.Add(codePackage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//如果历史港口映射有记录直接返回
|
|
|
|
|
if (mapPackageList.Any(a => a.LinkId == packageCodeId))
|
|
|
|
|
{
|
|
|
|
@ -2559,7 +2611,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
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);
|
|
|
|
|