Ver código fonte

临时提交

谢翼翔 1 ano atrás
pai
commit
e69c11852c

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

@@ -78,8 +78,8 @@ namespace SCADA_DAQ.Customer
             GetDBData();
             GetTableTime();
             GetRepairTime();
-            GetScheduleStopTime();
-            GetDeviceScheduleStopBetweenTime();
+            //GetScheduleStopTime();
+            //GetDeviceScheduleStopBetweenTime();
             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");
@@ -288,14 +288,28 @@ namespace SCADA_DAQ.Customer
         }
         public TimeSpan DevicMainTableTime(string deviceName)
         {
-
-            var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取设备维修时间
-            var MaintenanceTimeValue = new TimeSpan();
-            foreach (TimeSpan item in timeMaintenanceTable)
+            if (deviceMaintenanceTable.Count != 0)
+            {
+                var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取设备维修时间
+                var MaintenanceTimeValue = new TimeSpan();
+                foreach (TimeSpan item in timeMaintenanceTable)
+                {
+                    MaintenanceTimeValue = MaintenanceTimeValue + item;
+                }
+                return MaintenanceTimeValue;
+            }
+            else
             {
-                MaintenanceTimeValue = MaintenanceTimeValue + item;
+
+                return new TimeSpan(0, 0, 0); ;
             }
-            return MaintenanceTimeValue;
+            //var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取设备维修时间
+            //var MaintenanceTimeValue = new TimeSpan();
+            //foreach (TimeSpan item in timeMaintenanceTable)
+            //{
+            //    MaintenanceTimeValue = MaintenanceTimeValue + item;
+            //}
+            //return MaintenanceTimeValue;
         }
 
 
@@ -323,93 +337,93 @@ namespace SCADA_DAQ.Customer
             return RepairTime.Duration - RepairKeepTime;//设备保养时间到期所剩的天数
         }
 
