| | |
| | | #endregion << 版 本 注 释 >> |
| | | |
| | | using AutoMapper; |
| | | using Microsoft.Extensions.Configuration; |
| | | using Quartz; |
| | | using SqlSugar; |
| | | using System.Text.Json; |
| | | using WIDESEA_Core; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IMapper _mapper; |
| | | ConveyorLineDispatchHandler _conveyorLineDispatch; |
| | | private ConveyorLineDispatchHandler _conveyorLineDispatch; |
| | | private readonly HttpClientHelper _httpClientHelper; |
| | | |
| | | public CommonConveyorLineNewJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper) |
| | | public CommonConveyorLineNewJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, HttpClientHelper httpClientHelper) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _routerService = routerService; |
| | | _mapper = mapper; |
| | | _conveyorLineDispatch = new ConveyorLineDispatchHandler(_taskService, _taskExecuteDetailService, _routerService, _mapper); |
| | | _httpClientHelper = httpClientHelper; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | |
| | | try |
| | | { |
| | | ConveyorLineTaskCommandNew command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandNew>(childDeviceCode); |
| | | if (command == null || command.PLC_STB == 0) |
| | | |
| | | #region 检查特定位置是否有托盘 |
| | | |
| | | var checkPalletPositions = App.Configuration.GetSection("CheckPalletPositions") |
| | | .Get<List<CheckPalletPosition>>() ?? new List<CheckPalletPosition>(); |
| | | |
| | | if (checkPalletPositions.Any(x => x.Code == childDeviceCode)) |
| | | { |
| | | if (command.CV_State.ObjToBool()) |
| | | { |
| | | var existingTask = _taskService.Repository.QueryFirst(x => x.TargetAddress == childDeviceCode); |
| | | if (existingTask.IsNullOrEmpty()) |
| | | { |
| | | var position = checkPalletPositions.FirstOrDefault(x => x.Code == childDeviceCode); |
| | | var responseResult = _httpClientHelper.Post<WebResponseContent>("GetOutBoundTrayTaskAsync", new CreateTaskDto() |
| | | { |
| | | WarehouseId = position.WarehouseId, |
| | | TargetAddress = childDeviceCode |
| | | }.Serialize()); |
| | | |
| | | if (responseResult.IsSuccess && responseResult.Data.Status) |
| | | { |
| | | var wmsTask = JsonSerializer.Deserialize<List<WMSTaskDTO>>(responseResult.Data.Data.Serialize()); |
| | | if (wmsTask != null) |
| | | _taskService.ReceiveWMSTask(wmsTask); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | if (command == null || command.PLC_STB != 1) |
| | | { |
| | | return; |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode); |
| | | if (task.IsNullOrEmpty()) |
| | | if (command.TaskNo > 0) |
| | | { |
| | | _conveyorLineDispatch.RequestInbound(conveyorLine, command, childDeviceCode); |
| | | return; |
| | | } |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode); |
| | | if (task.IsNullOrEmpty()) |
| | | { |
| | | _conveyorLineDispatch.RequestInbound(conveyorLine, command, childDeviceCode); |
| | | return; |
| | | } |
| | | |
| | | // 处理任务状态 |
| | | ProcessTaskState(conveyorLine, command, task, childDeviceCode); |
| | | // 处理任务状态 |
| | | ProcessTaskState(conveyorLine, command, task, childDeviceCode); |
| | | } |
| | | } |
| | | catch (Exception innerEx) |
| | | { |
| | |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 处理任务状态 |
| | |
| | | switch (state) |
| | | { |
| | | case InExecuting: |
| | | if (isTargetAddress) |
| | | _conveyorLineDispatch.ConveyorLineInFinish(conveyorLine, command, childDeviceCode); |
| | | else |
| | | _conveyorLineDispatch.RequestInNextAddress(conveyorLine, command, childDeviceCode); |
| | | //if (isTargetAddress) |
| | | // _conveyorLineDispatch.ConveyorLineInFinish(conveyorLine, command, childDeviceCode); |
| | | //else |
| | | _conveyorLineDispatch.RequestInNextAddress(conveyorLine, command, childDeviceCode); |
| | | break; |
| | | |
| | | case OutExecuting: |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |