master
xjl 4 months ago
parent 3598548143
commit 27e52554a6

@ -118,7 +118,7 @@ public class StationParamConst
/// <summary> /// <summary>
/// 总体故障等级 /// 总体故障等级
/// </summary> /// </summary>
public static readonly string? Faultlevel = "Station.Faultlevel"; public static readonly string Faultlevel = "Station.Faultlevel";
/// <summary> /// <summary>
/// 加解锁方式 /// 加解锁方式
@ -148,7 +148,7 @@ public class StationParamConst
/// <summary> /// <summary>
/// 配电容量kVA /// 配电容量kVA
/// </summary> /// </summary>
public static readonly string? DistributionCapacity = "Station.DistributionCapacity"; public static readonly string DistributionCapacity = "Station.DistributionCapacity";
/// <summary> /// <summary>
/// 总功率kW /// 总功率kW
@ -204,6 +204,9 @@ public class StationParamConst
//电价模型 //电价模型
public static readonly string Ceid = "Station.Ceid"; public static readonly string Ceid = "Station.Ceid";
/// <summary>
/// 运营状态
/// </summary>
public static readonly string StationStatus = "Station.StationStatus"; public static readonly string StationStatus = "Station.StationStatus";
public static readonly string StationWay = "Station.StationWay"; public static readonly string StationWay = "Station.StationWay";
public static readonly string StationModel = "Station.StationModel"; public static readonly string StationModel = "Station.StationModel";

