cjy 3 months ago
commit 34c12e4a3c

@ -31,5 +31,10 @@ namespace DS.WMS.Core.Op.Dtos.TaskInteraction
/// 下一任务类型 /// 下一任务类型
/// </summary> /// </summary>
public TaskBaseTypeEnum? NextType { get; set; } public TaskBaseTypeEnum? NextType { get; set; }
/// <summary>
/// 是否现舱(默认null值)
/// </summary>
public bool? HasCabin { get; set; }
} }
} }

@ -70,10 +70,17 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
/// <returns></returns> /// <returns></returns>
Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false, IDictionary<string, object>? additionalData = null); Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false, IDictionary<string, object>? additionalData = null);
/// <summary> /// <summary>
/// 执行放舱任务(任务台使用) /// 执行放舱任务(任务台使用)
/// </summary> /// </summary>
Task SpaceReleaseTask(TaskFlowDataContext dataContext); Task SpaceReleaseTask(TaskFlowDataContext dataContext);
/// <summary>
/// 自动订舱
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
Task<DataResult> AutomaticBooking(long businessId, BusinessType businessType);
} }
} }

@ -7,6 +7,7 @@ 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;
using DS.WMS.Core.Op.Interface.TaskInteraction; using DS.WMS.Core.Op.Interface.TaskInteraction;
using DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector;
using DS.WMS.Core.TaskPlat; using DS.WMS.Core.TaskPlat;
using Fasterflect; using Fasterflect;
using Masuit.Tools; using Masuit.Tools;
@ -234,6 +235,37 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
await taskFlow.RunWithBsno(businessTask.TaskType, businessTask.BusinessId, dataContext); await taskFlow.RunWithBsno(businessTask.TaskType, businessTask.BusinessId, dataContext);
} }
/// <summary>
/// 自动订舱
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
public async Task<DataResult> AutomaticBooking(long businessId, BusinessType businessType)
{
try
{
var businessTask = await TenantDb.Queryable<BusinessTask>().Where(
x => x.BusinessId == businessId && x.BusinessType == businessType && x.TaskType == TaskBaseTypeEnum.WAIT_BOOKING).FirstAsync();
if (businessTask == null)
return DataResult.FailedWithDesc(MultiLanguageConst.TaskStatusNotSupported);
TaskFlowDataContext dataContext = new
(
(TaskFlowDataNameConst.BusinessTask, businessTask),
("TypeName", typeof(BookingSelector).AssemblyQualifiedName)
);
await ExecuteAsync(dataContext);
return DataResult.Success;
}
catch (Exception ex)
{
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
}
}
/// <summary> /// <summary>
/// 执行动作 /// 执行动作
/// </summary> /// </summary>
@ -250,7 +282,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
ServiceProvider = ServiceProvider ServiceProvider = ServiceProvider
}; };
foreach (var key in dataContext.Keys) foreach (var key in dataContext.Keys)
context.AdditionalData[key] = dataContext[key]; context.AdditionalData[key] = dataContext[key];