-        public List<ScheduleStopModel> deviceScheduleStop { get; set; }
-        public void GetScheduleStopTime()//设备停止计划时间
-        {
-            var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
-            var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-
-            deviceScheduleStop = DAL.App_Vertiv_ScheduleStop.GetData<ScheduleStopModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();//获取当天所有设备计划停止信息
-
-        }
-
-
-        public double DevicScheduleStop(string deviceName)
-        {
-
-            var scheduleStopTime = deviceScheduleStop.ToLookup(t => t.TableName)[deviceName].Select(t => t.DurationTime);//获取设备计划停止时间
-            var scheduleStopTimeValue = new TimeSpan();
-            foreach (TimeSpan item in scheduleStopTime)
-            {
-                scheduleStopTimeValue = scheduleStopTimeValue + item;
-            }
-            return Convert.ToDouble(scheduleStopTimeValue.TotalSeconds);
-        }
-
-        public List<MachineInfoModel> DeviceMachineInformation { get; set; }
-
-        public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
-
-        public int DeviceStateCodeScheduleStopBetWeenTime { get; set; }
-
-        public List<int> DeviceStateCodeScheduleStopBetweenTimeList { 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 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.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++)
-            {
-                DeviceIntValue = DeviceScheduleStopBetweenTimeList[i] + DeviceIntValue;
-            }
-            return DeviceIntValue;
-        }
+        //public List<ScheduleStopModel> deviceScheduleStop { get; set; }
+        //public void GetScheduleStopTime()//设备停止计划时间
+        //{
+        //    var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
+        //    var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+
+        //    deviceScheduleStop = DAL.App_Vertiv_ScheduleStop.GetData<ScheduleStopModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();//获取当天所有设备计划停止信息
+
+        //}
+
+
+        //public double DevicScheduleStop(string deviceName)
+        //{
+
+        //    var scheduleStopTime = deviceScheduleStop.ToLookup(t => t.TableName)[deviceName].Select(t => t.DurationTime);//获取设备计划停止时间
+        //    var scheduleStopTimeValue = new TimeSpan();
+        //    foreach (TimeSpan item in scheduleStopTime)
+        //    {
+        //        scheduleStopTimeValue = scheduleStopTimeValue + item;
+        //    }
+        //    return Convert.ToDouble(scheduleStopTimeValue.TotalSeconds);
+        //}
+
+        //public List<MachineInfoModel> DeviceMachineInformation { get; set; }
+
+        //public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
+
+        //public int DeviceStateCodeScheduleStopBetWeenTime { get; set; }
+
+        //public List<int> DeviceStateCodeScheduleStopBetweenTimeList { 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 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.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++)
+        //    {
+        //        DeviceIntValue = DeviceScheduleStopBetweenTimeList[i] + DeviceIntValue;
+        //    }
+        //    return DeviceIntValue;
+        //}
 
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
         {
@@ -422,8 +436,8 @@ namespace SCADA_DAQ.Customer
                     GetDBData();
                     GetTableTime();
                     GetRepairTime();
-                    GetScheduleStopTime();
-                    GetDeviceScheduleStopBetweenTime();
+                    //GetScheduleStopTime();
+                    //GetDeviceScheduleStopBetweenTime();
 
                     var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
                     var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间

+ 127 - 112
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmPunchingMachineEquipmentKanban.xaml.cs

@@ -50,9 +50,9 @@ namespace SCADA_DAQ.Customer
             GetDBData();
             GetTableTime();
             GetRepairTime();
-            GetScheduleStopTime();
-            GetDeviceAlarmTime();
-            GetDeviceStopTime();
+            //GetScheduleStopTime();
+            //GetDeviceAlarmTime();
+            //GetDeviceStopTime();
             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");
@@ -207,121 +207,136 @@ namespace SCADA_DAQ.Customer
         }
         public TimeSpan DevicMainTableTime(string deviceName)
         {
-            var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取激光机设备维修时间
-            var MaintenanceTimeValue = new TimeSpan();
-            foreach (TimeSpan item in timeMaintenanceTable)
+            if (deviceMaintenanceTable.Count != 0)
             {
-                MaintenanceTimeValue = MaintenanceTimeValue + item;
-            }
-            return MaintenanceTimeValue;
-        }
-
-        public List<ScheduleStopModel> deviceScheduleStop { get; set; }
-        public void GetScheduleStopTime()//设备停止计划时间
-        {
-            var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
-            var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-
-            deviceScheduleStop = DAL.App_Vertiv_ScheduleStop.GetData<ScheduleStopModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();//获取当天所有设备计划停止信息
-
-        }
-
-
-        public double DevicScheduleStop(string deviceName)
-        {
-
-            var scheduleStopTime = deviceScheduleStop.ToLookup(t => t.TableName)[deviceName].Select(t => t.DurationTime);//获取设备计划停止时间
-            var scheduleStopTimeValue = new TimeSpan();
-            foreach (TimeSpan item in scheduleStopTime)
-            {
-                scheduleStopTimeValue = scheduleStopTimeValue + item;
-            }
-            return Convert.ToDouble(scheduleStopTimeValue.TotalSeconds);
-        }
-
-
-        public List<AlarmColumModel> deviceAlarmTime { get; set; }
-
-        public List<AlarmColumModel> DistinctDeviceAlarmTime { get; set; }
-        public void GetDeviceAlarmTime()//获取设备一天报警信息
-        {
-            var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
-            var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-            deviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();
-
-            var classesYesterdayStartTime = Convert.ToDateTime(DateTime.Now.AddDays(-1).Date);
-            var classesDayEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-            DistinctDeviceAlarmTime =DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesYesterdayStartTime & t.CreateTime <= classesDayEndTime).ToList();
-
-        }
-        public List<DeviceScheduleStopModel> deviceStopTime { get; set; }
-
-        public void GetDeviceStopTime()//获取计划停止时间
-        {
-             deviceStopTime = DAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
-        }
-
-        public double DeviceAlarmTime(string deviceName)
-        {
-            var timeStopTime = deviceStopTime.ToLookup(t => t.Device)[deviceName];
-            var timeStopPieces = new List<TimePiece>();
-            if (timeStopTime.Count() != 0)
-            {
-                foreach (var item in timeStopTime)
+                var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取设备维修时间
+                var MaintenanceTimeValue = new TimeSpan();
+                foreach (TimeSpan item in timeMaintenanceTable)
                 {
-                    timeStopPieces.Add(new TimePiece
-                    {
-                        StartTime = Convert.ToDateTime(item.StartTime.ToString()).TimeOfDay,
-                        EndTime = Convert.ToDateTime(item.EndTime.ToString()).TimeOfDay
-                    });
+                    MaintenanceTimeValue = MaintenanceTimeValue + item;
                 }
+                return MaintenanceTimeValue;
             }
-                    
-            var informationValue = deviceAlarmTime?.ToLookup(t => t.Device_Str)[deviceName];
-            var deviceValueInformation = DistinctDeviceAlarmTime.ToLookup(t => t.Device_Str)[deviceName];
-            var timePieces = new List<TimePiece>();
-            if (deviceValueInformation.Count() != 0)
+            else
             {
-                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
-                        });
-                    }
-
-                }
 
