Jelajahi Sumber

临时提交

谢翼翔 1 tahun lalu
induk
melakukan
8386f313a7

+ 15 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/DistinctTimePiece/TimePiece.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models.DistinctTimePiece
+{
+    public class TimePiece
+    {
+        public TimeSpan StartTime { get; set; }
+
+        public TimeSpan EndTime { get; set; }
+    }
+}

+ 89 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/DistinctTimePiece/TimeTotalHelper.cs

@@ -0,0 +1,89 @@
+using SCADA.CommonLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models.DistinctTimePiece
+{
+    public class TimeTotalHelper:ObservableObject
+    {
+        public static List<TimePiece> DistinctTime(List<TimePiece> timePieces)
+        {
+            var result = new List<TimePiece>();
+
+            if (timePieces?.Count != null)
+            {
+                var ascTime = timePieces.OrderBy(t => t.StartTime).ToList();
+                result.Add(ascTime.First());
+                for (global::System.Int32 i = 0; i < ascTime.Count - 1; i++)
+                {
+                    if (ascTime[i + 1].StartTime <= ascTime[i].EndTime)
+                    {
+                        if (ascTime[i + 1].EndTime > ascTime[i].EndTime)
+                        {
+                            result.Last().EndTime = ascTime[i + 1].EndTime;
+                        }
+                    }
+                    else
+                    {
+                        result.Add(ascTime[i + 1]);
+                    }
+                }
+
+            }
+
+            return result;
+        }
+
+        public static TimeSpan DistinctPlanStopTime(List<TimePiece> timePieces, List<TimePiece> planStops)
+        {
+            var result = new TimeSpan();
+            var isInclude = false;
+            if (timePieces?.Count != null && planStops?.Count != null)
+            {
+                if (timePieces.Count > 0)
+                {
+
+                    for (int i = 0; i < timePieces.Count; i++)
+                    {
+                        isInclude = false;
+                        if (planStops.Count > 0)
+                        {
+                            for (int j = 0; j < planStops.Count; j++)
+                            {
+                                if ((timePieces[i].StartTime > planStops[j].StartTime && timePieces[i].StartTime < planStops[j].EndTime) ||
+                                        (timePieces[i].EndTime > planStops[j].StartTime && timePieces[i].EndTime < planStops[j].EndTime) ||
+                                            (timePieces[i].StartTime < planStops[j].StartTime && timePieces[i].EndTime > planStops[j].EndTime) ||
+                                                (timePieces[i].StartTime > planStops[j].StartTime && timePieces[i].EndTime < planStops[j].EndTime))
+                                {
+                                    if (timePieces[i].StartTime < planStops[j].StartTime)
+                                    {
+                                        result = result + (planStops[j].StartTime - timePieces[i].StartTime);
+                                    }
+                                    if (timePieces[i].EndTime > planStops[j].EndTime)
+                                    {
+                                        result = result + (timePieces[i].EndTime - planStops[j].EndTime);
+                                    }
+                                    isInclude = true;
+                                }
+
+                            }
+                            if (!isInclude)
+                            {
+                                result = result + (timePieces[i].EndTime - timePieces[i].StartTime);
+                            }
+                        }
+                        else
+                        {
+                            result = result + (timePieces[i].EndTime - timePieces[i].StartTime);
+                        }
+                    }
+
+                }
+            }
+            return result;
+        }
+    }
+}

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

@@ -6,22 +6,11 @@
       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" 
      x:Name="this"
-      Background="LightBlue"
-      d:DesignHeight="1080" d:DesignWidth="1920"
+         d:DesignHeight="1080" d:DesignWidth="1920"
       Title="UctFrmRunHistory">
     <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"/>-->
-        <uct:UctDeviceInformationControlsThird x:Name="PunchingMachineEquipmentKanbanOne" Text="高机冲孔机设备运行状况" Grid.Row="1"  />
+  
+   
     </Grid>
 
 </wpfcontrol:BaseUctFrm>

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

@@ -4,6 +4,7 @@ using NPOI.SS.Formula.Eval;
 using NPOI.SS.Formula.Functions;
 using SCADA.CommonCtrl.WpfControl;
 using SCADA.CommonLib.Data.DIL.Sqlite;
+using SCADA.CommonLib.Helper;
 using SCADA_DAQ.Customer.Models.AlarmTime;
 using SCADA_DAQ.Customer.Models.DeviceInfoTime;
 using SCADA_DAQ.Customer.Models.ScheduleStop;
