肖洋
2024-12-22 cdabe47ad8128c5006202e55c29746a617e988d6
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -90,10 +90,11 @@
                    task.Creater = "WMS";
                    if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                    {
                        if (task.TargetAddress == "002-021-001")
                        if (task.TargetAddress == "002-021-001" && task.Roadway.Contains("JZ") && task.TaskType == (int)TaskOutboundTypeEnum.OutTray)
                        {
                            task.TaskState = (int)TaskOutStatusEnum.OutNew;
                            task.CurrentAddress = item.SourceAddress;
                            task.NextAddress = item.TargetAddress;
                        }
                        else
                        {
@@ -128,6 +129,11 @@
                                task.NextAddress = routers.FirstOrDefault().ChildPosi;
                            }
                        }
                        else
                        {
                            task.CurrentAddress = "002-021-001";
                            task.NextAddress = item.TargetAddress;
                        }
                    }
                    tasks.Add(task);
                }
@@ -155,20 +161,31 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                var hasTask = await BaseDal.QueryFirstAsync(x => x.PalletCode == palletCode);
                if (hasTask != null)
                {
                    return content.OK("当前托盘存在任务");
                }
                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;
                if (wmsBase == null || requestTask == null)
                var wmsIpAddrss = string.Empty;
                var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == sourceAddress);
                if (stationManager.stationType == 5)
                {
                    throw new InvalidOperationException("WMS IP 未配置");
                    wmsIpAddrss = GetIpAddress(SysConfigKeyConst.WMSIP_BASE, SysConfigKeyConst.RequestInBoundTaskNG);
                }
                var wmsIpAddrss = wmsBase + requestTask;
                else
                {
                    wmsIpAddrss = GetIpAddress(SysConfigKeyConst.WMSIP_BASE, SysConfigKeyConst.RequestTask);
                }
                //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;
                //if (wmsBase == null || requestTask == null)
                //{
                //    throw new InvalidOperationException("WMS IP 未配置");
                //}
                //var wmsIpAddrss = wmsBase + requestTask;
                var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = sourceAddress, PalletCode = palletCode }.ToJsonString());
                content = JsonConvert.DeserializeObject<WebResponseContent>(result);
@@ -824,5 +841,18 @@
        {
            return BaseDal.QueryFirst(x => x.PalletCode == barcode && x.NextAddress == nextAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting), TaskOrderBy);
        }
        private string GetIpAddress(string baseIp,string name)
        {
            var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var wcsBasez = configz.Where(x => x.ConfigKey == baseIp).FirstOrDefault()?.ConfigValue;
            var address = configz.Where(x => x.ConfigKey == name).FirstOrDefault()?.ConfigValue;
            if (wcsBasez == null || address == null)
            {
                throw new InvalidOperationException("WMS IP 未配置");
            }
            return wcsBasez + address;
        }
    }
}