Browse Source

临时提交

谢翼翔 1 year ago
parent
commit
eafebeb7ba

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

@@ -9,6 +9,7 @@ using SCADA.CommonLib.Data.DIL;
 using SCADA.CommonLib.Data.DIL.Sqlite;
 using SCADA.Drive.Siemens.CNC840DA.Da;
 using SCADA_DAQ.Customer.Models;
+using SCADA_DAQ.Customer.Models.AlarmTime;
 using SCADA_DAQ.Customer.Models.DeviceInfoTime;
 using SCADA_DAQ.Customer.Models.ScheduleStop;
 using SqlSchema.DBNames;
@@ -87,22 +88,22 @@ namespace SCADA_DAQ.Customer
                 "换模时间:",
                 "报警/维修时间:",
                 "维保时间:"};
-           
 
-            var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
-            var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间
 
-            var sencondYaWeiRunTime = DeviceTimeValue("2号YaWei折弯机", "运行标志位");//2号YaWei折弯机运行时间
-            var sencondYaWeiMoldTime = DeviceTimeValue("2号YaWei折弯机", "换模标志位");//2号YaWei折弯机换模时间
+            var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
+            var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间
 
-            var thirdYaWweiRunTime = DeviceTimeValue("3号YaWei折弯机", "运行标志位"); ;//3号YaWei折弯机运行时间
-            var thirdYaWweiMoldTime = DeviceTimeValue("3号YaWei折弯机", "换模标志位");//3号YaWei折弯机换模时间
+            var sencondYaWeiRunTime = DeviceTimeValue("2号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "运行标志位");//2号YaWei折弯机运行时间
+            var sencondYaWeiMoldTime = DeviceTimeValue("2号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "换模标志位");//2号YaWei折弯机换模时间
 
-            var pbcYaWweiRunTime = DeviceTimeValue("亚威PBC折弯机", "运行标志位"); ;//亚威PBC折弯机运行时间
-            var pbcYaWweiMoldTime = DeviceTimeValue("亚威PBC折弯机", "换模标志位");//亚威PBC折弯机换模时间
+            var thirdYaWweiRunTime = DeviceTimeValue("3号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "运行标志位"); ;//3号YaWei折弯机运行时间
+            var thirdYaWweiMoldTime = DeviceTimeValue("3号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "换模标志位");//3号YaWei折弯机换模时间
 
-            var baiChaoRunTime = DeviceTimeValue("百超折弯机", "运行标志位"); ;//百超折弯机运行时间
-            var baiChaoMoldTime = DeviceTimeValue("百超折弯机", "换模标志位");//百超折弯机换模时间
+            var pbcYaWweiRunTime = DeviceTimeValue("亚威PBC折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "运行标志位"); ;//亚威PBC折弯机运行时间
+            var pbcYaWweiMoldTime = DeviceTimeValue("亚威PBC折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "换模标志位");//亚威PBC折弯机换模时间
+
+            var baiChaoRunTime = DeviceTimeValue("百超折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("百超折弯机", "运行标志位"); ;//百超折弯机运行时间
+            var baiChaoMoldTime = DeviceTimeValue("百超折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("百超折弯机", "换模标志位");//百超折弯机换模时间
 
 
             var firstYaWeiRepairTime = "倒计时" + DeviceRepairTime("亚威一号折弯机").ToString() + "天";//亚威一号折弯机设备保养信息
@@ -111,24 +112,28 @@ namespace SCADA_DAQ.Customer
             var pbcYaWweiRepairTime = "倒计时" + DeviceRepairTime("亚威PBC折弯机").ToString() + "天";//亚威PBC折弯机设备保养信息
             var baiChaoRepairTime = "倒计时" + DeviceRepairTime("百超折弯机").ToString() + "天";//百超折弯机设备保养信息
 
-            var firstYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威一号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("1号YaWei折弯机", "维修时间")));
-            var secondYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威二号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("2号YaWei折弯机", "维修时间")));
-            var thirdYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威三号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("3号YaWei折弯机", "维修时间")));
-            var pbcYaWweiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威PBC折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("亚威PBC折弯机", "维修时间")));
-            var baiChaoTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("百超折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("百超折弯机", "维修时间")));
-
+            var firstYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威一号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("1号YaWei折弯机", "维修时间"))
+                - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "维修时间")));
+            var secondYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威二号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("2号YaWei折弯机", "维修时间"))
+                - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "维修时间")));
+            var thirdYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威三号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("3号YaWei折弯机", "维修时间"))
+                - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "维修时间")));
+            var pbcYaWweiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威PBC折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("亚威PBC折弯机", "维修时间"))
+                - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "维修时间")));
+            var baiChaoTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("百超折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("百超折弯机", "维修时间"))
+                - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("百超折弯机", "维修时间")));
 
             double totalTimeOfDay = TimeSpan.Parse(DateTime.Now.ToString("HH:mm:ss")).TotalSeconds;
-            var firstYaWeiStopTime = totalTimeOfDay - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
-                 - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("1号YaWei折弯机");//1号YaWei折弯机等待时间
+            var firstYaWeiStopTime = totalTimeOfDay - firstYaWeiRunTime - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
+                - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "维修时间");//1号YaWei折弯机等待时间
             var sencondYaWeiStopTime = totalTimeOfDay - sencondYaWeiRunTime - sencondYaWeiMoldTime - DevicScheduleStop("2号YaWei折弯机")