+                return new TimeSpan(0, 0, 0); ;
             }
-            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 doubletotal = total.TotalSeconds;
-            return doubletotal;
-
+            //var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取激光机设备维修时间
+            //var MaintenanceTimeValue = new TimeSpan();
+            //foreach (TimeSpan item in timeMaintenanceTable)
+            //{
+            //    MaintenanceTimeValue = MaintenanceTimeValue + item;
+            //}
+            //return MaintenanceTimeValue;
         }
 
+        //public List<ScheduleStopModel> deviceScheduleStop { get; set; }
+        //public void GetScheduleStopTime()//设备停止计划时间
+        //{
+        //    var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
+        //    var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+
+        //    deviceScheduleStop = DAL.App_Vertiv_ScheduleStop.GetData<ScheduleStopModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();//获取当天所有设备计划停止信息
+
+        //}
+
+
+        //public double DevicScheduleStop(string deviceName)
+        //{
+
+        //    var scheduleStopTime = deviceScheduleStop.ToLookup(t => t.TableName)[deviceName].Select(t => t.DurationTime);//获取设备计划停止时间
+        //    var scheduleStopTimeValue = new TimeSpan();
+        //    foreach (TimeSpan item in scheduleStopTime)
+        //    {
+        //        scheduleStopTimeValue = scheduleStopTimeValue + item;
+        //    }
+        //    return Convert.ToDouble(scheduleStopTimeValue.TotalSeconds);
+        //}
+
+
+        //public List<AlarmColumModel> deviceAlarmTime { get; set; }
+
+        //public List<AlarmColumModel> DistinctDeviceAlarmTime { get; set; }
+        //public void GetDeviceAlarmTime()//获取设备一天报警信息
+        //{
+        //    var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
+        //    var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+        //    deviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();
+
+        //    var classesYesterdayStartTime = Convert.ToDateTime(DateTime.Now.AddDays(-1).Date);
+        //    var classesDayEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+        //    DistinctDeviceAlarmTime =DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesYesterdayStartTime & t.CreateTime <= classesDayEndTime).ToList();
+
+        //}
+        //public List<DeviceScheduleStopModel> deviceStopTime { get; set; }
+
+        //public void GetDeviceStopTime()//获取计划停止时间
+        //{
+        //     deviceStopTime = DAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
+        //}
+
+        //public double DeviceAlarmTime(string deviceName)
+        //{
+        //    var timeStopTime = deviceStopTime.ToLookup(t => t.Device)[deviceName];
+        //    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 informationValue = deviceAlarmTime?.ToLookup(t => t.Device_Str)[deviceName];
+        //    var deviceValueInformation = DistinctDeviceAlarmTime.ToLookup(t => t.Device_Str)[deviceName];
+        //    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 doubletotal = total.TotalSeconds;
+        //    return doubletotal;
+
+        //}
+
 
      
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
@@ -345,9 +360,9 @@ namespace SCADA_DAQ.Customer
                     GetDBData();
                     GetTableTime();
                     GetRepairTime();
