1
huangxiaoqiang
9 天以前 0939aa5f3cc12a8856456a51cf2b661b6cd780c7
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -16,10 +16,12 @@
#endregion << ç‰ˆ æœ¬ æ³¨ é‡Š >>
using AutoMapper;
using HslCommunication;
using Mapster;
using Newtonsoft.Json;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using WIDESEA_Comm.Http;
using WIDESEA_Common.Log;
using WIDESEAWCS_Common;
@@ -41,6 +43,7 @@
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.DeviceBase;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_TaskInfoRepository;
@@ -55,6 +58,7 @@
        private readonly ITask_HtyRepository _taskHtyRepository;
        private readonly ISys_ConfigService _sys_ConfigService;
        private readonly IMapper _mapper;
        private readonly IDeviceInfoRepository _deviceInfoRepository;
        private readonly IDt_StationManagerRepository _stationManagerRepository;
@@ -71,7 +75,8 @@
        public List<int> TaskOutboundTypes => typeof(TaskOutboundTypeEnum).GetEnumIndexList();
        public List<int> TaskRelocationboundTypes => typeof(TaskRelocationTypeEnum).GetEnumIndexList();
        public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService taskHtyService, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository taskHtyRepository) : base(BaseDal)
        public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, ITask_HtyService taskHtyService, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository taskHtyRepository,
        IDeviceInfoRepository deviceInfoRepository) : base(BaseDal)
        {
            _routerService = routerService;
            _taskExecuteDetailService = taskExecuteDetailService;
@@ -82,6 +87,7 @@
            _taskHtyRepository = taskHtyRepository;
            _mapper = mapper;
            _sys_ConfigService = sys_ConfigService;
            _deviceInfoRepository = deviceInfoRepository;
        }
        /// <summary>