-                - DevicMainTableTime("亚威二号折弯机").TotalSeconds - DeviceTimeValue("2号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("2号YaWei折弯机");//2号YaWei折弯机等待时间
+                - DevicMainTableTime("亚威二号折弯机").TotalSeconds - DeviceTimeValue("2号YaWei折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "维修时间");//2号YaWei折弯机等待时间
             var thirdYaWweiStopTime = totalTimeOfDay - thirdYaWweiRunTime - thirdYaWweiMoldTime - DevicScheduleStop("3号YaWei折弯机")
-                - DevicMainTableTime("亚威三号折弯机").TotalSeconds - DeviceTimeValue("3号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("3号YaWei折弯机");//3号YaWei折弯机等待时间
+                - DevicMainTableTime("亚威三号折弯机").TotalSeconds - DeviceTimeValue("3号YaWei折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "维修时间"); //3号YaWei折弯机等待时间
             var pbcYaWweiStopTime = totalTimeOfDay - pbcYaWweiRunTime - pbcYaWweiMoldTime - DevicScheduleStop("亚威PBC折弯机")
-                - DevicMainTableTime("亚威PBC折弯机").TotalSeconds - DeviceTimeValue("亚威PBC折弯机", "维修时间") + DeviceScheduleStopBetweenTime("亚威PBC折弯机");//亚威PBC折弯机等待时间
+                - DevicMainTableTime("亚威PBC折弯机").TotalSeconds - DeviceTimeValue("亚威PBC折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "维修时间");//亚威PBC折弯机等待时间
             var baiChaoStopTime = totalTimeOfDay - baiChaoRunTime - baiChaoMoldTime - DevicScheduleStop("百超折弯机")
-                - DevicMainTableTime("百超折弯机").TotalSeconds - DeviceTimeValue("百超折弯机", "维修时间") + DeviceScheduleStopBetweenTime("百超折弯机");//百超折弯机折弯机等待时间
+                - DevicMainTableTime("百超折弯机").TotalSeconds - DeviceTimeValue("百超折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("百超折弯机", "维修时间");//百超折弯机折弯机等待时间
 
             var firstYaWeiRunTimeSpan = TimeSpan.FromSeconds(Math.Round(firstYaWeiRunTime)).ToString();
             var firstYaWeiStopTimeSpan = TimeSpan.FromSeconds(Math.Round(firstYaWeiStopTime)).ToString();
@@ -287,27 +292,55 @@ namespace SCADA_DAQ.Customer
 
         public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
 
-        public int DeviceScheduleStopBetWeenTime { get; set; }
+        public int DeviceStateCodeScheduleStopBetWeenTime { get; set; }
 
-        public List<int> DeviceScheduleStopBetweenTimeList { get; set; }
+        public List<int> DeviceStateCodeScheduleStopBetweenTimeList { get; set; }
 
-        public int IntValue { get; set; }
+        public int DeviceStateCodeIntValue { get; set; }
         public void GetDeviceScheduleStopBetweenTime()
         {
             DeviceScheduleStopInformation = Env.SqlDAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
             DeviceMachineInformation = Env.SqlDAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>();
         }
-        public double DeviceScheduleStopBetweenTime(string deviceName)
+        public double DeviceStateCodeStopBetweenTime(string deviceName, string deviceStateCode)
         {
-
+            DeviceStateCodeIntValue = 0;
             List<int> DeviceValue = new List<int>();
             var deviceScheduleStop = DeviceScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
             foreach (var item in deviceScheduleStop)
             {
+                var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
+                var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
+                var deviceBetweenTime = DeviceMachineInformation.ToLookup(t => t.Device)[deviceName].ToLookup(t => t.StateCode)[deviceStateCode]?
+                .Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                DeviceStateCodeScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
+                DeviceValue.Add(DeviceStateCodeScheduleStopBetWeenTime);
+            }
+
+            DeviceStateCodeScheduleStopBetweenTimeList = DeviceValue;
+            for (int i = 0; i < DeviceStateCodeScheduleStopBetweenTimeList.Count; i++)
+            {
+                DeviceStateCodeIntValue = DeviceStateCodeScheduleStopBetweenTimeList[i] + DeviceStateCodeIntValue;
+            }
+            return DeviceStateCodeIntValue;
+        }
+
+        public int DeviceScheduleStopBetWeenTime { get; set; }
 
+        public List<int> DeviceScheduleStopBetweenTimeList { get; set; }
+
+        public int DeviceIntValue { get; set; }
+
+        public double DeviceScheduleStopBetweenTime(string deviceName)
+        {
+            DeviceIntValue = 0;
+            List<int> DeviceValue = new List<int>();
+            var deviceScheduleStop = DeviceScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
+            foreach (var item in deviceScheduleStop)
+            {
                 var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
                 var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
-                var deviceBetweenTime = DeviceMachineInformation?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                var deviceBetweenTime = DeviceMachineInformation.ToLookup(t => t.Device)[deviceName]?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
                 DeviceScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
                 DeviceValue.Add(DeviceScheduleStopBetWeenTime);
             }
@@ -315,12 +348,11 @@ namespace SCADA_DAQ.Customer
             DeviceScheduleStopBetweenTimeList = DeviceValue;
             for (int i = 0; i < DeviceScheduleStopBetweenTimeList.Count; i++)
             {
-                IntValue = DeviceScheduleStopBetweenTimeList[i] + IntValue;
+                DeviceIntValue = DeviceScheduleStopBetweenTimeList[i] + DeviceIntValue;
             }
-            return IntValue;
+            return DeviceIntValue;
         }
 
-
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
         {
 
@@ -334,27 +366,22 @@ namespace SCADA_DAQ.Customer
                     GetRepairTime();
                     GetScheduleStopTime();
                     GetDeviceScheduleStopBetweenTime();
-                    double totalTimeOfDay = TimeSpan.Parse(DateTime.Now.ToString("HH:mm:ss")).TotalSeconds;
-                    var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
-                    //var firstYaWeiStopTime = DeviceTimeValue("1号YaWei折弯机", "停止标志位") - DevicScheduleStop("1号YaWei折弯机");//1号YaWei折弯机等待时间
-                    var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间
 
-                    var sencondYaWeiRunTime = DeviceTimeValue("2号YaWei折弯机", "运行标志位");//2号YaWei折弯机运行时间
-                    //var sencondYaWeiStopTime = DeviceTimeValue("2号YaWei折弯机", "停止标志位") - DevicScheduleStop("2号YaWei折弯机");//2号YaWei折弯机等待时间
-                    var sencondYaWeiMoldTime = DeviceTimeValue("2号YaWei折弯机", "换模标志位");//2号YaWei折弯机换模时间
 
-                    var thirdYaWweiRunTime = DeviceTimeValue("3号YaWei折弯机", "运行标志位"); ;//3号YaWei折弯机运行时间
-                    //var thirdYaWweiStopTime = DeviceTimeValue("3号YaWei折弯机", "停止标志位") - DevicScheduleStop("3号YaWei折弯机");//3号YaWei折弯机等待时间
-                    var thirdYaWweiMoldTime = DeviceTimeValue("3号YaWei折弯机", "换模标志位");//3号YaWei折弯机换模时间
+                    var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
+                    var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间
 
-                    var pbcYaWweiRunTime = DeviceTimeValue("亚威PBC折弯机", "运行标志位"); ;//亚威PBC折弯机运行时间
-                    //var pbcYaWweiStopTime = DeviceTimeValue("亚威PBC折弯机", "停止标志位") - DevicScheduleStop("亚威PBC折弯机");//亚威PBC折弯机等待时间
-                    var pbcYaWweiMoldTime = DeviceTimeValue("亚威PBC折弯机", "换模标志位");//亚威PBC折弯机换模时间
+                    var sencondYaWeiRunTime = DeviceTimeValue("2号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "运行标志位");//2号YaWei折弯机运行时间
+                    var sencondYaWeiMoldTime = DeviceTimeValue("2号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "换模标志位");//2号YaWei折弯机换模时间
 
-                    var baiChaoRunTime = DeviceTimeValue("百超折弯机", "运行标志位"); ;//百超折弯机运行时间
-                    //var baiChaoStopTime = DeviceTimeValue("百超折弯机", "停止标志位") - DevicScheduleStop("百超折弯机");//百超折弯机折弯机等待时间
-                    var baiChaoMoldTime = DeviceTimeValue("百超折弯机", "换模标志位");//百超折弯机换模时间
+                    var thirdYaWweiRunTime = DeviceTimeValue("3号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "运行标志位"); ;//3号YaWei折弯机运行时间
+                    var thirdYaWweiMoldTime = DeviceTimeValue("3号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "换模标志位");//3号YaWei折弯机换模时间
 
+                    var pbcYaWweiRunTime = DeviceTimeValue("亚威PBC折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "运行标志位"); ;//亚威PBC折弯机运行时间
+                    var pbcYaWweiMoldTime = DeviceTimeValue("亚威PBC折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "换模标志位");//亚威PBC折弯机换模时间
+
+                    var baiChaoRunTime = DeviceTimeValue("百超折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("百超折弯机", "运行标志位"); ;//百超折弯机运行时间
+                    var baiChaoMoldTime = DeviceTimeValue("百超折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("百超折弯机", "换模标志位");//百超折弯机换模时间
 
 
                     var firstYaWeiRepairTime = "倒计时" + DeviceRepairTime("亚威一号折弯机").ToString() + "天";//亚威一号折弯机设备保养信息
@@ -363,23 +390,28 @@ namespace SCADA_DAQ.Customer
                     var pbcYaWweiRepairTime = "倒计时" + DeviceRepairTime("亚威PBC折弯机").ToString() + "天";//亚威PBC折弯机设备保养信息
                     var baiChaoRepairTime = "倒计时" + DeviceRepairTime("百超折弯机").ToString() + "天";//百超折弯机设备保养信息
 
-                    var firstYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威一号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("1号YaWei折弯机", "维修时间")));
-                    var secondYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威二号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("2号YaWei折弯机", "维修时间")));
-                    var thirdYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威三号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("3号YaWei折弯机", "维修时间")));
-                    var pbcYaWweiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威PBC折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("亚威PBC折弯机", "维修时间")));
-                    var baiChaoTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("百超折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("百超折弯机", "维修时间")));
+                    var firstYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威一号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("1号YaWei折弯机", "维修时间"))
+                        - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "维修时间")));
+                    var secondYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威二号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("2号YaWei折弯机", "维修时间"))
+                        - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "维修时间")));
+                    var thirdYaWeiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威三号折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("3号YaWei折弯机", "维修时间"))
+                        - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "维修时间")));
+                    var pbcYaWweiTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("亚威PBC折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("亚威PBC折弯机", "维修时间"))
+                        - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "维修时间")));
+                    var baiChaoTimeMaintenanceTable = Convert.ToString(DevicMainTableTime("百超折弯机") + TimeSpan.FromSeconds(DeviceTimeValue("百超折弯机", "维修时间"))
+                        - TimeSpan.FromSeconds(DeviceStateCodeStopBetweenTime("百超折弯机", "维修时间")));
 
