|
|
|
@ -33,24 +33,31 @@ 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);
|
|
|
|
|
private static DateTime _dateTime1 = DateTime.Now.AddSeconds(-30);
|
|
|
|
|
private static DateTime _dateTime2 = DateTime.Now.AddSeconds(-10);
|
|
|
|
|
private static DateTime _dateTime3 = DateTime.Now.AddSeconds(-10);
|
|
|
|
|
private static DateTime _dateTime4 = DateTime.Now.AddSeconds(-10);
|
|
|
|
|
private static DateTime _dateTime5 = DateTime.Now.AddMinutes(-15);//15分钟
|
|
|
|
|
private static DateTime _dateTime6 = DateTime.Now.AddMinutes(-15);//15分钟
|
|
|
|
|
private static DateTime _dateTime7 = DateTime.Today.AddHours(DateTime.Now.Hour-1);//小时
|
|
|
|
|
private static DateTime _dateTime8 = DateTime.Now.AddDays(-1).Date;//天
|
|
|
|
|
private static DateTime _dateTime8 = DateTime.Now.AddDays(-1).Date.AddHours(2);//天,每天两点
|
|
|
|
|
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 _dateTime10 = DateTime.Now.AddDays(-1).Date.AddHours(2);//天,每天两点
|
|
|
|
|
private static DateTime _dateTime11 = DateTime.Now.AddDays(-1).Date.AddHours(2);//天,每天两点
|
|
|
|
|
private static DateTime _dateTime12 = DateTime.Now.AddSeconds(-30);
|
|
|
|
|
private static DateTime _dateTime13 = DateTime.Now.AddSeconds(-30);
|
|
|
|
|
private static DateTime _dateTime14 = DateTime.Now.AddSeconds(-30);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private const int TimeSpan = 5;
|
|
|
|
|
|
|
|
|
|
private static ChargeDevDataInfo req = new ChargeDevDataInfo();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static async void Init()
|
|
|
|
|
{
|
|
|
|
@ -69,62 +76,89 @@ public class CloudClientMgr
|
|
|
|
|
CloudClient.AutoReConnect = true;
|
|
|
|
|
|
|
|
|
|
CloudClient.InitHandler();
|
|
|
|
|
var ddddd = CloudClient.Connected;
|
|
|
|
|
Task.Run(() => CloudClient.Connect());
|
|
|
|
|
|
|
|
|
|
RedisHelper? redisHelper = AppInfo.Container.Resolve<RedisHelper>();
|
|
|
|
|
BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 遥测合并上报
|
|
|
|
|
req.datainfo = new List<DataInfo>();
|
|
|
|
|
redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"receive UploadTelemetryData={value}");
|
|
|
|
|
|
|
|
|
|
if (value.HasValue)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
UploadTelemetryData? data = JsonConvert.DeserializeObject<UploadTelemetryData>(value.ToString());
|
|
|
|
|
if (data != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
BinInfo? binInfo = binInfoRepository.QueryByClause(it => it.ChargerNo == data.ChargerNo);
|
|
|
|
|
ChargeDevDataInfo req = new ChargeDevDataInfo();
|
|
|
|
|
//ChargeDevDataInfo req = new ChargeDevDataInfo();
|
|
|
|
|
req.sn = StaticStationInfo.StationNo;
|
|
|
|
|
req.en = StaticStationInfo.StationNo + data.ChargerNo;
|
|
|
|
|
req.sd = "A" + int.Parse(binInfo.No);
|
|
|
|
|
req.mtp = StaticStationInfo.ChargePower;
|
|
|
|
|
req.mcr = 1;
|
|
|
|
|
req.hb = binInfo?.Exists ?? 0;
|
|
|
|
|
req.el = 0;
|
|
|
|
|
req.cno = int.Parse(binInfo.No);
|
|
|
|
|
req.cs = binInfo.ChargeStatus ?? 0;
|
|
|
|
|
req.fs = 0;
|
|
|
|
|
req.@as = 0;
|
|
|
|
|
//fc = data.,
|
|
|
|
|
//st = data.,
|
|
|
|
|
req.ct = data.ChargingTime;
|
|
|
|
|
//ssoc = data.,
|
|
|
|
|
req.csoc = data.CurrentSoc;
|
|
|
|
|
//ssoe = data.,
|
|
|
|
|
//csoe = data.,
|
|
|
|
|
req.cvot = data.BmsChargingVoltage;
|
|
|
|
|
req.ccur = data.BmsChargingCurrent;
|
|
|
|
|
req.nvot = data.BmsNeedVoltage;
|
|
|
|
|
req.ncur = data.BmsNeedCurrent;
|
|
|
|
|
req.lsv = data.SingleBatteryMinVoltage;
|
|
|
|
|
req.hsv = data.SingleBatteryMaxVoltage;
|
|
|
|
|
req.lst = data.MinBatteryTemp;
|
|
|
|
|
req.hst = data.MaxBatteryTemp;
|
|
|
|
|
req.ws = 0xFF;
|
|
|
|
|
req.it = 0xFF;
|
|
|
|
|
req.ot = 0xFF;
|
|
|
|
|
req.bt = DateTime.Now;
|
|
|
|
|
DataInfo dataInfo = new DataInfo();
|
|
|
|
|
dataInfo.en = StaticStationInfo.StationNo + data.ChargerNo;
|
|
|
|
|
|
|
|
|
|
var areNotEqual = !dataInfo.en.Equals(
|
|
|
|
|
req.datainfo.Select(d => d.en)
|
|
|
|
|
.ToList()
|
|
|
|
|
.Any(x => x == dataInfo.en));
|
|
|
|
|
if (areNotEqual)//如果没有重复的
|
|
|
|
|
{
|
|
|
|
|
dataInfo.sd = "A" + int.Parse(binInfo.No);
|
|
|
|
|
dataInfo.mtp = StaticStationInfo.ChargePower;
|
|
|
|
|
dataInfo.mcr = 1;
|
|
|
|
|
dataInfo.hb = binInfo?.Exists ?? 0;
|
|
|
|
|
dataInfo.el = 0;
|
|
|
|
|
dataInfo.cno = int.Parse(binInfo.No);
|
|
|
|
|
dataInfo.cs = binInfo.ChargeStatus ?? 0;
|
|
|
|
|
dataInfo.fs = 0;
|
|
|
|
|
dataInfo.@as = 0;
|
|
|
|
|
//fc = data.,
|
|
|
|
|
//st = data.,
|
|
|
|
|
dataInfo.ct = data.ChargingTime;
|
|
|
|
|
//ssoc = data.,
|
|
|
|
|
dataInfo.csoc = data.CurrentSoc;
|
|
|
|
|
//ssoe = data.,
|
|
|
|
|
//csoe = data.,
|
|
|
|
|
dataInfo.cvot = data.BmsChargingVoltage;
|
|
|
|
|
dataInfo.ccur = data.BmsChargingCurrent;
|
|
|
|
|
dataInfo.nvot = data.BmsNeedVoltage;
|
|
|
|
|
dataInfo.ncur = data.BmsNeedCurrent;
|
|
|
|
|
dataInfo.lsv = data.SingleBatteryMinVoltage;
|
|
|
|
|
dataInfo.hsv = data.SingleBatteryMaxVoltage;
|
|
|
|
|
dataInfo.lst = data.MinBatteryTemp;
|
|
|
|
|
dataInfo.hst = data.MaxBatteryTemp;
|
|
|
|
|
dataInfo.ws = 0xFF;
|
|
|
|
|
dataInfo.it = 0xFF;
|
|
|
|
|
dataInfo.ot = 0xFF;
|
|
|
|
|
dataInfo.bt = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
if (req.datainfo.Count < 7)
|
|
|
|
|
{
|
|
|
|
|
req.datainfo.Add(dataInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((DateTime.Now - _dateTime).TotalSeconds <= 30)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dateTime = DateTime.Now;
|
|
|
|
|
CloudClient?.SendChargeDevDataInfo(req);
|
|
|
|
|
|
|
|
|
|
if (req.datainfo.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
CloudClient?.SendChargeDevDataInfo(req);
|
|
|
|
|
|
|
|
|
|
req = new ChargeDevDataInfo();
|
|
|
|
|
req.datainfo = new List<DataInfo>();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Log.Info($"receive UploadTelemetryData={value}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -133,7 +167,9 @@ public class CloudClientMgr
|
|
|
|
|
Log.Info("error", e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
redisHelper?.GetSubscriber().Subscribe("BatteryInfoUploadTask", (channel, value) =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -144,6 +180,11 @@ public class CloudClientMgr
|
|
|
|
|
BatDataInfo? data = JsonConvert.DeserializeObject<BatDataInfo>(value.ToString());
|
|
|
|
|
if (data != null)
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime1).TotalSeconds <= 30)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime1 = DateTime.Now;
|
|
|
|
|
CloudClient?.SendBatDataInfo(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -154,15 +195,13 @@ public class CloudClientMgr
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StartAsyncLoop();
|
|
|
|
|
StartAsyncLoop();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static async Task StartAsyncLoop()
|
|
|
|
|
{
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
@ -173,30 +212,44 @@ public class CloudClientMgr
|
|
|
|
|
{
|
|
|
|
|
if (CloudClient.Connected)
|
|
|
|
|
{
|
|
|
|
|
//Log.Info("测试111111111111111111111111111111111111111111111111111111111111111111111111111111");
|
|
|
|
|
CloudApi.SendStateLog(0);
|
|
|
|
|
|
|
|
|
|
//if (StationConstant.StationModel.Remote == BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
|
|
|
|
|
//StaticStationInfo.StationModel))
|
|
|
|
|
//{
|
|
|
|
|
// CloudApi.SendStateLog();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskHostStatusReported();
|
|
|
|
|
|
|
|
|
|
TaskAirConditioningData();
|
|
|
|
|
//TaskAirConditioningData();
|
|
|
|
|
|
|
|
|
|
//TaskTemperatureHumidityData();
|
|
|
|
|
|
|
|
|
|
//TaskPowerTotal();
|
|
|
|
|
|
|
|
|
|
//TaskStaChargingTota();
|
|
|
|
|
|
|
|
|
|
//TaskMeterEnergyKwh();
|
|
|
|
|
|
|
|
|
|
//TaskMeterDayEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskTemperatureHumidityData();
|
|
|
|
|
//TaskStaHourEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskPowerTotal();
|
|
|
|
|
//TaskStaDayEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskStaChargingTota();
|
|
|
|
|
//TaskStaDayOpeEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskMeterEnergyKwh();
|
|
|
|
|
////TaskStaHourAmountVal();
|
|
|
|
|
|
|
|
|
|
TaskMeterDayEnergyVal();
|
|
|
|
|
|
|
|
|
|
TaskStaHourEnergyVal();
|
|
|
|
|
//SendRealTimeFaultInfo();
|
|
|
|
|
|
|
|
|
|
TaskStaDayEnergyVal();
|
|
|
|
|
//SendStartLogMessage();
|
|
|
|
|
|
|
|
|
|
TaskStaDayOpeEnergyVal();
|
|
|
|
|
//SendBatteryTotal();
|
|
|
|
|
|
|
|
|
|
TaskStaHourAmountVal();
|
|
|
|
|
//SendChargingTotalDis();
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
@ -225,14 +278,15 @@ public class CloudClientMgr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dateTime2 = DateTime.Now;
|
|
|
|
|
EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
|
|
|
|
|
var EquipAlarm = equipAlarmRecordRepository.Query();
|
|
|
|
|
var ErrorLevel = Convert.ToInt32(EquipAlarm.Min(x => x.ErrorLevel));
|
|
|
|
|
|
|
|
|
|
//EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
|
|
|
|
|
//var EquipAlarm = equipAlarmRecordRepository.Query();
|
|
|
|
|
//var ErrorLevel = Convert.ToInt32(EquipAlarm.Min(x => x.ErrorLevel));
|
|
|
|
|
StationRunStatus stationRunStatus = new()
|
|
|
|
|
{
|
|
|
|
|
rs = StaticStationInfo.StationStatus == 1 ? 1 : 2,
|
|
|
|
|
rs = StaticStationInfo.Sevstatus,
|
|
|
|
|
os = StaticStationInfo.StationStatus,
|
|
|
|
|
fl = ErrorLevel,
|
|
|
|
|
fl =Convert.ToInt32( StaticStationInfo.Faultlevel),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -275,7 +329,7 @@ public class CloudClientMgr
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskTemperatureHumidityData()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime4).TotalSeconds <= 10)
|
|
|
|
|
if ((DateTime.Now - _dateTime4).TotalSeconds <= 30)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -299,7 +353,7 @@ public class CloudClientMgr
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 电能表累计值信息 15m
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskPowerTotal()//Desc记得改回来
|
|
|
|
|
private static void TaskPowerTotal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime5).TotalMinutes <= 15)
|
|
|
|
|
{
|
|
|
|
@ -325,7 +379,7 @@ public class CloudClientMgr
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
powerTotal.meter = new List<meter>();
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
for (int i = 0; i < emeterEnergy.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
meter meter = new()
|
|
|
|
|
{
|
|
|
|
@ -336,7 +390,7 @@ public class CloudClientMgr
|
|
|
|
|
};
|
|
|
|
|
powerTotal.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0;i < 7; i++)
|
|
|
|
|
for (int i = 0; i < emeterEnergyChange.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
meter meter = new()
|
|
|
|
|
{
|
|
|
|
@ -347,7 +401,8 @@ public class CloudClientMgr
|
|
|
|
|
};
|
|
|
|
|
powerTotal.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CloudApi.SendPowerTotal(powerTotal);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -383,7 +438,8 @@ public class CloudClientMgr
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
staChargingTotal.meter = new List<meter2>();
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < emeterEnergy.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
@ -396,7 +452,7 @@ public class CloudClientMgr
|
|
|
|
|
};
|
|
|
|
|
staChargingTotal.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
for (int i = 0; i < emeterEnergyChange.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
@ -424,7 +480,7 @@ public class CloudClientMgr
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dateTime7 = DateTime.Now;
|
|
|
|
|
_dateTime7 = DateTime.Today.AddHours(DateTime.Now.Hour);
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterHourEnergyService.QueryListByClause(u => u.UploadFlag == 0, 14, i => i.Time,
|
|
|
|
|
OrderByType.Desc);
|
|
|
|
@ -440,7 +496,7 @@ public class CloudClientMgr
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter = new List<meter2>();
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
for (int i = 0; i < emeterEnergy1.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
@ -455,7 +511,7 @@ public class CloudClientMgr
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
for (int i = 0; i < emeterEnergy2.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
@ -465,8 +521,8 @@ public class CloudClientMgr
|
|
|
|
|
mk = emeterEnergy2[i].Value,
|
|
|
|
|
//st = DateTime.Now.AddMinutes(-15),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy1[i].Time),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy1[i].Time).AddHours(1),
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy2[i].Time),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy2[i].Time).AddHours(1),
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
@ -489,7 +545,7 @@ public class CloudClientMgr
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime8 = DateTime.Now;
|
|
|
|
|
_dateTime8 = DateTime.Now.Date.AddHours(2);
|
|
|
|
|
|
|
|
|
|
EmeterDayEnergyService emeterDayEnergyService = AppInfo.Container.Resolve<EmeterDayEnergyService>();
|
|
|
|
|
|
|
|
|
@ -507,7 +563,7 @@ public class CloudClientMgr
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter = new List<meter2>();
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
for (int i = 0; i < emeterEnergy1.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
@ -522,7 +578,7 @@ public class CloudClientMgr
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter.Add(meter);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
for (int i = 0; i < emeterEnergy2.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
meter2 meter = new()
|
|
|
|
|
{
|
|
|
|
@ -532,8 +588,8 @@ public class CloudClientMgr
|
|
|
|
|
mk = emeterEnergy2[i].Value,
|
|
|
|
|
//st = DateTime.Now.AddDays(-1),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy1[i].Time).AddDays(-1),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy1[i].Time),
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy2[i].Time).AddDays(-1),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy2[i].Time),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
meterEnergyKwh.meter.Add(meter);
|
|
|
|
@ -558,7 +614,7 @@ public class CloudClientMgr
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime9 = DateTime.Now;
|
|
|
|
|
_dateTime9 = DateTime.Today.AddHours(DateTime.Now.Hour);
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterHourEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
|
|
|
|
|
OrderByType.Desc);
|
|
|
|
@ -591,7 +647,7 @@ public class CloudClientMgr
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime10 = DateTime.Now;
|
|
|
|
|
_dateTime10 = DateTime.Now.Date.AddHours(2);
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
|
|
|
|
|
OrderByType.Desc);
|
|
|
|
@ -626,76 +682,303 @@ public class CloudClientMgr
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime11 = DateTime.Now;
|
|
|
|
|
_dateTime11 = DateTime.Now.Date.AddHours(2);
|
|
|
|
|
|
|
|
|
|
ExStationDayRunResultService exStationDayRunResultService = AppInfo.Container.Resolve<ExStationDayRunResultService>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var exStationDayRunResult = exStationDayRunResultService.QueryByClause(u => u.Id !=0, i => i.CreatedTime,
|
|
|
|
|
OrderByType.Desc);
|
|
|
|
|
if (exStationDayRunResult!=null)
|
|
|
|
|
{
|
|
|
|
|
StaDayOpeEnergyVal staDayOpeEnergyVal = new()
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
sm = StaticStationInfo.StationName,
|
|
|
|
|
st = Convert.ToDateTime(exStationDayRunResult?.RunStartTime),
|
|
|
|
|
et = Convert.ToDateTime(exStationDayRunResult?.RunEndTime),
|
|
|
|
|
tt = Convert.ToInt32(exStationDayRunResult?.ToltalTimeCount),
|
|
|
|
|
ft = exStationDayRunResult?.FristSwapTime,
|
|
|
|
|
sp = exStationDayRunResult?.StopTime,
|
|
|
|
|
ts = Convert.ToSingle(exStationDayRunResult?.ToltalSwapAllTime * 60),
|
|
|
|
|
tc = Convert.ToInt32(exStationDayRunResult?.ToltalSwapCount),
|
|
|
|
|
cc = Convert.ToInt32(exStationDayRunResult?.ChgCount),
|
|
|
|
|
os = Convert.ToByte(exStationDayRunResult?.State),
|
|
|
|
|
at = Convert.ToSingle(exStationDayRunResult?.AvgRepTime),
|
|
|
|
|
ct = Convert.ToSingle(exStationDayRunResult?.AvgChgTime),
|
|
|
|
|
dt = Convert.ToDateTime(exStationDayRunResult?.SwapDate),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CloudApi.SendStaDayOpeEnergyVal(staDayOpeEnergyVal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站分时用电统计信息(站控不计价,这一帧不要)
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskStaHourAmountVal()
|
|
|
|
|
{
|
|
|
|
|
//if ((DateTime.Now - _dateTime2).TotalSeconds <= 30)
|
|
|
|
|
//{
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//_dateTime2 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
//var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
|
|
|
|
|
// OrderByType.Desc);
|
|
|
|
|
//float hc = emeterEnergy.Sum(e => e.Value);
|
|
|
|
|
|
|
|
|
|
//ElecPriceModelVersionDetailServices elecPriceModelVersionDetailServices = AppInfo.Container.Resolve<ElecPriceModelVersionDetailServices>();
|
|
|
|
|
|
|
|
|
|
//var elecPriceModelVersionDetail= elecPriceModelVersionDetailServices.QueryListByClause(u=>u.Version==1);
|
|
|
|
|
//var timeList = elecPriceModelVersionDetail.Select(u => u.StartHour).ToList();
|
|
|
|
|
//int targetTime = DateTime.Now.Hour;
|
|
|
|
|
//int index1 = timeList.FindIndex(time => time > targetTime)-1;
|
|
|
|
|
//index1 = index1<0? timeList.Count-1: index1;
|
|
|
|
|
//int index2 = timeList.FindIndex(time => time == targetTime);
|
|
|
|
|
//int index3 = index2 == -1 ? index1 : index2;
|
|
|
|
|
|
|
|
|
|
//var price = elecPriceModelVersionDetail[index3].Price;
|
|
|
|
|
//StaHourAmountVal staHourAmountVal = new()
|
|
|
|
|
//{
|
|
|
|
|
// sn = StaticStationInfo.StationNo,
|
|
|
|
|
// ht = Convert.ToSingle(hc * price),
|
|
|
|
|
// hc = Convert.ToSingle(hc * price),
|
|
|
|
|
// hs = 0,
|
|
|
|
|
// ho = 0,
|
|
|
|
|
// //st = DateTime.Now.AddHours(-1),
|
|
|
|
|
// //et = DateTime.Now,
|
|
|
|
|
// st = Convert.ToDateTime(emeterEnergy?.First().Time),
|
|
|
|
|
// et = Convert.ToDateTime(emeterEnergy?.First().Time).AddHours(1),
|
|
|
|
|
|
|
|
|
|
//};
|
|
|
|
|
//CloudApi.SendStaHourAmountVal(staHourAmountVal);
|
|
|
|
|
|
|
|
|
|
StaDayOpeEnergyVal staDayOpeEnergyVal = new()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <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,
|
|
|
|
|
sm = StaticStationInfo.StationName,
|
|
|
|
|
st = Convert.ToDateTime(exStationDayRunResult?.RunStartTime),
|
|
|
|
|
et = Convert.ToDateTime(exStationDayRunResult?.RunEndTime),
|
|
|
|
|
tt = Convert.ToInt32(exStationDayRunResult?.ToltalTimeCount),
|
|
|
|
|
//tt = 24 * 60,
|
|
|
|
|
ft = Convert.ToDateTime(exStationDayRunResult?.FristSwapTime),
|
|
|
|
|
sp = Convert.ToDateTime(exStationDayRunResult?.StopTime),
|
|
|
|
|
ts = Convert.ToSingle(exStationDayRunResult?.ToltalSwapAllTime * 60),
|
|
|
|
|
tc = exStationDayRunResult.ToltalSwapCount,
|
|
|
|
|
cc = exStationDayRunResult.ChgCount,
|
|
|
|
|
os = Convert.ToByte(exStationDayRunResult.State),
|
|
|
|
|
at = Convert.ToSingle(exStationDayRunResult?.AvgRepTime),
|
|
|
|
|
ct = Convert.ToSingle(exStationDayRunResult?.AvgChgTime),
|
|
|
|
|
dt = Convert.ToDateTime(exStationDayRunResult?.SwapDate),
|
|
|
|
|
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.SendStaDayOpeEnergyVal(staDayOpeEnergyVal);
|
|
|
|
|
CloudApi.SendDevList(devList);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站分时用电统计信息
|
|
|
|
|
/// 实时故障信息上传
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void TaskStaHourAmountVal()
|
|
|
|
|
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;
|
|
|
|
|
static bool variation = false;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站设备状态开始和结束日志信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void SendStartLogMessage()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime2).TotalSeconds <= 30)
|
|
|
|
|
if ((DateTime.Now - _dateTime12).TotalSeconds <= 30)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_dateTime2 = DateTime.Now;
|
|
|
|
|
_dateTime12 = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
|
|
|
|
|
OrderByType.Desc);
|
|
|
|
|
float hc = emeterEnergy.Sum(e => e.Value);
|
|
|
|
|
EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>();
|
|
|
|
|
var equipList = equipInfoRepository.Query();
|
|
|
|
|
if (equipInfos == null) { equipInfos = equipList; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ElecPriceModelVersionDetailServices elecPriceModelVersionDetailServices = AppInfo.Container.Resolve<ElecPriceModelVersionDetailServices>();
|
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
CloudApi.SendEndLogMessage(req);
|
|
|
|
|
variation = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elecPriceModelVersionDetail= elecPriceModelVersionDetailServices.QueryListByClause(u=>u.Version==1);
|
|
|
|
|
var timeList = elecPriceModelVersionDetail.Select(u => u.StartHour).ToList();
|
|
|
|
|
int targetTime = DateTime.Now.Hour;
|
|
|
|
|
int index1 = timeList.FindIndex(time => time > targetTime)-1;
|
|
|
|
|
index1 = index1<0? timeList.Count-1: index1;
|
|
|
|
|
int index2 = timeList.FindIndex(time => time == targetTime);
|
|
|
|
|
int index3 = index2 == -1 ? index1 : index2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var price = elecPriceModelVersionDetail[index3].Price;
|
|
|
|
|
StaHourAmountVal staHourAmountVal = new()
|
|
|
|
|
equipInfos = equipList;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换电站上报电池状态分布统计信息 2分钟
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void SendBatteryTotal()
|
|
|
|
|
{
|
|
|
|
|
if ((DateTime.Now - _dateTime13).TotalMinutes <= 2)
|
|
|
|
|
{
|
|
|
|
|
sn = StaticStationInfo.StationNo,
|
|
|
|
|
ht = Convert.ToSingle(hc * price),
|
|
|
|
|
hc = Convert.ToSingle(hc * price),
|
|
|
|
|
hs = 0,
|
|
|
|
|
ho = 0,
|
|
|
|
|
//st = DateTime.Now.AddHours(-1),
|
|
|
|
|
//et = DateTime.Now,
|
|
|
|
|
st = Convert.ToDateTime(emeterEnergy?.First().Time),
|
|
|
|
|
et = Convert.ToDateTime(emeterEnergy?.First().Time).AddHours(1),
|
|
|
|
|
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.SendStaHourAmountVal(staHourAmountVal);
|
|
|
|
|
|
|
|
|
|
CloudApi.SendChargingTotalDis(req);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|