@@ -89,91 +95,205 @@
        /// </summary>
        /// <param name="taskDTOs">WMS任务对象集合</param>
        /// <returns>返回处理结果</returns>
        public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTaskDTO> taskDTOs)
        public WebResponseContent ReceiveWMSTask([NotNull] WMSTaskDTO taskDTOs)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {// åˆ›å»ºä¸€ä¸ªDt_Task类型的列表用于存储转换后的任务数据
            {
                List<Dt_Task> tasks = new List<Dt_Task>();
                // éåŽ†ä¼ å…¥çš„WMSTaskDTO列表
                foreach (var item in taskDTOs)
                // åˆ¤æ–­ä»»åŠ¡ç±»åž‹æ˜¯å¦ä¸ºå‡ºåº“ä»»åŠ¡
                if (taskDTOs.TaskType == "2")
                {
                    var task = BaseDal.QueryFirst(x => x.WMSTaskNum == item.TaskId || x.PalletCode == item.TPbarcode);
                    if (task != null)
                    if (Convert.ToInt32(taskDTOs.EndPoint) > 1999 && Convert.ToInt32(taskDTOs.EndPoint) < 3000)
                    {
                        task.Creater = "WMS";
                        task.Grade = 1;
                        task.PalletCode = item.TPbarcode;
                        Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == taskDTOs.EndPoint);
                        if (stationManagerStart == null)
                        {
                            return content.Error("未找到出库站台信息");
                        }
                        Dt_Task taskIn = new Dt_Task()
                        {
                            TaskNum = BaseDal.GetTaskNo().Result,
                            Creater = "WMS",
                            WMSTaskNum = taskDTOs.TaskId,
                            Grade = 1,
                            PalletCode = taskDTOs.TPbarcode,
                            TaskType = (int)TaskOutboundTypeEnum.Outbound,
                            TaskState = (int)TaskOutStatusEnum.OutNew,
                            SourceAddress = taskDTOs.BeginPoint,
                            CurrentAddress = taskDTOs.BeginPoint,
                            Roadway = stationManagerStart.Roadway,
                            NextAddress = taskDTOs.EndPoint,
                            TargetAddress = taskDTOs.EndPoint,
                            Floor = stationManagerStart.stationFloor,
                            RGVName = ""
                        };
                        BaseDal.AddData(taskIn);
                    }
                    // åˆ¤æ–­ä»»åŠ¡ç±»åž‹æ˜¯å¦ä¸ºå‡ºåº“ä»»åŠ¡
                    if (item.TaskType == "2")
                    else
                    {
                        string[] targetCodes = item.BeginPoint.Split("-");
                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == GetScCode(Convert.ToInt32(targetCodes[0])) && x.stationType == 2);
                        string[] targetCodes = taskDTOs.BeginPoint.Split("-");
                        Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationChildCode == taskDTOs.EndPoint);
                        if (stationManagerEnd == null)
                        {
                            return content.Error("未找到出库站台信息");
                        }
                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == GetScCode(Convert.ToInt32(targetCodes[0])) && x.stationType == 2 && x.stationFloor == stationManagerEnd.stationFloor);
                        var RGVName = string.Empty;
                        if (stationManager.stationFloor == "1F")
                        {
                            RGVName = stationManager.RGVName;
                        }
                        Dt_Task taskOut = new Dt_Task()
                        {
                            TaskNum = BaseDal.GetTaskNo().Result,
                            Creater = "WMS",
                            WMSTaskNum=item.TaskId,
                            WMSTaskNum = taskDTOs.TaskId,
                            Grade = 1,
                            PalletCode = item.TPbarcode,
                            PalletCode = taskDTOs.TPbarcode,
                            TaskType = (int)TaskOutboundTypeEnum.Outbound,
                            TaskState = (int)TaskOutStatusEnum.OutNew,
                            SourceAddress = item.BeginPoint,
                            CurrentAddress = item.BeginPoint,
                            SourceAddress = taskDTOs.BeginPoint,
                            CurrentAddress = taskDTOs.BeginPoint,
                            Roadway = GetScCode(Convert.ToInt32(targetCodes[0])),
                            NextAddress = stationManager.stationChildCode,
                            TargetAddress = item.EndPoint,
                            RGVName = "RGV01"
                            TargetAddress = taskDTOs.EndPoint,
                            RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName,
                            Floor = stationManager.stationFloor,
                            TargetStation= stationManagerEnd.remark,
                            SourceStation= 0,
                        };
                        BaseDal.AddData(taskOut);
                    }
                    // åˆ¤æ–­ä»»åŠ¡ç±»åž‹æ˜¯å¦ä¸ºå…¥åº“ä»»åŠ¡
                    else if (item.TaskType == "1")
                }
                // åˆ¤æ–­ä»»åŠ¡ç±»åž‹æ˜¯å¦ä¸ºå…¥åº“ä»»åŠ¡
                else if (taskDTOs.TaskType == "1")
                {
                    if (taskDTOs.BeginPoint == "3002")
                    {
                        task.TaskType = (int)TaskInboundTypeEnum.Inbound;
                        task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish;
                        task.CurrentAddress = item.BeginPoint;
                        task.WMSTaskNum = item.TaskId;
                        task.TargetAddress = item.EndPoint;
                        string[] targetCodes = item.EndPoint.Split("-");
                        task.Roadway = GetScCode(Convert.ToInt32(targetCodes[0]));
                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 3);
                        task.NextAddress = stationManager.stationChildCode;
                        BaseDal.UpdateData(task);
                    }
                    else if (item.TaskType == "3")
                        Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == taskDTOs.BeginPoint);
                        if (stationManagerStart == null)
                        {
                            return content.Error("未找到入库站台信息");
                        }
                        string[] targetCodes = taskDTOs.EndPoint.Split("-");
                        Dt_Task taskIn = new Dt_Task()
                        {
                            TaskNum = BaseDal.GetTaskNo().Result,
                            Creater = "WMS",
                            WMSTaskNum = taskDTOs.TaskId,
                            Grade = 1,
                            PalletCode = taskDTOs.TPbarcode,
                            TaskType = (int)TaskInboundTypeEnum.Inbound,
                            TaskState = (int)TaskInStatusEnum.HoistNew,
                            SourceAddress = taskDTOs.BeginPoint,
                            CurrentAddress = stationManagerStart.stationChildCode,
                            Roadway = GetScCode(Convert.ToInt32(targetCodes[0])),
                            NextAddress = stationManagerStart.stationNextChildCode,
                            TargetAddress = taskDTOs.EndPoint,
                            Floor = stationManagerStart.stationFloor,
                            RGVName = "RGV03"
                        };
                        BaseDal.AddData(taskIn);
                    }
                    else if (Convert.ToInt32(taskDTOs.BeginPoint) > 1999 && Convert.ToInt32(taskDTOs.BeginPoint) < 3000)
                    {
                        task.TaskType = (int)TaskRelocationTypeEnum.Relocation;
                        task.TaskState = (int)TaskRelocationStatusEnum.RelocationNew;
                        task.SourceAddress = item.BeginPoint;
                        task.CurrentAddress = item.BeginPoint;
                        task.NextAddress = item.EndPoint;
                        task.TargetAddress = item.EndPoint;
                        task.Grade = 3;
                        BaseDal.AddData(tasks);
                        Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == taskDTOs.BeginPoint);
                        if (stationManagerStart == null)
                        {
                            return content.Error("未找到出库站台信息");
                        }
                        Dt_Task taskIn = new Dt_Task()
                        {
                            TaskNum = BaseDal.GetTaskNo().Result,
                            Creater = "WMS",
                            WMSTaskNum = taskDTOs.TaskId,
                            Grade = 1,
                            PalletCode = taskDTOs.TPbarcode,
                            TaskType = (int)TaskInboundTypeEnum.Inbound,
                            TaskState = (int)TaskInStatusEnum.Line_InFinish,
                            SourceAddress = taskDTOs.BeginPoint,
                            CurrentAddress = stationManagerStart.stationChildCode,
                            Roadway = stationManagerStart.Roadway,
                            NextAddress = taskDTOs.EndPoint,
                            TargetAddress = taskDTOs.EndPoint,
                            Floor = stationManagerStart.stationFloor,
                            RGVName = ""
                        };
                        BaseDal.AddData(taskIn);
                    }
                    else
                    {
                        return content.Error($"任务类型错误,未找到该任务类型,任务号:【{item.TaskId}】,任务类型:【{item.TaskType}】");
                        var task = BaseDal.QueryFirst(x => x.PalletCode == taskDTOs.TPbarcode);
                        if (task != null)
                        {
                            task.Creater = "WMS";
                            task.Grade = 1;
                            task.PalletCode = taskDTOs.TPbarcode;
                            task.TaskType = (int)TaskInboundTypeEnum.Inbound;
                            task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish;
                            task.CurrentAddress = taskDTOs.BeginPoint;
                            task.WMSTaskNum = taskDTOs.TaskId;
                            task.TargetAddress = taskDTOs.EndPoint;
                            string[] targetCodes = taskDTOs.EndPoint.Split("-");
                            task.Roadway = GetScCode(Convert.ToInt32(targetCodes[0]));
                            Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 3 && x.stationFloor == task.Floor);
                            Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode==taskDTOs.BeginPoint && x.stationFloor == task.Floor);
                            task.NextAddress = stationManager.stationChildCode;
                            task.SourceStation = stationManagerStart.remark;
                            task.TargetStation = stationManager.stationRemark;
                            BaseDal.UpdateData(task);
                        }
                        else
                        {
                            return content.Error($"未找到该托盘【{taskDTOs.TPbarcode}】任务");
                        }
                    }
                }
                else if (taskDTOs.TaskType == "3")
                {
                    string[] targetCodes = taskDTOs.BeginPoint.Split("-");
                    Dt_Task taskRelocation = new Dt_Task()
                    {
                        TaskType = (int)TaskRelocationTypeEnum.Relocation,
                        TaskState = (int)TaskRelocationStatusEnum.RelocationNew,
                        Roadway = GetScCode(Convert.ToInt32(targetCodes[0])),
                        SourceAddress = taskDTOs.BeginPoint,
                        CurrentAddress = taskDTOs.BeginPoint,
                        NextAddress = taskDTOs.EndPoint,
                        TargetAddress = taskDTOs.EndPoint,
                        Grade = 3,
                    };
                    BaseDal.AddData(taskRelocation);
                }
                else
                {
                    return content.Error($"任务类型错误,未找到该任务类型,任务号:【{taskDTOs.TaskId}】,任务类型:【{taskDTOs.TaskType}】");
                }
                _taskExecuteDetailService.AddTaskExecuteDetail(tasks.Select(x => x.TaskId).ToList(), "接收WMS任务");
                content = WebResponseContent.Instance.OK("成功");
