huangxiaoqiang
2025-04-21 2a20cd300ab6d9233a708a0f4558ba3d92c9f0a2
优化入库查询任务方法,高温2号堆垛机缓存俩框
已修改6个文件
86 ■■■■ 文件已修改
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs
@@ -112,6 +112,15 @@
        /// <summary>
        /// 根据设备编号、当前地址、托盘号查询输送线未执行的任务
        /// </summary>
        /// <param name="deviceNo">设备编号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <param name="Barcode">托盘号</param>
        /// <returns></returns>
        Dt_Task QueryConveyorLineTask(string deviceNo, string currentAddress,string Barcode);
        /// <summary>
        /// 根据设备编号、当前地址查询输送线未执行的任务
        /// </summary>
        /// <param name="deviceNo">设备编号</param>
@@ -136,6 +145,14 @@
        Dt_Task QueryExecutingConveyorLineTask(int taskNum, string nextAddress);
        /// <summary>
        /// 根据任务号、下一地址查询输送线执行中的任务
        /// </summary>
        /// <param name="taskNum">任务号</param>
        /// <param name="nextAddress">下一地址</param>
        /// <returns></returns>
        Dt_Task QueryExecutingConveyorLineTask(int taskNum, string nextAddress, string Barcode);
        /// <summary>
        /// 根据托盘号、下一地址查询输送线执行中的任务
        /// </summary>
        /// <param name="taskNum">任务号</param>
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -266,6 +266,17 @@
        /// <param name="deviceNo">设备编号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        public Dt_Task QueryConveyorLineTask(string deviceNo, string currentAddress,string Barcode)
        {
            return BaseDal.QueryFirst(x => ((TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew) || (TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)) && x.CurrentAddress == currentAddress && x.PalletCode == Barcode, TaskOrderBy);
        }
        /// <summary>
        /// 根据设备编号、当前地址查询输送线未执行的任务
        /// </summary>
        /// <param name="deviceNo">设备编号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        public Dt_Task QueryNextConveyorLineTask(string deviceNo, string currentAddress)
        {
            return BaseDal.QueryFirst(x => ((TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew) || (TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)) && x.NextAddress == currentAddress, TaskOrderBy);
@@ -294,6 +305,17 @@
        }
        /// <summary>
        /// 根据任务号、下一地址查询输送线执行中的任务
        /// </summary>
        /// <param name="taskNum">任务号</param>
        /// <param name="nextAddress">下一地址</param>
        /// <returns></returns>
        public Dt_Task QueryExecutingConveyorLineTask(int taskNum, string nextAddress,string Barcode)
        {
            return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.NextAddress == nextAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting), TaskOrderBy);
        }
        /// <summary>
        /// 根据任务号、当前地址查询输送线完成的任务
        /// </summary>
        /// <param name="taskNum">任务号</param>
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -382,7 +382,8 @@
            _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
            WriteInfo(conveyorLine.DeviceName, log);
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            //Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode, command.Barcode);
            if (task != null)
            {
                if (command.Barcode == task.PalletCode)
@@ -428,7 +429,8 @@
                _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
                WriteInfo(conveyorLine.DeviceName, log);
                var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                //var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode, command.Barcode);
                if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish)
                {
                    if (command.Barcode == task.PalletCode && childDeviceCode == task.NextAddress)
@@ -550,7 +552,8 @@
            WriteInfo(conveyorLine.DeviceName, log);
            // 查询正在执行的输送线任务,根据任务号和子设备代码获取任务信息
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            //Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode, command.Barcode);
            // 如果任务存在
            if (task != null)
@@ -610,7 +613,8 @@
                WriteInfo(conveyorLine.DeviceName, logs);
                // 查询正在执行的输送线任务
                var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                //var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
                var task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode, command.Barcode);
                // 如果任务存在
                if (task != null)
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
@@ -152,7 +152,7 @@
                var content = CreateAndSendTask(taskDTO);
                if (content.Status)
                {
                    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
                    if (task != null)
                    {
                        //var taskCommand = MapTaskCommand(task, command);
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
@@ -212,6 +212,12 @@
                }
                else
                {
                    var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList();
                    if (GWTask.Count >= 2 && childDeviceCode == "1039")
                    {
                        ConsoleHelper.WriteErrorLine($"托盘号:【{command.ConveyorLineBarcode}】高温二已存在【{GWTask.Count}】个任务大于2个任务不可下发");
                        return;
                    }
                    ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
@@ -232,7 +238,8 @@
        /// <param name="childDeviceCode">子设备编号</param>
        public void RequestInNextAddress(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
        {
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
            //Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode);
            if (task != null)
            {
                if (command.ConveyorLineBarcode != task.PalletCode)
@@ -308,7 +315,8 @@
        /// <param name="childDeviceCode">子设备编号</param>
        public void RequestOutNextAddress(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
        {
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
            //Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode);
            if (task != null)
            {
                var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
@@ -367,7 +375,8 @@
        /// <param name="childDeviceCode">子设备编号</param>
        public void ConveyorLineOutFinish(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
        {
            var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
            //var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
            var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode);
            if (task != null)
            {
                WebResponseContent content = new WebResponseContent();
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
@@ -183,7 +183,7 @@
                    //    break;
                    //}
                    RequestWmsTask(conveyorLine, command, childDeviceCode);
                    RequestWmsTask(conveyorLine, command, childDeviceCode,stationManager);
                    break;
            }
        }
@@ -272,7 +272,7 @@
                var content = CreateAndSendTask(taskDTO);
                if (content.Status)
                {
                    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                    var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.ConveyorLineBarcode);
                    if (task != null)
                    {
                        var taskCommand = MapTaskCommand(task, command);
@@ -318,7 +318,7 @@
        /// <summary>
        /// 请求WMS任务
        /// </summary>
        private async void RequestWmsTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
        private async void RequestWmsTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, Dt_StationManager stationManager)
        {
            //var taskGW = _taskRepository.QueryFirst(x => x.TargetAddress == childDeviceCode && (x.TaskState == (int)TaskOutStatusEnum.OutFinish || x.TaskState == (int)TaskOutStatusEnum.OutPending));
            //if (taskGW != null)
@@ -333,16 +333,24 @@
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, task.TaskNum, childDeviceCode);
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, childDeviceCode);
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, command.ConveyorLineBarcode, childDeviceCode);
                    var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList();
                    if (GWTask.Count >= 2 && childDeviceCode == "1039")
                    {
                        ConsoleHelper.WriteErrorLine($"托盘号:【{command.ConveyorLineBarcode}】高温二已存在【{GWTask.Count}】个任务大于2个任务不可下发");
                        return;
                    }
                    ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    _taskService.UpdateTaskStatusToNext(task);
                }
            }
            else
            {
                WriteInfo(conveyorLine.DeviceName, content.Message);
                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                ConsoleHelper.WriteErrorLine($"【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】请求点位:【{childDeviceCode}】异常信息【{content.Message}】");
                //_taskRepository.AddData(taskGW);
            }