10 Commits 3d8956b19b ... eda06f2199

Author SHA1 Message Date
  谢翼翔 eda06f2199 临时提交 1 year ago
  谢翼翔 c7d3be4c38 临时提交 1 year ago
  谢翼翔 1005ba4546 临时提交 1 year ago
  谢翼翔 cea0419f19 临时提交 1 year ago
  谢翼翔 953e86deae 临时提交 1 year ago
  谢翼翔 f6951d7f28 临时提交 1 year ago
  谢翼翔 78cf586982 临时提交 1 year ago
  谢翼翔 b7a7aedac3 临时提交 1 year ago
  谢翼翔 cbf250f7f1 Merge branch '45维谛技术数采一期' of http://www.imaodou.com.cn:30030/c_jack/Aliyun_EICP3.0 into 45维谛技术数采一期 1 year ago
  谢翼翔 c0d0e3e2c1 临时提交 1 year ago
23 changed files with 1029 additions and 422 deletions
  1. 230 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/SqlServer.cs
  2. 296 253
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/CP1HMachine.cs
  3. 0 2
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/FXMachine.cs
  4. 3 17
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/DeviceInfoTime/MachineInfoModel.cs
  5. 2 2
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/MachineMoldTime/QueryMachineMoldModel.cs
  6. 117 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/OEEData/OEEDataModel.cs
  7. 50 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/OEEData/OeeAxisXYModels.cs
  8. 15 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/OEEData/OeeProperty.cs
  9. 2 1
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/YaweiWorkInfoModel.cs
  10. 31 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/YaweiWorkInfoModel.cs.ldtmp
  11. 95 25
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/CustomerService.cs
  12. 9 7
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmDeviceOeeInformation.xaml
  13. 59 2
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmDeviceOeeInformation.xaml.cs
  14. 26 26
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmKanbanForPressBrakeEquipment.xaml.cs
  15. 1 1
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmMachineRepairTimeQuery.xaml.cs
  16. 54 66
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmRunHistory.xaml.cs
  17. 6 7
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Dashboard/LaserAndDigitalPunchingEquipmentWidget.xaml.cs
  18. 6 5
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctDeviceChart.xaml
  19. 23 1
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctDeviceChart.xaml.cs
  20. 2 3
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctDeviceInformationControls.xaml
  21. 1 3
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctDeviceInformationControlsSencd.xaml
  22. 1 1
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Env.cs
  23. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/SCADA_DAQ.csproj

+ 230 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/SqlServer.cs

@@ -2,6 +2,7 @@
 using System;
 using System.Collections.Generic;
 using System.Data.SqlClient;
+using System.Linq.Expressions;
 using SCADA.CommonLib;
 using SCADA.CommonLib.Data;
 using SCADA.CommonLib.Data.DIL;
@@ -261,6 +262,53 @@ public static class T_Col_Name
                 /// </summary>
                  public const string @ModifyUser_Str=nameof(@ModifyUser_Str);
                     
+             }
+             /// <summary> 
+             /// App_Vertiv_MachineInfoOeeData
+             /// </summary>
+             public class App_Vertiv_MachineInfoOeeData
+             {
+             	/// <summary>
+                /// 
+                /// </summary>
+                 public const string @ID=nameof(@ID);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @OrgID_Int=nameof(@OrgID_Int);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @StateId_Str=nameof(@StateId_Str);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @Device_Str=nameof(@Device_Str);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @CreateTime_Dt=nameof(@CreateTime_Dt);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @ModifyTime_Dt=nameof(@ModifyTime_Dt);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @ModifyUser_Str=nameof(@ModifyUser_Str);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @RunDayTime_Int=nameof(@RunDayTime_Int);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @AllDayTime_Int=nameof(@AllDayTime_Int);
+                    /// <summary>
+                /// 
+                /// </summary>
+                 public const string @Duration_Dec=nameof(@Duration_Dec);
+                    
              }
              /// <summary> 
              /// App_Vertiv_MaintenanceTable
@@ -1587,6 +1635,163 @@ namespace DBModel
                 }
             }
             
+             }
+             /// <summary> 
+             /// 
+             /// </summary>
+             public class App_Vertiv_MachineInfoOeeData:ObservableObject
+             {
+             	  private int _ID;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public int ID
+                {
+                get {return _ID;}
+                set{
+                    if(value!=(_ID))
+                    {
+                        _ID=value;
+                        OnPropertyChanged(nameof( ID));
+                    }
+                }
+            }
+              private int? _OrgID_Int;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public int? OrgID_Int
+                {
+                get {return _OrgID_Int;}
+                set{
+                    if(value!=(_OrgID_Int))
+                    {
+                        _OrgID_Int=value;
+                        OnPropertyChanged(nameof( OrgID_Int));
+                    }
+                }
+            }
+              private string _StateId_Str;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public string StateId_Str
+                {
+                get {return _StateId_Str;}
+                set{
+                    if(value!=(_StateId_Str))
+                    {
+                        _StateId_Str=value;
+                        OnPropertyChanged(nameof( StateId_Str));
+                    }
+                }
+            }
+              private string _Device_Str;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public string Device_Str
+                {
+                get {return _Device_Str;}
+                set{
+                    if(value!=(_Device_Str))
+                    {
+                        _Device_Str=value;
+                        OnPropertyChanged(nameof( Device_Str));
+                    }
+                }
+            }
+              private DateTime? _CreateTime_Dt;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public DateTime? CreateTime_Dt
+                {
+                get {return _CreateTime_Dt;}
+                set{
+                    if(value!=(_CreateTime_Dt))
+                    {
+                        _CreateTime_Dt=value;
+                        OnPropertyChanged(nameof( CreateTime_Dt));
+                    }
+                }
+            }
+              private DateTime? _ModifyTime_Dt;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public DateTime? ModifyTime_Dt
+                {
+                get {return _ModifyTime_Dt;}
+                set{
+                    if(value!=(_ModifyTime_Dt))
+                    {
+                        _ModifyTime_Dt=value;
+                        OnPropertyChanged(nameof( ModifyTime_Dt));
+                    }
+                }
+            }
+              private string _ModifyUser_Str;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public string ModifyUser_Str
+                {
+                get {return _ModifyUser_Str;}
+                set{
+                    if(value!=(_ModifyUser_Str))
+                    {
+                        _ModifyUser_Str=value;
+                        OnPropertyChanged(nameof( ModifyUser_Str));
+                    }
+                }
+            }
+              private int? _RunDayTime_Int;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public int? RunDayTime_Int
+                {
+                get {return _RunDayTime_Int;}
+                set{
+                    if(value!=(_RunDayTime_Int))
+                    {
+                        _RunDayTime_Int=value;
+                        OnPropertyChanged(nameof( RunDayTime_Int));
+                    }
+                }
+            }
+              private int? _AllDayTime_Int;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public int? AllDayTime_Int
+                {
+                get {return _AllDayTime_Int;}
+                set{
+                    if(value!=(_AllDayTime_Int))
+                    {
+                        _AllDayTime_Int=value;
+                        OnPropertyChanged(nameof( AllDayTime_Int));
+                    }
+                }
+            }
+              private string _Duration_Dec;
+                /// <summary>
+                /// 
+                /// </summary>
+                 public string Duration_Dec
+                {
+                get {return _Duration_Dec;}
+                set{
+                    if(value!=(_Duration_Dec))
+                    {
+                        _Duration_Dec=value;
+                        OnPropertyChanged(nameof( Duration_Dec));
+                    }
+                }
+            }
+            
              }
              /// <summary> 
              /// 
@@ -3348,6 +3553,10 @@ public BaseTable App_Vertiv_MachineInfo{get;private set;}
  /// <summary> 
  ///  
  /// </summary> 
+public BaseTable App_Vertiv_MachineInfoOeeData{get;private set;}
+ /// <summary> 
+ ///  
+ /// </summary> 
 public BaseTable App_Vertiv_MaintenanceTable{get;private set;}
  /// <summary> 
  ///  
@@ -3388,6 +3597,7 @@ App_Vertiv_ByBendInfo=CreateTable("ID","App_Vertiv_ByBendInfo");
 App_Vertiv_ByBendPowerOnTime=CreateTable("ID","App_Vertiv_ByBendPowerOnTime");
 App_Vertiv_DeviceScheduleStop=CreateTable("ID","App_Vertiv_DeviceScheduleStop");
 App_Vertiv_MachineInfo=CreateTable("ID","App_Vertiv_MachineInfo");
+App_Vertiv_MachineInfoOeeData=CreateTable("ID","App_Vertiv_MachineInfoOeeData");
 App_Vertiv_MaintenanceTable=CreateTable("ID","App_Vertiv_MaintenanceTable");
 App_Vertiv_ProductionLog=CreateTable("ID","App_Vertiv_ProductionLog");
 APP_Vertiv_RepairTable=CreateTable("ID","APP_Vertiv_RepairTable");
@@ -3426,6 +3636,10 @@ public BaseTable App_Vertiv_MachineInfo{get;private set;}
  /// <summary> 
  ///  
  /// </summary> 
+public BaseTable App_Vertiv_MachineInfoOeeData{get;private set;}
+ /// <summary> 
+ ///  
+ /// </summary> 
 public BaseTable App_Vertiv_MaintenanceTable{get;private set;}
  /// <summary> 
  ///  
@@ -3472,6 +3686,7 @@ App_Vertiv_ByBendInfo=innerDb.CreateTable("ID","App_Vertiv_ByBendInfo");
 App_Vertiv_ByBendPowerOnTime=innerDb.CreateTable("ID","App_Vertiv_ByBendPowerOnTime");
 App_Vertiv_DeviceScheduleStop=innerDb.CreateTable("ID","App_Vertiv_DeviceScheduleStop");
 App_Vertiv_MachineInfo=innerDb.CreateTable("ID","App_Vertiv_MachineInfo");
+App_Vertiv_MachineInfoOeeData=innerDb.CreateTable("ID","App_Vertiv_MachineInfoOeeData");
 App_Vertiv_MaintenanceTable=innerDb.CreateTable("ID","App_Vertiv_MaintenanceTable");
 App_Vertiv_ProductionLog=innerDb.CreateTable("ID","App_Vertiv_ProductionLog");
 APP_Vertiv_RepairTable=innerDb.CreateTable("ID","APP_Vertiv_RepairTable");
