From f48469da6417ae92a516da5c0467a5c250389d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ZR20090193-=E9=99=88=E6=95=AC=E5=8B=87?= Date: Tue, 25 Jun 2024 17:44:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E5=A4=A7=E7=AE=80=E4=BA=91?= =?UTF-8?q?=E8=A7=84=E5=88=99=E5=BC=95=E6=93=8E=E5=8F=8AOCR=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constants/MultiLanguageConst.cs | 3 + .../DS.Module.DjyRulesEngine.csproj | 14 + .../IRuleEngineService.cs | 18 + .../RuleEngineHttpUtil.cs | 261 ++++++ .../RuleEngineModuleInstall.cs | 27 + .../DS.Module.DjyRulesEngine/RuleEngineReq.cs | 113 +++ .../RuleEngineResult.cs | 114 +++ .../RuleEngineService.cs | 63 ++ ...RulesEngineOrderBookingMainBusinessInfo.cs | 797 ++++++++++++++++++ ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj | 1 + .../Op/Interface/ISeaExportService.cs | 9 + .../Op/Method/SeaExportCommonService.cs | 2 +- .../Op/Method/SeaExportOcrService.cs | 46 +- .../Op/Method/SeaExportRuleEngineService.cs | 58 ++ .../DS.WMS.Core/Op/Method/SeaExportService.cs | 119 ++- .../Controllers/SeaExportController.cs | 20 +- .../DS.WMS.OpApi/DS.WMS.OpApi.csproj | 1 + ds-wms-service/DS.WMS.OpApi/Program.cs | 2 + ds-wms-service/DS.WMS.OpApi/appsettings.json | 6 + ds-wms-service/ds-wms-service.sln | 9 +- 20 files changed, 1673 insertions(+), 10 deletions(-) create mode 100644 ds-wms-service/DS.Module.DjyRulesEngine/DS.Module.DjyRulesEngine.csproj create mode 100644 ds-wms-service/DS.Module.DjyRulesEngine/IRuleEngineService.cs create mode 100644 ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineHttpUtil.cs create mode 100644 ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineModuleInstall.cs create mode 100644 ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineReq.cs create mode 100644 ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineResult.cs create mode 100644 ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineService.cs create mode 100644 ds-wms-service/DS.Module.DjyRulesEngine/RulesEngineOrderBookingMainBusinessInfo.cs create mode 100644 ds-wms-service/DS.WMS.Core/Op/Method/SeaExportRuleEngineService.cs diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index 0a784ba9..b879ba35 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -437,6 +437,9 @@ public static class MultiLanguageConst [Description("请先选择场站!")] public const string SeaExportYardCheck = "Sea_Export_Yard_Check"; + [Description("海运出口规则引擎校验完成!")] + public const string SeaExportRuleEngineFinished = "Sea_Export_RuleEngine_Finished"; + [Description("海运出口存在费用信息")] public const string SeaExportFeeExist = "Sea_Export_Fee_Exist"; diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/DS.Module.DjyRulesEngine.csproj b/ds-wms-service/DS.Module.DjyRulesEngine/DS.Module.DjyRulesEngine.csproj new file mode 100644 index 00000000..b3971ede --- /dev/null +++ b/ds-wms-service/DS.Module.DjyRulesEngine/DS.Module.DjyRulesEngine.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/IRuleEngineService.cs b/ds-wms-service/DS.Module.DjyRulesEngine/IRuleEngineService.cs new file mode 100644 index 00000000..868d9745 --- /dev/null +++ b/ds-wms-service/DS.Module.DjyRulesEngine/IRuleEngineService.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.Module.DjyRulesEngine +{ + public interface IRuleEngineService + { + /// + /// 执行海运出口规则引擎校验 + /// + /// 修改服务状态详情 + /// 返回回执 + public Task ExcuteRulesOceanBooking(RuleEngineReq req); + } +} diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineHttpUtil.cs b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineHttpUtil.cs new file mode 100644 index 00000000..a1360238 --- /dev/null +++ b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineHttpUtil.cs @@ -0,0 +1,261 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Security; +using System.Net; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; + +namespace DS.Module.DjyRulesEngine +{ + /// + /// 大简云规则引擎服务封装请求工具类 + /// + public class RuleEngineHttpUtil + { + + /// 平台ip + /// + private static string _ip; + + /// + /// 平台端口 + /// + private static int _port = 443; + + /// + /// 平台APPKey + /// + private static string _appkey; + + /// + /// 平台APPSecret + /// + private static string _secret; + + /// + /// 是否使用HTTPS协议 + /// + private static bool _isHttps = true; + + /// + /// 设置信息参数 + /// + /// 合作方APPKey + /// 合作方APPSecret + /// 平台IP + /// 平台端口,默认HTTPS的443端口 + /// 是否启用HTTPS协议,默认HTTPS + /// string appkey, string secret, + public static void SetPlatformInfo(string ip, int port = 443, bool isHttps = true) + { + //_appkey = appkey; + //_secret = secret; + _ip = ip; + _port = port; + _isHttps = isHttps; + + // 设置并发数,如不设置默认为2 + ServicePointManager.DefaultConnectionLimit = 512; + } + /// + /// HTTP GET请求 + /// + /// HTTP接口Url,不带协议和端口,如/artemis/api/resource/v1/cameras/indexCode?cameraIndexCode=a10cafaa777c49a5af92c165c95970e0 + /// 请求超时时间,单位:秒 + /// + public static string HttpGet(string uri, int timeout) + { + Dictionary header = new Dictionary(); + + // 初始化请求:组装请求头,设置远程证书自动验证通过 + initRequest(header, uri, "", false); + + // build web request object + StringBuilder sb = new StringBuilder(); + sb.Append(_isHttps ? "https://" : "http://").Append(_ip).Append(":").Append(_port.ToString()).Append(uri); + + HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(sb.ToString()); + req.KeepAlive = false; + req.ProtocolVersion = HttpVersion.Version11; + req.AllowAutoRedirect = false; // 不允许自动重定向 + req.Method = "GET"; + req.Timeout = timeout * 1000; // 传入是秒,需要转换成毫秒 + req.Accept = header["Accept"]; + req.ContentType = header["Content-Type"]; + + foreach (string headerKey in header.Keys) + { + if (headerKey.Contains("USER_KEY")) + { + req.Headers.Add(headerKey + ":" + header[headerKey]); + } + if (headerKey.Contains("USER_SECRET")) + { + req.Headers.Add(headerKey + ":" + header[headerKey]); + } + //if (headerKey.Contains("sign")) + //{ + // req.Headers.Add(headerKey + ":" + header[headerKey]); + //} + } + + HttpWebResponse rsp = null; + try + { + rsp = (HttpWebResponse)req.GetResponse(); + if (HttpStatusCode.OK == rsp.StatusCode) + { + Stream rspStream = rsp.GetResponseStream(); // 响应内容字节流 + StreamReader sr = new StreamReader(rspStream); + string strStream = sr.ReadToEnd(); + long streamLength = strStream.Length; + byte[] response = System.Text.Encoding.UTF8.GetBytes(strStream); + rsp.Close(); + return System.Text.Encoding.UTF8.GetString(response); + } + else if (HttpStatusCode.Found == rsp.StatusCode || HttpStatusCode.Moved == rsp.StatusCode) // 302/301 redirect + { + string reqUrl = rsp.Headers["Location"].ToString(); // 获取重定向URL + WebRequest wreq = WebRequest.Create(reqUrl); // 重定向请求对象 + WebResponse wrsp = wreq.GetResponse(); // 重定向响应 + long streamLength = wrsp.ContentLength; // 重定向响应内容长度 + Stream rspStream = wrsp.GetResponseStream(); // 响应内容字节流 + byte[] response = new byte[streamLength]; + rspStream.Read(response, 0, (int)streamLength); // 读取响应内容至byte数组 + rspStream.Close(); + rsp.Close(); + return System.Text.Encoding.UTF8.GetString(response); + } + + rsp.Close(); + } + catch (WebException e) + { + if (rsp != null) + { + rsp.Close(); + } + } + + return null; + } + /// + /// HTTP Post请求 + /// + /// HTTP接口Url,不带协议和端口,如/artemis/api/resource/v1/org/advance/orgList + /// 请求参数 + /// 请求超时时间,单位:秒 + /// 请求结果 + public static string HttpPost(string uri, string body, int timeout) + { + Dictionary header = new Dictionary(); + + // 初始化请求:组装请求头,设置远程证书自动验证通过 + initRequest(header, uri, body, true); + + // build web request object + StringBuilder sb = new StringBuilder(); + sb.Append(_isHttps ? "https://" : "http://").Append(_ip).Append(":").Append(_port.ToString()).Append(uri); + + // 创建POST请求 + HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(sb.ToString()); + req.KeepAlive = false; + req.ProtocolVersion = HttpVersion.Version11; + req.AllowAutoRedirect = false; // 不允许自动重定向 + req.Method = "POST"; + req.Timeout = timeout * 1000; // 传入是秒,需要转换成毫秒 + req.Accept = header["Accept"]; + req.ContentType = header["Content-Type"]; + req.UserAgent = "PostmanRuntime/7.26.8"; + + foreach (string headerKey in header.Keys) + { + if (headerKey.Contains("USER_KEY")) + { + req.Headers.Add(headerKey + ":" + header[headerKey]); + } + if (headerKey.Contains("USER_SECRET")) + { + req.Headers.Add(headerKey + ":" + header[headerKey]); + } + //if (headerKey.Contains("sign")) + //{ + // req.Headers.Add(headerKey + ":" + header[headerKey]); + //} + } + byte[] data = Encoding.UTF8.GetBytes(body); + + req.ContentLength = data.Length; + + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + + reqStream.Close(); + } + + HttpWebResponse response = (HttpWebResponse)req.GetResponse(); + Stream stream = response.GetResponseStream(); + Encoding encode = Encoding.UTF8; + StreamReader reader = new StreamReader(stream, encode); + string content = reader.ReadToEnd(); + stream.Close(); + reader.Close(); + return content; + } + + + /// + /// 远程证书验证 + /// + /// + /// + /// + /// + /// 验证是否通过,始终通过 + private static bool remoteCertificateValidate(object sender, X509Certificate cert, X509Chain chain, + SslPolicyErrors error) + { + return true; + } + + private static void initRequest(Dictionary header, string url, string body, bool isPost) + { + // Accept + // string accept = "application/json"; // "*/*"; + string accept = "*/*"; // "*/*"; + header.Add("Accept", accept); + + // ContentType + string contentType = "application/json"; + header.Add("Content-Type", contentType); + + + //// appId + //header.Add("USER_KEY", _appkey); + //// appId + //header.Add("USER_SECRET", _secret); + //var timestamp = DateTime.Now.DateToTimeStamp(); + //// build string to sign + //string signedStr = MD5Helper.Md5EncryptLowerCase(timestamp + _secret); + + //// timestamp + //header.Add("timestamp", DateTime.Now.DateToTimeStamp()); + //// sign + //header.Add("sign", signedStr); + + if (_isHttps) + { + // set remote certificate Validation auto pass + ServicePointManager.ServerCertificateValidationCallback = + new System.Net.Security.RemoteCertificateValidationCallback(remoteCertificateValidate); + // FIX:修复不同.Net版对一些SecurityProtocolType枚举支持情况不一致导致编译失败等问题,这里统一使用数值 + // ServicePointManager.SecurityProtocol = (SecurityProtocolType)48 | (SecurityProtocolType)3072 | + // (SecurityProtocolType)768 | (SecurityProtocolType)192 ; + // ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; + } + } + } +} diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineModuleInstall.cs b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineModuleInstall.cs new file mode 100644 index 00000000..23fc4da1 --- /dev/null +++ b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineModuleInstall.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.Module.DjyRulesEngine +{ + /// + /// 注入大简云规则引擎服务 + /// + public static class RuleEngineModuleInstall + { + /// + /// + /// + /// + /// + public static void AddRuleEngineModuleInstall(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + services.AddScoped(); + } + } +} diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineReq.cs b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineReq.cs new file mode 100644 index 00000000..9821cb3a --- /dev/null +++ b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineReq.cs @@ -0,0 +1,113 @@ +using DS.Module.Core.Extensions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.Module.DjyRulesEngine +{ + /// + /// 规则引擎封装请求 + /// + public class RuleEngineReq + { + /// + /// 请求报文表头(head) + /// + public HeadInfo Head { get; set; } + + /// + /// 请求报文表体(main) + /// + public MainInfo Main { get; set; } + + public RuleEngineReq() + { + Head = new HeadInfo(); + Main = new MainInfo(); + } + } + + public class HeadInfo { + + public HeadInfo() + { + + GID = DateTime.Now.DateToTimeStamp(); + MessageType = "SHIP_ORDER_COMPARE"; + SenderId = "Dongsheng8"; + SenderName = "东胜8平台"; + ReceiverId = "RulesEngine"; + ReceiverName = "大简云规则引擎"; + Version = "1.0"; + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + RequestAction = "Compare"; + } + /// + /// 报文惟一主键 + /// + public string GID { get; set; } = DateTime.Now.DateToTimeStamp(); + /// + /// 报文类型 + /// + public string MessageType { get; set; } = "SHIP_ORDER_COMPARE"; + /// + /// 发送方代码 + /// + public string SenderId { get; set; } = "Dongsheng8"; + /// + /// 发送方名称 + /// + public string SenderName { get; set; } = "东胜8平台"; + /// + /// 接收方代码 + /// + public string ReceiverId { get; set; } = "RulesEngine"; + /// + /// 接收方名称 大简云规则引擎 + /// + public string ReceiverName { get; set; } = "大简云规则引擎"; + /// + /// 请求方登录TOKEN + /// + public string Token { get; set; } = ""; + /// + /// 版本号 + /// + public string Version { get; set; } = "1.0"; + /// + /// 请求时间 + /// + public string RequestDate { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + /// + /// 请求操作类型 + /// + public string RequestAction { get; set; } = "Compare"; + + /// + /// 请求授权KEY + /// + public string SenderKey { get; set; } + + } + + public class MainInfo + { + + public MainInfo() { + + ProjectCode = [ "OCEAN_BOOKING" ]; + + BusinessInfo = new RulesEngineOrderBookingMainBusinessInfo(); + } + /// + /// 项目代码 项目代码可以传多个,具体按照业务分类来定义,默认传OCEAN_BOOKING + /// + public string[] ProjectCode { get; set; } = { "OCEAN_BOOKING" }; + /// + /// 请求报文表体的海运主业务信息(main.businessInfo) + /// + public RulesEngineOrderBookingMainBusinessInfo BusinessInfo { get; set; } + } +} diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineResult.cs b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineResult.cs new file mode 100644 index 00000000..66621953 --- /dev/null +++ b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineResult.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.Module.DjyRulesEngine +{ + /// + /// 请求结果 + /// + public class RuleEngineResult + { + /// + /// 是否成功 true=成功 false=失败 + /// + public string Succ { get; set; } + /// + /// 状态 0-成功 + /// + public int Status { get; set; } + /// + /// 返回消息 + /// + public string Msg { get; set; } + /// + /// 总记录数 + /// + public int Total { get; set; } + /// + /// 当前页列表数据 + /// + public string Rows { get; set; } + /// + /// 合计信息 + /// + public string Summary { get; set; } + /// + /// 回执详情 + /// + public Extra Extra { get; set; } + /// + /// + /// + public string extra2 { get; set; } + + /// + /// + /// + /// + /// + public static RuleEngineResult Failed(string message) + { + return new RuleEngineResult() + { + Succ = "false", + Msg = message + }; + } + } + + /// + /// 请求结果 extra详情 + /// + public class Extra + { + /// + /// 是否成功 true=成功 false=失败 + /// + public string IsSuccess { get; set; } + /// + /// 请求报文HEAD的GID + /// + public string RequestId { get; set; } + /// + /// 执行时间 + /// + public string ExcuteDate { get; set; } + /// + /// 规则详情 + /// + public List DetailList { get; set; } + } + /// + /// 请求结果 detailList详情 + /// + public class DetailListItem + { + /// + /// 当前规则是否校验成功 true=成功 false=失败 + /// + public string IsSuccess { get; set; } + /// + /// 返回代码 + /// + public string ResultCode { get; set; } + /// + /// [返回校验说明 + /// + public string ResultName { get; set; } + /// + /// 规则提醒类型 + /// + public string ErrorType { get; set; } + /// + /// 规则名称 + /// + public string RuleName { get; set; } + /// + /// 规则集名称 + /// + public string WfName { get; set; } + } +} diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineService.cs b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineService.cs new file mode 100644 index 00000000..16ec03f7 --- /dev/null +++ b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineService.cs @@ -0,0 +1,63 @@ +using DS.Module.Core; +using DS.Module.Core.Extensions; +using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; +using NLog; + +namespace DS.Module.DjyRulesEngine +{ + /// + /// + /// + public class RuleEngineService : IRuleEngineService + { + private readonly IServiceProvider _serviceProvider; + private readonly string ip; + private readonly int port; + private readonly string senderKey; + //private readonly string accessSecret; + private readonly string sendUrl; + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + /// + /// 构造函数 + /// + /// + public RuleEngineService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + + ip = AppSetting.app(new string[] { "ExcuteRuleService", "IP" }).ObjToString(); + port = AppSetting.app(new string[] { "ExcuteRuleService", "Port" }).ToInt(); + senderKey = AppSetting.app(new string[] { "ExcuteRuleService", "SenderKey" }).ObjToString(); + + sendUrl = AppSetting.app(new string[] { "ExcuteRuleService", "SendUrl" }).ObjToString(); + } + + /// + /// 执行海运出口规则引擎校验 + /// + /// 修改服务状态详情 + /// 返回回执 + public async Task ExcuteRulesOceanBooking(RuleEngineReq req) + { + // 只要平台信息参数一致,多个请求只需设置一次参数 + RuleEngineHttpUtil.SetPlatformInfo(ip, port, false); + + // 发起POST请求,超时时间15秒,返回响应字节数组 + string result = RuleEngineHttpUtil.HttpPost(sendUrl, JsonConvert.SerializeObject(req), 30); + if (null == result) + { + return await Task.FromResult(RuleEngineResult.Failed("请求失败,请联系管理员")); + } + else + { + var res = JsonConvert.DeserializeObject(result); + // Console.WriteLine(System.Text.Encoding.UTF8.GetString(result)); + return await Task.FromResult(res); + } + + } + + } +} diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/RulesEngineOrderBookingMainBusinessInfo.cs b/ds-wms-service/DS.Module.DjyRulesEngine/RulesEngineOrderBookingMainBusinessInfo.cs new file mode 100644 index 00000000..e27a549b --- /dev/null +++ b/ds-wms-service/DS.Module.DjyRulesEngine/RulesEngineOrderBookingMainBusinessInfo.cs @@ -0,0 +1,797 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.Module.DjyRulesEngine +{ + /// + /// + /// + public class RulesEngineOrderBookingMainBusinessInfo + { + /// + /// 主提单号 + /// + public string MasterBlNo { get; set; } + /// + /// 分提单号 + /// + public string HouseBlNo { get; set; } + /// + /// 订舱编号 + /// + public string BookingNo { get; set; } + /// + /// 合约号 + /// + public string ContrNo { get; set; } + /// + /// 客户合同号 + /// + public string ServContrNo { get; set; } + + /// + /// 发货人代码 + /// + public string ShipperId { get; set; } + /// + /// 收货人代码 + /// + public string ConsigneeId { get; set; } + /// + /// 通知人代码 + /// + public string NotifyPartyId { get; set; } + /// + /// 发货人 + /// + public string Shipper { get; set; } + /// + /// 收货人 + /// + public string Consignee { get; set; } + /// + /// 通知人 + /// + public string NotifyParty { get; set; } + /// + /// 第二通知人 + /// + public string NotifyPrt2 { get; set; } + /// + /// 场站代码 + /// + public string YardId { get; set; } + /// + /// 场站名称 + /// + public string Yard { get; set; } + /// + /// 船舶呼号 + /// + public string VesselId { get; set; } + /// + /// 船名 + /// + public string Vessel { get; set; } + /// + /// 海关航次 + /// + public string Voyno { get; set; } + /// + /// 内部航次 + /// + public string VoynoIn { get; set; } + /// + /// 开船日期 + /// + public string ETD { get; set; } + /// + /// 实际开船日期 + /// + public string ATD { get; set; } + /// + /// 预计到港日期 + /// + public string ETA { get; set; } + /// + /// 截港日期 + /// + public string ClosingDate { get; set; } + /// + /// 截单日期 + /// + public string CloseDocDate { get; set; } + /// + /// 截VGM时间 + /// + public string CloseVGMDate { get; set; } + /// + /// 收货地代码 + /// + public string PlaceReceiptId { get; set; } + /// + /// 收货地 + /// + public string PlaceReceipt { get; set; } + /// + /// 起运港代码 + /// + public string PortLoadId { get; set; } + /// + /// 起运港 + /// + public string PortLoad { get; set; } + /// + /// 卸货港代码 + /// + public string PortDischargeId { get; set; } + /// + /// 卸货港 + /// + public string PortDischarge { get; set; } + /// + /// 交货地代码 + /// + public string PlaceDeliveryId { get; set; } + /// + /// 交货地 + /// + public string PlaceDelivery { get; set; } + /// + /// 目的地代码 + /// + public string DestinationId { get; set; } + /// + /// 目的地 + /// + public string Destination { get; set; } + /// + /// 提单份数 + /// + public string NoBill { get; set; } + /// + /// 副本提单份数 + /// + public string CopyNoBill { get; set; } + /// + /// 签单方式 1-Seaway 2-正本 3-电放 + /// + public string IssueType { get; set; } + /// + /// 签单日期 + /// + public string IssueDate { get; set; } + /// + /// 签单地点代码 + /// + public string IssuePlaceId { get; set; } + /// + /// 签单地点 + /// + public string IssuePlace { get; set; } + /// + /// 付费方式 + /// + public string Blfrt { get; set; } + /// + /// 预付地点 + /// + public string PrepardAt { get; set; } + /// + /// 到付地点 + /// + public string PayableAt { get; set; } + /// + /// 运输条款 + /// + public string Service { get; set; } + + /// + /// 唛头 + /// + public string Marks { get; set; } + /// + /// HS代码 + /// + public string HsCode { get; set; } + /// + /// 货描 + /// + public string GoodsDescription { get; set; } + /// + /// 件数 + /// + public Nullable PKGs { get; set; } + /// + /// 包装 + /// + public string KindPKGs { get; set; } + /// + /// 毛重 + /// + public Nullable KGs { get; set; } + /// + /// 尺码 + /// + public Nullable CBM { get; set; } + /// + /// 件数大写 + /// + public string TotalNO { get; set; } + /// + /// 集装箱 + /// + public string CntrTotal { get; set; } + /// + /// 船公司代号 + /// + public string CarrierId { get; set; } + /// + /// 船公司 + /// + public string Carrier { get; set; } + /// + /// 货物标识 + /// + public string CargoId { get; set; } + /// + /// 危险品类别 + /// + public string DClass { get; set; } + /// + /// 危险品编号 + /// + public string DUnno { get; set; } + /// + /// 危险品页号 + /// + public string DPage { get; set; } + /// + /// 危险品标签 + /// + public string DLabel { get; set; } + /// + /// 危险品联系人 + /// + public string DLinkMan { get; set; } + /// + /// 温度单位 + /// + public string TempId { get; set; } + /// + /// 温度单位 + /// + public string TempSet { get; set; } + /// + /// 通风度 + /// + public string Reeferf { get; set; } + /// + /// 湿度 + /// + public string Humidity { get; set; } + /// + /// 最低温度 + /// + public string TempMin { get; set; } + /// + /// 最高温度 + /// + public string TempMax { get; set; } + /// + /// 是否SOC箱 + /// + public Nullable IsContaSOC { get; set; } + /// + /// SO备注 + /// + public string SORemark { get; set; } + /// + /// SI备注 + /// + public string SIRemark { get; set; } + /// + /// 场站备注 + /// + public string YardRemark { get; set; } + /// + /// 公司ID + /// + public string CompId { get; set; } + /// + /// 公司名称 + /// + public string CompName { get; set; } + /// + /// 发货人名称 + /// + public string ShipperName { get; set; } + /// + /// 发货人地址1 + /// + public string ShipperAddr1 { get; set; } + /// + /// 发货人地址2 + /// + public string ShipperAddr2 { get; set; } + /// + /// 发货人地址3 + /// + public string ShipperAddr3 { get; set; } + /// + /// 发货人城市 + /// + public string ShipperCity { get; set; } + /// + /// 发货人省份代码 + /// + public string ShipperProvice { get; set; } + /// + /// 发货人邮编 + /// + public string ShipperPostCode { get; set; } + /// + /// 发货人国家代码 + /// + public string ShipperCountry { get; set; } + /// + /// 发货人联系人 + /// + public string ShipperAttn { get; set; } + /// + /// 发货人电话 + /// + public string ShipperTel { get; set; } + /// + /// 收货人名称 + /// + public string ConsigneeName { get; set; } + /// + /// 收货人地址1 + /// + public string ConsigneeAddr1 { get; set; } + /// + /// 收货人地址2 + /// + public string ConsigneeAddr2 { get; set; } + /// + /// 收货人地址3 + /// + public string ConsigneeAddr3 { get; set; } + /// + /// 收货人城市 + /// + public string ConsigneeCity { get; set; } + /// + /// 收货人省份代码 + /// + public string ConsigneeProvince { get; set; } + /// + /// 收货人邮编 + /// + public string ConsigneePostCode { get; set; } + /// + /// 收货人国家代码 + /// + public string ConsigneeCountry { get; set; } + /// + /// 收货人联系人 + /// + public string ConsigneeAttn { get; set; } + /// + /// 收货人电话 + /// + public string ConsigneeTel { get; set; } + /// + /// 通知人名称 + /// + public string NotifyPartyName { get; set; } + /// + /// 通知人地址1 + /// + public string NotifyPartyAddr1 { get; set; } + /// + /// 通知人地址2 + /// + public string NotifyPartyAddr2 { get; set; } + /// + /// 通知人地址3 + /// + public string NotifyPartyAddr3 { get; set; } + /// + /// 通知人城市 + /// + public string NotifyPartyCity { get; set; } + /// + /// 通知人省份代码 + /// + public string NotifyPartyProvince { get; set; } + /// + /// 通知人邮编 + /// + public string NotifyPartyPostCode { get; set; } + /// + /// 通知人国家代码 + /// + public string NotifyPartyCountry { get; set; } + /// + /// 通知人联系人 + /// + public string NotifyPartyAttn { get; set; } + /// + /// 通知人电话 + /// + public string NotifyPartyTel { get; set; } + /// + /// PO号 + /// + public string PONo { get; set; } + /// + /// 操作id + /// + public string OPID { get; set; } + /// + /// 单证id + /// + public string DOCID { get; set; } + /// + /// 操作 + /// + public string OP { get; set; } + /// + /// 单证 + /// + public string Doc { get; set; } + /// + /// 销售ID + /// + public string SaleId { get; set; } + /// + /// 销售 + /// + public string Sale { get; set; } + /// + /// 客服ID + /// + public string CustserviceId { get; set; } + /// + /// 客服 + /// + public string Custservice { get; set; } + /// + /// 客户 + /// + public string CustserviceName { get; set; } + /// + /// 订舱代理 + /// + public string Forwarder { get; set; } + /// + /// 船代 + /// + public string ShipAgency { get; set; } + /// + /// 报关行 + /// + public string CustomsER { get; set; } + /// + /// 车队 + /// + public string TruckER { get; set; } + /// + /// 国外代理 + /// + public string AgentId { get; set; } + /// + /// 客户ID + /// + public Nullable CustomerId { get; set; } + /// + /// 订舱代理ID + /// + public string ForwarderId { get; set; } + /// + /// 船代ID + /// + public string ShipAgencyId { get; set; } + /// + /// 报关行ID + /// + public string CustomsERId { get; set; } + /// + /// 车队ID + /// + public string TruckERId { get; set; } + /// + /// 国外代理名称 + /// + public string AgentName { get; set; } + /// + /// 委托方 + /// + public string WeiTo { get; set; } + /// + /// 收货人DOOR地址 + /// + public string ConsigneeDoorAddr { get; set; } + /// + /// 发货人DOOR地址 + /// + public string ShipperDoorAddr { get; set; } + /// + /// SCAC代码 + /// + public string SCACCode { get; set; } + /// + /// ITN编号 + /// + public string ITNCode { get; set; } + /// + /// 预付地点ID + /// + public string PrePardAtId { get; set; } + /// + /// 到付地点ID + /// + public string PayableAtId { get; set; } + /// + /// 客户系统编号 + /// + public string CustNo { get; set; } + /// + /// 中转港代码 + /// + public string TransportId { get; set; } + /// + /// 中转港 + /// + public string Transport { get; set; } + /// + /// 第三付款地 + /// + public string ThirdPayAddr { get; set; } + /// + /// 场站联系人电话 + /// + public string YardContractTel { get; set; } + /// + /// 场站联系人邮箱 + /// + public string YardContractEmail { get; set; } + /// + /// 费用自结 + /// + public Nullable FeeSelf { get; set; } + /// + /// 航线代码 + /// + public string LaneCode { get; set; } + /// + /// 航线名称 + /// + public string LaneName { get; set; } + /// + /// 付款方 + /// + public string FreightPayer { get; set; } + + /// + /// 发货人税号 + /// + public string ShipperTaxNo { get; set; } + + /// + /// 收货人税号 + /// + public string ConsigneeTaxNo { get; set; } + + /// + /// 通知人税号 + /// + public string NotifyPartyTaxNo { get; set; } + + /// + /// 是否船开后变更签单方式 1-是 0-否 + /// + public Nullable IsATDChangeIssueType { get; set; } + + /// + /// 是否条形中英文章 + /// + public Nullable IsEngChinaLineBar { get; set; } + + /// + /// 是否双Shipper + /// + public Nullable IsDoubleShipper { get; set; } + + /// + /// 是否整箱和拼箱混合 + /// + public Nullable IsFCLAndLCLMix { get; set; } + + /// + /// 是否多品名 + /// + public Nullable IsMutipleGoods { get; set; } + + /// + /// 是否拼箱 + /// + public Nullable IsContaLCL { get; set; } + + /// + /// 卸货港国家代码 + /// + public string PortDischargeCountryNo { get; set; } + + /// + /// 卸货港国家英文 + /// + public string PortDischargeEN { get; set; } + + /// + /// 卸货港国家中文 + /// + public string PortDischargeCN { get; set; } + + /// + /// 中转港国家代码 + /// + public string TransportCountryNo { get; set; } + + /// + /// 中转港国家英文 + /// + public string TransportEN { get; set; } + + /// + /// 中转港国家中文 + /// + public string TransportCN { get; set; } + + /// + /// 箱信息 + /// + public List ContaList { get; set; } + } + + /// + /// 集装箱信息 + /// + public class RulesEngineOrderBookingContaInfo + { + /// + /// 箱型代码 + /// + public string ContaType { get; set; } + /// + /// 箱型 + /// + public string ContaTypeName { get; set; } + /// + /// TEU + /// + public Nullable TEU { get; set; } + /// + /// 箱号 + /// + public string ContaNo { get; set; } + /// + /// 封号 + /// + public string SealNo { get; set; } + /// + /// 件数 + /// + public Nullable PKGs { get; set; } + /// + /// 包装 + /// + public string KindPKGs { get; set; } + /// + /// 毛重 + /// + public Nullable KGs { get; set; } + /// + /// 尺码 + /// + public Nullable CBM { get; set; } + /// + /// 皮重 + /// + public Nullable TareWeight { get; set; } + /// + /// 箱状态 + /// + public string ContaStatus { get; set; } + /// + /// 称重方式 + /// + public string WeighType { get; set; } + /// + /// 称重重量 + /// + public Nullable WeighKGs { get; set; } + /// + /// 称重联系人 + /// + public string WeighAttn { get; set; } + /// + /// VGM联系公司 + /// + public string VGMConnCom { get; set; } + /// + /// VGM联系电话 + /// + public string WeighTel { get; set; } + /// + /// 称重日期 + /// + public string WeighDate { get; set; } + /// + /// VGM地址 + /// + public string VGMAddr { get; set; } + /// + /// VGM邮箱 + /// + public string VGMEmail { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 大小箱分类(small-小箱 big-大箱) + /// + public string ContaCategory { get; set; } + + /// + /// 货物明细 + /// + public List CargoList { get; set; } + } + + /// + /// 集装箱内货物信息 + /// + public class RulesEngineOrderBookingContaCargoInfo + { + /// + /// 件数 + /// + public Nullable PKGs { get; set; } + /// + /// 包装 + /// + public string KindPKGs { get; set; } + /// + /// 毛重 + /// + public Nullable KGs { get; set; } + /// + /// 尺码 + /// + public Nullable CBM { get; set; } + /// + /// HS编码 + /// + public string HSCode { get; set; } + /// + /// 唛头 + /// + public string Marks { get; set; } + /// + /// 货描 + /// + public string Description { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj index 397acccb..28ea4271 100644 --- a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj +++ b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj @@ -25,6 +25,7 @@ + diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportService.cs index a826dd21..8a64a7cf 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportService.cs @@ -1,5 +1,6 @@ using DS.Module.Core; using DS.Module.Core.Data; +using DS.Module.DjyRulesEngine; using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.EDI; using Microsoft.AspNetCore.Http; @@ -160,4 +161,12 @@ public interface ISeaExportService /// /// public Task> UploadOcrFile(IFormFile file, [FromForm] OpFileReq req); + + /// + /// 海运出口规则引擎校验 + /// + /// + /// + + public Task> ExcuteRuleEngine(string id); } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportCommonService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportCommonService.cs index 5b577ab1..8749a7cf 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportCommonService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportCommonService.cs @@ -1817,7 +1817,7 @@ namespace DS.WMS.Core.Op.Method /// public async Task> GetConfigData(string code) { - var config = await db.Queryable().Where(x => x.Code == code && x.Status == StatusEnum.Enable).FirstAsync(); + var config = await db.Queryable().Filter(null, true).Where(x => x.Code == code && x.Status == StatusEnum.Enable).FirstAsync(); if (config.IsNull()) { return await Task.FromResult(DataResult.Failed("OCR接口地址未配置!")); diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportOcrService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportOcrService.cs index d52585e3..c87a074a 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportOcrService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportOcrService.cs @@ -37,18 +37,54 @@ namespace DS.WMS.Core.Op.Method { return await Task.FromResult(DataResult.Failed("附件不存在!")); } - // 先存库获取Id + + var limitFiles = AppSetting.app(new string[] { "FileSettings", "FileType" }); + var originalFilename = file.FileName; // 文件原始名称 + var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀 + if (!limitFiles.Contains(fileSuffix)) + { + return await Task.FromResult(DataResult.Failed("不允许的文件类型!")); + } + var basePath = AppSetting.app(new string[] { "FileSettings", "BasePath" }); + var relativePath = AppSetting.app(new string[] { "FileSettings", "RelativePath" }); + var dirAbs = string.Empty; + var fileRelaPath = string.Empty; + var fileAbsPath = string.Empty; + if (string.IsNullOrEmpty(basePath)) + { + dirAbs = Path.Combine(_environment.WebRootPath, relativePath); + } + else + { + dirAbs = Path.Combine(basePath, relativePath); + } + + if (!Directory.Exists(dirAbs)) + Directory.CreateDirectory(dirAbs); + + + // 先存库获取Id + var id = SnowFlakeSingle.Instance.NextId(); + var fileSaveName = $"{id}{fileSuffix}".ToLower(); + fileRelaPath = Path.Combine(relativePath, fileSaveName).ToLower(); + fileAbsPath = Path.Combine(dirAbs, fileSaveName).ToLower(); var newFile = new OpFile { + Id = id, + //FileName = originalFilename, + FilePath = fileSaveName, TypeCode = req.TypeCode, TypeName = req.TypeName, - LinkId = req.LinkId, + LinkId = req.LinkId, }; + //await tenantDb.Insertable(newFile).ExecuteCommandAsync(); - var originalFilename = file.FileName; // 文件原始名称 - var fileSuffix = Path.GetExtension(file.FileName).ToLower(); // 文件后缀 + using (var stream = File.Create(fileAbsPath)) + { + await file.CopyToAsync(stream); + } - var config = await db.Queryable().Where(x => x.Code == "ocr_api_url" && x.Status == StatusEnum.Enable).FirstAsync(); + var config = await db.Queryable().Filter(null,true).Where(x => x.Code == "ocr_api_url" && x.Status == StatusEnum.Enable).FirstAsync(); if (config.IsNull()) { return await Task.FromResult(DataResult.Failed("OCR接口地址未配置!")); diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportRuleEngineService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportRuleEngineService.cs new file mode 100644 index 00000000..fbafff48 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportRuleEngineService.cs @@ -0,0 +1,58 @@ +using DS.Module.Core; +using DS.Module.Core.Extensions; +using DS.Module.DjyRulesEngine; +using DS.WMS.Core.Op.Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Mapster; + +namespace DS.WMS.Core.Op.Method +{ + /// + /// 海运出口规则引擎接口 + /// + public partial class SeaExportService + { + + /// + /// 海运出口规则引擎校验 + /// + /// + /// + + public async Task> ExcuteRuleEngine(string id) + { + var SenderKey = AppSetting.app(new string[] { "ExcuteRuleService", "SenderKey" }).ObjToString(); + + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(id)).First(); + if (info.IsNull()) + return await Task.FromResult(DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist)); + + var mainInfo = info.Adapt(); + + var ctnlist = new List(); + + var ctns= tenantDb.Queryable().Where(x => x.BSNO == id).ToList(); + if (ctns.Count > 0) + { + ctns.Adapt(ctnlist); + mainInfo.ContaList = ctnlist; + } + + var req = new RuleEngineReq(); + //req.Head = new HeadInfo(); + req.Head.SenderKey = SenderKey; + req.Main.BusinessInfo = mainInfo; + + var res = await _ruleEngineService.ExcuteRulesOceanBooking(req); + + + return await Task.FromResult(DataResult.Success("海运出口规则引擎校验完成!", res, MultiLanguageConst.SeaExportRuleEngineFinished)); + } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs index a31498bc..d64e4016 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs @@ -2,6 +2,7 @@ using AngleSharp.Dom; using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Extensions; +using DS.Module.DjyRulesEngine; using DS.Module.DjyServiceStatus; using DS.Module.SqlSugar; using DS.Module.UserModule; @@ -35,7 +36,7 @@ public partial class SeaExportService : ISeaExportService private readonly ISeaExportCommonService seaComService; private readonly IWebHostEnvironment _environment; private readonly IDjyServiceStatusService _djyServiceStatusService; - + private readonly IRuleEngineService _ruleEngineService; 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"; @@ -63,6 +64,7 @@ public partial class SeaExportService : ISeaExportService //_printService = _serviceProvider.GetRequiredService(); _djyServiceStatusService = _serviceProvider.GetRequiredService(); + _ruleEngineService = _serviceProvider.GetRequiredService(); #region 设置对象映射 TypeAdapterConfig @@ -199,6 +201,121 @@ public partial class SeaExportService : ISeaExportService .Map(dto => dto.KGS, poco => poco.KGS) .Map(dto => dto.CBM, poco => poco.CBM); //.IgnoreNonMapped(true);//只映射Map指定的属性,其他属性都排除; + + + //映射规则引擎 + TypeAdapterConfig + .NewConfig() + .Map(dto => dto.MasterBlNo, poco => poco.MBLNO) + .Map(dto => dto.HouseBlNo, poco => poco.HBLNO) + .Map(dto => dto.BookingNo, poco => poco.BookingNo) + .Map(dto => dto.ServContrNo, poco => poco.ServiceContractNo) + .Map(dto => dto.Shipper, poco => poco.Shipper) + .Map(dto => dto.ShipperId, poco => poco.ShipperId) + .Map(dto => dto.Consignee, poco => poco.Consignee) + .Map(dto => dto.ConsigneeId, poco => poco.ConsigneeId) + .Map(dto => dto.NotifyParty, poco => poco.NotifyParty) + .Map(dto => dto.NotifyPartyId, poco => poco.NotifyPartyId) + .Map(dto => dto.NotifyPrt2, poco => poco.SecondNotifyParty) + .Map(dto => dto.Yard, poco => poco.Yard) + .Map(dto => dto.YardId, poco => poco.YardId) + .Map(dto => dto.Vessel, poco => poco.Vessel) + .Map(dto => dto.VesselId, poco => poco.VesselId) + .Map(dto => dto.Voyno, poco => poco.Voyno) + .Map(dto => dto.VoynoIn, poco => poco.InnerVoyno) + .Map(dto => dto.ETD, poco => poco.ETD) + .Map(dto => dto.ATD, poco => poco.ATD) + .Map(dto => dto.ETA, poco => poco.ETA) + .Map(dto => dto.ClosingDate, poco => poco.ClosingDate) + .Map(dto => dto.CloseDocDate, poco => poco.CloseDocDate) + .Map(dto => dto.CloseVGMDate, poco => poco.CloseVgmDate) + .Map(dto => dto.PortLoad, poco => poco.LoadPort) + .Map(dto => dto.PortLoadId, poco => poco.LoadPortId) + .Map(dto => dto.PlaceReceipt, poco => poco.ReceiptPlace) + .Map(dto => dto.PlaceReceiptId, poco => poco.ReceiptPlaceId) + .Map(dto => dto.PortDischarge, poco => poco.DischargePort) + .Map(dto => dto.PortDischargeId, poco => poco.DischargePortId) + .Map(dto => dto.PlaceDelivery, poco => poco.DeliveryPlace) + .Map(dto => dto.PlaceDeliveryId, poco => poco.DeliveryPlaceId) + .Map(dto => dto.Destination, poco => poco.Destination) + .Map(dto => dto.DestinationId, poco => poco.DestinationId) + .Map(dto => dto.NoBill, poco => poco.NoBill) + .Map(dto => dto.CopyNoBill, poco => poco.CopyNoBill) + .Map(dto => dto.IssueType, poco => poco.IssueType) + .Map(dto => dto.IssueDate, poco => poco.IssueDate) + .Map(dto => dto.IssuePlace, poco => poco.IssuePlace) + .Map(dto => dto.Blfrt, poco => poco.MBLFrt) + .Map(dto => dto.PrepardAt, poco => poco.PrepareAt) + .Map(dto => dto.PayableAt, poco => poco.PayableAt) + .Map(dto => dto.Service, poco => poco.Service) + .Map(dto => dto.Marks, poco => poco.Marks) + .Map(dto => dto.HsCode, poco => poco.HSCode) + .Map(dto => dto.GoodsDescription, poco => poco.Description) + .Map(dto => dto.PKGs, poco => poco.PKGS) + .Map(dto => dto.KindPKGs, poco => poco.KindPkgs) + .Map(dto => dto.KGs, poco => poco.KGS) + .Map(dto => dto.CBM, poco => poco.CBM) + .Map(dto => dto.TotalNO, poco => poco.TotalNo) + .Map(dto => dto.CntrTotal, poco => poco.CntrTotal) + .Map(dto => dto.Carrier, poco => poco.Carrier) + //.Map(dto => dto.CarrierId, poco => poco.Carrier) + .Map(dto => dto.CargoId, poco => poco.CargoId) + .Map(dto => dto.DClass, poco => poco.DangerClass) + .Map(dto => dto.DUnno, poco => poco.DangerNo) + .Map(dto => dto.DPage, poco => poco.DangerPage) + .Map(dto => dto.DLabel, poco => poco.DangerLabel) + //.Map(dto => dto.DLinkMan, poco => poco.dan) + .Map(dto => dto.TempId, poco => poco.TemperatureUnit) + .Map(dto => dto.TempSet, poco => poco.TemperatureSet) + .Map(dto => dto.Reeferf, poco => poco.ReeferQuantity) + .Map(dto => dto.Humidity, poco => poco.Humidity) + .Map(dto => dto.TempMin, poco => poco.TemperatureMin) + .Map(dto => dto.TempMax, poco => poco.TemperatureMax) + .Map(dto => dto.IsContaSOC, poco => poco.IsContainerSoc) + .Map(dto => dto.YardRemark, poco => poco.YardRemark) + //.Map(dto => dto.CompId, poco => poco.OrgId.ToString()) + //.Map(dto => dto.CompName, poco => poco.OrgId.ToString()) + //.Map(dto => dto.CustserviceName, poco => poco.CustserviceName) + .Map(dto => dto.Forwarder, poco => poco.Forwarder) + .Map(dto => dto.ShipAgency, poco => poco.ShipAgency) + .Map(dto => dto.CustomsER, poco => poco.Customser) + .Map(dto => dto.TruckER, poco => poco.Trucker) + .Map(dto => dto.AgentId, poco => poco.AgentId) + .Map(dto => dto.CustomerId, poco => poco.CustomerId) + .Map(dto => dto.ForwarderId, poco => poco.ForwarderId) + .Map(dto => dto.ShipAgencyId, poco => poco.ShipAgencyId) + .Map(dto => dto.CustomsERId, poco => poco.CustomserId) + .Map(dto => dto.TruckERId, poco => poco.TruckerId) + //.Map(dto => dto.AgentName, poco => poco.Agent) + .Map(dto => dto.WeiTo, poco => poco.CustomerName) + //.Map(dto => dto.SCACCode, poco => poco.sca) + //.Map(dto => dto.ITNCode, poco => poco.it) + .Map(dto => dto.PrePardAtId, poco => poco.PrepareAtId) + //.Map(dto => dto.PayableAtId, poco => poco.pa) + .Map(dto => dto.CustNo, poco => poco.CustomNo) + .Map(dto => dto.TransportId, poco => poco.TransportCode) + .Map(dto => dto.Transport, poco => poco.Transport) + .Map(dto => dto.IsMutipleGoods, poco => poco.IsMoreGood); + + + + TypeAdapterConfig + .NewConfig() + .Map(dto => dto.ContaType, poco => poco.CtnCode) + .Map(dto => dto.ContaTypeName, poco => poco.CtnAll) + .Map(dto => dto.ContaNo, poco => poco.CntrNo) + .Map(dto => dto.TEU, poco => poco.TEU) + .Map(dto => dto.SealNo, poco => poco.SealNo) + .Map(dto => dto.PKGs, poco => poco.PKGS) + .Map(dto => dto.KindPKGs, poco => poco.KindPkgs) + .Map(dto => dto.KGs, poco => poco.KGS) + .Map(dto => dto.CBM, poco => poco.CBM) + .Map(dto => dto.TareWeight, poco => poco.TareWeight) + .Map(dto => dto.WeighKGs, poco => poco.WeightKGS) + .Map(dto => dto.WeighType, poco => poco.WeightType) + .Map(dto => dto.ContaStatus, poco => poco.CtnStatus) + + ; #endregion 设置对象映射 } diff --git a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportController.cs b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportController.cs index 96533b62..341cfe95 100644 --- a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportController.cs +++ b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportController.cs @@ -2,6 +2,7 @@ using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Helpers; +using DS.Module.DjyRulesEngine; using DS.WMS.Core.Info.Dtos; using DS.WMS.Core.Info.Interface; using DS.WMS.Core.Op.Dtos; @@ -13,6 +14,7 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using NPOI.XWPF.UserModel; using Org.BouncyCastle.Ocsp; +using System.Net; namespace DS.WMS.OpApi.Controllers; @@ -323,7 +325,7 @@ public class SeaExportController : ApiController //var str = await $"{url}pdf/getRegionText?fileName={fileName}&scale={scale}&x={x}&y={y}&w={w}&h={h}" //.PostAsStringAsync(); - var str = RequestHelper.Post("",url); + var str = RequestHelper.Post("", postUrl); return await Task.FromResult(DataResult.Success(str)); ; } @@ -351,7 +353,9 @@ public class SeaExportController : ApiController } var postUrl = $"{url}pdf/getCanvasImage?fileName={fileName}&scale={scale}"; - byte[] byteArr = System.IO.File.ReadAllBytes(postUrl); + WebClient mywebclient = new WebClient(); + byte[] byteArr = mywebclient.DownloadData(postUrl); + //byte[] byteArr = System.IO.File.ReadAllBytes(postUrl); string mimeType = "application/octet-stream"; return new FileContentResult(byteArr, mimeType) { @@ -359,4 +363,16 @@ public class SeaExportController : ApiController }; } + + /// + /// 海运出口规则引擎校验 + /// + /// 业务id + /// + [HttpGet] + [Route("ExcuteRuleEngine")] + public async Task> ExcuteRuleEngine([FromQuery] string id) + { + return await _invokeService.ExcuteRuleEngine(id); + } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj index afae3c05..e89fa938 100644 --- a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj +++ b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj @@ -12,6 +12,7 @@ + diff --git a/ds-wms-service/DS.WMS.OpApi/Program.cs b/ds-wms-service/DS.WMS.OpApi/Program.cs index 278ab572..004b74c3 100644 --- a/ds-wms-service/DS.WMS.OpApi/Program.cs +++ b/ds-wms-service/DS.WMS.OpApi/Program.cs @@ -14,6 +14,7 @@ using DS.Module.UserModule; using NLog.Web; using Swashbuckle.AspNetCore.SwaggerUI; using DS.Module.PrintModule; +using DS.Module.DjyRulesEngine; var builder = WebApplication.CreateBuilder(args); var environment = builder.Environment.EnvironmentName; @@ -41,6 +42,7 @@ builder.Services.AddJwtInstall(); builder.Services.AddSaasDbInstall();//ֿ builder.Services.AddMultiLanguageInstall();//Է builder.Services.AddDjyModuleInstall();//Djy +builder.Services.AddRuleEngineModuleInstall();//DjyУ // builder.Services.AddEndpointsApiExplorer(); // builder.Services.AddSwaggerGen(); diff --git a/ds-wms-service/DS.WMS.OpApi/appsettings.json b/ds-wms-service/DS.WMS.OpApi/appsettings.json index cda320eb..a1076f79 100644 --- a/ds-wms-service/DS.WMS.OpApi/appsettings.json +++ b/ds-wms-service/DS.WMS.OpApi/appsettings.json @@ -79,5 +79,11 @@ "GetServiceStatusListUrl": "/EmbedProjectGoodsStatus/GetServiceStatusList", "SaveServiceStatusUrl": "/EmbedProjectGoodsStatus/SaveServiceStatus", "CancelServiceStatusUrl": "/EmbedProjectGoodsStatus/CancelServiceStatus" + }, + "ExcuteRuleService": { + "IP": "47.104.73.97", + "Port": "7115", + "SenderKey": "SEFBZkh5V3R1TGxtdlBIcTF4QmNMWURCS08vb2EvTzVxS0F0eDFKdlgyS3lKVUx6K3JRRE94Q2kvcWZMRytZeWxyVkhLdk9hRGpzVStPamhIUXd5NU9FMjhFTktwUlZ2eThJZGlQd3p5dUk9", + "SendUrl": "/api/RulesEngineManage/ExcuteWorkFlow" } } diff --git a/ds-wms-service/ds-wms-service.sln b/ds-wms-service/ds-wms-service.sln index c4a0dbd8..ab9bde2a 100644 --- a/ds-wms-service/ds-wms-service.sln +++ b/ds-wms-service/ds-wms-service.sln @@ -51,7 +51,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.Module.CrawlerData", "DS EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.Module.DjyServiceStatus", "DS.Module.DjyServiceStatus\DS.Module.DjyServiceStatus.csproj", "{86AF9895-D98D-4BFD-BEB9-CE291A382426}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DS.WMS.CheckApi", "DS.WMS.CheckApi\DS.WMS.CheckApi.csproj", "{4EE319A5-22DC-43F8-BA3C-A34494B4BB8D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.WMS.CheckApi", "DS.WMS.CheckApi\DS.WMS.CheckApi.csproj", "{4EE319A5-22DC-43F8-BA3C-A34494B4BB8D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DS.Module.DjyRulesEngine", "DS.Module.DjyRulesEngine\DS.Module.DjyRulesEngine.csproj", "{C3296BF4-9A02-4C7D-90C9-7BBFDAA4F1A1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -147,6 +149,10 @@ Global {4EE319A5-22DC-43F8-BA3C-A34494B4BB8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {4EE319A5-22DC-43F8-BA3C-A34494B4BB8D}.Release|Any CPU.ActiveCfg = Release|Any CPU {4EE319A5-22DC-43F8-BA3C-A34494B4BB8D}.Release|Any CPU.Build.0 = Release|Any CPU + {C3296BF4-9A02-4C7D-90C9-7BBFDAA4F1A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3296BF4-9A02-4C7D-90C9-7BBFDAA4F1A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3296BF4-9A02-4C7D-90C9-7BBFDAA4F1A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3296BF4-9A02-4C7D-90C9-7BBFDAA4F1A1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -174,6 +180,7 @@ Global {AB3034D8-91F4-42A6-BFE9-497B238D65AD} = {518DB9B5-80A8-4B2C-8570-52BD406458DE} {86AF9895-D98D-4BFD-BEB9-CE291A382426} = {518DB9B5-80A8-4B2C-8570-52BD406458DE} {4EE319A5-22DC-43F8-BA3C-A34494B4BB8D} = {65D75DB2-12D5-4D1F-893D-9750905CE5E4} + {C3296BF4-9A02-4C7D-90C9-7BBFDAA4F1A1} = {518DB9B5-80A8-4B2C-8570-52BD406458DE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {66115F23-94B4-43C0-838E-33B5CF77F788}