diff --git a/Myshipping.Application/Helper/YardDataHelper.cs b/Myshipping.Application/Helper/YardDataHelper.cs new file mode 100644 index 00000000..7266f4b8 --- /dev/null +++ b/Myshipping.Application/Helper/YardDataHelper.cs @@ -0,0 +1,119 @@ +using Furion; +using Furion.Logging; +using Furion.RemoteRequest.Extensions; +using Myshipping.Core; +using Myshipping.Core.Service; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Helper +{ + /// + /// 获取场站数据辅助类(调用爬虫新运踪接口) + /// + public static class YardDataHelper + { + public static async Task> GetYardData(long tenantId, string tenantName, string mblno, string yardid, bool isWeb = true) + { + var cacheService = App.GetService(); + + + var sysConfig = await cacheService.GetAllSysConfig(); + var userKey = sysConfig.FirstOrDefault(x => x.Code == "spiderUserKeyBilltrace"); + var userSecret = sysConfig.FirstOrDefault(x => x.Code == "spiderUserSecretBilltrace"); + var spiderServerUrl = sysConfig.FirstOrDefault(x => x.Code == "spiderServerUrlBillTraceNew"); + + if (yardid == "YIHANG" || yardid == "YZH") yardid = "GLJ"; + + var qduname = ""; + var qdpwd = ""; + if (yardid == "YGT" || yardid == "CHANGRONG" || yardid == "GLR" || yardid == "JZLG") + { + //从租户参数中获取网站青岛港账号密码 + var tenantParam = await cacheService.GetAllTenantParam(); + var tenantUserName = tenantParam.FirstOrDefault(x => x.TenantId == tenantId && x.ParaCode == "QDPORT_USERNAME"); + var tenantPwd = tenantParam.FirstOrDefault(x => x.TenantId == tenantId && x.ParaCode == "QDPORT_PWD"); + + if (tenantUserName == null || tenantPwd == null) + { + return new KeyValuePair(false, "未找到青岛港用户名、密码配置"); + } + + qduname = tenantUserName.ItemCode; + qdpwd = tenantPwd.ItemCode; + } + + var yardMappings = await cacheService.GetAllMappingYard(); + var ym = yardMappings.FirstOrDefault(x => x.Code == yardid && x.Module == "BillTrace"); + if (ym == null) + { + return new KeyValuePair(false, $"场站代号配置未找到:{yardid}"); + } + + var objSend = new + { + user_key = userKey.Value, + user_secret = userSecret.Value, + customer_id = tenantId.ToString(), + customer_name = tenantName, + web_code = ym.MapCode, + bno = mblno, + req_type = isWeb ? "1" : "0", + web_user = qduname, + web_psw = qdpwd, + }; + + var urlYard = spiderServerUrl.Value; + if (!urlYard.EndsWith("/")) + { + urlYard += "/"; + } + + urlYard = "real/query"; + + var strJson = objSend.ToString(); + Log.Debug($"查询实时场站数据发送数据,url:{urlYard},json:{strJson}"); + string rtn = await urlYard.SetBody(objSend).PostAsStringAsync(); + Log.Debug($"查询实时场站数据,返回:{rtn}"); + var rtnObj = JObject.Parse(rtn); + if (rtnObj.GetIntValue("code") != 200) + { + return new KeyValuePair(false, $"获取场站数失败:{rtnObj.GetStringValue("msg")}"); + } + else + { + var rtnData = rtnObj.GetStringValue("data"); + if (isWeb) + { + var viewstatehtml = GetDataHtmlList(rtnData, "__VIEWSTATE", "/>"); + if (viewstatehtml != "") + { + rtnData = rtnData.Replace(viewstatehtml, ""); + } + } + + return new KeyValuePair(true, rtnData); + } + } + + private static string GetDataHtmlList(string html, string startstr, string endstr) + { + var subhtml = html; + var htmllength = subhtml.Length; + var startindex = subhtml.IndexOf(startstr); + //if (startindex == -1 || startindex == 0) return ""; + if (startindex == -1) return ""; + subhtml = subhtml.Substring(startindex + startstr.Length, htmllength - startindex - startstr.Length); + var endindex = subhtml.IndexOf(endstr); + if (endindex != -1 && endindex != 0) + subhtml = subhtml.Substring(0, endindex); + + return subhtml; + + } + } +} diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index f3ab8f03..fcf09bfb 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -47,6 +47,7 @@ using Myshipping.Application.EDI.WY; using Myshipping.Application.EDI.YML; using Myshipping.Application.EDI.YT; using System.Runtime.InteropServices; +using Myshipping.Application.Helper; namespace Myshipping.Application { @@ -262,7 +263,7 @@ namespace Myshipping.Application [HttpPost("/BookingOrder/Add")] public async Task Add(AddBookingOrderInput input) { - + JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail"); JsonUtil.TrimFields(input); if (input.ctnInputs != null) @@ -552,7 +553,7 @@ namespace Myshipping.Application FilePath = fileRelaPath, TypeCode = dto.TypeCode, TypeName = dto.TypeName, - BookingId= dto.BookingId + BookingId = dto.BookingId }; await _bookingfile.InsertAsync(newFile); using (var stream = File.Create(fileAbsPath)) @@ -1691,12 +1692,12 @@ namespace Myshipping.Application throw Oops.Oh($"货明细的包装{cargo.KINDPKGS}的EDI代码未找到"); cargoModel.KINDPKGS_EDI_CODE = ediDetailPkgs.MapCode; - + primaryModel.CTNGOODSLIST.Add(cargoModel); } //这里临时赋值,等明确对应的扩展表字段后赋值 - #if DEBUG +#if DEBUG primaryModel.MasterBOLIndicator = "A1"; primaryModel.ConsigneeEdiCode = "CEE1"; primaryModel.ShipperEdiCode = "SHIP1"; @@ -1715,9 +1716,9 @@ namespace Myshipping.Application throw Oops.Bah(result.msg); } - - + + return result.extra.ToString(); } @@ -1997,6 +1998,31 @@ namespace Myshipping.Application } + /// + /// 获取场站数据 + /// + /// + /// + /// + [HttpGet("/BookingOrder/GetYardData")] + public async Task GetYardData(long bookingId, bool isWeb = false) + { + //订舱数据 + var order = _rep.FirstOrDefault(x => x.Id == bookingId); + if (order == null) + { + throw Oops.Bah(BookingErrorCode.BOOK001); + } + + var rtn = await YardDataHelper.GetYardData(order.TenantId.Value, order.TenantName, order.MBLNO, order.YARDID, isWeb); + if (!rtn.Key) + { + throw Oops.Bah(rtn.Value); + } + + return rtn.Value; + } + /// /// 记录或更新订舱状态 /// @@ -2005,7 +2031,7 @@ namespace Myshipping.Application /// /// [NonAction] - public async Task SaveBookingStatus(long bookingId, string code, string name) + private async Task SaveBookingStatus(long bookingId, string code, string name) { var bookSta = _repBookingStatus.FirstOrDefault(x => x.BookingId == bookingId && x.StaCode == code); if (bookSta == null) diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index e5a691df..e9551e35 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -13839,116 +13839,11 @@ EDI类型名称 - - - 服务器IP - - - - - 文件夹 - - - - - 用户名 - - - - - 密码 - - - - - 发送方代码 - - - - - 接收方代码 - - - - - 发送方名称 - - - - - 发送方联系人 - - - - - 发送方邮箱 - - - - - 发送方电话 - - - - - 发送方公司代码 - - - - - 发送方部门代码 - - 船公司代码 - - - 接收方邮箱 - - - - - 接收方SI邮箱 - - - - - 接收方操作 - - - - - 接收方销售 - - - - - 接收方部门 - - - - - 发送人电话 - - - - - 收货人电话 - - - - - 通知人电话 - - - - - 是否设置TEL - - 租户ID diff --git a/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs b/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs index f47aef8c..1754687d 100644 --- a/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs +++ b/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs @@ -22,7 +22,7 @@ namespace Myshipping.Core.Service private readonly SqlSugarRepository _rep; private readonly ISysCacheService _cacheService; private readonly ILogger _logger; - + public DjyEdiSettingService(SqlSugarRepository rep, ILogger logger, ISysCacheService cacheService) { _rep = rep; @@ -38,32 +38,11 @@ namespace Myshipping.Core.Service [HttpGet("/DjyEdiSetting/page")] public async Task Page([FromQuery] QueryDjyEdiSettingInput input) { - _rep.Context.QueryFilter.Clear(); - var entities = await _rep.AsQueryable() + var entities = await _rep.AsQueryable().Filter(null, true) .WhereIF(!string.IsNullOrWhiteSpace(input.EDICODE), u => u.EDICODE == input.EDICODE) .WhereIF(!string.IsNullOrWhiteSpace(input.EDINAME), u => u.EDINAME.Contains(input.EDINAME.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SERVERIP), u => u.SERVERIP.Contains(input.SERVERIP.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.FOLDERNAME), u => u.FOLDERNAME.Contains(input.FOLDERNAME.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.USERNAME), u => u.USERNAME.Contains(input.USERNAME.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.PASSWORD), u => u.PASSWORD.Contains(input.PASSWORD.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SENDCODE), u => u.SENDCODE.Contains(input.SENDCODE.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.RECEIVECODE), u => u.RECEIVECODE.Contains(input.RECEIVECODE.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SENDNAME), u => u.SENDNAME.Contains(input.SENDNAME.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SENDATTN), u => u.SENDATTN.Contains(input.SENDATTN.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SENDTEL), u => u.SENDTEL.Contains(input.SENDTEL.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SENDEMAIL), u => u.SENDEMAIL.Contains(input.SENDEMAIL.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SENDCOMPANYCODE), u => u.SENDCOMPANYCODE.Contains(input.SENDCOMPANYCODE.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SENDSUBCOMPANYCODE), u => u.SENDSUBCOMPANYCODE.Contains(input.SENDSUBCOMPANYCODE.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.CARRIERID), u => u.CARRIERID.Contains(input.CARRIERID.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.RECEIVEEMAIL), u => u.RECEIVEEMAIL.Contains(input.RECEIVEEMAIL.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.RECEIVESIEMAIL), u => u.RECEIVESIEMAIL.Contains(input.RECEIVESIEMAIL.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.RECEIVEOP), u => u.RECEIVEOP.Contains(input.RECEIVEOP.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.RECEIVESALE), u => u.RECEIVESALE.Contains(input.RECEIVESALE.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.RECEIVEDEPT), u => u.RECEIVEDEPT.Contains(input.RECEIVEDEPT.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.SHIPPERTEL), u => u.SHIPPERTEL.Contains(input.SHIPPERTEL.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.CONSIGNEETEL), u => u.CONSIGNEETEL.Contains(input.CONSIGNEETEL.Trim())) - .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYTEL), u => u.NOTIFYPARTYTEL == input.NOTIFYPARTYTEL) - .WhereIF(!string.IsNullOrWhiteSpace(input.ISUSETEL), u => u.ISUSETEL == input.ISUSETEL) + .WhereIF(input.TenantId > 0, u => u.TenantId == input.TenantId) .WhereIF(!string.IsNullOrWhiteSpace(input.TenantName), u => u.TenantName.Contains(input.TenantName.Trim())) .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); diff --git a/Myshipping.Core/Service/DjyEdiSetting/Dto/DjyEdiSettingInput.cs b/Myshipping.Core/Service/DjyEdiSetting/Dto/DjyEdiSettingInput.cs index 471df7af..223eeaf8 100644 --- a/Myshipping.Core/Service/DjyEdiSetting/Dto/DjyEdiSettingInput.cs +++ b/Myshipping.Core/Service/DjyEdiSetting/Dto/DjyEdiSettingInput.cs @@ -193,117 +193,12 @@ namespace Myshipping.Core /// EDI类型名称 /// public virtual string EDINAME { get; set; } - - /// - /// 服务器IP - /// - public virtual string SERVERIP { get; set; } - - /// - /// 文件夹 - /// - public virtual string FOLDERNAME { get; set; } - - /// - /// 用户名 - /// - public virtual string USERNAME { get; set; } - - /// - /// 密码 - /// - public virtual string PASSWORD { get; set; } - - /// - /// 发送方代码 - /// - public virtual string SENDCODE { get; set; } - - /// - /// 接收方代码 - /// - public virtual string RECEIVECODE { get; set; } - - /// - /// 发送方名称 - /// - public virtual string SENDNAME { get; set; } - - /// - /// 发送方联系人 - /// - public virtual string SENDATTN { get; set; } - - /// - /// 发送方邮箱 - /// - public virtual string SENDTEL { get; set; } - - /// - /// 发送方电话 - /// - public virtual string SENDEMAIL { get; set; } - - /// - /// 发送方公司代码 - /// - public virtual string SENDCOMPANYCODE { get; set; } - - /// - /// 发送方部门代码 - /// - public virtual string SENDSUBCOMPANYCODE { get; set; } - + /// /// 船公司代码 /// public virtual string CARRIERID { get; set; } - /// - /// 接收方邮箱 - /// - public virtual string RECEIVEEMAIL { get; set; } - - /// - /// 接收方SI邮箱 - /// - public virtual string RECEIVESIEMAIL { get; set; } - - /// - /// 接收方操作 - /// - public virtual string RECEIVEOP { get; set; } - - /// - /// 接收方销售 - /// - public virtual string RECEIVESALE { get; set; } - - /// - /// 接收方部门 - /// - public virtual string RECEIVEDEPT { get; set; } - - /// - /// 发送人电话 - /// - public virtual string SHIPPERTEL { get; set; } - - /// - /// 收货人电话 - /// - public virtual string CONSIGNEETEL { get; set; } - - /// - /// 通知人电话 - /// - public virtual string NOTIFYPARTYTEL { get; set; } - - /// - /// 是否设置TEL - /// - public virtual string ISUSETEL { get; set; } - /// /// 租户ID /// diff --git a/Myshipping.Report/Myshipping.Report.csproj.user b/Myshipping.Report/Myshipping.Report.csproj.user index c54031d1..5831b7bf 100644 --- a/Myshipping.Report/Myshipping.Report.csproj.user +++ b/Myshipping.Report/Myshipping.Report.csproj.user @@ -8,7 +8,7 @@ - Release|Any CPU + Debug|Any CPU