@@ -3539,6 +3754,21 @@ V_Base_AlarmLog=innerDb.CreateTable("ID","V_Base_AlarmLog");
             {
                 return innerDb.UpdateColumnComment(tableName,columnName, comment);
             }
+
+            public override bool BatchUpdateOrInsert<T>(IEnumerable<T> modelList, Expression<Func<T, dynamic>> onRelations, string destinationTableName = null, Expression<Func<T, dynamic>> updateProperts = null)
+            {
+                return innerDb.BatchUpdateOrInsert(modelList, onRelations, destinationTableName, updateProperts);
+            }
+
+            public override int BatchDelete(IEnumerable<object> ids, string destinationTableName, string idColumn = "ID")
+            {
+                return base.BatchDelete(ids, destinationTableName, idColumn);
+            }
+
+            public override int BatchDelete<T>(IEnumerable<T> modelList, Expression<Func<T, dynamic>> onRelations, string destinationTableName = null)
+            {
+                return base.BatchDelete(modelList, onRelations, destinationTableName);
+            }
 #endregion
 
     }

+ 296 - 253
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/CP1HMachine.cs

@@ -2,6 +2,7 @@
 using SCADA;
 using SCADA.CommonLib;
 using SCADA.CommonLib.Data.DIL;
+using SCADA.CommonLib.Helper;
 using SCADA.Drive;
 using SCADA_DAQ.Customer.Models;
 using SCADA_DAQ.Plugin.Machine;
@@ -14,6 +15,7 @@ using System.Configuration;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using static log4net.Appender.RollingFileAppender;
 using static NPOI.HSSF.Util.HSSFColor;
 
 namespace SCADA_DAQ.Customer.Machines
@@ -68,8 +70,8 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                          $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
-                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
                         WaitTime.OnOrgID_Str = "";
                         WaitNameStateCode = "";
                     }
@@ -77,8 +79,8 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                              $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
-                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ChangeModel.StateOnTime_Dt).TotalSeconds));
                         ChangeModel.OnOrgID_Str = "";
                     }
 
@@ -86,8 +88,8 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                         $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ProgramStart.StateOnTime_Dt).TotalSeconds));
                         ProgramStart.OnOrgID_Str = "";
                     }
 
@@ -95,9 +97,9 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                        $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
-                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - RepairTime.StateOnTime_Dt)),
-                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - RepairTime.StateOnTime_Dt).TotalSeconds));
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt)),
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt).TotalSeconds));
                         RepairTime.OnOrgID_Str = "";
                     }
 
@@ -105,9 +107,9 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                         $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.OnOrgID_Str}'",
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - AlarmTime.StateOnTime_Dt)),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - AlarmTime.StateOnTime_Dt).TotalSeconds));
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt)),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt).TotalSeconds));
                         AlarmTime.OnOrgID_Str = "";
                     }
 
@@ -119,194 +121,22 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         if (ConnectState == SCADA.Comm.ConnectStates.Connected)
                         {
-                            var repairTime = this.GetListenReg("维修时间");
-                            if (repairTime.Value == 1)
-                            {
-                                RepairValueRegTrue = true;
-                                RepairTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                                RepairTime.StateOnTime_Dt = DateTime.Now;
-                                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, RepairTime.OnOrgID_Str),
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "维修时间"));
-
-                            }
-                            else if (repairTime.Value == 0)
-                            {
-                                if (RepairTime.OnOrgID_Str != "")
-                                {
-                                    RepairValueRegTrue = false;
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - RepairTime.StateOnTime_Dt)),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - RepairTime.StateOnTime_Dt).TotalSeconds));
-                                    RepairTime.OnOrgID_Str = "";
-                                }
-
-
-                            }
-
-                            var runTIme = this.GetListenReg("运行标志位");
-                            if (runTIme.Value == 1 && RepairValueRegTrue != true && AlarmCode != true)
-                            {
-                                ProgramStart.OnOrgID_Str = Guid.NewGuid().ToString();
-                                ProgramStart.StateOnTime_Dt = DateTime.Now;
-                                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ProgramStart.OnOrgID_Str),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "运行标志位"));
-                            }
-                            else if (runTIme.Value == 0)
-                            {
-                                if (ProgramStart.OnOrgID_Str != "")
-                                {
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                   $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
-                                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
-                                    ProgramStart.OnOrgID_Str = "";
-
-                                }
-
-
-                            }
-
-                            var changeMoldTime = this.GetListenReg("换模标志位");
-                            if (changeMoldTime.Value == 0 && RepairValueRegTrue != true && AlarmCode != true)
-                            {
-                                ChangeModel.OnOrgID_Str = Guid.NewGuid().ToString();
-                                ChangeModel.StateOnTime_Dt = DateTime.Now;
-                                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ChangeModel.OnOrgID_Str),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "换模标志位"));
-                            }
-                            else
-                            {
-                                if (ChangeModel.OnOrgID_Str != "")
-                                {
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                  $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
-                                  new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                  //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
-                                  new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
-                                    ChangeModel.OnOrgID_Str = "";
-                                }
-
-                            }
-
-                            var runFlag = this.GetListenReg("运行标志位");
-                            var toolChangeFlag = this.GetListenReg("换模标志位");
-                            var repairFlag = this.GetListenReg("维修时间");
-                            RegInfo reg = runFlag.Value == 1 ? runFlag : toolChangeFlag.Value == 0 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
-                            if (reg == null && AlarmCode != true)
-                            {
-                                if (WaitNameStateCode != "停止标志位")
-                                {
-                                    WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                                    WaitTime.StateOnTime_Dt = DateTime.Now;
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
-                                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
-                                    WaitNameStateCode = "停止标志位";
-                                }
-
-                            }
-                            else
-                            {
-                                if (WaitTime.OnOrgID_Str != "")
-                                {
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                      $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
-                                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                      //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
-                                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
-                                    WaitTime.OnOrgID_Str = "";
-                                    WaitNameStateCode = "";
-                                }
-
-                            }
-
-                            if (AlarmCode == true && RepairValueRegTrue != true)
-                            {
-                                if (WaitTime.OnOrgID_Str != "")
-                                {
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                     $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
-                                     new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
-                                    WaitTime.OnOrgID_Str = "";
-                                    WaitNameStateCode = "";
-                                }
-                                if (ChangeModel.OnOrgID_Str != "")
-                                {
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                         $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
-                                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
-                                    ChangeModel.OnOrgID_Str = "";
-                                }
-                                if (ProgramStart.OnOrgID_Str != "")
-                                {
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
-                                    ProgramStart.OnOrgID_Str = "";
-                                }
-                                if (AlarmTime.OnOrgID_Str == "")
-                                {
-                                    AlarmTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                                    AlarmTime.StateOnTime_Dt = DateTime.Now;
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, AlarmTime.OnOrgID_Str),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "故障标志位"));
-                                }
-                           
-                            }
-                            else
-                            {
-                                if (AlarmTime.OnOrgID_Str != "")
-                                {
-                                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
-                                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.OnOrgID_Str}'",
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - AlarmTime.StateOnTime_Dt)),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - AlarmTime.StateOnTime_Dt).TotalSeconds));
-                                    AlarmTime.OnOrgID_Str = "";
-                                }
-                            }
-
+                            DeviceInsert();
                         }
                         else
                         {
                             if (WaitNameStateCode != "停止标志位")
                             {
                                 WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                                WaitTime.StateOnTime_Dt = DateTime.Now;
+                                WaitTime.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
                                 Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
                                     new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
                                     new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                                     new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
                                 WaitNameStateCode = "停止标志位";
                             }
-                            //WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                            //WaitTime.StateOnTime_Dt = DateTime.Now;
-                            //Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                            //    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
-                            //    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                            //    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                            //    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
-                            //WaitNameStateCode = "停止标志位";
+                
                         }
 
 
@@ -334,11 +164,11 @@ namespace SCADA_DAQ.Customer.Machines
                         {
                             RepairValueRegTrue = true;
                             RepairTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                            RepairTime.StateOnTime_Dt = DateTime.Now;
+                            RepairTime.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
                             Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, RepairTime.OnOrgID_Str),
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "维修时间"));
 
                         }
@@ -349,9 +179,9 @@ namespace SCADA_DAQ.Customer.Machines
                             {
                                 Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                                $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
-                               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - RepairTime.StateOnTime_Dt)),
-                               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - RepairTime.StateOnTime_Dt).TotalSeconds));
+                               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt),
+                               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt).TotalSeconds));
                                 RepairTime.OnOrgID_Str = "";
                             }
                          
@@ -366,11 +196,11 @@ namespace SCADA_DAQ.Customer.Machines
                         if (reg.Value == 1)
                         {
                             ProgramStart.OnOrgID_Str = Guid.NewGuid().ToString();
-                            ProgramStart.StateOnTime_Dt = DateTime.Now;
+                            ProgramStart.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
                             Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ProgramStart.OnOrgID_Str),
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "运行标志位"));
                         }
                         else if (reg.Value == 0)
@@ -379,8 +209,8 @@ namespace SCADA_DAQ.Customer.Machines
                             {
                                 Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                                 $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ProgramStart.StateOnTime_Dt).TotalSeconds));
                                 ProgramStart.OnOrgID_Str = "";
                             }
 
@@ -393,11 +223,11 @@ namespace SCADA_DAQ.Customer.Machines
                         if (reg.Value == 0)
                         {
                             ChangeModel.OnOrgID_Str = Guid.NewGuid().ToString();
-                            ChangeModel.StateOnTime_Dt = DateTime.Now;
+                            ChangeModel.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
                             Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ChangeModel.OnOrgID_Str),
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "换模标志位"));
                         }
                         else
@@ -406,9 +236,9 @@ namespace SCADA_DAQ.Customer.Machines
                             {
                                 Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                          $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
-                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                          //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
-                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ChangeModel.StateOnTime_Dt).TotalSeconds));
                                 ChangeModel.OnOrgID_Str = "";
                             }
 
@@ -423,11 +253,11 @@ namespace SCADA_DAQ.Customer.Machines
                         if (WaitTime.OnOrgID_Str == "" & WaitNameStateCode != "停止标志位")
                         {
                             WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                            WaitTime.StateOnTime_Dt = DateTime.Now;
+                            WaitTime.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
                             Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
                             WaitNameStateCode = "停止标志位";
                         }
