diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
index 1af87bf7..36fae8aa 100644
--- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
+++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
@@ -1522,6 +1522,15 @@ public static class MultiLanguageConst
[Description("BC匹配订单失败")]
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
#region 邮件解析配置
diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs
index 311fd8d7..4af728ad 100644
--- a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs
+++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs
@@ -70,14 +70,15 @@ namespace DS.WMS.Core.TaskPlat.Interface
///
/// 通过BC任务匹配订单(任务台使用)
///
- Task> BcMatchSeaExportTask(TaskFlowDataContext dataContext);
+ Task> BcMatchSeaExportTask(TaskFlowDataContext dataContext);
///
/// 上传BC文件并触发执行BC任务
///
/// 船公司代码
+ /// 任务主键
/// BC文件
- Task UploadBcThenRunTask(string carrierCode, IFormFile file);
+ Task UploadBcThenRunTask(string carrierCode, long taskId, IFormFile file);
}
}
diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs
index 4862d874..5881983c 100644
--- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs
+++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs
@@ -1336,7 +1336,7 @@ namespace DS.WMS.Core.TaskPlat.Method
///
/// 通过BC任务匹配订单(任务台使用)
///
- public async Task> BcMatchSeaExportTask(TaskFlowDataContext dataContext)
+ public async Task> BcMatchSeaExportTask(TaskFlowDataContext dataContext)
{
var taskBcInfo = dataContext.Get(TaskFlowDataNameConst.TaskBCInfo) ?? throw new ArgumentException($"缺少参数:{nameof(TaskFlowDataNameConst.TaskBCInfo)}");
@@ -1355,33 +1355,34 @@ namespace DS.WMS.Core.TaskPlat.Method
///
/// 通过BC任务匹配订单
///
- private async Task> BcMatchSeaExport(TaskBCInfo taskBcInfo)
+ private async Task> BcMatchSeaExport(TaskBCInfo taskBcInfo)
{
- List seaExportList = new();
+ var queryable = tenantDb.Queryable();
if (taskBcInfo.BOOKING_ORDER_ID == null || taskBcInfo.BOOKING_ORDER_ID == 0)
{
- seaExportList = await tenantDb.Queryable()
- .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();
+ queryable.Where(x => x.ParentId == 0 && (taskBcInfo.MBL_NO == x.MBLNO || taskBcInfo.MBL_NO == x.BookingNo));
}
else
{
- seaExportList = await tenantDb.Queryable().Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID).ToListAsync();
+ queryable.Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID);
}
+ List 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)}");
var seaExport = seaExportList.FirstOrDefault();
@@ -1389,11 +1390,11 @@ namespace DS.WMS.Core.TaskPlat.Method
{
taskBcInfo.BOOKING_ORDER_ID = seaExport.Id;
- return DataResult.Success("匹配订单成功", seaExport, MultiLanguageConst.OperationSuccess);
+ return DataResult.Success("匹配订单成功", seaExport, MultiLanguageConst.OperationSuccess);
}
else
{
- return DataResult.Failed("匹配订单失败", MultiLanguageConst.BcMatchSeaExportFailed);
+ return DataResult.Failed("匹配订单失败", MultiLanguageConst.BcMatchSeaExportFailed);
}
}
@@ -2504,12 +2505,14 @@ namespace DS.WMS.Core.TaskPlat.Method
/// 上传BC文件并触发执行BC任务
///
/// 船公司代码
+ /// 任务主键
/// BC文件
- public async Task UploadBcThenRunTask([Required] string carrierCode, [Required] IFormFile file)
+ public async Task UploadBcThenRunTask(string carrierCode, long taskId, IFormFile file)
{
- return DataResult.Failed("开发中...", MultiLanguageConst.Operation_Failed);
+ //return DataResult.Failed("开发中...", MultiLanguageConst.Operation_Failed);
/*
- 解析BC附件,生成BC任务
+ 解析BC文件,生成BC任务
+ 生成Base任务
生成擦写后的文件
保存文件和擦写后的文件到硬盘
保存任务对象
@@ -2517,203 +2520,245 @@ namespace DS.WMS.Core.TaskPlat.Method
触发BC任务
*/
- //ArgumentNullException.ThrowIfNullOrWhiteSpace(carrierCode, nameof(carrierCode));
- //ArgumentNullException.ThrowIfNull(file, nameof(file));
- //ArgumentNullException.ThrowIfNull(taskBaseId, nameof(taskBaseId));
-
string batchNo = Guid.NewGuid().ToString();
logger.LogInformation("批次={no} 接收到上传BC请求", batchNo);
- try
+ List supportCarrier = ["MSK", "CMA"];
+ if (!supportCarrier.Contains(carrierCode))
{
+ return DataResult.Failed(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BCParserNotSupportedCarrier)), carrierCode));
+ }
- // 解析BC附件
- var parserBcInfo = await GetReadBC(carrierCode, file);
- if (!parserBcInfo.Succeeded || parserBcInfo.Data == null)
- {
- return DataResult.Failed(parserBcInfo.Message);
- }
-
- // 解析出BC任务
- var taskBcInfo = parserBcInfo.Adapt();
- 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;
+ // 解析BC附件
+ var parserBcInfo = await GetReadBC(carrierCode, file);
+ if (!parserBcInfo.Succeeded || parserBcInfo.Data == null)
+ {
+ return DataResult.Failed(parserBcInfo.Message);
+ }
- taskBcInfo.TASK_ID = taskInfo.Id;
+ // 解析出BC任务
+ var taskBcInfo = parserBcInfo.Data.Adapt();
+ taskBcInfo.Id = SnowFlakeSingle.Instance.NextId();
+
+ // 获取待放舱任务中的订单主键
+ var fangcangTask = await tenantDb.Queryable()
+ .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();
- var ctnList = parserBcInfo.Data.CtnList?.Select(ctn =>
+ // 获取订单信息
+ var seaExport = await BcMatchSeaExport(taskBcInfo);
+ 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();
+ var ctnList = parserBcInfo.Data.CtnList?.Select(ctn =>
+ {
+ var bcCtnInfo = ctn.Adapt();
+ bcCtnInfo.Id = SnowFlakeSingle.Instance.NextId();
+ bcCtnInfo.P_ID = taskBcInfo.Id;
+
+ if (string.IsNullOrEmpty(bcCtnInfo.CTNCODE))
{
- var bcCtnInfo = ctn.Adapt();
- bcCtnInfo.Id = SnowFlakeSingle.Instance.NextId();
- bcCtnInfo.P_ID = taskBcInfo.Id;
+ var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.CtnName) && a.CtnName.Equals(bcCtnInfo.CTNALL, StringComparison.OrdinalIgnoreCase));
- if (string.IsNullOrEmpty(bcCtnInfo.CTNCODE))
- {
- var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.CtnName) && a.CtnName.Equals(bcCtnInfo.CTNALL, StringComparison.OrdinalIgnoreCase));
+ bcCtnInfo.CTNCODE = ctnCode != null ? ctnCode.EdiCode : "";
+ }
- 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;
- return bcCtnInfo;
+ // 获取任务分配关系
+ TaskFlowDataContext allotDataContext = new TaskFlowDataContext((TaskFlowDataNameConst.Business, seaExport.Data));
+ var allotUserList = await taskAllocationService.Value.GetAllotUserBySeaExportId(TaskBaseTypeEnum.BC, seaExport.Data.Id, allotDataContext);
+ List 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();
+ 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擦写文件
- string bcNotifyFileName = file.FileName + "_MODIFY";
- 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()
- };
+ // 保存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擦写文件
+ 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(taskBcInfo).ExecuteCommandAsync();
await tenantDb.Insertable(ctnList).ExecuteCommandAsync();
+ await tenantDb.Insertable(allocationList).ExecuteCommandAsync();
- if (allotUserList.Succeeded && allotUserList.Data?.Count > 0)
- {
- await SetTaskOwner([taskInfo.Id], allotUserList.Data);
- }
+ await tenantDb.Ado.CommitTranAsync();
+ }
+ catch (Exception ex)
+ {
+ await tenantDb.Ado.RollbackTranAsync();
+ logger.LogError(ex, "手动上传BC时,在存库的过程中发生异常");
+ throw;
+ }
- // 触发BC任务,执行自动化操作
- TaskManageOrderBCInfo messageBcInfo = taskBcInfo.Adapt();
- messageBcInfo.CtnList = ctnList.Adapt>();
+ // 触发BC任务,执行自动化操作
+ TaskManageOrderBCInfo messageBcInfo = taskBcInfo.Adapt();
+ messageBcInfo.CtnList = ctnList.Adapt>();
- TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo()
+ TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo()
+ {
+ Main = new TaskManageOrderMessageMainInfo()
{
- Main = new TaskManageOrderMessageMainInfo()
- {
- BCInfo = messageBcInfo,
- TaskType = TaskBaseTypeEnum.BC,
- TaskBatchNo = batchNo,
- },
- Head = new TaskManageOrderMessageHeadInfo()
- {
- RequestAction = "add"
- }
- };
+ BCInfo = messageBcInfo,
+ TaskType = TaskBaseTypeEnum.BC,
+ TaskBatchNo = batchNo,
+ },
+ Head = new TaskManageOrderMessageHeadInfo()
+ {
+ RequestAction = "add"
+ }
+ };
- TaskFlowDataContext dataContext = new(
- // 固定
- (TaskFlowDataNameConst.TaskBaseInfo, taskInfo),
+ TaskFlowDataContext dataContext = new(
+ // 固定
+ (TaskFlowDataNameConst.TaskBaseInfo, taskInfo),
- // 邮件接收任务特有
- (TaskFlowDataNameConst.TaskManageOrderMessageInfo, messageInfo),
+ // 邮件接收任务特有
+ (TaskFlowDataNameConst.TaskManageOrderMessageInfo, messageInfo),
- // BC任务特有
- (TaskFlowDataNameConst.BCFileInfo, new DynameFileInfo { FileBytes = file.ToByteArray(), FileName = file.FileName }),
- (TaskFlowDataNameConst.BCNotifyFileInfo, new DynameFileInfo { FileBytes = bcFileBytes, FileName = bcNotifyFileName }),
- (TaskFlowDataNameConst.TaskBCInfo, taskBcInfo),
- (TaskFlowDataNameConst.TaskBCCtnList, ctnList)
- );
+ // BC任务特有
+ (TaskFlowDataNameConst.BCFileInfo, new DynameFileInfo { FileBytes = file.ToByteArray(), FileName = file.FileName }),
+ (TaskFlowDataNameConst.BCNotifyFileInfo, new DynameFileInfo { FileBytes = bcFileBytes, FileName = bcNotifyFileName }),
+ (TaskFlowDataNameConst.TaskBCInfo, taskBcInfo),
+ (TaskFlowDataNameConst.TaskBCCtnList, ctnList)
+ );
- TaskFlowRuner taskFlow = new TaskFlowRuner(tenantDb, serviceProvider);
- await taskFlow.Run(TaskBaseTypeEnum.BC, taskInfo.Id, dataContext);
- }
- catch (Exception ex)
- {
- return DataResult.Failed("操作失败!", MultiLanguageConst.Operation_Failed);
- }
- return DataResult.Successed("操作成功!", MultiLanguageConst.OperationSuccess);
+ TaskFlowRuner taskFlow = new TaskFlowRuner(tenantDb, serviceProvider);
+ await taskFlow.Run(TaskBaseTypeEnum.BC, taskInfo.Id, dataContext);
+
+ return DataResult.Successed("上传完成,请审核相关任务及订单状态", MultiLanguageConst.UploadBcThenRunTaskSuccess);
}
}
}
diff --git a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageBCController.cs b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageBCController.cs
index 92e366f0..7f812b0c 100644
--- a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageBCController.cs
+++ b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageBCController.cs
@@ -102,11 +102,12 @@ namespace DS.WMS.TaskApi.Controllers
/// 上传BC文件并触发执行BC任务
///
/// 船公司代码
+ /// 任务主键
/// BC文件
[HttpPost("UploadBcThenRunTask")]
- public async Task UploadBcThenRunTask(string carrierCode, IFormFile file)
+ public async Task UploadBcThenRunTask([FromQuery] string carrierCode, [FromQuery] long taskId, IFormFile file)
{
- return await _taskManageBCService.UploadBcThenRunTask(carrierCode, file);
+ return await _taskManageBCService.UploadBcThenRunTask(carrierCode, taskId, file);
}
#endregion
}