booking_auth_dev
wanghaomei 2 years ago
commit 1f53908b3a

@ -90,7 +90,7 @@ namespace Myshipping.Application.EDI.PIL
string Shipping = str;
if (fileType == "txt")
{
Shipping = formatEdiStr("txt", str);
//Shipping = formatEdiStr("txt", str);
}
else if (fileType == "xml")
{
@ -1648,7 +1648,7 @@ namespace Myshipping.Application.EDI.PIL
//4 //Filler//M//X(127)//124 //250 //Spaces
r.WriteLine(GetSpaceStr(tempstr, 250));
if (bill.ACIHBL != "")
if (!string.IsNullOrWhiteSpace(bill.ACIHBL))
{
tempstr = "73";//1 //RECORD_ID//M//9(2)//1 //2 //73
tempstr += "B";//2 //Remarks_indicator//M//X(1)//3 //3 //O-Onhold, B-Booking, C-Customs, M-Manifest, X-Special, A-Additional, G-General, T-Transhipment, E-EDI //"73B,必填内容1SALES REP CODE;2ACI HBL 1,2,3加拿大线的HBL3) 货物混装描述 S0C+C0C)"//分三行
@ -1657,7 +1657,7 @@ namespace Myshipping.Application.EDI.PIL
r.WriteLine(GetSpaceStr(tempstr, 250));
}
if (bill.S0CC0C != "")
if (!string.IsNullOrWhiteSpace(bill.S0CC0C))
{
tempstr = "73";//1 //RECORD_ID//M//9(2)//1 //2 //73
tempstr += "B";//2 //Remarks_indicator//M//X(1)//3 //3 //O-Onhold, B-Booking, C-Customs, M-Manifest, X-Special, A-Additional, G-General, T-Transhipment, E-EDI //"73B,必填内容1SALES REP CODE;2ACI HBL 1,2,3加拿大线的HBL3) 货物混装描述 S0C+C0C)"//分三行
@ -1720,7 +1720,7 @@ namespace Myshipping.Application.EDI.PIL
tempstr = "74";//1//RECORD-ID//M//9(2)//1//2//74//
tempstr += GetSpaceStr("", 3);//2//Filler//O//X(3)//3//5//Spaces//
tempstr += GetSpaceStr(bill.ISSUEPLACEID, 5);//3//Place of BL issue//M//X(5)//6//10//webCSM Port code (Port of BL Issuance)//提单签发地//webcsm港口代码BL发行端口
if (bill.ISSUEDATE.ToString().Trim() == "")
if (string.IsNullOrWhiteSpace(bill.ISSUEDATE))
{
tempstr += GetSpaceStr("", 8);//4//Date of BL issue//M//X(8)//11//18//YYYYMMDD//提单签发日期//年月日
}

@ -8757,7 +8757,7 @@
请求规则平台
</summary>
</member>
<member name="M:Myshipping.Application.RulesEngineClientService.#ctor(Myshipping.Core.SqlSugarRepository{Myshipping.Application.Entity.BookingOrder},Myshipping.Core.SqlSugarRepository{Myshipping.Application.Entity.BookingCtn},Myshipping.Core.SqlSugarRepository{Myshipping.Application.Entity.BookingCtnDetail},Myshipping.Core.Service.ISysCacheService)">
<member name="M:Myshipping.Application.RulesEngineClientService.#ctor(Myshipping.Core.SqlSugarRepository{Myshipping.Application.Entity.BookingOrder},Myshipping.Core.SqlSugarRepository{Myshipping.Application.Entity.BookingCtn},Myshipping.Core.SqlSugarRepository{Myshipping.Application.Entity.BookingCtnDetail},Myshipping.Core.Service.ISysCacheService,Myshipping.Core.SqlSugarRepository{Myshipping.Core.Entity.RelaPortCarrierLane})">
<summary>
</summary>
@ -8783,6 +8783,13 @@
<param name="model">海运订舱报文类</param>
<returns>返回回执</returns>
</member>
<member name="M:Myshipping.Application.RulesEngineClientService.GetMessageInfo(Myshipping.Application.RulesEngineOrderBookingMainBusinessInfo)">
<summary>
生成请求规则报文
</summary>
<param name="mainInfo">订舱主业务信息</param>
<returns>返回请求报文类</returns>
</member>
<member name="M:Myshipping.Application.RulesEngineClientService.ExcuteRulesEngine(Myshipping.Application.RulesEngineOrderBookingMessageInfo)">
<summary>
请求规则平台

@ -1983,6 +1983,9 @@ namespace Myshipping.Application
if (ediExtModel == null)
throw Oops.Bah($"获取EDI信息失败");
if (string.IsNullOrWhiteSpace(ediExtModel.OpEName))
throw Oops.Bah("未填写(EDI并补充信息)操作英文名称");
CheckBookingOrClosingEDI(order);
EDIRouteEnum ediRouteEnum = GetEDIRoute(order.CARRIERID);
@ -2006,6 +2009,9 @@ namespace Myshipping.Application
if (ediSOSICfg == null || string.IsNullOrWhiteSpace(ediSOSICfg.MapCode))
throw Oops.Bah($"CARRIERID={order.CARRIERID} 发送SO(SI)的船公司EDI代码未找到");
var ediModel = new EDIBaseModel();
var ftpSet = _cache.GetAllEdiSetting().GetAwaiter().GetResult()
@ -2024,7 +2030,7 @@ namespace Myshipping.Application
//读取文件配置
var fileCfg = App.GetOptions<BookingAttachOptions>();
string filePath = $"{Path.Combine(!string.IsNullOrWhiteSpace(fileCfg.basePath) ? fileCfg.basePath : App.WebHostEnvironment.WebRootPath, fileCfg.relativePath)}/edifiles/{order.BSNO}";
string filePath = $"{Path.Combine(!string.IsNullOrWhiteSpace(fileCfg.basePath) ? fileCfg.basePath : App.WebHostEnvironment.WebRootPath, fileCfg.relativePath)}\\edifiles\\{order.BSNO}";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
filePath = filePath.Replace("\\", "/");
@ -2045,7 +2051,23 @@ namespace Myshipping.Application
var primaryModel = order.Adapt<MsOpSeaeEDIBaseModel>();
//场站
var ediYardList = _cache.GetAllMappingYard().GetAwaiter().GetResult()
.Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)).ToList();
if (!string.IsNullOrWhiteSpace(order.YARDID))
{
var currYardInfo = ediYardList.FirstOrDefault(t => t.Code.Equals(order.YARDID, StringComparison.OrdinalIgnoreCase));
if (currYardInfo == null)
throw Oops.Bah($"场站{order.YARDID}的EDI代码未找到");
primaryModel.YARDEDICODE = currYardInfo.MapCode?.Trim();
primaryModel.YARD = currYardInfo.MapName?.Trim();
}
primaryModel.CARRIEREDICODE = ediSOSICfg.MapCode;
primaryModel.ORDERNO = order.BOOKINGNO;
var ediPkgs = ediPkgsList.FirstOrDefault(x => x.Code.Equals(order.KINDPKGS, StringComparison.OrdinalIgnoreCase));
@ -2073,6 +2095,8 @@ namespace Myshipping.Application
primaryModel.AMSCONSIGNEE = ediExtModel.AMSConsignee;
primaryModel.AMSNOTIFYPARTY = ediExtModel.AMSNotifyParty;
primaryModel.OpEName = ediExtModel.OpEName;
primaryModel.OpTel = ediExtModel.OpTel;
primaryModel.OpEmail = ediExtModel.OpEmail;
@ -2104,7 +2128,7 @@ namespace Myshipping.Application
if (currConta == null)
throw Oops.Oh($"集装箱包装{conta.KINDPKGS}的EDI代码未找到");
contaModel.KINDPKGS_EDI_CODE = ediContaPkgs.MapCode;
contaModel.KINDPKGS_EDI_CODE = ediContaPkgs.MapCode?.Trim();
primaryModel.CTNLIST.Add(contaModel);
}
@ -2125,13 +2149,11 @@ namespace Myshipping.Application
if (ediDetailPkgs == null)
throw Oops.Oh($"货明细的包装{cargo.KINDPKGS}的EDI代码未找到");
cargoModel.KINDPKGS_EDI_CODE = ediDetailPkgs.MapCode;
cargoModel.KINDPKGS_EDI_CODE = ediDetailPkgs.MapCode?.Trim();
primaryModel.CTNGOODSLIST.Add(cargoModel);
}
ediModel.BSLIST.Add(primaryModel);
var result = await InnerSendBookingOrClosingEDI(model, ediModel, ediRouteEnum);
@ -2345,8 +2367,8 @@ namespace Myshipping.Application
if (string.IsNullOrWhiteSpace(order.CARRIERID))
throw Oops.Bah("船公司必须填写");
if (string.IsNullOrWhiteSpace(order.OPID))
throw Oops.Bah("未填写操作人");
//if (string.IsNullOrWhiteSpace(order.OPID))
// throw Oops.Bah("未填写操作人");
if (string.IsNullOrWhiteSpace(order.KINDPKGS))
throw Oops.Bah("包装种类未填写");