@@ -439,9 +269,9 @@ namespace SCADA_DAQ.Customer.Machines
                         {
                             Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                               $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
-                              new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
+                              new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                               //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
-                              new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                              new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
                             WaitTime.OnOrgID_Str = "";
                             WaitNameStateCode = "";
                         }
@@ -455,8 +285,8 @@ namespace SCADA_DAQ.Customer.Machines
                         {
                             Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                              $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
-                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
                             WaitTime.OnOrgID_Str = "";
                             WaitNameStateCode = "";
                         }
@@ -464,26 +294,26 @@ namespace SCADA_DAQ.Customer.Machines
                         {
                             Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                                  $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
-                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ChangeModel.StateOnTime_Dt).TotalSeconds));
                             ChangeModel.OnOrgID_Str = "";
                         }
                         if (ProgramStart.OnOrgID_Str != "")
                         {
                             Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                             $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ProgramStart.StateOnTime_Dt).TotalSeconds));
                             ProgramStart.OnOrgID_Str = "";
                         }
                         if (AlarmTime.OnOrgID_Str == "")
                         {
                             AlarmTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                            AlarmTime.StateOnTime_Dt = DateTime.Now;
+                            AlarmTime.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
                             Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, AlarmTime.OnOrgID_Str),
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "故障标志位"));
                         }
 
@@ -496,30 +326,17 @@ namespace SCADA_DAQ.Customer.Machines
                         {
                             Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                             $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.OnOrgID_Str}'",
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - AlarmTime.StateOnTime_Dt)),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - AlarmTime.StateOnTime_Dt).TotalSeconds));
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt)),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt).TotalSeconds));
                             AlarmTime.OnOrgID_Str = "";
+                            
+                            DeviceInsert();
                         }
                     }
                 
                 }
-                else
-                {
-                    if (WaitNameStateCode != "停止标志位")
-                    {
-                        WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                        WaitTime.StateOnTime_Dt = DateTime.Now;
-                        Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
-                        WaitNameStateCode = "停止标志位";
-                    }
-                  
-                }
-
+               
 
             }
           
@@ -535,22 +352,23 @@ namespace SCADA_DAQ.Customer.Machines
                 
                     if (ConnectState != SCADA.Comm.ConnectStates.Connected)
                     {
+                       
                         PowerOn.OnOrgID_Str = Guid.NewGuid().ToString();
                         Env.SqlDAL.App_Vertiv_WorkTime.Insert(
                             new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.OrgID_Str, PowerOn.OnOrgID_Str),
                             new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DeviceName_Str, BaseDevice.DeviceID)
                             );
                         PowerOn.StateOnTime_Dt = DateTime.Now;
-
+                       DeviceUpdate();
 
                     if (WaitNameStateCode != "停止标志位")
                     {
                         WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
-                        WaitTime.StateOnTime_Dt = DateTime.Now;
+                        WaitTime.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
                         Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
-                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Now),
+                            new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"),
                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.TagName_Str, "停止标志位"));
                         WaitNameStateCode = "停止标志位";
@@ -572,11 +390,10 @@ namespace SCADA_DAQ.Customer.Machines
                         {
                             Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                            $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
-                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
                         }
-
-
+                      DeviceInsert();
                     }
                 
 
@@ -606,7 +423,13 @@ namespace SCADA_DAQ.Customer.Machines
                         new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DeviceName_Str, BaseDevice.DeviceID));
                     PowerOn.StateOnTime_Dt = DateTime.Now;
                 }
+                if (!IsOpenTime)
+                {
+                    DeviceUpdate();
 
+                    DeviceInsert();
+                }
+             
 
             }
 
@@ -620,8 +443,8 @@ namespace SCADA_DAQ.Customer.Machines
                         {
                             Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                            $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
-                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                           new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
                         }
                     }
 
@@ -629,15 +452,15 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                          $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
-                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - WaitTime.StateOnTime_Dt).TotalSeconds));
+                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
                     }
                     if (ChangeModel.OnOrgID_Str != "")
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                              $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
-                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                             new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ChangeModel.StateOnTime_Dt).TotalSeconds));
 
                     }
 
@@ -645,8 +468,8 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                         $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ProgramStart.StateOnTime_Dt).TotalSeconds));
 
                     }
 
@@ -654,9 +477,9 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                        $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
-                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - RepairTime.StateOnTime_Dt)),
-                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - RepairTime.StateOnTime_Dt).TotalSeconds));
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt)),
+                       new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt).TotalSeconds));
 
                     }
 
@@ -664,9 +487,9 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         Env.SqlDAL.App_Vertiv_MachineInfo.Update(
                         $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.OnOrgID_Str}'",
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - AlarmTime.StateOnTime_Dt)),
-                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Now - AlarmTime.StateOnTime_Dt).TotalSeconds));
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt)),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format())- AlarmTime.StateOnTime_Dt).TotalSeconds));
 
                     }
                 
@@ -674,6 +497,226 @@ namespace SCADA_DAQ.Customer.Machines
         }
 
 
+        public void DeviceUpdate()
+        {
+            if (WaitTime.OnOrgID_Str != "")
+            {
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                 $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
+                 new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
+                WaitTime.OnOrgID_Str = "";
+                WaitNameStateCode = "";
+            }
+            if (ChangeModel.OnOrgID_Str != "")
+            {
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                     $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
+                     new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                     new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                ChangeModel.OnOrgID_Str = "";
+            }
+
+            if (ProgramStart.OnOrgID_Str != "")
+            {
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                ProgramStart.OnOrgID_Str = "";
+            }
+
+            if (RepairTime.OnOrgID_Str != "")
+            {
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+               $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
+               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt)),
+               new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt).TotalSeconds));
+                RepairTime.OnOrgID_Str = "";
+            }
+
+            if (AlarmTime.OnOrgID_Str != "")
+            {
+                Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.OnOrgID_Str}'",
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt)),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt).TotalSeconds));
+                AlarmTime.OnOrgID_Str = "";
+            }
+
+        }
+        public void DeviceInsert()
+        {
+            var repairTime = this.GetListenReg("维修时间");
+            if (repairTime.Value == 1)
+            {
+                RepairValueRegTrue = true;
+                RepairTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                RepairTime.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
+                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, RepairTime.OnOrgID_Str),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "维修时间"));
+
+            }
+            else if (repairTime.Value == 0)
+            {
+                if (RepairTime.OnOrgID_Str != "")
+                {
+                    RepairValueRegTrue = false;
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{RepairTime.OnOrgID_Str}'",
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt)),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - RepairTime.StateOnTime_Dt).TotalSeconds));
+                    RepairTime.OnOrgID_Str = "";
+                }
+
+
+            }
+
+            var runTIme = this.GetListenReg("运行标志位");
+            if (runTIme.Value == 1 && RepairValueRegTrue != true && AlarmCode != true)
+            {
+                ProgramStart.OnOrgID_Str = Guid.NewGuid().ToString();
+                ProgramStart.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
+                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ProgramStart.OnOrgID_Str),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "运行标志位"));
+            }
+            else if (runTIme.Value == 0)
+            {
+                if (ProgramStart.OnOrgID_Str != "")
+                {
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                   $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
+                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                    ProgramStart.OnOrgID_Str = "";
+
+                }
+
+
+            }
+
+            var changeMoldTime = this.GetListenReg("换模标志位");
+            if (changeMoldTime.Value == 0 && RepairValueRegTrue != true && AlarmCode != true)
+            {
+                ChangeModel.OnOrgID_Str = Guid.NewGuid().ToString();
+                ChangeModel.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
+                Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, ChangeModel.OnOrgID_Str),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "换模标志位"));
+            }
+            else
+            {
+                if (ChangeModel.OnOrgID_Str != "")
+                {
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                  $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
+                  new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                  //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
+                  new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                    ChangeModel.OnOrgID_Str = "";
+                }
+
+            }
+
+            var runFlag = this.GetListenReg("运行标志位");
+            var toolChangeFlag = this.GetListenReg("换模标志位");
+            var repairFlag = this.GetListenReg("维修时间");
+            RegInfo reg = runFlag.Value == 1 ? runFlag : toolChangeFlag.Value == 0 ? toolChangeFlag : repairFlag.Value == 1 ? repairFlag : null;
+            if (reg == null && AlarmCode != true)
+            {
+                if (WaitNameStateCode != "停止标志位")
+                {
+                    WaitTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                    WaitTime.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, WaitTime.OnOrgID_Str),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                        new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "停止标志位"));
+                    WaitNameStateCode = "停止标志位";
+                }
+
+            }
+            else
+            {
+                if (WaitTime.OnOrgID_Str != "")
+                {
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                      $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
+                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                      //new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Now - ProgramStart.StateOnTime_Dt)),
+                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
+                    WaitTime.OnOrgID_Str = "";
+                    WaitNameStateCode = "";
+                }
+
+            }
+
+            if (AlarmCode == true && RepairValueRegTrue != true)
+            {
+                if (WaitTime.OnOrgID_Str != "")
+                {
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                     $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{WaitTime.OnOrgID_Str}'",
+                     new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                   new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - WaitTime.StateOnTime_Dt).TotalSeconds));
+                    WaitTime.OnOrgID_Str = "";
+                    WaitNameStateCode = "";
+                }
+                if (ChangeModel.OnOrgID_Str != "")
+                {
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                         $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ChangeModel.OnOrgID_Str}'",
+                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                         new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ChangeModel.StateOnTime_Dt).TotalSeconds));
+                    ChangeModel.OnOrgID_Str = "";
+                }
+                if (ProgramStart.OnOrgID_Str != "")
+                {
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{ProgramStart.OnOrgID_Str}'",
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - ProgramStart.StateOnTime_Dt).TotalSeconds));
+                    ProgramStart.OnOrgID_Str = "";
+                }
+                if (AlarmTime.OnOrgID_Str == "")
+                {
+                    AlarmTime.OnOrgID_Str = Guid.NewGuid().ToString();
+                    AlarmTime.StateOnTime_Dt = DateTime.Parse(DateTime.Now.Format());
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, AlarmTime.OnOrgID_Str),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Device_Str, BaseDevice.DeviceID),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StartTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, "故障标志位"));
+                }
+
+            }
+            else
+            {
+                if (AlarmTime.OnOrgID_Str != "")
+                {
+                    Env.SqlDAL.App_Vertiv_MachineInfo.Update(
+                    $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{AlarmTime.OnOrgID_Str}'",
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Parse(DateTime.Now.Format())),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt)),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (DateTime.Parse(DateTime.Now.Format()) - AlarmTime.StateOnTime_Dt).TotalSeconds));
+                    AlarmTime.OnOrgID_Str = "";
+
+
+                }
+            }
+        }
         public override void Dispose()
         {
             Env.Schedual.DateTimeChanged -= Schedual_DateTimeChanged;

+ 0 - 2
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/FXMachine.cs

@@ -158,8 +158,6 @@ namespace SCADA_DAQ.Customer.Machines
                 if (ConnectState == SCADA.Comm.ConnectStates.Connected)
                 {
                     InsertStateRecord(reg);
-
-
                 }
 
             }

