|
|
|
@ -38,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
|
|
|
|
|
{
|
|
|
|
@ -56,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;
|
|
|
|
@ -94,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>);
|
|
|
|
@ -1196,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;
|
|
|
|
@ -1229,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($"订舱的委托客户不能为空");
|
|
|
|
@ -1256,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)
|
|
|
|
|
{
|
|
|
|
@ -1269,7 +1292,10 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
if (bookingOrderEntity.OperatorId > 0)
|
|
|
|
|
{
|
|
|
|
|
var opId = bookingOrderEntity.OperatorId;
|
|
|
|
|
var opUser = _userService.GetUserInfo(opId.ToString()).Data;
|
|
|
|
|
|
|
|
|
|
var opUser = db.Queryable<SysUser>().Filter(null,true).First(x => x.Id == bookingOrderEntity.OperatorId && x.TenantId == long.Parse(user.TenantId));
|
|
|
|
|
|
|
|
|
|
//var opUser = _userService.GetUserInfo(opId.ToString()).Data;
|
|
|
|
|
|
|
|
|
|
if (opUser != null && !string.IsNullOrWhiteSpace(opUser.Email))
|
|
|
|
|
{
|
|
|
|
@ -1303,7 +1329,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
string emailTitle = $"Booking Confirmation : {taskBCInfo.MBL_NO}";
|
|
|
|
|
string filePath = string.Empty;
|
|
|
|
|
|
|
|
|
|
UserViewModel opUserInfo = _userService.GetUserInfo(bookingOrderEntity.OperatorId.ToString()).Data;
|
|
|
|
|
var opUserInfo = db.Queryable<SysUser>().Filter(null, true).First(x => x.Id == bookingOrderEntity.OperatorId && x.TenantId == long.Parse(user.TenantId));
|
|
|
|
|
|
|
|
|
|
if (taskBCInfo.BUSI_TYPE == "BookingAmendment")
|
|
|
|
|
{
|
|
|
|
@ -1341,8 +1367,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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -1440,7 +1473,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
/// <param name="opUserInfo">订舱OP详情</param>
|
|
|
|
|
/// <param name="tenantName">当前租户全称</param>
|
|
|
|
|
/// <returns>返回生成的HTML</returns>
|
|
|
|
|
public async Task<string> GenerateSendEmailHtml(TaskBCInfo taskBCInfo, UserViewModel opUserInfo, string tenantName)
|
|
|
|
|
public async Task<string> GenerateSendEmailHtml(TaskBCInfo taskBCInfo, SysUser opUserInfo, string tenantName)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
|
|
|
|
@ -1599,7 +1632,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
/// <param name="opUserInfo">订舱OP详情</param>
|
|
|
|
|
/// <param name="tenantName">当前租户全称</param>
|
|
|
|
|
/// <returns>返回生成的HTML</returns>
|
|
|
|
|
public async Task<string> GenerateSendEmailHtmlAmendment(TaskBCInfo taskBCInfo, UserViewModel opUserInfo, string tenantName)
|
|
|
|
|
public async Task<string> GenerateSendEmailHtmlAmendment(TaskBCInfo taskBCInfo, SysUser opUserInfo, string tenantName)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
|
|
|
|
@ -1617,7 +1650,7 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(basePath))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = Path.Combine(_environment.WebRootPath, relativePath);
|
|
|
|
|
dirAbs = Path.Combine(_environment.WebRootPath ?? "", relativePath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1891,11 +1924,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 请联系管理员");
|
|
|
|
@ -1930,10 +1963,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)
|
|
|
|
@ -1947,13 +1983,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,
|
|
|
|
@ -2028,23 +2064,73 @@ namespace DS.WMS.Core.TaskPlat.Method
|
|
|
|
|
if (orderInfo != null && orderInfo.currOrder != null)
|
|
|
|
|
{
|
|
|
|
|
//更新订舱相关内容
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(paramConfig) && paramConfig.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
//如果是拆票需要按照分票明细单个发送邮件
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
if (paramConfig.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
await GenerateSendEmail(taskBcInfo, taskBaseInfo, orderInfo);
|
|
|
|
|
//这里没有取到订舱信息,终止,并发出邮件通知
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|