|
@@ -183,7 +183,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
machineStateResumeModel.StateCode = reg.Comment.Annotation;
|
|
|
machineStateResumeModels.Add(machineStateResumeModel);
|
|
|
machineStateResumeModel.StartTime = DateTime.Parse(DateTime.Now.Format());
|
|
|
- machineStateResumeModel.TagName = reg.Comment.Variable;
|
|
|
+ machineStateResumeModel.TagName = reg.Comment.RegName;
|
|
|
Env.SqlDAL.App_Vertiv_MachineInfo.Insert(
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateId_Str, machineStateResumeModel.StateId),
|
|
|
new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.StateCode_Str, reg.Comment.Annotation),
|
|
@@ -201,7 +201,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
if (machineStateResumeModels.Count > 0)
|
|
|
{
|
|
|
- if (machineStateResumeModels[0].TagName == reg.Comment.Variable)
|
|
|
+ if (machineStateResumeModels[0].StateCode == reg.Comment.Variable)
|
|
|
{
|
|
|
machineStateResumeModels[0].EndTime = DateTime.Parse(DateTime.Now.Format());
|
|
|
Env.SqlDAL.App_Vertiv_MachineInfo.Update(
|
|
@@ -231,14 +231,45 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
//断线更新数据
|
|
|
if (machineStateResumeModels.Count > 0)
|
|
|
{
|
|
|
- machineStateResumeModels[0].EndTime = DateTime.Parse(DateTime.Now.Format());
|
|
|
- Env.SqlDAL.App_Vertiv_MachineInfo.Update(
|
|
|
- $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{machineStateResumeModels[0].StateId}'",
|
|
|
- new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now.Format()),
|
|
|
- new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime),
|
|
|
- new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime).TotalSeconds)
|
|
|
- );
|
|
|
- machineStateResumeModels.RemoveAt(0);
|
|
|
+ if (machineStateResumeModels.Count == 1)
|
|
|
+ {
|
|
|
+ machineStateResumeModels[0].EndTime = DateTime.Parse(DateTime.Now.Format());
|
|
|
+ Env.SqlDAL.App_Vertiv_MachineInfo.Update(
|
|
|
+ $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{machineStateResumeModels[0].StateId}'",
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, DateTime.Now.Format()),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (machineStateResumeModels[0].EndTime - machineStateResumeModels[0].StartTime).TotalSeconds)
|
|
|
+ );
|
|
|
+ machineStateResumeModels.RemoveAt(0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var orderTime = machineStateResumeModels.OrderBy(t=>t.StartTime).ToList();
|
|
|
+ for (int i = 0; i < orderTime.Count; i++)
|
|
|
+ {
|
|
|
+ if (i < orderTime.Count - 1)
|
|
|
+ {
|
|
|
+ orderTime[i].EndTime = orderTime[i+1].StartTime;
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (i == orderTime.Count - 1)
|
|
|
+ {
|
|
|
+ orderTime[i].EndTime = DateTime.Parse(DateTime.Now.Format());
|
|
|
+
|
|
|
+ }
|
|
|
+ Env.SqlDAL.App_Vertiv_MachineInfo.Update(
|
|
|
+ $"{T_Col_Name.App_Vertiv_MachineInfo.StateId_Str} = '{orderTime[i].StateId}'",
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.EndTime_Dt, orderTime[i].EndTime),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.Duration_Dt, orderTime[i].EndTime - orderTime[i].StartTime),
|
|
|
+ new UpdateItem(T_Col_Name.App_Vertiv_MachineInfo.DurationSec_Int, (orderTime[i].EndTime - orderTime[i].StartTime).TotalSeconds)
|
|
|
+ );
|
|
|
+ ListenReg[orderTime[i].TagName].Value = 0;
|
|
|
+ //machineStateResumeModels.RemoveAt(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ machineStateResumeModels.Clear();
|
|
|
+
|
|
|
+
|
|
|
//不写Log
|
|
|
//Log.Info($"设备名{BaseDevice.DeviceID},断线更新状态{machineStateResumeModels[0].StateCode},记录列表有{machineStateResumeModels.Count}条数据");
|
|
|
}
|
|
@@ -293,6 +324,7 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
InsertStateRecord(reg);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public override void Dispose()
|