@ -36,6 +36,7 @@ public class CloudClientMgr
private static DateTime _dateTime = DateTime.Now.AddSeconds(-30); 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 _dateTime2 = DateTime.Now.AddSeconds(-10);
private static DateTime _dateTime3 = DateTime.Now.AddSeconds(-10); private static DateTime _dateTime3 = DateTime.Now.AddSeconds(-10);
private static DateTime _dateTime4 = DateTime.Now.AddSeconds(-10); private static DateTime _dateTime4 = DateTime.Now.AddSeconds(-10);
@ -51,6 +52,8 @@ public class CloudClientMgr
private const int TimeSpan = 5; private const int TimeSpan = 5;
private static ChargeDevDataInfo req = new ChargeDevDataInfo();
public static async void Init() public static async void Init()
{ {
@ -74,57 +77,84 @@ public class CloudClientMgr
RedisHelper? redisHelper = AppInfo.Container.Resolve<RedisHelper>(); RedisHelper? redisHelper = AppInfo.Container.Resolve<RedisHelper>();
BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>(); BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
#region 遥测合并上报
req.datainfo = new List<DataInfo>();
redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) => redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) =>
{ {
try try
{ {
Log.Info($"receive UploadTelemetryData={value}");
if (value.HasValue) if (value.HasValue)
{ {
UploadTelemetryData? data = JsonConvert.DeserializeObject<UploadTelemetryData>(value.ToString()); UploadTelemetryData? data = JsonConvert.DeserializeObject<UploadTelemetryData>(value.ToString());
if (data != null) if (data != null)
{ {
BinInfo? binInfo = binInfoRepository.QueryByClause(it => it.ChargerNo == data.ChargerNo); BinInfo? binInfo = binInfoRepository.QueryByClause(it => it.ChargerNo == data.ChargerNo);
ChargeDevDataInfo req = new ChargeDevDataInfo(); //ChargeDevDataInfo req = new ChargeDevDataInfo();
req.sn = StaticStationInfo.StationNo; req.sn = StaticStationInfo.StationNo;
req.en = StaticStationInfo.StationNo + data.ChargerNo; DataInfo dataInfo = new DataInfo();
req.sd = "A" + int.Parse(binInfo.No); dataInfo.en = StaticStationInfo.StationNo + data.ChargerNo;
req.mtp = StaticStationInfo.ChargePower;
req.mcr = 1; var areNotEqual = !dataInfo.en.Equals(
req.hb = binInfo?.Exists ?? 0; req.datainfo.Select(d => d.en)
req.el = 0; .ToList()
req.cno = int.Parse(binInfo.No); .Any(x => x == dataInfo.en));
req.cs = binInfo.ChargeStatus ?? 0; if (areNotEqual)//如果没有重复的
req.fs = 0; {
req.@as = 0; 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., //fc = data.,
//st = data., //st = data.,
req.ct = data.ChargingTime; dataInfo.ct = data.ChargingTime;
//ssoc = data., //ssoc = data.,
req.csoc = data.CurrentSoc; dataInfo.csoc = data.CurrentSoc;
//ssoe = data., //ssoe = data.,
//csoe = data., //csoe = data.,
req.cvot = data.BmsChargingVoltage; dataInfo.cvot = data.BmsChargingVoltage;
req.ccur = data.BmsChargingCurrent; dataInfo.ccur = data.BmsChargingCurrent;
req.nvot = data.BmsNeedVoltage; dataInfo.nvot = data.BmsNeedVoltage;
req.ncur = data.BmsNeedCurrent; dataInfo.ncur = data.BmsNeedCurrent;
req.lsv = data.SingleBatteryMinVoltage; dataInfo.lsv = data.SingleBatteryMinVoltage;
req.hsv = data.SingleBatteryMaxVoltage; dataInfo.hsv = data.SingleBatteryMaxVoltage;
req.lst = data.MinBatteryTemp; dataInfo.lst = data.MinBatteryTemp;
req.hst = data.MaxBatteryTemp; dataInfo.hst = data.MaxBatteryTemp;
req.ws = 0xFF; dataInfo.ws = 0xFF;
req.it = 0xFF; dataInfo.it = 0xFF;
req.ot = 0xFF; dataInfo.ot = 0xFF;
req.bt = DateTime.Now; dataInfo.bt = DateTime.Now;
if (req.datainfo.Count < 7)
{
req.datainfo.Add(dataInfo);
}
}
if ((DateTime.Now - _dateTime).TotalSeconds <= 30) if ((DateTime.Now - _dateTime).TotalSeconds <= 30)
{ {
return; return;
} }
_dateTime = DateTime.Now; _dateTime = DateTime.Now;
if (req.datainfo.Count > 0)
{
CloudClient?.SendChargeDevDataInfo(req); CloudClient?.SendChargeDevDataInfo(req);
req = new ChargeDevDataInfo();
req.datainfo = new List<DataInfo>();
}
Log.Info($"receive UploadTelemetryData={value}");
} }
} }
} }
@ -133,6 +163,9 @@ public class CloudClientMgr
Log.Info("error", e); Log.Info("error", e);
} }
}); });
#endregion
var sv = StaticStationInfo.StationSftVer.ToString();
redisHelper?.GetSubscriber().Subscribe("BatteryInfoUploadTask", (channel, value) => redisHelper?.GetSubscriber().Subscribe("BatteryInfoUploadTask", (channel, value) =>
{ {
@ -144,6 +177,11 @@ public class CloudClientMgr
BatDataInfo? data = JsonConvert.DeserializeObject<BatDataInfo>(value.ToString()); BatDataInfo? data = JsonConvert.DeserializeObject<BatDataInfo>(value.ToString());
if (data != null) if (data != null)
{ {
if ((DateTime.Now - _dateTime1).TotalSeconds <= 30)
{
return;
}
_dateTime1 = DateTime.Now;
CloudClient?.SendBatDataInfo(data); CloudClient?.SendBatDataInfo(data);
} }
} }
@ -173,7 +211,6 @@ public class CloudClientMgr
{ {
if (CloudClient.Connected) if (CloudClient.Connected)
{ {
//Log.Info("测试111111111111111111111111111111111111111111111111111111111111111111111111111111");
CloudApi.SendStateLog(0); CloudApi.SendStateLog(0);
TaskHostStatusReported(); TaskHostStatusReported();
@ -225,14 +262,15 @@ public class CloudClientMgr
} }
_dateTime2 = DateTime.Now; _dateTime2 = DateTime.Now;
EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
var EquipAlarm = equipAlarmRecordRepository.Query(); //EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
var ErrorLevel = Convert.ToInt32(EquipAlarm.Min(x => x.ErrorLevel)); //var EquipAlarm = equipAlarmRecordRepository.Query();
//var ErrorLevel = Convert.ToInt32(EquipAlarm.Min(x => x.ErrorLevel));
StationRunStatus stationRunStatus = new() StationRunStatus stationRunStatus = new()
{ {
rs = StaticStationInfo.StationStatus == 1 ? 1 : 2, rs = StaticStationInfo.Sevstatus,
os = StaticStationInfo.StationStatus, os = StaticStationInfo.StationStatus,
fl = ErrorLevel, fl =Convert.ToInt32( StaticStationInfo.Faultlevel),
}; };
@ -641,8 +679,8 @@ public class CloudClientMgr
et = Convert.ToDateTime(exStationDayRunResult?.RunEndTime), et = Convert.ToDateTime(exStationDayRunResult?.RunEndTime),
tt = Convert.ToInt32(exStationDayRunResult?.ToltalTimeCount), tt = Convert.ToInt32(exStationDayRunResult?.ToltalTimeCount),
//tt = 24 * 60, //tt = 24 * 60,
ft = Convert.ToDateTime(exStationDayRunResult?.FristSwapTime), ft = exStationDayRunResult?.FristSwapTime,
sp = Convert.ToDateTime(exStationDayRunResult?.StopTime), sp = exStationDayRunResult?.StopTime,
ts = Convert.ToSingle(exStationDayRunResult?.ToltalSwapAllTime * 60), ts = Convert.ToSingle(exStationDayRunResult?.ToltalSwapAllTime * 60),
tc = exStationDayRunResult.ToltalSwapCount, tc = exStationDayRunResult.ToltalSwapCount,
cc = exStationDayRunResult.ChgCount, cc = exStationDayRunResult.ChgCount,

@ -12,6 +12,17 @@ namespace Service.Cloud.Msg.Host.Req
/// </summary> /// </summary>
public string sn { get; set; } public string sn { get; set; }
public List<DataInfo> datainfo { get; set; }
public string GetCmd()
{
return CloudConst.chargeDevDataInfo;
}
}
public class DataInfo
{
/// <summary> /// <summary>
/// 设备编号 设备编号 /// 设备编号 设备编号
/// </summary> /// </summary>
@ -154,10 +165,5 @@ namespace Service.Cloud.Msg.Host.Req
/// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ” /// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary> /// </summary>
public DateTime bt { get; set; } public DateTime bt { get; set; }
public string GetCmd()
{
return CloudConst.chargeDevDataInfo;
}
} }
} }