-                    GetScheduleStopTime();
-                    GetDeviceAlarmTime();
-                    GetDeviceStopTime();
+                    //GetScheduleStopTime();
+                    //GetDeviceAlarmTime();
+                    //GetDeviceStopTime();
                      var kimFangyuanRepairTime = "倒计时" + DeviceRepairTime("金方圆铜排冲剪机").ToString() + "天";//金方圆铜排冲剪机设备保养信息
                     var highmachineRepairTime = "倒计时" + DeviceRepairTime("高机铜排冲剪机").ToString() + "天";//高机铜排冲剪机设备保养信息
                      //var kimFangyuanArlamTimeSpanString = Convert.ToString(DevicMainTableTime("金方圆铜排冲剪机")

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

@@ -54,7 +54,7 @@ namespace SCADA_DAQ.Customer
             TimeSelect.SelectTimeChangeEvent += TimeSelect_SelectTimeChangeEvent; ;
             TimeSelect.ReturnTodayEvent += TimeSelect_ReturnTodayEvent; ;
             Env.selectTimeModel.PropertyChanged += SelectTimeModel_PropertyChanged;
-
+            var OOO = new TimeSpan(0, 0, 0);
         }
         private void SelectTimeModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
         {

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

@@ -49,13 +49,9 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             InitializeComponent();
             GetDBData();
             GetTableTime();
-            GetScheduleStopTime();
             GetRepairTime();
-            GetDeviceAlarmTime();
             GetHighDeviceWorkTime();
-            GetDeviceScheduleStopBetweenTime();
-            GetDeviceAlarmScheduleStopBetweenTime();
-            GetDeviceStopTime();
+       
             var laserRepairTime = "倒计时" + DeviceRepairTime("激光机").ToString() + "天";//激光机设备保养信息
             var siemensRepairTime = "倒计时" + DeviceRepairTime("西门子840D数冲").ToString() + "天";//西门子设备保养信息
             var behwifRepairTime = "倒计时" + DeviceRepairTime("倍福数冲机").ToString() + "天";//倍福数冲设备保养信息
@@ -259,119 +255,134 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
         }
         public TimeSpan DevicMainTableTime(string deviceName)
         {
-            var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取激光机设备维修时间
-            var MaintenanceTimeValue = new TimeSpan();
-            foreach (TimeSpan item in timeMaintenanceTable)
+            if (deviceMaintenanceTable.Count != 0)
             {
-                MaintenanceTimeValue = MaintenanceTimeValue + item;
-            }
-            return MaintenanceTimeValue;
-        }
-        public List<ScheduleStopModel> deviceScheduleStop { get; set; }
-        public void GetScheduleStopTime()//设备停止计划时间
-        {
-            var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
-            var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-
-            deviceScheduleStop = DAL.App_Vertiv_ScheduleStop.GetData<ScheduleStopModel>().ToList();//获取当天所有设备计划停止信息
-
-        }
-        public double DevicScheduleStop(string deviceName)
-        {
-            //var classesStartTimeSpan = Env.Schedual.CurrentClasses.StartTime.ToString();
-            //var classesEndTimeSpan = Env.Schedual.CurrentClasses.EndTime.ToString();
-            //var classesStartTime = Convert.ToDateTime(classesStartTimeSpan);
-            //var classesEndTime = Convert.ToDateTime(classesEndTimeSpan);
-            var scheduleStopTime = deviceScheduleStop.ToLookup(t => t.TableName)[deviceName].Select(t => t.DurationTime);//获取设备计划停止时间
-            var scheduleStopTimeValue = new TimeSpan();
-            foreach (TimeSpan item in scheduleStopTime)
-            {
-                scheduleStopTimeValue = scheduleStopTimeValue + item;
-            }
-            return Convert.ToDouble(scheduleStopTimeValue.TotalSeconds);
-        }
-
-        public List<AlarmColumModel> deviceAlarmTime { get; set; }
-
-        public List<AlarmColumModel> DistinctDeviceAlarmTime { get; set; }
-        public void GetDeviceAlarmTime()//获取设备一天报警信息
-        {
-            var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
-            var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-            deviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();
-
-            var classesYesterdayStartTime = Convert.ToDateTime(DateTime.Now.AddDays(-1).Date);
-            var classesDayEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
-            DistinctDeviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesYesterdayStartTime & t.CreateTime <= classesDayEndTime).ToList();
-        }
-        public List<DeviceScheduleStopModel> deviceStopTime { get; set; }
-
-        public void GetDeviceStopTime()//获取计划停止时间
-        {
-            deviceStopTime = DAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
-        }
-
-        public double DeviceAlarmTime(string deviceName)
-        {
-            var timeStopTime = deviceStopTime.ToLookup(t => t.Device)[deviceName];
-            var timeStopPieces = new List<TimePiece>();
-            if (timeStopTime.Count() != 0)
-            {
-                foreach (var item in timeStopTime)
+                var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取设备维修时间
+                var MaintenanceTimeValue = new TimeSpan();
+                foreach (TimeSpan item in timeMaintenanceTable)
                 {
-                    timeStopPieces.Add(new TimePiece
-                    {
-                        StartTime = Convert.ToDateTime(item.StartTime.ToString()).TimeOfDay,
-                        EndTime = Convert.ToDateTime(item.EndTime.ToString()).TimeOfDay
-                    });
+                    MaintenanceTimeValue = MaintenanceTimeValue + item;
                 }
+                return MaintenanceTimeValue;
             }
-
-            var informationValue = deviceAlarmTime?.ToLookup(t => t.Device_Str)[deviceName];
-            var deviceValueInformation = DistinctDeviceAlarmTime.ToLookup(t => t.Device_Str)[deviceName];
-            var timePieces = new List<TimePiece>();
-            if (deviceValueInformation.Count() != 0)
+            else
             {
-                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())},
-                     };
+                return new TimeSpan(0, 0, 0); ;
             }
