|
@@ -16,6 +16,7 @@ using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using System.Windows.Navigation;
|
|
|
using System.Windows.Shapes;
|
|
|
+using SCADA_DAQ.Customer.Models.OEEData;
|
|
|
|
|
|
namespace SCADA_DAQ.Customer
|
|
|
{
|
|
@@ -25,15 +26,21 @@ namespace SCADA_DAQ.Customer
|
|
|
[UctMenu("设备OEE界面",Icon ="看板")]
|
|
|
public partial class UctFrmDeviceOeeInformation : BaseUctFrm
|
|
|
{
|
|
|
+
|
|
|
public UctFrmDeviceOeeInformation()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+
|
|
|
ToolBar.Visibility = Visibility.Collapsed;
|
|
|
Image_Title.Source = SCADA.CommonCtrl.WpfHelper.VisualHelper.ImageToImageSource(@"Icon\VertivBck.png");
|
|
|
LocalTime.Text = DateTime.Now.ToString("dddd yyyy年MM月dd日 HH:mm");
|
|
|
+ GetOeeData();
|
|
|
+
|
|
|
+ new OeeProperty().DeviceEvceryOeePercent = OeePercent("高机母线冲剪机");
|
|
|
|
|
|
+
|
|
|
}
|
|
|
- public List<MachineInfoModel> OeeData { get; set; }
|
|
|
+ public IEnumerable<OEEDataModel> OeeData { get; set; }
|
|
|
|
|
|
public List<TimeSection> Days { get; set; }
|
|
|
public void GetOeeData()
|
|
@@ -41,46 +48,36 @@ namespace SCADA_DAQ.Customer
|
|
|
Days = DateTimeHelper.GetDays(DateTimeHelper.ToMonthStart(DateTime.Now), DateTimeHelper.ToMonthEnd(DateTime.Now));
|
|
|
var first = DateTime.Parse(Days.First().StartTime.ToString());
|
|
|
var last = DateTime.Parse(Days.Last().EndTime.ToString());
|
|
|
- OeeData = Env.SqlDAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>();
|
|
|
- var deviceMonthTime = OeeData.Where(t => t.CreateTime >= first & t.CreateTime <= last);
|
|
|
+ OeeData = Env.SqlDAL.App_Vertiv_MachineInfoOeeData.GetData<OEEDataModel>().Where(t => t.CreateTime >= first & t.CreateTime <= last);
|
|
|
+
|
|
|
}
|
|
|
- public List<double> OeePercent(string deviceName, string deviceCode)
|
|
|
+ public List<double> OeePercent(string deviceName)
|
|
|
{
|
|
|
- var allTime = new List<double>();
|
|
|
- var dayAllTime = 0;
|
|
|
+ var allOeePercentage = new List<double>();
|
|
|
var runTime = new List<double>();
|
|
|
- var dayRunTime = 0;
|
|
|
+ double dayRunTime = 0;
|
|
|
for (int i = 0; i < Days.Count; i++)
|
|
|
{
|
|
|
var hourStartResult = Days[i].StartTime.Format();
|
|
|
var hourEndResult = Days[i].EndTime.Format();
|
|
|
- var deviceDayTIme = OeeData.ToLookup(t => t.Device)[deviceName]
|
|
|
+ var OeePercentSting = OeeData.ToLookup(t => t.DeviceName)[deviceName]
|
|
|
.Where(t => t.CreateTime >= DateTime.Parse(hourStartResult) & t.CreateTime < DateTime.Parse(hourEndResult));
|
|
|
- foreach (var item in deviceDayTIme)
|
|
|
+ foreach (var item in OeePercentSting)
|
|
|
{
|
|
|
- dayAllTime = item.DurationSec + dayAllTime;
|
|
|
+ if (OeePercentSting.Count() == 0)
|
|
|
+ {
|
|
|
+ dayRunTime = 0;
|
|
|
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dayRunTime = double.Parse(OeePercentSting.First().OeePercentage.ToString());
|
|
|
+ }
|
|
|
}
|
|
|
- var deviceRunDayTIme = OeeData.ToLookup(t => t.Device)[deviceName].ToLookup(t => t.StateCode)[deviceCode]
|
|
|
- .Where(t => t.CreateTime >= DateTime.Parse(hourStartResult) & t.CreateTime < DateTime.Parse(hourEndResult));
|
|
|
- foreach (var item in deviceRunDayTIme)
|
|
|
- {
|
|
|
- dayRunTime = item.DurationSec + dayRunTime;
|
|
|
- }
|
|
|
- if (dayAllTime != 0)
|
|
|
- {
|
|
|
- var oeeValue = Convert.ToDouble(dayRunTime) / dayAllTime;
|
|
|
- //var percentOeeValue = oeeValue.ToString("0.##%");
|
|
|
- allTime.Add(Math.Round(oeeValue, 2));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- allTime.Add(0);
|
|
|
- }
|
|
|
- dayAllTime = 0;
|
|
|
- dayRunTime = 0;
|
|
|
+ allOeePercentage.Add(dayRunTime);
|
|
|
+ dayRunTime=0;
|
|
|
}
|
|
|
- return allTime;
|
|
|
+ return allOeePercentage;
|
|
|
}
|
|
|
}
|
|
|
}
|