@ -35,12 +35,12 @@ public class StaDayOpeEnergyVal : ICmd
/// <summary> /// <summary>
/// 首次换电时刻 格式 ”yyyy-MM-dd HH:mm:ss ” /// 首次换电时刻 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary> /// </summary>
public DateTime ft { get; set; } public string ft { get; set; }
/// <summary> /// <summary>
/// 结束换电时刻 格式 ”yyyy-MM-dd HH:mm:ss ” /// 结束换电时刻 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary> /// </summary>
public DateTime sp { get; set; } public string sp { get; set; }
/// <summary> /// <summary>
/// 换电总时长 单位: 秒 /// 换电总时长 单位: 秒

@ -171,7 +171,48 @@ public abstract class CloudApi
{ {
return; return;
} }
/// <summary>
/// 换电车辆数据上报
/// </summary>
/// <param name="req"></param>
public static void SendVehicleDataReporting(SwappingStateMachine machine,int vet)
{
var carInfoBatteryInfos = machine.BoxCarInfoModel?.CarInfo?.BatteryInfos;
CardataReport cardataReport = new()
{
on = machine.SwapOrder.Sn,
ct = DateTime.Now,
cn = machine.SwapOrder.VehicleNo,
rfid = "",
Vi = machine.SwapOrder.VehicleVin,
mc = "",
bn = carInfoBatteryInfos.Count > 0 ? carInfoBatteryInfos[0].BatteryNo : "",
ec = 0,
soc = carInfoBatteryInfos.Count > 0 ? Convert.ToSingle(carInfoBatteryInfos[0].Soc) : 0,
bskm = Convert.ToSingle(machine.BoxCarInfoModel?.ElecMsg?.SubMile),
btkm = Convert.ToSingle(machine.BoxCarInfoModel?.ElecMsg?.TotalMile),
soh = carInfoBatteryInfos.Count > 0 ? Convert.ToSingle(carInfoBatteryInfos[0].Soh) : 0,
soe = carInfoBatteryInfos.Count > 0 ? Convert.ToSingle(carInfoBatteryInfos[0].Soe) : 0,
vtm = Convert.ToSingle(machine.BoxCarInfoModel?.ElecMsg?.TotalMile),
vet = vet,
vtdc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.AccDischargeCount),
vtfe = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.AccFallbackCount),
vtcc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.AccChargeCount),
vtec = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.AccKgce),
rtdc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ThisTimeRealDischarge),
lsdc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceDischarge),
rtfc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ThisTimeRealFeedbackPower),
lsfc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceFeedbackPower),
rtcc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ThisTimeRealChargeCount),
lscc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceChargeCount),
rtec = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ThisTimeRealKgce),
ltfc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceKgce),
wsec = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ElectricityToBeSettled),
};
CloudClientMgr.CloudClient?.SendVehicleDataReporting(cardataReport,
global::System.TimeSpan.FromSeconds(TimeSpan));
}
/// <summary> /// <summary>
/// 云平台下发换电指令 /// 云平台下发换电指令
/// </summary> /// </summary>
@ -330,4 +371,46 @@ public abstract class CloudApi
CloudClientMgr.CloudClient?.SendStaHourAmountVal(req, CloudClientMgr.CloudClient?.SendStaHourAmountVal(req,
global::System.TimeSpan.FromSeconds(TimeSpan)); global::System.TimeSpan.FromSeconds(TimeSpan));
} }
/// <summary>
/// 换电站进行签到认证
/// </summary>
/// <param name="req"></param>
public static void SendSignIn(SignIn req)
{
SignIn signIn = new()
{
sn = StaticStationInfo.StationNo,
ky = StaticStationInfo.StationSn,
st = "02",
dv = "",
sv = StaticStationInfo.StationSftVer.ToString(),
ss = StaticStationInfo.Sevstatus,
ca = Convert.ToSingle(StaticStationInfo.DistributionCapacity),
VS = "",
cp = 0,
bs="",
lo="",
la="",
en=1,
cn=1,
eid=1,
oid=1,
};
CloudClientMgr.CloudClient?.SendSignIn(req,
global::System.TimeSpan.FromSeconds(TimeSpan));
}
public static void SendReportingDeviceList(DevList req)
{
DevList devList = new()
{
};
CloudClientMgr.CloudClient?.SendReportingDeviceList(req,
global::System.TimeSpan.FromSeconds(TimeSpan));
}
} }