-
-            var total = TimeTotalHelper.DistinctPlanStopTime(TimeTotalHelper.DistinctTime(timePieces), timeStopPieces);
-            var doubletotal = total.TotalSeconds;
-            return doubletotal;
-
+            //var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取激光机设备维修时间
+            //var MaintenanceTimeValue = new TimeSpan();
+            //foreach (TimeSpan item in timeMaintenanceTable)
+            //{
+            //    MaintenanceTimeValue = MaintenanceTimeValue + item;
+            //}
+            //return MaintenanceTimeValue;
         }
+        //public List<ScheduleStopModel> deviceScheduleStop { get; set; }
+        //public void GetScheduleStopTime()//设备停止计划时间
+        //{
+        //    var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
+        //    var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+
+        //    deviceScheduleStop = DAL.App_Vertiv_ScheduleStop.GetData<ScheduleStopModel>().ToList();//获取当天所有设备计划停止信息
+
+        //}
+        //public double DevicScheduleStop(string deviceName)
+        //{
+        //    //var classesStartTimeSpan = Env.Schedual.CurrentClasses.StartTime.ToString();
+        //    //var classesEndTimeSpan = Env.Schedual.CurrentClasses.EndTime.ToString();
+        //    //var classesStartTime = Convert.ToDateTime(classesStartTimeSpan);
+        //    //var classesEndTime = Convert.ToDateTime(classesEndTimeSpan);
+        //    var scheduleStopTime = deviceScheduleStop.ToLookup(t => t.TableName)[deviceName].Select(t => t.DurationTime);//获取设备计划停止时间
+        //    var scheduleStopTimeValue = new TimeSpan();
+        //    foreach (TimeSpan item in scheduleStopTime)
+        //    {
+        //        scheduleStopTimeValue = scheduleStopTimeValue + item;
+        //    }
+        //    return Convert.ToDouble(scheduleStopTimeValue.TotalSeconds);
+        //}
+
+        //public List<AlarmColumModel> deviceAlarmTime { get; set; }
+
+        //public List<AlarmColumModel> DistinctDeviceAlarmTime { get; set; }
+        //public void GetDeviceAlarmTime()//获取设备一天报警信息
+        //{
+        //    var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
+        //    var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+        //    deviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();
+
+        //    var classesYesterdayStartTime = Convert.ToDateTime(DateTime.Now.AddDays(-1).Date);
+        //    var classesDayEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+        //    DistinctDeviceAlarmTime = DAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesYesterdayStartTime & t.CreateTime <= classesDayEndTime).ToList();
+        //}
+        //public List<DeviceScheduleStopModel> deviceStopTime { get; set; }
+
+        //public void GetDeviceStopTime()//获取计划停止时间
+        //{
+        //    deviceStopTime = DAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
+        //}
+
+        //public double DeviceAlarmTime(string deviceName)
+        //{
+        //    var timeStopTime = deviceStopTime.ToLookup(t => t.Device)[deviceName];
+        //    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 informationValue = deviceAlarmTime?.ToLookup(t => t.Device_Str)[deviceName];
+        //    var deviceValueInformation = DistinctDeviceAlarmTime.ToLookup(t => t.Device_Str)[deviceName];
+        //    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 doubletotal = total.TotalSeconds;
+        //    return doubletotal;
+
+        //}
 
 
         public List<DeviceWorkTimeModel> DeviceWorkTime { get; set; }//所有设备一天通电时间的信息