@ -20,7 +20,7 @@ namespace Myshipping.Application
.Map(dest => dest.BLFRT, src => src.BLFRT)
.Map(dest => dest.VESSEL, src => src.VESSEL)
.Map(dest => dest.VOYNO, src => src.VOYNO)
.Map(dest => dest.ETD, src => src.ETD.HasValue? src.ETD.Value.ToString("yyyy-MM-dd"):"")
.Map(dest => dest.ETD, src => src.ETD.HasValue ? src.ETD.Value.ToString("yyyy-MM-dd") : "")
.Map(dest => dest.SIREMARK, src => src.SIREMARK)
.Map(dest => dest.SHIPPER, src => src.SHIPPER)
.Map(dest => dest.CONSIGNEE, src => src.CONSIGNEE)
@ -35,7 +35,7 @@ namespace Myshipping.Application
.Map(dest => dest.PORTDISCHARGE, src => src.PORTDISCHARGE)
.Map(dest => dest.DESTINATIONID, src => src.DESTINATIONID)
.Map(dest => dest.DESTINATION, src => src.DESTINATION)
.Map(dest => dest.PKGS, src => src.PKGS.HasValue? src.PKGS.Value:0)
.Map(dest => dest.PKGS, src => src.PKGS.HasValue ? src.PKGS.Value : 0)
.Map(dest => dest.KINDPKGS, src => src.KINDPKGS)
.Map(dest => dest.KGS, src => src.KGS.HasValue ? src.KGS.Value : 0)
.Map(dest => dest.CBM, src => src.CBM.HasValue ? src.CBM.Value : 0)

