|
@@ -18,16 +18,22 @@ using System.Windows.Navigation;
|
|
|
using System.Windows.Shapes;
|
|
|
using SCADA_DAQ.Customer.Models.OEEData;
|
|
|
using LiveCharts;
|
|
|
+using NPOI.POIFS.Properties;
|
|
|
+using System.Windows.Forms;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
+using NPOI.HSSF.Record;
|
|
|
|
|
|
namespace SCADA_DAQ.Customer
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// UctFrmDeviceOeeInformation.xaml 的交互逻辑
|
|
|
/// </summary>
|
|
|
- [UctMenu("设备OEE界面", Icon = "看板")]
|
|
|
+ [UctMenu("时间稼动率界面", Icon = "看板")]
|
|
|
public partial class UctFrmDeviceOeeInformation : BaseUctFrm
|
|
|
{
|
|
|
public OeeProperty DeviceOeePercenValue = new OeeProperty();
|
|
|
+
|
|
|
+
|
|
|
public UctFrmDeviceOeeInformation()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -35,18 +41,96 @@ namespace SCADA_DAQ.Customer
|
|
|
ToolBar.Visibility = Visibility.Collapsed;
|
|
|
Image_Title.Source = SCADA.CommonCtrl.WpfHelper.VisualHelper.ImageToImageSource(@"Icon\VertivBck.png");
|
|
|
LocalTime.Text = DateTime.Now.ToString("dddd yyyy年MM月dd日 HH:mm");
|
|
|
- //GetOeeData();
|
|
|
- //OeePercent("高机母线冲剪机");
|
|
|
- //var listdouble = OeePercent("高机母线冲剪机");
|
|
|
- //HighDevice.OeeValue.Values = new ChartValues<double>();
|
|
|
- //for (int i = 0; i < OeePercent("高机母线冲剪机").Count; i++)
|
|
|
- //{
|
|
|
- // HighDevice.OeeValue.Values.Add(OeePercent("高机母线冲剪机")[i]);
|
|
|
- //}
|
|
|
-
|
|
|
+ GetOeeData();
|
|
|
+ TenOeeChart();
|
|
|
+ Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
|
|
|
+ LaserDevice.Title = new string[] { "单位:%", "激光机"};
|
|
|
+ simenDevice.Title = new string[] { "单位:%", "西门子数冲机" };
|
|
|
+ BeiFuDevice.Title = new string[] { "单位:%", "倍福数冲机" };
|
|
|
+ KimFangyuanDevice.Title = new string[] { "单位:%", "金方圆数控母线冲孔机" };
|
|
|
+ HighDevice.Title = new string[] { "单位:%", "高机母线冲剪机" };
|
|
|
+ OneBendingDevice.Title = new string[] { "单位:%", "1号YaWei折弯机" };
|
|
|
+ TwoBendingDevice.Title = new string[] { "单位:%", "2号YaWei折弯机" };
|
|
|
+ ThreeBendingDevice.Title = new string[] { "单位:%", "3号YaWei折弯机" };
|
|
|
+ YaWeiPBCDevice.Title = new string[] { "单位:%", "亚威PBC折弯机" };
|
|
|
+ BaiChaoDevice.Title = new string[] { "单位:%", "百超折弯机" };
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
|
|
|
+ {
|
|
|
+ if (e.ChangeType == DateTimeChangeType.SecondChanged && e.TimeFlag.Second % 10 == 0)
|
|
|
+ {
|
|
|
+ Dispatcher.Invoke(new Action(() =>
|
|
|
+ {
|
|
|
+ GetOeeData();
|
|
|
+ TenOeeChart();
|
|
|
+ //LaserDevice.OeeValueUpdate.Update();
|
|
|
+ //simenDevice.OeeValueUpdate.Update();
|
|
|
+ //BeiFuDevice.OeeValueUpdate.Update();
|
|
|
+ //KimFangyuanDevice.OeeValueUpdate.Update();
|
|
|
+ //HighDevice.OeeValueUpdate.Update();
|
|
|
+ //OneBendingDevice.OeeValueUpdate.Update();
|
|
|
+ //TwoBendingDevice.OeeValueUpdate.Update();
|
|
|
+ //ThreeBendingDevice.OeeValueUpdate.Update();
|
|
|
+ //YaWeiPBCDevice.OeeValueUpdate.Update();
|
|
|
+ //BaiChaoDevice.OeeValueUpdate.Update();
|
|
|
+ }));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void TenOeeChart()
|
|
|
+ {
|
|
|
+ OeeChart("激光机", LaserDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, LaserDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+ OeeChart("西门子840D数冲", simenDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, simenDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+ OeeChart("倍福数冲机", BeiFuDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, BeiFuDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+ OeeChart("金方圆数控母线冲孔机", KimFangyuanDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, KimFangyuanDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+ OeeChart("高机母线冲剪机", HighDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, HighDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+ OeeChart("1号YaWei折弯机", OneBendingDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, OneBendingDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+ OeeChart("2号YaWei折弯机", TwoBendingDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, TwoBendingDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+ OeeChart("3号YaWei折弯机", ThreeBendingDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, ThreeBendingDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList); ;
|
|
|
+ OeeChart("亚威PBC折弯机", YaWeiPBCDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, YaWeiPBCDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+ OeeChart("百超折弯机", BaiChaoDevice.Axisx.Labels = DeviceOeePercenValue.ChartOeeAxisXList, BaiChaoDevice.OeeValue.Values = DeviceOeePercenValue.ChartOeeAxisYList);
|
|
|
+
|
|
|
+ OeeAVGChart("激光机", LaserDevice.OeeValueAGV.Values= DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("西门子840D数冲", simenDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("倍福数冲机", BeiFuDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("金方圆数控母线冲孔机", KimFangyuanDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("高机母线冲剪机", HighDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("1号YaWei折弯机", OneBendingDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("2号YaWei折弯机", TwoBendingDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("3号YaWei折弯机", ThreeBendingDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("亚威PBC折弯机", YaWeiPBCDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ OeeAVGChart("百超折弯机", BaiChaoDevice.OeeValueAGV.Values = DeviceOeePercenValue.ChartOeeAVGAxisYList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void OeeChart(string deviceName, IList<string> DeviceAisxX, IChartValues DeviceAxisY)
|
|
|
+ {
|
|
|
+
|
|
|
+ var listdouble = OeePercent(deviceName);
|
|
|
+ for (int i = 0; i < listdouble.Count; i++)
|
|
|
+ {
|
|
|
+ DeviceAxisY.Add(listdouble[i]);
|
|
|
+ DeviceAisxX.Add(((i + 1).ToString() + "日"));
|
|
|
+
|
|
|
+ }
|
|
|
+ DeviceOeePercenValue.ChartOeeAxisYList = new ChartValues<double>();
|
|
|
+ DeviceOeePercenValue.ChartOeeAxisXList = new List<string>();
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public void OeeAVGChart(string deviceName , IChartValues DeviceAxisY)
|
|
|
+ {
|
|
|
+ var deviceAVG = OeePercentAVG(deviceName);
|
|
|
+ for (int i = 0; i < deviceAVG.Count(); i++)
|
|
|
+ {
|
|
|
+ DeviceAxisY.Add(deviceAVG[i]);
|
|
|
+ }
|
|
|
+ DeviceOeePercenValue.ChartOeeAVGAxisYList = new ChartValues<double>();
|
|
|
+ }
|
|
|
|
|
|
public IEnumerable<OEEDataModel> OeeData { get; set; }
|
|
|
|
|
@@ -58,6 +142,7 @@ namespace SCADA_DAQ.Customer
|
|
|
var last = DateTime.Parse(Days.Last().EndTime.ToString());
|
|
|
OeeData = Env.SqlDAL.App_Vertiv_MachineInfoOeeData.GetData<OEEDataModel>().Where(t => t.CreateTime >= first & t.CreateTime <= last);
|
|
|
|
|
|
+
|
|
|
}
|
|
|
public List<double> OeePercent(string deviceName)
|
|
|
{
|
|
@@ -66,6 +151,8 @@ namespace SCADA_DAQ.Customer
|
|
|
double dayRunTime = 0;
|
|
|
for (int i = 0; i < Days.Count; i++)
|
|
|
{
|
|
|
+ //var hourStartResult = Days[i].StartTime.Format();
|
|
|
+ //var hourEndResult = Days[i].EndTime.Format();
|
|
|
var hourStartResult = Days[i].StartTime.Format();
|
|
|
var hourEndResult = Days[i].EndTime.Format();
|
|
|
var OeePercentSting = OeeData.ToLookup(t => t.DeviceName)[deviceName]
|
|
@@ -82,10 +169,29 @@ namespace SCADA_DAQ.Customer
|
|
|
dayRunTime = double.Parse(OeePercentSting.First().OeePercentage.ToString());
|
|
|
}
|
|
|
}
|
|
|
- allOeePercentage.Add(dayRunTime);
|
|
|
+ allOeePercentage.Add(dayRunTime*100);
|
|
|
dayRunTime = 0;
|
|
|
}
|
|
|
return allOeePercentage;
|
|
|
}
|
|
|
+ public List<double> OeePercentAVG(string deviceName)
|
|
|
+ {
|
|
|
+ var hourStartResult = DateTime.Parse(Days.First().StartTime.ToString());
|
|
|
+ var hourEndResult = DateTime.Parse(DateTime.Now.ToString("00:00:00"));
|
|
|
+ var OeePercentStingAVG = OeeData.ToLookup(t => t.DeviceName)[deviceName]
|
|
|
+ .Where(t => t.CreateTime >= DateTime.Parse(hourStartResult.Format()) & t.CreateTime < DateTime.Parse(hourEndResult.Format()));
|
|
|
+ double aVGValue = 0;
|
|
|
+ var aVGOeePercentage = new List<double>();
|
|
|
+ foreach (var item in OeePercentStingAVG)
|
|
|
+ {
|
|
|
+ aVGValue = double.Parse(item.OeePercentage) + aVGValue;
|
|
|
+ }
|
|
|
+ var allAVGValue = aVGValue / OeePercentStingAVG.Count();
|
|
|
+ for (int i = 0; i < Days.Count; i++)
|
|
|
+ {
|
|
|
+ aVGOeePercentage.Add(allAVGValue*100);
|
|
|
+ }
|
|
|
+ return aVGOeePercentage;
|
|
|
+ }
|
|
|
}
|
|
|
}
|