From 223a7b9cdb5db711ac644bcfdbbbc7c4d2b7f344 Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期四, 26 十二月 2024 13:58:24 +0800 Subject: [PATCH] 优化代码结构和增强功能 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 51 ++++++++++++--------------------------------------- 1 files changed, 12 insertions(+), 39 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs index beee08f..433a120 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs @@ -101,7 +101,7 @@ // 杈撳嚭璀﹀憡淇℃伅 ConsoleHelper.WriteWarningLine($"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戠┖鎵樼洏璇锋眰鎵爜鍏ュ簱"); // 澶勭悊鍏ュ簱璇锋眰 - NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation); + NGRequestTaskInbound(conveyorLine, command, station, 0); } else { @@ -162,26 +162,12 @@ #region 璋冪敤浜嬩欢鎬荤嚎閫氱煡鍓嶇 // 鑾峰彇缂撳瓨涓殑鐢ㄦ埛淇℃伅 - if (userTokenIds == null && userIds == null) + var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); + if (tokenInfos != null && tokenInfos.Any()) { - var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); - if (tokenInfos != null && tokenInfos.Any()) - { - userTokenIds = tokenInfos.Select(x => x.Token_ID).ToList(); - userIds = tokenInfos.Select(x => x.UserId).ToList(); + userTokenIds = tokenInfos.Select(x => x.Token_ID).ToList(); + userIds = tokenInfos.Select(x => x.UserId).ToList(); - // 鏋勯�犻�氱煡鏁版嵁 - object obj = new - { - command, - commandWrite - }; - // 鍙戦�侀�氱煡 - _noticeService.LineData(userIds.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, childDeviceCode, data = obj }); - } - } - else - { // 鏋勯�犻�氱煡鏁版嵁 object obj = new { @@ -726,7 +712,7 @@ #region 璁惧NG鍙e叆搴� - public void NGRequestTaskInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue, string TargetAddress) + public void NGRequestTaskInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManager stationManager, int ProtocalDetailValue) { var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.MOMIP_BASE)?.ConfigValue; @@ -735,7 +721,6 @@ { throw new InvalidOperationException("MOM IP 鏈厤缃�"); } - Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode); TrayCellsStatusDto trayCells = new TrayCellsStatusDto() { Software = "WMS", @@ -750,9 +735,9 @@ var MOMIpAddress = wmsBase + ipAddress; var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.ToJsonString()).Result; - WriteInfo("鍏ョ珯鏍¢獙", $"銆恵childDeviceCode}銆戝叆绔欐牎楠岃姹傚弬鏁般�恵trayCells.ToJsonString()}銆�"); + WriteInfo("鍏ョ珯鏍¢獙", $"銆恵stationManager.stationChildCode}銆戝叆绔欐牎楠岃姹傚弬鏁般�恵trayCells.ToJsonString()}銆�"); WriteInfo("鍏ョ珯鏍¢獙", ""); - WriteInfo("鍏ョ珯鏍¢獙", $"銆恵childDeviceCode}銆戝叆绔欐牎楠岃繑鍥炲弬鏁般�恵result}銆�"); + WriteInfo("鍏ョ珯鏍¢獙", $"銆恵stationManager.stationChildCode}銆戝叆绔欐牎楠岃繑鍥炲弬鏁般�恵result}銆�"); ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result); if (result1.Success) @@ -765,28 +750,16 @@ if (result1.SerialNos.Count <= 0) { - // 绌烘墭鐩樺叆搴撻�昏緫 - Dt_Task dt_Task = new Dt_Task() - { - TargetAddress = TargetAddress, - PalletCode = command.Barcode, - NextAddress = TargetAddress, - TaskNum = 0 - }; - var next = dt_Task.NextAddress; - var taskCommand = MapTaskCommand(dt_Task, command); - dt_Task.NextAddress = next; + conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, stationManager.stationLocation, stationManager.stationChildCode); - conveyorLine.SendCommand(taskCommand, childDeviceCode); - - ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); + ConveyorLineSendFinish(conveyorLine, stationManager.stationChildCode, ProtocalDetailValue, true); } else { - conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, 1000, childDeviceCode); + conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, 1000, stationManager.stationChildCode); - ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); + ConveyorLineSendFinish(conveyorLine, stationManager.stationChildCode, ProtocalDetailValue, true); } } else -- Gitblit v1.9.3