diff --git a/InSituLaboratory.Assets/Fonts/方正楷体简体.ttf b/InSituLaboratory.Assets/Fonts/方正楷体简体.ttf new file mode 100644 index 0000000..1ef7053 Binary files /dev/null and b/InSituLaboratory.Assets/Fonts/方正楷体简体.ttf differ diff --git a/InSituLaboratory.Assets/InSituLaboratory.Assets.csproj b/InSituLaboratory.Assets/InSituLaboratory.Assets.csproj index b7bb907..8c316db 100644 --- a/InSituLaboratory.Assets/InSituLaboratory.Assets.csproj +++ b/InSituLaboratory.Assets/InSituLaboratory.Assets.csproj @@ -9,6 +9,7 @@ + @@ -25,6 +26,9 @@ + + Always + Always diff --git a/InSituLaboratory.Entities/SysDevice.cs b/InSituLaboratory.Entities/SysDevice.cs index feba862..7eb9f63 100644 --- a/InSituLaboratory.Entities/SysDevice.cs +++ b/InSituLaboratory.Entities/SysDevice.cs @@ -28,6 +28,11 @@ namespace InSituLaboratory.Entities /// public string? DeviceName { get; set; } + /// + /// 工作时长 + /// + public string? WorkTime { get; set; } + } } diff --git a/InSituLaboratory.Entities/SysSequentialDetails.cs b/InSituLaboratory.Entities/SysSequentialDetails.cs index 6d08e98..ce0caf3 100644 --- a/InSituLaboratory.Entities/SysSequentialDetails.cs +++ b/InSituLaboratory.Entities/SysSequentialDetails.cs @@ -20,25 +20,35 @@ namespace InSituLaboratory.Entities [Key] public int Number { get; set; } + /// + /// 母表ID + /// + public int SysSquentialID { get; set; } + + /// + /// 配置号 + /// + + public string? SequenceGroup { get; set; } + /// /// 传感器ID /// public string? SensorID { get; set; } + /// + /// 工作时长 + /// + + public string? WorkTime { get; set; } + /// /// 循环时长 /// public string? DurationTime { get; set; } - - /// - /// 母表ID - /// - public int SysSquentialID { get; set; } - - - /// + ///// /// 创建时间 /// public DateTime? CreateTime { get; set; } diff --git a/InSituLaboratory.IService/IDeviceSvice.cs b/InSituLaboratory.IService/IDeviceSvice.cs index f583589..eb2a77b 100644 --- a/InSituLaboratory.IService/IDeviceSvice.cs +++ b/InSituLaboratory.IService/IDeviceSvice.cs @@ -14,5 +14,7 @@ namespace InSituLaboratory.IService /// /// IEnumerable GetDevices(); + + string GetDeviceByDeviceName(string DeviceName); } } diff --git a/InSituLaboratory.Service/DeviceService.cs b/InSituLaboratory.Service/DeviceService.cs index be26ffc..7366e69 100644 --- a/InSituLaboratory.Service/DeviceService.cs +++ b/InSituLaboratory.Service/DeviceService.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Text; using System.Threading.Tasks; @@ -18,5 +19,18 @@ namespace InSituLaboratory.Service { return this.Set(); } + + public string GetDeviceByDeviceName(string DeviceName) + { + var workTime = ""; + var sysDevice = this.Query(m=> m.DeviceName == DeviceName).ToList(); + + foreach (var item in sysDevice) + { + workTime = item.WorkTime; + } + + return workTime; + } } } diff --git a/InSituLaboratory/App.xaml b/InSituLaboratory/App.xaml index 440b235..5beddc0 100644 --- a/InSituLaboratory/App.xaml +++ b/InSituLaboratory/App.xaml @@ -18,6 +18,7 @@ /InSituLaboratory.Assets;component/Fonts/iconfont.ttf#zx_icons + /InSituLaboratory.Assets;component/Fonts/#方正楷体简体 diff --git a/InSituLaboratory/ViewModels/Pages/Dialogs/ModifySequentialViewModel.cs b/InSituLaboratory/ViewModels/Pages/Dialogs/ModifySequentialViewModel.cs index bec693a..fe70be7 100644 --- a/InSituLaboratory/ViewModels/Pages/Dialogs/ModifySequentialViewModel.cs +++ b/InSituLaboratory/ViewModels/Pages/Dialogs/ModifySequentialViewModel.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; +using System.Windows.Media.Animation; namespace InSituLaboratory.ViewModels.Pages.Dialogs { @@ -18,16 +19,199 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs /// public class ModifySequentialViewModel : DialogViewModelBase { + #region Model + /// + /// 传感器设备集合 + /// public List DeviceNodes { get; set; } = new List(); + public string? workTime { get; set; } + + public long? workInt { get; set; } + + /// + /// 开始时间 + /// + public DateTime? startTime { get; set; } + + /// + /// 结束时间 + /// public DateTime? endTime { get; set; } + /// + /// 配置 + /// + public string SequenceGroup { get; set; } + + /// + /// 序号 + /// public int Number { get; set; } - public string SensorID { get; set; } + + /// + /// 传感器设备 + /// + private string _sensorID; + + public string SensorID + { + get { return _sensorID;} + set + { + _sensorID = value; + //通过设备信息查询设备工作时长 + workTime = _deviceSvice.GetDeviceByDeviceName(_sensorID); + + this.ErrorList.Clear(); + if (_sensorID == "质谱仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(WorkTime) > workInt) + { + ErrorList.Add("WorkTime", new List { "质谱仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + else + { + ErrorList.Remove("WorkTime"); + this.RaiseErrorsChanged("WorkTime"); + } + } + else if (_sensorID == "二氧化碳同位素分析仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(WorkTime) > workInt) + { + ErrorList.Add("WorkTime", new List { "二氧化碳同位素分析仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + else + { + ErrorList.Remove("WorkTime"); + this.RaiseErrorsChanged("WorkTime"); + } + } + else if (_sensorID == "甲烷同位素分析仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(WorkTime) > workInt) + { + ErrorList.Add("WorkTime", new List { "甲烷同位素分析仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + } + else if (_sensorID == "气相色谱仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(WorkTime) > workInt) + { + ErrorList.Add("WorkTime", new List { "气相色谱仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + } + else if (_sensorID == "基因测序仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(WorkTime) > workInt) + { + ErrorList.Add("WorkTime", new List { "基因测序仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + } + else + { + ErrorList.Remove("WorkTime"); + this.RaiseErrorsChanged("WorkTime"); + } + + } + } + + + /// + /// 循环时长 + /// public string DurationTime { get; set; } + + /// + /// 时序类别 + /// public string kind { get; set; } + private string _workTime; + /// + /// 工作时长 + /// + + public string WorkTime + { + get { return _workTime; } + set + { + _workTime = value; + this.ErrorList.Clear(); + if (string.IsNullOrEmpty(value)) + { + ErrorList.Add("WorkTime", new List { "工作时长不能为空" }); + this.RaiseErrorsChanged(); + } + else if (_sensorID == "质谱仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(value) > workInt) + { + ErrorList.Add("WorkTime", new List { "质谱仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + } + else if (_sensorID == "二氧化碳同位素分析仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(value) > workInt) + { + ErrorList.Add("WorkTime", new List { "二氧化碳同位素分析仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + } + else if (_sensorID == "甲烷同位素分析仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(value) > workInt) + { + ErrorList.Add("WorkTime", new List { "甲烷同位素分析仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + } + else if (_sensorID == "气相色谱仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(value) > workInt) + { + ErrorList.Add("WorkTime", new List { "气相色谱仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + } + else if (_sensorID == "基因测序仪") + { + workInt = Convert.ToInt64(workTime) * 60 * 60; + if (Convert.ToInt64(value) > workInt) + { + ErrorList.Add("WorkTime", new List { "基因测序仪已超出最大工作时长" }); + this.RaiseErrorsChanged("WorkTime"); + } + } + else + { + ErrorList.Remove("WorkTime"); + this.RaiseErrorsChanged("WorkTime"); + } + } + } + + #endregion + ISysSequentialService _sequentialService; IDeviceSvice _deviceSvice; @@ -66,6 +250,8 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs { try { + if (this.HasErrors) return; + var data = _sequentialService.GetSequentials(kind).ToList(); //保存时 首次去查询 data == null 说明数据库中无数据 为第一次插入 if (data.Count() == 0) diff --git a/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs b/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs index ea2a709..6fc08bc 100644 --- a/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs +++ b/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs @@ -161,6 +161,8 @@ namespace InSituLaboratory.ViewModels.Pages sysSequentialDetail.Number = item.Number; sysSequentialDetail.DurationTime = item.DurationTime; sysSequentialDetail.SensorID = item.SensorID; + sysSequentialDetail.WorkTime = item.WorkTime; + sysSequentialDetail.SequenceGroup = item.SequenceGroup; sysSequentialDetail.CreateTime = item.CreateTime; sysSequentialDetail.Sequential = item.Sequential; sysSequentialDetail.SysSquentialID = item.SysSquentialID; diff --git a/InSituLaboratory/Views/LoginView.xaml b/InSituLaboratory/Views/LoginView.xaml index 428b91e..8c72f31 100644 --- a/InSituLaboratory/Views/LoginView.xaml +++ b/InSituLaboratory/Views/LoginView.xaml @@ -7,6 +7,7 @@ xmlns:b="clr-namespace:InSituLaboratory.Base" xmlns:c="clr-namespace:InSituLaboratory.Controls;assembly=InSituLaboratory.Controls" mc:Ignorable="d" + FontFamily="{StaticResource DigitalDisplay}" Height="400" Width="650">