@@ -389,80 +400,80 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             return DeviceWait;
         }
 
-        public List<MachineInfoModel> DeviceMachineInformation { get; set; }
+        //public List<MachineInfoModel> DeviceMachineInformation { get; set; }
 
-        public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
+        //public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
 
-        public int DeviceScheduleStopBetWeenTime { get; set; }
+        //public int DeviceScheduleStopBetWeenTime { get; set; }
 
-        public List<int> DeviceScheduleStopBetweenTimeList { get; set; }
+        //public List<int> DeviceScheduleStopBetweenTimeList { get; set; }
 
-        public int IntValue { 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 int IntValue { 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)
+        //{
 
-            List<int> DeviceValue = new List<int>();
-            var deviceScheduleStop = DeviceScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
-            foreach (var item in deviceScheduleStop)
-            {
+        //    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);
-                DeviceScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
-                DeviceValue.Add(DeviceScheduleStopBetWeenTime);
-            }
+        //        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);
+        //        DeviceScheduleStopBetWeenTime = deviceBetweenTime.Sum(t => t.DurationSec);
+        //        DeviceValue.Add(DeviceScheduleStopBetWeenTime);
+        //    }
 
-            DeviceScheduleStopBetweenTimeList = DeviceValue;
-            for (int i = 0; i < DeviceScheduleStopBetweenTimeList.Count; i++)
-            {
-                IntValue = DeviceScheduleStopBetweenTimeList[i] + IntValue;
-            }
-            return IntValue;
-        }
+        //    DeviceScheduleStopBetweenTimeList = DeviceValue;
+        //    for (int i = 0; i < DeviceScheduleStopBetweenTimeList.Count; i++)
+        //    {
+        //        IntValue = DeviceScheduleStopBetweenTimeList[i] + IntValue;
+        //    }
+        //    return IntValue;
+        //}
 
 
 
 
-        public List<AlarmColumModel> DeviceAlarmMachineInformation { get; set; }
+        //public List<AlarmColumModel> DeviceAlarmMachineInformation { get; set; }
 
-        public List<DeviceScheduleStopModel> DeviceAlarmScheduleStopInformation { get; set; }
-        public int DeviceAlarmInt { get; set; }
+        //public List<DeviceScheduleStopModel> DeviceAlarmScheduleStopInformation { get; set; }
+        //public int DeviceAlarmInt { get; set; }
 
-        public List<int> DeviceAlarmIntList { get; set; }
-        public void GetDeviceAlarmScheduleStopBetweenTime()
-        {
-            DeviceAlarmScheduleStopInformation = Env.SqlDAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
+        //public List<int> DeviceAlarmIntList { get; set; }
+        //public void GetDeviceAlarmScheduleStopBetweenTime()
+        //{
+        //    DeviceAlarmScheduleStopInformation = Env.SqlDAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
 
-            DeviceAlarmMachineInformation = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>();
-        }
+        //    DeviceAlarmMachineInformation = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>();
+        //}
 