@@ -21,6 +22,7 @@ using System.Windows.Documents;
 using System.Windows.Forms;
 using System.Windows.Input;
 using System.Windows.Media;
+using System.Windows.Media.Animation;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
@@ -33,145 +35,174 @@ namespace SCADA_DAQ.Customer
     /// </summary>
     [UctMenu("设备运行界面", Icon = "看板")]
 
+
     public partial class UctFrmRunHistory : BaseUctFrm
     {
         private static SqlSchema.DIL.DILDB DAL = Env.SqlDAL;
         //private static DIL.DILDB sqliteDAL = Env.DAL;
+
         public UctFrmRunHistory()
         {
             InitializeComponent();
-            GetDeviceScheduleStopBetweenTime();
-            GetDeviceAlarmScheduleStopBetweenTime();
-
-            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)
+            var timeList = new List<TimePiece>();
+            var timeListAdd = new List<List<TimePiece>>();
+
+            var timeStopTime = DAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>().ToLookup(t => t.Device)["高机母线冲剪机"];
+            var timeStopPieces = new List<TimePiece>();
+            if (timeStopTime.Count() != 0)
             {
-                GetDeviceScheduleStopBetweenTime();
-                GetDeviceAlarmScheduleStopBetweenTime();
-                PunchingMachineEquipmentKanbanOne.DeviceNameOne.Value = TimeSpan.FromSeconds(Math.Round(DeviceScheduleStopBetweenTime("1号YaWei折弯机"))).ToString();
-                PunchingMachineEquipmentKanbanOne.DeviceNameTwo.Value = TimeSpan.FromSeconds(Math.Round(DeviceAlarmScheduleStopBetweenTime("西门子840D数冲"))).ToString();
+                foreach (var item in timeStopTime)
+                {
+                    timeStopPieces.Add(new TimePiece
+                    {
+                        StartTime = Convert.ToDateTime(item.StartTime.ToString()).TimeOfDay,
+                        EndTime = Convert.ToDateTime(item.EndTime.ToString()).TimeOfDay
+                    });
+                }
             }
-        }
-
-        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("00:00:00"));
+            var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString("23:59:59"));
+            var informationValue = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>()?.Where(t => t.CreateTime >= classesStartTime & t.CreateTime <= classesEndTime).ToLookup(t => t.Device_Str)["高机母线冲剪机"];
+            var timePieces = new List<TimePiece>();
+            if (informationValue.Count() != 0)
             {
-                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);
+                foreach (var item in informationValue)
+                {
+                    timePieces.Add(new TimePiece
+                    {
+                        StartTime = item.StartTime.TimeOfDay,
+                        EndTime = item.EndTime.TimeOfDay
+                    });
+                }
             }
-
-            DeviceStateCodeScheduleStopBetweenTimeList = DeviceValue;
-            for (int i = 0; i < DeviceStateCodeScheduleStopBetweenTimeList.Count; i++)
+            else
             {
-                DeviceStateCodeIntValue = DeviceStateCodeScheduleStopBetweenTimeList[i] + DeviceStateCodeIntValue;
+                timePieces = new List<TimePiece>() {
+
+                      new TimePiece{StartTime =TimeSpan.FromSeconds(DateTime.Now.ToOADate()) ,
+                          EndTime = TimeSpan.FromSeconds(DateTime.Now.ToOADate())},
+                     };
             }
-            return DeviceStateCodeIntValue;
-        }
+        
 
+            var total = TimeTotalHelper.DistinctPlanStopTime(TimeTotalHelper.DistinctTime(timePieces), timeStopPieces);
 
-        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)
-            {
+            //foreach (var item in a)
+            //{
 
-                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);
-            }
+            //    var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
+            //    var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
 
-            DeviceScheduleStopBetweenTimeList = DeviceValue;
-            
-            for (int i = 0; i < DeviceScheduleStopBetweenTimeList.Count; i++)
-            {
-                IntValue = DeviceScheduleStopBetweenTimeList[i] + IntValue;
-            }
-            return IntValue;
-        }
+            //}
 
-      
-        public List<AlarmColumModel> DeviceAlarmMachineInformation { get; set; }
 
-        public List<DeviceScheduleStopModel> DeviceAlarmScheduleStopInformation { get; set; }
-        public int DeviceAlarmInt { get; set; }
 
+            //var stopList = new List<TimePiece>()
+            //{
 