+ 3 - 17
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/DeviceInfoTime/MachineInfoModel.cs

@@ -15,6 +15,8 @@ namespace SCADA_DAQ.Customer.Models.DeviceInfoTime
     {
         private static SqlSchema.DIL.DILDB DAL = Env.SqlDAL;
 
+
+
         /// <summary>
         /// 唯一码
         /// </summary>
@@ -138,23 +140,7 @@ namespace SCADA_DAQ.Customer.Models.DeviceInfoTime
 
         }
 
-        //public double DeviceTimeValue(string StateCode)//设备运行状态时间
-        //{
-        //    //获取当天所有设备信息
-        //    var deviceInformation = DAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>()?.Where(t => t.CreateTime.Date == DateTime.Now.Date);
-        //    var keepTime = deviceInformation.ToLookup(t => t.Device)[Device].ToLookup(t => t.StateCode)[StateCode].Sum(t => t.DurationSec);
-        //    return Convert.ToDouble(keepTime);
-        //}
-
-        //public ILookup<string, MachineInfoModel> DeviceTimeValue_2()//设备运行状态时间
-        //{
-        //    //获取当天所有设备信息
-        //    var deviceInformation = DAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>()?
-        //        .Where(t => t.CreateTime.Date == DateTime.Now.Date && t.Device == Device).ToLookup(t => t.StateCode);
-        //    //var keepTime = deviceInformation.ToLookup(t => t.Device)[Device].ToLookup(t => t.StateCode)[StateCode].Sum(t => t.DurationSec);
-        //    //return Convert.ToDouble(keepTime);
-        //    return deviceInformation;
-        //}
+     
 
         public double DeviceTimeValue_3(List<MachineInfoModel> data, string Device, string StateCode)//设备运行状态时间
         {

+ 2 - 2
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/MachineMoldTime/QueryMachineMoldModel.cs

@@ -46,7 +46,7 @@ namespace SCADA_DAQ.Customer.Models.MachineMoldTime
         /// <summary>
         /// 
         /// </summary>
-        [AutoViewProperty("设备状态")]
+        [AutoViewProperty("设备状态",OptionItemsSource = nameof(DeviceCode), StringType = StringType.IsLimited)]
         [Query(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str)]
         public string StateCode
         {
@@ -61,7 +61,7 @@ namespace SCADA_DAQ.Customer.Models.MachineMoldTime
             }
         }
         private string _StateCode;
-        //public List<string> DeviceCode { get; set; } = new List<string> { "换模标志位", "停止标志位" };
+        public List<string> DeviceCode { get; set; } = new List<string> { null,"运行标志位", "停止标志位","故障标志位","换模标志位","维修时间"};
 
         /// <summary>
         /// 

+ 117 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/OEEData/OEEDataModel.cs

@@ -0,0 +1,117 @@
+using SCADA.CommonLib;
+using SCADA.CommonLib.Helper;
+using SCADA_DAQ.Customer.Models.DeviceInfoTime;
+using SCADA_DAQ.Customer.Models.DistinctTimePiece;
+using SqlSchema.DBNames;
+using System;
+using System.Collections.Generic;
+using System.Drawing.Printing;
+using System.Linq;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models.OEEData
+{
+ 
+    public class OEEDataModel:ObservableObject
+    {
+
+
+        /// <summary>
+        /// 设备名称
+        /// </summary>
+        [Column(T_Col_Name.App_Vertiv_MachineInfoOeeData.Device_Str)]
+        public string DeviceName
+        {
+            get { return _DeviceName; }
+            set
+            {
+                if (value != _DeviceName)
+                {
+                    _DeviceName = value;
+                    OnPropertyChanged(nameof(DeviceName));
+                }
+            }
+        }
+        private string _DeviceName;
+
+
+        /// <summary>
+        /// 设备运行时间
+        /// </summary>
+        [Column(T_Col_Name.App_Vertiv_MachineInfoOeeData.RunDayTime_Int)]
+        public int RunTime
+        {
+            get { return _RunTime; }
+            set
+            {
+                if (value != _RunTime)
+                {
+                    _RunTime = value;
+                    OnPropertyChanged(nameof(RunTime));
+                }
+            }
+        }
+        private int _RunTime;
+
+
+        /// <summary>
+        /// 设备今日总时间
+        /// </summary>
+        [Column(T_Col_Name.App_Vertiv_MachineInfoOeeData.AllDayTime_Int)]
+        public int DeviceDayTime
+        {
+            get { return _DeviceDayTime; }
+            set
+            {
+                if (value != _DeviceDayTime)
+                {
+                    _DeviceDayTime = value;
+                    OnPropertyChanged(nameof(DeviceDayTime));
+                }
+            }
+        }
+        private int _DeviceDayTime;
+
+
+        /// <summary>
+        /// 设备Oee百分比
+        /// </summary>
+        [Column(T_Col_Name.App_Vertiv_MachineInfoOeeData.Duration_Dec)]
+        public string OeePercentage
+        {
+            get { return _OeePercentage; }
+            set
+            {
+                if (value != _OeePercentage)
+                {
+                    _OeePercentage = value;
+                    OnPropertyChanged(nameof(OeePercentage));
+                }
+            }
+        }
+        private string _OeePercentage;
+
+
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        [Column(T_Col_Name.App_Vertiv_MachineInfoOeeData.CreateTime_Dt)]
+        public DateTime CreateTime
+        {
+            get { return _CreateTime; }
+            set
+            {
+                if (value != _CreateTime)
+                {
+                    _CreateTime = value;
+                    OnPropertyChanged(nameof(CreateTime));
+                }
+            }
+        }
+        private DateTime _CreateTime;
+
+    }
+    
+}

+ 50 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/OEEData/OeeAxisXYModels.cs

@@ -0,0 +1,50 @@
+using SCADA.CommonLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models.OEEData
+{
+    public class OeeAxisXYModels:ObservableObject
+    {
+
+        private double _Indx;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public double Indx
+        {
+            get { return _Indx; }
+            set
+            {
+                if (value != _Indx)
+                {
+                    _Indx = value;
+                    OnPropertyChanged(nameof(Indx));
+                }
+            }
+        }
+
+
+        private double _Value;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public double Value
+        {
+            get { return _Value; }
+            set
+            {
+                if (value != _Value)
+                {
+                    _Value = value;
+                    OnPropertyChanged(nameof(Value));
+                }
+            }
+        }
+    }
+}

+ 15 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/OEEData/OeeProperty.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models.OEEData
+{
+    public class OeeProperty
+    {
+        public List<double> DeviceEveryDayOeePercent { get; set; }
+
+
+    }
+}

+ 2 - 1
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/YaweiWorkInfoModel.cs

@@ -1,4 +1,5 @@
-using System;
+using SCADA.CommonLib.Helper;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;

+ 31 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/YaweiWorkInfoModel.cs.ldtmp

@@ -0,0 +1,31 @@
+using SCADA.CommonLib.Helper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models
+{
+    public class YaweiWorkInfoModel
+    {
+        public YaweiStateInfoModel Power { get; set; } = new YaweiStateInfoModel();
+
+        public YaweiStateInfoModel Work { get; set; } = new YaweiStateInfoModel();
+
+        public YaweiStateInfoModel Error { get; set; } = new YaweiStateInfoModel();
+
+        public YaweiStateInfoModel Program { get; set; } = new YaweiStateInfoModel();
+    }
+
+    public class YaweiStateInfoModel
+    {
+        public bool StateOn_Bool;
+
+        public string OnOrgID_Str = "";
+
+        public DateTime StateOnTime_Dt;
+
+        public double StateOnDuration_Double;
+    }
+}

+ 95 - 25
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/CustomerService.cs

@@ -1,4 +1,5 @@
-using Microsoft.Expression.Interactivity.Media;
+using ControlzEx.Standard;
+using Microsoft.Expression.Interactivity.Media;
 using NPOI.SS.Formula.Functions;
 using Opc.Ua;
 using SCADA;
@@ -7,6 +8,8 @@ using SCADA.CommonLib.Data.DIL;
 using SCADA.CommonLib.Helper;
 using SCADA.CommonLib.Service;
 using SCADA_DAQ.Customer.Models;
+using SCADA_DAQ.Customer.Models.DeviceInfoTime;
+using SCADA_DAQ.Customer.Models.OEEData;
 using SCADA_DAQ.Plugin.Machine.Config;
 using SqlSchema.DBNames;
 using System;
@@ -88,8 +91,9 @@ namespace SCADA_DAQ.Customer.Service
             Timer.Start();
             Timer.Elapsed += Timer_Elapsed;
             Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
+            GetOeeData();
             var str = $"{T_Col_Name.App_Vertiv_MachineInfo.Device_Str} = '亚威PBC折弯机' ";
-            var lastTime = Env.SqlDAL.App_Vertiv_MachineInfo.GetTopOne(str, "StartTime_Dt"," ID Desc ");
+            var lastTime = Env.SqlDAL.App_Vertiv_MachineInfo.GetTopOne(str, "StartTime_Dt", " ID Desc ");
             LastRecordTime = Convert.ToDateTime(lastTime);
             return base.Start();
 
@@ -99,12 +103,12 @@ namespace SCADA_DAQ.Customer.Service
 
         private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
         {
-            if (e.ChangeType==DateTimeChangeType.MinuteChanged)
+            if (e.ChangeType == DateTimeChangeType.MinuteChanged)
             {
                 TimeToUpdate();
             }
 
-            if (e.ChangeType==DateTimeChangeType.DayChanged)
+            if (e.ChangeType == DateTimeChangeType.DayChanged)
             {
                 TimeToUpdate();
                 yaweiMac.Power.OnOrgID_Str = Guid.NewGuid().ToString();
@@ -118,6 +122,7 @@ namespace SCADA_DAQ.Customer.Service
                 Env.SqlDAL.App_Vertiv_WorkTime.Insert(
                     new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DeviceName_Str, "西门子840D数冲"),
                     new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.OrgID_Str, simensModel.OnOrgID_Str));
