|
|
@ -0,0 +1,430 @@
|
|
|
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Op.Dtos;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Op.Dtos.BookingAI;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Op.Interface;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
|
|
|
using LanguageExt.Pipes;
|
|
|
|
|
|
|
|
using MathNet.Numerics;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
using NPOI.OpenXmlFormats.Dml.Diagram;
|
|
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public class SeaExportAIService: ISeaExportAIService
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
|
|
|
|
private readonly IUser user;
|
|
|
|
|
|
|
|
private readonly ISaasDbService saasService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="serviceProvider"></param>
|
|
|
|
|
|
|
|
public SeaExportAIService(IServiceProvider serviceProvider)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
|
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
|
|
|
|
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<DataResult<SeaExportAIRes>> GetBookingAIResultAsync(IFormFile file)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
//未上传文件
|
|
|
|
|
|
|
|
if (file == null || file.Length == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportAIRes>.Failed("上传文件不存在!"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var config = await db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "booking_ai_api_url" && x.Status == StatusEnum.Enable).FirstAsync();
|
|
|
|
|
|
|
|
if (config.IsNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportAIRes>.Failed("booking_ai_api_url接口地址未配置!"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var url = config.Value;
|
|
|
|
|
|
|
|
var originalFilename = file.FileName; // 文件原始名称
|
|
|
|
|
|
|
|
var ms = new MemoryStream();
|
|
|
|
|
|
|
|
await file.CopyToAsync(ms);
|
|
|
|
|
|
|
|
//使用HttpClient方式上传文件
|
|
|
|
|
|
|
|
ms.Position = 0;
|
|
|
|
|
|
|
|
var formData = new MultipartFormDataContent();
|
|
|
|
|
|
|
|
formData.Add(new StreamContent(ms, (int)ms.Length), "file", originalFilename);
|
|
|
|
|
|
|
|
formData.Add(new StringContent("QWEN"), "platform");
|
|
|
|
|
|
|
|
var _httpclient = new HttpClient();
|
|
|
|
|
|
|
|
var response = await _httpclient.PostAsync(url, formData);
|
|
|
|
|
|
|
|
if (response.IsSuccessStatusCode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var strRtn = response.Content.ReadAsStringAsync().Result;
|
|
|
|
|
|
|
|
var res = JsonConvert.DeserializeObject<ParseItemRes>(strRtn);
|
|
|
|
|
|
|
|
if (res.Code == 200)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Console.WriteLine(res.Data);
|
|
|
|
|
|
|
|
var result = await DealAIData(res,tenantDb);
|
|
|
|
|
|
|
|
//return await Task.FromResult(DataResult<SeaExportAIRes>.Success(newFile.FileName));
|
|
|
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportAIRes>.Success(result));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportAIRes>.Failed(res.Msg));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportAIRes>.Failed("请求AI文件解析接口错误,请联系管理员!"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<SeaExportAIRes> DealAIData(ParseItemRes req,SqlSugarScopeProvider tenantDb) {
|
|
|
|
|
|
|
|
var aiInfo = req.Data[0];
|
|
|
|
|
|
|
|
var info = new SeaExportAIRes() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Id = 0,
|
|
|
|
|
|
|
|
ParentId = 0,
|
|
|
|
|
|
|
|
BusinessStatus = "Uncommitted",
|
|
|
|
|
|
|
|
BusinessStatusName = "未提交",
|
|
|
|
|
|
|
|
CustomerNo = "",
|
|
|
|
|
|
|
|
MBLNO = aiInfo.BLNo,
|
|
|
|
|
|
|
|
BookingNo = aiInfo.ReferenceNo,
|
|
|
|
|
|
|
|
Voyno = aiInfo.Voyage,
|
|
|
|
|
|
|
|
ClosingDate = String.IsNullOrEmpty(aiInfo.ClosingDate)? null : DateTime.Parse(aiInfo.ClosingDate),
|
|
|
|
|
|
|
|
VGMCloseDate = String.IsNullOrEmpty(aiInfo.VGMCutOffTime) ? null : DateTime.Parse(aiInfo.VGMCutOffTime),
|
|
|
|
|
|
|
|
ETA = String.IsNullOrEmpty(aiInfo.ETA) ? null : DateTime.Parse(aiInfo.ETA),
|
|
|
|
|
|
|
|
ETD = String.IsNullOrEmpty(aiInfo.ETD) ? null : DateTime.Parse(aiInfo.ETD),
|
|
|
|
|
|
|
|
CloseDocDate = String.IsNullOrEmpty(aiInfo.CutSingleTime) ? null : DateTime.Parse(aiInfo.CutSingleTime),
|
|
|
|
|
|
|
|
Remark = aiInfo.Remark,
|
|
|
|
|
|
|
|
Service = aiInfo.ShippingTerms,
|
|
|
|
|
|
|
|
ServiceContractNo =aiInfo.AboutNo,
|
|
|
|
|
|
|
|
YardATTN = aiInfo.StationContact,
|
|
|
|
|
|
|
|
YardTel = aiInfo.StationContactNumber,
|
|
|
|
|
|
|
|
//PortOfDestinationETA ShippingWay PreportTransportationMode CollectionTerminal CYCutOffTime
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//委托单位
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.BookingParty))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var client = await tenantDb.Queryable<InfoClient>().Where(a => a.Description.Contains(aiInfo.BookingParty) && SqlFunc.Subqueryable<InfoClientAttribute>().Where(
|
|
|
|
|
|
|
|
b => b.ClientId == a.Id && b.Value == "isController").Any()).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (client.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.CustomerId = client.Id;
|
|
|
|
|
|
|
|
info.CustomerName = client.ShortName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.CustomerName = aiInfo.BookingParty;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//发货人
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.Shipper))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var client = await tenantDb.Queryable<InfoClient>().Where(a => a.Description.Contains(aiInfo.Shipper) && SqlFunc.Subqueryable<InfoClientAttribute>().Where(
|
|
|
|
|
|
|
|
b => b.ClientId == a.Id && b.Value == "isShipper").Any()).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (client.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.ShipperId = client.Id;
|
|
|
|
|
|
|
|
info.Shipper = client.ShortName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.Shipper = aiInfo.Shipper;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//收货人
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.Consigner))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var client = await tenantDb.Queryable<InfoClient>().Where(a => a.Description.Contains(aiInfo.Consigner) && SqlFunc.Subqueryable<InfoClientAttribute>().Where(
|
|
|
|
|
|
|
|
b => b.ClientId == a.Id && b.Value == "isConsigner").Any()).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (client.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.ConsigneeId = client.Id;
|
|
|
|
|
|
|
|
info.Consignee = client.ShortName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.Consignee = aiInfo.Consigner;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//通知人
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.NotifyParty))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var client = await tenantDb.Queryable<InfoClient>().Where(a => a.Description.Contains(aiInfo.NotifyParty) && SqlFunc.Subqueryable<InfoClientAttribute>().Where(
|
|
|
|
|
|
|
|
b => b.ClientId == a.Id && b.Value == "isNotifyParty").Any()).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (client.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.NotifyPartyId = client.Id;
|
|
|
|
|
|
|
|
info.NotifyParty = client.ShortName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.NotifyParty = aiInfo.NotifyParty;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//船名
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.Vessel))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var vessel = await tenantDb.Queryable<CodeVessel>().Where(a => a.VesselName.Contains(aiInfo.Vessel)).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (vessel.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.VesselId = vessel.Id;
|
|
|
|
|
|
|
|
info.Vessel = vessel.VesselName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.Vessel = aiInfo.Vessel;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//船公司
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.ShippingCompany))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var client = await tenantDb.Queryable<CodeCarrier>().Where(a => a.EnName.Contains(aiInfo.ShippingCompany) ).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (client.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.CarrierId = client.Id;
|
|
|
|
|
|
|
|
info.Carrier = client.EdiCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.Carrier = aiInfo.ShippingCompany;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//收货地
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.PlaceOfReceipt))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var port = await tenantDb.Queryable<CodePort>().Where(a => a.PortName.Contains(aiInfo.PlaceOfReceipt)).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.ReceiptPlaceId = port.Id;
|
|
|
|
|
|
|
|
info.ReceiptPlace = port.PortName;
|
|
|
|
|
|
|
|
info.ReceiptPlaceCode = port.EdiCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.ReceiptPlace = aiInfo.PlaceOfReceipt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//装货港
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.LoadingPort))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var port = await tenantDb.Queryable<CodePort>().Where(a => a.PortName.Contains(aiInfo.LoadingPort)).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.LoadPortId = port.Id;
|
|
|
|
|
|
|
|
info.LoadPort = port.PortName;
|
|
|
|
|
|
|
|
info.LoadPortCode = port.EdiCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.LoadPort = aiInfo.LoadingPort;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//卸货港
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.DischargingPort))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var port = await tenantDb.Queryable<CodePort>().Where(a => a.PortName.Contains(aiInfo.DischargingPort)).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.DischargePortId = port.Id;
|
|
|
|
|
|
|
|
info.DischargePort = port.PortName;
|
|
|
|
|
|
|
|
info.DischargePortCode = port.EdiCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.DischargePort = aiInfo.DischargingPort;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//交货地
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.DeliveryPlace))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var port = await tenantDb.Queryable<CodePort>().Where(a => a.PortName.Contains(aiInfo.DeliveryPlace)).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.DeliveryPlaceId = port.Id;
|
|
|
|
|
|
|
|
info.DeliveryPlace = port.PortName;
|
|
|
|
|
|
|
|
info.DeliveryPlaceCode = port.EdiCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.DeliveryPlace = aiInfo.DeliveryPlace;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//品名
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.OfTheGoods))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var good = await tenantDb.Queryable<CodeGoods>().Where(a => a.GoodName.Contains(aiInfo.OfTheGoods)).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (good.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.GoodsId = good.Id;
|
|
|
|
|
|
|
|
info.GoodsName = good.GoodName;
|
|
|
|
|
|
|
|
info.HSCode = good.HSCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.GoodsName = aiInfo.OfTheGoods;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//签单地
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.SignTheBillLocation))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var port = await tenantDb.Queryable<CodePort>().Where(a => a.PortName.Contains(aiInfo.SignTheBillLocation)).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.IssuePlaceId = port.Id;
|
|
|
|
|
|
|
|
info.IssuePlace = port.PortName;
|
|
|
|
|
|
|
|
info.IssuePlaceCode = port.EdiCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.IssuePlace = aiInfo.SignTheBillLocation;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//预付地
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.PlaceInAdvance))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var port = await tenantDb.Queryable<CodePort>().Where(a => a.PortName.Contains(aiInfo.PlaceInAdvance)).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (port.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.PayableAtId = port.Id;
|
|
|
|
|
|
|
|
info.PayableAt = port.PortName;
|
|
|
|
|
|
|
|
info.PayableAtCode = port.EdiCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.PayableAt = aiInfo.PlaceInAdvance;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//船代
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.ShipAgency))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var client = await tenantDb.Queryable<InfoClient>().Where(a => a.Description.Contains(aiInfo.ShipAgency) && SqlFunc.Subqueryable<InfoClientAttribute>().Where(
|
|
|
|
|
|
|
|
b => b.ClientId == a.Id && b.Value == "isShipAgency").Any()).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (client.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.ShipAgencyId = client.Id;
|
|
|
|
|
|
|
|
info.ShipAgency = client.ShortName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.ShipAgency = aiInfo.ShipAgency;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//货代
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.FreightForwarder))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var client = await tenantDb.Queryable<InfoClient>().Where(a => a.Description.Contains(aiInfo.ShipAgency) && SqlFunc.Subqueryable<InfoClientAttribute>().Where(
|
|
|
|
|
|
|
|
b => b.ClientId == a.Id && b.Value == "isBooking").Any()).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (client.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.ForwarderId = client.Id;
|
|
|
|
|
|
|
|
info.Forwarder = client.ShortName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.Forwarder = aiInfo.FreightForwarder;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//场站
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.Station))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var client = await tenantDb.Queryable<InfoClient>().Where(a => a.Description.Contains(aiInfo.Station) && SqlFunc.Subqueryable<InfoClientAttribute>().Where(
|
|
|
|
|
|
|
|
b => b.ClientId == a.Id && b.Value == "isYard").Any()).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (client.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.YardId = client.Id;
|
|
|
|
|
|
|
|
info.Yard = client.ShortName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.Yard = aiInfo.Station;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//客服
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(aiInfo.FirstCustomerServiceName))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var service = await db.Queryable<SysUser>().Where(a => a.UserEnName.Contains(aiInfo.FirstCustomerServiceName) ).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (service.IsNotNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.CustomerService = service.Id;
|
|
|
|
|
|
|
|
info.CustomerServiceName = service.UserEnName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
info.CustomerServiceName = aiInfo.FirstCustomerServiceName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//集装箱信息
|
|
|
|
|
|
|
|
if (aiInfo.Containers.IsNotNull() && aiInfo.Containers.Count>0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var ctnList = new List<OpCtnRes>();
|
|
|
|
|
|
|
|
var ctns = await tenantDb.Queryable<CodeCtn>().ToListAsync();
|
|
|
|
|
|
|
|
foreach (var item in aiInfo.Containers)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var ctnInfo = ctns.FirstOrDefault(x => x.CtnName == item.BoxPile.Replace("'", ""));
|
|
|
|
|
|
|
|
if (ctnInfo.IsNotNull()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctnList.Add(new OpCtnRes()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = 0,
|
|
|
|
|
|
|
|
BSNO ="",
|
|
|
|
|
|
|
|
CtnId = ctnInfo.Id,
|
|
|
|
|
|
|
|
CtnCode = ctnInfo.EdiCode,
|
|
|
|
|
|
|
|
Ctn = ctnInfo.CtnName,
|
|
|
|
|
|
|
|
CtnNum = int.Parse(item.CartonQuantity),
|
|
|
|
|
|
|
|
Size = item.Size,
|
|
|
|
|
|
|
|
KGS = !String.IsNullOrEmpty(item.GrossWeight) ? decimal.Parse(item.GrossWeight.Replace(" KGM", "")) :0,
|
|
|
|
|
|
|
|
TareWeight = !String.IsNullOrEmpty(item.TareWeight) ? decimal.Parse(item.TareWeight.Replace(" KGM", "")) : 0,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ctnList.Add(new OpCtnRes()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = 0,
|
|
|
|
|
|
|
|
BSNO = "",
|
|
|
|
|
|
|
|
Ctn = item.BoxPile.Replace("'", ""),
|
|
|
|
|
|
|
|
CtnNum = int.Parse(item.CartonQuantity),
|
|
|
|
|
|
|
|
Size = item.Size,
|
|
|
|
|
|
|
|
KGS = !String.IsNullOrEmpty(item.GrossWeight) ? decimal.Parse(item.GrossWeight.Replace(" KGM", "")) : 0,
|
|
|
|
|
|
|
|
TareWeight = !String.IsNullOrEmpty(item.TareWeight) ? decimal.Parse(item.TareWeight.Replace(" KGM", "")) : 0,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
info.CtnInfo = ctnList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|