运踪接口 及部分修改

master
ZR20090193-陈敬勇 7 months ago
parent 0a4ada0508
commit c4d0de85d4

@ -326,7 +326,7 @@ public static class MultiLanguageConst
#endregion #endregion
#region 海出口 #region 海出口
[Description("海运出口信息已存在")] [Description("海运出口信息已存在")]
public const string SeaExportExist = "Sea_Export_Exist"; public const string SeaExportExist = "Sea_Export_Exist";
[Description("海运出口信息不存在")] [Description("海运出口信息不存在")]
@ -336,6 +336,9 @@ public static class MultiLanguageConst
[Description("海运出口备注不存在")] [Description("海运出口备注不存在")]
public const string SeaExportRemarkNotExist = "Sea_Export_Remark_Not_Exist"; public const string SeaExportRemarkNotExist = "Sea_Export_Remark_Not_Exist";
[Description("请先选择场站!")]
public const string SeaExportYardCheck = "Sea_Export_Yard_Check";
[Description("海运出口存在费用信息")] [Description("海运出口存在费用信息")]
public const string SeaExportFeeExist = "Sea_Export_Fee_Exist"; public const string SeaExportFeeExist = "Sea_Export_Fee_Exist";

@ -224,13 +224,23 @@ public class DataResult<TData> : IDataResult<ResultCode, TData>
/// ///
/// </summary> /// </summary>
/// <param name="message"></param> /// <param name="message"></param>
/// <param name="ResultCode"></param>
/// <param name="multiCode"></param> /// <param name="multiCode"></param>
/// <returns></returns> /// <returns></returns>
public static DataResult<TData> Failed(string message, ResultCode ResultCode = ResultCode.Error,string multiCode ="") public static DataResult<TData> Failed(string message, string multiCode = "")
{ {
return new DataResult<TData>(ResultCode, message,multiCode); return new DataResult<TData>(ResultCode.Error, message, multiCode);
} }
///// <summary>
/////
///// </summary>
///// <param name="message"></param>
///// <param name="ResultCode"></param>
///// <param name="multiCode"></param>
///// <returns></returns>
//public static DataResult<TData> Failed(string message, ResultCode ResultCode = ResultCode.Error,string multiCode ="")
//{
// return new DataResult<TData>(ResultCode, message,multiCode);
//}
/// <summary> /// <summary>
/// ///

@ -14,7 +14,7 @@ using SqlSugar;
namespace DS.Module.CrawlerData namespace DS.Module.CrawlerData
{ {
public class CrawlerDataService : ICrawlerDataService internal class CrawlerDataService : ICrawlerDataService
{ {
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db; private readonly ISqlSugarClient db;

@ -1,6 +1,7 @@
using DS.Module.Core; using DS.Module.Core;
using DS.WMS.Core.Code.Dtos; using DS.WMS.Core.Code.Dtos;
using FluentValidation; using FluentValidation;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -23,7 +24,10 @@ namespace DS.WMS.Core.Map.Dtos
/// 关联业务id /// 关联业务id
/// </summary> /// </summary>
public long LinkId { get; set; } public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary> /// <summary>
/// 模块 /// 模块
/// </summary> /// </summary>

@ -23,7 +23,10 @@ namespace DS.WMS.Core.Map.Dtos
/// </summary> /// </summary>
public long LinkId { get; set; } public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary> /// <summary>
/// 模块 /// 模块

@ -24,7 +24,10 @@ namespace DS.WMS.Core.Map.Dtos
/// </summary> /// </summary>
public long LinkId { get; set; } public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary> /// <summary>
/// 模块 /// 模块
/// </summary> /// </summary>

@ -23,7 +23,10 @@ namespace DS.WMS.Core.Map.Dtos
/// </summary> /// </summary>
public long LinkId { get; set; } public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary> /// <summary>
/// 模块 /// 模块

@ -1,4 +1,5 @@
using DS.Module.Core.Data; using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -18,7 +19,11 @@ namespace DS.WMS.Core.Map.Entity
/// 关联业务id /// 关联业务id
/// </summary> /// </summary>
public long LinkId { get; set; } public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
[SugarColumn(ColumnDescription = "代码", Length = 100, IsNullable = false)]
public string Code { get; set; }
/// <summary> /// <summary>
/// 模块 /// 模块
/// </summary> /// </summary>
@ -42,5 +47,11 @@ namespace DS.WMS.Core.Map.Entity
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "船司Id", IsNullable = true,DefaultValue ="0")] [SugarColumn(ColumnDescription = "船司Id", IsNullable = true,DefaultValue ="0")]
public long CarrierId { get; set; } public long CarrierId { get; set; }
/// <summary>
/// 状态 0启用 1禁用
/// </summary>
[SugarColumn(ColumnDescription = "状态", DefaultValue = "0")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
} }
} }

