|
@@ -1,4 +1,5 @@
|
|
|
-using Microsoft.Expression.Interactivity.Media;
|
|
|
+using ControlzEx.Standard;
|
|
|
+using Microsoft.Expression.Interactivity.Media;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using Opc.Ua;
|
|
|
using SCADA;
|
|
@@ -7,6 +8,8 @@ using SCADA.CommonLib.Data.DIL;
|
|
|
using SCADA.CommonLib.Helper;
|
|
|
using SCADA.CommonLib.Service;
|
|
|
using SCADA_DAQ.Customer.Models;
|
|
|
+using SCADA_DAQ.Customer.Models.DeviceInfoTime;
|
|
|
+using SCADA_DAQ.Customer.Models.OEEData;
|
|
|
using SCADA_DAQ.Plugin.Machine.Config;
|
|
|
using SqlSchema.DBNames;
|
|
|
using System;
|
|
@@ -88,8 +91,9 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
Timer.Start();
|
|
|
Timer.Elapsed += Timer_Elapsed;
|
|
|
Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
|
|
|
+ GetOeeData();
|
|
|
var str = $"{T_Col_Name.App_Vertiv_MachineInfo.Device_Str} = '亚威PBC折弯机' ";
|
|
|
- var lastTime = Env.SqlDAL.App_Vertiv_MachineInfo.GetTopOne(str, "StartTime_Dt"," ID Desc ");
|
|
|
+ var lastTime = Env.SqlDAL.App_Vertiv_MachineInfo.GetTopOne(str, "StartTime_Dt", " ID Desc ");
|
|
|
LastRecordTime = Convert.ToDateTime(lastTime);
|
|
|
return base.Start();
|
|
|
|
|
@@ -99,12 +103,12 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
|
|
|
private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
|
|
|
{
|
|
|
- if (e.ChangeType==DateTimeChangeType.MinuteChanged)
|
|
|
+ if (e.ChangeType == DateTimeChangeType.MinuteChanged)
|
|
|
{
|
|
|
TimeToUpdate();
|
|
|
}
|
|
|
|
|
|
- if (e.ChangeType==DateTimeChangeType.DayChanged)
|
|
|
+ if (e.ChangeType == DateTimeChangeType.DayChanged)
|
|
|
{
|
|
|
TimeToUpdate();
|
|
|
yaweiMac.Power.OnOrgID_Str = Guid.NewGuid().ToString();
|
|
@@ -118,6 +122,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
Env.SqlDAL.App_Vertiv_WorkTime.Insert(
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DeviceName_Str, "西门子840D数冲"),
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.OrgID_Str, simensModel.OnOrgID_Str));
|
|
|
+ OeePercent();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -158,10 +163,17 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_ScheduleStop.Duration_Dt, lastTime)
|
|
|
);
|
|
|
OrgID = null;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged & e.TimeFlag.Second % 10 == 0 )
|
|
|
+ {
|
|
|
+ GetOeeData();
|
|
|
+ OeePercent();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
|
@@ -235,11 +247,11 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var modeChange = recordModelList.Where(t => t.@event == "mode" && t.StrTimeFormat(t.time) > LastRecordTime).ToList();
|
|
|
if (modeChange != null)
|
|
|
{
|
|
|
- if (modeChange.Count >0)
|
|
|
+ if (modeChange.Count > 0)
|
|
|
{
|
|
|
foreach (var item in modeChange)
|
|
|
{
|
|
@@ -256,14 +268,14 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
ref yaweiMac.Program.StateOnDuration_Double);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var stepList = recordModelList.Where(t=>t.@event == "step" && t.StrTimeFormat(t.time) > LastRecordTime).ToList();
|
|
|
+ var stepList = recordModelList.Where(t => t.@event == "step" && t.StrTimeFormat(t.time) > LastRecordTime).ToList();
|
|
|
if (stepList != null)
|
|
|
{
|
|
|
- if (stepList.Count>0)
|
|
|
+ if (stepList.Count > 0)
|
|
|
{
|
|
|
foreach (var item in stepList)
|
|
|
{
|
|
@@ -272,18 +284,18 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //if (recordModelList[i].StrTimeFormat(recordModelList[i].time) > LastRecordTime)
|
|
|
- // {
|
|
|
- // //程序启动
|
|
|
- // if (recordModelList[i].@event == "start")
|
|
|
- // {
|
|
|
- // Env.SqlDAL.App_Vertiv_ProductionLog.Insert(
|
|
|
- // new UpdateItem(T_Col_Name.App_Vertiv_ProductionLog.DeviceName_Str, "亚威PBC折弯机"));
|
|
|
- // InsertStateCode(ref yaweiMac.Work.OnOrgID_Str,
|
|
|
- // "运行标志位",
|
|
|
- // ref yaweiMac.Work.StateOn_Bool,
|
|
|
- // recordModelList[i].StrTimeFormat(recordModelList[i].time),
|
|
|
- // ref yaweiMac.Work.StateOnTime_Dt);
|
|
|
+ //if (recordModelList[i].StrTimeFormat(recordModelList[i].time) > LastRecordTime)
|
|
|
+ // {
|
|
|
+ // //程序启动
|
|
|
+ // if (recordModelList[i].@event == "start")
|
|
|
+ // {
|
|
|
+ // Env.SqlDAL.App_Vertiv_ProductionLog.Insert(
|
|
|
+ // new UpdateItem(T_Col_Name.App_Vertiv_ProductionLog.DeviceName_Str, "亚威PBC折弯机"));
|
|
|
+ // InsertStateCode(ref yaweiMac.Work.OnOrgID_Str,
|
|
|
+ // "运行标志位",
|
|
|
+ // ref yaweiMac.Work.StateOn_Bool,
|
|
|
+ // recordModelList[i].StrTimeFormat(recordModelList[i].time),
|
|
|
+ // ref yaweiMac.Work.StateOnTime_Dt);
|
|
|
|
|
|
// }
|
|
|
// else if (recordModelList[i].@event == "mode")
|
|
@@ -319,9 +331,9 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
|
|
|
|
|
|
|
|
|
- LastRecordTime = recordModelList.Last().StrTimeFormat(recordModelList.Last().time);
|
|
|
+ LastRecordTime = recordModelList.Last().StrTimeFormat(recordModelList.Last().time);
|
|
|
file.Close();
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
try
|
|
@@ -369,7 +381,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.DurationSec_Dec, yaweiMac.Power.StateOnDuration_Double),
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.TurnOffTime_Dt, DateTime.Now.Format()));
|
|
|
yaweiMac.Power.StateOn_Bool = false;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(OrgID))
|
|
|
{
|
|
@@ -512,5 +524,63 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_WorkTime.TurnOffTime_Dt, DateTime.Now.Format()));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public IEnumerable<MachineInfoModel> OeeData { get; set; }
|
|
|
+
|
|
|
+ public IEnumerable<OEEDataModel> DailyOeeData { get; set; }
|
|
|
+ public void GetOeeData()
|
|
|
+ {
|
|
|
+ var startDayTime = DateTime.Parse(DateTime.Now.ToString("00:00:00"));
|
|
|
+ var endDayTime = DateTime.Parse(DateTime.Now.ToString("23:59:59"));
|
|
|
+ OeeData = Env.SqlDAL.App_Vertiv_MachineInfo.GetData<MachineInfoModel>().Where(t => t.CreateTime >= startDayTime & t.CreateTime <= endDayTime);
|
|
|
+ DailyOeeData = Env.SqlDAL.App_Vertiv_MachineInfoOeeData.GetData<OEEDataModel>().Where(t => t.CreateTime >= startDayTime & t.CreateTime <= endDayTime);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public string OeeValue { get; set; }
|
|
|
+
|
|
|
+ public void OeePercent()
|
|
|
+ {
|
|
|
+ var deviceName = new List<string>{"高机母线冲剪机", "2号YaWei折弯机", "3号YaWei折弯机", "激光机", "1号YaWei折弯机", "百超折弯机",
|
|
|
+ "倍福数冲机", "金方圆数控母线冲孔机", "西门子840D数冲", "亚威PBC折弯机"};
|
|
|
+
|
|
|
+ for (int i = 0; i < deviceName.Count; i++)
|
|
|
+ {
|
|
|
+ var device = deviceName[i];
|
|
|
+ var deviceDayTIme = OeeData.ToLookup(t => t.Device)[deviceName[i]].Sum(t => t.DurationSec);
|
|
|
+ var deviceRunDayTIme = OeeData.ToLookup(t => t.Device)[deviceName[i]].ToLookup(t => t.StateCode)["运行标志位"].Sum(t => t.DurationSec);
|
|
|
+
|
|
|
+ if (deviceDayTIme == 0)
|
|
|
+ {
|
|
|
+ OeeValue = "0";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OeeValue = Math.Round(Convert.ToDouble(deviceRunDayTIme) / deviceDayTIme, 4).ToString();
|
|
|
+
|
|
|
+ }
|
|
|
+ if (DailyOeeData.Count() != 0)
|
|
|
+ {
|
|
|
+ Env.SqlDAL.App_Vertiv_MachineInfoOeeData.Update(
|
|
|
+ $"{T_Col_Name.App_Vertiv_MachineInfoOeeData.Device_Str} = '{deviceName[i]}'",
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.RunDayTime_Int, deviceRunDayTIme),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.AllDayTime_Int, deviceDayTIme),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.Duration_Dec, OeeValue));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OrgID = Guid.NewGuid().ToString();
|
|
|
+ Env.SqlDAL.App_Vertiv_MachineInfoOeeData.Insert(
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.Device_Str, deviceName[i]),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.StateId_Str, OrgID),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.RunDayTime_Int, deviceRunDayTIme),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.AllDayTime_Int, deviceDayTIme),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfoOeeData.Duration_Dec, OeeValue));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|