ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -468,8 +468,13 @@
                    }
                    if (task.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
                    {
                        var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress);
                        SendAgvTask(station.stationRemark, task.TaskNum);
                        string TargetAddress = GetLocation(task.PalletCode);
                        if (TargetAddress == "")
                        {
                            return content.Error($"未获取出库终点货位信息");
                        }
                        task.NextAddress = TargetAddress;
                        task.TargetAddress = TargetAddress;
                    }
                }
@@ -482,45 +487,21 @@
                    {
                        #region å…¥åº“调用接口获取货位地址
                        //var taskDto = new RequestTaskDto()
                        //{
                        //    Position = task.NextAddress,
                        //    PalletCode = task.PalletCode,
                        //};
                        //// èŽ·å–WMSip地址
                        //var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
                        //var wmsBasez = configz.Where(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE).FirstOrDefault()?.ConfigValue;
                        //var requestLocation = configz.Where(x => x.ConfigKey == SysConfigKeyConst.RequestLocation).FirstOrDefault()?.ConfigValue;
                        //if (wmsBasez == null || requestLocation == null)
                        //{
                        //    throw new InvalidOperationException("WMS IP æœªé…ç½®");
                        //}
                        //var wmsIpAddrss = wmsBasez + requestLocation;
                        //// å‘送请求并等待响应
                        //var abc = HttpHelper.PostAsync(wmsIpAddrss, taskDto.ToJsonString()).Result;
                        //if (abc == null)
                        //    return content.Error();
                        //// ååºåˆ—化响应内容
                        //content = JsonConvert.DeserializeObject<WebResponseContent>(abc);
                        //LogFactory.WriteError($"获取货位", $"获取货位,任务号:【{task.TaskNum}】,托盘号:【{task.PalletCode}】返回参数【{JsonConvert.SerializeObject(content)}】");
                        //// æ£€æŸ¥çŠ¶æ€å¹¶è¿”å›ž
                        //if (!content.Status)
                        //{
                        //    return content;
                        //}
                        //// ååºåˆ—化任务数据
                        //var taskResult = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
                        string TargetAddress= GetLocation(task.PalletCode);
                        if (TargetAddress == null)
                        {
                            return content.Error($"未获取入库终点货位信息");
                        }
                        task.CurrentAddress = task.NextAddress;
                        task.NextAddress = task.TargetAddress;
                        task.TargetAddress = task.NextAddress;
                        task.NextAddress = TargetAddress;
                        task.TargetAddress = TargetAddress;
                        #endregion å…¥åº“调用接口获取货位地址
                    }
                    else if (task.TaskState == (int)TaskInStatusEnum.Line_InExecuting)
                    {
                        UpdateStartLocationInfo(task);
                    }
                    else if (task.TaskState == (int)TaskInStatusEnum.SC_InFinish)
                    {
@@ -630,7 +611,7 @@
                        taskNew.CurrentAddress = stationManager.stationChildCode;
                        taskNew.NextAddress = task.TargetAddress;
                        taskNew.NextAddress = taskDTO.TargetAddress;
                        taskNew.Floor = stationManager.stationFloor;
@@ -693,6 +674,46 @@
            return content;
        }
        public string GetLocation(string palletCode)
        {
            var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
            var updateTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestLocation)?.ConfigValue;
            if (wmsBase == null || updateTask == null)
            {
                throw new InvalidOperationException("WMS IP æœªé…ç½®");
            }
            var wmsIpAddress = wmsBase + updateTask;
            var keys = new Dictionary<string, object>()
            {
                {"palletCode", palletCode}
            };
            var result = HttpHelper.GetAsync(wmsIpAddress, keys).Result;
            WebResponseContent? content = JsonConvert.DeserializeObject<WebResponseContent>(result);
            if (content.Status)
            {
                return content.Data.ToString();
            }
            else
            {
                return string.Empty;
            }
        }
        public void UpdateStartLocationInfo(Dt_Task task)
        {
            var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
            var updateTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.UpdateStartLocationInfo)?.ConfigValue;
            if (wmsBase == null || updateTask == null)
            {
                throw new InvalidOperationException("WMS IP æœªé…ç½®");
            }
            var wmsIpAddress = wmsBase + updateTask;
            var result = HttpHelper.PostAsync(wmsIpAddress, task.ToJsonString()).Result;
        }
        public void CompletedTask(int taskNum)
        {
            #region WMS同步任务完成
@@ -740,6 +761,8 @@
                    task.ModifyDate = DateTime.Now;
                    task.Modifier = "System";
                    BaseDal.UpdateData(task);
                    UpdateStartLocationInfo(task);
                    content.OK(data: task);
@@ -889,6 +912,11 @@
            return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskType == (int)TaskRelocationTypeEnum.Relocation && x.TaskState == (int)TaskRelocationStatusEnum.RelocationNew);
        }
        public Dt_Task QueryExecutingTask(string deviceNo)
        {
            return BaseDal.QueryFirst(x => x.Roadway == deviceNo &&( x.TaskState == (int)TaskRelocationStatusEnum.SC_RelocationExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskInStatusEnum.SC_InExecuting));
        }
        private string GetIpAddress(string baseIp, string name)
        {