cjy 3 months ago
commit 36474256b6

@ -50,13 +50,18 @@ namespace DS.WMS.Core.Info.Method
if (model == null) if (model == null)
return param; return param;
if (typeof(T).IsEnum && Enum.TryParse(typeof(T), model.ItemCode, true, out object? enumValue)) //枚举特殊处理 var type = typeof(T);
var targetType = Nullable.GetUnderlyingType(type);
if (targetType != null)
type = targetType;
if (type.IsEnum && Enum.TryParse(type, model.ItemCode, true, out object? enumValue)) //枚举特殊处理
{ {
param.Value = (T)enumValue; param.Value = (T)enumValue;
} }
else else
{ {
param.Value = (T)Convert.ChangeType(model.ItemCode, typeof(T)); param.Value = (T)Convert.ChangeType(model.ItemCode, type);
} }
return param; return param;

@ -1,4 +1,5 @@
using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.Module.Core.Data;
using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Entity.TaskInteraction; using DS.WMS.Core.Op.Entity.TaskInteraction;
namespace DS.WMS.Core.Op.Interface.TaskInteraction namespace DS.WMS.Core.Op.Interface.TaskInteraction
@ -21,5 +22,12 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
/// <param name="task"></param> /// <param name="task"></param>
/// <returns></returns> /// <returns></returns>
Task CreateSubTaskAsync(BusinessTask task); Task CreateSubTaskAsync(BusinessTask task);
/// <summary>
/// 创建关联子任务
/// </summary>
/// <param name="dataContext"></param>
/// <returns></returns>
Task CreateSubTaskAsync(TaskFlowDataContext dataContext);
} }
} }

@ -29,39 +29,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
return Task.CompletedTask; return Task.CompletedTask;
} }
protected async Task<DataResult> CreateTaskIfNotExistAsync(ActionExecutionContext context)
{
if (!context.TaskInfo.NextType.HasValue)
return DataResult.Success;
var result = await TaskService.ExistsAsync(context.TaskInfo.BusinessId, context.TaskInfo.BusinessType, context.TaskInfo.NextType.Value);
//任务已存在,跳过创建步骤
if (result.Data)
return DataResult.Success;
return await TaskService.CreateTaskAsync(new TaskCreationRequest
{
BusinessId = context.TaskInfo.BusinessId,
BusinessType = context.TaskInfo.BusinessType,
TaskTypeName = context.TaskInfo.NextType.Value.ToString()
});
}
protected async Task SetTaskCompleteAsync(ActionExecutionContext context)
{
if (!context.TaskInfo.NextType.HasValue)
return;
var result = await TaskService.SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = context.TaskInfo.BusinessId,
BusinessType = context.TaskInfo.BusinessType,
TaskTypeName = context.TaskInfo.NextType.Value.ToString(),
TaskStatus = TaskStatusEnum.Complete,
AutoCreateNext = true
});
if (!result.Succeeded)
await LogService.WriteLogAsync(context.TaskInfo, $"未能设置任务【{context.TaskInfo.NextType.Value.GetDescription()}】完成,返回结果:{result.Message}");
}
} }
} }

@ -1,7 +1,7 @@
using DS.WMS.Core.Op.Dtos; using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Interface; using DS.WMS.Core.Op.Interface;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
@ -11,7 +11,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
/// </summary> /// </summary>
public class EDIActionExecutor : BookingActionExecutor public class EDIActionExecutor : BookingActionExecutor
{ {
public async override Task ExecuteAsync(ActionExecutionContext context) public async override Task ExecuteAsync(ActionExecutionContext context)
{ {
await base.ExecuteAsync(context); await base.ExecuteAsync(context);
@ -41,7 +40,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
return; return;
} }
await SetTaskCompleteAsync(context); var task = context.TaskInfo;
task.TaskType = TaskBaseTypeEnum.WAIT_BOOKING;
await SetTaskCompleteAsync(task, TaskService, LogService);
} }
} }
} }

@ -1,4 +1,5 @@
using DS.WMS.Core.Op.Dtos; using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Entity.TaskInteraction; using DS.WMS.Core.Op.Entity.TaskInteraction;
@ -79,7 +80,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
return; return;
} }
await SetTaskCompleteAsync(context); var task = context.TaskInfo;
task.TaskType = TaskBaseTypeEnum.WAIT_BOOKING;
await SetTaskCompleteAsync(task, TaskService, LogService);
} }
} }

