肖洋
2024-12-15 ccf5c6a4396e810b46676e545f7ad8970b3787f1
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -4,13 +4,11 @@
using Quartz;
using SqlSugar;
using System.Reflection;
using System.Threading.Tasks;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_BasicInfoService;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Caches;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core.HttpContextUser;
using WIDESEAWCS_DTO.MOM;
@@ -26,7 +24,6 @@
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_SignalR;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using static System.Collections.Specialized.BitVector32;
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
namespace WIDESEAWCS_Tasks
@@ -77,6 +74,8 @@
                    List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
                    foreach (var station in stationManagers)
                    {
                        if (station.stationType == 11)
                        {
                        ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
                        ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
                        if (command != null && commandWrite != null)
@@ -84,7 +83,13 @@
                            var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
                            if (structs[0] == true)
                            {
                                    ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{station.stationChildCode}】空托盘请求扫码入库");
                                NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation);
                                }
                                else
                                {
                                    ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
                                }
                            }
                        }
                    }
@@ -174,7 +179,6 @@
                    }
                }
                #region 调用事件总线通知前端
                var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken");
@@ -199,6 +203,7 @@
        }
        #region 入库
        /// <summary>
        /// 输送线请求入库
        /// </summary>
@@ -210,7 +215,7 @@
        {
            try
            {
                //ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库");
                ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库");
                var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
                HandleTaskOut(conveyorLine, command, childDeviceCode, ProtocalDetailValue, task);
@@ -239,6 +244,8 @@
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null)
            {
                if (command.Barcode == task.PalletCode)
                {
                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
                if (newTask != null)
                {
@@ -254,8 +261,9 @@
                }
            }
        }
        }
        #endregion
        #endregion 输送线请求入库下一地址
        /// <summary>
        /// 输送线入库完成
@@ -268,6 +276,8 @@
        {
            var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish)
            {
                if (command.Barcode == task.PalletCode)
            {
                ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线入库完成,下一目标地址【等待分配货位】");
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
@@ -290,13 +300,14 @@
                    WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
                    Console.Out.WriteLine(content.ToJsonString());
                }
                }
            }
        }
        #endregion
        #endregion 入库
        #region 出库
        /// <summary>
        /// 输送线请求出信息
        /// </summary>
@@ -308,6 +319,8 @@
        {
            var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            if (task != null)
            {
                if (command.Barcode == task.PalletCode)
            {
                //task.NextAddress = task.NextAddress.Replace("-1", "");
                //ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
@@ -330,6 +343,7 @@
                }
            }
        }
        }
        /// <summary>
        /// 输送线请求出库下一地址
@@ -341,6 +355,8 @@
        {
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null)
            {
                if (command.Barcode == task.PalletCode)
            {
                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
                if (newTask != null)
@@ -361,6 +377,7 @@
                }
            }
        }
        }
        /// <summary>
        /// 输送线出库完成
@@ -372,6 +389,8 @@
        {
            var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null)
            {
                if (command.Barcode == task.PalletCode)
            {
                WebResponseContent content = new WebResponseContent();
                //ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
@@ -398,8 +417,9 @@
                content = _taskService.UpdateTaskStatusToNext(task);
            }
        }
        }
        #endregion
        #endregion 出库
        /// <summary>
        /// 输送线交互完成
@@ -418,6 +438,7 @@
        }
        #region 检测空盘实盘任务
        /// <summary>
        /// 监测空托盘实盘出库
        /// </summary>
@@ -450,6 +471,7 @@
            if (tasks.Count < index)
            {
                ConsoleHelper.WriteErrorLine($"【{childDeviceCode}】请求【{taskType.ToString()}】任务,已有【{taskType.ToString()}】任务【{tasks.Count}】,最多拥有【{index - 1}】");
                #region 调用WMS获取出库任务
                WMSTaskDTO taskDTO = new WMSTaskDTO();
@@ -464,7 +486,6 @@
                }
                var wmsIpAddress = wmsBase + requestTrayOutTask;
                var result = await HttpHelper.PostAsync(wmsIpAddress, new { position = childDeviceCode, tag = (int)taskType, areaCdoe = roadWay, platform.ProductionLine }.ToJsonString());
                //var result = await HttpHelper.PostAsync("http://localhost:5000/api/Task/RequestTrayOutTaskAsync", dynamic.ToJsonString());
@@ -476,7 +497,7 @@
                taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                #endregion
                #endregion 调用WMS获取出库任务
                CreateAndSendTask(taskDTO);
            }
@@ -494,8 +515,8 @@
            }
            return content;
        }
        #endregion
        #endregion 检测空盘实盘任务
        #region 化成NG口入库
@@ -575,7 +596,6 @@
            }
        }
        #endregion
        #endregion 化成NG口入库
    }
}