-                    var firstYaWeiStopTime = totalTimeOfDay  - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
-                        - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间")+ DeviceScheduleStopBetweenTime("1号YaWei折弯机");//1号YaWei折弯机等待时间
+                    double totalTimeOfDay = TimeSpan.Parse(DateTime.Now.ToString("HH:mm:ss")).TotalSeconds;
+                    var firstYaWeiStopTime = totalTimeOfDay - firstYaWeiRunTime - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
+                        - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "维修时间");//1号YaWei折弯机等待时间
                     var sencondYaWeiStopTime = totalTimeOfDay - sencondYaWeiRunTime - sencondYaWeiMoldTime - DevicScheduleStop("2号YaWei折弯机")
-                        - DevicMainTableTime("亚威二号折弯机").TotalSeconds - DeviceTimeValue("2号YaWei折弯机", "维修时间")+ DeviceScheduleStopBetweenTime("2号YaWei折弯机");//2号YaWei折弯机等待时间
+                        - DevicMainTableTime("亚威二号折弯机").TotalSeconds - DeviceTimeValue("2号YaWei折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "维修时间");//2号YaWei折弯机等待时间
                     var thirdYaWweiStopTime = totalTimeOfDay - thirdYaWweiRunTime - thirdYaWweiMoldTime - DevicScheduleStop("3号YaWei折弯机")
-                        - DevicMainTableTime("亚威三号折弯机").TotalSeconds - DeviceTimeValue("3号YaWei折弯机", "维修时间")+ DeviceScheduleStopBetweenTime("3号YaWei折弯机");//3号YaWei折弯机等待时间
+                        - DevicMainTableTime("亚威三号折弯机").TotalSeconds - DeviceTimeValue("3号YaWei折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "维修时间"); //3号YaWei折弯机等待时间
                     var pbcYaWweiStopTime = totalTimeOfDay - pbcYaWweiRunTime - pbcYaWweiMoldTime - DevicScheduleStop("亚威PBC折弯机")
-                        - DevicMainTableTime("亚威PBC折弯机").TotalSeconds - DeviceTimeValue("亚威PBC折弯机", "维修时间")+ DeviceScheduleStopBetweenTime("亚威PBC折弯机");//亚威PBC折弯机等待时间
+                        - DevicMainTableTime("亚威PBC折弯机").TotalSeconds - DeviceTimeValue("亚威PBC折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "维修时间");//亚威PBC折弯机等待时间
                     var baiChaoStopTime = totalTimeOfDay - baiChaoRunTime - baiChaoMoldTime - DevicScheduleStop("百超折弯机")
-                        - DevicMainTableTime("百超折弯机").TotalSeconds - DeviceTimeValue("百超折弯机", "维修时间")+ DeviceScheduleStopBetweenTime("百超折弯机");//百超折弯机折弯机等待时间
-
+                        - DevicMainTableTime("百超折弯机").TotalSeconds - DeviceTimeValue("百超折弯机", "维修时间") + DeviceStateCodeStopBetweenTime("百超折弯机", "维修时间");//百超折弯机折弯机等待时间
 
                     var firstYaWeiRunTimeSpan = TimeSpan.FromSeconds(Math.Round(firstYaWeiRunTime)).ToString();
                     var firstYaWeiStopTimeSpan = TimeSpan.FromSeconds(Math.Round(firstYaWeiStopTime)).ToString();

+ 10 - 7
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmPunchingMachineEquipmentKanban.xaml.cs

@@ -260,6 +260,7 @@ namespace SCADA_DAQ.Customer
             return highDeviceWait;
         }
 
+
         public List<MachineInfoModel> DeviceMachineInformation { get; set; }
 
         public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
@@ -284,7 +285,7 @@ namespace SCADA_DAQ.Customer
 
                 var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
                 var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
-                var deviceBetweenTime = DeviceMachineInformation?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                var deviceBetweenTime = DeviceMachineInformation.ToLookup(t => t.Device)[deviceName]?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
                 DeviceScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
                 DeviceValue.Add(DeviceScheduleStopBetWeenTime);
             }
@@ -298,13 +299,15 @@ namespace SCADA_DAQ.Customer
         }
 
 
