|
|
|
@ -25,11 +25,22 @@ using DS.WMS.Core.TaskPlat.Interface;
|
|
|
|
|
using HtmlAgilityPack;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using NLog;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using LanguageExt.Common;
|
|
|
|
|
using Microsoft.AspNet.SignalR.Hosting;
|
|
|
|
|
using Masuit.Tools;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
{
|
|
|
|
@ -49,6 +60,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
private readonly IWebHostEnvironment _environment;
|
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
|
|
|
|
|
|
private readonly string bcCompareUrl;
|
|
|
|
|
private readonly string bcMSKReadUrl;
|
|
|
|
|
private readonly string bcMSKModifyFileUrl;
|
|
|
|
|
private readonly string bcCMAReadUrl;
|
|
|
|
|
|
|
|
|
|
// 按需构建
|
|
|
|
|
private Lazy<IBookingSlotService> bookingSlotService;
|
|
|
|
|
private Lazy<ISeaExportService> seaExportService;
|
|
|
|
@ -64,6 +80,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
//自动转发是否默认抄送操作
|
|
|
|
|
const string CONST_AUTO_TRANS_EMAIL_OP_CCTO = "AUTO_TRANS_EMAIL_OP_CCTO";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TaskManageBCService(IUser user,
|
|
|
|
|
ILogger<TaskManageBCService> logger,
|
|
|
|
@ -96,6 +113,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
tenantDb.QueryFilter.Clear<IOrgId>();
|
|
|
|
|
|
|
|
|
|
bcCompareUrl = AppSetting.app(new string[] { "BCCompare", "Url" });
|
|
|
|
|
bcMSKReadUrl = AppSetting.app(new string[] { "BCCompare", "MSKBCReadUrl" });
|
|
|
|
|
bcMSKModifyFileUrl = AppSetting.app(new string[] { "BCCompare", "MSKBCModifyFileUrl" });
|
|
|
|
|
bcCMAReadUrl = AppSetting.app(new string[] { "BCCompare", "CMABCReadUrl" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -2231,5 +2253,163 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
return await SyncBookingSlotChange(taskBaseId.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 读取BC详情
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取BC详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="carrierCode">船公司代码</param>
|
|
|
|
|
/// <param name="file">BC文件</param>
|
|
|
|
|
/// <returns>返回解析详情</returns>
|
|
|
|
|
public async Task<DataResult<ParserBCInfoDto>> GetReadBC(string carrierCode, IFormFile file)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
|
string msg = string.Empty;
|
|
|
|
|
|
|
|
|
|
var messageInfo = new
|
|
|
|
|
{
|
|
|
|
|
Head = new
|
|
|
|
|
{
|
|
|
|
|
GID = SnowFlakeSingle.Instance.NextId().ToString(),
|
|
|
|
|
MessageType = "BOOKING_GAMENDMENT",
|
|
|
|
|
SenderId = AppSetting.app(new string[] { "ExcuteRuleService", "RulesEngineSender" }),
|
|
|
|
|
SenderName = AppSetting.app(new string[] { "ExcuteRuleService", "RulesEngineSenderName" }),
|
|
|
|
|
ReceiverId = "RulesEngine",
|
|
|
|
|
ReceiverName = "大简云规则引擎",
|
|
|
|
|
Version = "1.0",
|
|
|
|
|
RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
|
|
RequestAction = "ReadFile",
|
|
|
|
|
},
|
|
|
|
|
Main = new
|
|
|
|
|
{
|
|
|
|
|
TenantId = user.TenantId.ToString()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using (var httpClient = new HttpClient())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var reduceAttach = new MultipartFormDataContent())
|
|
|
|
|
{
|
|
|
|
|
var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageInfo)));
|
|
|
|
|
|
|
|
|
|
dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
|
|
|
|
|
{
|
|
|
|
|
Name = "jsonData"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reduceAttach.Add(dataContent);
|
|
|
|
|
|
|
|
|
|
#region 文件参数
|
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
|
|
|
|
var Content = new ByteArrayContent(file.ToByteArray());
|
|
|
|
|
|
|
|
|
|
Content.Headers.Add("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
reduceAttach.Add(Content, "file", HttpUtility.UrlEncode(file.FileName));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
var url = string.Empty;
|
|
|
|
|
|
|
|
|
|
if (carrierCode.Equals("MSK", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
url = bcMSKReadUrl;
|
|
|
|
|
|
|
|
|
|
if (carrierCode.Equals("CMA", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
url = bcCMAReadUrl;
|
|
|
|
|
//请求
|
|
|
|
|
var response = httpClient.PostAsync(url, reduceAttach).Result;
|
|
|
|
|
string result = response.Content.ReadAsStringAsync().Result;
|
|
|
|
|
|
|
|
|
|
var model = JsonConvert.DeserializeObject<BCReadResultDto>(result);
|
|
|
|
|
|
|
|
|
|
if(model != null && model.succ)
|
|
|
|
|
{
|
|
|
|
|
var bcInfo = JsonConvert.DeserializeObject<ParserBCInfoDto>(JsonConvert.SerializeObject(model.extra));
|
|
|
|
|
|
|
|
|
|
return DataResult<ParserBCInfoDto>.Success(bcInfo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
msg = model.msg;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, "请求BC读取详情异常,原因:{error}", ex.Message);
|
|
|
|
|
|
|
|
|
|
msg = $"请求BC读取详情异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult<ParserBCInfoDto>.Failed(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读取BC擦写后文件流
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取BC擦写后文件流
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="carrierCode">船公司代码</param>
|
|
|
|
|
/// <param name="file">BC文件</param>
|
|
|
|
|
/// <returns>返回解析详情</returns>
|
|
|
|
|
public async Task<DataResult<byte[]>> GetModifyBCFile(string carrierCode, IFormFile file)
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes;
|
|
|
|
|
|
|
|
|
|
var result = string.Empty;
|
|
|
|
|
|
|
|
|
|
using (var httpClient = new HttpClient())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var reduceAttach = new MultipartFormDataContent())
|
|
|
|
|
{
|
|
|
|
|
var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(""));
|
|
|
|
|
|
|
|
|
|
dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
|
|
|
|
|
{
|
|
|
|
|
Name = "jsonData"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reduceAttach.Add(dataContent);
|
|
|
|
|
|
|
|
|
|
#region 文件参数
|
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
|
|
|
|
var Content = new ByteArrayContent(file.ToByteArray());
|
|
|
|
|
|
|
|
|
|
Content.Headers.Add("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
reduceAttach.Add(Content, "file", HttpUtility.UrlEncode(file.FileName));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//请求
|
|
|
|
|
var response = httpClient.PostAsync(bcMSKModifyFileUrl, reduceAttach).Result;
|
|
|
|
|
bytes = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
return DataResult<byte[]>.Success(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, "请求自动变更文件内容异常,原因:{error}", ex.Message);
|
|
|
|
|
|
|
|
|
|
result = $"请求自动变更文件内容异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult<byte[]>.Failed(result);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|