@ -1,4 +1,5 @@
using DS.WMS.Core.Info.Interface; using DS.Module.Core;
using DS.WMS.Core.Info.Interface;
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.Interface.TaskInteraction; using DS.WMS.Core.Op.Interface.TaskInteraction;
@ -18,10 +19,15 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector
public async Task<IActionExecutor> GetActionExecutor(ActionExecutionContext context) public async Task<IActionExecutor> GetActionExecutor(ActionExecutionContext context)
{ {
//var taskService = context.ServiceProvider.GetRequiredService<ITaskService>();
//var list = await taskService.GetTasks(context.TaskInfo.BusinessId, context.TaskInfo.BusinessType, TaskBaseTypeEnum.WAIT_BOOKING);
//if (list.Data?.Count > 0 && list.Data?[0].TaskStatus == TaskStatusEnum.Complete)
// return new DefaultActionExecutor();
switch (context.TaskInfo.BusinessType) switch (context.TaskInfo.BusinessType)
{ {
case BusinessType.OceanShippingExport: case BusinessType.OceanShippingExport:
var seTaskService = context.ServiceProvider.GetService<ISeaExportTaskService>(); var seTaskService = context.ServiceProvider.GetRequiredService<ISeaExportTaskService>();
var order = await seTaskService.AsQueryable(x => x.Id == context.TaskInfo.BusinessId).Select(x => new var order = await seTaskService.AsQueryable(x => x.Id == context.TaskInfo.BusinessId).Select(x => new
{ {
x.BookingNo, x.BookingNo,

@ -99,7 +99,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
TenantDb.QueryFilter.Clear<IOrgId>(); TenantDb.QueryFilter.Clear<IOrgId>();
} }
/// <summary> /// <summary>
/// 创建关联任务 /// 创建关联任务
/// </summary> /// </summary>
@ -111,6 +110,14 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (!await EnsureModuleAuthorized()) if (!await EnsureModuleAuthorized())
return DataResult.SuccessedWithDesc(nameof(MultiLanguageConst.ModuleUnauthorized)); return DataResult.SuccessedWithDesc(nameof(MultiLanguageConst.ModuleUnauthorized));
if (request.HasCabin.GetValueOrDefault())
{
//如果为现舱,获取下一任务类型进行创建
var nextType = await GetNextTypeAsync(request.BusinessId, request.BusinessType, request.TaskType);
if (nextType.HasValue)
request.TaskTypeName = nextType.Value.ToString();
}
var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync(); var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
if (task != null && task.TaskStatus != TaskStatusEnum.Cancel) if (task != null && task.TaskStatus != TaskStatusEnum.Cancel)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists));
@ -661,8 +668,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
public virtual async Task UpdateBusinessAsync(FlowCallback callback) public virtual async Task UpdateBusinessAsync(FlowCallback callback)
{ {
ArgumentNullException.ThrowIfNull(callback, nameof(callback)); ArgumentNullException.ThrowIfNull(callback, nameof(callback));
if (callback.Type == null || callback.BusinessType == null)
return;
var taskType = TypeMappings.Where(x => x.Value == callback.Type.GetValueOrDefault()).Select(x => x.Key).FirstOrDefault(); var taskType = TypeMappings.Where(x => x.Value == callback.Type.Value).Select(x => x.Key).FirstOrDefault();
var req = new TaskUpdateRequest var req = new TaskUpdateRequest
{ {
BusinessId = callback.BusinessId, BusinessId = callback.BusinessId,
@ -741,14 +750,24 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <returns></returns> /// <returns></returns>
protected async Task<TaskBaseTypeEnum?> GetNextTypeAsync(BusinessTask current) protected async Task<TaskBaseTypeEnum?> GetNextTypeAsync(BusinessTask current)
{ {
var order = await ActionService.GetBusinessDataAsync(current.BusinessId, current.BusinessType); return await GetNextTypeAsync(current.BusinessId, current.BusinessType, current.TaskType);
TaskFlowRuner flowRuner = new(TenantDb, ServiceProvider); }
var taskType = await flowRuner.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN,
new TaskFlowDataContext(
(TaskFlowDataNameConst.Business, order)
), current.TaskType);
return taskType; /// <summary>
/// 获取给定任务的下一任务类型
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="currentType">当前任务类型</param>
/// <returns></returns>
protected async Task<TaskBaseTypeEnum?> GetNextTypeAsync(long bsId, BusinessType businessType, TaskBaseTypeEnum currentType)
{
var order = await ActionService.GetBusinessDataAsync(bsId, businessType);
TaskFlowRuner flowRuner = new(TenantDb, ServiceProvider);
return await flowRuner.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN,
new TaskFlowDataContext(
(TaskFlowDataNameConst.Business, order)
), currentType);
} }
/// <summary> /// <summary>

@ -58,6 +58,20 @@ namespace DS.WMS.OpApi.Controllers
return await logService.ReadLogAsync(businessId, businessType); return await logService.ReadLogAsync(businessId, businessType);
} }
/// <summary>
/// 触发自动订舱
/// </summary>
/// <param name="actionService"></param>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型(可空,默认=海运出口)</param>
/// <returns></returns>
[HttpPost, Route("AutomaticBooking")]
public async Task<DataResult> AutomaticBookingAsync([FromServices] IActionManagerService actionService,
[FromQuery] long businessId, [FromQuery] BusinessType businessType = BusinessType.OceanShippingExport)
{
return await actionService.AutomaticBooking(businessId, businessType);
}
/// <summary> /// <summary>
/// 创建关联任务 /// 创建关联任务
/// </summary> /// </summary>

Loading…
Cancel
Save