From 1ff9f4e6ba64ebad9ccf0367d6d23c75cc27dd27 Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期日, 22 十二月 2024 18:47:16 +0800 Subject: [PATCH] 重构任务处理方法,改用异步方式处理新任务,优化事件通知逻辑 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 103 insertions(+), 5 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs index 327afad..5923b5e 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs @@ -93,21 +93,72 @@ var result = await HttpHelper.PostAsync(wmsIpAddrss, new { palletCode = palletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode }.ToJsonString()); content = JsonConvert.DeserializeObject<WebResponseContent>(result); - if (!content.Status) { // wms澶辫触杩斿洖鍘籒G鍙d换鍔� - - + //if (stationManager.stationChildCode != stationManager.stationNGChildCode) + //{ + // WMSTaskDTO taskDTO = new WMSTaskDTO() + // { + // Grade = 8, + // PalletCode = palletCode, + // SourceAddress = stationManager.stationLocation, + // TargetAddress = stationManager.stationNGLocation, + // RoadWay = stationManager.Roadway, + // TaskNum = 1000, + // TaskState = (int)TaskOutStatusEnum.OutNew, + // TaskType = (int)TaskOutboundTypeEnum.InToOut + // }; + //} return content; } var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); + ConsoleHelper.WriteSuccessLine(content.Data.ToString()); return ReceiveByWMSTask(task); } catch (Exception ex) { return WebResponseContent.Instance.Error(ex.Message); + } + } + + public async Task<WebResponseContent> RequestOutTaskToBZAsync(Dt_StationManager stationManager) + { + WebResponseContent content = new WebResponseContent(); + try + { + 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.RequestOutTaskToBZ)?.ConfigValue; + if (wmsBase == null || requestTask == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + var wmsIpAddrss = wmsBase + requestTask; + + var result = await HttpHelper.PostAsync(wmsIpAddrss, new { }.ToJsonString()); + content = JsonConvert.DeserializeObject<WebResponseContent>(result); + if (!content.Status) + { + //鏃犳弧瓒虫潯浠跺彲鍑哄簱鑷冲寘瑁呯殑搴撳瓨 + return content; + } + + var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); + ConsoleHelper.WriteSuccessLine(content.Data.ToString()); + content = ReceiveByWMSTask(task); + //if (content.Status) + //{ + // //鐩稿簲鐨勫湪閫旀暟鎹�+1 + // // _taskNeedBarcodeRepository.UpdateData(); + //} + return content; + } + catch (Exception ex) + { + + return content.Error(ex.Message); } } @@ -146,6 +197,53 @@ task.NextAddress = stationinfo.stationChildCode; task.TargetAddress = taskDTO.TargetAddress; } + else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) + { + task.TaskState = (int)TaskStatus.Created; + task.SourceAddress = taskDTO.SourceAddress; + task.CurrentAddress = taskDTO.SourceAddress; + task.NextAddress = taskDTO.TargetAddress; + task.TargetAddress = taskDTO.TargetAddress; + } + + BaseDal.AddData(task); + + _taskExecuteDetailService.AddTaskExecuteDetail(task.WMSId, "鎺ユ敹WMS浠诲姟"); + + content = WebResponseContent.Instance.OK("鎴愬姛"); + } + catch (Exception ex) + { + content = WebResponseContent.Instance.Error($"浠诲姟鎺ユ敹閿欒,閿欒淇℃伅:{ex.Message}"); + } + return content; + } + + /// <summary> + /// 楂樻俯鍑哄簱 + /// </summary> + /// <param name="taskDTO"></param> + /// <returns></returns> + public WebResponseContent ReceiveByWMSGWTask([NotNull] WMSTaskDTO taskDTO) + { + WebResponseContent content = new WebResponseContent(); + try + { + if (BaseDal.QueryFirst(x => x.TaskNum == taskDTO.TaskNum || x.PalletCode == taskDTO.PalletCode) != null) + { + return content.OK(); + } + Dt_Task task = _mapper.Map<Dt_Task>(taskDTO); + task.Creater = "WMS"; + + if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) + { + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.CurrentAddress = taskDTO.RoadWay; + task.NextAddress = "002-000-002"; + task.SourceAddress = taskDTO.SourceAddress; + task.TargetAddress = taskDTO.TargetAddress; + } BaseDal.AddData(task); _taskExecuteDetailService.AddTaskExecuteDetail(task.WMSId, "鎺ユ敹WMS浠诲姟"); @@ -179,7 +277,7 @@ } var wmsIpAddrss = wmsBase + requestTask; - var result = await HttpHelper.PostAsync(wmsIpAddrss, new { EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode }.ToJsonString()); + var result = await HttpHelper.PostAsync(wmsIpAddrss, new { EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode }.ToJsonString()); content = JsonConvert.DeserializeObject<WebResponseContent>(result); if (!content.Status) @@ -277,7 +375,7 @@ if (content.Status) { - task.TaskState = (int)TaskOutStatusEnum.OutFinish; + task.TaskState = 1; //浠诲姟瀹屾垚 BaseDal.DeleteData(task); } -- Gitblit v1.9.3