-        public double DeviceAlarmScheduleStopBetweenTime(string deviceName)
-        {
+        //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);
-                DeviceAlarmInt = deviceBetweenTime.Sum(t => t.DurationSec);
-                DeviceValue.Add(DeviceAlarmInt);
-            }
+        //    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);
+        //        DeviceAlarmInt = deviceBetweenTime.Sum(t => t.DurationSec);
+        //        DeviceValue.Add(DeviceAlarmInt);
+        //    }
 
-            DeviceAlarmIntList = DeviceValue;
-            for (int i = 0; i < DeviceAlarmIntList.Count; i++)
-            {
-                DeviceAlarmInt = DeviceAlarmIntList[i] + DeviceAlarmInt;
-            }
-            return DeviceAlarmInt;
-        }
+        //    DeviceAlarmIntList = DeviceValue;
+        //    for (int i = 0; i < DeviceAlarmIntList.Count; i++)
+        //    {
+        //        DeviceAlarmInt = DeviceAlarmIntList[i] + DeviceAlarmInt;
+        //    }
+        //    return DeviceAlarmInt;
+        //}
 
 
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
@@ -477,13 +488,9 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
                     System.GC.Collect(2);
                     GetDBData();
                     GetTableTime();
-                    GetScheduleStopTime();
                     GetRepairTime();
-                    GetDeviceAlarmTime();
                     GetHighDeviceWorkTime();
-                    GetDeviceScheduleStopBetweenTime();
-                    GetDeviceAlarmScheduleStopBetweenTime();
-                    GetDeviceStopTime();
+                 
             
                     var laserRepairTime = "倒计时" + DeviceRepairTime("激光机").ToString() + "天";//激光机设备保养信息
                     var siemensRepairTime = "倒计时" + DeviceRepairTime("西门子840D数冲").ToString() + "天";//西门子设备保养信息

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

@@ -45,9 +45,9 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
         {
             InitializeComponent();
             GetDBData();
-            GetScheduleStopTime();
+            //GetScheduleStopTime();
             GetTableTime();
-            GetDeviceScheduleStopBetweenTime();
+            //GetDeviceScheduleStopBetweenTime();
             string[] deviceStatus = { "运行", "等待", "报警/维修", "换模" };
 
             var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
@@ -139,31 +139,31 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
         }
 
 
-        public List<ScheduleStopModel> deviceScheduleStop { get; set; }
-        public void GetScheduleStopTime()//设备停止计划时间
-        {
-            //var classesStartTimeSpan = Env.Schedual.CurrentClasses.StartTime.ToString();
-            //var classesEndTimeSpan = Env.Schedual.CurrentClasses.EndTime.ToString();
-            //var classesStartTime = Convert.ToDateTime(classesStartTimeSpan);
-            //var classesEndTime = Convert.ToDateTime(classesEndTimeSpan);
-            var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
-            var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+        //public List<ScheduleStopModel> deviceScheduleStop { get; set; }
+        //public void GetScheduleStopTime()//设备停止计划时间
+        //{
+        //    //var classesStartTimeSpan = Env.Schedual.CurrentClasses.StartTime.ToString();
+        //    //var classesEndTimeSpan = Env.Schedual.CurrentClasses.EndTime.ToString();
+        //    //var classesStartTime = Convert.ToDateTime(classesStartTimeSpan);
+        //    //var classesEndTime = Convert.ToDateTime(classesEndTimeSpan);
+        //    var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString("00:00:00"));
+        //    var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
 
-            deviceScheduleStop = DAL.App_Vertiv_ScheduleStop.GetData<ScheduleStopModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();//获取当天所有设备计划停止信息
+        //    deviceScheduleStop = DAL.App_Vertiv_ScheduleStop.GetData<ScheduleStopModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToList();//获取当天所有设备计划停止信息
 
-        }
+        //}
 
 
-        public double DevicScheduleStop(string deviceName)
-        {
-            var scheduleStopTime = deviceScheduleStop.ToLookup(t => t.TableName)[deviceName].Select(t => t.DurationTime);//获取设备计划停止时间
-            var scheduleStopTimeValue = new TimeSpan();
-            foreach (TimeSpan item in scheduleStopTime)
-            {
-                scheduleStopTimeValue = scheduleStopTimeValue + item;
-            }
-            return Convert.ToDouble(scheduleStopTimeValue.TotalSeconds);
-        }
+        //public double DevicScheduleStop(string deviceName)
+        //{
+        //    var scheduleStopTime = deviceScheduleStop.ToLookup(t => t.TableName)[deviceName].Select(t => t.DurationTime);//获取设备计划停止时间
+        //    var scheduleStopTimeValue = new TimeSpan();
+        //    foreach (TimeSpan item in scheduleStopTime)
+        //    {
+        //        scheduleStopTimeValue = scheduleStopTimeValue + item;
+        //    }
+        //    return Convert.ToDouble(scheduleStopTimeValue.TotalSeconds);
+        //}
 
         public List<MaintenanceTableModel> deviceMaintenanceTable { get; set; }
         public void GetTableTime()
