From b80a24f97815bf71ba8c557cf4ac2c92e5dbfabe Mon Sep 17 00:00:00 2001 From: hanqiangqiang <1364346467@qq.com> Date: Thu, 10 Aug 2023 16:18:48 +0800 Subject: [PATCH] =?UTF-8?q?[UI.Client]=20=E5=88=A0=E9=99=A4=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=9F=A5=E8=AF=A2=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD=20[RT.EquipmentLi?= =?UTF-8?q?brary]=201=E5=88=A0=E9=99=A4=E6=97=A7=E7=9A=84=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8A=9F=E8=83=BD=202=E9=87=8D=E5=86=99=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=9F=A5=E8=AF=A2=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Common/DeviceData/GasFlowSum.cs | 2 - .../HardwareUnits/GasFlow/GasFlowSqlHelp.cs | 172 ++++++++++++------ .../HardwareUnits/GasFlow/PMGsaFlow.cs | 74 +------- .../CenterViews/Modules/PM/PMProcessView.xaml | 33 +--- .../Modules/PM/PMProcessViewModel.cs | 154 +++++----------- 5 files changed, 168 insertions(+), 267 deletions(-) diff --git a/MECF.Framework.Common/Aitex/Core/Common/DeviceData/GasFlowSum.cs b/MECF.Framework.Common/Aitex/Core/Common/DeviceData/GasFlowSum.cs index f1d0f53..94884d1 100644 --- a/MECF.Framework.Common/Aitex/Core/Common/DeviceData/GasFlowSum.cs +++ b/MECF.Framework.Common/Aitex/Core/Common/DeviceData/GasFlowSum.cs @@ -30,7 +30,6 @@ namespace MECF.Framework.Common.Aitex.Core.Common.DeviceData set { _runVolume = value; - Volume = _runVolume + _ventVolume; InvokePropertyChanged(); } } @@ -46,7 +45,6 @@ namespace MECF.Framework.Common.Aitex.Core.Common.DeviceData set { _ventVolume = value; - Volume = _runVolume + _ventVolume; InvokePropertyChanged(); } } diff --git a/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/GasFlowSqlHelp.cs b/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/GasFlowSqlHelp.cs index 7abbb89..f019740 100644 --- a/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/GasFlowSqlHelp.cs +++ b/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/GasFlowSqlHelp.cs @@ -1,5 +1,7 @@ using Aitex.Core.RT.DBCore; +using MECF.Framework.Common.Aitex.Core.Common.DeviceData; using MECF.Framework.Common.DataCenter; +using MECF.Framework.Common.Equipment; using Sicentury.Core; using System; using System.Collections.Generic; @@ -15,64 +17,133 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow /// public class GasFlowSqlHelp { + + /// - /// 根据名称和时间段查询结果 + /// 查询当天的气体体积数据 /// - /// 模块名称 - /// - /// - /// + /// 拆分的天 + /// PM名称 + /// 显示列表对象 /// - public static double Query(string module, string name, DateTime start, DateTime end) + public static List GetDayGasFlowSum(DateRangeHelper daySlices, string moduleName, List gasFlowSumList) { - var daySlices = DateRangeHelper.SplitInToHours(new DateRangeHelper(start, end), 12); - string tableName = module; - string propertyCmd = "," + $"\"{module}.{name}.FeedBack\""; - string property = $"{module}.{name}.FeedBack"; + List dataTableList = GetAllGasListDaySlices(daySlices, moduleName, gasFlowSumList); - return GetData(GetDataSetList(daySlices, tableName, propertyCmd, property), property); - } - private static List GetDataSetList(IEnumerable daySlices, string tableName, string propertyCmd, string property) - { - List dataTableList = new List(); - foreach (var range in daySlices) + string rowStr; + + List GasFlowrRunVentList = new List(); + + foreach (var item in gasFlowSumList) { - var ts = range.Diff; - for (var day = 0; day <= ts.Days; day++) + GasFlowrRunVentList.Add(new GasFlowSum() { Name = $"{item.Name}_Run" }); + GasFlowrRunVentList.Add(new GasFlowSum() { Name = $"{item.Name}_Vent" }); + } + foreach (var table in dataTableList) { } + foreach (DataTable ds in dataTableList) + { + double timeDifference = 0; + for (int i = 0; i < ds.Rows.Count; i++) { - var tblName = $"{range.Start.AddDays(day):yyyyMMdd}.{tableName}"; - var sql = new StringBuilder(); - // 检查表名是否存在,否则SQL执行出错。 - if (CheckTableExists(tblName)) + foreach (var item in GasFlowrRunVentList) { - sql.Append("select time AS InternalTimeStamp"); - // 添加待查询的列 - sql.Append(propertyCmd); - sql.Append($", \"time\""); - sql.Append($" from \"{tblName}\""); - - if (day < ts.Days) - sql.Append(" UNION "); - sql.Append( - $" where time between {range.Start.Ticks} and {range.End.Ticks} and '{property}' is not NULL order by InternalTimeStamp asc"); - try - { - var dataSet = QueryDataClient.Instance.Service.QueryData(sql.ToString()); - if (dataSet is not null && dataSet.Rows.Count > 0) - dataTableList.Add(dataSet); - } - catch (Exception ex)//查询较早日期时,可能不存在属性会报错 + //$"{moduleName}.GasRealTimeFlow.{item.Name}_Run.FeedBack" + string property = $"{moduleName}.GasRealTimeFlow.{item.Name}.FeedBack"; + rowStr = ds.Rows[i][property].ToString(); + if (rowStr is not null && rowStr.Length == 0) + continue; + double bd = double.Parse(ds.Rows[i][property].ToString()); + if (bd > 0) { + if (i != ds.Rows.Count - 1)//最后一个数据使用的时间差,是它前一个计算得到的 + { + var startTime = new DateTime(long.Parse(ds.Rows[i]["time"].ToString())); + var endTime = new DateTime(long.Parse(ds.Rows[i + 1]["time"].ToString())); + timeDifference = (endTime - startTime).TotalSeconds; + } + item.Volume += bd * timeDifference; } } } } + return GasFlowrRunVentList; + } + + /// + /// 根据拆分的天循查询数据 + /// + /// 拆分的天 + /// PM名称 + /// 显示集合列表 + /// + private static List GetAllGasListDaySlices(DateRangeHelper daySlices, string moduleName, List gasFlowSumList) + { + List dataTableList = new List(); + var ts = daySlices.Diff; + for (var day = 0; day <= ts.Days; day++) + { + var tblName = $"{daySlices.Start.AddDays(day):yyyyMMdd}.{moduleName}"; + var sql = new StringBuilder(); + // 检查表名是否存在,否则SQL执行出错。 + if (CheckTableExists(tblName)) + { + sql.Append("select time AS InternalTimeStamp"); + // 添加待查询的列 + + // 添加待查询的列 + foreach (var item in gasFlowSumList) + { + sql.Append("," + $"\"{moduleName}.GasRealTimeFlow.{item.Name}_Run.FeedBack\""); + + sql.Append("," + $"\"{moduleName}.GasRealTimeFlow.{item.Name}_Vent.FeedBack\""); + } + + sql.Append($", \"time\""); + sql.Append($" from \"{tblName}\""); + + if (day < ts.Days) + sql.Append(" UNION "); + sql.Append( + $" where time between {daySlices.Start.Ticks} and {daySlices.End.Ticks} order by InternalTimeStamp asc"); + try + { + var dataSet = QueryDataClient.Instance.Service.QueryData(sql.ToString()); + if (dataSet is not null && dataSet.Rows.Count > 0) + dataTableList.Add(dataSet); + } + catch (Exception ex)//查询较早日期时,可能不存在属性会报错 + { + + } + + } + } + return dataTableList; } - public static List GetDataSetListDaySlices(DateRangeHelper daySlices, string tableName, string propertyCmd, string property) + private static bool CheckTableExists(string tableName) + { + var sql = + $"SELECT EXISTS ( SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = '{tableName}' )"; + var table = QueryDataClient.Instance.Service.QueryData(sql); + if (table == null) + return false; + + if (table.Rows.Count <= 0) + return false; + + var value = table.Rows[0]["exists"].ToString(); + if (value.ToLower() == "true") + return true; + + return false; + } + + + public static List GetDataSetDaySlices(DateRangeHelper daySlices, string tableName, string propertyCmd, string property) { List dataTableList = new List(); var ts = daySlices.Diff; @@ -109,6 +180,9 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow return dataTableList; } + + + public static double GetData(List dataTableList, string property) { double values = 0; @@ -138,22 +212,6 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow return values; } - private static bool CheckTableExists(string tableName) - { - var sql = - $"SELECT EXISTS ( SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = '{tableName}' )"; - var table = QueryDataClient.Instance.Service.QueryData(sql); - if (table == null) - return false; - - if (table.Rows.Count <= 0) - return false; - - var value = table.Rows[0]["exists"].ToString(); - if (value.ToLower() == "true") - return true; - - return false; - } + } } diff --git a/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/PMGsaFlow.cs b/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/PMGsaFlow.cs index 0fb6e6b..6d38ea8 100644 --- a/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/PMGsaFlow.cs +++ b/MECF.Framework.RT.EquipmentLibrary/HardwareUnits/GasFlow/PMGsaFlow.cs @@ -33,17 +33,12 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow DATA.Subscribe($"{ModuleName}.PMGasNameList", () => GasNameList); DATA.Subscribe($"{ModuleName}.PMGasFlowSumList", () => GasFlowSumList); - - OP.Subscribe($"{ModuleName}.GasFlowSum.Query", (string cmd, object[] args) => Query(args)); - - OP.Subscribe($"{ModuleName}.GasFlowSum.QueryAll", (string cmd, object[] args) => QueryAll(args)); - var _thread = new PeriodicJob(1000, OnTimer, $"{moduleName}.ModuleGsaFlow", true); } private bool OnTimer() { - foreach (var Unit in GasFlowUnitList) + foreach (GasFlowUnit Unit in GasFlowUnitList) { Unit.GetGasFlowFeedBack(); } @@ -62,7 +57,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow GasNameList = new() { "All" };//添加总的查询选项 - //单中气体初始化 + //单种气体初始化 foreach (var unit in GasFlowUnitList) { unit.Initialize(moduleName); @@ -79,70 +74,5 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow } } - - /// - /// 单种气体体积使用查询 - /// - /// - /// - private bool Query(object[] objects) - { - Task.Run(() => - { - string flowName = objects[0].ToString(); - start = Convert.ToDateTime(objects[1]); - end = Convert.ToDateTime(objects[2]); - - QueryRunVentVolume(flowName + "_Run"); - QueryRunVentVolume(flowName + "_Vent"); - - }); - return true; - } - /// - /// 所有气体使用体积查询 - /// - /// - /// - private bool QueryAll(object[] objects) - { - Task.Run(() => - { - start = Convert.ToDateTime(objects[0]); - end = Convert.ToDateTime(objects[1]); - - foreach (var item in GasFlowSumList) - { - QueryRunVentVolume(item.Name + "_Run"); - QueryRunVentVolume(item.Name + "_Vent"); - } - - }); - return true; - } - private void QueryRunVentVolume(string flowName) - { - Task.Run(() => - { - double values = GasFlowSqlHelp.Query(ModuleName, "GasRealTimeFlow." + flowName, start, end); - foreach (var item in GasFlowSumList) - { - if (flowName.Contains(item.Name)) - { - if (flowName.Contains("Run")) - item.RunVolume = values * 1.66667 * Math.Pow(10, -7); - else - item.VentVolume = values * 1.66667 * Math.Pow(10, -7); - return; - } - } - }); - - } - - - - - } } diff --git a/MECF.Framework.UI.Client/CenterViews/Modules/PM/PMProcessView.xaml b/MECF.Framework.UI.Client/CenterViews/Modules/PM/PMProcessView.xaml index 7ac35e3..ce79280 100644 --- a/MECF.Framework.UI.Client/CenterViews/Modules/PM/PMProcessView.xaml +++ b/MECF.Framework.UI.Client/CenterViews/Modules/PM/PMProcessView.xaml @@ -2000,20 +2000,18 @@ - + - - - + - - + +