|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Dtos;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
|
using DS.WMS.Core.TaskPlat.Dtos;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
{
|
|
|
|
@ -14,7 +14,8 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class PreAlertTaskService : TaskService, IPreAlertTaskService
|
|
|
|
|
{
|
|
|
|
|
const TaskBaseTypeEnum TASK_TYPE = TaskBaseTypeEnum.PRE_ALERT;
|
|
|
|
|
IMailTemplateService mailTemplateService;
|
|
|
|
|
ITaskLogService logService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
@ -22,6 +23,8 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
/// <param name="provider"></param>
|
|
|
|
|
public PreAlertTaskService(IServiceProvider provider) : base(provider)
|
|
|
|
|
{
|
|
|
|
|
mailTemplateService = provider.GetRequiredService<IMailTemplateService>();
|
|
|
|
|
logService = provider.GetRequiredService<ITaskLogService>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -72,7 +75,9 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
s.Id,
|
|
|
|
|
s.CustomerNo,
|
|
|
|
|
s.CustomerId,
|
|
|
|
|
s.BLConfirmationId,
|
|
|
|
|
s.BLConfirmationId, //提单确认方
|
|
|
|
|
s.AgentId, //国外代理
|
|
|
|
|
s.IssueType,
|
|
|
|
|
s.IssuingWay,
|
|
|
|
|
s.MBLNO,
|
|
|
|
|
s.ETD,
|
|
|
|
@ -123,7 +128,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
foreach (var task in taskList)
|
|
|
|
|
{
|
|
|
|
|
var order = orders.Find(s => s.Id == task.BusinessId);
|
|
|
|
|
var request2 = new TaskCreationRequest
|
|
|
|
|
var request2 = new TaskCreationRequest //委托单位PA
|
|
|
|
|
{
|
|
|
|
|
BusinessId = task.BusinessId,
|
|
|
|
|
BusinessType = task.BusinessType,
|
|
|
|
@ -151,7 +156,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
|
|
|
|
|
if ((order.SourceName != "CIF-自揽货" && order.SourceDetailName != "WSL Member") || (order.SourceName != "CIF-自揽货" && order.SourceDetailName != "国外同行"))
|
|
|
|
|
{
|
|
|
|
|
var request3 = new TaskCreationRequest
|
|
|
|
|
var request3 = new TaskCreationRequest //国外代理PA
|
|
|
|
|
{
|
|
|
|
|
BusinessId = task.BusinessId,
|
|
|
|
|
BusinessType = task.BusinessType,
|
|
|
|
@ -180,7 +185,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
|
|
|
|
|
if (order.IssuingWay == "zd" && order.CustomerId != order.BLConfirmationId)
|
|
|
|
|
{
|
|
|
|
|
var request4 = new TaskCreationRequest
|
|
|
|
|
var request4 = new TaskCreationRequest //提单确认方PA
|
|
|
|
|
{
|
|
|
|
|
BusinessId = task.BusinessId,
|
|
|
|
|
BusinessType = task.BusinessType,
|
|
|
|
@ -209,6 +214,58 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Fastest<BusinessTask>().BulkCopyAsync(subTaskList);//保存子任务
|
|
|
|
|
var allTasks = taskList.Union(subTaskList).ToArray();
|
|
|
|
|
await logService.WriteLogAsync(string.Empty, allTasks);
|
|
|
|
|
|
|
|
|
|
var unionIds = orders.Select(x => x.Id).Union(bills.Select(x => x.Id)); //合并订单ID与分单ID
|
|
|
|
|
var opFiles = await TenantDb.Queryable<OpFile>().Where(x => unionIds.Contains(x.LinkId))
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.LinkId,
|
|
|
|
|
x.TypeCode,
|
|
|
|
|
x.FileName,
|
|
|
|
|
x.FilePath
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
List<MailDraft> mailDrafts = [];
|
|
|
|
|
foreach (var task in subTaskList)
|
|
|
|
|
{
|
|
|
|
|
var draftResult = await mailTemplateService.CreateDraftAsync(task);
|
|
|
|
|
if (!draftResult.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
await LogService.WriteLogAsync(task, "未能创建默认草稿,错误消息:" + draftResult.Message);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
draftResult.Data.TaskId = task.Id;
|
|
|
|
|
var order = orders.Find(x => x.Id == task.BusinessId);
|
|
|
|
|
string typeCode = string.Empty;
|
|
|
|
|
switch (order.IssueType)
|
|
|
|
|
{
|
|
|
|
|
case "正本":
|
|
|
|
|
typeCode = "OringinalBill_Mbl"; //正本提单扫描件
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "SWB":
|
|
|
|
|
typeCode = "swb";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "EBL":
|
|
|
|
|
typeCode = "OringinalBill_Mbl";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
var opFile = opFiles.Find(x => x.LinkId == order.Id && x.TypeCode == typeCode);
|
|
|
|
|
opFile ??= opFiles.Find(x => x.LinkId == order.Id && x.TypeCode == "format_sheet");
|
|
|
|
|
|
|
|
|
|
if (opFile == null) //获取不到订单附件则记录错误日志
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mailDrafts.Add(draftResult.Data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mailDrafts.Count > 0)
|
|
|
|
|
await TenantDb.InsertNav(mailDrafts).Include(x => x.Attaches).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
@ -220,9 +277,6 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
|
|
|
|
|
if (result.Data is FlowInstance instance)
|
|
|
|
|
await Db.Deleteable(instance).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
|