+                OeePercent();
 
             }
 
@@ -158,10 +163,17 @@ namespace SCADA_DAQ.Customer.Service
                                new UpdateItem(T_Col_Name.App_Vertiv_ScheduleStop.Duration_Dt, lastTime)
                                    );
                             OrgID = null;
-                         }
+                        }
                     }
                 }
             }
+
+
+            if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged & e.TimeFlag.Second % 10 == 0 )
+            {
+                GetOeeData();
+                OeePercent();
+            }
         }
 
         private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
@@ -235,11 +247,11 @@ namespace SCADA_DAQ.Customer.Service
                                     }
                                 }
                             }
-                            
+
                             var modeChange = recordModelList.Where(t => t.@event == "mode" && t.StrTimeFormat(t.time) > LastRecordTime).ToList();
                             if (modeChange != null)
                             {
-                                if (modeChange.Count >0)
+                                if (modeChange.Count > 0)
                                 {
                                     foreach (var item in modeChange)
                                     {
@@ -256,14 +268,14 @@ namespace SCADA_DAQ.Customer.Service
                                                 ref yaweiMac.Program.StateOnDuration_Double);
                                         }
                                     }
-             
+
                                 }
                             }
 
-                            var stepList = recordModelList.Where(t=>t.@event == "step" && t.StrTimeFormat(t.time) > LastRecordTime).ToList();
+                            var stepList = recordModelList.Where(t => t.@event == "step" && t.StrTimeFormat(t.time) > LastRecordTime).ToList();
                             if (stepList != null)
                             {
-                                if (stepList.Count>0)
+                                if (stepList.Count > 0)
                                 {
                                     foreach (var item in stepList)
                                     {
@@ -272,18 +284,18 @@ namespace SCADA_DAQ.Customer.Service
                                     }
                                 }
                             }
-                                //if (recordModelList[i].StrTimeFormat(recordModelList[i].time) > LastRecordTime)
-                                //    {
-                                //        //程序启动
-                                //        if (recordModelList[i].@event == "start")
-                                //        {
-                                //            Env.SqlDAL.App_Vertiv_ProductionLog.Insert(
-                                //                new UpdateItem(T_Col_Name.App_Vertiv_ProductionLog.DeviceName_Str, "亚威PBC折弯机"));
-                                //            InsertStateCode(ref yaweiMac.Work.OnOrgID_Str,
-                                //                "运行标志位",
-                                //                ref yaweiMac.Work.StateOn_Bool,
-                                //                recordModelList[i].StrTimeFormat(recordModelList[i].time),
-                                //                ref yaweiMac.Work.StateOnTime_Dt);
+                            //if (recordModelList[i].StrTimeFormat(recordModelList[i].time) > LastRecordTime)
+                            //    {
+                            //        //程序启动
+                            //        if (recordModelList[i].@event == "start")
+                            //        {
+                            //            Env.SqlDAL.App_Vertiv_ProductionLog.Insert(
+                            //                new UpdateItem(T_Col_Name.App_Vertiv_ProductionLog.DeviceName_Str, "亚威PBC折弯机"));
+                            //            InsertStateCode(ref yaweiMac.Work.OnOrgID_Str,
+                            //                "运行标志位",
+                            //                ref yaweiMac.Work.StateOn_Bool,
+                            //                recordModelList[i].StrTimeFormat(recordModelList[i].time),
+                            //                ref yaweiMac.Work.StateOnTime_Dt);
 
                             //        }
                             //        else if (recordModelList[i].@event == "mode")
@@ -319,9 +331,9 @@ namespace SCADA_DAQ.Customer.Service
 
 
 
-                                LastRecordTime = recordModelList.Last().StrTimeFormat(recordModelList.Last().time);
+                            LastRecordTime = recordModelList.Last().StrTimeFormat(recordModelList.Last().time);
                             file.Close();
-                         
+
 
 
                             try
@@ -369,7 +381,7 @@ namespace SCADA_DAQ.Customer.Service
                         new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DurationSec_Dec, yaweiMac.Power.StateOnDuration_Double),
                         new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.TurnOffTime_Dt, DateTime.Now.Format()));
                     yaweiMac.Power.StateOn_Bool = false;
-                    
+
                 }
                 if (!string.IsNullOrEmpty(OrgID))
                 {
@@ -512,5 +524,63 @@ namespace SCADA_DAQ.Customer.Service
                     new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.TurnOffTime_Dt, DateTime.Now.Format()));
             }
         }
+
+
+        public IEnumerable<MachineInfoModel> OeeData { get; set; }
+
+        public IEnumerable<OEEDataModel> DailyOeeData { get; set; }
+        public void GetOeeData()
+        {
+            var startDayTime = DateTime.Parse(DateTime.Now.ToString("00:00:00"));
+            var endDayTime = DateTime.Parse(DateTime.Now.ToString("23:59:59"));
+            OeeData = Env.SqlDAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>().Where(t => t.CreateTime >= startDayTime & t.CreateTime <= endDayTime);
+            DailyOeeData = Env.SqlDAL.App_Vertiv_MachineInfoOeeData.GetData<OEEDataModel>().Where(t => t.CreateTime >= startDayTime & t.CreateTime <= endDayTime);
+
+        }
+
+        public string OeeValue { get; set; }
+
+        public void OeePercent()
+        {
+            var deviceName = new List<string>{"高机母线冲剪机", "2号YaWei折弯机", "3号YaWei折弯机", "激光机", "1号YaWei折弯机", "百超折弯机",
+            "倍福数冲机", "金方圆数控母线冲孔机", "西门子840D数冲", "亚威PBC折弯机"};
+
+            for (int i = 0; i < deviceName.Count; i++)
+            {
+                var device = deviceName[i];
+                var deviceDayTIme = OeeData.ToLookup(t => t.Device)[deviceName[i]].Sum(t => t.DurationSec);
+                var deviceRunDayTIme = OeeData.ToLookup(t => t.Device)[deviceName[i]].ToLookup(t => t.StateCode)["运行标志位"].Sum(t => t.DurationSec);
+
+                if (deviceDayTIme == 0)
+                {
+                    OeeValue = "0";
+                }
+                else
+                {
+                    OeeValue = Math.Round(Convert.ToDouble(deviceRunDayTIme) / deviceDayTIme, 4).ToString();
+                  
+                }
+                if (DailyOeeData.Count() != 0)
+                {
+                    Env.SqlDAL.App_Vertiv_MachineInfoOeeData.Update(
+                       $"{T_Col_Name.App_Vertiv_MachineInfoOeeData.Device_Str} = '{deviceName[i]}'",
+                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.RunDayTime_Int, deviceRunDayTIme),
+                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.AllDayTime_Int, deviceDayTIme),
+                      new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.Duration_Dec, OeeValue));
+                }
+                else
+                {
+                    OrgID = Guid.NewGuid().ToString();
+                    Env.SqlDAL.App_Vertiv_MachineInfoOeeData.Insert(
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.Device_Str, deviceName[i]),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.StateId_Str, OrgID),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.RunDayTime_Int, deviceRunDayTIme),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.AllDayTime_Int, deviceDayTIme),
+                    new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.Duration_Dec, OeeValue));
+
+                }
+            }
+
+        }
     }
 }

+ 9 - 7
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmDeviceOeeInformation.xaml

@@ -28,13 +28,15 @@
                 <ColumnDefinition/>
             </Grid.ColumnDefinitions>
             <uct:UctDeviceChart  x:Name="LaserDevice"/>
-            <uct:UctDeviceChart Grid.Row="1" x:Name="Device"/>
-            <uct:UctDeviceChart Grid.Row="2" x:Name="D"/>
-            <uct:UctDeviceChart Grid.Row="3" x:Name="De"/>
-            <uct:UctDeviceChart Grid.Row="4" x:Name="Dev"/>
-            
-            
+            <uct:UctDeviceChart Grid.Row="1" x:Name="simenDevice"/>
+            <uct:UctDeviceChart Grid.Row="2" x:Name="BeiFuDevice"/>
+            <uct:UctDeviceChart Grid.Row="3" x:Name="KimFangyuanDevice"/>
+            <uct:UctDeviceChart Grid.Row="4" x:Name="HighDevice"/>
+            <uct:UctDeviceChart Grid.Column="1" x:Name="OneBendingDevice" />
+            <uct:UctDeviceChart Grid.Row="1" x:Name="TwoBendingDevice" Grid.Column="1"/>
+            <uct:UctDeviceChart Grid.Row="2" x:Name="ThreeBendingDevice" Grid.Column="1"/>
+            <uct:UctDeviceChart Grid.Row="3" x:Name="YaWeiPBCDevice" Grid.Column="1"/>
+            <uct:UctDeviceChart Grid.Row="4" x:Name="BaiChaoDevice" Grid.Column="1"/>
         </Grid>
-     
     </Grid>
 </wpfcontrol:BaseUctFrm>

+ 59 - 2
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmDeviceOeeInformation.xaml.cs

@@ -1,4 +1,7 @@
 using SCADA.CommonCtrl.WpfControl;
