wangxinhui
2025-01-10 741cc4cde8bc475366891e795988a11153eae07c
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -116,7 +116,8 @@
                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
                if (task != null)
                {
                    BaseDal.DeleteAndMoveIntoHty(task, App.User == null ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                    task.TaskState = TaskStatusEnum.Finish.ObjToInt();
                    BaseDal.DeleteAndMoveIntoHty(task, App.User?.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                }
                string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.FeedBackWMSTaskCompleted.ToString())?.ApiAddress;
                if (string.IsNullOrEmpty(url))
@@ -169,7 +170,7 @@
                        Dt_StationManger stationManger;
                        if (taskTypeGroup == TaskTypeGroup.InboundGroup)
                        {
                            stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == item.SourceAddress);
                            stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == item.SourceAddress || x.StationDeviceCode == item.SourceAddress);
                        }
                        else
                        {
@@ -180,7 +181,7 @@
                            return WebResponseContent.Instance.Error($"未找到站台配置信息");
                        }
                        List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (item.SourceAddress == x.StartPosi || item.RoadWay == x.StartPosi));
                        List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (item.SourceAddress == x.StartPosi || item.RoadWay == x.StartPosi || item.RoadWay == x.ChildPosiDeviceCode || item.RoadWay == x.ChildPosi));
                        router = routers.FirstOrDefault();
                        if (router == null)
                        {
@@ -189,15 +190,28 @@
                        if (routers.Count == 1)
                        {
                            if(taskTypeGroup == TaskTypeGroup.InboundGroup && item.TargetAddress == stationManger.StackerCraneCode)
                            if (taskTypeGroup == TaskTypeGroup.InboundGroup && item.TargetAddress == stationManger.StackerCraneCode)
                            {
                                task.NextAddress = router.NextPosi;
                                task.DeviceCode = stationManger.StationDeviceCode;
                            }
                            else if (item.TaskType == TaskTypeEnum.MesOutbound.ObjToInt())
                            {
                                task.NextAddress = router.NextPosi;
                                task.DeviceCode = stationManger.StackerCraneCode;
                            }
                            else
                            {
                                task.NextAddress = item.TargetAddress;
                                task.DeviceCode = stationManger.StationDeviceCode;
                                if (item.RoadWay.Contains("AGV"))
                                {
                                    task.DeviceCode = item.RoadWay;
                                    task.AgvTaskNum = task.DeviceCode + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
                                }
                                else
                                {
                                    task.DeviceCode = stationManger.StationDeviceCode;
                                }
                            }
                        }
                        else
@@ -210,7 +224,7 @@
                    {
                        if (taskTypeGroup == TaskTypeGroup.OutbondGroup)
                        {
                            task.AgvTaskNum = "AGV-" + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
                            task.AgvTaskNum = item.AGVArea + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
                            List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.NextPosi);
                            if (routers.FirstOrDefault() == null)
                            {
@@ -224,7 +238,7 @@
                        }
                        else
                        {
                            task.AgvTaskNum = "AGV-" + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
                            task.AgvTaskNum = item.AGVArea + DateTime.Now.ToString("yyyyMMdd") + item.TaskNum;
                            List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.StartPosi);
                            if (routers.FirstOrDefault() == null)
                            {
@@ -275,8 +289,12 @@
                {
                    return WebResponseContent.Instance.Error($"未找到站台信息");
                }
                string responseStr = HttpHelper.Get($"http://127.0.0.1:9293/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}");
                string address = AppSettings.Get("WMSApiAddress");
                if (string.IsNullOrEmpty(address))
                {
                    return WebResponseContent.Instance.Error($"未找到WMSApi地址");
                }
                string responseStr = HttpHelper.Get($"{address}/api/Task/DeviceRequestInboundTask?stationCode={sourceAddress}&roadwayNo={stationManger.StackerCraneCode}&palletCode={palletCode}");
                WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
                if (responseContent != null && responseContent.Status && responseContent.Data != null)
                {
@@ -295,6 +313,31 @@
            return content;
        }
        public WebResponseContent RequestWMSAssignRoadway(int taskNum, List<string> roadwayNos)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string address = AppSettings.Get("WMSApiAddress");
                if (string.IsNullOrEmpty(address))
                {
                    return WebResponseContent.Instance.Error($"未找到WMSApi地址");
                }
                string responseStr = HttpHelper.Post($"{address}/api/Task/AssignRoadway?taskNum={taskNum}", roadwayNos.Serialize());
                WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
                if (responseContent != null && responseContent.Status && responseContent.Data != null)
                {
                    return responseContent;
                }
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// å‘WMS申请分配货位
        /// </summary>
@@ -303,7 +346,9 @@
        /// <returns></returns>
        public string? RequestAssignLocation(int taskNum, string roadwayNo)
        {
            string responseStr = HttpHelper.Get($"http://127.0.0.1:9283/api/Task/AssignInboundTaskLocation?taskNum={taskNum}&roadwayNo={roadwayNo}");
            string address = AppSettings.Get("WMSApiAddress");
            if (string.IsNullOrEmpty(address)) throw new Exception("未找到WMSApi地址");
            string responseStr = HttpHelper.Get($"{address}/api/Task/AssignInboundTaskLocation?taskNum={taskNum}&roadwayNo={roadwayNo}");
            WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(responseStr);
            if (responseContent != null && responseContent.Status && responseContent.Data != null)