|
|
|
@ -33,6 +33,7 @@ public class CloudClientMgr
|
|
|
|
|
|
|
|
|
|
static EmeterDayEnergyService emeterDayEnergyService = AppInfo.Container.Resolve<EmeterDayEnergyService>();
|
|
|
|
|
static EmeterHourEnergyService emeterHourEnergyService = AppInfo.Container.Resolve<EmeterHourEnergyService>();
|
|
|
|
|
static BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static DateTime _dateTime = DateTime.Now.AddSeconds(-30);
|
|
|
|
@ -47,6 +48,9 @@ public class CloudClientMgr
|
|
|
|
|
private static DateTime _dateTime9 = DateTime.Today.AddHours(DateTime.Now.Hour - 1);//小时
|
|
|
|
|
private static DateTime _dateTime10 = DateTime.Now.AddDays(-1).Date;//天
|
|
|
|
|
private static DateTime _dateTime11 = DateTime.Now.AddDays(-1).Date;//天
|
|
|
|
|
private static DateTime _dateTime12 = DateTime.Now.AddSeconds(-30);
|
|
|
|
|
private static DateTime _dateTime13 = DateTime.Now.AddSeconds(-30);
|
|
|
|
|
private static DateTime _dateTime14 = DateTime.Now.AddSeconds(-30);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -78,6 +82,8 @@ public class CloudClientMgr
|
|
|
|
|
RedisHelper? redisHelper = AppInfo.Container.Resolve<RedisHelper>();
|
|
|
|
|
BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
|
|
|
|
|
|
CloudApi.SendSignIn();
|
|
|
|
|
|
|
|
|
|
#region 遥测合并上报
|
|
|
|
|
req.datainfo = new List<DataInfo>();
|
|
|
|
|
redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) =>
|
|
|
|
@ -165,8 +171,7 @@ public class CloudClientMgr
|
|
|
|
|
});
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
var sv = StaticStationInfo.StationSftVer.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisHelper?.GetSubscriber().Subscribe("BatteryInfoUploadTask", (channel, value) =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -200,7 +205,6 @@ public class CloudClientMgr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static async Task StartAsyncLoop()
|
|
|
|
|
{
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
@ -211,7 +215,12 @@ public class CloudClientMgr
|
|
|
|
|
{
|
|
|
|
|
if (CloudClient.Connected)
|
|
|
|
|
{
|
|
|
|
|
CloudApi.SendStateLog(0);
|
|
|
|
|
if (StationConstant.StationModel.Remote == BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
|
|
|
|
|
StaticStationInfo.StationModel))
|
|
|
|
|
{
|
|
|
|
|
CloudApi.SendStateLog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskHostStatusReported();
|
|
|
|
|
|
|
|
|
@ -233,7 +242,16 @@ public class CloudClientMgr
|
|
|
|
|
|
|
|
|
|
TaskStaDayOpeEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskStaHourAmountVal();
|
|
|
|
|
//TaskStaHourAmountVal();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SendRealTimeFaultInfo();
|
|
|
|
|
|
|
|
|
|
SendStartLogMessage();
|
|
|
|
|
|
|
|
|
|
SendBatteryTotal();
|
|
|
|
|
|
|
|
|
|
SendChargingTotalDis();
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
@ -313,7 +331,7 @@ public class CloudClientMgr
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskTemperatureHumidityData()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime4).TotalSeconds <= 10)
|
|
|
|
|
if ((DateTime.Now - _dateTime4).TotalSeconds <= 30)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -337,7 +355,7 @@ public class CloudClientMgr
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 电能表累计值信息 15m
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskPowerTotal()//Desc记得改回来
|
|
|
|
|
private static void TaskPowerTotal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime5).TotalMinutes <= 15)
|
|
|
|
|
{
|
|
|
|
@ -736,4 +754,225 @@ public class CloudClientMgr
|
|
|
|
|
CloudApi.SendStaHourAmountVal(staHourAmountVal);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站上报设备列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void SendDevList(int ot)
|
|
|
|
|
{
|
|
|
|
|
EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>();
|
|
|
|
|
var equipList = equipInfoRepository.Query();
|
|
|
|
|
|
|
|
|
|
DevList devList = new()
|
|
|
|
|
{
|
|
|
|
|
ot = ot,
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
vs = "1.0",
|
|
|
|
|
};
|
|
|
|
|
devList.d_info = new List<D_INFO>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < equipList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
D_INFO d_INFO = new D_INFO();
|
|
|
|
|
d_INFO.dn = (equipList[i].TypeCode==0?"充电机":"电表")+ equipList[i].Code;
|
|
|
|
|
d_INFO.dt = equipList[i].TypeCode == 0 ? "充电机" : "电表";
|
|
|
|
|
d_INFO.dc = equipList[i].TypeCode.ToString();
|
|
|
|
|
d_INFO.tc = equipList[i].Status.ToString();
|
|
|
|
|
d_INFO.ds = equipList[i].Id.ToString();
|
|
|
|
|
d_INFO.sn = equipList[i].Code;
|
|
|
|
|
d_INFO.en = "";
|
|
|
|
|
d_INFO.hv = "";
|
|
|
|
|
d_INFO.sv = "";
|
|
|
|
|
d_INFO.mn = "";
|
|
|
|
|
d_INFO.ns = equipList[i].Addr.ToString();
|
|
|
|
|
d_INFO.ti = equipList[i].CreatedTime.ToString();
|
|
|
|
|
|
|
|
|
|
devList.d_info.Add(d_INFO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CloudApi.SendDevList(devList);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 实时故障信息上传
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void SendRealTimeFaultInfo()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
|
|
|
|
|
var AlarmList = equipAlarmRecordRepository.QueryListByClause(u => u.UploadStatus == 0);
|
|
|
|
|
|
|
|
|
|
EquipAlarmProcessRecordRepository equipAlarmProcessRecordRepository = AppInfo.Container.Resolve<EquipAlarmProcessRecordRepository>();
|
|
|
|
|
var AlarmProcessList = equipAlarmProcessRecordRepository.QueryListByClause(u => u.UploadStatus == 0);
|
|
|
|
|
|
|
|
|
|
//产生上传
|
|
|
|
|
for (int i = 0; i < AlarmList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
FaultReport faultReport = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
en= AlarmList[i].EquipCode,
|
|
|
|
|
fc= AlarmList[i].ErrorCode,
|
|
|
|
|
ft= AlarmList[i].ErrorMsg,
|
|
|
|
|
fl= Convert.ToInt32( AlarmList[i].ErrorLevel),
|
|
|
|
|
fg= 1,
|
|
|
|
|
bt= AlarmList[i].StartTime.ToString(),
|
|
|
|
|
cm=1,
|
|
|
|
|
};
|
|
|
|
|
CloudApi.SendRealTimeFaultInfo(faultReport);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//消失上传
|
|
|
|
|
for (int i = 0; i < AlarmProcessList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
FaultReport faultReport = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
en = AlarmProcessList[i].EquipCode,
|
|
|
|
|
fc = AlarmProcessList[i].ErrorCode,
|
|
|
|
|
ft = AlarmProcessList[i].ErrorMsg,
|
|
|
|
|
fl = Convert.ToInt32(AlarmProcessList[i].ErrorLevel),
|
|
|
|
|
fg = 2,
|
|
|
|
|
bt = AlarmProcessList[i].ProcessTime.ToString(),
|
|
|
|
|
cm = 1,
|
|
|
|
|
};
|
|
|
|
|
CloudApi.SendRealTimeFaultInfo(faultReport);
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static List<EquipInfo> equipInfos;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站设备状态开始和结束日志信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void SendStartLogMessage()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime12).TotalSeconds <= 30)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime12 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>();
|
|
|
|
|
var equipList = equipInfoRepository.Query();
|
|
|
|
|
if (equipInfos == null) { equipInfos = equipList; }
|
|
|
|
|
bool variation = false;
|
|
|
|
|
|
|
|
|
|
if (variation)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < equipList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (equipInfos[i].UpdatedTime != equipList[i].UpdatedTime)
|
|
|
|
|
{
|
|
|
|
|
EqmStateEndLogInfo req = new()
|
|
|
|
|
{
|
|
|
|
|
en = StaticStationInfo.StationNo + equipInfos[i].Code,
|
|
|
|
|
sv = Convert.ToByte(equipInfos[i].Status),
|
|
|
|
|
sm = equipInfos[i].Status == 1 ? "启用" : "停用",
|
|
|
|
|
st = equipInfos[i].UpdatedTime,
|
|
|
|
|
et = equipList[i].UpdatedTime,
|
|
|
|
|
ke= (int)(equipList[i].UpdatedTime- equipInfos[i].UpdatedTime).TotalSeconds,
|
|
|
|
|
cm = 1,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < equipList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (equipInfos[i].UpdatedTime != equipList[i].UpdatedTime)
|
|
|
|
|
{
|
|
|
|
|
EqmStateStartLogInfo req = new()
|
|
|
|
|
{
|
|
|
|
|
en = StaticStationInfo.StationNo + equipInfos[i].Code,
|
|
|
|
|
SV = Convert.ToByte(equipInfos[i].Status),
|
|
|
|
|
sm = equipInfos[i].Status == 1 ? "启用": "停用" ,
|
|
|
|
|
st = equipList[i].UpdatedTime,
|
|
|
|
|
cm = 1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CloudApi.SendStartLogMessage(req);
|
|
|
|
|
variation= true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
equipInfos = equipList;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站上报电池状态分布统计信息 2分钟
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void SendBatteryTotal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime13).TotalMinutes <= 2)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime13 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var binList = binInfoRepository.Query();
|
|
|
|
|
int bt = binList.Select(u => u.Exists == 1).Count();
|
|
|
|
|
int ct = binList.Select(u => u.Soc >= StaticStationInfo.SwapSoc).Count();
|
|
|
|
|
int cc = binList.Select(u => u.ChargeStatus ==1).Count();
|
|
|
|
|
int ca = binList.Select(u => u.Soc < StaticStationInfo.SwapSoc).Count();
|
|
|
|
|
BatteryTotal devList = new()
|
|
|
|
|
{
|
|
|
|
|
sn= StaticStationInfo.StationNo,
|
|
|
|
|
btc=1,
|
|
|
|
|
sm="99999999",
|
|
|
|
|
bn="默认型号",
|
|
|
|
|
bc= bt,
|
|
|
|
|
ct= ct,
|
|
|
|
|
cc=cc,
|
|
|
|
|
ca=ca,
|
|
|
|
|
ut=DateTime.Now,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CloudApi.SendBatteryTotal(devList);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站充电电池电量分布统计信息 2分钟
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void SendChargingTotalDis()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime14).TotalMinutes <= 2)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime14 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var binList = binInfoRepository.Query();
|
|
|
|
|
int hc = binList.Select(u => u.Soc >= 90).Count();
|
|
|
|
|
int mc = binList.Select(u => u.Soc >= 80&& u.Soc<90).Count();
|
|
|
|
|
int lc = binList.Select(u => u.Soc >= 0&& u.Soc<80).Count();
|
|
|
|
|
|
|
|
|
|
ChargingTotalDis req = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
bs = "99999999",
|
|
|
|
|
bn = "默认型号",
|
|
|
|
|
hc = hc,
|
|
|
|
|
mc = mc,
|
|
|
|
|
lc = lc,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CloudApi.SendChargingTotalDis(req);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|