@@ -181,80 +181,88 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
         }
         public TimeSpan DevicMainTableTime(string deviceName)
         {
-
-            var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取设备维修时间
-            var MaintenanceTimeValue = new TimeSpan();
-            foreach (TimeSpan item in timeMaintenanceTable)
+            if (deviceMaintenanceTable.Count != 0 )
             {
-                MaintenanceTimeValue = MaintenanceTimeValue + item;
-            }
-            return MaintenanceTimeValue;
-        }
-
-        public List<MachineInfoModel> DeviceMachineInformation { get; set; }
-
-        public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
-
-        public int DeviceStateCodeScheduleStopBetWeenTime { get; set; }
-
-        public List<int> DeviceStateCodeScheduleStopBetweenTimeList { 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 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);
+                var timeMaintenanceTable = deviceMaintenanceTable.ToLookup(t => t.DeviceName)[deviceName].Select(t => t.DurationTime);//获取设备维修时间
+                var MaintenanceTimeValue = new TimeSpan();
+                foreach (TimeSpan item in timeMaintenanceTable)
+                {
+                    MaintenanceTimeValue = MaintenanceTimeValue + item;
+                }
+                return MaintenanceTimeValue;
             }
-
-            DeviceStateCodeScheduleStopBetweenTimeList = DeviceValue;
-            for (int i = 0; i < DeviceStateCodeScheduleStopBetweenTimeList.Count; i++)
+            else
             {
-                DeviceStateCodeIntValue = DeviceStateCodeScheduleStopBetweenTimeList[i] + DeviceStateCodeIntValue;
+                
+                return new TimeSpan(0, 0, 0); ;
             }
-            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.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++)
-            {
-                DeviceIntValue = DeviceScheduleStopBetweenTimeList[i] + DeviceIntValue;
-            }
-            return DeviceIntValue;
-        }
+        //public List<MachineInfoModel> DeviceMachineInformation { get; set; }
+
+        //public List<DeviceScheduleStopModel> DeviceScheduleStopInformation { get; set; }
+
+        //public int DeviceStateCodeScheduleStopBetWeenTime { get; set; }
+
+        //public List<int> DeviceStateCodeScheduleStopBetweenTimeList { 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 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.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++)
+        //    {
+        //        DeviceIntValue = DeviceScheduleStopBetweenTimeList[i] + DeviceIntValue;
+        //    }
+        //    return DeviceIntValue;
+        //}
 
         private void Schedual_DateTimeChanged(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
         {
@@ -264,9 +272,9 @@ namespace SCADA_DAQ.Customer.Views.Dashboard
             {
                 System.GC.Collect(2);
                 GetDBData();
-                GetScheduleStopTime();
+                //GetScheduleStopTime();
                 GetTableTime();
-                GetDeviceScheduleStopBetweenTime();
+                //GetDeviceScheduleStopBetweenTime();
                 string[] deviceStatus = { "运行", "等待", "报警/维修", "换模" };
                 var firstYaWeiRunTime = DeviceTimeValue("1号YaWei折弯机", "运行标志位");//1号YaWei折弯机运行时间
                 var firstYaWeiMoldTime = DeviceTimeValue("1号YaWei折弯机", "换模标志位");//1号YaWei折弯机换模时间