wanshenmean
2025-03-20 047e8be481b2b626a5dbcc613b5f2e77323239be
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -2,6 +2,7 @@
using Mapster;
using Newtonsoft.Json;
using System.Diagnostics.CodeAnalysis;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
@@ -214,7 +215,6 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                StaticVariable.isLineRun = false;
                // 检查当前托盘是否存在任务
                if (await HasTask(palletCode))
@@ -228,25 +228,22 @@
                    return content.Error($"【{stationManager.stationChildCode}】已存在直接出库任务任务");
                }
                if (StaticVariable.isStackerRun)
                {
                    if (stationManager.stationType == 7)
                    {
                        var result = await HandleStationType7(palletCode, stationManager);
                        if (result != null)
                        {
                            return result;
                        }
                    }
                    else if (stationManager.stationType == 6)
                    {
                        var result = await HandleStationType6(palletCode, stationManager);
                        if (result != null)
                        {
                            return result;
                        }
                    }
                }
                //if (stationManager.stationType == 7)
                //{
                //    var result = await HandleStationType7(palletCode, stationManager);
                //    if (result != null)
                //    {
                //        return result;
                //    }
                //}
                //else if (stationManager.stationType == 6)
                //{
                //    var result = await HandleStationType6(palletCode, stationManager);
                //    if (result != null)
                //    {
                //        return result;
                //    }
                //}
                // 发起请求获取入库任务
                content = await RequestInTask(palletCode, stationManager);
@@ -264,10 +261,6 @@
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
            finally
            {
                StaticVariable.isLineRun = true;
            }
        }
@@ -287,38 +280,9 @@
        }
        // 处理 stationType 为 7 的情况
        private async Task<WebResponseContent> HandleStationType7(string palletCode, Dt_StationManager stationManager)
        private async Task<WebResponseContent> HandleStationType7(Dt_StationManager stationManager)
        {
            var station = await _stationManagerRepository.QueryFirstAsync(x => x.stationType == 6 && x.productLine == stationManager.productLine && x.stationArea == stationManager.stationArea);
            var runTask = await BaseDal.QueryFirstAsync(x => x.CurrentAddress == station.stationChildCode && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && x.TaskType == (int)TaskInboundTypeEnum.InTray);
            if (runTask != null)
            {
                runTask.TargetAddress = stationManager.stationLocation;
                runTask.NextAddress = stationManager.stationChildCode;
                runTask.Grade = 3;
                runTask.TaskType = (int)TaskOutboundTypeEnum.InToOut;
                runTask.TaskState = (int)TaskOutStatusEnum.OutNew;
                var wmsIpAddrss = GetWmsIpAddress(SysConfigKeyConst.SetEmptyOutbyInToOutAsync);
                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { palletCode = runTask.PalletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = station.stationChildCode }.ToJsonString());
                var content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                if (content.Status)
                {
                    await BaseDal.UpdateDataAsync(runTask);
                    ConsoleHelper.WriteSuccessLine($"【{runTask.PalletCode}直接出库至二封】");
                    return content.OK("成功");
                }
                else
                {
                    ConsoleHelper.WriteErrorLine(content.Message);
                }
            }
            else
            {
                ConsoleHelper.WriteErrorLine($"【{station.stationChildCode}】未找到空托盘入库任务");
            }
            var station = await _taskNeedBarcodeRepository.QueryFirstAsync(x => x.toArea == stationManager.stationChildCode && x.productLine == stationManager.productLine);
            return null;
        }
@@ -406,9 +370,9 @@
                var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                ConsoleHelper.WriteSuccessLine(content.Data.ToString());
                content = ReceiveWMSTask(new List<WMSTaskDTO> { task });
                return content;
            }
            catch (Exception ex)