查询所有子时序的工作时长与时序总时长进行对比,验证
This commit is contained in:
parent
eb6cf78500
commit
76864f1cb1
20
InSituLaboratory.Entities/SysEmu.cs
Normal file
20
InSituLaboratory.Entities/SysEmu.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InSituLaboratory.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 子时序号枚举
|
||||
/// </summary>
|
||||
public class SysEmu
|
||||
{
|
||||
[Key]
|
||||
public int ID { get; set; }
|
||||
|
||||
public int Number { get; set; }
|
||||
}
|
||||
}
|
||||
@ -31,5 +31,12 @@ namespace InSituLaboratory.IService
|
||||
/// <returns></returns>
|
||||
string GetDeviceByDeviceNameMinTime(string DeviceName);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取子时序号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerable<SysEmu> GetNum();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,6 +72,7 @@ namespace InSituLaboratory.ORM
|
||||
public virtual DbSet<SysSequential> SysSequential { get; set; }
|
||||
public virtual DbSet<SysSequentialDetails> SysSequentialDetails { get; set; }
|
||||
public virtual DbSet<SysDevice> SysDevice { get; set; }
|
||||
public virtual DbSet<SysEmu> SysEmu { get; set; }
|
||||
public virtual DbSet<SysSequentialTotal> SysSequentialTotal { get; set; }
|
||||
public virtual DbSet<CurrentFaultyEquipment> CurrentFaultyEquipment { get; set; }
|
||||
public virtual DbSet<CurrentWorkEquipment> CurrentWorkEquipment { get; set; }
|
||||
|
||||
@ -57,5 +57,11 @@ namespace InSituLaboratory.Service
|
||||
|
||||
return workTime;
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<SysEmu> GetNum()
|
||||
{
|
||||
return this.Set<SysEmu>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
||||
@ -26,6 +27,7 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
||||
/// 传感器设备集合
|
||||
/// </summary>
|
||||
public List<SysDevice> DeviceNodes { get; set; } = new List<SysDevice>();
|
||||
public List<SysEmu> SysNumberList { get; set; } = new List<SysEmu>();
|
||||
|
||||
public SysSequentialDetails SysSequentialdata { get; set; }
|
||||
|
||||
@ -46,12 +48,12 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
|
||||
public DateTime? startTime { get; set; }
|
||||
public DateTime startTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
public DateTime? endTime { get; set; }
|
||||
public DateTime endTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
@ -163,34 +165,34 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
||||
}
|
||||
|
||||
DeviceNodes = _deviceSvice.GetDevices().ToList();
|
||||
Intlist = new List<Int32>() { 1, 2, 3, 4, 5, 6 };
|
||||
//更换子时序号数据源
|
||||
SysNumberList = _deviceSvice.GetNum().ToList();
|
||||
}
|
||||
|
||||
public override void DoSave()
|
||||
{
|
||||
try
|
||||
{
|
||||
//非空校验
|
||||
#region 非空校验
|
||||
if (string.IsNullOrEmpty(SequenceGroup))
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("子时序号不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("子时序号不能为空");
|
||||
}
|
||||
else if (string.IsNullOrEmpty(SensorID))
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("设备编号不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("设备编号不能为空");
|
||||
}
|
||||
else if (WorkTime == null || WorkTime == 0)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("工作时长不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("工作时长不能为空");
|
||||
}
|
||||
else if (DurationTime == null || DurationTime == 0)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("循环间隔时长不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("循环间隔时长不能为空");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 传感器是否已存在校验 | 循环时长校验
|
||||
var data = _sequentialService.GetSequentials(kind).ToList();
|
||||
if (data.Count != 0)
|
||||
{
|
||||
@ -203,14 +205,13 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
||||
if (Device != SensorID)
|
||||
{
|
||||
//传感器是否已存在校验
|
||||
var selectFirst = _sequentialService.Query<SysSequentialDetails>(m => m.SensorID == SensorID && m.Sequential == kind && m.IsDelete == 0).ToList();
|
||||
var selectFirst = _sequentialService.Query<SysSequentialDetails>(m => m.Number == Number).ToList();
|
||||
if (selectFirst.Count != 0)
|
||||
{
|
||||
foreach (var item in selectFirst)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(kind + "- 子时序" + item.SequenceGroup + "中,已配置" + SensorID + "!!!" + " 请重新配置。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
System.Windows.Forms.MessageBox.Show(kind + "- 子时序" + selectFirst[0].SequenceGroup + "中,已配置" + SensorID + "!!!" + " 请重新配置。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -229,6 +230,7 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///循环时长校验
|
||||
if (data1.StartTime == startTime && data1.EndTime == endTime)
|
||||
{
|
||||
@ -243,8 +245,10 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 工作时长是否已超过传感器预设时间
|
||||
|
||||
///工作时长是否已超过传感器预设时间
|
||||
workTime = _deviceSvice.GetDeviceByDeviceName(SensorID);
|
||||
minworkTime = _deviceSvice.GetDeviceByDeviceNameMinTime(SensorID);
|
||||
if (workTime == "无")
|
||||
@ -257,74 +261,118 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
||||
}
|
||||
workInt = Convert.ToInt64(workTime); //设备预设最大工作时长
|
||||
minworkInt = Convert.ToInt64(minworkTime);//设备预设最小工作时长
|
||||
|
||||
switch (SensorID)
|
||||
{
|
||||
case "气相色谱仪":
|
||||
if (Convert.ToInt64(WorkTime) > workInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
else if (Convert.ToInt64(WorkTime) < minworkInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
break;
|
||||
case "质谱仪":
|
||||
if (Convert.ToInt64(WorkTime) > workInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
else if (Convert.ToInt64(WorkTime) < minworkInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
break;
|
||||
case "二氧化碳同位素分析仪":
|
||||
if (Convert.ToInt64(WorkTime) > workInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
else if (Convert.ToInt64(WorkTime) < minworkInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
break;
|
||||
case "甲烷传感器":
|
||||
if (Convert.ToInt64(WorkTime) > workInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + "超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
else if (Convert.ToInt64(WorkTime) < minworkInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
break;
|
||||
case "显微拉曼分析仪":
|
||||
if (Convert.ToInt64(WorkTime) < minworkInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
break;
|
||||
case "色质联用":
|
||||
if (Convert.ToInt64(WorkTime) < minworkInt)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
return;
|
||||
throw new Exception("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
///计算设备工作时长是否超过总时序时长
|
||||
System.TimeSpan t1 = endTime - startTime;
|
||||
float getMinute = (float)t1.TotalMinutes;
|
||||
|
||||
//根据开始时间、结束时间、是否删除查询母时序表
|
||||
//若存在记录,则根据母表ID去查询子表中所有子时序的工作时长与时序总时长进行对比
|
||||
var serID = 0;
|
||||
float? time = 0;
|
||||
var DataList = _sequentialService.Query<SysSequential>(m => m.StartTime == startTime && m.EndTime == endTime && m.IsDelete == 0 && m.Sequential == kind).ToList();
|
||||
if (DataList.Count() != 0)
|
||||
{
|
||||
foreach (var Data in DataList)
|
||||
{
|
||||
serID = Data.Number;
|
||||
}
|
||||
var data_child = _sequentialService.Query<SysSequentialDetails>(m => m.SysSquentialID == serID && m.IsDelete == 0).ToList();
|
||||
foreach (var Data in data_child)
|
||||
{
|
||||
time += Data.WorkTime;
|
||||
}
|
||||
//编辑情况下
|
||||
if (Number != 0)
|
||||
{
|
||||
var child = _sequentialService.Query<SysSequentialDetails>(m => m.Number == Number).ToList();
|
||||
if (WorkTime > child[0].WorkTime)
|
||||
{
|
||||
time = time - child[0].WorkTime;
|
||||
var total = time + WorkTime;
|
||||
if (total > getMinute)
|
||||
{
|
||||
throw new Exception("当前设置的传感器总工作时长" + "(" + total + "分钟" + ")" + " 已超过时序总时长!" + "(" + getMinute + "分钟" + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var total = time + WorkTime;
|
||||
if (total > getMinute)
|
||||
{
|
||||
throw new Exception("当前设置的传感器总工作时长" + "(" + total + "分钟" + ")" + " 已超过时序总时长!" + "(" + getMinute + "分钟" + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WorkTime > getMinute)
|
||||
{
|
||||
throw new Exception("当前设置的传感器总工作时长" + "(" + WorkTime + "分钟" + ")" + " 已超过时序总时长!" + "(" + getMinute + "分钟" + ")");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//保存时 首次去查询 data == null 说明数据库中无数据 为第一次插入
|
||||
if (data.Count() == 0)
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
<TextBlock Text="设备工作时长(min)" Grid.Row="2" VerticalAlignment="Center" Foreground="#888"/>
|
||||
<TextBlock Text="循环间隔时长(min)" Grid.Row="3" VerticalAlignment="Center" Foreground="#888"/>
|
||||
|
||||
<hc:ComboBox Grid.Row="0" Name="pb" Margin="0,9,0,8" Grid.Column="1" IsEditable="False" ItemsSource="{Binding Intlist}" SelectedValue="{Binding SequenceGroup}" RenderTransformOrigin="0.498,0.193"/>
|
||||
<hc:ComboBox Grid.Row="0" Name="pb" Margin="0,9,0,8" Grid.Column="1" IsEditable="False" ItemsSource="{Binding SysNumberList}" DisplayMemberPath="Number" SelectedValuePath="Number" SelectedValue="{Binding SequenceGroup}" RenderTransformOrigin="0.498,0.193"/>
|
||||
<hc:ComboBox Grid.Row="1" Margin="0,9,0,8" Grid.Column="1" IsEditable="False" ItemsSource="{Binding DeviceNodes}" DisplayMemberPath="DeviceName" SelectedValuePath="DeviceName" SelectedValue="{Binding SensorID}" RenderTransformOrigin="0.498,0.193"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="0,2" Height="30" Text="{Binding WorkTime}" Style="{StaticResource NormalTextBoxStyle}"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Margin="0,2" Height="30" Text="{Binding DurationTime}" Style="{StaticResource NormalTextBoxStyle}"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user