-        public int DeviceAlarmIntValue { get; set; }
-       
+            //    new TimePiece{StartTime = new TimeSpan(1,10,0) ,EndTime = new TimeSpan(1,20,0)},
+            //    new TimePiece{StartTime = new TimeSpan(2,10,0) ,EndTime = new TimeSpan(3,00,0)}
+            //};
+            //var b = TimeTotalHelper.DistinctPlanStopTime(a, stopList);
 
-        public List<int> DeviceAlarmIntList { get; set; }
-        public void GetDeviceAlarmScheduleStopBetweenTime()
+        }
+
+    }
+
+        class TimePiece
         {
-            DeviceAlarmScheduleStopInformation = Env.SqlDAL.App_Vertiv_DeviceScheduleStop.GetData<DeviceScheduleStopModel>();
+            public TimeSpan StartTime { get; set; }
 
-            DeviceAlarmMachineInformation = Env.SqlDAL.Base_AlarmLog.GetData<AlarmColumModel>();
+            public TimeSpan EndTime { get; set; }
         }
 
-
-        public double DeviceAlarmScheduleStopBetweenTime(string deviceName)
+        class TimeTotalHelper
         {
-            
-            List<int> DeviceValue = new List<int>();
-            var deviceScheduleStop = DeviceAlarmScheduleStopInformation.ToLookup(t => t.Device)[deviceName];
-            foreach (var item in deviceScheduleStop)
+            public static List<TimePiece> DistinctTime(List<TimePiece> timePieces)
             {
-                var classesStartTime = Convert.ToDateTime(DateTime.Now.ToString(item.StartTime.ToString()));
-                var classesEndTime = Convert.ToDateTime(DateTime.Now.ToString(item.EndTime.ToString()));
-                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);
+                var result = new List<TimePiece>();
+
+                if (timePieces?.Count != null)
+                {
+                    var ascTime = timePieces.OrderBy(t => t.StartTime).ToList();
+                    result.Add(ascTime.First());
+                    for (global::System.Int32 i = 0; i < ascTime.Count - 1; i++)
+                    {
+                        if (ascTime[i + 1].StartTime <= ascTime[i].EndTime)
+                        {
+                            if (ascTime[i + 1].EndTime > ascTime[i].EndTime)
+                            {
+                                result.Last().EndTime = ascTime[i + 1].EndTime;
+                            }
+                        }
+                        else
+                        {
+                            result.Add(ascTime[i + 1]);
+                        }
+                    }
+
+                }
+
+                return result;
             }
 
-            DeviceAlarmIntList = DeviceValue;
-            for (int i = 0; i < DeviceAlarmIntList.Count; i++)
+            public static TimeSpan DistinctPlanStopTime(List<TimePiece> timePieces, List<TimePiece> planStops)
             {
-                DeviceAlarmIntValue = DeviceAlarmIntList[i] + DeviceAlarmIntValue;
+                var result = new TimeSpan();
+                var isInclude = false;
+                if (timePieces?.Count != null && planStops?.Count != null)
+                {
+                    if (timePieces.Count > 0)
+                    {
+
+                        for (int i = 0; i < timePieces.Count; i++)
+                        {
+                            isInclude = false;
+                            if (planStops.Count > 0)
+                            {
+                                for (int j = 0; j < planStops.Count; j++)
+                                {
+                                    if ((timePieces[i].StartTime > planStops[j].StartTime && timePieces[i].StartTime < planStops[j].EndTime) ||
+                                            (timePieces[i].EndTime > planStops[j].StartTime && timePieces[i].EndTime < planStops[j].EndTime) ||
+                                                (timePieces[i].StartTime < planStops[j].StartTime && timePieces[i].EndTime > planStops[j].EndTime) ||
+                                                    (timePieces[i].StartTime > planStops[j].StartTime && timePieces[i].EndTime < planStops[j].EndTime))
+                                    {
+                                        if (timePieces[i].StartTime < planStops[j].StartTime)
+                                        {
+                                            result = result + (planStops[j].StartTime - timePieces[i].StartTime);
+                                        }
+                                        if (timePieces[i].EndTime > planStops[j].EndTime)
+                                        {
+                                            result = result + (timePieces[i].EndTime - planStops[j].EndTime);
+                                        }
+                                        isInclude = true;
+                                    }
+
+                                }
+                                if (!isInclude)
+                                {
+                                    result = result + (timePieces[i].EndTime - timePieces[i].StartTime);
+                                }
+                            }
+                            else
+                            {
+                                result = result + (timePieces[i].EndTime - timePieces[i].StartTime);
+                            }
+                        }
+
+                    }
+                }
+                return result;
             }
-            return DeviceAlarmIntValue;
         }
 
     }
-}
+
+