| | |
| | | using Newtonsoft.Json; |
| | | using Autofac; |
| | | using Newtonsoft.Json; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using WIDESEAWCS_Common.HttpEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | |
| | | private readonly IRouterService _routerService; |
| | | private readonly HttpClientHelper _httpClientHelper; |
| | | private readonly IRobotTaskService _robotTaskService; |
| | | private readonly ITaskService _taskService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly IComponentContext _componentContext; |
| | | |
| | | /// <summary> |
| | | /// 初始化出库任务流程服务。 |
| | |
| | | /// <param name="routerService">路由服务。</param> |
| | | /// <param name="httpClientHelper">WMS接口调用帮助类。</param> |
| | | /// <param name="robotTaskService">机械手任务服务。</param> |
| | | /// <param name="taskService">任务服务(用于接收入库任务)。</param> |
| | | /// <param name="taskRepository">任务仓储(用于删除出库任务)。</param> |
| | | public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService, ITaskService taskService, ITaskRepository taskRepository) |
| | | /// <param name="componentContext">Autofac组件上下文(用于延迟解析ITaskService以避免循环依赖)。</param> |
| | | public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService, ITaskRepository taskRepository, IComponentContext componentContext) |
| | | { |
| | | _routerService = routerService; |
| | | _httpClientHelper = httpClientHelper; |
| | | _robotTaskService = robotTaskService; |
| | | _taskService = taskService; |
| | | _taskRepository = taskRepository; |
| | | _componentContext = componentContext; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 延迟解析ITaskService以避免循环依赖 |
| | | /// </summary> |
| | | private ITaskService TaskService => _componentContext.Resolve<ITaskService>(); |
| | | |
| | | /// <summary> |
| | | /// 接收WMS任务时初始化出库任务。 |
| | |
| | | _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.自动完成); |
| | | |
| | | // 调用ReceiveWMSTask创建本地入库任务 |
| | | var receiveResult = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { inboundTaskDto }); |
| | | var receiveResult = TaskService.ReceiveWMSTask(new List<WMSTaskDTO> { inboundTaskDto }); |
| | | if (!receiveResult.Status) |
| | | { |
| | | return content.Error($"创建本地入库任务失败: {receiveResult.Message}"); |