|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using Amazon.Runtime.Internal.Util;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Constants;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.DjyServiceStatus;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
@ -37,7 +38,9 @@ using NPOI.XWPF.UserModel;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text.Json.Nodes;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
{
|
|
|
|
@ -55,6 +58,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
private readonly IUserService _userService;
|
|
|
|
|
private readonly IUserEmailService _userEmailService;
|
|
|
|
|
private readonly IWebHostEnvironment _environment;
|
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
|
|
|
|
|
|
// 按需构建
|
|
|
|
|
private Lazy<IBookingSlotService> bookingSlotService;
|
|
|
|
@ -93,6 +97,8 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
_userEmailService = userEmailService;
|
|
|
|
|
_environment = environment;
|
|
|
|
|
|
|
|
|
|
db = serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
|
|
|
|
|
bookingSlotService = new Lazy<IBookingSlotService>(serviceProvider.GetRequiredService<IBookingSlotService>);
|
|
|
|
|
seaExportService = new Lazy<ISeaExportService>(serviceProvider.GetRequiredService<ISeaExportService>);
|
|
|
|
|
djyServiceStatusService = new Lazy<IDjyServiceStatusService>(serviceProvider.GetRequiredService<IDjyServiceStatusService>);
|
|
|
|
@ -257,7 +263,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
throw new Exception($"未获取有效任务记录,更新失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var currBCOrder = await tenantDb.Queryable<TaskBaseInfo>().Where(a => a.Id == bcEntity.Id).FirstAsync();
|
|
|
|
|
//if (currBCOrder != null && model.IsDirectSend)
|
|
|
|
@ -1110,6 +1116,81 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 对比BC与海运出口订单(任务台使用)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<DataResult<TaskManageExcuteResultDto>> ExcuteCompareTask(TaskFlowDataContext dataContext)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var taskBcId = dataContext.Get<long?>(TaskFlowDataNameConst.TaskBCId);
|
|
|
|
|
if (taskBcId == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCId)}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var taskBcInfo = await tenantDb.Queryable<TaskBCInfo>().Where(x => x.Id == taskBcId).FirstAsync();
|
|
|
|
|
if (taskBcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
string msg = $"执行ExcuteCompareTask时,根据未获取到BC信息";
|
|
|
|
|
logger.LogInformation(msg);
|
|
|
|
|
return DataResult<TaskManageExcuteResultDto>.Failed("对比失败:" + msg);
|
|
|
|
|
}
|
|
|
|
|
var taskBcCtnList = await tenantDb.Queryable<TaskBCCTNInfo>().Where(x => x.P_ID == taskBcInfo.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
// 运费协议号(约号)是唯一的,服务合同号可能不是唯一的
|
|
|
|
|
|
|
|
|
|
// BC信息
|
|
|
|
|
ParserBCInfoDto bcSrcDto = new ParserBCInfoDto()
|
|
|
|
|
{
|
|
|
|
|
ContractNo = taskBcInfo.CONTRACTNO,
|
|
|
|
|
Vessel = taskBcInfo.VESSEL,
|
|
|
|
|
VoyNo = taskBcInfo.VOYNO,
|
|
|
|
|
//TemperatureMin = taskBcInfo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//bcTargetDto.CtnList = dto.DataObj.CtnList.GroupBy(x => x.CtnAll)
|
|
|
|
|
// .Select(x =>
|
|
|
|
|
// {
|
|
|
|
|
// return new ParserBCCTNInfoDto
|
|
|
|
|
// {
|
|
|
|
|
// CtnALL = x.Key,
|
|
|
|
|
// CtnNum = x.ToList().Sum(a => a.CtnNum)
|
|
|
|
|
// };
|
|
|
|
|
// }).ToList();
|
|
|
|
|
|
|
|
|
|
var seaExport = await tenantDb.Queryable<SeaExport>().Where(x => x.MBLNO == taskBcInfo.MBL_NO).FirstAsync();
|
|
|
|
|
|
|
|
|
|
// 订单信息
|
|
|
|
|
ParserBCInfoDto bcTargetDto = new ParserBCInfoDto()
|
|
|
|
|
{
|
|
|
|
|
ContractNo = seaExport.ContractNo,
|
|
|
|
|
Vessel = seaExport.Vessel,
|
|
|
|
|
VoyNo = seaExport.Voyno,
|
|
|
|
|
TemperatureMin = seaExport.TemperatureMin,
|
|
|
|
|
TemperatureMax = seaExport.TemperatureMax,
|
|
|
|
|
TemperatureSet = seaExport.TemperatureSet,
|
|
|
|
|
Humidity = seaExport.Humidity,
|
|
|
|
|
DischargePort = seaExport.DischargePort,
|
|
|
|
|
Destination = seaExport.Destination,
|
|
|
|
|
|
|
|
|
|
//CtnList = new List<ParserBCCTNInfoDto>(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return default;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 生成并推送邮件
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1120,7 +1201,9 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
/// <param name="orderInfo">检索订舱相关</param>
|
|
|
|
|
/// <param name="usePersonalEmailSend">是否默认使用用户个人邮箱发送</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
private async Task<DataResult> GenerateSendEmail(TaskBCInfo taskBCInfo, TaskBaseInfo bcTaskInfo, SeaExportOrderExtension orderInfo, bool usePersonalEmailSend = false)
|
|
|
|
|
private async Task<DataResult> GenerateSendEmail(TaskBCInfo taskBCInfo, TaskBaseInfo bcTaskInfo, SeaExportOrderExtension orderInfo, SeaExport currSeaExportOrder,
|
|
|
|
|
bool saveBookingId = false,
|
|
|
|
|
bool usePersonalEmailSend = false)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
string msg = string.Empty;
|
|
|
|
@ -1153,10 +1236,26 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
var bookingOrderEntity = orderInfo.currOrder;
|
|
|
|
|
var bookingOrderEntity = currSeaExportOrder;
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"获取订舱详情完成,bookid={bookingOrderEntity.Id}");
|
|
|
|
|
|
|
|
|
|
if (saveBookingId && taskBCInfo.BOOKING_ORDER_ID != currSeaExportOrder.Id)
|
|
|
|
|
{
|
|
|
|
|
taskBCInfo.BOOKING_ORDER_ID = currSeaExportOrder.Id;
|
|
|
|
|
taskBCInfo.UpdateTime = DateTime.Now;
|
|
|
|
|
taskBCInfo.UpdateBy = long.Parse(user.UserId);
|
|
|
|
|
taskBCInfo.UpdateUserName = user.UserName;
|
|
|
|
|
|
|
|
|
|
await tenantDb.Updateable<TaskBCInfo>(taskBCInfo).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BOOKING_ORDER_ID,
|
|
|
|
|
x.UpdateTime,
|
|
|
|
|
x.UpdateBy,
|
|
|
|
|
x.UpdateUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bookingOrderEntity.CustomerId == 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"订舱的委托客户不能为空");
|
|
|
|
@ -1180,7 +1279,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
string opEmail = string.Empty;
|
|
|
|
|
|
|
|
|
|
var bookingContactList = tenantDb.Queryable<BusinessOrderContact>()
|
|
|
|
|
.Where(a => a.BusinessId == taskBCInfo.BOOKING_ORDER_ID).ToList();
|
|
|
|
|
.Where(a => a.BusinessId == currSeaExportOrder.Id).ToList();
|
|
|
|
|
|
|
|
|
|
if (bookingContactList == null || bookingContactList.Count == 0)
|
|
|
|
|
{
|
|
|
|
@ -1265,8 +1364,15 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fileInfo = tenantDb.Queryable<TaskFileInfo>().Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY_NOTICE"))
|
|
|
|
|
.OrderByDescending(a => a.CreateTime).First();
|
|
|
|
|
if (orderInfo.splitOrMergeFlag == 1)
|
|
|
|
|
{
|
|
|
|
|
//这里需要按照箱量重新修改变更附件
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fileInfo = tenantDb.Queryable<TaskFileInfo>().Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY_NOTICE"))
|
|
|
|
|
.OrderByDescending(a => a.CreateTime).First();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -1541,7 +1647,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(basePath))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = Path.Combine(_environment.WebRootPath, relativePath);
|
|
|
|
|
dirAbs = Path.Combine(_environment.WebRootPath ?? "", relativePath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1815,11 +1921,11 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
private async Task<DataResult> PushEmail(EmailApiUserDefinedDto emailApiUserDefinedDto, string filePath)
|
|
|
|
|
{
|
|
|
|
|
List<EmailApiUserDefinedDto> emailList = new List<EmailApiUserDefinedDto>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
|
string msg = string.Empty;
|
|
|
|
|
|
|
|
|
|
var emailUrl = "";
|
|
|
|
|
var emailUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "email_api_url" && x.TenantId == 1288018625843826688).First().Value;
|
|
|
|
|
|
|
|
|
|
if (emailUrl == null)
|
|
|
|
|
throw new Exception("字典未配置 url_set->email_api_url 请联系管理员");
|
|
|
|
@ -1854,10 +1960,13 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
DateTime bDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
HttpResponseMessage res = null;
|
|
|
|
|
string res = string.Empty;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var jsonBody = JsonConvert.SerializeObject(emailList);
|
|
|
|
|
|
|
|
|
|
res = RequestHelper.Post(jsonBody, emailUrl);
|
|
|
|
|
//res = await emailUrl.SetBody(emailList, "application/json").PostAsync();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -1871,13 +1980,13 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"邮件上传完成 上传文件大小:{heByte.Length} 用时:{timeDiff}ms.,");
|
|
|
|
|
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"发送邮件返回:{JsonConvert.SerializeObject(res)}");
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"发送邮件返回:{res}");
|
|
|
|
|
|
|
|
|
|
if (res != null && res.StatusCode == System.Net.HttpStatusCode.OK)
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(res))
|
|
|
|
|
{
|
|
|
|
|
var userResult = await res.Content.ReadAsStringAsync();
|
|
|
|
|
//var userResult = await res.Content.ReadAsStringAsync();
|
|
|
|
|
|
|
|
|
|
var respObj = JsonConvert.DeserializeAnonymousType(userResult, new
|
|
|
|
|
var respObj = JsonConvert.DeserializeAnonymousType(res, new
|
|
|
|
|
{
|
|
|
|
|
Success = false,
|
|
|
|
|
Message = string.Empty,
|
|
|
|
@ -1952,23 +2061,73 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
if (orderInfo != null && orderInfo.currOrder != null)
|
|
|
|
|
{
|
|
|
|
|
//更新订舱相关内容
|
|
|
|
|
|
|
|
|
|
if (paramConfig.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
await GenerateSendEmail(taskBcInfo, taskBaseInfo, orderInfo);
|
|
|
|
|
//如果是拆票需要按照分票明细单个发送邮件
|
|
|
|
|
if (orderInfo.splitOrMergeFlag == 1)
|
|
|
|
|
{
|
|
|
|
|
var splitOrderIds = new List<long>();
|
|
|
|
|
|
|
|
|
|
splitOrderIds.Add(orderInfo.currOrder.Id);
|
|
|
|
|
splitOrderIds.Append(orderInfo.otherOrderList.Select(b => b.Id).ToList());
|
|
|
|
|
|
|
|
|
|
var bookList = tenantDb.Queryable<SeaExport>().Where(b => splitOrderIds.Contains(b.Id)).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var seaExportId in splitOrderIds)
|
|
|
|
|
{
|
|
|
|
|
var currSeaExport = bookList.FirstOrDefault(b => b.Id == seaExportId);
|
|
|
|
|
|
|
|
|
|
bool saveBookingId = currSeaExport.Id == orderInfo.currOrder.Id;
|
|
|
|
|
|
|
|
|
|
await GenerateSendEmail(taskBcInfo, taskBaseInfo, orderInfo, currSeaExport, saveBookingId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var currSeaExport = tenantDb.Queryable<SeaExport>().First(b => b.Id == orderInfo.currOrder.Id);
|
|
|
|
|
//普通和合票都按单票处理
|
|
|
|
|
await GenerateSendEmail(taskBcInfo, taskBaseInfo, orderInfo, currSeaExport, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//这里没有取到订舱信息,终止,并发出邮件通知
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"taskPKId={taskPKId} mblno={taskBcInfo.MBL_NO} 当前租户未配置自动转发邮件");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//终止执行
|
|
|
|
|
//这里没有取到订舱信息,终止,并发出邮件通知
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"taskPKId={taskPKId} mblno={taskBcInfo.MBL_NO} 没有找到订单");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"执行SyncBookingSlotChange时,异常{ex.Message}");
|
|
|
|
|
|
|
|
|
|
return DataResult.Failed($"执行SyncBookingSlotChange时,异常{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Successed("");
|
|
|
|
|
return DataResult.Successed(MultiLanguageConst.DataCreateSuccess);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 同步舱位变更(任务自动)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dataContext">上下文</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<DataResult> SyncBookingSlotChangeTask(TaskFlowDataContext dataContext)
|
|
|
|
|
{
|
|
|
|
|
var taskBaseId = dataContext.Get<long?>(TaskFlowDataNameConst.TaskBaseId);
|
|
|
|
|
if (taskBaseId == null)
|
|
|
|
|
{
|
|
|
|
|
Logger.Log(NLog.LogLevel.Info, $"执行ApiReceiveTask时,未获取到{TaskFlowDataNameConst.TaskBaseId}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await SyncBookingSlotChange(taskBaseId.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|