chenyong
2025-05-22 03e09a08f4609cc61e64ca16129db5a3ccb85c1d
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
@@ -216,9 +216,14 @@
                }
                else
                {
                    ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    //ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                    //conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, (long)task.TaskNum, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    _taskService.UpdateTaskStatusToNext(task);
                }
            }
@@ -236,7 +241,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)
@@ -248,13 +254,11 @@
                Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
                if (newTask != null)
                {
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, newTask.TaskNum, childDeviceCode);
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, newTask.NextAddress, childDeviceCode);
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, command.ConveyorLineBarcode, childDeviceCode);
                    ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask);
                    //taskCommand.InteractiveSignal = command.InteractiveSignal;
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, (long)newTask.TaskNum, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, newTask.NextAddress, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, newTask.PalletCode, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    _taskService.UpdateData(newTask);
                }
            }
        }
@@ -294,10 +298,16 @@
        public void RequestOutbound(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
        {
            var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            //var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.ConveyorLineBarcode);
            if (task != null)
            {
                ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                //ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                //conveyorLine.SendCommand(taskCommand, childDeviceCode);
                //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, (long)task.TaskNum, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, childDeviceCode);
                conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
@@ -317,7 +327,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);
@@ -351,16 +362,27 @@
                    Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
                    if (newTask != null)
                    {
                        ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask);
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        //ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask);
                        //conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                        conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, (long)newTask.TaskNum, childDeviceCode);
                        conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, newTask.NextAddress, childDeviceCode);
                        conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, newTask.PalletCode, childDeviceCode);
                        conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                        _taskService.UpdateData(newTask);
                    }
                }
                else
                {
                    ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                    taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationNGChildCode);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    //ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                    //taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationNGChildCode);
                    //conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, (long)task.TaskNum, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, childDeviceCode);
                    conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    _taskService.UpdateTaskStatusToNext(task);
                }
@@ -377,7 +399,8 @@
        {
            try
            {
                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();
@@ -424,6 +447,7 @@
                    conveyorLine.Communicator.Write(address, 1);
                    //conveyorLine.SetValue(ConveyorLineDBName_After.InteractiveSignal, taskCommand.InteractiveSignal, childDeviceCode);
                    //conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
                    WriteInfo($"{conveyorLine.DeviceName}输送线出库完成", $"子节点【{childDeviceCode}】托盘号:【{command.ConveyorLineBarcode}】");
                }
            }
            catch (Exception ex)
@@ -494,8 +518,8 @@
                }
                var wmsIpAddress = wmsBase + requestTrayOutTask;
                var device = _deviceInfoRepository.QueryData(x => x.DeviceStatus == "1" && x.DeviceRemark == platform.Id.ToString());
                var deviceCode = device.Select(x => x.DeviceCode).ToList();
                //var device = _deviceInfoRepository.QueryData(x => x.DeviceStatus == "1" && x.DeviceRemark == platform.Id.ToString());
                //var deviceCode = device.Select(x => x.DeviceCode).ToList();
                List<string> strings = platform.Location.Split(',').ToList();
                var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = platform.Stacker, AreaCdoes = strings, platform.ProductionLine }.ToJsonString());
@@ -508,7 +532,7 @@
                    return;
                taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                //WriteInfo("出库", $"【{JsonConvert.SerializeObject(taskDTO)}】");
                WriteInfo("出库", $"【{JsonConvert.SerializeObject(taskDTO)}】");
                #endregion 调用WMS获取出库任务
                CreateAndSendTask(taskDTO);