wanshenmean
2024-11-06 fb77cc8fe39bd3c3f49b336bf9e664957fe2dc07
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>
        /// 处理出库任务
@@ -34,7 +35,7 @@
            bool isOutboundAndOutFinish = taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.SC_OutFinish;
            bool isOutboundAndLineOutExecuting = taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting;
            if (isOutTray || isOutboundAndOutFinish || isOutboundAndLineOutExecuting)
            if (isOutTray || isOutboundAndOutFinish || !isOutboundAndLineOutExecuting)
            {
                // 发送命令到输送线
                conveyorLine.SendCommand(taskCommand, childDeviceCode);
@@ -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 @@
            }
        }
    }
}
}