+using SCADA.CommonLib.Helper;
+using SCADA.CommonLib;
+using SCADA_DAQ.Customer.Models.DeviceInfoTime;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -13,22 +16,76 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using SCADA_DAQ.Customer.Models.OEEData;
+using LiveCharts;
 
 namespace SCADA_DAQ.Customer
 {
     /// <summary>
     /// UctFrmDeviceOeeInformation.xaml 的交互逻辑
     /// </summary>
-    [UctMenu("设备OEE界面",Icon ="看板")]
+    [UctMenu("设备OEE界面", Icon = "看板")]
     public partial class UctFrmDeviceOeeInformation : BaseUctFrm
     {
+        public OeeProperty DeviceOeePercenValue = new OeeProperty();
         public UctFrmDeviceOeeInformation()
         {
             InitializeComponent();
+
             ToolBar.Visibility = Visibility.Collapsed;
             Image_Title.Source = SCADA.CommonCtrl.WpfHelper.VisualHelper.ImageToImageSource(@"Icon\VertivBck.png");
             LocalTime.Text = DateTime.Now.ToString("dddd yyyy年MM月dd日 HH:mm");
-            
+            //GetOeeData();
+            //OeePercent("高机母线冲剪机");
+            //var listdouble = OeePercent("高机母线冲剪机");
+            //HighDevice.OeeValue.Values = new ChartValues<double>();
+            //for (int i = 0; i < OeePercent("高机母线冲剪机").Count; i++)
+            //{
+            //    HighDevice.OeeValue.Values.Add(OeePercent("高机母线冲剪机")[i]);
+            //}
+          
+
+
+        }
+      
+        public IEnumerable<OEEDataModel> OeeData { get; set; }
+
+        public List<TimeSection> Days { get; set; }
+        public void GetOeeData()
+        {
+            Days = DateTimeHelper.GetDays(DateTimeHelper.ToMonthStart(DateTime.Now), DateTimeHelper.ToMonthEnd(DateTime.Now));
+            var first = DateTime.Parse(Days.First().StartTime.ToString());
+            var last = DateTime.Parse(Days.Last().EndTime.ToString());
+            OeeData = Env.SqlDAL.App_Vertiv_MachineInfoOeeData.GetData<OEEDataModel>().Where(t => t.CreateTime >= first & t.CreateTime <= last);
+
+        }
+        public List<double> OeePercent(string deviceName)
+        {
+            var allOeePercentage = new List<double>();
+            var runTime = new List<double>();
+            double dayRunTime = 0;
+            for (int i = 0; i < Days.Count; i++)
+            {
+                var hourStartResult = Days[i].StartTime.Format();
+                var hourEndResult = Days[i].EndTime.Format();
+                var OeePercentSting = OeeData.ToLookup(t => t.DeviceName)[deviceName]
+                 .Where(t => t.CreateTime >= DateTime.Parse(hourStartResult) & t.CreateTime < DateTime.Parse(hourEndResult));
+                foreach (var item in OeePercentSting)
+                {
+                    if (OeePercentSting.Count() == 0)
+                    {
+                        dayRunTime = 0;
+
+                    }
+                    else
+                    {
+                        dayRunTime = double.Parse(OeePercentSting.First().OeePercentage.ToString());
+                    }
+                }
+                allOeePercentage.Add(dayRunTime);
+                dayRunTime = 0;
+            }
+            return allOeePercentage;
         }
     }
 }

+ 26 - 26
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmKanbanForPressBrakeEquipment.xaml.cs

@@ -60,32 +60,32 @@ namespace SCADA_DAQ.Customer
             LocalTime.Text = DateTime.Now.ToString("dddd yyyy年MM月dd日 HH:mm");
             KanbanForPressBrakeEquipmentOne.Title = new string[] { "运行时间:",
                 "等待时间:",
-                "换模时间:",
                 "报警/维修时间:",
+                "换模时间:",
                 "维保时间:"};
 
             KanbanForPressBrakeEquipmentTwo.Title = new string[] { "运行时间:",
                 "等待时间:",
-                "换模时间:",
                 "报警/维修时间:",
+                "换模时间:",
                 "维保时间:"};
 
             KanbanForPressBrakeEquipmentThree.Title = new string[] { "运行时间:",
                 "等待时间:",
-                "换模时间:",
                 "报警/维修时间:",
+                "换模时间:",
                 "维保时间:"};
 
             KanbanForPressBrakeEquipmentFour.Title = new string[] { "运行时间:",
                 "等待时间:",
-                "换模时间:",
                 "报警/维修时间:",
+                "换模时间:",
                 "维保时间:"};
 
             KanbanForPressBrakeEquipmentFive.Title = new string[] { "运行时间:",
                 "等待时间:",
-                "换模时间:",
                 "报警/维修时间:",
+                "换模时间:",
                 "维保时间:"};
 
 
@@ -162,7 +162,7 @@ namespace SCADA_DAQ.Customer
             var baiChaoTimeMaintenanceTable = TimeSpan.FromSeconds(Math.Round(baiChaoTimeMaintenanceTableDouble)).ToString();
 
 
-            var firstYaWeiStopTime = DeviceTimeValue("1号YaWei折弯机", "停止标志位")- DevicMainTableTime("亚威一号折弯机").TotalSeconds;//1号YaWei折弯机等待时间
+            var firstYaWeiStopTime = DeviceTimeValue("1号YaWei折弯机", "停止标志位") - DevicMainTableTime("亚威一号折弯机").TotalSeconds;//1号YaWei折弯机等待时间
             var sencondYaWeiStopTime = DeviceTimeValue("2号YaWei折弯机", "停止标志位") - DevicMainTableTime("亚威二号折弯机").TotalSeconds;//2号YaWei折弯机等待时间
             var thirdYaWweiStopTime = DeviceTimeValue("3号YaWei折弯机", "停止标志位") - DevicMainTableTime("亚威三号折弯机").TotalSeconds; //3号YaWei折弯机等待时间
             var pbcYaWweiStopTime = DeviceTimeValue("亚威PBC折弯机", "停止标志位") - DevicMainTableTime("亚威PBC折弯机").TotalSeconds;//亚威PBC折弯机等待时间
@@ -194,32 +194,32 @@ namespace SCADA_DAQ.Customer
 
             KanbanForPressBrakeEquipmentOne.DeviceNameOne.Value = firstYaWeiRunTimeSpan;
             KanbanForPressBrakeEquipmentOne.DeviceNameTwo.Value = firstYaWeiStopTimeSpan;
-            KanbanForPressBrakeEquipmentOne.DeviceNameThree.Value = firstYaWeiMoldTimeSpan;
-            KanbanForPressBrakeEquipmentOne.DeviceNameFour.Value = firstYaWeiTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentOne.DeviceNameThree.Value = firstYaWeiTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentOne.DeviceNameFour.Value = firstYaWeiMoldTimeSpan;
             KanbanForPressBrakeEquipmentOne.DeviceNameFive.Value = firstYaWeiRepairTime;
 
             KanbanForPressBrakeEquipmentTwo.DeviceNameOne.Value = sencondYaWeiRunTimeSpan;
             KanbanForPressBrakeEquipmentTwo.DeviceNameTwo.Value = sencondYaWeiStopTimeSpan;
-            KanbanForPressBrakeEquipmentTwo.DeviceNameThree.Value = sencondYaWeiMoldTimeSpan;
-            KanbanForPressBrakeEquipmentTwo.DeviceNameFour.Value = secondYaWeiTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentTwo.DeviceNameThree.Value = secondYaWeiTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentTwo.DeviceNameFour.Value = sencondYaWeiMoldTimeSpan;
             KanbanForPressBrakeEquipmentTwo.DeviceNameFive.Value = secondYaWeiRepairTime;
 
             KanbanForPressBrakeEquipmentThree.DeviceNameOne.Value = thirdYaWweiRunTimeSpan;
             KanbanForPressBrakeEquipmentThree.DeviceNameTwo.Value = thirdYaWweiStopTimeSpan;
-            KanbanForPressBrakeEquipmentThree.DeviceNameThree.Value = thirdYaWweiMoldTimeSpan;
-            KanbanForPressBrakeEquipmentThree.DeviceNameFour.Value = thirdYaWeiTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentThree.DeviceNameThree.Value = thirdYaWeiTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentThree.DeviceNameFour.Value = thirdYaWweiMoldTimeSpan;
             KanbanForPressBrakeEquipmentThree.DeviceNameFive.Value = thirdYaWeiRepairTime;
 
             KanbanForPressBrakeEquipmentFour.DeviceNameOne.Value = pbcYaWweiRunTimeSpan;
             KanbanForPressBrakeEquipmentFour.DeviceNameTwo.Value = pbcYaWweiStopTimeSpan;
-            KanbanForPressBrakeEquipmentFour.DeviceNameThree.Value = pbcYaWweiMoldTimeSpan;
-            KanbanForPressBrakeEquipmentFour.DeviceNameFour.Value = pbcYaWweiTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentFour.DeviceNameThree.Value = pbcYaWweiTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentFour.DeviceNameFour.Value =  pbcYaWweiMoldTimeSpan;
             KanbanForPressBrakeEquipmentFour.DeviceNameFive.Value = pbcYaWweiRepairTime;
 
             KanbanForPressBrakeEquipmentFive.DeviceNameOne.Value = baiChaoRunTimeSpan;
             KanbanForPressBrakeEquipmentFive.DeviceNameTwo.Value = baiChaoStopTimeSpan;
-            KanbanForPressBrakeEquipmentFive.DeviceNameThree.Value = baiChaoMoldTimeSpan;
-            KanbanForPressBrakeEquipmentFive.DeviceNameFour.Value = baiChaoTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentFive.DeviceNameThree.Value = baiChaoTimeMaintenanceTable;
+            KanbanForPressBrakeEquipmentFive.DeviceNameFour.Value =  baiChaoMoldTimeSpan;
             KanbanForPressBrakeEquipmentFive.DeviceNameFive.Value = baiChaoRepairTime;
             Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
         }
