获取场站数据

booking_auth_dev
wanghaomei 2 years ago
parent 8215685b89
commit 9083456d20

@ -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
{
/// <summary>
/// 获取场站数据辅助类(调用爬虫新运踪接口)
/// </summary>
public static class YardDataHelper
{
public static async Task<KeyValuePair<bool, string>> GetYardData(long tenantId, string tenantName, string mblno, string yardid, bool isWeb = true)
{
var cacheService = App.GetService<ISysCacheService>();
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<bool, string>(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<bool, string>(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<bool, string>(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<bool, string>(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;
}
}
}

@ -47,6 +47,7 @@ using Myshipping.Application.EDI.WY;
using Myshipping.Application.EDI.YML; using Myshipping.Application.EDI.YML;
using Myshipping.Application.EDI.YT; using Myshipping.Application.EDI.YT;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Myshipping.Application.Helper;
namespace Myshipping.Application namespace Myshipping.Application
{ {
@ -262,7 +263,7 @@ namespace Myshipping.Application
[HttpPost("/BookingOrder/Add")] [HttpPost("/BookingOrder/Add")]
public async Task Add(AddBookingOrderInput input) public async Task Add(AddBookingOrderInput input)
{ {
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail"); JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail");
JsonUtil.TrimFields(input); JsonUtil.TrimFields(input);
if (input.ctnInputs != null) if (input.ctnInputs != null)
@ -552,7 +553,7 @@ namespace Myshipping.Application
FilePath = fileRelaPath, FilePath = fileRelaPath,
TypeCode = dto.TypeCode, TypeCode = dto.TypeCode,
TypeName = dto.TypeName, TypeName = dto.TypeName,
BookingId= dto.BookingId BookingId = dto.BookingId
}; };
await _bookingfile.InsertAsync(newFile); await _bookingfile.InsertAsync(newFile);
using (var stream = File.Create(fileAbsPath)) using (var stream = File.Create(fileAbsPath))
@ -1691,12 +1692,12 @@ namespace Myshipping.Application
throw Oops.Oh($"货明细的包装{cargo.KINDPKGS}的EDI代码未找到"); throw Oops.Oh($"货明细的包装{cargo.KINDPKGS}的EDI代码未找到");
cargoModel.KINDPKGS_EDI_CODE = ediDetailPkgs.MapCode; cargoModel.KINDPKGS_EDI_CODE = ediDetailPkgs.MapCode;
primaryModel.CTNGOODSLIST.Add(cargoModel); primaryModel.CTNGOODSLIST.Add(cargoModel);
} }
//这里临时赋值,等明确对应的扩展表字段后赋值 //这里临时赋值,等明确对应的扩展表字段后赋值
#if DEBUG #if DEBUG
primaryModel.MasterBOLIndicator = "A1"; primaryModel.MasterBOLIndicator = "A1";
primaryModel.ConsigneeEdiCode = "CEE1"; primaryModel.ConsigneeEdiCode = "CEE1";
primaryModel.ShipperEdiCode = "SHIP1"; primaryModel.ShipperEdiCode = "SHIP1";
@ -1715,9 +1716,9 @@ namespace Myshipping.Application
throw Oops.Bah(result.msg); throw Oops.Bah(result.msg);
} }
return result.extra.ToString(); return result.extra.ToString();
} }
@ -1997,6 +1998,31 @@ namespace Myshipping.Application
} }
/// <summary>
/// 获取场站数据
/// </summary>
/// <param name="bookingId"></param>
/// <param name="isWeb"></param>
/// <returns></returns>
[HttpGet("/BookingOrder/GetYardData")]
public async Task<string> 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;
}
/// <summary> /// <summary>
/// 记录或更新订舱状态 /// 记录或更新订舱状态
/// </summary> /// </summary>
@ -2005,7 +2031,7 @@ namespace Myshipping.Application
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
[NonAction] [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); var bookSta = _repBookingStatus.FirstOrDefault(x => x.BookingId == bookingId && x.StaCode == code);
if (bookSta == null) if (bookSta == null)

@ -13839,116 +13839,11 @@
EDI类型名称 EDI类型名称
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SERVERIP">
<summary>
服务器IP
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.FOLDERNAME">
<summary>
文件夹
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.USERNAME">
<summary>
用户名
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.PASSWORD">
<summary>
密码
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SENDCODE">
<summary>
发送方代码
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.RECEIVECODE">
<summary>
接收方代码
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SENDNAME">
<summary>
发送方名称
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SENDATTN">
<summary>
发送方联系人
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SENDTEL">
<summary>
发送方邮箱
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SENDEMAIL">
<summary>
发送方电话
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SENDCOMPANYCODE">
<summary>
发送方公司代码
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SENDSUBCOMPANYCODE">
<summary>
发送方部门代码
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.CARRIERID"> <member name="P:Myshipping.Core.QueryDjyEdiSettingInput.CARRIERID">
<summary> <summary>
船公司代码 船公司代码
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.RECEIVEEMAIL">
<summary>
接收方邮箱
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.RECEIVESIEMAIL">
<summary>
接收方SI邮箱
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.RECEIVEOP">
<summary>
接收方操作
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.RECEIVESALE">
<summary>
接收方销售
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.RECEIVEDEPT">
<summary>
接收方部门
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.SHIPPERTEL">
<summary>
发送人电话
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.CONSIGNEETEL">
<summary>
收货人电话
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.NOTIFYPARTYTEL">
<summary>
通知人电话
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.ISUSETEL">
<summary>
是否设置TEL
</summary>
</member>
<member name="P:Myshipping.Core.QueryDjyEdiSettingInput.TenantId"> <member name="P:Myshipping.Core.QueryDjyEdiSettingInput.TenantId">
<summary> <summary>
租户ID 租户ID