-
-
         public List<AlarmColumModel> DeviceAlarmMachineInformation { get; set; }
 
         public List<DeviceScheduleStopModel> DeviceAlarmScheduleStopInformation { get; set; }
         public int DeviceAlarmInt { get; set; }
 
+
+        public int DeviceAlarmIntValue { get; set; }
+
+
         public List<int> DeviceAlarmIntList { get; set; }
         public void GetDeviceAlarmScheduleStopBetweenTime()
         {
@@ -313,6 +316,7 @@ namespace SCADA_DAQ.Customer
             DeviceAlarmMachineInformation = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>();
         }
 
+
         public double DeviceAlarmScheduleStopBetweenTime(string deviceName)
         {
 
@@ -322,7 +326,7 @@ namespace SCADA_DAQ.Customer
             {
                 var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
                 var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
-                var deviceBetweenTime = DeviceAlarmMachineInformation?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                var deviceBetweenTime = DeviceAlarmMachineInformation.ToLookup(t => t.Device_Str)[deviceName]?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
                 DeviceAlarmInt = deviceBetweenTime.Sum(t => t.DurationSec);
                 DeviceValue.Add(DeviceAlarmInt);
             }
@@ -330,11 +334,10 @@ namespace SCADA_DAQ.Customer
             DeviceAlarmIntList = DeviceValue;
             for (int i = 0; i < DeviceAlarmIntList.Count; i++)
             {
-                DeviceAlarmInt = DeviceAlarmIntList[i] + DeviceAlarmInt;
+                DeviceAlarmIntValue = DeviceAlarmIntList[i] + DeviceAlarmIntValue;
             }
-            return DeviceAlarmInt;
+            return DeviceAlarmIntValue;
         }
-
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
         {
 

+ 15 - 15
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmRunHistory.xaml

@@ -4,24 +4,24 @@
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:SCADA_DAQ.Customer" xmlns:uct="clr-namespace:SCADA_DAQ.Customer.Views.Uct" xmlns:dashboard="clr-namespace:SCADA_DAQ.Customer.Views.Dashboard"
-                        mc:Ignorable="d" 
+      mc:Ignorable="d" 
      x:Name="this"
+      Background="LightBlue"
       d:DesignHeight="1080" d:DesignWidth="1920"
       Title="UctFrmRunHistory">
-  
-        <Grid Width="1920" Height="1080">
-            <!--<Grid.RowDefinitions>
-                <RowDefinition Height="60"/>
-                <RowDefinition/>
-            </Grid.RowDefinitions>
-            <Image x:Name="Image_Title" Grid.RowSpan="3"  Stretch="Fill"/>
-            <TextBlock x:Name="LocalTime" Foreground="White" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,10,10,0" FontWeight="Bold"/>
-            <TextBlock Text="设备运行信息" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="White" FontWeight="Bold" />-->
-            <!--<uct:UctAllDeviceInformation Margin="0,50,0,0" Grid.Row="1"/>-->
+    <Grid >
+        <Grid.RowDefinitions>
+            <RowDefinition Height="60"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <Image x:Name="Image_Title" Grid.RowSpan="3"  Stretch="Fill"/>
+        <TextBlock x:Name="LocalTime" Foreground="White" FontSize="20" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,10,10,0" FontWeight="Bold"/>
+        <TextBlock Text="设备运行信息" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="LightBlue"  FontWeight="Bold" />
+        <!--<uct:UctAllDeviceInformation Margin="0,50,0,0" Grid.Row="1"/>-->
         <!--<DatePicker  x:Name="uu" Width="100" Height="120" FontSize="30" />-->
-        <wpfcontrol:DateSelecter x:Name="Time" Title="时间计划表" />
-        <ContentControl x:Name="MaintainTime"/>
-        <TextBlock x:Name="HHHH" FontSize="100" VerticalAlignment="Center" HorizontalAlignment="Center"  Foreground="Black"/>
+        <!--<wpfcontrol:DateSelecter x:Name="Time" Title="时间计划表" />
+        <ContentControl x:Name="MaintainTime"/>-->
+        <uct:UctDeviceInformationControlsThird x:Name="PunchingMachineEquipmentKanbanOne" Text="高机冲孔机设备运行状况" Grid.Row="1"  />
     </Grid>
-  
+
 </wpfcontrol:BaseUctFrm>

+ 65 - 20
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmRunHistory.xaml.cs

@@ -37,37 +37,78 @@ namespace SCADA_DAQ.Customer
     {
         private static SqlSchema.DIL.DILDB DAL = Env.SqlDAL;
         //private static DIL.DILDB sqliteDAL = Env.DAL;
-
-
-
-
-
         public UctFrmRunHistory()
         {
             InitializeComponent();
             GetDeviceScheduleStopBetweenTime();
             GetDeviceAlarmScheduleStopBetweenTime();
-            ToolBar.Visibility = Visibility.Collapsed;
-            var Value = DeviceScheduleStopBetweenTime("1号YaWei折弯机");
-            var Alarm = DeviceAlarmScheduleStopBetweenTime("高机母线冲剪机");
+
+            PunchingMachineEquipmentKanbanOne.DeviceNameOne.Value = TimeSpan.FromSeconds(Math.Round(DeviceScheduleStopBetweenTime("1号YaWei折弯机"))).ToString();
+            PunchingMachineEquipmentKanbanOne.DeviceNameTwo.Value = TimeSpan.FromSeconds(Math.Round(DeviceAlarmScheduleStopBetweenTime("西门子840D数冲"))).ToString();
+            
+            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
+            var AA= DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "换模标志位");
+            var BB = DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "运行标志位");
+            var CC = DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "维修时间");
+        }
+
+        private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
+        {
+            if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged && e.TimeFlag.Second % 5 == 0)
+            {
+                GetDeviceScheduleStopBetweenTime();
+                GetDeviceAlarmScheduleStopBetweenTime();
+                PunchingMachineEquipmentKanbanOne.DeviceNameOne.Value = TimeSpan.FromSeconds(Math.Round(DeviceScheduleStopBetweenTime("1号YaWei折弯机"))).ToString();
+                PunchingMachineEquipmentKanbanOne.DeviceNameTwo.Value = TimeSpan.FromSeconds(Math.Round(DeviceAlarmScheduleStopBetweenTime("西门子840D数冲"))).ToString();
+            }
         }
