BC流程相关

usertest
zhangxiaofeng 3 months ago
parent c30289dc28
commit 324edb3561

@ -38,9 +38,14 @@
/// <summary> /// <summary>
/// BC对比订单后是否存在差异 /// BC对比订单后是否存在差异
/// </summary> /// </summary>
/// <remarks>类型:<see cref="bool" /></remarks> /// <remarks>类型:CompareResultInfo</remarks>
public const string BcCompareWithSeaExportResult = "BcCompareWithSeaExportResult"; public const string BcCompareWithSeaExportResult = "BcCompareWithSeaExportResult";
/// <summary>
/// BC是否匹配到了海运出口订单
/// </summary>
public const string BcIsMatchSeaExport = "BcIsMatchSeaExport";
/// <summary> /// <summary>
/// BC文件 /// BC文件
/// </summary> /// </summary>

@ -1184,7 +1184,7 @@ namespace DS.WMS.Core.TaskPlat.Method
SeaExport = seaExport, SeaExport = seaExport,
OpCtnList = seaExportCtnList OpCtnList = seaExportCtnList
}; };
var result = await CompareBcWithSeaExport(compareDto); CompareResultInfo result = await CompareBcWithSeaExport(compareDto);
dataContext.Set(TaskFlowDataNameConst.BcCompareWithSeaExportResult, result); dataContext.Set(TaskFlowDataNameConst.BcCompareWithSeaExportResult, result);
@ -1345,14 +1345,23 @@ namespace DS.WMS.Core.TaskPlat.Method
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)}");
var result = await BcMatchSeaExport(taskBcInfo); var result = await BcMatchSeaExport(taskBcInfo);
if (result.Succeeded && result.Data != null) if (result.Succeeded && result.Data != null && result.Data.Id != 0)
{ {
dataContext.Set(TaskFlowDataNameConst.BusinessId, result.Data.Id!); // BC是否匹配到了海运出口订单=>true
dataContext.Set(TaskFlowDataNameConst.BcIsMatchSeaExport, true);
// 订单Id
dataContext.Set(TaskFlowDataNameConst.BusinessId, result.Data.Id);
await tenantDb.Updateable<TaskBCInfo>() await tenantDb.Updateable<TaskBCInfo>()
.SetColumns(x => x.BOOKING_ORDER_ID == result.Data.Id) .SetColumns(x => x.BOOKING_ORDER_ID == result.Data.Id)
.Where(x => x.Id == taskBcInfo.Id) .Where(x => x.Id == taskBcInfo.Id)
.ExecuteCommandAsync(); .ExecuteCommandAsync();
await tenantDb.Updateable<TaskBaseInfo>()
.SetColumns(x => x.OUT_BS_NO == result.Data.Id)
.Where(x => x.Id == taskBcInfo.TASK_ID)
.ExecuteCommandAsync();
} }
return result; return result;
} }
@ -1362,6 +1371,7 @@ namespace DS.WMS.Core.TaskPlat.Method
private async Task<DataResult<SeaExportRes?>> BcMatchSeaExport(TaskBCInfo taskBcInfo) private async Task<DataResult<SeaExportRes?>> BcMatchSeaExport(TaskBCInfo taskBcInfo)
{ {
var queryable = tenantDb.Queryable<SeaExport>(); var queryable = tenantDb.Queryable<SeaExport>();
if (taskBcInfo.BOOKING_ORDER_ID is not null or 0) if (taskBcInfo.BOOKING_ORDER_ID is not null or 0)
{ {
queryable.Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID); queryable.Where(x => x.Id == taskBcInfo.BOOKING_ORDER_ID);
@ -2592,6 +2602,10 @@ namespace DS.WMS.Core.TaskPlat.Method
{ {
return DataResult.Failed("未执行:当前任务状态为已完成,请重新查询"); return DataResult.Failed("未执行:当前任务状态为已完成,请重新查询");
} }
if (waitBcTask.OUT_BS_NO == null)
{
return DataResult.Failed("未执行当前任务的业务主键为null");
}
taskBcInfo.BOOKING_ORDER_ID = waitBcTask.OUT_BS_NO; taskBcInfo.BOOKING_ORDER_ID = waitBcTask.OUT_BS_NO;
// 获取订单信息 // 获取订单信息
@ -2738,6 +2752,7 @@ namespace DS.WMS.Core.TaskPlat.Method
FILE_CATEGORY_NAME = TaskFileCategoryEnum.BC.EnumDescription() FILE_CATEGORY_NAME = TaskFileCategoryEnum.BC.EnumDescription()
}; };
// 存库 // 存库
try try
{ {
@ -2757,6 +2772,20 @@ namespace DS.WMS.Core.TaskPlat.Method
throw; throw;
} }
var taskService = serviceProvider.GetRequiredService<ITaskService>();
var rlt = await taskService.SetTaskStatusAsync(new TaskUpdateRequest()
{
AutoCreateNext = false,
BusinessId = (long)waitBcTask.OUT_BS_NO,
BusinessType = BusinessType.OceanShippingExport,
TaskStatus = TaskStatusEnum.Complete,
TaskTypeName = TaskBaseTypeEnum.WAIT_BC.ToString()
});
if (!rlt.Succeeded)
{
logger.LogError("手动上传BC设置收BC任务完成时失败message:" + rlt.Message);
}
// 触发BC任务,执行自动化操作 // 触发BC任务,执行自动化操作
TaskManageOrderBCInfo messageBcInfo = taskBcInfo.Adapt<TaskManageOrderBCInfo>(); TaskManageOrderBCInfo messageBcInfo = taskBcInfo.Adapt<TaskManageOrderBCInfo>();
messageBcInfo.CtnList = ctnList.Adapt<List<TaskManageOrderBCCTNInfo>>(); messageBcInfo.CtnList = ctnList.Adapt<List<TaskManageOrderBCCTNInfo>>();
@ -2801,32 +2830,70 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <param name="dataContext">数据上下文</param> /// <param name="dataContext">数据上下文</param>
public async Task<DataResult> BCTaskCompleteThenNext(TaskFlowDataContext dataContext) public async Task<DataResult> BCTaskCompleteThenNext(TaskFlowDataContext dataContext)
{ {
var businessId = dataContext.Get<long?>(TaskFlowDataNameConst.BusinessId); // 这里获取到的是获取BC任务的基础任务
if (businessId == null || businessId == 0) var taskBaseInfo = dataContext.Get<TaskBaseInfo>(TaskFlowDataNameConst.TaskBaseInfo);
if (taskBaseInfo == null)
{
return DataResult.Failed("未获取到BC任务对象TaskBaseInfo");
}
await SetTaskStatus(taskBaseInfo, TaskStatusEnum.Complete, DateTime.Now);
if (taskBaseInfo.OUT_BS_NO is null or 0)
{ {
Logger.Log(NLog.LogLevel.Info, $"执行BCTaskCompleteThenNext时未获取到businessId{businessId}"); logger.LogError("BCTaskCompleteThenNextBC任务对象TaskBaseInfo的OUT_BS_NO为空或0");
return DataResult.Failed("未获取到订单Id"); return DataResult.Failed("任务对象的业务主键为空");
} }
else else
{ {
var taskService = serviceProvider.GetRequiredService<ITaskService>(); var req = new TaskCreationRequest
var rlt = await taskService.SetTaskStatusAsync(new TaskUpdateRequest()
{ {
AutoCreateNext = true, BusinessId = (long)taskBaseInfo.OUT_BS_NO,
BusinessId = (long)businessId,
BusinessType = BusinessType.OceanShippingExport, BusinessType = BusinessType.OceanShippingExport,
TaskStatus = TaskStatusEnum.Complete, TaskTypeName = TaskBaseTypeEnum.WAIT_SPACE_RELEASE.ToString(),
TaskTypeName = TaskBaseTypeEnum.WAIT_BC.ToString() };
});
if (rlt.Succeeded) CompareResultInfo? compareResult = dataContext.Get<CompareResultInfo>(TaskFlowDataNameConst.BcCompareWithSeaExportResult);
{ if (compareResult != null && compareResult.IsExistsDiff)
return DataResult.Successed("BC任务已完成并创建下一步任务");
}
else
{ {
return DataResult.Failed(rlt.Message); req.TaskDescription = "未放舱原因BC对比存在差异";
} }
var taskService = serviceProvider.GetRequiredService<ITaskService>();
var result = await taskService.CreateTaskAsync(req, false);
if (!result.Succeeded)
return DataResult.Failed("创建下一任务时返回错误:" + result.Message, result.MultiCode);
} }
return DataResult.Successed("BC任务已完成并创建下一步任务");
/*
//之前这里结束的待收BC任务后面改为结束BC任务
//var businessId = dataContext.Get<long?>(TaskFlowDataNameConst.BusinessId);
//if (businessId == null || businessId == 0)
//{
// Logger.Log(NLog.LogLevel.Info, $"执行BCTaskCompleteThenNext时未获取到businessId{businessId}");
// return DataResult.Failed("未获取到订单Id");
//}
//else
//{
//var taskService = serviceProvider.GetRequiredService<ITaskService>();
//var rlt = await taskService.SetTaskStatusAsync(new TaskUpdateRequest()
// {
// AutoCreateNext = false,
// BusinessId = (long)businessId,
// BusinessType = BusinessType.OceanShippingExport,
// TaskStatus = TaskStatusEnum.Complete,
// TaskTypeName = TaskBaseTypeEnum.WAIT_BC.ToString()
// });
// if (rlt.Succeeded)
// {
// return DataResult.Successed("BC任务已完成并创建下一步任务");
// }
// else
// {
// return DataResult.Failed(rlt.Message);
// }
//} */
} }
} }
} }