@ -22,7 +22,7 @@ namespace Myshipping.Core.Service
private readonly SqlSugarRepository<DjyEdiSetting> _rep; private readonly SqlSugarRepository<DjyEdiSetting> _rep;
private readonly ISysCacheService _cacheService; private readonly ISysCacheService _cacheService;
private readonly ILogger<DjyEdiSetting> _logger; private readonly ILogger<DjyEdiSetting> _logger;
public DjyEdiSettingService(SqlSugarRepository<DjyEdiSetting> rep, ILogger<DjyEdiSetting> logger, ISysCacheService cacheService) public DjyEdiSettingService(SqlSugarRepository<DjyEdiSetting> rep, ILogger<DjyEdiSetting> logger, ISysCacheService cacheService)
{ {
_rep = rep; _rep = rep;
@ -38,32 +38,11 @@ namespace Myshipping.Core.Service
[HttpGet("/DjyEdiSetting/page")] [HttpGet("/DjyEdiSetting/page")]
public async Task<dynamic> Page([FromQuery] QueryDjyEdiSettingInput input) public async Task<dynamic> Page([FromQuery] QueryDjyEdiSettingInput input)
{ {
_rep.Context.QueryFilter.Clear(); var entities = await _rep.AsQueryable().Filter(null, true)
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.EDICODE), u => u.EDICODE == input.EDICODE) .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.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.CARRIERID), u => u.CARRIERID.Contains(input.CARRIERID.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.RECEIVEEMAIL), u => u.RECEIVEEMAIL.Contains(input.RECEIVEEMAIL.Trim())) .WhereIF(input.TenantId > 0, u => u.TenantId == input.TenantId)
.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(!string.IsNullOrWhiteSpace(input.TenantName), u => u.TenantName.Contains(input.TenantName.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.TenantName), u => u.TenantName.Contains(input.TenantName.Trim()))
.ToPagedListAsync(input.PageNo, input.PageSize); .ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult(); return entities.XnPagedResult();

@ -193,117 +193,12 @@ namespace Myshipping.Core
/// EDI类型名称 /// EDI类型名称
/// </summary> /// </summary>
public virtual string EDINAME { get; set; } public virtual string EDINAME { get; set; }
/// <summary>
/// 服务器IP
/// </summary>
public virtual string SERVERIP { get; set; }
/// <summary>
/// 文件夹
/// </summary>
public virtual string FOLDERNAME { get; set; }
/// <summary>
/// 用户名
/// </summary>
public virtual string USERNAME { get; set; }
/// <summary>
/// 密码
/// </summary>
public virtual string PASSWORD { get; set; }
/// <summary>
/// 发送方代码
/// </summary>
public virtual string SENDCODE { get; set; }
/// <summary>
/// 接收方代码
/// </summary>
public virtual string RECEIVECODE { get; set; }
/// <summary>
/// 发送方名称
/// </summary>
public virtual string SENDNAME { get; set; }
/// <summary>
/// 发送方联系人
/// </summary>
public virtual string SENDATTN { get; set; }
/// <summary>
/// 发送方邮箱
/// </summary>
public virtual string SENDTEL { get; set; }
/// <summary>
/// 发送方电话
/// </summary>
public virtual string SENDEMAIL { get; set; }
/// <summary>
/// 发送方公司代码
/// </summary>
public virtual string SENDCOMPANYCODE { get; set; }
/// <summary>
/// 发送方部门代码
/// </summary>
public virtual string SENDSUBCOMPANYCODE { get; set; }
/// <summary> /// <summary>
/// 船公司代码 /// 船公司代码
/// </summary> /// </summary>
public virtual string CARRIERID { get; set; } public virtual string CARRIERID { get; set; }
/// <summary>
/// 接收方邮箱
/// </summary>
public virtual string RECEIVEEMAIL { get; set; }
/// <summary>
/// 接收方SI邮箱
/// </summary>
public virtual string RECEIVESIEMAIL { get; set; }
/// <summary>
/// 接收方操作
/// </summary>
public virtual string RECEIVEOP { get; set; }
/// <summary>
/// 接收方销售
/// </summary>
public virtual string RECEIVESALE { get; set; }
/// <summary>
/// 接收方部门
/// </summary>
public virtual string RECEIVEDEPT { get; set; }
/// <summary>
/// 发送人电话
/// </summary>
public virtual string SHIPPERTEL { get; set; }
/// <summary>
/// 收货人电话
/// </summary>
public virtual string CONSIGNEETEL { get; set; }
/// <summary>
/// 通知人电话
/// </summary>
public virtual string NOTIFYPARTYTEL { get; set; }
/// <summary>
/// 是否设置TEL
/// </summary>
public virtual string ISUSETEL { get; set; }
/// <summary> /// <summary>
/// 租户ID /// 租户ID
/// </summary> /// </summary>

@ -8,7 +8,7 @@
<IISExpressWindowsAuthentication /> <IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode /> <IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile /> <UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig> <LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <VisualStudio>

Loading…
Cancel
Save