From 67844d0b962e62d65e5c118d3251aeeeda50810f Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期日, 16 二月 2025 11:24:09 +0800 Subject: [PATCH] 1 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs | 150 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 146 insertions(+), 4 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 0c41a5d..c8dbbc8 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs @@ -13,6 +13,10 @@ using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob.Models; +using System.Drawing; +using WIDESEAWCS_ITaskInfoService; +using Mapster; +using AngleSharp.Io; namespace WIDESEAWCS_TaskInfoService { @@ -81,6 +85,48 @@ { return content.Error("褰撳墠鎵樼洏瀛樺湪浠诲姟"); } + var Station = await _stationManagerRepository.QueryFirstAsync(x => x.stationType == 6 && x.productLine == stationManager.productLine && x.stationArea == stationManager.stationArea); + var tasks= await BaseDal.QueryFirstAsync(x => x.TaskType == (int)TaskOutboundTypeEnum.InToOut && x.TargetAddress == stationManager.stationLocation && x.CurrentAddress == Station.stationChildCode); + if(tasks!=null) + { + ConsoleHelper.WriteErrorLine($"銆恵stationManager.stationChildCode}銆戝凡瀛樺湪鐩存帴鍑哄簱浠诲姟浠诲姟"); + return content.Error($"銆恵stationManager.stationChildCode}銆戝凡瀛樺湪鐩存帴鍑哄簱浠诲姟浠诲姟"); + } + if (stationManager.stationType == 7) + { + + var runTask = await BaseDal.QueryFirstAsync(x => x.CurrentAddress == Station.stationChildCode && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && x.TaskType == (int)TaskInboundTypeEnum.InTray); + if (runTask != null) + { + runTask.TargetAddress = stationManager.stationLocation; + runTask.NextAddress = stationManager.stationChildCode; + runTask.Grade = 3; + runTask.TaskType = (int)TaskOutboundTypeEnum.InToOut; + runTask.TaskState = (int)TaskOutStatusEnum.OutNew; + + var config1 = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); + var wmsBase1 = config1.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue; + var requestTask1 = config1.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.SetEmptyOutbyInToOutAsync)?.ConfigValue; + if (wmsBase1 == null || requestTask1 == null) + { + throw new InvalidOperationException("WMS IP 鏈厤缃�"); + } + var wmsIpAddrss1 = wmsBase1 + requestTask1; + + var result1 = await HttpHelper.PostAsync(wmsIpAddrss1, new { palletCode = runTask.PalletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = Station.stationChildCode }.ToJsonString()); + content = JsonConvert.DeserializeObject<WebResponseContent>(result1); + if (content.Status) + { + await BaseDal.UpdateDataAsync(runTask); + ConsoleHelper.WriteSuccessLine($"銆恵runTask.PalletCode}鐩存帴鍑哄簱鑷充簩灏併��"); + return content.OK("鎴愬姛"); + } + else + ConsoleHelper.WriteErrorLine(content.Message); + } + else + ConsoleHelper.WriteErrorLine($"銆恵Station.stationChildCode}銆戞湭鎵惧埌绌烘墭鐩樺叆搴撲换鍔�"); + } var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue; @@ -93,21 +139,75 @@ 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); - + ConsoleHelper.WriteErrorLine($"{stationManager.stationChildCode}绔欏彴璇锋眰鍝嶅簲淇℃伅:{content.ToJsonString()}"); 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 { Position = stationManager.stationChildCode }.ToJsonString()); + content = JsonConvert.DeserializeObject<WebResponseContent>(result); + if (!content.Status) + { + //鏃犳弧瓒虫潯浠跺彲鍑哄簱鑷冲寘瑁呯殑搴撳瓨 + return content; + } + + var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); + ConsoleHelper.WriteSuccessLine(content.Data.ToString()); + //_taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO })鈥� + content = ReceiveWMSTask(new List<WMSTaskDTO> { task }); + //content = ReceiveByBZOtuTask(task); + //if (content.Status) + //{ + // //鐩稿簲鐨勫湪閫旀暟鎹�+1 + // // _taskNeedBarcodeRepository.UpdateData(); + //} + return content; + } + catch (Exception ex) + { + + return content.Error(ex.Message); } } @@ -167,6 +267,46 @@ } return content; } + + /// <summary> + /// 鎺ユ敹WMS浠诲姟淇℃伅 + /// </summary> + /// <param name="taskDTOs">WMS浠诲姟瀵硅薄闆嗗悎</param> + /// <returns>杩斿洖澶勭悊缁撴灉</returns> + public WebResponseContent ReceiveByBZOtuTask([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) + { + var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay); + task.TaskState = (int)TaskOutStatusEnum.OutNew; + task.CurrentAddress = stationinfo.stationChildCode; + task.NextAddress = stationinfo.stationChildCode; + task.SourceAddress = taskDTO.SourceAddress; + 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> /// 楂樻俯鍑哄簱 @@ -245,7 +385,7 @@ } /// <summary> - /// 鏍规嵁鎵樼洏鍙峰拰璁惧鍙锋煡璇㈠叆搴撲换鍔� + /// 鏍规嵁鎵樼洏鍙峰拰璁惧鍙锋煡璇换鍔� /// </summary> /// <param name="taskNum">浠诲姟鍙�</param> /// <param name="currentAddress">褰撳墠鍦板潃</param> @@ -325,6 +465,8 @@ if (content.Status) { task.TaskState = 1; //浠诲姟瀹屾垚 + var taskHty = task.Adapt<Dt_Task_Hty>(); + _taskHtyRepository.AddData(taskHty); BaseDal.DeleteData(task); } -- Gitblit v1.9.3