修改派车的引入场站数据

optimize
jianghaiqing 2 years ago
parent 0736176506
commit 43819d8d0d

@ -1,9 +1,11 @@
using Furion; using Furion;
using Furion.FriendlyException;
using Furion.Logging; using Furion.Logging;
using Furion.RemoteRequest.Extensions; using Furion.RemoteRequest.Extensions;
using Myshipping.Core; using Myshipping.Core;
using Myshipping.Core.Service; using Myshipping.Core.Service;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Asn1.X500;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -17,6 +19,16 @@ namespace Myshipping.Application.Helper
/// </summary> /// </summary>
public static class YardDataHelper public static class YardDataHelper
{ {
/// <summary>
/// 异步调取出口运踪场站详情(按箱明细显示)
/// </summary>
/// <param name="userId">用户名ID</param>
/// <param name="tenantId">租户ID</param>
/// <param name="tenantName">租户名称</param>
/// <param name="mblno">提单号</param>
/// <param name="yardid">场站ID</param>
/// <param name="isWeb">是否网站</param>
/// <returns>返回场站详情(按箱明细显示)</returns>
public static async Task<KeyValuePair<bool, string>> GetYardData(long userId, long tenantId, string tenantName, string mblno, string yardid, bool isWeb = true) public static async Task<KeyValuePair<bool, string>> GetYardData(long userId, long tenantId, string tenantName, string mblno, string yardid, bool isWeb = true)
{ {
var cacheService = App.GetService<ISysCacheService>(); var cacheService = App.GetService<ISysCacheService>();
@ -116,6 +128,62 @@ namespace Myshipping.Application.Helper
} }
} }
#region 异步调取出口运踪场站详情
/// <summary>
/// 异步调取出口运踪场站详情(按箱明细显示,并对箱型做了本地转换)
/// </summary>
/// <param name="userId">用户名ID</param>
/// <param name="tenantId">租户ID</param>
/// <param name="tenantName">租户名称</param>
/// <param name="mblno">提单号</param>
/// <param name="yardid">场站ID</param>
/// <param name="isWeb">是否网站</param>
/// <returns>返回场站详情(按箱明细显示,并对箱型做了本地转换)</returns>
public static async Task<string> GetYardDataWithTranslateAsync(long userId, long tenantId, string tenantName, string mblno,
string yardid, bool isWeb = true)
{
var rtn = await GetYardData(userId, tenantId, tenantName, mblno, yardid, isWeb);
if (!rtn.Key)
{
throw Oops.Bah(rtn.Value);
}
var _cache = App.GetService<ISysCacheService>();
//场站引入的数据,转换为订舱箱型,且带上箱型代码
var ctnList = await _cache.GetAllCodeCtn();
var mapCtn = await _cache.GetAllMappingCtn();
var jData = JArray.Parse(rtn.Value);
foreach (JObject item in jData)
{
var ctnall = item.GetStringValue("CTNALL");
var findMap = mapCtn.FirstOrDefault(x => x.Module == "YardData" && x.MapCode == ctnall);
var findCtn = ctnList.FirstOrDefault(x => x.Name == ctnall);
if (findMap != null)
{
item.Add("CtnCode", findMap.Code);
findCtn = ctnList.First(c => c.Code == findMap.Code);
item["CTNALL"] = findCtn.Name; //名称显示维护的箱型
}
else if (findCtn != null)
{
item.Add("CtnCode", findCtn.Code);
item["CTNALL"] = findCtn.Name; //名称显示维护的箱型
}
else
{
throw Oops.Bah($"未找到箱型{ctnall}的场站引入配置");
}
}
return jData.ToString();
}
#endregion
private static string GetDataHtmlList(string html, string startstr, string endstr) private static string GetDataHtmlList(string html, string startstr, string endstr)
{ {
var subhtml = html; var subhtml = html;

@ -1804,6 +1804,29 @@ namespace Myshipping.Application
if (bookingTruckInfo.TenantId.HasValue) if (bookingTruckInfo.TenantId.HasValue)
messageInfo.Main.TenantId = bookingTruckInfo.TenantId.Value; messageInfo.Main.TenantId = bookingTruckInfo.TenantId.Value;
//这里增加判断如果派车回写里包含车队信息,自动回写到订舱信息里
if(!string.IsNullOrWhiteSpace(info.TruckCode))
{
var bookingOrder = _bookingOrderRepository.AsQueryable()
.First(a => a.Id == bookingTruckInfo.BookingId);
if(bookingOrder != null && string.IsNullOrWhiteSpace(bookingOrder.TRUCKERID))
{
_logger.LogInformation("判断回写需要更新订舱的车队 id={id} truck={truck}", bookingTruckInfo.BookingId, info.TruckName);
bookingOrder.TRUCKERID = info.TruckCode;
bookingOrder.TRUCKER = info.TruckName;
await _bookingOrderRepository.AsUpdateable(bookingOrder).UpdateColumns(it => new
{
it.TRUCKERID,
it.TRUCKER
}).ExecuteCommandAsync();
_logger.LogInformation("判断回写需要更新订舱的车队,更新完成");
}
}
var mqRlt = await PushSyncBookingTruckMQToDS6(messageInfo); var mqRlt = await PushSyncBookingTruckMQToDS6(messageInfo);
_logger.LogInformation("发送MQrlt={rlt}", JSON.Serialize(mqRlt)); _logger.LogInformation("发送MQrlt={rlt}", JSON.Serialize(mqRlt));
@ -1918,15 +1941,10 @@ namespace Myshipping.Application
throw Oops.Bah("提单号不能为空"); throw Oops.Bah("提单号不能为空");
} }
var rtn = await YardDataHelper.GetYardData(UserManager.UserId, bookingOrder.TenantId.Value, bookingOrder.TenantName, var rtn = await YardDataHelper.GetYardDataWithTranslateAsync(UserManager.UserId, bookingOrder.TenantId.Value, bookingOrder.TenantName,
mblNo, yardId, isWeb); mblNo, yardId, isWeb);
if (!rtn.Key) return rtn;
{
throw Oops.Bah(rtn.Value);
}
return rtn.Value;
} }
} }
} }

Loading…
Cancel
Save