wanshenmean
2024-11-07 959aa7cefa8f416452444160cdd4edbea2cadae7
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
@@ -13,10 +13,11 @@
using WIDESEAWCS_Tasks.ConveyorLineJob;
using HslCommunication;
using OfficeOpenXml.ConditionalFormatting;
using WIDESEAWCS_DTO.WMS;
namespace WIDESEAWCS_Tasks
{
    partial class CommonConveyorLineJob
    public partial class CommonConveyorLineJob
    {
        /// <summary>
        /// 处理出库任务
@@ -43,7 +44,7 @@
                // 更新任务状态
                _taskService.UpdateTaskStatusToNext(taskOut);
            }
            else if (taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
            else if (taskOut.TaskType == (int)TaskOutboundTypeEnum.OutTray && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
            {
                // 完成WMS任务
                CompleteWmsTask(taskOut, command, conveyorLine, childDeviceCode, ProtocalDetailValue);
@@ -56,13 +57,14 @@
        private void HandleNewTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            // 特定条件下创建并发送空托盘入库任务
            if (conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016")
            if ((conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016") || (conveyorLine.DeviceCode == "1005" && childDeviceCode == "1048"))
            {
                // 请求WMS空托盘任务
                CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
            }
            else if (conveyorLine.DeviceCode == "1001" && childDeviceCode == "1088")
            else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1088")||(conveyorLine.DeviceCode == "1004" && childDeviceCode == "1339"))
            {
                // 请求WMS任务
                // 请求WMS入库任务
                RequestWmsTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
            }
            else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1073") || (conveyorLine.DeviceCode == "1003" && childDeviceCode == "1002"))
@@ -109,7 +111,7 @@
        /// <summary>
        /// 创建并发送空托盘任务
        /// </summary>
        private void CreateAndSendEmptyTrayTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        public void CreateAndSendEmptyTrayTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            if (command.Barcode != "NoRead")
            {
@@ -142,18 +144,38 @@
        private WMSTaskDTO CreateEmptyTrayTaskDto(string barcode, string childDeviceCode)
        {
            // 创建并返回空托盘任务DTO
            return new WMSTaskDTO
            //return new WMSTaskDTO
            //{
            //    TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
            //    Grade = 1,
            //    PalletCode = barcode,
            //    RoadWay = "JZSC01",
            //    SourceAddress = childDeviceCode,
            //    TargetAddress = "JZSC01",
            //    TaskState = (int)TaskInStatusEnum.InNew,
            //    Id = 0,
            //    TaskType = (int)TaskInboundTypeEnum.InTray,
            //};
            #region 向WMS请求空托盘任务
            WMSTaskDTO wMSTaskDTO = new WMSTaskDTO();
            RequestTaskDto request = new RequestTaskDto()
            {
                TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
                Grade = 1,
                Position = childDeviceCode,
                PalletCode = barcode,
                RoadWay = "CHSC01",
                SourceAddress = childDeviceCode,
                TargetAddress = "CHSC01",
                TaskState = (int)TaskInStatusEnum.InNew,
                Id = 0,
                TaskType = (int)TaskInboundTypeEnum.InTray,
            };
            var result = HttpHelper.PostAsync("http:127.0.0.1:8098/api/Task/RequestTaskAsync", request.ToJsonString()).Result;
            WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
            // 检查状态并返回
            if (!content.Status)
                return wMSTaskDTO;
            return JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
            #endregion 向WMS请求空托盘任务
        }
        /// <summary>
@@ -180,4 +202,4 @@
            }
        }
    }
}
}