+
         public List<MachineInfoModel> DeviceMachineInformation { get; set; }
 
         public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
 
-        public int DeviceScheduleStopBetWeenTime { get; set; }
+        public int DeviceStateCodeScheduleStopBetWeenTime { get; set; }
 
-        public List<int> DeviceScheduleStopBetweenTimeList { get; set; }
+        public List<int> DeviceStateCodeScheduleStopBetweenTimeList { get; set; }
 
-        public int IntValue { get; set; }
+        public int DeviceStateCodeIntValue { get; set; }
         public void GetDeviceScheduleStopBetweenTime()
         {
             DeviceScheduleStopInformation = Env.SqlDAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
             DeviceMachineInformation = Env.SqlDAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>();
         }
-        public double DeviceScheduleStopBetweenTime(string deviceName)
+        public double DeviceStateCodeStopBetweenTime(string deviceName, string deviceStateCode)
         {
+            DeviceStateCodeIntValue = 0;
+            List<int> DeviceValue = new List<int>();
+            var deviceScheduleStop = DeviceScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
+            foreach (var item in deviceScheduleStop)
+            {
+                var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
+                var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
+                var deviceBetweenTime = DeviceMachineInformation.ToLookup(t => t.Device)[deviceName].ToLookup(t => t.StateCode)[deviceStateCode]?
+                .Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                DeviceStateCodeScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
+                DeviceValue.Add(DeviceStateCodeScheduleStopBetWeenTime);
+            }
+
+            DeviceStateCodeScheduleStopBetweenTimeList = DeviceValue;
+            for (int i = 0; i < DeviceStateCodeScheduleStopBetweenTimeList.Count; i++)
+            {
+                DeviceStateCodeIntValue = DeviceStateCodeScheduleStopBetweenTimeList[i] + DeviceStateCodeIntValue;
+            }
+            return DeviceStateCodeIntValue;
+        }
+
+
+        public int DeviceScheduleStopBetWeenTime { get; set; }
+
+        public List<int> DeviceScheduleStopBetweenTimeList { get; set; }
 
+        public int IntValue { get; set; }
+        public double DeviceScheduleStopBetweenTime(string deviceName)
+        {
+            IntValue = 0;
             List<int> DeviceValue = new List<int>();
             var deviceScheduleStop = DeviceScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
             foreach (var item in deviceScheduleStop)
@@ -75,12 +116,13 @@ namespace SCADA_DAQ.Customer
 
                 var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
                 var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
-                var deviceBetweenTime = DeviceMachineInformation?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                var deviceBetweenTime = DeviceMachineInformation.ToLookup(t => t.Device)[deviceName]?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
                 DeviceScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
                 DeviceValue.Add(DeviceScheduleStopBetWeenTime);
             }
 
             DeviceScheduleStopBetweenTimeList = DeviceValue;
+            
             for (int i = 0; i < DeviceScheduleStopBetweenTimeList.Count; i++)
             {
                 IntValue = DeviceScheduleStopBetweenTimeList[i] + IntValue;
@@ -88,14 +130,16 @@ namespace SCADA_DAQ.Customer
             return IntValue;
         }
 
-
-
-
+      
         public List<AlarmColumModel> DeviceAlarmMachineInformation { get; set; }
 
         public List<DeviceScheduleStopModel> DeviceAlarmScheduleStopInformation { get; set; }
         public int DeviceAlarmInt { get; set; }
 
+
+        public int DeviceAlarmIntValue { get; set; }
+       
+
         public List<int> DeviceAlarmIntList { get; set; }
         public void GetDeviceAlarmScheduleStopBetweenTime()
         {
@@ -104,16 +148,17 @@ namespace SCADA_DAQ.Customer
             DeviceAlarmMachineInformation = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>();
         }
 
+
         public double DeviceAlarmScheduleStopBetweenTime(string deviceName)
         {
-
+            
             List<int> DeviceValue = new List<int>();
             var deviceScheduleStop = DeviceAlarmScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
             foreach (var item in deviceScheduleStop)
             {
                 var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
                 var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
-                var deviceBetweenTime = DeviceAlarmMachineInformation?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                var deviceBetweenTime = DeviceAlarmMachineInformation.ToLookup(t => t.Device_Str)[deviceName]?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
                 DeviceAlarmInt = deviceBetweenTime.Sum(t => t.DurationSec);
                 DeviceValue.Add(DeviceAlarmInt);
             }
@@ -121,9 +166,9 @@ namespace SCADA_DAQ.Customer
             DeviceAlarmIntList = DeviceValue;
             for (int i = 0; i < DeviceAlarmIntList.Count; i++)
             {
-                DeviceAlarmInt = DeviceAlarmIntList[i] + DeviceAlarmInt;
+                DeviceAlarmIntValue = DeviceAlarmIntList[i] + DeviceAlarmIntValue;
             }
-            return DeviceAlarmInt;
+            return DeviceAlarmIntValue;
         }
 
     }

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

@@ -461,7 +461,7 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
                         + DeviceScheduleStopBetweenTime("西门子840D数冲")+ DeviceAlarmScheduleStopBetweenTime("西门子840D数冲");//西门子等待时间
                     var behwiftStopTime = totalTimeOfDay - behwiftRunTime - behwiftMoldTime - DevicScheduleStop("倍福数冲机") - bewiftArlamDouble
                         + DeviceScheduleStopBetweenTime("倍福数冲机") + DeviceAlarmScheduleStopBetweenTime("倍福数冲机");//倍福数冲等待时间
-
+                 
 
                     var laserStopTimeSpan = TimeSpan.FromSeconds(Math.Round(laserStopTime)).ToString();
                     var siemensStopTimeSpan = TimeSpan.FromSeconds(Math.Round(siemensStopTime)).ToString();

+ 74 - 64
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Dashboard/YaweiPressBrakeOneWidget.xaml.cs