@ -1,4 +1,5 @@
using DS.Module.Core.Data; using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -18,6 +19,11 @@ namespace DS.WMS.Core.Map.Entity
/// 关联业务id /// 关联业务id
/// </summary> /// </summary>
public long LinkId { get; set; } public long LinkId { get; set; }
/// <summary>
/// 代码
/// </summary>
[SugarColumn(ColumnDescription = "代码", Length = 100, IsNullable = false)]
public string Code { get; set; }
/// <summary> /// <summary>
@ -43,5 +49,11 @@ namespace DS.WMS.Core.Map.Entity
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "船司Id", IsNullable = true,DefaultValue ="0")] [SugarColumn(ColumnDescription = "船司Id", IsNullable = true,DefaultValue ="0")]
public long CarrierId { get; set; } public long CarrierId { get; set; }
/// <summary>
/// 状态 0启用 1禁用
/// </summary>
[SugarColumn(ColumnDescription = "状态", DefaultValue = "0")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
} }
} }

@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Dtos
{
/// <summary>
/// 场站箱型引入信息
/// </summary>
public class YardCtnImportRes
{
/// <summary>
/// 箱号
/// </summary>
public string CNTRNO { get; set; }
/// <summary>
/// 封号
/// </summary>
public string SEALNO { get; set; }
/// <summary>
/// 箱型
/// </summary>
public string CTNALL { get; set; }
/// <summary>
/// 箱量
/// </summary>
public int XiangLiang { get; set; }
/// <summary>
/// 船名
/// </summary>
public string VESSEL { get; set; }
/// <summary>
/// 航次
/// </summary>
public string VOYNO { get; set; }
/// <summary>
/// 中转港
/// </summary>
public string tra_name { get; set; }
/// <summary>
/// 卸货港
/// </summary>
public string pod_name { get; set; }
/// <summary>
/// 目的港
/// </summary>
public string Destination { get; set; }
/// <summary>
/// 皮重
/// </summary>
public float? TAREWEIGHT { get; set; }
/// <summary>
/// 车号
/// </summary>
public string CheHao { get; set; }
/// <summary>
/// 包装
/// </summary>
public string KINDPKGS { get; set; }
/// <summary>
/// 件数
/// </summary>
public int PKGS { get; set; }
/// <summary>
/// 尺码
/// </summary>
public float? CBM { get; set; }
/// <summary>
/// 货重
/// </summary>
public float? KGS { get; set; }
/// <summary>
/// 提箱时间
/// </summary>
public string TiXiangShiJian { get; set; }
/// <summary>
/// 返场时间
/// </summary>
public string FanChangShiJian { get; set; }
/// <summary>
/// 集港时间
/// </summary>
public string JiGangShiJian { get; set; }
/// <summary>
/// 计划集港开始时间
/// </summary>
public string PortStartPlanTime { get; set; }
/// <summary>
/// 计划集港结束时间
/// </summary>
public string PortEndPlanTime { get; set; }
/// <summary>
/// 完船时间
/// </summary>
public string WanChuanShiJian { get; set; }
/// <summary>
/// 危险品主等级
/// </summary>
public string DClass { get; set; }
/// <summary>
/// 危险品编号
/// </summary>
public string DUNNo { get; set; }
/// <summary>
/// 危险品副等级
/// </summary>
public string FuDClass { get; set; }
/// <summary>
/// 危险品副编号
/// </summary>
public string FuDUNNo { get; set; }
/// <summary>
/// 海污
/// </summary>
public string HaiWu { get; set; }
/// <summary>
/// 温度
/// </summary>
public string TempSet { get; set; }
/// <summary>
/// 通风
/// </summary>
public string Reeferf { get; set; }
/// <summary>
/// 湿度
/// </summary>
public string Humidity { get; set; }
/// <summary>
/// 箱型代码
/// </summary>
public string CtnCode { get; set; }
}
}

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Dtos
{
/// <summary>
///
/// </summary>
public class YardDataReq
{
///// <summary>
///// 用户名ID
///// </summary>
//public long UserId { get; set; }
///// <summary>
///// 租户ID
///// </summary>
//public long TenantId { get; set; }
///// <summary>
///// 租户名称
///// </summary>
//public string TenantName { get; set; }
/// <summary>
/// 提单号
/// </summary>
public string MBLNO { get; set; }
/// <summary>
/// 场站ID
/// </summary>
public long YardId { get; set; }
/// <summary>
/// 是否网站
/// </summary>
public bool IsWeb { get; set; } = true;
}
}

