wanshenmean
2025-03-22 c200233f68393549ce2fee57aaeb6f671d6c2d14
更新 .gitignore 和重构 RequestInbound.cs

- 更新了 `.gitignore` 文件,添加了多个路径以忽略不必要的文件和目录。
- 删除了多个不再需要的二进制文件。
- 清理了 `DocumentLayout.backup.json` 和 `DocumentLayout.json` 中的冗余 JSON 内容。
- 在 `RequestInbound.cs` 中重构了代码,添加了 `LogAndSendFinish` 方法,提升了可读性和可维护性。
- 增加了对任务请求的处理逻辑,改进了日志记录和任务状态更新的方式。
已删除8个文件
已修改2个文件
639 ■■■■ 文件已修改
.gitignore 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/.futdcache.v2 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/DocumentLayout.backup.json 176 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/fileList.bin 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs 201 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/.vs/ProjectEvaluation/widesea_wmsserver.strings.v9.bin 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/DesignTimeBuild/.dtbcache.v2 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/.suo 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/DocumentLayout.json 253 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/fileList.bin 补丁 | 查看 | 原始文档 | blame | 历史
.gitignore
@@ -54991,3 +54991,12 @@
*.v2
CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/.futdcache.v2
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/obj/Release/net6.0/WIDESEAWCS_Common.GlobalUsings.g.cs
/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/copilot-chat/bef6627e/sessions/2923046d-159a-498d-ad80-1f1082024059
/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/.futdcache.v2
/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/DocumentLayout.backup.json
/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/fileList.bin
/CodeManagement/WMS/WIDESEA_WMSServer/.vs/ProjectEvaluation/widesea_wmsserver.strings.v9.bin
/CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/DesignTimeBuild/.dtbcache.v2
/CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/.suo
/CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/DocumentLayout.json
/CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/fileList.bin
CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/.futdcache.v2
Binary files differ
CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/DocumentLayout.backup.json
ÎļþÒÑɾ³ý
CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/v17/fileList.bin
Binary files differ
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
@@ -1,5 +1,6 @@
using HslCommunication;
//using HslCommunication;
using Mapster;
using Masuit.Tools;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
@@ -282,8 +283,18 @@
        private async Task RequestWmsTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue, Dt_StationManager stationManager)
        {
            string isTrue = string.Empty;
            ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
            ResultTrayCellsStatus result = GetResultTrayCellsStatus(command, stationManager);
            if(result.SerialNos.Count == 0)
            {
                var Traycontent = await _taskService.RequestWMSTask(command.Barcode, childDeviceCode);
                if (Traycontent.Status)
                {
                    ConsoleHelper.WriteSuccessLine("请求回流静置");
                    ExecuteConveyorLineTask(conveyorLine, command, ProtocalDetailValue, childDeviceCode);
                }
            }
            List<string> strings = stationManager.Roadway.Split(",").ToList();
            foreach (string item in strings)
@@ -504,61 +515,161 @@
                }
            }
        }
        public void ExecuteConveyorLineTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, int ProtocalDetailValue ,string childDeviceCode)
        /// <summary>
        /// æ‰§è¡Œè¾“送线任务
        /// </summary>
        /// <param name="conveyorLine">输送线对象</param>
        /// <param name="command">输送线任务命令</param>
        /// <param name="ProtocalDetailValue">协议明细值</param>
        /// <param name="childDeviceCode">子设备编号</param>
        //public void ExecuteConveyorLineTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, int ProtocalDetailValue, string childDeviceCode)
        //{
        //    var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
        //    if (task != null)
        //    {
        //        var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue;
        //        var valueList = value.Split(',').ToList();
        //        if (valueList.Contains(task.SourceAddress))
        //        {
        //            conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTargetAddress, "1000", childDeviceCode);
        //            var log = $"【{conveyorLine._deviceName}】任务号:【{task.TaskNum}】,托盘条码:【{task.PalletCode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{1000}】";
        //            ConsoleHelper.WriteWarningLine(log);
        //            _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
        //            WriteInfo(conveyorLine.DeviceName, log);
        //            ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
        //        }
        //        else
        //        {
        //            if (task.Roadway.Contains("JZ"))
        //            {
        //                var outJZTask = _taskRepository.QueryData(x => x.Roadway== task.Roadway && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish);
        //                if (outJZTask.IsNullOrEmpty())
        //                {
        //                    var next = task.NextAddress;
        //                    var taskCommand = MapTaskCommand(task, command);
        //                    task.NextAddress = next;
        //                    var log = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{taskCommand.TargetAddress}】";
        //                    ConsoleHelper.WriteWarningLine(log);
        //                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
        //                    WriteInfo(conveyorLine.DeviceName, log);
        //                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
        //                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
        //                    _taskService.UpdateTaskStatusToNext(task);
        //                }
        //                else
        //                {
        //                    ConsoleHelper.WriteWarningLine("已存在静置出库任务,静置入库任务无法下发线体");
        //                }
        //            }
        //            else
        //            {
        //                var next = task.NextAddress;
        //                var taskCommand = MapTaskCommand(task, command);
        //                task.NextAddress = next;
        //                var log = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{taskCommand.TargetAddress}】";
        //                ConsoleHelper.WriteWarningLine(log);
        //                _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
        //                WriteInfo(conveyorLine.DeviceName, log);
        //                conveyorLine.SendCommand(taskCommand, childDeviceCode);
        //                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
        //                _taskService.UpdateTaskStatusToNext(task);
        //            }
        //        }
        //    }
        //}
        /// <summary>
        /// æ‰§è¡Œè¾“送线任务
        /// </summary>
        /// <param name="conveyorLine">输送线对象</param>
        /// <param name="command">输送线任务命令</param>
        /// <param name="ProtocalDetailValue">协议明细值</param>
        /// <param name="childDeviceCode">子设备编号</param>
        public void ExecuteConveyorLineTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, int ProtocalDetailValue, string childDeviceCode)
        {
            // æŸ¥è¯¢ä»»åŠ¡ä¿¡æ¯
            var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
            if (task != null)
            if (task == null) return;
            // èŽ·å–é…ç½®å€¼å¹¶è½¬æ¢ä¸ºåˆ—è¡¨
            var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue;
            var valueList = value.Split(',').ToList();
            // æ—¥å¿—模板
            var logMessage = $"【{conveyorLine._deviceName}】任务号:【{task.TaskNum}】,托盘条码:【{task.PalletCode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{{0}}】";
            // åˆ¤æ–­ä»»åŠ¡çš„èµ·å§‹åœ°å€æ˜¯å¦åœ¨é…ç½®åˆ—è¡¨ä¸­
            if (valueList.Contains(task.SourceAddress))
            {
                var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue;
                var valueList = value.Split(',').ToList();
                if (valueList.Contains(task.SourceAddress))
                // è®¾ç½®ç›®æ ‡åœ°å€ä¸º "1000"
                conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTargetAddress, "1000", childDeviceCode);
                // è®°å½•日志并发送完成信号
                LogAndSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, logMessage, "1000");
            }
            else if (task.Roadway.Contains("JZ"))
            {
                // æŸ¥è¯¢æ˜¯å¦å­˜åœ¨é™ç½®å‡ºåº“任务
                var outJZTask = _taskRepository.QueryData(x => x.Roadway == task.Roadway &&
                    (x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting ||
                     x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting ||
                     x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish));
                if (outJZTask.IsNullOrEmpty())
                {
                    conveyorLine.SetValue(ConveyorLineDBName.WriteConveyorLineTargetAddress, "1000", childDeviceCode);
                    var log = $"【{conveyorLine._deviceName}】任务号:【{task.TaskNum}】,托盘条码:【{task.PalletCode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{1000}】";
                    ConsoleHelper.WriteWarningLine(log);
                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
                    WriteInfo(conveyorLine.DeviceName, log);
                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                }
                else if (task.TargetAddress == "1020-1")
                {
                    var next = task.NextAddress;
                    // æ˜ å°„任务命令
                    var taskCommand = MapTaskCommand(task, command);
                    task.NextAddress = next;
                    var log = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{taskCommand.TargetAddress}】";
                    ConsoleHelper.WriteWarningLine(log);
                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
                    WriteInfo(conveyorLine.DeviceName, log);
                    // è®°å½•日志并发送完成信号
                    LogAndSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, logMessage, taskCommand.TargetAddress.ToString());
                    // å‘送任务命令
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                    var taskHty = task.Adapt<Dt_Task_Hty>();
                    _task_HtyRepository.AddData(taskHty);
                    _taskService.DeleteData(task);
                    // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                    _taskService.UpdateTaskStatusToNext(task);
                }
                else
                {
                    var next = task.NextAddress;
                    var taskCommand = MapTaskCommand(task, command);
                    task.NextAddress = next;
                    var log = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求扫码入库(实盘),下一目标地址【{taskCommand.TargetAddress}】";
                    ConsoleHelper.WriteWarningLine(log);
                    _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
                    WriteInfo(conveyorLine.DeviceName, log);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                    _taskService.UpdateTaskStatusToNext(task);
                    ConsoleHelper.WriteWarningLine("已存在静置出库任务,静置入库任务无法下发至线体");
                }
            }
            else
            {
                // æ˜ å°„任务命令
                var taskCommand = MapTaskCommand(task, command);
                // è®°å½•日志并发送完成信号
                LogAndSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, logMessage, taskCommand.TargetAddress.ToString());
                // å‘送任务命令
                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                _taskService.UpdateTaskStatusToNext(task);
            }
        }
        /// <summary>
        /// è®°å½•日志并发送完成信号
        /// </summary>
        /// <param name="conveyorLine">输送线对象</param>
        /// <param name="childDeviceCode">子设备编号</param>
        /// <param name="ProtocalDetailValue">协议明细值</param>
        /// <param name="logMessage">日志消息模板</param>
        /// <param name="targetAddress">目标地址</param>
        private void LogAndSendFinish(CommonConveyorLine conveyorLine, string childDeviceCode, int ProtocalDetailValue, string logMessage, string targetAddress)
        {
            // æ ¼å¼åŒ–日志消息
            var log = string.Format(logMessage, targetAddress);
            // è¾“出警告日志
            ConsoleHelper.WriteWarningLine(log);
            // è®°å½•日志
            _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log, time = DateTime.Now.ToString("G"), color = "red" });
            WriteInfo(conveyorLine.DeviceName, log);
            // å‘送完成信号
            ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
        }
    }
}
CodeManagement/WMS/WIDESEA_WMSServer/.vs/ProjectEvaluation/widesea_wmsserver.strings.v9.bin
Binary files differ
CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/DesignTimeBuild/.dtbcache.v2
Binary files differ
CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/.suo
Binary files differ
CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/DocumentLayout.json
ÎļþÒÑɾ³ý
CodeManagement/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/v17/fileList.bin
Binary files differ