TODO 能耗定时上传
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using JY.MES;
|
||||
using JY.Inspection.Common;
|
||||
using JY.MES;
|
||||
using JY.MES.Entity;
|
||||
using JY.MES.Enum;
|
||||
using JY.MES.Exceptions;
|
||||
@@ -8,6 +9,7 @@ using JY.Utility;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using NPOI.OpenXmlFormats.Spreadsheet;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -55,6 +57,7 @@ namespace JY.Inspection.Mes
|
||||
// TODO 上传设备报警信息
|
||||
|
||||
// TODO 能耗
|
||||
void UpEnergyDataMqtt(List<double> dataList);
|
||||
|
||||
// TODO 设备打标
|
||||
}
|
||||
@@ -380,5 +383,46 @@ namespace JY.Inspection.Mes
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
// TODO 能耗定时上传
|
||||
public void UpEnergyDataMqtt(List<double> dataList)
|
||||
{
|
||||
if (dataList == null || dataList.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string topic = $"EVE/{Global.systemConfig.siteCode}/EQP/{Global.systemConfig.equipCode}";
|
||||
|
||||
CmdEnergyData cmd = new CmdEnergyData() {
|
||||
// TODO BU编码
|
||||
Bu_id = string.Empty,
|
||||
// TODO 区域简称
|
||||
District_id = string.Empty,
|
||||
Factory_id = Global.systemConfig.siteCode,
|
||||
Production_line_id = Global.systemConfig.lineCode,
|
||||
Production_processes_id = string.Empty,
|
||||
Work_center_id = string.Empty,
|
||||
Station_id = string.Empty,
|
||||
Device_name = Global.systemConfig.equipCode,
|
||||
};
|
||||
|
||||
string[] dataNameArr = new string[] {
|
||||
"相电压UA", "相电压UB","相电压UC","线电压UAB","线电压UBC","线电压UAC","电流IA","电流IB",
|
||||
"电流IC","A相有功功率","B相有功功率","C相有功功率","总有功功率"
|
||||
};
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
cmd.Taglist.Add(new CollectionItem() {
|
||||
Equipment_Code = Global.systemConfig.equipCode,
|
||||
EMeter_Name = dataNameArr[i],
|
||||
EMeter_Value = dataList[i].ToString()
|
||||
});
|
||||
}
|
||||
|
||||
string payload = JsonHelper.Serialize(cmd);
|
||||
|
||||
MqttSingleton.Instance.SendAsync(topic, payload).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user