@ -76,4 +76,12 @@ public interface ISeaExportService
/// <returns></returns> /// <returns></returns>
public DataResult SeaExportFeeUnLook(string id); public DataResult SeaExportFeeUnLook(string id);
/// <summary>
/// 获取场站数据
/// </summary>
/// <param name="id">业务Id</param>
/// <param name="isWeb">是否网站数据 默认false</param>
/// <returns></returns>
public Task<DataResult<string>> GetYardData(string id, bool isWeb = false);
} }

@ -2,22 +2,22 @@ using AngleSharp.Dom;
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data; using DS.Module.Core.Data;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.SqlSugar; using DS.Module.SqlSugar;
using DS.Module.UserModule; using DS.Module.UserModule;
using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Map.Entity;
using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface; using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface; using DS.WMS.Core.System.Interface;
using DS.WMS.Core.System.Method;
using Mapster; using Mapster;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Ocsp;
using SqlSugar; using SqlSugar;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace DS.WMS.Core.Op.Method; namespace DS.WMS.Core.Op.Method;
@ -27,7 +27,7 @@ public class SeaExportService : ISeaExportService
private readonly ISqlSugarClient db; private readonly ISqlSugarClient db;
private readonly IUser user; private readonly IUser user;
private readonly ISaasDbService saasService; private readonly ISaasDbService saasService;
//private readonly ICrawlerDataService crawlerService;
private readonly ICommonService commonService; private readonly ICommonService commonService;
/// <summary> /// <summary>
/// ///
@ -40,6 +40,8 @@ public class SeaExportService : ISeaExportService
user = _serviceProvider.GetRequiredService<IUser>(); user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>(); saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
commonService = _serviceProvider.GetRequiredService<ICommonService>(); commonService = _serviceProvider.GetRequiredService<ICommonService>();
//crawlerService = _serviceProvider.GetRequiredService<ICrawlerDataService>();
} }
/// <summary> /// <summary>
@ -466,7 +468,159 @@ public class SeaExportService : ISeaExportService
} }
#endregion #endregion
/// <summary>
/// 获取场站数据
/// </summary>
/// <param name="id">业务Id</param>
/// <param name="isWeb"></param>
/// <returns></returns>
public async Task<DataResult<string>> GetYardData(string id, bool isWeb = false)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var info = tenantDb.Queryable<SeaExport>().Where(x => x.Id == long.Parse(id)).First();
if (info.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist));
}
if (string.IsNullOrEmpty(info.YardId.ToString()))
{
return await Task.FromResult(DataResult<string>.Failed("请先选择场站!", MultiLanguageConst.SeaExportNotExist));
}
var data = GetYardDataAndMappingSystem(info, isWeb);
return await Task.FromResult(DataResult<string>.Success(""));
}
/// <summary>
/// 从爬虫获取场站数据,并映射为系统中的箱型
/// </summary>
/// <returns></returns>
private async Task<DataResult<List<YardCtnImportRes>>> GetYardDataAndMappingSystem(SeaExport order, bool isWeb = false)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var req = new YardDataReq
{
YardId = order.YardId,
MBLNO = order.MBLNO,
IsWeb = isWeb
};
{
var rtn = await GetYardData(req);
//if (!rtn.Key)
//{
// throw Oops.Bah(rtn.Value);
//}
//场站引入的数据,转换为订舱箱型,且带上箱型代码
var ctnList = tenantDb.Queryable<CodeCtn>().Where(x => x.Status == StatusEnum.Enable).WithCache().ToList();
var mapCtn = tenantDb.Queryable<MappingCtn>().Where(x => x.Status == StatusEnum.Enable).WithCache().ToList();
var listRtn = JsonConvert.DeserializeObject<List<YardCtnImportRes>>(rtn.Data);
foreach (var item in listRtn)
{
var ctnall = item.CTNALL;
var findMap = mapCtn.FirstOrDefault(x => x.Module == "YardData" && x.MapCode == ctnall);
var findCtn = ctnList.FirstOrDefault(x => x.CtnName == ctnall);
if (findMap != null)
{
item.CtnCode = findMap.Code;
findCtn = ctnList.First(c => c.EdiCode == findMap.Code);
item.CTNALL = findCtn.CtnName; //名称显示维护的箱型
}
else if (findCtn != null)
{
item.CtnCode = findCtn.EdiCode;
item.CTNALL = findCtn.CtnName; //名称显示维护的箱型
}
else
{
return await Task.FromResult(DataResult<List<YardCtnImportRes>>.Failed($"未找到箱型{ctnall}的场站引入配置"));
}
}
return await Task.FromResult(DataResult<List<YardCtnImportRes>>.Success(listRtn));
}
}
/// <summary>
/// 异步调取出口运踪场站详情(按箱明细显示)
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult<string>> GetYardData(YardDataReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var account = tenantDb.Queryable<CodeThirdParty>().Where(x => x.CustomerId == req.YardId && x.AccountType == "BillTrace").First();
var userKey = db.Queryable<SysConfig>().Where(x => x.Code == "spiderUserKeyBilltrace").WithCache().First().Value;
var userSecret = db.Queryable<SysConfig>().Where(x => x.Code == "spiderUserSecretBilltrace").WithCache().First().Value;
var spiderServerUrl = db.Queryable<SysConfig>().Where(x => x.Code == "spiderServerUrlBillTraceNew").WithCache().First().Value;
var tenantName = db.Queryable<SysTenant>().Filter(null, true).Where(x => x.Id == long.Parse(user.TenantId)).WithCache().First().Name;
if (account.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed("未配置出口运踪场站第三方账号信息!"));
}
var yardMap = tenantDb.Queryable<MappingYard>().Where(x => x.LinkId == req.YardId && x.Module == "BillTrace").First();
if (yardMap.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed($"场站代号配置未找到:{req.YardId}"));
}
var objSend = new
{
user_key = userKey,
user_secret = userSecret,
customer_id = user.TenantId,
customer_name = tenantName,
web_code = yardMap.MapCode,
bno = req.MBLNO,
req_type = req.IsWeb ? "1" : "0",
web_user = account.AppKey,
web_psw = account.AppSecret,
};
var urlYard = spiderServerUrl;
if (!urlYard.EndsWith("/"))
{
urlYard += "/";
}
urlYard += "real/query";
var res = RequestHelper.Post(JsonConvert.SerializeObject(objSend), urlYard);
var rtnObj = JObject.Parse(res);
if (rtnObj.GetIntValue("code") != 200)
{
return await Task.FromResult(DataResult<string>.Failed("$\"获取场站数失败:{rtnObj.GetStringValue(\"msg\")}\"!"));
}
else
{
var rtnData = rtnObj.GetStringValue("data");
if (req.IsWeb)
{
var viewstatehtml = GetDataHtmlList(rtnData, "__VIEWSTATE", "/>");
if (viewstatehtml != "")
{
rtnData = rtnData.Replace(viewstatehtml, "");
}
}
return await Task.FromResult(DataResult<string>.Success(rtnData));
}
}
public 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;
}
} }