@ -34,6 +34,9 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingCtn> _bookingOrderContaRepository;
private readonly SqlSugarRepository<BookingCtnDetail> _bookingOrderContaCargoRepository;
private readonly ISysCacheService _cache;
private readonly SqlSugarRepository<RelaPortCarrierLane> _relaPortCarrierLaneRep;
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
/// <summary>
///
@ -41,12 +44,14 @@ namespace Myshipping.Application
public RulesEngineClientService(SqlSugarRepository<BookingOrder> bookingOrderRepository,
SqlSugarRepository<BookingCtn> bookingOrderContaRepository,
SqlSugarRepository<BookingCtnDetail> bookingOrderContaCargoRepository,
ISysCacheService cache)
ISysCacheService cache,
SqlSugarRepository<RelaPortCarrierLane> relaPortCarrierLaneRep)
{
_bookingOrderRepository = bookingOrderRepository;
_bookingOrderContaRepository = bookingOrderContaRepository;
_bookingOrderContaCargoRepository = bookingOrderContaCargoRepository;
_cache = cache;
_relaPortCarrierLaneRep = relaPortCarrierLaneRep;
}
#region 海运订舱请求规则引擎校验
@ -110,42 +115,22 @@ namespace Myshipping.Application
if (model == null)
throw Oops.Oh($"订舱主键{bookingId}无法获取业务信息");
RulesEngineOrderBookingMessageInfo msgModel = new RulesEngineOrderBookingMessageInfo();
msgModel.Head = new RulesEngineWebAPIHeadBase
{
GID = IDGen.NextID().ToString(),
MessageType = "BUSI_RULE",
SenderId = App.Configuration["RulesEngineSender"],
SenderName = App.Configuration["RulesEngineSenderName"],
SenderKey = App.Configuration["RulesEngineAuthKey"],
ReceiverId = "RulesEngine",
ReceiverName = "大简云规则引擎",
Version = "1.0",
RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss"),
RequestAction = "CheckRule",
};
msgModel.Main = new RulesEngineOrderBookingMainInfo {
ProjectCode = App.Configuration["RulesEngineProjects"].Split(new char[] { ','}).ToArray(),
};
msgModel.Main.BusinessInfo = model.Adapt<RulesEngineOrderBookingMainBusinessInfo>();
var mainInfo = model.Adapt<RulesEngineOrderBookingMainBusinessInfo>();
var contaList = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == model.Id).ToListAsync();
if (contaList.Count > 0)
{
msgModel.Main.BusinessInfo.ContaList = contaList.Adapt<List<RulesEngineOrderBookingContaInfo>>();
mainInfo.ContaList = contaList.Adapt<List<RulesEngineOrderBookingContaInfo>>();
var ctnArg = contaList.Select(t => t.Id).ToArray();
var cargoList = await _bookingOrderContaCargoRepository.AsQueryable()
.Where(x=> ctnArg.Contains(x.CTNID.Value)).ToListAsync();
var cargoList = await _bookingOrderContaCargoRepository.AsQueryable()
.Where(x => ctnArg.Contains(x.CTNID.Value)).ToListAsync();
if(cargoList.Count > 0)
if (cargoList.Count > 0)
{
msgModel.Main.BusinessInfo.ContaList = contaList.GroupJoin(cargoList, l => l.Id, r => r.CTNID, (l, r) => {
mainInfo.ContaList = contaList.GroupJoin(cargoList, l => l.Id, r => r.CTNID, (l, r) => {
var currList = r.ToList();
if (currList.Count > 0)
@ -162,11 +147,13 @@ namespace Myshipping.Application
}
else
{
msgModel.Main.BusinessInfo.ContaList = contaList.Adapt<List<RulesEngineOrderBookingContaInfo>>();
mainInfo.ContaList = contaList.Adapt<List<RulesEngineOrderBookingContaInfo>>();
}
}
var msgModel = GetMessageInfo(mainInfo);
var ruleResult = await ExcuteRulesEngine(msgModel);
if(ruleResult == null)
@ -218,91 +205,10 @@ namespace Myshipping.Application
{
DateTime nowDate = DateTime.Now;
//var model =
//if()
// _bookingOrderRepository.AsQueryable().InSingle(bookingId);
//if (model == null)
// throw Oops.Oh($"订舱主键{bookingId}无法获取业务信息");
RulesEngineOrderBookingMessageInfo msgModel = new RulesEngineOrderBookingMessageInfo();
msgModel.Head = new RulesEngineWebAPIHeadBase
{
GID = IDGen.NextID().ToString(),
MessageType = "BUSI_RULE",
SenderId = App.Configuration["RulesEngineSender"],
SenderName = App.Configuration["RulesEngineSenderName"],
SenderKey = App.Configuration["RulesEngineAuthKey"],
ReceiverId = "RulesEngine",
ReceiverName = "大简云规则引擎",
Version = "1.0",
RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss"),
RequestAction = "CheckRule",
};
msgModel.Main = new RulesEngineOrderBookingMainInfo
{
ProjectCode = App.Configuration["RulesEngineProjects"].Split(new char[] { ',' }).ToArray(),
};
msgModel.Main.BusinessInfo = model.Adapt<RulesEngineOrderBookingMainBusinessInfo>();
//根据卸货港翻译航线信息
if(!string.IsNullOrWhiteSpace(model.PORTDISCHARGEID))
{
var laneList = _cache.GetAllRelaPortCarrierLane().GetAwaiter().GetResult();
var laneInfo = laneList
.FirstOrDefault(p => !string.IsNullOrWhiteSpace(model.CARRIER) && !string.IsNullOrWhiteSpace(p.CarrierCode) &&
p.CarrierCode.Equals(model.CARRIER, StringComparison.OrdinalIgnoreCase) && p.PortCode.Equals(model.PORTDISCHARGEID, StringComparison.OrdinalIgnoreCase));
var mainInfo = model.Adapt<RulesEngineOrderBookingMainBusinessInfo>();
if(laneInfo == null)
laneInfo = laneList.FirstOrDefault(p => string.IsNullOrWhiteSpace(p.CarrierCode) && p.PortCode.Equals(model.PORTDISCHARGEID, StringComparison.OrdinalIgnoreCase));
RulesEngineOrderBookingMessageInfo msgModel = GetMessageInfo(mainInfo);
if (laneInfo != null)
{
var lineModel = _cache.GetAllCodeLane().GetAwaiter().GetResult().FirstOrDefault(t => t.Code.Equals(laneInfo.LaneCode, StringComparison.OrdinalIgnoreCase));
msgModel.Main.BusinessInfo.LaneCode = laneInfo.LaneCode;
msgModel.Main.BusinessInfo.LaneName = lineModel?.CnName;
}
}
var contaList = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == model.Id).ToListAsync();
if (contaList.Count > 0)
{
msgModel.Main.BusinessInfo.ContaList = contaList.Adapt<List<RulesEngineOrderBookingContaInfo>>();
var cargoList = await _bookingOrderContaCargoRepository.AsQueryable()
.Where(x => contaList.Any(a => a.Id == x.CTNID)).ToListAsync();
if (cargoList.Count > 0)
{
msgModel.Main.BusinessInfo.ContaList = contaList.GroupJoin(cargoList, l => l.Id, r => r.CTNID, (l, r) =>
{
var currList = r.ToList();
if (currList.Count > 0)
{
var info = l.Adapt<RulesEngineOrderBookingContaInfo>();
info.CargoList = currList.Adapt<List<RulesEngineOrderBookingContaCargoInfo>>();
return info;
}
return l.Adapt<RulesEngineOrderBookingContaInfo>();
}).ToList();
}
else
{
msgModel.Main.BusinessInfo.ContaList = contaList.Adapt<List<RulesEngineOrderBookingContaInfo>>();
}
}
var ruleResult = await ExcuteRulesEngine(msgModel);
if (ruleResult == null)
@ -330,12 +236,95 @@ namespace Myshipping.Application
}
#endregion
/// <summary>
/// 生成请求规则报文
/// </summary>
/// <param name="mainInfo">订舱主业务信息</param>
/// <returns>返回请求报文类</returns>
[NonAction]
private RulesEngineOrderBookingMessageInfo GetMessageInfo(RulesEngineOrderBookingMainBusinessInfo mainInfo)
{
DateTime nowDate = DateTime.Now;
RulesEngineOrderBookingMessageInfo msgModel = new RulesEngineOrderBookingMessageInfo();
msgModel.Head = new RulesEngineWebAPIHeadBase
{
GID = IDGen.NextID().ToString(),
MessageType = "BUSI_RULE",
SenderId = App.Configuration["RulesEngineSender"],
SenderName = App.Configuration["RulesEngineSenderName"],
SenderKey = App.Configuration["RulesEngineAuthKey"],
ReceiverId = "RulesEngine",
ReceiverName = "大简云规则引擎",
Version = "1.0",
RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss"),
RequestAction = "CheckRule",
};
msgModel.Main = new RulesEngineOrderBookingMainInfo
{
ProjectCode = App.Configuration["RulesEngineProjects"].Split(new char[] { ',' }).ToArray(),
};
msgModel.Main.BusinessInfo = mainInfo;
//根据卸货港翻译航线信息
if (!string.IsNullOrWhiteSpace(mainInfo.PortDischargeId))
{
var laneList = _cache.GetAllRelaPortCarrierLane().GetAwaiter().GetResult();
var laneInfo = laneList
.FirstOrDefault(p => !string.IsNullOrWhiteSpace(mainInfo.CarrierId) && !string.IsNullOrWhiteSpace(p.CarrierCode) &&
p.CarrierCode.Equals(mainInfo.CarrierId, StringComparison.OrdinalIgnoreCase) && p.PortCode.Equals(mainInfo.PortDischargeId, StringComparison.OrdinalIgnoreCase));
if (laneInfo == null)
laneInfo = laneList.FirstOrDefault(p => string.IsNullOrWhiteSpace(p.CarrierCode) && p.PortCode.Equals(mainInfo.PortDischargeId, StringComparison.OrdinalIgnoreCase));
if (laneInfo != null)
{
var lineModel = _cache.GetAllCodeLane().GetAwaiter().GetResult().FirstOrDefault(t => t.Code.Equals(laneInfo.LaneCode, StringComparison.OrdinalIgnoreCase));
msgModel.Main.BusinessInfo.LaneCode = laneInfo.LaneCode;
msgModel.Main.BusinessInfo.LaneName = lineModel?.CnName;
}
}
//对应签单方式
if (!string.IsNullOrWhiteSpace(mainInfo.IssueType))
{
var issueType = _cache.GetAllCodeIssueType().GetAwaiter().GetResult().FirstOrDefault(p => p.EnName.Equals(mainInfo.IssueType, StringComparison.OrdinalIgnoreCase));
//这里规则约定用了签单方式的代码大写
if (issueType != null)
msgModel.Main.BusinessInfo.IssueType = issueType.Code.ToUpper();
}
if (mainInfo.ContaList != null && mainInfo.ContaList.Count > 0)
{
var contaList = _cache.GetAllMappingCtn().GetAwaiter().GetResult();
mainInfo.ContaList.ForEach(t =>
{
var currContaType = contaList.FirstOrDefault(x => x.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase)
&& x.Code.Equals(t.ContaType, StringComparison.OrdinalIgnoreCase));
if (currContaType != null)
{
t.ContaType = currContaType.MapCode?.ToUpper();
}
});
}
return msgModel;
}
#region 请求规则平台
/// <summary>
/// 请求规则平台
/// </summary>
/// <param name="BusinessMsg"></param>
/// <returns></returns>
[NonAction]
private async Task<RulesEngineWebApiResult> ExcuteRulesEngine(RulesEngineOrderBookingMessageInfo info)
{
RulesEngineWebApiResult model = null;

Loading…
Cancel
Save