@@ -474,32 +474,32 @@ namespace SCADA_DAQ.Customer
                     {
                         KanbanForPressBrakeEquipmentOne.DeviceNameOne.Value = firstYaWeiRunTimeSpan;
                         KanbanForPressBrakeEquipmentOne.DeviceNameTwo.Value = firstYaWeiStopTimeSpan;
-                        KanbanForPressBrakeEquipmentOne.DeviceNameThree.Value = firstYaWeiMoldTimeSpan;
-                        KanbanForPressBrakeEquipmentOne.DeviceNameFour.Value = firstYaWeiTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentOne.DeviceNameThree.Value = firstYaWeiTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentOne.DeviceNameFour.Value = firstYaWeiMoldTimeSpan;
                         KanbanForPressBrakeEquipmentOne.DeviceNameFive.Value = firstYaWeiRepairTime;
 
                         KanbanForPressBrakeEquipmentTwo.DeviceNameOne.Value = sencondYaWeiRunTimeSpan;
                         KanbanForPressBrakeEquipmentTwo.DeviceNameTwo.Value = sencondYaWeiStopTimeSpan;
-                        KanbanForPressBrakeEquipmentTwo.DeviceNameThree.Value = sencondYaWeiMoldTimeSpan;
-                        KanbanForPressBrakeEquipmentTwo.DeviceNameFour.Value = secondYaWeiTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentTwo.DeviceNameThree.Value = secondYaWeiTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentTwo.DeviceNameFour.Value = sencondYaWeiMoldTimeSpan;
                         KanbanForPressBrakeEquipmentTwo.DeviceNameFive.Value = secondYaWeiRepairTime;
 
                         KanbanForPressBrakeEquipmentThree.DeviceNameOne.Value = thirdYaWweiRunTimeSpan;
                         KanbanForPressBrakeEquipmentThree.DeviceNameTwo.Value = thirdYaWweiStopTimeSpan;
-                        KanbanForPressBrakeEquipmentThree.DeviceNameThree.Value = thirdYaWweiMoldTimeSpan;
-                        KanbanForPressBrakeEquipmentThree.DeviceNameFour.Value = thirdYaWeiTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentThree.DeviceNameThree.Value = thirdYaWeiTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentThree.DeviceNameFour.Value = thirdYaWweiMoldTimeSpan;
                         KanbanForPressBrakeEquipmentThree.DeviceNameFive.Value = thirdYaWeiRepairTime;
 
                         KanbanForPressBrakeEquipmentFour.DeviceNameOne.Value = pbcYaWweiRunTimeSpan;
                         KanbanForPressBrakeEquipmentFour.DeviceNameTwo.Value = pbcYaWweiStopTimeSpan;
-                        KanbanForPressBrakeEquipmentFour.DeviceNameThree.Value = pbcYaWweiMoldTimeSpan;
-                        KanbanForPressBrakeEquipmentFour.DeviceNameFour.Value = pbcYaWweiTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentFour.DeviceNameThree.Value = pbcYaWweiTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentFour.DeviceNameFour.Value = pbcYaWweiMoldTimeSpan;
                         KanbanForPressBrakeEquipmentFour.DeviceNameFive.Value = pbcYaWweiRepairTime;
 
                         KanbanForPressBrakeEquipmentFive.DeviceNameOne.Value = baiChaoRunTimeSpan;
                         KanbanForPressBrakeEquipmentFive.DeviceNameTwo.Value = baiChaoStopTimeSpan;
-                        KanbanForPressBrakeEquipmentFive.DeviceNameThree.Value = baiChaoMoldTimeSpan;
-                        KanbanForPressBrakeEquipmentFive.DeviceNameFour.Value = baiChaoTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentFive.DeviceNameThree.Value = baiChaoTimeMaintenanceTable;
+                        KanbanForPressBrakeEquipmentFive.DeviceNameFour.Value = baiChaoMoldTimeSpan;
                         KanbanForPressBrakeEquipmentFive.DeviceNameFive.Value = baiChaoRepairTime;
                     }));
                 }

+ 1 - 1
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmMachineRepairTimeQuery.xaml.cs

@@ -22,7 +22,7 @@ namespace SCADA_DAQ.Customer
     /// <summary>
     /// UctFrmMachineRepairTimeQuery.xaml 的交互逻辑
     /// </summary>
-    [UctMenu("设备维修时间查询",Icon ="查询")]
+    [UctMenu("设备断电维修时间查询",Icon ="查询")]
     public partial class UctFrmMachineRepairTimeQuery : BaseUctFrm<QueryMachinRepairModel>
     {
         public UctFrmMachineRepairTimeQuery()

+ 54 - 66
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmRunHistory.xaml.cs

@@ -4,11 +4,13 @@ using Mysqlx.Crud;
 using NPOI.SS.Formula.Eval;
 using NPOI.SS.Formula.Functions;
 using SCADA.CommonCtrl.WpfControl;
+using SCADA.CommonLib;
 using SCADA.CommonLib.Data.DIL.Sqlite;
 using SCADA.CommonLib.Helper;
 using SCADA_DAQ.Customer.Models.AlarmTime;
 using SCADA_DAQ.Customer.Models.DeviceInfoTime;
 using SCADA_DAQ.Customer.Models.DistinctTimePiece;
+using SCADA_DAQ.Customer.Models.OEEData;
 using SCADA_DAQ.Customer.Models.ScheduleStop;
 using SqlSchema.DBNames;
 using System;
@@ -46,78 +48,64 @@ namespace SCADA_DAQ.Customer
         public UctFrmRunHistory()
         {
             InitializeComponent();
-
-            //    var timeListAdd = new List<List<TimePiece>>();
-            //    var timeStopTime = DAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>().ToLookup(t => t.Device)["激光机"];
-            //    var timeStopPieces = new List<TimePiece>();
-            //    if (timeStopTime.Count() != 0)
-            //    {
-            //        foreach (var item in timeStopTime)
-            //        {
-            //            timeStopPieces.Add(new TimePiece
-            //            {
-            //                StartTime = Convert.ToDateTime(item.StartTime.ToString()).TimeOfDay,
-            //                EndTime = Convert.ToDateTime(item.EndTime.ToString()).TimeOfDay
-            //            });
-            //        }
-            //    }
-
-            //    var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
-            //    var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-            //    var informationValue = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToLookup(t => t.Device_Str)["激光机"];
-
-            //    var classesYesterdayStartTime = Convert.ToDateTime(DateTime.Now.AddDays(-1).Date);
-            //    var classesDayEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-            //    var deviceValueInformation = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesYesterdayStartTime & t.CreateTime <= classesDayEndTime).ToLookup(t => t.Device_Str)["激光机"];
-
-            //    var timePieces = new List<TimePiece>();
-            //    if (deviceValueInformation.Count() != 0)
-            //    {
-            //        foreach (var item in deviceValueInformation)
-            //        {
-            //            if (item.StartTime < Convert.ToDateTime(DateTime.Now.ToString("00:00:00")) & item.EndTime > Convert.ToDateTime(DateTime.Now.ToString("00:00:00")))
-            //            {
-            //                timePieces.Add(new TimePiece
-            //                {
-            //                    StartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00")).TimeOfDay,
-            //                    EndTime = item.EndTime.TimeOfDay
-            //                });
-            //            }
-
-            //        }
-
-            //    }
-            //    if (informationValue.Count() != 0)
-            //    {
-            //        foreach (var item in informationValue)
-            //        {
-            //            timePieces.Add(new TimePiece
-            //            {
-            //                StartTime = item.StartTime.TimeOfDay,
-            //                EndTime = item.EndTime.TimeOfDay
-            //            });
-            //        }
-            //    }
-
-            //   if(timePieces.Count() == 0 )
-            //    {
-            //        timePieces = new List<TimePiece>() {
-
-            //              new TimePiece{StartTime =TimeSpan.FromSeconds(DateTime.Now.ToOADate()) ,
-            //                  EndTime = TimeSpan.FromSeconds(DateTime.Now.ToOADate())},
-            //             };
-            //    }
-            //    var total = TimeTotalHelper.DistinctPlanStopTime(TimeTotalHelper.DistinctTime(timePieces), timeStopPieces);
-
+          var  uuu = Convert.ToDecimal(Math.Round(Convert.ToDouble(198) / 273, 4));
 
         }
+        //public List<MachineInfoModel> OeeData { get; set; }
+
+        //public List<TimeSection> Days { get; set; }
+        //public void GetOeeData()
+        //{
+        //    Days = DateTimeHelper.GetDays(DateTimeHelper.ToMonthStart(DateTime.Now), DateTimeHelper.ToMonthEnd(DateTime.Now));
+        //    var first = DateTime.Parse(Days.First().StartTime.ToString());
+        //    var last = DateTime.Parse(Days.Last().EndTime.ToString());
+        //    OeeData = Env.SqlDAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>();
+        //    var deviceMonthTime = OeeData.Where(t => t.CreateTime >= first & t.CreateTime <= last);
+        //}
+        //public List<double> OeePercent(string deviceName, string deviceCode)
+        //{
+        //    var allTime = new List<double>();
+        //    var dayAllTime = 0;
+        //    var runTime = new List<double>();
+        //    var dayRunTime = 0;
+        //    for (int i = 0; i < Days.Count; i++)
+        //    {
+        //        var hourStartResult = Days[i].StartTime.Format();
+        //        var hourEndResult = Days[i].EndTime.Format();
+        //        var deviceDayTIme = OeeData.ToLookup(t => t.Device)[deviceName]
+        //         .Where(t => t.CreateTime >= DateTime.Parse(hourStartResult) & t.CreateTime < DateTime.Parse(hourEndResult));
+        //        foreach (var item in deviceDayTIme)
+        //        {
+        //            dayAllTime = item.DurationSec + dayAllTime;
+
+        //        }
+        //        var deviceRunDayTIme = OeeData.ToLookup(t => t.Device)[deviceName].ToLookup(t => t.StateCode)[deviceCode]
+        //            .Where(t => t.CreateTime >= DateTime.Parse(hourStartResult) & t.CreateTime < DateTime.Parse(hourEndResult));
+        //        foreach (var item in deviceRunDayTIme)
+        //        {
+        //            dayRunTime = item.DurationSec + dayRunTime;
+        //        }
+        //        if (dayAllTime != 0)
+        //        {
+        //            var oeeValue = Convert.ToDouble(dayRunTime) / dayAllTime;
+        //            //var percentOeeValue = oeeValue.ToString("0.##%");
+        //            allTime.Add(Math.Round(oeeValue, 2));
+        //        }
+        //        else
+        //        {
+        //            allTime.Add(0);
+        //        }
+        //        dayAllTime = 0;
+        //        dayRunTime = 0;
+        //    }
+        //    return allTime;
+        //}
 
-    }
-
-       
 
     }
 
+}
+
 
 
 

+ 6 - 7
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Dashboard/LaserAndDigitalPunchingEquipmentWidget.xaml.cs

@@ -166,21 +166,21 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             LaserCountingPunchesOne.DeviceNameThree.Value = laserArlamString;
             LaserCountingPunchesOne.DeviceNameFour.Value = laserRepairTime;
             //LaserCountingPunchesOne.DeviceNameFive.Value = Time.ToString();
-;           LaserCountingPunchesOne.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(laserCeShi)).ToString();
+;      /*     LaserCountingPunchesOne.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(laserCeShi)).ToString();*/
 
             LaserCountingPunchesTwo.DeviceNameOne.Value = siemensRunTimeSpan;
             LaserCountingPunchesTwo.DeviceNameTwo.Value = siemensStopTimeSpan;
             LaserCountingPunchesTwo.DeviceNameThree.Value = siemensArlamString;
             LaserCountingPunchesTwo.DeviceNameFour.Value = siemensMoldTimeSpan;
             LaserCountingPunchesTwo.DeviceNameFive.Value = siemensRepairTime;
