|
|
@ -25,12 +25,16 @@ using DS.WMS.Core.TaskPlat.Interface;
|
|
|
|
using HtmlAgilityPack;
|
|
|
|
using HtmlAgilityPack;
|
|
|
|
using Mapster;
|
|
|
|
using Mapster;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -50,6 +54,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
private readonly IWebHostEnvironment _environment;
|
|
|
|
private readonly IWebHostEnvironment _environment;
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
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<IBookingSlotService> bookingSlotService;
|
|
|
|
private Lazy<ISeaExportService> seaExportService;
|
|
|
|
private Lazy<ISeaExportService> seaExportService;
|
|
|
@ -65,6 +74,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
//自动转发是否默认抄送操作
|
|
|
|
//自动转发是否默认抄送操作
|
|
|
|
const string CONST_AUTO_TRANS_EMAIL_OP_CCTO = "AUTO_TRANS_EMAIL_OP_CCTO";
|
|
|
|
const string CONST_AUTO_TRANS_EMAIL_OP_CCTO = "AUTO_TRANS_EMAIL_OP_CCTO";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TaskManageBCService(IUser user,
|
|
|
|
public TaskManageBCService(IUser user,
|
|
|
|
ILogger<TaskManageBCService> logger,
|
|
|
|
ILogger<TaskManageBCService> logger,
|
|
|
@ -97,6 +107,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
tenantDb.QueryFilter.Clear<IOrgId>();
|
|
|
|
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>
|
|
|
|
/// <summary>
|
|
|
@ -1121,12 +1136,12 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 对比BC与海运出口订单(任务台使用)
|
|
|
|
/// 对比BC与海运出口订单(任务台使用)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public async Task<DataResult<CompareResultInfo>> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext)
|
|
|
|
public async Task<DataResult<(bool isExistsDiff, List<CompareResultDetailInfo>)>> CompareBcWithSeaExportTask(TaskFlowDataContext dataContext)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var taskBcInfo = dataContext.Get<TaskBCInfo?>(TaskFlowDataNameConst.TaskBCInfo) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCInfo)}");
|
|
|
|
var taskBcInfo = dataContext.Get<TaskBCInfo?>(TaskFlowDataNameConst.TaskBCInfo) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCInfo)}");
|
|
|
|
var taskBcCtnList = dataContext.Get<List<TaskBCCTNInfo>?>(TaskFlowDataNameConst.TaskBCCtnList) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCCtnList)}");
|
|
|
|
var taskBcCtnList = dataContext.Get<List<TaskBCCTNInfo>?>(TaskFlowDataNameConst.TaskBCCtnList) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCCtnList)}");
|
|
|
|
|
|
|
|
|
|
|
|
var seaExport = await tenantDb.Queryable<SeaExport>().Where(x => x.ParentId == 0 && taskBcInfo.MBL_NO == x.MBLNO).Select(x => new SeaExport()
|
|
|
|
var seaExport = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID).Select(x => new SeaExport()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|
MBLNO = x.MBLNO,
|
|
|
|
MBLNO = x.MBLNO,
|
|
|
@ -1159,19 +1174,18 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
SeaExport = seaExport,
|
|
|
|
SeaExport = seaExport,
|
|
|
|
OpCtnList = seaExportCtnList
|
|
|
|
OpCtnList = seaExportCtnList
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var result = await CompareBcWithSeaExport(compareDto);
|
|
|
|
(bool isExistsDiff, List<CompareResultDetailInfo>) result = await CompareBcWithSeaExport(compareDto);
|
|
|
|
|
|
|
|
|
|
|
|
dataContext.Set(TaskFlowDataNameConst.BcCompareWithSeaExportResult, result);
|
|
|
|
dataContext.Set(TaskFlowDataNameConst.BcCompareBcWithSeaExportIsExistsDiff, result.isExistsDiff);
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult<CompareResultInfo>.Success(result);
|
|
|
|
return DataResult<(bool isExistsDiff, List<CompareResultDetailInfo>)>.Success(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 对比BC与海运出口订单
|
|
|
|
/// 对比BC与海运出口订单
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public async Task<CompareResultInfo> CompareBcWithSeaExport(CompareBcWithSeaExportDto compareDto)
|
|
|
|
public async Task<(bool isExistsDiff, List<CompareResultDetailInfo>)> CompareBcWithSeaExport(CompareBcWithSeaExportDto compareDto)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var taskBcInfo = compareDto.TaskBCInfo;
|
|
|
|
var taskBcInfo = compareDto.TaskBCInfo;
|
|
|
|
var taskBcCtnList = compareDto.TaskBCCtnList;
|
|
|
|
var taskBcCtnList = compareDto.TaskBCCtnList;
|
|
|
|
var seaExport = compareDto.SeaExport;
|
|
|
|
var seaExport = compareDto.SeaExport;
|
|
|
@ -1243,7 +1257,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
|
|
logger.LogInformation($"批次={batchNo} taskBcInfo.id={taskBcInfo.Id} seaExport.id={seaExport.Id} 请求BC对比订单结果完成,耗时:{timeDiff}ms,是否成功:{(compareResult?.succ == true ? "成功" : "失败")} ");
|
|
|
|
logger.LogInformation($"批次={batchNo} taskBcInfo.id={taskBcInfo.Id} seaExport.id={seaExport.Id} 请求BC对比订单结果完成,耗时:{timeDiff}ms,是否成功:{(compareResult?.succ == true ? "成功" : "失败")} ");
|
|
|
|
|
|
|
|
|
|
|
|
if (compareResult != null && compareResult?.succ == true)
|
|
|
|
if (compareResult != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogInformation($"批次={batchNo} BC对比订单结果={JsonConvert.SerializeObject(compareResult)}");
|
|
|
|
logger.LogInformation($"批次={batchNo} BC对比订单结果={JsonConvert.SerializeObject(compareResult)}");
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
@ -1289,22 +1303,13 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
it.UpdateUserName
|
|
|
|
it.UpdateUserName
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new CompareResultInfo()
|
|
|
|
|
|
|
|
{
|
|
|
|
return (compareResult.extra.IsExistsDiff, compareResult.extra.ShowDetailList);
|
|
|
|
IsExistsDiff = compareResult.extra.IsExistsDiff,
|
|
|
|
|
|
|
|
ShowDetailList = compareResult.extra.ShowDetailList,
|
|
|
|
|
|
|
|
DetailList = compareResult.extra.DetailList,
|
|
|
|
|
|
|
|
IsSuccess = true
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//return (compareResult.extra.IsExistsDiff, compareResult.extra.ShowDetailList);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger.LogError($"批次={batchNo} BC对比订单结果为空");
|
|
|
|
logger.LogError($"批次={batchNo} BC对比订单结果为空");
|
|
|
|
return new CompareResultInfo()
|
|
|
|
throw new Exception($"批次={batchNo} BC对比订单结果为空");
|
|
|
|
{
|
|
|
|
|
|
|
|
IsSuccess = false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2271,5 +2276,163 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
|
|
return await SyncBookingSlotChange(taskBaseId.Value);
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|