@@ -195,17 +315,25 @@
            {
                return "SC01";
            }
            else if (number >= 5 && number <= 8)
            else if (number >= 5 && number <= 7)
            {
                return "SC02";
            }
            else if (number >= 9 && number <= 12)
            else if (number >= 8 && number <= 10)
            {
                return "SC03";
            }
            else if (number >= 13 && number <= 16)
            else if (number >= 11 && number <= 14)
            {
                return "SC04";
            }
            else if (number >= 15 && number <= 18)
            {
                return "SC05";
            }
            else if (number >= 19 && number <= 22)
            {
                return "SC06";
            }
            else
            {
@@ -221,8 +349,8 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Task task = BaseDal.QueryFirst(x => x.WMSTaskNum == taskDTO.TaskId || x.Roadway == taskDTO.WhCode);
                Dt_Task_Hty taskHty = _taskHtyRepository.QueryFirst(x => x.WMSTaskNum == taskDTO.TaskId || x.Roadway == taskDTO.WhCode);
                Dt_Task task = BaseDal.QueryFirst(x => x.WMSTaskNum == taskDTO.TaskId && x.Roadway == taskDTO.WhCode);
                Dt_Task_Hty taskHty = _taskHtyRepository.QueryFirst(x => x.WMSTaskNum == taskDTO.TaskId && x.Roadway == taskDTO.WhCode);
                if (task != null)
                {
                    return content.OK(data: new WMSTaskDTO()
@@ -317,7 +445,7 @@
        /// <param name="deviceNo">设备编号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        public Dt_Task QueryConveyorLineTask(string currentAddress)
        public Dt_Task QueryConveyorLineTask(string currentAddress,int taskNum)
        {
            Dt_Task task= BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.RGV_InExecutingFinish && x.CurrentAddress == currentAddress, TaskOrderBy);
            if (task == null)
@@ -333,12 +461,12 @@
        /// <param name="deviceNo">设备编号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        public Dt_Task QueryConveyorLineFinishTask(string currentAddress)
        public Dt_Task QueryConveyorLineFinishTask(string currentAddress,int taskNum)
        {
            Dt_Task task = BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InExecuting && x.NextAddress == currentAddress, TaskOrderBy);
            Dt_Task task = BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.Line_InExecuting && x.NextAddress == currentAddress && x.TaskNum == taskNum, TaskOrderBy);
            if (task == null)
            {
                task = BaseDal.QueryFirst(x => TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting && x.NextAddress == currentAddress, TaskOrderBy);
                task = BaseDal.QueryFirst(x => TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting && x.CurrentAddress == currentAddress && x.TaskNum == taskNum, TaskOrderBy);
            }
            return task;
        }
@@ -352,7 +480,18 @@
        /// <returns></returns>
        public Dt_Task QueryRGVExecutingTask(string deviceNo)
        {
            return BaseDal.QueryFirst(x => TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish);
            return BaseDal.QueryFirst(x => (x.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish|| x.TaskState == (int)TaskInStatusEnum.RGV_InAwaitWMS|| x.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish) && x.RGVName == deviceNo);
        }
        /// <summary>
        /// æ ¹æ®è®¾å¤‡ç¼–号、当前地址查询RGV未执行的任务
        /// </summary>
        /// <param name="deviceNo">设备编号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        public Dt_Task QueryRGVExecutingTask(string deviceNo,int taskNum)
        {
            return BaseDal.QueryFirst(x => (x.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish || x.TaskState == (int)TaskInStatusEnum.RGV_InAwaitWMS) && x.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish && x.RGVName == deviceNo&&x.TaskNum==taskNum);
        }
        /// <summary>
@@ -404,6 +543,11 @@
        public Dt_Task QueryRGVTask(string deviceNo)
        {
            return BaseDal.QueryFirst(x => x.RGVName == deviceNo && ((TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew) || (TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Line_OutFinish)), TaskOrderBy);
        }
        public List<Dt_Task> QueryRGVTask()
        {
            return BaseDal.QueryData(x => ((TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew) || (TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.Line_OutFinish) && x.Floor == "1F"), TaskOrderBy);
        }
        /// <summary>
@@ -540,6 +684,15 @@
                        BaseDal.DeleteData(task);
                        _taskHtyRepository.AddData(task_Hty);
                    }
                    if (task.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
                    {
                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode == task.NextAddress);
                        Dt_StationManager stationManagerend = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress);
                        task.CurrentAddress = task.NextAddress;
                        task.NextAddress = task.TargetAddress;
                        task.SourceStation = stationManager.stationRemark;
                        task.TargetStation = stationManagerend.remark;
                    }
                    if (task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
                    {
@@ -551,13 +704,8 @@
                {
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
                    task.TaskState = nextStatus;
                    if (task.TaskState == (int)TaskInStatusEnum.Line_InExecuting)
                    {
                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationChildCode== task.NextAddress);
                        task.CurrentAddress = task.NextAddress;
                        task.NextAddress = stationManager.stationNextChildCode;
                    }
                    else if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish)
                    if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish)
                    {
                        task.CurrentAddress = task.NextAddress;
                        task.NextAddress = task.TargetAddress;
@@ -616,38 +764,39 @@
                if (task.TaskState == (int)TaskInStatusEnum.RGV_Indispatch)
                {
                    //var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                    //var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                    //var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
                    //var keys = new Dictionary<string, object>()
                    //{
                    //    {"TPbarcode", Barcode},
                    //    {"WhCode", "1001"},
                    //    {"BeginPoint", task.SourceAddress}
                    //};
                    //if (wmsBase == null || requestTask == null)
                    //{
                    //    throw new InvalidOperationException("WMS IP æœªé…ç½®");
                    //}
                    //var wmsIpAddress = wmsBase + requestTask;
                    //var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, keys.ToString()).Result;
                    task.TaskState = (int)TaskInStatusEnum.RGV_InAwaitWMS;
                    task.PalletCode = Barcode;
                    task.ModifyDate = DateTime.Now;
                    BaseDal.UpdateData(task);
                    //if (result != null)
                    //{
                        task.TaskState = (int)TaskInStatusEnum.RGV_InAwaitWMS;
                        task.PalletCode = Barcode;
                        task.ModifyDate = DateTime.Now;
                        BaseDal.UpdateData(task);
                    //}
                    var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                    var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                    var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
                    WMSTaskDTO taskDTO = new WMSTaskDTO()
                    {
                        TPbarcode = Barcode,
                        WhCode = "1001",
                        BeginPoint = task.SourceAddress
                    };
                    if (wmsBase == null || requestTask == null)
                    {
                        throw new InvalidOperationException("WMS IP æœªé…ç½®");
                    }
                    var wmsIpAddress = wmsBase + requestTask;
                    var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"RGV调度完成等待WMS任务");
                }
                else if (task.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
                {
                    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress);
                    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress && x.stationFloor == task.Floor);
                    task.TaskState = (int)TaskInStatusEnum.RGV_InExecutingFinish;
                    task.NextAddress = stationManager.stationNextChildCode;
                    task.CurrentAddress = task.NextAddress;
                    task.NextAddress = stationManager.stationNextChildCode;
                    task.ModifyDate = DateTime.Now;
                    BaseDal.UpdateData(task);
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"RGV入库完成");
@@ -659,9 +808,8 @@
                    BaseDal.UpdateData(task);
                }
                else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting)
                else if (task.TaskState == (int)TaskInStatusEnum.InRetuen)
                {
                    task.TaskState = (int)TaskOutStatusEnum.RGV_OutFinish;
                    task.ModifyDate = DateTime.Now;
                    task.Modifier = "System";
@@ -670,6 +818,40 @@
                    BaseDal.DeleteData(task);
                    _taskHtyRepository.AddData(task_Hty);
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"RGV出库完成");
                }
                else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting)
                {
                    task.TaskState = (int)TaskOutStatusEnum.OutFinish;
                    task.ModifyDate = DateTime.Now;
                    task.Modifier = "System";
                    Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task);
                    task_Hty.TaskId = 0;
                    BaseDal.DeleteData(task);
                    _taskHtyRepository.AddData(task_Hty);
                    var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                    var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                    var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
                    WMSTaskDTO taskDTO = new WMSTaskDTO()
                    {
                        TaskId = task.WMSTaskNum,
                        TPbarcode = task.PalletCode,
                        WhCode = "1001",
                        BeginPoint = task.SourceAddress,
                        EndPoint = task.TargetAddress,
                        Results = "1"
                    };
                    if (wmsBase == null || requestTask == null)
                    {
                        throw new InvalidOperationException("WMS IP æœªé…ç½®");
                    }
                    var wmsIpAddress = wmsBase + requestTask;
                    var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"RGV出库完成");
                }
                else
