调整:上传BC文件并触发执行BC任务

usertest
zhangxiaofeng 3 months ago
parent 364a696ecc
commit 7092ffec63

@ -1522,6 +1522,15 @@ public static class MultiLanguageConst
[Description("BC匹配订单失败")] [Description("BC匹配订单失败")]
public const string BcMatchSeaExportFailed = "BcMatchSeaExportFailed"; public const string BcMatchSeaExportFailed = "BcMatchSeaExportFailed";
[Description("未执行:放舱任务中相应订单的提单号【{0}】与BC附件的提单号【{1}】不一致,请检查")]
public const string BCMblnoNotMatchSeaexport = "BCMblnoNotMatchSeaexport";
[Description("暂不支持BC解析的船公司{0}")]
public const string BCParserNotSupportedCarrier = "BCParserNotSupportedCarrier";
[Description("上传完成,请关注相关任务及订单状态")]
public const string UploadBcThenRunTaskSuccess = "UploadBcThenRunTaskSuccess";
#endregion #endregion
#region 邮件解析配置 #region 邮件解析配置

@ -70,14 +70,15 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// <summary> /// <summary>
/// 通过BC任务匹配订单任务台使用 /// 通过BC任务匹配订单任务台使用
/// </summary> /// </summary>
Task<DataResult<SeaExport?>> BcMatchSeaExportTask(TaskFlowDataContext dataContext); Task<DataResult<SeaExportRes?>> BcMatchSeaExportTask(TaskFlowDataContext dataContext);
/// <summary> /// <summary>
/// 上传BC文件并触发执行BC任务 /// 上传BC文件并触发执行BC任务
/// </summary> /// </summary>
/// <param name="carrierCode">船公司代码</param> /// <param name="carrierCode">船公司代码</param>
/// <param name="taskId">任务主键</param>
/// <param name="file">BC文件</param> /// <param name="file">BC文件</param>
Task<DataResult> UploadBcThenRunTask(string carrierCode, IFormFile file); Task<DataResult> UploadBcThenRunTask(string carrierCode, long taskId, IFormFile file);
} }
} }