@ -196,7 +196,6 @@ public class CarPrepareState : IState
{ {
CarAuthRes? vehicleCertificationResp = CarAuthRes? vehicleCertificationResp =
CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder); CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder);
if (vehicleCertificationResp == null || vehicleCertificationResp.re != 0) if (vehicleCertificationResp == null || vehicleCertificationResp.re != 0)
{ {
_log.Info("cloud check vehicle error"); _log.Info("cloud check vehicle error");
@ -241,6 +240,14 @@ public class CarPrepareState : IState
if (isConnect) if (isConnect)
{ {
machine.BoxConnectFlag = true; machine.BoxConnectFlag = true;
//上报车辆数据
if (!machine.CloudTBoxFlag)
{
SwapOrderRepository _swapOrderRepository = AppInfo.Container.Resolve<SwapOrderRepository>();
var vet = _swapOrderRepository.QueryListByClause(u => u.SwapResult == 1&&u.VehicleVin== machine.SwapOrder.VehicleVin).Count;
CloudApi.SendVehicleDataReporting(machine, vet);
}
} }
}, () => }, () =>
{ {

@ -10,12 +10,17 @@ namespace Service.Init;
/// </summary> /// </summary>
public class StaticStationInfo public class StaticStationInfo
{ {
public static int StationStatus public static int StationStatus
{ {
get => int.Parse(Resolve(StationParamConst.StationStatus)); get => int.Parse(Resolve(StationParamConst.StationStatus));
set => Set(StationParamConst.StationStatus, value); set => Set(StationParamConst.StationStatus, value);
} }
public static int Sevstatus
{
get => int.Parse(Resolve(StationParamConst.Sevstatus));
set => Set(StationParamConst.Sevstatus, value);
}
public static string OperationStartTime public static string OperationStartTime
{ {
get => Resolve(StationParamConst.OperationStartTime); get => Resolve(StationParamConst.OperationStartTime);
@ -72,6 +77,22 @@ public class StaticStationInfo
set => Set(StationParamConst.SwapSoc, value); set => Set(StationParamConst.SwapSoc, value);
} }
public static int StationSftVer
{
get => int.Parse(Resolve(StationParamConst.StationSftVer));
set => Set(StationParamConst.StationSftVer, value);
}
public static string Faultlevel
{
get => Resolve(StationParamConst.Faultlevel);
set => Set(StationParamConst.Faultlevel, value);
}
public static string DistributionCapacity
{
get => Resolve(StationParamConst.DistributionCapacity);
set => Set(StationParamConst.DistributionCapacity, value);
}
#region Tbox #region Tbox
public static bool TboxStateConnect public static bool TboxStateConnect

@ -2,7 +2,7 @@
"ConnectionStrings": { "ConnectionStrings": {
"ConfigId": "master", "ConfigId": "master",
"DbType": "MySql", "DbType": "MySql",
"SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;" "SqlConnection": "server=127.0.0.1;Port=3306;Database=huanneng_dev1;Uid=root;Pwd=123456;Charset=utf8;"
}, },
"Update": { "Update": {
"AutoUpdate": "false", "AutoUpdate": "false",
@ -10,7 +10,7 @@
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml" "Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
}, },
"Redis": { "Redis": {
"Connection": "106.12.36.89:6379,password=123456", "Connection": "127.0.0.1:6379,password=123456",
"InstanceName": "local", "InstanceName": "local",
"DefaultDB": "8" "DefaultDB": "8"
}, },
@ -111,7 +111,7 @@
} }
}, },
"cloud": { "cloud": {
"enable": false "enable": true
}, },
"plc": { "plc": {
"enable": true "enable": true

Loading…
Cancel
Save