@@ -694,49 +876,43 @@
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                if (task == null) return WebResponseContent.Instance.Error($"未找到该任务信息,任务号:【{taskNum}】");
                //var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                //var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                //var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
                //var keys = new Dictionary<string, object>()
                //    {
                //        {"TaskId", task.WMSTaskNum},
                //        {"TPbarcode", task.PalletCode},
                //        {"WhCode", "1001"},
                //        {"BeginPoint", task.SourceAddress},
                //        {"EndPoint", task.TargetAddress},
                //        {"Results", 1},
                //    };
                //if (wmsBase == null || requestTask == null)
                //{
                //    throw new InvalidOperationException("WMS IP æœªé…ç½®");
                //}
                //var wmsIpAddress = wmsBase + requestTask;
                //var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, keys.ToString()).Result;
                //if (result != null)
                //{
                //    task.ExceptionMessage += "   " + content.Message;
                //}
                if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting)
                {
                    task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish;
                    if (Convert.ToInt32(task.TargetAddress) > 1999 && Convert.ToInt32(task.TargetAddress) < 3000)
                    {
                        task.TaskState = (int)TaskOutStatusEnum.OutFinish; ;
                        task.ModifyDate = DateTime.Now;
                        task.Modifier = "System";
                    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2);
                        Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task);
                        task_Hty.TaskId = 0;
                    task.CurrentAddress = task.NextAddress;
                        BaseDal.DeleteData(task);
                        _taskHtyRepository.AddData(task_Hty);
                        _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机出库完成");
                    }
                    else
                    {
                        task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish;
                    task.NextAddress = stationManager.stationNextChildCode;
                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2 && x.stationFloor == task.Floor);
                    BaseDal.UpdateData(task);
                        task.CurrentAddress = task.NextAddress;
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机出库完成");
                        task.NextAddress = stationManager.stationNextChildCode;
                        BaseDal.UpdateData(task);
                        _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机出库完成");
                    }
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
                {
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)
                {
                    //todo åŒæ­¥åˆ°WMS
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
                    task.TaskState = nextStatus;
                    task.TaskState = (int)TaskInStatusEnum.InFinish; ;
                    task.ModifyDate = DateTime.Now;
                    task.Modifier = "System";
@@ -746,6 +922,25 @@
                    BaseDal.DeleteData(task);
                    _taskHtyRepository.AddData(task_Hty);
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机入库完成");
                    var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                    var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                    var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
                    WMSTaskDTO taskDTO = new WMSTaskDTO()
                    {
                        TaskId = task.WMSTaskNum,
                        TPbarcode = task.PalletCode,
                        WhCode = "1001",
                        BeginPoint = task.SourceAddress,
                        EndPoint = task.TargetAddress,
                        Results = "1"
                    };
                    if (wmsBase == null || requestTask == null)
                    {
                        throw new InvalidOperationException("WMS IP æœªé…ç½®");
                    }
                    var wmsIpAddress = wmsBase + requestTask;
                    var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
                {
@@ -760,6 +955,25 @@
                    BaseDal.DeleteData(task);
                    _taskHtyRepository.AddData(task_Hty);
                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机移库完成");
                    var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                    var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
                    var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
                    WMSTaskDTO taskDTO = new WMSTaskDTO()
                    {
                        TaskId = task.WMSTaskNum,
                        TPbarcode = task.PalletCode,
                        WhCode = "1001",
                        BeginPoint = task.SourceAddress,
                        EndPoint = task.TargetAddress,
                        Results = "1"
                    };
                    if (wmsBase == null || requestTask == null)
                    {
                        throw new InvalidOperationException("WMS IP æœªé…ç½®");
                    }
                    var wmsIpAddress = wmsBase + requestTask;
                    var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup)
                {
@@ -954,5 +1168,64 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public WebResponseContent TaskComplete()
        {
            WebResponseContent content = new WebResponseContent();
            //var result = _stationManagerRepository.Db.Queryable<Dt_StationManager>()
            //    .Where(t => SqlFunc.Abs(t.LevelPointFist - taskNum) <= 1000)
            //    .ToList();
            var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
            var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
            WMSTaskDTO taskDTO = new WMSTaskDTO()
            {
                TaskId="1",
                TPbarcode = "123456",
                WhCode = "1001",
                BeginPoint = "1013",
                EndPoint="1-1-1",
                Results="1"
            };
            if (wmsBase == null || requestTask == null)
            {
                throw new InvalidOperationException("WMS IP æœªé…ç½®");
            }
            var wmsIpAddress = wmsBase + requestTask;
            var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
            return content.OK(data: result);
        }
        public WebResponseContent RequestTask()
        {
            WebResponseContent content = new WebResponseContent();
            //var result = _stationManagerRepository.Db.Queryable<Dt_StationManager>()
            //    .Where(t => SqlFunc.Abs(t.LevelPointFist - taskNum) <= 1000)
            //    .ToList();
            var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
            var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
            //var keys = new Dictionary<string, object>()
            //{
            //    {"TPbarcode", "123456"},
            //    {"WhCode", "1001"},
            //    {"BeginPoint", "1013"}
            //};
            WMSTaskDTO taskDTO = new WMSTaskDTO()
            {
                TPbarcode = "123456",
                WhCode = "1001",
                BeginPoint = "1013"
            };
            if (wmsBase == null || requestTask == null)
            {
                throw new InvalidOperationException("WMS IP æœªé…ç½®");
            }
            var wmsIpAddress = wmsBase + requestTask;
            var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
            return content.OK(data: result);
        }
    }
}