@ -1336,7 +1336,7 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <summary> /// <summary>
/// 通过BC任务匹配订单任务台使用 /// 通过BC任务匹配订单任务台使用
/// </summary> /// </summary>
public async Task<DataResult<SeaExport?>> BcMatchSeaExportTask(TaskFlowDataContext dataContext) public async Task<DataResult<SeaExportRes?>> BcMatchSeaExportTask(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)}");
@ -1355,33 +1355,34 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <summary> /// <summary>
/// 通过BC任务匹配订单 /// 通过BC任务匹配订单
/// </summary> /// </summary>
private async Task<DataResult<SeaExport?>> BcMatchSeaExport(TaskBCInfo taskBcInfo) private async Task<DataResult<SeaExportRes?>> BcMatchSeaExport(TaskBCInfo taskBcInfo)
{ {
List<SeaExport> seaExportList = new(); var queryable = tenantDb.Queryable<SeaExport>();
if (taskBcInfo.BOOKING_ORDER_ID == null || taskBcInfo.BOOKING_ORDER_ID == 0) if (taskBcInfo.BOOKING_ORDER_ID == null || taskBcInfo.BOOKING_ORDER_ID == 0)
{ {
seaExportList = await tenantDb.Queryable<SeaExport>() queryable.Where(x => x.ParentId == 0 && (taskBcInfo.MBL_NO == x.MBLNO || taskBcInfo.MBL_NO == x.BookingNo));
.Where(x => x.ParentId == 0 && (taskBcInfo.MBL_NO == x.MBLNO || taskBcInfo.MBL_NO == x.BookingNo))
.Select(x => new SeaExport()
{
Id = x.Id,
MBLNO = x.MBLNO,
OperatorId = x.OperatorId,
OperatorName = x.OperatorName,
Doc = x.Doc,
DocName = x.DocName,
SaleId = x.SaleId,
Sale = x.Sale,
CustomerService = x.CustomerService,
CustomerServiceName = x.CustomerServiceName,
ForeignCustomerService = x.ForeignCustomerService,
ForeignCustomerServiceName = x.ForeignCustomerServiceName
}).ToListAsync();
} }
else else
{ {
seaExportList = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID).ToListAsync(); queryable.Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID);
} }
List<SeaExportRes> seaExportList = await queryable.Select(x => new SeaExportRes()
{
Id = x.Id,
MBLNO = x.MBLNO,
BookingNo = x.BookingNo,
OperatorId = x.OperatorId,
OperatorName = x.OperatorName,
Doc = x.Doc,
DocName = x.DocName,
SaleId = x.SaleId,
Sale = x.Sale,
CustomerService = x.CustomerService,
CustomerServiceName = x.CustomerServiceName,
ForeignCustomerService = x.ForeignCustomerService,
ForeignCustomerServiceName = x.ForeignCustomerServiceName
}).ToListAsync();
logger.LogInformation($"通过BC任务匹配订单任务台使用根据taskBcInfo.MBL_NO【{taskBcInfo.MBL_NO}】查询订单后seaExportList结果为{JsonConvert.SerializeObject(seaExportList)}"); logger.LogInformation($"通过BC任务匹配订单任务台使用根据taskBcInfo.MBL_NO【{taskBcInfo.MBL_NO}】查询订单后seaExportList结果为{JsonConvert.SerializeObject(seaExportList)}");
var seaExport = seaExportList.FirstOrDefault(); var seaExport = seaExportList.FirstOrDefault();
@ -1389,11 +1390,11 @@ namespace DS.WMS.Core.TaskPlat.Method
{ {
taskBcInfo.BOOKING_ORDER_ID = seaExport.Id; taskBcInfo.BOOKING_ORDER_ID = seaExport.Id;
return DataResult<SeaExport?>.Success("匹配订单成功", seaExport, MultiLanguageConst.OperationSuccess); return DataResult<SeaExportRes?>.Success("匹配订单成功", seaExport, MultiLanguageConst.OperationSuccess);
} }
else else
{ {
return DataResult<SeaExport?>.Failed("匹配订单失败", MultiLanguageConst.BcMatchSeaExportFailed); return DataResult<SeaExportRes?>.Failed("匹配订单失败", MultiLanguageConst.BcMatchSeaExportFailed);
} }
} }
@ -2504,12 +2505,14 @@ namespace DS.WMS.Core.TaskPlat.Method
/// 上传BC文件并触发执行BC任务 /// 上传BC文件并触发执行BC任务
/// </summary> /// </summary>
/// <param name="carrierCode">船公司代码</param> /// <param name="carrierCode">船公司代码</param>
/// <param name="taskId">任务主键</param>
/// <param name="file">BC文件</param> /// <param name="file">BC文件</param>
public async Task<DataResult> UploadBcThenRunTask([Required] string carrierCode, [Required] IFormFile file) public async Task<DataResult> UploadBcThenRunTask(string carrierCode, long taskId, IFormFile file)
{ {
return DataResult.Failed("开发中...", MultiLanguageConst.Operation_Failed); //return DataResult.Failed("开发中...", MultiLanguageConst.Operation_Failed);
/* /*
BCBC BCBC
Base
@ -2517,203 +2520,245 @@ namespace DS.WMS.Core.TaskPlat.Method
BC BC
*/ */
//ArgumentNullException.ThrowIfNullOrWhiteSpace(carrierCode, nameof(carrierCode));
//ArgumentNullException.ThrowIfNull(file, nameof(file));
//ArgumentNullException.ThrowIfNull(taskBaseId, nameof(taskBaseId));
string batchNo = Guid.NewGuid().ToString(); string batchNo = Guid.NewGuid().ToString();
logger.LogInformation("批次={no} 接收到上传BC请求", batchNo); logger.LogInformation("批次={no} 接收到上传BC请求", batchNo);
try List<string> supportCarrier = ["MSK", "CMA"];
if (!supportCarrier.Contains(carrierCode))
{ {
return DataResult.Failed(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BCParserNotSupportedCarrier)), carrierCode));
}
// 解析BC附件 // 解析BC附件
var parserBcInfo = await GetReadBC(carrierCode, file); var parserBcInfo = await GetReadBC(carrierCode, file);
if (!parserBcInfo.Succeeded || parserBcInfo.Data == null) if (!parserBcInfo.Succeeded || parserBcInfo.Data == null)
{ {
return DataResult.Failed(parserBcInfo.Message); return DataResult.Failed(parserBcInfo.Message);
} }
// 解析出BC任务
var taskBcInfo = parserBcInfo.Adapt<TaskBCInfo>();
taskBcInfo.Id = SnowFlakeSingle.Instance.NextId();
// 获取订单信息
var seaExport = await BcMatchSeaExport(taskBcInfo);
if (!seaExport.Succeeded || seaExport.Data == null)
{
return DataResult.Failed(seaExport.Message);
}
// 构建Base任务
var taskInfo = new TaskBaseInfo
{
Id = SnowFlakeSingle.Instance.NextId(),
STATUS = TaskStatusEnum.Create.ToString(),
STATUS_NAME = TaskStatusEnum.Create.EnumDescription(),
IS_EXCEPT = 0,
IS_COMPLETE = 0,
MBL_NO = taskBcInfo.MBL_NO,
TASK_TYPE = TaskBaseTypeEnum.BC.ToString(),
TASK_TYPE_NAME = TaskBaseTypeEnum.BC.EnumDescription(),
//TASK_BASE_TYPE = info.Main.TaskType.ToString(),
//CARRIER_ID = info.Main.CarrierId?.Trim(),
//IS_PUBLIC = string.IsNullOrWhiteSpace(info.Main.TaskUserId) ? 1 : 0,
IS_PUBLIC = 1,
//OUT_BUSI_NO = $"{info.Head.SenderId}_{info.Head.GID}",
TASK_TITLE = $"手动上传-BC {taskBcInfo.VESSEL}/{taskBcInfo.VOYNO} ETD:{taskBcInfo.ETD} BLNo:{taskBcInfo.MBL_NO}",
//TASK_DESP = info.Main.TaskDesp,
TASK_SOURCE = "ManualUploadBC",
TASK_SOURCE_NAME = "手动上传BC",
VESSEL_VOYNO = $"{taskBcInfo.VESSEL}/{taskBcInfo.VOYNO}"?.Trim(),
CONTA_INFO = taskBcInfo.CTN_STAT,
TASK_REQ_USERNAME = user.UserName,
YARD_NAME = taskBcInfo.YARD,
ETD = taskBcInfo.ETD,
BATCH_STATIC = batchNo,
//DJYUserId = info.Head.DJYUserId,
CreateTime = DateTime.Now,
CreateBy = long.Parse(user.UserId),
CreateUserName = user.UserName,
OUT_BS_NO = seaExport.Data.Id,
BOOK_ORDER_NO = seaExport.Data.Id.ToString(),
CARRIER_ID = seaExport.Data.CarrierId,
CARRIER_NAME = seaExport.Data.Carrier,
CUSTOMER_ID = seaExport.Data.CustomerId,
CUSTOMER_NAME = seaExport.Data.CustomerName,
};
taskInfo.TASK_DESP = taskInfo.TASK_TITLE;
taskBcInfo.TASK_ID = taskInfo.Id; // 解析出BC任务
var taskBcInfo = parserBcInfo.Data.Adapt<TaskBCInfo>();
taskBcInfo.Id = SnowFlakeSingle.Instance.NextId();
// 获取待放舱任务中的订单主键
var fangcangTask = await tenantDb.Queryable<TaskBaseInfo>()
.Where(x => x.Id == taskId)
.Select(x => new
{
x.Id,
x.OUT_BS_NO,
x.STATUS
}).FirstAsync();
if (fangcangTask == null)
{
return DataResult.Failed("未执行:放舱任务不存在,请刷新页面");
}
if (fangcangTask.STATUS == TaskStatusEnum.Complete.ToString())
{
return DataResult.Failed("未执行:放舱任务状态为已完成,无法放舱,请刷新页面");
}
taskBcInfo.BOOKING_ORDER_ID = fangcangTask.OUT_BS_NO;
// 构建箱信息 // 获取订单信息
var ctnCodeList = (await codeCtnService.GetAllList()).Data ?? new List<Code.Dtos.CodeCtnRes>(); var seaExport = await BcMatchSeaExport(taskBcInfo);
var ctnList = parserBcInfo.Data.CtnList?.Select(ctn => if (!seaExport.Succeeded || seaExport.Data == null)
{
return DataResult.Failed("未执行:" + seaExport.Message);
}
if (seaExport.Data.MBLNO != taskBcInfo.MBL_NO && seaExport.Data.BookingNo != taskBcInfo.MBL_NO)
{
return DataResult.Failed(string.Format(MultiLanguageConst.BCMblnoNotMatchSeaexport, seaExport.Data.MBLNO, taskBcInfo.MBL_NO));
}
// 构建Base任务
var taskInfo = new TaskBaseInfo
{
Id = SnowFlakeSingle.Instance.NextId(),
STATUS = TaskStatusEnum.Complete.ToString(),
STATUS_NAME = TaskStatusEnum.Complete.EnumDescription(),
IS_EXCEPT = 0,
IS_COMPLETE = 1,
MBL_NO = taskBcInfo.MBL_NO,
TASK_TYPE = TaskBaseTypeEnum.BC.ToString(),
TASK_TYPE_NAME = TaskBaseTypeEnum.BC.EnumDescription(),
//TASK_BASE_TYPE = info.Main.TaskType.ToString(),
//CARRIER_ID = info.Main.CarrierId?.Trim(),
//IS_PUBLIC = string.IsNullOrWhiteSpace(info.Main.TaskUserId) ? 1 : 0,
IS_PUBLIC = 1,
//OUT_BUSI_NO = $"{info.Head.SenderId}_{info.Head.GID}",
TASK_TITLE = $"手动上传-BC {taskBcInfo.VESSEL}/{taskBcInfo.VOYNO} ETD:{taskBcInfo.ETD} BLNo:{taskBcInfo.MBL_NO}",
//TASK_DESP = info.Main.TaskDesp,
TASK_SOURCE = "ManualUploadBC",
TASK_SOURCE_NAME = "手动上传BC",
VESSEL_VOYNO = $"{taskBcInfo.VESSEL}/{taskBcInfo.VOYNO}"?.Trim(),
CONTA_INFO = taskBcInfo.CTN_STAT,
TASK_REQ_USERNAME = user.UserName,
YARD_NAME = taskBcInfo.YARD,
ETD = taskBcInfo.ETD,
BATCH_STATIC = batchNo,
//DJYUserId = info.Head.DJYUserId,
CreateTime = DateTime.Now,
CreateBy = long.Parse(user.UserId),
CreateUserName = user.UserName,
OUT_BS_NO = seaExport.Data.Id,
BOOK_ORDER_NO = seaExport.Data.Id.ToString(),
CARRIER_ID = seaExport.Data.CarrierId,
CARRIER_NAME = seaExport.Data.Carrier,
CUSTOMER_ID = seaExport.Data.CustomerId,
CUSTOMER_NAME = seaExport.Data.CustomerName,
};
taskInfo.TASK_DESP = taskInfo.TASK_TITLE;
taskBcInfo.TASK_ID = taskInfo.Id;
// 构建箱信息
var ctnCodeList = (await codeCtnService.GetAllList()).Data ?? new List<Code.Dtos.CodeCtnRes>();
var ctnList = parserBcInfo.Data.CtnList?.Select(ctn =>
{
var bcCtnInfo = ctn.Adapt<TaskBCCTNInfo>();
bcCtnInfo.Id = SnowFlakeSingle.Instance.NextId();
bcCtnInfo.P_ID = taskBcInfo.Id;
if (string.IsNullOrEmpty(bcCtnInfo.CTNCODE))
{ {
var bcCtnInfo = ctn.Adapt<TaskBCCTNInfo>(); var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.CtnName) && a.CtnName.Equals(bcCtnInfo.CTNALL, StringComparison.OrdinalIgnoreCase));
bcCtnInfo.Id = SnowFlakeSingle.Instance.NextId();
bcCtnInfo.P_ID = taskBcInfo.Id;
if (string.IsNullOrEmpty(bcCtnInfo.CTNCODE)) bcCtnInfo.CTNCODE = ctnCode != null ? ctnCode.EdiCode : "";
{ }
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.CtnName) && a.CtnName.Equals(bcCtnInfo.CTNALL, StringComparison.OrdinalIgnoreCase));
bcCtnInfo.CTNCODE = ctnCode != null ? ctnCode.EdiCode : ""; bcCtnInfo.CreateBy = taskInfo.CreateBy;
} bcCtnInfo.CreateTime = taskInfo.CreateTime;
return bcCtnInfo;
}).ToList();
bcCtnInfo.CreateBy = taskInfo.CreateBy; // 获取任务分配关系
bcCtnInfo.CreateTime = taskInfo.CreateTime; TaskFlowDataContext allotDataContext = new TaskFlowDataContext((TaskFlowDataNameConst.Business, seaExport.Data));
return bcCtnInfo; var allotUserList = await taskAllocationService.Value.GetAllotUserBySeaExportId(TaskBaseTypeEnum.BC, seaExport.Data.Id, allotDataContext);
List<TaskBaseAllocation> allocationList = [];
if (allotUserList.Succeeded && allotUserList.Data?.Count > 0)
{
allocationList = allotUserList.Data.Select(x => new TaskBaseAllocation
{
TaskId = taskInfo.Id,
UserId = x.RecvUserId,
UserName = x.RecvUserName,
Status = TaskStatusEnum.Complete.ToString(),
StatusName = TaskStatusEnum.Complete.EnumDescription(),
StatusTime = DateTime.Now
}).ToList(); }).ToList();
taskInfo.IS_PUBLIC = 0;
}
// 获取任务分配关系
TaskFlowDataContext allotDataContext = new TaskFlowDataContext((TaskFlowDataNameConst.Business, seaExport.Data));
var allotUserList = await taskAllocationService.Value.GetAllotUserBySeaExportId(TaskBaseTypeEnum.BC, seaExport.Data.Id, allotDataContext);
// 保存BC文件
string bcFileName = file.FileName;
var bcFileBytes = file.ToByteArray();
var bcNoExtensionFileName = Path.GetFileNameWithoutExtension(file.FileName);
var bcFileFullName = await SaveFile(taskInfo.Id.ToString()!,
bcFileBytes,
batchNo,
bcNoExtensionFileName,
GetFileType(file.FileName),
"bcfiles");
// 构建BC文件索引信息
var bcFileInfo = new TaskFileInfo
{
Id = SnowFlakeSingle.Instance.NextId(),
TASK_PKID = taskInfo.Id,
CreateBy = taskInfo.CreateBy,
CreateTime = taskInfo.CreateTime,
FILE_PATH = bcFileFullName,
FILE_NAME = bcFileName,
FILE_TYPE = Path.GetExtension(bcFileName).ToLower(),
FILE_CATEGORY = TaskFileCategoryEnum.BC.ToString(),
FILE_CATEGORY_NAME = TaskFileCategoryEnum.BC.EnumDescription()
};
// 保存BC擦写文件 // 保存BC文件
string bcNotifyFileName = file.FileName + "_MODIFY"; string bcFileName = file.FileName;
var bcNotifyFileBytes = await GetModifyBCFile(carrierCode, file); var bcFileBytes = file.ToByteArray();
if (!bcNotifyFileBytes.Succeeded || bcNotifyFileBytes.Data == null || bcNotifyFileBytes.Data.Length == 0) var bcNoExtensionFileName = Path.GetFileNameWithoutExtension(file.FileName);
{ var bcFileFullName = await SaveFile(taskInfo.Id.ToString()!,
return DataResult.Failed(bcNotifyFileBytes.Message); bcFileBytes,
} batchNo,
var bcNotifyNoExtensionFileName = Path.GetFileNameWithoutExtension(bcNotifyFileName); bcNoExtensionFileName,
var bcNotifyFileFullName = await SaveFile(taskInfo.Id.ToString()!, GetFileType(file.FileName),
bcNotifyFileBytes.Data, "bcfiles");
batchNo, // 构建BC文件索引信息
bcNotifyNoExtensionFileName, var bcFileInfo = new TaskFileInfo
GetFileType(bcNotifyFileName), {
"bcnoticefiles"); Id = SnowFlakeSingle.Instance.NextId(),
// 构建BC文件擦写文件索引信息 TASK_PKID = taskInfo.Id,
var bcNotifyFileInfo = new TaskFileInfo CreateBy = taskInfo.CreateBy,
{ CreateTime = taskInfo.CreateTime,
Id = SnowFlakeSingle.Instance.NextId(), FILE_PATH = bcFileFullName,
TASK_PKID = taskInfo.Id, FILE_NAME = bcFileName,
CreateBy = taskInfo.CreateBy, FILE_TYPE = Path.GetExtension(bcFileName).ToLower(),
CreateTime = taskInfo.CreateTime, FILE_CATEGORY = TaskFileCategoryEnum.BC.ToString(),
FILE_PATH = bcNotifyFileFullName, FILE_CATEGORY_NAME = TaskFileCategoryEnum.BC.EnumDescription()
FILE_NAME = bcNotifyFileName, };
FILE_TYPE = Path.GetExtension(bcNotifyFileName).ToLower(),
FILE_CATEGORY = TaskFileCategoryEnum.BC.ToString(), // 保存BC擦写文件
FILE_CATEGORY_NAME = TaskFileCategoryEnum.BC.EnumDescription() string bcNotifyFileName = $"{bcNoExtensionFileName}_MODIFY{Path.GetExtension(bcFileName).ToLower()}";
}; var bcNotifyFileBytes = await GetModifyBCFile(carrierCode, file);
if (!bcNotifyFileBytes.Succeeded || bcNotifyFileBytes.Data == null || bcNotifyFileBytes.Data.Length == 0)
{
return DataResult.Failed(bcNotifyFileBytes.Message);
}
var bcNotifyNoExtensionFileName = Path.GetFileNameWithoutExtension(bcNotifyFileName);
var bcNotifyFileFullName = await SaveFile(taskInfo.Id.ToString()!,
bcNotifyFileBytes.Data,
batchNo,
bcNotifyNoExtensionFileName,
GetFileType(bcNotifyFileName),
"bcnoticefiles");
// 构建BC文件擦写文件索引信息
var bcNotifyFileInfo = new TaskFileInfo
{
Id = SnowFlakeSingle.Instance.NextId(),
TASK_PKID = taskInfo.Id,
CreateBy = taskInfo.CreateBy,
CreateTime = taskInfo.CreateTime,
FILE_PATH = bcNotifyFileFullName,
FILE_NAME = bcNotifyFileName,
FILE_TYPE = Path.GetExtension(bcNotifyFileName).ToLower(),
FILE_CATEGORY = TaskFileCategoryEnum.BC.ToString(),
FILE_CATEGORY_NAME = TaskFileCategoryEnum.BC.EnumDescription()
};
// 存库
try
{
await tenantDb.Ado.BeginTranAsync();
// 存库
await tenantDb.Insertable(taskInfo).ExecuteCommandAsync(); await tenantDb.Insertable(taskInfo).ExecuteCommandAsync();
await tenantDb.Insertable(taskBcInfo).ExecuteCommandAsync(); await tenantDb.Insertable(taskBcInfo).ExecuteCommandAsync();
await tenantDb.Insertable(ctnList).ExecuteCommandAsync(); await tenantDb.Insertable(ctnList).ExecuteCommandAsync();
await tenantDb.Insertable(allocationList).ExecuteCommandAsync();
if (allotUserList.Succeeded && allotUserList.Data?.Count > 0) await tenantDb.Ado.CommitTranAsync();
{ }
await SetTaskOwner([taskInfo.Id], allotUserList.Data); catch (Exception ex)
} {
await tenantDb.Ado.RollbackTranAsync();
logger.LogError(ex, "手动上传BC时在存库的过程中发生异常");
throw;
}
// 触发BC任务,执行自动化操作 // 触发BC任务,执行自动化操作
TaskManageOrderBCInfo messageBcInfo = taskBcInfo.Adapt<TaskManageOrderBCInfo>(); TaskManageOrderBCInfo messageBcInfo = taskBcInfo.Adapt<TaskManageOrderBCInfo>();
messageBcInfo.CtnList = ctnList.Adapt<List<TaskManageOrderBCCTNInfo>>(); messageBcInfo.CtnList = ctnList.Adapt<List<TaskManageOrderBCCTNInfo>>();
TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo() TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo()
{
Main = new TaskManageOrderMessageMainInfo()
{ {
Main = new TaskManageOrderMessageMainInfo() BCInfo = messageBcInfo,
{ TaskType = TaskBaseTypeEnum.BC,
BCInfo = messageBcInfo, TaskBatchNo = batchNo,
TaskType = TaskBaseTypeEnum.BC, },
TaskBatchNo = batchNo, Head = new TaskManageOrderMessageHeadInfo()
}, {
Head = new TaskManageOrderMessageHeadInfo() RequestAction = "add"
{ }
RequestAction = "add" };
}
};
TaskFlowDataContext dataContext = new( TaskFlowDataContext dataContext = new(
// 固定 // 固定
(TaskFlowDataNameConst.TaskBaseInfo, taskInfo), (TaskFlowDataNameConst.TaskBaseInfo, taskInfo),
// 邮件接收任务特有 // 邮件接收任务特有
(TaskFlowDataNameConst.TaskManageOrderMessageInfo, messageInfo), (TaskFlowDataNameConst.TaskManageOrderMessageInfo, messageInfo),
// BC任务特有 // BC任务特有
(TaskFlowDataNameConst.BCFileInfo, new DynameFileInfo { FileBytes = file.ToByteArray(), FileName = file.FileName }), (TaskFlowDataNameConst.BCFileInfo, new DynameFileInfo { FileBytes = file.ToByteArray(), FileName = file.FileName }),
(TaskFlowDataNameConst.BCNotifyFileInfo, new DynameFileInfo { FileBytes = bcFileBytes, FileName = bcNotifyFileName }), (TaskFlowDataNameConst.BCNotifyFileInfo, new DynameFileInfo { FileBytes = bcFileBytes, FileName = bcNotifyFileName }),
(TaskFlowDataNameConst.TaskBCInfo, taskBcInfo), (TaskFlowDataNameConst.TaskBCInfo, taskBcInfo),
(TaskFlowDataNameConst.TaskBCCtnList, ctnList) (TaskFlowDataNameConst.TaskBCCtnList, ctnList)
); );
TaskFlowRuner taskFlow = new TaskFlowRuner(tenantDb, serviceProvider); TaskFlowRuner taskFlow = new TaskFlowRuner(tenantDb, serviceProvider);
await taskFlow.Run(TaskBaseTypeEnum.BC, taskInfo.Id, dataContext); await taskFlow.Run(TaskBaseTypeEnum.BC, taskInfo.Id, dataContext);
}
catch (Exception ex) return DataResult.Successed("上传完成,请审核相关任务及订单状态", MultiLanguageConst.UploadBcThenRunTaskSuccess);
{
return DataResult.Failed("操作失败!", MultiLanguageConst.Operation_Failed);
}
return DataResult.Successed("操作成功!", MultiLanguageConst.OperationSuccess);
} }
} }
} }

@ -102,11 +102,12 @@ namespace DS.WMS.TaskApi.Controllers
/// 上传BC文件并触发执行BC任务 /// 上传BC文件并触发执行BC任务
/// </summary> /// </summary>
/// <param name="carrierCode">船公司代码</param> /// <param name="carrierCode">船公司代码</param>
/// <param name="taskId">任务主键</param>
/// <param name="file">BC文件</param> /// <param name="file">BC文件</param>
[HttpPost("UploadBcThenRunTask")] [HttpPost("UploadBcThenRunTask")]
public async Task<DataResult> UploadBcThenRunTask(string carrierCode, IFormFile file) public async Task<DataResult> UploadBcThenRunTask([FromQuery] string carrierCode, [FromQuery] long taskId, IFormFile file)
{ {
return await _taskManageBCService.UploadBcThenRunTask(carrierCode, file); return await _taskManageBCService.UploadBcThenRunTask(carrierCode, taskId, file);
} }
#endregion #endregion
} }

Loading…
Cancel
Save