@ -520,28 +520,24 @@ namespace DS.WMS.Core.TaskPlat.Method
.Where(t => t.Id == taskBaseId) .Where(t => t.Id == taskBaseId)
.FirstAsync(); .FirstAsync();
return await SetTaskStatus(taskInfo, taskBaseTypeEnum, taskStatusEnum, statusTime, bsno); return await SetTaskStatus(taskInfo, taskStatusEnum, statusTime, bsno);
} }
/// <summary> /// <summary>
/// 通过任务主表对象设置任务状态() /// 通过任务主表对象设置任务状态()
/// </summary> /// </summary>
/// <param name="taskInfo">任务主表对象</param> /// <param name="taskInfo">任务主表对象</param>
/// <param name="taskBaseTypeEnum">业务类型</param>
/// <param name="taskStatusEnum">业务状态</param> /// <param name="taskStatusEnum">业务状态</param>
/// <param name="statusTime">状态发生时间</param> /// <param name="statusTime">状态发生时间</param>
/// <param name="bsno">业务主键</param> /// <param name="bsno">业务主键</param>
protected async Task<DataResult> SetTaskStatus(TaskBaseInfo taskInfo, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, long? bsno = null) public async Task<DataResult> SetTaskStatus(TaskBaseInfo taskInfo, TaskStatusEnum taskStatusEnum, DateTime? statusTime, long? bsno = null)
{ {
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId); if (taskInfo is null)
if (taskInfo == null)
{ {
logger.LogInformation($"根据bsno:【{bsno}】,TaskBaseTypeEnum【{taskBaseTypeEnum}】未查询到任务"); throw new ArgumentNullException(nameof(taskInfo));
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
} }
logger.LogInformation("接收到任务状态修改报文 任务主键={id} 状态设置={status}", taskInfo.Id, taskStatusEnum.ToString()); SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
// 修改任务的状态 // 修改任务的状态
taskInfo.STATUS = taskStatusEnum.ToString(); taskInfo.STATUS = taskStatusEnum.ToString();
@ -553,7 +549,7 @@ namespace DS.WMS.Core.TaskPlat.Method
// 如果任务状态为已完成,则查询任务完成时任务对应模块的配置中要设置的业务状态,然后进行设置 // 如果任务状态为已完成,则查询任务完成时任务对应模块的配置中要设置的业务状态,然后进行设置
if (taskStatusEnum == TaskStatusEnum.Complete && bsno != null) if (taskStatusEnum == TaskStatusEnum.Complete && bsno != null)
{ {
string? statusCode = await tenantDb.Queryable<TaskFlowModule>().Where(x => x.ModuleType == 2 && x.TaskType == taskBaseTypeEnum.ToString()).Select(x => x.BusinessStatusCode).FirstAsync(); string? statusCode = await tenantDb.Queryable<TaskFlowModule>().Where(x => x.ModuleType == 2 && x.TaskType == taskInfo.TASK_TYPE).Select(x => x.BusinessStatusCode).FirstAsync();
if (!string.IsNullOrEmpty(statusCode)) if (!string.IsNullOrEmpty(statusCode))
{ {
await seaExportCommonService.Value.SetGoodsStatus(statusCode, (long)bsno, tenantDb); await seaExportCommonService.Value.SetGoodsStatus(statusCode, (long)bsno, tenantDb);

@ -136,7 +136,7 @@ namespace DS.WMS.Core.TaskPlat.Method
return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData))); return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData)));
} }
return await SetTaskStatus(taskInfo, taskBaseTypeEnum, taskStatusEnum, statusTime, bsno); return await SetTaskStatus(taskInfo, taskStatusEnum, statusTime, bsno);
} }
@ -2112,13 +2112,6 @@ namespace DS.WMS.Core.TaskPlat.Method
TASK_USER_STATUS_TIME = a.StatusTime TASK_USER_STATUS_TIME = a.StatusTime
}).Distinct().ToQueryPageAsync(querySearch.PageCondition); }).Distinct().ToQueryPageAsync(querySearch.PageCondition);
//var sql = queryable.Select<dynamic>((t, a) => new
//{
// PK_ID = t.Id.SelectAll(),
// TASK_USER_STATUS = a.Status,
// TASK_USER_STATUS_NAME = a.StatusName,
// TASK_USER_STATUS_TIME = a.StatusTime
//}).Distinct().ToSqlString();
return result; return result;
} }

@ -109,7 +109,7 @@ namespace DS.WMS.Core.TaskPlat
} }
if (targetConfig == null) if (targetConfig == null)
{ {
throw new Exception("targetConfig目标流程意外为null"); throw new Exception("targetConfig目标流程意外为null"); // 不会走到这里,至少会有一条流程匹配到
} }
// 待执行的流程(节点列表) // 待执行的流程(节点列表)
@ -192,10 +192,11 @@ namespace DS.WMS.Core.TaskPlat
if (executeConfig == null) if (executeConfig == null)
{ {
flowLog.IsComplete = false; //调整:没有找到待执行的节点,不认为整个流程失败或者未完成
flowLog.IsSuccess = false; //flowLog.IsComplete = false;
flowLog.Note += $"【执行时未找到符合执行条件的节点经判断条件的节点Id如下{string.Join(',', waitMatchConfigList.Select(x => x.Id))}】"; //flowLog.IsSuccess = false;
flowLog.Note += $"【执行时未找到符合执行条件的节点经判断条件的节点Id如下{string.Join(',', waitMatchConfigList.Select(x => x.Id))}】";
break; break;
} }

Loading…
Cancel
Save