2024-04-09 08:17:44 +00:00
|
|
|
|
using InSituLaboratory.Entities;
|
|
|
|
|
|
using InSituLaboratory.IService;
|
|
|
|
|
|
using InSituLaboratory.Models;
|
|
|
|
|
|
using InSituLaboratory.Service;
|
2024-04-12 09:47:43 +00:00
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
2024-04-09 08:17:44 +00:00
|
|
|
|
using Microsoft.VisualBasic.ApplicationServices;
|
2024-03-27 13:49:16 +00:00
|
|
|
|
using Prism.Services.Dialogs;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2024-04-09 08:17:44 +00:00
|
|
|
|
using System.Windows;
|
2024-04-12 09:47:43 +00:00
|
|
|
|
using System.Windows.Forms;
|
2024-04-10 09:50:54 +00:00
|
|
|
|
using System.Windows.Media.Animation;
|
2024-03-27 13:49:16 +00:00
|
|
|
|
|
|
|
|
|
|
namespace InSituLaboratory.ViewModels.Pages.Dialogs
|
|
|
|
|
|
{
|
2024-04-09 08:17:44 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 新增或者增加时序
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class ModifySequentialViewModel : DialogViewModelBase
|
2024-03-27 13:49:16 +00:00
|
|
|
|
{
|
2024-04-10 09:50:54 +00:00
|
|
|
|
#region Model
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 传感器设备集合
|
|
|
|
|
|
/// </summary>
|
2024-04-09 08:17:44 +00:00
|
|
|
|
public List<SysDevice> DeviceNodes { get; set; } = new List<SysDevice>();
|
|
|
|
|
|
|
2024-04-12 09:47:43 +00:00
|
|
|
|
public SysSequentialDetails SysSequentialdata { get; set; }
|
2024-04-11 09:49:43 +00:00
|
|
|
|
|
2024-08-22 08:01:33 +00:00
|
|
|
|
public List<Int32> Intlist { get; set; } = new List<Int32>() { 1, 2, 3, 4, 5, 6 };
|
|
|
|
|
|
|
2024-04-10 09:50:54 +00:00
|
|
|
|
public string? workTime { get; set; }
|
2024-06-28 09:51:00 +00:00
|
|
|
|
public string? minworkTime { get; set; }
|
2024-04-10 09:50:54 +00:00
|
|
|
|
|
|
|
|
|
|
public long? workInt { get; set; }
|
2024-06-28 09:51:00 +00:00
|
|
|
|
public long? minworkInt { get; set; }
|
2024-04-15 10:06:19 +00:00
|
|
|
|
|
2024-04-13 03:38:55 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 记录编辑时第一次带入的设备名称
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Device { get; set; }
|
2024-04-10 09:50:54 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 开始时间
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
public DateTime? startTime { get; set; }
|
2024-04-10 09:50:54 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 结束时间
|
|
|
|
|
|
/// </summary>
|
2024-04-09 08:17:44 +00:00
|
|
|
|
public DateTime? endTime { get; set; }
|
|
|
|
|
|
|
2024-04-12 05:30:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 序号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int Number { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 时序类别
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string kind { get; set; }
|
|
|
|
|
|
|
2024-04-15 10:06:19 +00:00
|
|
|
|
|
2024-04-12 09:47:43 +00:00
|
|
|
|
private string _sequenceGroup;
|
|
|
|
|
|
|
2024-04-10 09:50:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 配置
|
|
|
|
|
|
/// </summary>
|
2024-04-11 09:49:43 +00:00
|
|
|
|
public string SequenceGroup
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _sequenceGroup; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
_sequenceGroup = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-04-12 09:47:43 +00:00
|
|
|
|
private string? _sensorID;
|
2024-04-10 09:50:54 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 传感器设备
|
|
|
|
|
|
/// </summary>
|
2024-04-12 09:47:43 +00:00
|
|
|
|
public string? SensorID
|
2024-04-10 09:50:54 +00:00
|
|
|
|
{
|
2024-04-11 09:49:43 +00:00
|
|
|
|
get { return _sensorID; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2024-04-10 09:50:54 +00:00
|
|
|
|
_sensorID = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
|
2024-06-28 09:51:00 +00:00
|
|
|
|
private float? _workTime;
|
2024-04-10 09:50:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 工作时长
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
2024-06-28 09:51:00 +00:00
|
|
|
|
public float? WorkTime
|
2024-04-10 09:50:54 +00:00
|
|
|
|
{
|
|
|
|
|
|
get { return _workTime; }
|
2024-04-11 09:49:43 +00:00
|
|
|
|
set
|
2024-04-10 09:50:54 +00:00
|
|
|
|
{
|
|
|
|
|
|
_workTime = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-15 10:06:19 +00:00
|
|
|
|
|
2024-06-28 09:51:00 +00:00
|
|
|
|
private float? _durationTime;
|
2024-04-12 09:47:43 +00:00
|
|
|
|
|
2024-04-12 05:30:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 循环时长
|
|
|
|
|
|
/// </summary>
|
2024-06-28 09:51:00 +00:00
|
|
|
|
public float? DurationTime
|
2024-04-12 05:30:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
get { return _durationTime; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
_durationTime = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-19 02:19:37 +00:00
|
|
|
|
private string totalKind;
|
|
|
|
|
|
|
2024-04-10 09:50:54 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
ISysSequentialService _sequentialService;
|
|
|
|
|
|
IDeviceSvice _deviceSvice;
|
|
|
|
|
|
|
|
|
|
|
|
public ModifySequentialViewModel(ISysSequentialService sequentialService, IDeviceSvice deviceSvice)
|
2024-03-27 13:49:16 +00:00
|
|
|
|
{
|
2024-04-09 08:17:44 +00:00
|
|
|
|
_sequentialService = sequentialService;
|
|
|
|
|
|
_deviceSvice = deviceSvice;
|
2024-04-12 09:47:43 +00:00
|
|
|
|
|
2024-03-27 13:49:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnDialogOpened(IDialogParameters parameters)
|
|
|
|
|
|
{
|
2024-04-09 08:17:44 +00:00
|
|
|
|
var SequentialDetail = parameters.GetValue<SysSequentialDetails>("model");
|
|
|
|
|
|
startTime = parameters.GetValue<DateTime>("sequentialStartTime");
|
|
|
|
|
|
endTime = parameters.GetValue<DateTime>("sequentialEndTime");
|
|
|
|
|
|
kind = parameters.GetValue<string>("kind");
|
2024-04-11 09:49:43 +00:00
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
|
2024-06-19 02:19:37 +00:00
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
if (SequentialDetail == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Title = "新增时序配置";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Title = "编辑时序配置";
|
|
|
|
|
|
var su = _sequentialService.Find<SysSequentialDetails>(SequentialDetail.Number);
|
|
|
|
|
|
Number = su.Number;
|
2024-04-12 09:47:43 +00:00
|
|
|
|
SequenceGroup = su.SequenceGroup;
|
2024-04-09 08:17:44 +00:00
|
|
|
|
SensorID = su.SensorID;
|
2024-04-11 09:49:43 +00:00
|
|
|
|
WorkTime = su.WorkTime;
|
2024-04-09 08:17:44 +00:00
|
|
|
|
DurationTime = su.DurationTime;
|
2024-04-13 03:38:55 +00:00
|
|
|
|
Device = SensorID;
|
2024-04-09 08:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DeviceNodes = _deviceSvice.GetDevices().ToList();
|
2024-03-27 13:49:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void DoSave()
|
|
|
|
|
|
{
|
2024-04-09 08:17:44 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2024-04-12 09:47:43 +00:00
|
|
|
|
//非空校验
|
|
|
|
|
|
if (string.IsNullOrEmpty(SequenceGroup))
|
|
|
|
|
|
{
|
2024-07-01 10:12:44 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show("子时序号不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (string.IsNullOrEmpty(SensorID))
|
|
|
|
|
|
{
|
2024-07-01 10:12:44 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show("设备编号不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-06-28 09:51:00 +00:00
|
|
|
|
else if (WorkTime == null || WorkTime == 0)
|
2024-04-12 09:47:43 +00:00
|
|
|
|
{
|
2024-06-17 10:12:16 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show("工作时长不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-06-28 09:51:00 +00:00
|
|
|
|
else if (DurationTime == null || DurationTime == 0)
|
2024-04-12 09:47:43 +00:00
|
|
|
|
{
|
2024-07-01 10:12:44 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show("循环间隔时长不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-04-15 10:06:19 +00:00
|
|
|
|
var data = _sequentialService.GetSequentials(kind).ToList();
|
|
|
|
|
|
if (data.Count != 0)
|
2024-04-12 09:47:43 +00:00
|
|
|
|
{
|
2024-04-15 10:06:19 +00:00
|
|
|
|
var data1 = _sequentialService.GetSequentials(kind).First();
|
|
|
|
|
|
if (data1.StartTime == startTime && data1.EndTime == endTime)
|
2024-04-13 03:38:55 +00:00
|
|
|
|
{
|
2024-04-15 10:06:19 +00:00
|
|
|
|
//编辑情况下
|
|
|
|
|
|
if (Number != 0)
|
2024-04-13 03:38:55 +00:00
|
|
|
|
{
|
2024-04-15 10:06:19 +00:00
|
|
|
|
if (Device != SensorID)
|
|
|
|
|
|
{
|
|
|
|
|
|
//传感器是否已存在校验
|
2024-06-17 10:12:16 +00:00
|
|
|
|
var selectFirst = _sequentialService.Query<SysSequentialDetails>(m => m.SensorID == SensorID && m.Sequential == kind && m.IsDelete == 0).ToList();
|
2024-04-15 10:06:19 +00:00
|
|
|
|
if (selectFirst.Count != 0)
|
|
|
|
|
|
{
|
2024-06-17 10:12:16 +00:00
|
|
|
|
foreach (var item in selectFirst)
|
|
|
|
|
|
{
|
2024-07-01 10:12:44 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show(kind + "- 子时序" + item.SequenceGroup + "中,已配置" + SensorID + "!!!" + " 请重新配置。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
2024-06-17 10:12:16 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-04-15 10:06:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//传感器是否已存在校验
|
2024-06-17 10:12:16 +00:00
|
|
|
|
var select = _sequentialService.Query<SysSequentialDetails>(m => m.SensorID == SensorID && m.Sequential == kind && m.IsDelete == 0).ToList();
|
2024-04-15 10:06:19 +00:00
|
|
|
|
if (select.Count != 0)
|
|
|
|
|
|
{
|
2024-06-17 10:12:16 +00:00
|
|
|
|
foreach (var item in select)
|
|
|
|
|
|
{
|
2024-07-01 10:12:44 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show(kind + "- 子时序" + item.SequenceGroup + "中,已配置" + SensorID + "!!!" + " 请重新配置。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
2024-06-17 10:12:16 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-04-15 10:06:19 +00:00
|
|
|
|
}
|
2024-04-13 03:38:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-04-15 10:06:19 +00:00
|
|
|
|
|
|
|
|
|
|
///循环时长校验
|
|
|
|
|
|
if (data1.StartTime == startTime && data1.EndTime == endTime)
|
2024-04-13 03:38:55 +00:00
|
|
|
|
{
|
2024-04-15 10:06:19 +00:00
|
|
|
|
var SysSequentialdata1 = _sequentialService.GetSequentialSequenceGroup(SequenceGroup, kind, data1.Number);
|
|
|
|
|
|
if (SysSequentialdata1 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (DurationTime != SysSequentialdata1.DurationTime)
|
|
|
|
|
|
{
|
2024-07-01 10:12:44 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show(kind + "- 子时序" + SequenceGroup + " 已存在循环时长:" + SysSequentialdata1.DurationTime + "分钟" + ",无法修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-15 10:06:19 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-04-13 03:38:55 +00:00
|
|
|
|
}
|
2024-04-12 09:47:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///工作时长是否已超过传感器预设时间
|
|
|
|
|
|
workTime = _deviceSvice.GetDeviceByDeviceName(SensorID);
|
2024-06-28 09:51:00 +00:00
|
|
|
|
minworkTime = _deviceSvice.GetDeviceByDeviceNameMinTime(SensorID);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
if (workTime == "无")
|
2024-04-11 09:49:43 +00:00
|
|
|
|
{
|
2024-04-12 09:47:43 +00:00
|
|
|
|
workTime = "0";
|
|
|
|
|
|
}
|
2024-06-28 09:51:00 +00:00
|
|
|
|
if (minworkTime == "无")
|
|
|
|
|
|
{
|
|
|
|
|
|
minworkTime = "0";
|
|
|
|
|
|
}
|
|
|
|
|
|
workInt = Convert.ToInt64(workTime); //设备预设最大工作时长
|
|
|
|
|
|
minworkInt = Convert.ToInt64(minworkTime);//设备预设最小工作时长
|
2024-04-12 09:47:43 +00:00
|
|
|
|
switch (SensorID)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "气相色谱仪":
|
|
|
|
|
|
if (Convert.ToInt64(WorkTime) > workInt)
|
|
|
|
|
|
{
|
2024-06-28 09:51:00 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (Convert.ToInt64(WorkTime) < minworkInt)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "质谱仪":
|
|
|
|
|
|
if (Convert.ToInt64(WorkTime) > workInt)
|
|
|
|
|
|
{
|
2024-06-28 09:51:00 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (Convert.ToInt64(WorkTime) < minworkInt)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "二氧化碳同位素分析仪":
|
|
|
|
|
|
if (Convert.ToInt64(WorkTime) > workInt)
|
|
|
|
|
|
{
|
2024-06-28 09:51:00 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",已超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (Convert.ToInt64(WorkTime) < minworkInt)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2024-06-28 09:51:00 +00:00
|
|
|
|
case "甲烷传感器":
|
2024-04-12 09:47:43 +00:00
|
|
|
|
if (Convert.ToInt64(WorkTime) > workInt)
|
|
|
|
|
|
{
|
2024-06-28 09:51:00 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + "超过设备最大工作时长:" + workTime + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (Convert.ToInt64(WorkTime) < minworkInt)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "显微拉曼分析仪":
|
|
|
|
|
|
if (Convert.ToInt64(WorkTime) < minworkInt)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "色质联用":
|
|
|
|
|
|
if (Convert.ToInt64(WorkTime) < minworkInt)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Windows.Forms.MessageBox.Show("您填写的" + SensorID + "设置的工作时长:" + WorkTime + "分钟" + ",未能达到设备最小工作时长:" + minworkInt + "分钟" + "\n 请修改您填写的设备工作时长后重试!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-12 09:47:43 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2024-06-17 10:12:16 +00:00
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
//保存时 首次去查询 data == null 说明数据库中无数据 为第一次插入
|
|
|
|
|
|
if (data.Count() == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
_sequentialService.Insert(new SysSequential
|
|
|
|
|
|
{
|
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
|
EndTime = endTime,
|
|
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
|
Sequential = kind,
|
2024-06-17 10:12:16 +00:00
|
|
|
|
Status = "已生成未下发",
|
2024-04-09 08:17:44 +00:00
|
|
|
|
IsDelete = 0
|
|
|
|
|
|
});
|
|
|
|
|
|
var Squential = _sequentialService.Query<SysSequential>(m => m.Sequential == kind).OrderByDescending(n => n.CreateTime).First();
|
|
|
|
|
|
_sequentialService.Insert(new SysSequentialDetails
|
|
|
|
|
|
{
|
|
|
|
|
|
SysSquentialID = Squential.Number,
|
|
|
|
|
|
SensorID = SensorID,
|
|
|
|
|
|
DurationTime = DurationTime,
|
2024-04-11 09:49:43 +00:00
|
|
|
|
WorkTime = WorkTime,
|
|
|
|
|
|
SequenceGroup = SequenceGroup,
|
2024-04-09 08:17:44 +00:00
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
|
Sequential = kind,
|
|
|
|
|
|
IsDelete = 0
|
|
|
|
|
|
});
|
2024-04-15 10:06:19 +00:00
|
|
|
|
|
|
|
|
|
|
//向时序总表中插入相应的数据
|
|
|
|
|
|
_sequentialService.Insert(new SysSequentialTotal
|
|
|
|
|
|
{
|
|
|
|
|
|
Sequential = kind,
|
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
|
EndTime = endTime,
|
|
|
|
|
|
SensorID = SensorID,
|
|
|
|
|
|
DurationTime = DurationTime,
|
|
|
|
|
|
WorkTime = WorkTime,
|
|
|
|
|
|
SequenceGroup = SequenceGroup,
|
|
|
|
|
|
CreateTime = DateTime.Now,
|
2024-06-17 10:12:16 +00:00
|
|
|
|
Status = "已生成未下发",
|
2024-04-15 10:06:19 +00:00
|
|
|
|
IsDelete = 0
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
//判断查询的当前时序开始和结束时间与打开的窗口传值是否有变化
|
|
|
|
|
|
//无变化说明是在当前时序下新增传感器运行时间配置
|
|
|
|
|
|
var data1 = _sequentialService.GetSequentials(kind).First();
|
|
|
|
|
|
if (data1.StartTime == startTime && data1.EndTime == endTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
//新增传感器配置
|
|
|
|
|
|
if (Number == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
_sequentialService.Insert(new SysSequentialDetails
|
|
|
|
|
|
{
|
|
|
|
|
|
SysSquentialID = data1.Number,
|
|
|
|
|
|
SensorID = SensorID,
|
|
|
|
|
|
DurationTime = DurationTime,
|
2024-04-12 09:47:43 +00:00
|
|
|
|
WorkTime = WorkTime,
|
|
|
|
|
|
SequenceGroup = SequenceGroup,
|
2024-04-09 08:17:44 +00:00
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
|
Sequential = kind,
|
|
|
|
|
|
IsDelete = 0
|
|
|
|
|
|
});
|
2024-04-15 10:06:19 +00:00
|
|
|
|
|
|
|
|
|
|
//向时序总表中插入相应的数据
|
|
|
|
|
|
_sequentialService.Insert(new SysSequentialTotal
|
|
|
|
|
|
{
|
|
|
|
|
|
Sequential = kind,
|
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
|
EndTime = endTime,
|
|
|
|
|
|
SensorID = SensorID,
|
|
|
|
|
|
DurationTime = DurationTime,
|
|
|
|
|
|
WorkTime = WorkTime,
|
|
|
|
|
|
SequenceGroup = SequenceGroup,
|
|
|
|
|
|
CreateTime = DateTime.Now,
|
2024-06-17 10:12:16 +00:00
|
|
|
|
Status = "已生成未下发",
|
2024-04-15 10:06:19 +00:00
|
|
|
|
IsDelete = 0
|
|
|
|
|
|
});
|
2024-04-09 08:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//修改传感器配置
|
|
|
|
|
|
var ssd = _sequentialService.Find<SysSequentialDetails>(Number);
|
|
|
|
|
|
ssd.SensorID = SensorID;
|
|
|
|
|
|
ssd.DurationTime = DurationTime;
|
2024-04-11 09:49:43 +00:00
|
|
|
|
ssd.WorkTime = WorkTime;
|
|
|
|
|
|
ssd.SequenceGroup = SequenceGroup;
|
2024-04-09 08:17:44 +00:00
|
|
|
|
_sequentialService.Update(ssd);
|
2024-04-15 10:06:19 +00:00
|
|
|
|
|
|
|
|
|
|
//修改时序总表中的相应的数据
|
|
|
|
|
|
var ssm = _sequentialService.Find<SysSequentialTotal>(Number);
|
|
|
|
|
|
ssm.SensorID = SensorID;
|
|
|
|
|
|
ssm.DurationTime = DurationTime;
|
|
|
|
|
|
ssm.WorkTime = WorkTime;
|
|
|
|
|
|
ssm.SequenceGroup = SequenceGroup;
|
|
|
|
|
|
_sequentialService.Update(ssd);
|
|
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//新的时序
|
|
|
|
|
|
_sequentialService.Insert(new SysSequential
|
|
|
|
|
|
{
|
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
|
EndTime = endTime,
|
|
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
|
Sequential = kind,
|
2024-06-17 10:12:16 +00:00
|
|
|
|
Status = "已生成未下发",
|
2024-04-09 08:17:44 +00:00
|
|
|
|
IsDelete = 0
|
|
|
|
|
|
});
|
|
|
|
|
|
var Squential = _sequentialService.Query<SysSequential>(m => m.Sequential == kind).OrderByDescending(n => n.CreateTime).First();
|
|
|
|
|
|
_sequentialService.Insert(new SysSequentialDetails
|
|
|
|
|
|
{
|
|
|
|
|
|
SysSquentialID = Squential.Number,
|
|
|
|
|
|
SensorID = SensorID,
|
|
|
|
|
|
DurationTime = DurationTime,
|
2024-04-11 09:49:43 +00:00
|
|
|
|
WorkTime = WorkTime,
|
|
|
|
|
|
SequenceGroup = SequenceGroup,
|
2024-04-09 08:17:44 +00:00
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
|
Sequential = kind,
|
|
|
|
|
|
IsDelete = 0
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-04-15 10:06:19 +00:00
|
|
|
|
|
|
|
|
|
|
//向时序总表中插入相应的数据
|
|
|
|
|
|
_sequentialService.Insert(new SysSequentialTotal
|
|
|
|
|
|
{
|
|
|
|
|
|
Sequential = kind,
|
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
|
EndTime = endTime,
|
|
|
|
|
|
SensorID = SensorID,
|
|
|
|
|
|
DurationTime = DurationTime,
|
|
|
|
|
|
WorkTime = WorkTime,
|
|
|
|
|
|
SequenceGroup = SequenceGroup,
|
|
|
|
|
|
CreateTime = DateTime.Now,
|
2024-06-17 10:12:16 +00:00
|
|
|
|
Status = "已生成未下发",
|
2024-04-15 10:06:19 +00:00
|
|
|
|
IsDelete = 0
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-04-11 09:49:43 +00:00
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
base.DoSave();
|
2024-03-27 13:49:16 +00:00
|
|
|
|
|
2024-04-09 08:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2024-06-17 10:12:16 +00:00
|
|
|
|
System.Windows.Forms.MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
2024-04-09 08:17:44 +00:00
|
|
|
|
}
|
2024-03-27 13:49:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|