@ -1,6 +1,9 @@
using DS.Module.Core; using DS.Module.Core;
using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction; using DS.WMS.Core.Op.Interface.TaskInteraction;
using Masuit.Tools.Systems;
namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor
{ {
@ -25,5 +28,57 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor
{ {
return Task.CompletedTask; return Task.CompletedTask;
} }
/// <summary>
/// 如果指定类型的任务不存在则创建
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="type">业务类型</param>
/// <param name="taskType">任务类型</param>
/// <param name="taskService">任务服务</param>
/// <param name="logService">任务日志服务</param>
/// <returns></returns>
protected async Task<DataResult> CreateTaskIfNotExistAsync(long bsId, BusinessType type, TaskBaseTypeEnum taskType,
ITaskService taskService, ITaskLogService? logService = null)
{
ArgumentNullException.ThrowIfNull(taskService, nameof(taskService));
var result = await taskService.ExistsAsync(bsId, type, taskType);
//任务已存在,跳过创建步骤
if (result.Data)
return DataResult.Success;
return await taskService.CreateTaskAsync(new TaskCreationRequest
{
BusinessId = bsId,
BusinessType = type,
TaskTypeName = taskType.ToString()
});
}
/// <summary>
/// 设置任务状态为完成
/// </summary>
/// <param name="task">任务对象</param>
/// <param name="taskService">任务服务</param>
/// <param name="logService">任务日志服务</param>
/// <returns></returns>
protected virtual async Task SetTaskCompleteAsync(BusinessTask task, ITaskService taskService, ITaskLogService? logService = null)
{
ArgumentNullException.ThrowIfNull(task, nameof(task));
ArgumentNullException.ThrowIfNull(taskService, nameof(taskService));
var result = await taskService.SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = task.BusinessId,
BusinessType = task.BusinessType,
TaskTypeName = task.TaskType.ToString(),
TaskStatus = TaskStatusEnum.Complete,
AutoCreateNext = true
});
if (!result.Succeeded && logService != null)
await logService.WriteLogAsync(task, $"未能设置任务【{task.NextType?.GetDescription()}】完成,返回结果:{result.Message}");
}
} }
} }

@ -108,16 +108,27 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease
await LogService.WriteLogAsync(context.TaskInfo, result.Message); await LogService.WriteLogAsync(context.TaskInfo, result.Message);
return; return;
} }
await SetTaskCompleteAsync(context.TaskInfo,
context.ServiceProvider.GetRequiredService<ITaskService>(), LogService);
} }
//转发BC //转发BC
async Task RelayBCAsync(ActionExecutionContext context) async Task RelayBCAsync(ActionExecutionContext context)
{ {
var taskBase = context.AdditionalData[TaskFlowDataNameConst.TaskBaseInfo] as TaskBaseInfo; var taskBase = context.AdditionalData[TaskFlowDataNameConst.TaskBaseInfo] as TaskBaseInfo;
if (taskBase != null) if (taskBase == null)
await BCService.SyncBookingSlotChange(taskBase.Id); return;
var result = await BCService.SyncBookingSlotChange(taskBase.Id);
if (!result.Succeeded)
return;
await SetTaskCompleteAsync(context.TaskInfo,
context.ServiceProvider.GetRequiredService<ITaskService>(), LogService);
} }
//下货纸 //下货纸
async Task SendShippingOrderAsync(ActionExecutionContext context) async Task SendShippingOrderAsync(ActionExecutionContext context)
{ {

@ -649,7 +649,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
BusinessType = callback.BusinessType.Value, BusinessType = callback.BusinessType.Value,
TaskTypeName = taskType.ToString(), TaskTypeName = taskType.ToString(),
TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending, TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
AutoCreateNext = false //审批完成后需根据业务需要自定义任务类型,因此设置为不自动创建下一任务 AutoCreateNext = true
}; };
//根据审批结果更新任务状态 //根据审批结果更新任务状态
await SetTaskStatusAsync(req); await SetTaskStatusAsync(req);

Loading…
Cancel
Save