-            LaserCountingPunchesTwo.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(siemensCeShi)).ToString();
+            //LaserCountingPunchesTwo.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(siemensCeShi)).ToString();
 
             LaserCountingPunchesThree.DeviceNameOne.Value = behwiftRunTimeSpan;
             LaserCountingPunchesThree.DeviceNameTwo.Value = behwiftStopTimeSpan;
             LaserCountingPunchesThree.DeviceNameThree.Value = behwiftArlamString;
             LaserCountingPunchesThree.DeviceNameFour.Value = behwiftMoldTimeSpan;
             LaserCountingPunchesThree.DeviceNameFive.Value = behwifRepairTime;
-            LaserCountingPunchesThree.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(behwiftCeShi)).ToString();
+            //LaserCountingPunchesThree.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(behwiftCeShi)).ToString();
             // 界面文本
             LaserCountingPunchesOne.Title = new string[] { "激光机运行时间:",
                 "激光机等待时间:",
@@ -566,21 +566,20 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
                         LaserCountingPunchesOne.DeviceNameThree.Value = laserArlamString;
                         LaserCountingPunchesOne.DeviceNameFour.Value = laserRepairTime;
                         //LaserCountingPunchesOne.DeviceNameFive.Value = Time.ToString();
-                        ; LaserCountingPunchesOne.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(laserCeShi)).ToString();
-
+                     
                         LaserCountingPunchesTwo.DeviceNameOne.Value = siemensRunTimeSpan;
                         LaserCountingPunchesTwo.DeviceNameTwo.Value = siemensStopTimeSpan;
                         LaserCountingPunchesTwo.DeviceNameThree.Value = siemensArlamString;
                         LaserCountingPunchesTwo.DeviceNameFour.Value = siemensMoldTimeSpan;
                         LaserCountingPunchesTwo.DeviceNameFive.Value = siemensRepairTime;
-                        LaserCountingPunchesTwo.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(siemensCeShi)).ToString();
+                
 
                         LaserCountingPunchesThree.DeviceNameOne.Value = behwiftRunTimeSpan;
                         LaserCountingPunchesThree.DeviceNameTwo.Value = behwiftStopTimeSpan;
                         LaserCountingPunchesThree.DeviceNameThree.Value = behwiftArlamString;
                         LaserCountingPunchesThree.DeviceNameFour.Value = behwiftMoldTimeSpan;
                         LaserCountingPunchesThree.DeviceNameFive.Value = behwifRepairTime;
-                        LaserCountingPunchesThree.DeviceNameSix.Value = TimeSpan.FromSeconds(Math.Round(behwiftCeShi)).ToString();
+                    
                     }));
 
                 }

+ 6 - 5
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctDeviceChart.xaml

@@ -5,11 +5,12 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:SCADA_DAQ.Customer.Views.Uct" xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=SCADA.CommonCtrl"
              mc:Ignorable="d" 
+             x:Name="this"
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid>
-        <lvc:CartesianChart DisableAnimations="True" Margin="4" Grid.Row="1">
+        <lvc:CartesianChart DisableAnimations="True" Margin="4" Grid.Row="1" DataClick="CartesianChart_DataClick">
             <lvc:CartesianChart.AxisX>
-                <lvc:Axis MaxValue="22" x:Name="Axisx" ShowLabels="True" >
+                <lvc:Axis x:Name="Axisx" ShowLabels="True" MinValue="1">
                     <lvc:Axis.Separator>
                         <lvc:Separator  x:Name="XSeparator" Stroke="{DynamicResource MahApps.Brushes.Gray8}" Step="1"/>
                     </lvc:Axis.Separator>
@@ -18,17 +19,17 @@
 
             <lvc:CartesianChart.AxisY>
                 <lvc:Axis x:Name="AxisY" 
-                         MinValue="0" MaxValue="20" ShowLabels="True">
+                         MinValue="0" MaxValue="1" ShowLabels="True">
                     <lvc:Axis.Separator >
                         <lvc:Separator  x:Name="YSeparator" 
-                                            Step="20" 
+                                            Step="1" 
                                             Stroke="{DynamicResource MahApps.Brushes.Gray8}" />
                     </lvc:Axis.Separator>
                 </lvc:Axis>
              </lvc:CartesianChart.AxisY>
 
             <lvc:CartesianChart.Series>
-                <lvc:LineSeries  x:Name="Cloum1" Title="流量计:L/Min" DataLabels="True" ScalesYAt="1"/>
+                <lvc:LineSeries  x:Name ="OeeValue"  DataLabels="True" ScalesYAt="1" />
             </lvc:CartesianChart.Series>
         </lvc:CartesianChart>
     </Grid>

+ 23 - 1
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctDeviceChart.xaml.cs

@@ -1,4 +1,8 @@
-using System;
+using LiveCharts;
+using LiveCharts.Configurations;
+using LiveCharts.Wpf;
+using SCADA_DAQ.Customer.Models.OEEData;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -23,6 +27,24 @@ namespace SCADA_DAQ.Customer.Views.Uct
         public UctDeviceChart()
         {
             InitializeComponent();
+            var mapper = Mappers.Xy<OeeAxisXYModels>()
+                             .X(model => model.Indx)
+                             .Y(model => model.Value);
+            Charting.For<OeeAxisXYModels>(mapper);
+            OeeValue.Values = new ChartValues<OeeAxisXYModels>();
+            List<double> values = new List<double>() { 0.3, 0.4, 0.5, 0.6, 0.8 };
+            List<double> Indxvalues = new List<double>() { 1, 2, 3, 4, 5 };
+            for (int i = 0; i < values.Count(); i++)
+            {
+                OeeValue.Values.Add(new OeeAxisXYModels { Indx = Indxvalues[i], Value = values[i] });
+            
+            }
+
+        }
+
+        private void CartesianChart_DataClick(object sender, LiveCharts.ChartPoint chartPoint)
+        {
+
         }
     }
 }

+ 2 - 3
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctDeviceInformationControls.xaml

@@ -17,15 +17,14 @@
                 <RowDefinition/>
                 <RowDefinition/>
                 <RowDefinition/>
-                <RowDefinition/>
-            </Grid.RowDefinitions> 
+           </Grid.RowDefinitions> 
             <local:UctMidcard Title="{Binding Text,ElementName=this}" FontSize="22" Margin="8.8" HorizontalAlignment="Left" />
             <local:UctNameTheTimeControl Grid.Row="1" Title="{Binding Title[0],ElementName=this}" Margin="8.8" x:Name="DeviceNameOne"/>
             <local:UctNameTheTimeControl Grid.Row="2" Title="{Binding Title[1],ElementName=this}" Margin="8.8" x:Name="DeviceNameTwo"/>
             <local:UctNameTheTimeControl Grid.Row="3" Title="{Binding Title[2],ElementName=this}" Margin="8.8" x:Name="DeviceNameThree"/>
             <local:UctNameTheTimeControl Grid.Row="4" Title="{Binding Title[3],ElementName=this}" Margin="8.8" x:Name="DeviceNameFour"/>
             <local:UctNameTheTimeControl Grid.Row="5" Title="{Binding Title[4],ElementName=this}" Margin="8.8" x:Name="DeviceNameFive"/>
-            <local:UctNameTheTimeControl Grid.Row="6" Title="{Binding Title[5],ElementName=this}" Margin="8.8" x:Name="DeviceNameSix"/>
+            <!--<local:UctNameTheTimeControl Grid.Row="6" Title="{Binding Title[5],ElementName=this}" Margin="8.8" x:Name="DeviceNameSix"/>-->
         </Grid>
     </Grid>
 </UserControl>

+ 1 - 3
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctDeviceInformationControlsSencd.xaml

@@ -18,8 +18,6 @@
                 <RowDefinition/>
                 <RowDefinition/>
                 <RowDefinition/>
-                <RowDefinition/>
-        
             </Grid.RowDefinitions>
             <local:UctMidcard Title="{Binding Text,ElementName=this}" FontSize="22"  Margin="8.8"/>
             <local:UctNameTheTimeControlSencd Title="{Binding Title[0],ElementName=this}" Margin="8.8" x:Name="DeviceNameOne" Grid.Row="1"  />
@@ -27,7 +25,7 @@
             <local:UctNameTheTimeControlSencd Grid.Row="3" Title="{Binding Title[2],ElementName=this}" Margin="8.8" x:Name="DeviceNameThree"/>
             <local:UctNameTheTimeControlSencd Grid.Row="4" Title="{Binding Title[3],ElementName=this}" Margin="8.8" x:Name="DeviceNameFour"/>
             <local:UctNameTheTimeControlSencd Grid.Row="5" Title="{Binding Title[4],ElementName=this}" Margin="8.8" x:Name="DeviceNameFive"/>
-            <local:UctNameTheTimeControlSencd Grid.Row="6" Title="{Binding Title[5],ElementName=this}" Margin="8.8" x:Name="DeviceNameSix"/>
+            <!--<local:UctNameTheTimeControlSencd Grid.Row="6" Title="{Binding Title[5],ElementName=this}" Margin="8.8" x:Name="DeviceNameSix"/>-->
          </Grid>
     </Grid>
 </UserControl>

+ 1 - 1
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Env.cs

@@ -30,7 +30,7 @@ namespace SCADA_DAQ
         //public static SqlSchema.DIL.DILDB SqlDAL = new SqlSchema.DIL.DILDB("10.163.96.79", "Vertiv", "sa", "1qaz2wsx");
 
         public static SqlSchema.DIL.DILDB SqlDAL = new SqlSchema.DIL.DILDB("127.0.0.1", "Vertiv", "sa", "M+123456");
-         //public static SqlSchema.DIL.DILDB SqlDAL = new SqlSchema.DIL.DILDB("10.163.96.79", "Vertiv", "sa", "1qaz2wsx");
+       //public static SqlSchema.DIL.DILDB SqlDAL = new SqlSchema.DIL.DILDB("10.163.96.79", "Vertiv", "sa", "1qaz2wsx");
 
         //public static SqlSchema.DIL.DILDB SqlDAL;
 

File diff suppressed because it is too large
+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/SCADA_DAQ.csproj


Some files were not shown because too many files changed in this diff