From bebfcf25bea32eb6d61e1da608adf72e15b3665f Mon Sep 17 00:00:00 2001 From: hwh <332078369@qq.com> Date: 星期三, 28 八月 2024 13:24:32 +0800 Subject: [PATCH] Merge branch 'hwh' --- Admin.NET/WCS.Application/PLC/PLCService.cs | 50 +++++++++++++++++++------------------------------- 1 files changed, 19 insertions(+), 31 deletions(-) diff --git a/Admin.NET/WCS.Application/PLC/PLCService.cs b/Admin.NET/WCS.Application/PLC/PLCService.cs index cf5a94c..3b8b3f3 100644 --- a/Admin.NET/WCS.Application/PLC/PLCService.cs +++ b/Admin.NET/WCS.Application/PLC/PLCService.cs @@ -1,12 +1,19 @@ 锘� using Furion.Logging; using IoTClient; +using Microsoft.AspNetCore.SignalR; using System.Data; namespace WCS.Application; public static class PLCService { private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId); + private static readonly IHubContext<TaskLogHub, ITaskLogHub> _taskLogHubContext; + + static PLCService() + { + _taskLogHubContext = App.GetService<IHubContext<TaskLogHub, ITaskLogHub>>(); + } public static void OnChangeEvent(object sender, EventArgs e) { @@ -107,12 +114,8 @@ modTaskMonitor.InteractiveMsg = "璧峰鍌ㄤ綅涓虹┖!"; _db.Insertable(modTaskMonitor).ExecuteCommand(); - - // 閫氱煡浠诲姟鐣岄潰浠诲姟宸插瓨鍦ㄦ洿鏂� 璇锋洿鏂扮晫闈� - //if (TaskAction.refresh) - //{ - // wSChat.AlarmInformation("1"); - //} + //涓嬪彂浠诲姟鏃ュ織 + _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>()); break; } //缁橮LC鍐欏叆浠诲姟鏁版嵁 @@ -165,11 +168,8 @@ EndLocat = outStationNum, }; _db.Insertable(modInsertTaskMonitor).ExecuteCommand(); - // 閫氱煡浠诲姟鐣岄潰浠诲姟宸插瓨鍦ㄦ洿鏂� 璇锋洿鏂扮晫闈� - //if (TaskAction.refresh) - //{ - // wSChat.AlarmInformation("1"); - //} + //涓嬪彂浠诲姟鏃ュ織 + _taskLogHubContext.Clients.All.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>()); //淇敼led灞忎俊鎭� //LedDisplay(modDevice.LedIP, "宸ヤ綅:" + modTask.EndLocate, "鍑哄簱涓� " + $"鍌ㄤ綅鍦板潃锛歿modTask.StartLocate}", "鎵樼洏鍙�:" + modTask.PalletNo); } @@ -236,11 +236,8 @@ Status = TaskStatusEnum.Complete }; _db.Insertable(modTaskMonitor).ExecuteCommand(); - //閫氱煡浠诲姟鐣岄潰浠诲姟宸插瓨鍦ㄦ洿鏂� 璇锋洿鏂扮晫闈� - //if (TaskAction.refresh) - //{ - // wSChat.AlarmInformation("1"); - //} + //涓嬪彂浠诲姟鏃ュ織 + _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>()); } else if (modTask.TaskType.Value == TaskTypeEnum.Out) @@ -277,11 +274,8 @@ Status = TaskStatusEnum.Complete }; _db.Insertable(modTaskMonitor).ExecuteCommand(); - //閫氱煡浠诲姟鐣岄潰浠诲姟宸插瓨鍦ㄦ洿鏂� 璇锋洿鏂扮晫闈� - //if (TaskAction.refresh) - //{ - // wSChat.AlarmInformation("1"); - //} + //涓嬪彂浠诲姟鏃ュ織 + _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>()); } } break; @@ -344,11 +338,8 @@ Status = TaskStatusEnum.Complete }; _db.Insertable(modTaskMonitor).ExecuteCommand(); - // 閫氱煡浠诲姟鐣岄潰浠诲姟宸插瓨鍦ㄦ洿鏂� 璇锋洿鏂扮晫闈� - //if (TaskAction.refresh) - //{ - // wSChat.AlarmInformation("1"); - //} + //涓嬪彂浠诲姟鏃ュ織 + _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>()); } else { @@ -427,11 +418,8 @@ }; _db.Insertable(modTaskMonitor).ExecuteCommand(); - // 閫氱煡浠诲姟鐣岄潰浠诲姟宸插瓨鍦ㄦ洿鏂� 璇锋洿鏂扮晫闈� - //if (TaskAction.refresh) - //{ - // wSChat.AlarmInformation("1"); - //} + //涓嬪彂浠诲姟鏃ュ織 + _taskLogHubContext.Clients.All.PublicTaskMonitor(modTaskMonitor.Adapt<WcsTaskMonitorOutput>()); //todo:鍨涙満鍑哄簱涓嶇┖璺� } -- Gitblit v1.8.0