@ -102,54 +102,16 @@ public class SeaExportController : ApiController
var res = _invokeService.SeaExportBatchDel(req); var res = _invokeService.SeaExportBatchDel(req);
return res; return res;
} }
/// <summary>
/// 获取场站数据
///// <summary> /// </summary>
///// 业务锁定 /// <param name="id">业务Id</param>
///// </summary> /// <param name="isWeb">是否网站数据 默认false</param>
///// <param name="id">主键id</param> /// <returns></returns>
///// <returns></returns> [HttpGet]
//[HttpGet] [Route("GetYardData")]
//[Route("SeaExportBusinessLook")] public async Task<DataResult<string>> GetYardData([FromQuery] string id, bool isWeb = false)
//public DataResult SeaExportBusinessLook([FromQuery] string id) {
//{ return await _invokeService.GetYardData(id, isWeb);
// var res = _invokeService.SeaExportBusinessLook(id); }
// return res;
//}
///// <summary>
///// 业务锁定解锁
///// </summary>
///// <param name="id">主键id</param>
///// <returns></returns>
//[HttpGet]
//[Route("SeaExportBusinessUnLook")]
//public DataResult SeaExportBusinessUnLook([FromQuery] string id)
//{
// var res = _invokeService.SeaExportBusinessUnLook(id);
// return res;
//}
///// <summary>
///// 费用锁定
///// </summary>
///// <param name="id">主键id</param>
///// <returns></returns>
//[HttpGet]
//[Route("SeaExportFeeLook")]
//public DataResult SeaExportFeeLook([FromQuery] string id)
//{
// var res = _invokeService.SeaExportFeeLook(id);
// return res;
//}
///// <summary>
///// 费用锁定解锁
///// </summary>
///// <param name="id">主键id</param>
///// <returns></returns>
//[HttpGet]
//[Route("SeaExportFeeUnLook")]
//public DataResult SeaExportFeeUnLook([FromQuery] string id)
//{
// var res = _invokeService.SeaExportFeeUnLook(id);
// return res;
//}
} }

@ -10,6 +10,7 @@ using DS.Module.MultiLanguage;
using DS.Module.SqlSugar; using DS.Module.SqlSugar;
using DS.Module.Swagger; using DS.Module.Swagger;
using DS.Module.UserModule; using DS.Module.UserModule;
using DS.Module.CrawlerData;
using NLog.Web; using NLog.Web;
using Swashbuckle.AspNetCore.SwaggerUI; using Swashbuckle.AspNetCore.SwaggerUI;
@ -41,6 +42,8 @@ builder.Services.AddMultiLanguageInstall();//
// builder.Services.AddEndpointsApiExplorer(); // builder.Services.AddEndpointsApiExplorer();
// builder.Services.AddSwaggerGen(); // builder.Services.AddSwaggerGen();
//builder.Services.AddCrawlerModuleInstall();//ÔË×Ù·þÎñ
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.

Loading…
Cancel
Save