From 058ce925c640598340552fb045dcf43266ba44f6 Mon Sep 17 00:00:00 2001 From: "nodyang@aliyun.com" Date: Thu, 14 Nov 2024 17:51:30 +0800 Subject: [PATCH] fix --- RfidWeb/RfidWeb.csproj | 2 + RfidWeb/Tool/BaseManager.cs | 25 ++++++++++ RfidWeb/Tool/HimAlarmManager.cs | 77 +----------------------------- RfidWeb/Tool/PromptAlarmManager.cs | 55 +++++++++++++++++++++ Tool/Model/CacheKeyManager.cs | 25 ++++++++++ Tool/Model/HmiPoint.cs | 25 ---------- Tool/Tool.csproj | 1 + 7 files changed, 110 insertions(+), 100 deletions(-) create mode 100644 RfidWeb/Tool/BaseManager.cs create mode 100644 RfidWeb/Tool/PromptAlarmManager.cs create mode 100644 Tool/Model/CacheKeyManager.cs diff --git a/RfidWeb/RfidWeb.csproj b/RfidWeb/RfidWeb.csproj index de8df20..0d9b127 100644 --- a/RfidWeb/RfidWeb.csproj +++ b/RfidWeb/RfidWeb.csproj @@ -192,7 +192,9 @@ + + diff --git a/RfidWeb/Tool/BaseManager.cs b/RfidWeb/Tool/BaseManager.cs new file mode 100644 index 0000000..520879e --- /dev/null +++ b/RfidWeb/Tool/BaseManager.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using DB.Entity; +using DB.Service; +using NewLife.Caching; + +namespace RfidWeb +{ + public class BaseManager + { + protected AlarmDataService alarmDataService = new AlarmDataService(); + protected ICache cache = Cache.Default; + protected readonly int Max = 31; + protected readonly TimeSpan timeOut = TimeSpan.FromSeconds(5); + protected Dictionary GetDic(List list, string plcAb, string address) + { + var dicCha = list.Where(x => x.PlcAb == plcAb && x.Address == address + && !string.IsNullOrEmpty(x.Msg)) + .ToDictionary(x => x.No, x => x.Msg); + + return dicCha; + } + } +} \ No newline at end of file diff --git a/RfidWeb/Tool/HimAlarmManager.cs b/RfidWeb/Tool/HimAlarmManager.cs index c307fec..33a0d3f 100644 --- a/RfidWeb/Tool/HimAlarmManager.cs +++ b/RfidWeb/Tool/HimAlarmManager.cs @@ -9,25 +9,12 @@ using Tool.Model; namespace RfidWeb { - public class HimAlarmManager + public class HimAlarmManager:BaseManager { private HmiChAlarm hmiChAlarm = new HmiChAlarm(); private HmiCqAlarm hmiCq = new HmiCqAlarm(); EsStop esStop=new EsStop(); - AlarmDataService alarmDataService = new AlarmDataService(); - - private readonly int Max = 31; - private readonly TimeSpan timeOut = TimeSpan.FromSeconds(5); - - private Dictionary GetDic(List list, string plcAb, string address) - { - var dicCha = list.Where(x => x.PlcAb == plcAb && x.Address == address - && !string.IsNullOrEmpty(x.Msg)) - .ToDictionary(x => x.No, x => x.Msg); - - return dicCha; - } - + private void SetCH_alarm(Dictionary dictionary,List list) { var a = hmiChAlarm.GetPlcDb(); @@ -176,7 +163,6 @@ namespace RfidWeb } - ICache cache = Cache.Default; public Dictionary GetList() { @@ -194,63 +180,4 @@ namespace RfidWeb } - - public class PromptAlarmManager - { - - private Dictionary GetDic(List list, string plcAb, string address) - { - var dicCha = list.Where(x => x.PlcAb == plcAb && x.Address == address - && !string.IsNullOrEmpty(x.Msg)) - .ToDictionary(x => x.No, x => x.Msg); - - return dicCha; - } - - AlarmDataService alarmDataService = new AlarmDataService(); - PromptAlarm cPromptAlarm=new PromptAlarm(); - private readonly int Max = 31; - private readonly TimeSpan timeOut = TimeSpan.FromSeconds(5); - - ICache cache = Cache.Default; - public Dictionary GetList() - { - - - - Dictionary dictionary = cache[CacheKeyManager.Prompt_alarmList] as Dictionary - ?? new Dictionary(); - - List list = alarmDataService.GetList(); - - var listEs = GetDic(list, "", "Prompt_alarm"); - var bools = cPromptAlarm.GetDb(); - - - cache.Set(CacheKeyManager.Prompt_alarm, bools, timeOut); - - for (int i = 0; i < Max; i++) - { - var obj = bools[i]; - if (!listEs.TryGetValue(i, out var value)) continue; - if (Convert.ToBoolean(obj)) - { - if (!dictionary.ContainsKey(value)) - { - dictionary[value] = DateTime.Now; - } - } - else - { - dictionary.Remove(value); - } - } - - cache.Set(CacheKeyManager.Prompt_alarmList, dictionary, TimeSpan.FromMinutes(10)); - return dictionary; - } - - } - - // } \ No newline at end of file diff --git a/RfidWeb/Tool/PromptAlarmManager.cs b/RfidWeb/Tool/PromptAlarmManager.cs new file mode 100644 index 0000000..ce62c7b --- /dev/null +++ b/RfidWeb/Tool/PromptAlarmManager.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using DB.Entity; +using DB.Service; +using NewLife.Caching; +using Tool.Model; + +namespace RfidWeb +{ + public class PromptAlarmManager:BaseManager + { + + + + PromptAlarm cPromptAlarm=new PromptAlarm(); + + public Dictionary GetList() + { + + + + Dictionary dictionary = cache[CacheKeyManager.Prompt_alarmList] as Dictionary + ?? new Dictionary(); + + List list = alarmDataService.GetList(); + + var listEs = GetDic(list, "", "Prompt_alarm"); + var bools = cPromptAlarm.GetDb(); + + + cache.Set(CacheKeyManager.Prompt_alarm, bools, timeOut); + + for (int i = 0; i < Max; i++) + { + var obj = bools[i]; + if (!listEs.TryGetValue(i, out var value)) continue; + if (Convert.ToBoolean(obj)) + { + if (!dictionary.ContainsKey(value)) + { + dictionary[value] = DateTime.Now; + } + } + else + { + dictionary.Remove(value); + } + } + cache.Set(CacheKeyManager.Prompt_alarmList, dictionary, TimeSpan.FromMinutes(10)); + return dictionary; + } + + } +} \ No newline at end of file diff --git a/Tool/Model/CacheKeyManager.cs b/Tool/Model/CacheKeyManager.cs new file mode 100644 index 0000000..4a72748 --- /dev/null +++ b/Tool/Model/CacheKeyManager.cs @@ -0,0 +1,25 @@ +namespace Tool.Model +{ + public class CacheKeyManager + { + public static readonly string UpdateLog = "UpdateLog"; + + public static readonly string User = "HmiUser"; + + public static readonly string AesPwd = "nodyang"; + + public static readonly string AramlList = "AramlList"; + + public static readonly string AramlDataList = "AramlDataList"; + + public static readonly string CH_alarm = "CH_alarm"; + public static readonly string CQ_alarm = "CQ_alarm"; + public static readonly string estop_temporary_storage = "estop_temporary_storage"; + + public static readonly string Prompt_alarm = "Prompt_alarm"; + + public static readonly string Prompt_alarmList = "Prompt_alarmList"; + + + } +} \ No newline at end of file diff --git a/Tool/Model/HmiPoint.cs b/Tool/Model/HmiPoint.cs index 63f1bd9..1bd4083 100644 --- a/Tool/Model/HmiPoint.cs +++ b/Tool/Model/HmiPoint.cs @@ -54,29 +54,4 @@ namespace Tool.Model return ls.ToArray(); } } - - - - public class CacheKeyManager - { - public static readonly string UpdateLog = "UpdateLog"; - - public static readonly string User = "HmiUser"; - - public static readonly string AesPwd = "nodyang"; - - public static readonly string AramlList = "AramlList"; - - public static readonly string AramlDataList = "AramlDataList"; - - public static readonly string CH_alarm = "CH_alarm"; - public static readonly string CQ_alarm = "CQ_alarm"; - public static readonly string estop_temporary_storage = "estop_temporary_storage"; - - public static readonly string Prompt_alarm = "Prompt_alarm"; - - public static readonly string Prompt_alarmList = "Prompt_alarmList"; - - - } } diff --git a/Tool/Tool.csproj b/Tool/Tool.csproj index 3b70f63..ec0a1ba 100644 --- a/Tool/Tool.csproj +++ b/Tool/Tool.csproj @@ -68,6 +68,7 @@ +