@@ -35,7 +35,7 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
     public partial class YaweiPressBrakeOneWidget : BaseUserControl
     {
         private static SqlSchema.DIL.DILDB DAL = Env.SqlDAL;
-    
+
         private List<LaserMmachinePieChartModel> pressBrakeOneValue = new List<LaserMmachinePieChartModel>();
         private List<LaserMmachinePieChartModel> pressBrakeTwoValue = new List<LaserMmachinePieChartModel>();
         private List<LaserMmachinePieChartModel> pressBrakeThreeValue = new List<LaserMmachinePieChartModel>();
@@ -50,40 +50,25 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             GetTableTime();
             GetDeviceScheduleStopBetweenTime();
             string[] deviceStatus = { "运行", "等待", "报警/维修", "换模" };
-            var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
-            //var firstYaWeiStopTime = DeviceTimeValue("1号YaWei折弯机", "停止标志位")- DevicScheduleStop("1号YaWei折弯机");//1号YaWei折弯机等待时间
-            var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间
+            var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
+            var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间
 
-            var sencondYaWeiRunTime = DeviceTimeValue("2号YaWei折弯机", "运行标志位");//2号YaWei折弯机运行时间
-            //var sencondYaWeiStopTime = DeviceTimeValue("2号YaWei折弯机", "停止标志位") - DevicScheduleStop("2号YaWei折弯机");//2号YaWei折弯机等待时间
-            var sencondYaWeiMoldTime = DeviceTimeValue("2号YaWei折弯机", "换模标志位");//2号YaWei折弯机换模时间
+            var sencondYaWeiRunTime = DeviceTimeValue("2号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "运行标志位");//2号YaWei折弯机运行时间
+            var sencondYaWeiMoldTime = DeviceTimeValue("2号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "换模标志位");//2号YaWei折弯机换模时间
 
-            var thirdYaWweiRunTime = DeviceTimeValue("3号YaWei折弯机", "运行标志位"); ;//3号YaWei折弯机运行时间
-            //var thirdYaWweiStopTime = DeviceTimeValue("3号YaWei折弯机", "停止标志位") - DevicScheduleStop("3号YaWei折弯机");//3号YaWei折弯机等待时间
-            var thirdYaWweiMoldTime = DeviceTimeValue("3号YaWei折弯机", "换模标志位");//3号YaWei折弯机换模时间
+            var thirdYaWweiRunTime = DeviceTimeValue("3号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "运行标志位"); //3号YaWei折弯机运行时间
+            var thirdYaWweiMoldTime = DeviceTimeValue("3号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "换模标志位");//3号YaWei折弯机换模时间
 
-            var pbcYaWweiRunTime = DeviceTimeValue("亚威PBC折弯机", "运行标志位"); ;//亚威PBC折弯机运行时间
-            //var pbcYaWweiStopTime = DeviceTimeValue("亚威PBC折弯机", "停止标志位") - DevicScheduleStop("亚威PBC折弯机");//亚威PBC折弯机等待时间
-            var pbcYaWweiMoldTime = DeviceTimeValue("亚威PBC折弯机", "换模标志位");//亚威PBC折弯机换模时间
+            var pbcYaWweiRunTime = DeviceTimeValue("亚威PBC折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "运行标志位");//亚威PBC折弯机运行时间
+            var pbcYaWweiMoldTime = DeviceTimeValue("亚威PBC折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "换模标志位");//亚威PBC折弯机换模时间
 
-            var baiChaoRunTime = DeviceTimeValue("百超折弯机", "运行标志位"); ;//百超折弯机运行时间
-            //var baiChaoStopTime = DeviceTimeValue("百超折弯机", "停止标志位") - DevicScheduleStop("百超折弯机");//百超折弯机折弯机等待时间
-            var baiChaoMoldTime = DeviceTimeValue("百超折弯机", "换模标志位");//百超折弯机换模时间
+            var baiChaoRunTime = DeviceTimeValue("百超折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("百超折弯机", "运行标志位"); //百超折弯机运行时间
+            var baiChaoMoldTime = DeviceTimeValue("百超折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("百超折弯机", "换模标志位");//百超折弯机换模时间
 
             double totalTimeOfDay = TimeSpan.Parse(DateTime.Now.ToString("HH:mm:ss")).TotalSeconds;
-            //var firstYaWeiStopTime = totalTimeOfDay - firstYaWeiRunTime - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
-            //    - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间");//1号YaWei折弯机等待时间
-            //var sencondYaWeiStopTime = totalTimeOfDay - sencondYaWeiRunTime - sencondYaWeiMoldTime - DevicScheduleStop("2号YaWei折弯机")
-            //    - DevicMainTableTime("亚威二号折弯机").TotalSeconds - DeviceTimeValue("2号YaWei折弯机", "维修时间");//2号YaWei折弯机等待时间
-            //var thirdYaWweiStopTime = totalTimeOfDay - thirdYaWweiRunTime - thirdYaWweiMoldTime - DevicScheduleStop("3号YaWei折弯机")
-            //    - DevicMainTableTime("亚威三号折弯机").TotalSeconds - DeviceTimeValue("3号YaWei折弯机", "维修时间");//3号YaWei折弯机等待时间
-            //var pbcYaWweiStopTime = totalTimeOfDay - pbcYaWweiRunTime - pbcYaWweiMoldTime - DevicScheduleStop("亚威PBC折弯机")
-            //    - DevicMainTableTime("亚威PBC折弯机").TotalSeconds - DeviceTimeValue("亚威PBC折弯机", "维修时间");//亚威PBC折弯机等待时间
-            //var baiChaoStopTime = totalTimeOfDay - baiChaoRunTime - baiChaoMoldTime - DevicScheduleStop("百超折弯机")
-            //    - DevicMainTableTime("百超折弯机").TotalSeconds - DeviceTimeValue("百超折弯机", "维修时间");//百超折弯机折弯机等待时间
-
-            var firstYaWeiStopTime = totalTimeOfDay - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
-              - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("1号YaWei折弯机");//1号YaWei折弯机等待时间
+
+            var firstYaWeiStopTime = totalTimeOfDay - firstYaWeiRunTime - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
+                 - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("1号YaWei折弯机");//1号YaWei折弯机等待时间
             var sencondYaWeiStopTime = totalTimeOfDay - sencondYaWeiRunTime - sencondYaWeiMoldTime - DevicScheduleStop("2号YaWei折弯机")
                 - DevicMainTableTime("亚威二号折弯机").TotalSeconds - DeviceTimeValue("2号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("2号YaWei折弯机");//2号YaWei折弯机等待时间
             var thirdYaWweiStopTime = totalTimeOfDay - thirdYaWweiRunTime - thirdYaWweiMoldTime - DevicScheduleStop("3号YaWei折弯机")
@@ -93,11 +78,11 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             var baiChaoStopTime = totalTimeOfDay - baiChaoRunTime - baiChaoMoldTime - DevicScheduleStop("百超折弯机")
                 - DevicMainTableTime("百超折弯机").TotalSeconds - DeviceTimeValue("百超折弯机", "维修时间") + DeviceScheduleStopBetweenTime("百超折弯机");//百超折弯机折弯机等待时间
 
-            var firstYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威一号折弯机").TotalSeconds + DeviceTimeValue("1号YaWei折弯机", "维修时间");
-            var secondYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威二号折弯机").TotalSeconds + DeviceTimeValue("2号YaWei折弯机", "维修时间");
-            var thirdYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威三号折弯机").TotalSeconds + DeviceTimeValue("3号YaWei折弯机", "维修时间");
-            var pbcYaWweiTimeMaintenanceTable = DevicMainTableTime("亚威PBC折弯机").TotalSeconds + DeviceTimeValue("亚威PBC折弯机", "维修时间");
-            var baiChaoTimeMaintenanceTable = DevicMainTableTime("百超折弯机").TotalSeconds+ DeviceTimeValue("百超折弯机", "维修时间");
+            var firstYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威一号折弯机").TotalSeconds + DeviceTimeValue("1号YaWei折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "维修时间");
+            var secondYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威二号折弯机").TotalSeconds + DeviceTimeValue("2号YaWei折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "维修时间");
+            var thirdYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威三号折弯机").TotalSeconds + DeviceTimeValue("3号YaWei折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "维修时间");
+            var pbcYaWweiTimeMaintenanceTable = DevicMainTableTime("亚威PBC折弯机").TotalSeconds + DeviceTimeValue("亚威PBC折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "维修时间");
+            var baiChaoTimeMaintenanceTable = DevicMainTableTime("百超折弯机").TotalSeconds + DeviceTimeValue("百超折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("百超折弯机", "维修时间");
 
             var firstYaWeiValueTime = new double[] { firstYaWeiRunTime, firstYaWeiStopTime, firstYaWeiTimeMaintenanceTable, firstYaWeiMoldTime };
             var sencondYaWeiValueTime = new double[] { sencondYaWeiRunTime, sencondYaWeiStopTime, secondYaWeiTimeMaintenanceTable, sencondYaWeiMoldTime };
@@ -217,31 +202,60 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             }
             return MaintenanceTimeValue;
         }
+
         public List<MachineInfoModel> DeviceMachineInformation { get; set; }
 
         public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
 
-        public int DeviceScheduleStopBetWeenTime { get; set; }
+        public int DeviceStateCodeScheduleStopBetWeenTime { get; set; }
 
-        public List<int> DeviceScheduleStopBetweenTimeList { get; set; }
+        public List<int> DeviceStateCodeScheduleStopBetweenTimeList { get; set; }
 
-        public int IntValue { get; set; }
+        public int DeviceStateCodeIntValue { get; set; }
         public void GetDeviceScheduleStopBetweenTime()
         {
             DeviceScheduleStopInformation = Env.SqlDAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
             DeviceMachineInformation = Env.SqlDAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>();
         }
-        public double DeviceScheduleStopBetweenTime(string deviceName)
+        public double DeviceStateCodeStopBetweenTime(string deviceName, string deviceStateCode)
         {
-
+            DeviceStateCodeIntValue = 0;
             List<int> DeviceValue = new List<int>();
             var deviceScheduleStop = DeviceScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
             foreach (var item in deviceScheduleStop)
             {
+                var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
+                var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
+                var deviceBetweenTime = DeviceMachineInformation.ToLookup(t => t.Device)[deviceName].ToLookup(t => t.StateCode)[deviceStateCode]?
+                .Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                DeviceStateCodeScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
+                DeviceValue.Add(DeviceStateCodeScheduleStopBetWeenTime);
+            }
+
+            DeviceStateCodeScheduleStopBetweenTimeList = DeviceValue;
+            for (int i = 0; i < DeviceStateCodeScheduleStopBetweenTimeList.Count; i++)
+            {
+                DeviceStateCodeIntValue = DeviceStateCodeScheduleStopBetweenTimeList[i] + DeviceStateCodeIntValue;
+            }
+            return DeviceStateCodeIntValue;
+        }
+
+        public int DeviceScheduleStopBetWeenTime { get; set; }
 
+        public List<int> DeviceScheduleStopBetweenTimeList { get; set; }
+
+        public int DeviceIntValue { get; set; }
+
+        public double DeviceScheduleStopBetweenTime(string deviceName)
+        {
+            DeviceIntValue = 0;
+            List<int> DeviceValue = new List<int>();
+            var deviceScheduleStop = DeviceScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
+            foreach (var item in deviceScheduleStop)
+            {
                 var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
                 var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
-                var deviceBetweenTime = DeviceMachineInformation?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
+                var deviceBetweenTime = DeviceMachineInformation.ToLookup(t => t.Device)[deviceName]?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime);
                 DeviceScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
                 DeviceValue.Add(DeviceScheduleStopBetWeenTime);
             }
@@ -249,9 +263,9 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             DeviceScheduleStopBetweenTimeList = DeviceValue;
             for (int i = 0; i < DeviceScheduleStopBetweenTimeList.Count; i++)
             {
-                IntValue = DeviceScheduleStopBetweenTimeList[i] + IntValue;
+                DeviceIntValue = DeviceScheduleStopBetweenTimeList[i] + DeviceIntValue;
             }
-            return IntValue;
+            return DeviceIntValue;
         }
 
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
@@ -266,29 +280,25 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
                     GetTableTime();
                     GetDeviceScheduleStopBetweenTime();
                     string[] deviceStatus = { "运行", "等待", "报警/维修", "换模" };
-                    var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
-                    //var firstYaWeiStopTime = DeviceTimeValue("1号YaWei折弯机", "停止标志位") - DevicScheduleStop("1号YaWei折弯机");//1号YaWei折弯机等待时间
-                    var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间
+                    var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
+                    var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间
 
-                    var sencondYaWeiRunTime = DeviceTimeValue("2号YaWei折弯机", "运行标志位");//2号YaWei折弯机运行时间
-                    //var sencondYaWeiStopTime = DeviceTimeValue("2号YaWei折弯机", "停止标志位") - DevicScheduleStop("2号YaWei折弯机");//2号YaWei折弯机等待时间
-                    var sencondYaWeiMoldTime = DeviceTimeValue("2号YaWei折弯机", "换模标志位");//2号YaWei折弯机换模时间
+                    var sencondYaWeiRunTime = DeviceTimeValue("2号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "运行标志位");//2号YaWei折弯机运行时间
+                    var sencondYaWeiMoldTime = DeviceTimeValue("2号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "换模标志位");//2号YaWei折弯机换模时间
 
-                    var thirdYaWweiRunTime = DeviceTimeValue("3号YaWei折弯机", "运行标志位"); ;//3号YaWei折弯机运行时间
-                    //var thirdYaWweiStopTime = DeviceTimeValue("3号YaWei折弯机", "停止标志位") - DevicScheduleStop("3号YaWei折弯机");//3号YaWei折弯机等待时间
-                    var thirdYaWweiMoldTime = DeviceTimeValue("3号YaWei折弯机", "换模标志位");//3号YaWei折弯机换模时间
+                    var thirdYaWweiRunTime = DeviceTimeValue("3号YaWei折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "运行标志位"); //3号YaWei折弯机运行时间
+                    var thirdYaWweiMoldTime = DeviceTimeValue("3号YaWei折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "换模标志位");//3号YaWei折弯机换模时间
 
-                    var pbcYaWweiRunTime = DeviceTimeValue("亚威PBC折弯机", "运行标志位"); ;//亚威PBC折弯机运行时间
-                    //var pbcYaWweiStopTime = DeviceTimeValue("亚威PBC折弯机", "停止标志位") - DevicScheduleStop("亚威PBC折弯机");//亚威PBC折弯机等待时间
-                    var pbcYaWweiMoldTime = DeviceTimeValue("亚威PBC折弯机", "换模标志位");//亚威PBC折弯机换模时间
+                    var pbcYaWweiRunTime = DeviceTimeValue("亚威PBC折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "运行标志位");//亚威PBC折弯机运行时间
+                    var pbcYaWweiMoldTime = DeviceTimeValue("亚威PBC折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "换模标志位");//亚威PBC折弯机换模时间
 
-                    var baiChaoRunTime = DeviceTimeValue("百超折弯机", "运行标志位"); ;//百超折弯机运行时间
-                    //var baiChaoStopTime = DeviceTimeValue("百超折弯机", "停止标志位") - DevicScheduleStop("百超折弯机");//百超折弯机折弯机等待时间
-                    var baiChaoMoldTime = DeviceTimeValue("百超折弯机", "换模标志位");//百超折弯机换模时间
+                    var baiChaoRunTime = DeviceTimeValue("百超折弯机", "运行标志位") - DeviceStateCodeStopBetweenTime("百超折弯机", "运行标志位"); //百超折弯机运行时间
+                    var baiChaoMoldTime = DeviceTimeValue("百超折弯机", "换模标志位") - DeviceStateCodeStopBetweenTime("百超折弯机", "换模标志位");//百超折弯机换模时间
 
                     double totalTimeOfDay = TimeSpan.Parse(DateTime.Now.ToString("HH:mm:ss")).TotalSeconds;
-                    var firstYaWeiStopTime = totalTimeOfDay - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
-                  - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("1号YaWei折弯机");//1号YaWei折弯机等待时间
+
+                    var firstYaWeiStopTime = totalTimeOfDay - firstYaWeiRunTime - firstYaWeiMoldTime - DevicScheduleStop("1号YaWei折弯机")
+                         - DevicMainTableTime("亚威一号折弯机").TotalSeconds - DeviceTimeValue("1号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("1号YaWei折弯机");//1号YaWei折弯机等待时间
                     var sencondYaWeiStopTime = totalTimeOfDay - sencondYaWeiRunTime - sencondYaWeiMoldTime - DevicScheduleStop("2号YaWei折弯机")
                         - DevicMainTableTime("亚威二号折弯机").TotalSeconds - DeviceTimeValue("2号YaWei折弯机", "维修时间") + DeviceScheduleStopBetweenTime("2号YaWei折弯机");//2号YaWei折弯机等待时间
                     var thirdYaWweiStopTime = totalTimeOfDay - thirdYaWweiRunTime - thirdYaWweiMoldTime - DevicScheduleStop("3号YaWei折弯机")
@@ -298,11 +308,11 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
                     var baiChaoStopTime = totalTimeOfDay - baiChaoRunTime - baiChaoMoldTime - DevicScheduleStop("百超折弯机")
                         - DevicMainTableTime("百超折弯机").TotalSeconds - DeviceTimeValue("百超折弯机", "维修时间") + DeviceScheduleStopBetweenTime("百超折弯机");//百超折弯机折弯机等待时间
 
-                    var firstYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威一号折弯机").TotalSeconds + DeviceTimeValue("1号YaWei折弯机", "维修时间");
-                    var secondYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威二号折弯机").TotalSeconds + DeviceTimeValue("2号YaWei折弯机", "维修时间");
-                    var thirdYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威三号折弯机").TotalSeconds + DeviceTimeValue("3号YaWei折弯机", "维修时间");
-                    var pbcYaWweiTimeMaintenanceTable = DevicMainTableTime("亚威PBC折弯机").TotalSeconds + DeviceTimeValue("亚威PBC折弯机", "维修时间");
-                    var baiChaoTimeMaintenanceTable = DevicMainTableTime("百超折弯机").TotalSeconds + DeviceTimeValue("百超折弯机", "维修时间");
+                    var firstYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威一号折弯机").TotalSeconds + DeviceTimeValue("1号YaWei折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("1号YaWei折弯机", "维修时间");
+                    var secondYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威二号折弯机").TotalSeconds + DeviceTimeValue("2号YaWei折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("2号YaWei折弯机", "维修时间");
+                    var thirdYaWeiTimeMaintenanceTable = DevicMainTableTime("亚威三号折弯机").TotalSeconds + DeviceTimeValue("3号YaWei折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("3号YaWei折弯机", "维修时间");
+                    var pbcYaWweiTimeMaintenanceTable = DevicMainTableTime("亚威PBC折弯机").TotalSeconds + DeviceTimeValue("亚威PBC折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("亚威PBC折弯机", "维修时间");
+                    var baiChaoTimeMaintenanceTable = DevicMainTableTime("百超折弯机").TotalSeconds + DeviceTimeValue("百超折弯机", "维修时间") - DeviceStateCodeStopBetweenTime("百超折弯机", "维修时间");
 
                     var firstYaWeiValueTime = new double[] { firstYaWeiRunTime, firstYaWeiStopTime, firstYaWeiTimeMaintenanceTable, firstYaWeiMoldTime };
                     var sencondYaWeiValueTime = new double[] { sencondYaWeiRunTime, sencondYaWeiStopTime, secondYaWeiTimeMaintenanceTable, sencondYaWeiMoldTime };