master
xjl 4 months ago
parent 3598548143
commit 27e52554a6

@ -118,7 +118,7 @@ public class StationParamConst
/// <summary>
/// 总体故障等级
/// </summary>
public static readonly string? Faultlevel = "Station.Faultlevel";
public static readonly string Faultlevel = "Station.Faultlevel";
/// <summary>
/// 加解锁方式
@ -148,7 +148,7 @@ public class StationParamConst
/// <summary>
/// 配电容量kVA
/// </summary>
public static readonly string? DistributionCapacity = "Station.DistributionCapacity";
public static readonly string DistributionCapacity = "Station.DistributionCapacity";
/// <summary>
/// 总功率kW
@ -204,6 +204,9 @@ public class StationParamConst
//电价模型
public static readonly string Ceid = "Station.Ceid";
/// <summary>
/// 运营状态
/// </summary>
public static readonly string StationStatus = "Station.StationStatus";
public static readonly string StationWay = "Station.StationWay";
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 _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);
@ -51,6 +52,8 @@ public class CloudClientMgr
private const int TimeSpan = 5;
private static ChargeDevDataInfo req = new ChargeDevDataInfo();
public static async void Init()
{
@ -74,57 +77,84 @@ public class CloudClientMgr
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;
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.,
req.ct = data.ChargingTime;
dataInfo.ct = data.ChargingTime;
//ssoc = data.,
req.csoc = data.CurrentSoc;
dataInfo.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.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;
if (req.datainfo.Count > 0)
{
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);
}
});
#endregion
var sv = StaticStationInfo.StationSftVer.ToString();
redisHelper?.GetSubscriber().Subscribe("BatteryInfoUploadTask", (channel, value) =>
{
@ -144,6 +177,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);
}
}
@ -173,7 +211,6 @@ public class CloudClientMgr
{
if (CloudClient.Connected)
{
//Log.Info("测试111111111111111111111111111111111111111111111111111111111111111111111111111111");
CloudApi.SendStateLog(0);
TaskHostStatusReported();
@ -225,14 +262,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),
};
@ -641,8 +679,8 @@ public class CloudClientMgr
et = Convert.ToDateTime(exStationDayRunResult?.RunEndTime),
tt = Convert.ToInt32(exStationDayRunResult?.ToltalTimeCount),
//tt = 24 * 60,
ft = Convert.ToDateTime(exStationDayRunResult?.FristSwapTime),
sp = Convert.ToDateTime(exStationDayRunResult?.StopTime),
ft = exStationDayRunResult?.FristSwapTime,
sp = exStationDayRunResult?.StopTime,
ts = Convert.ToSingle(exStationDayRunResult?.ToltalSwapAllTime * 60),
tc = exStationDayRunResult.ToltalSwapCount,
cc = exStationDayRunResult.ChgCount,

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

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

@ -171,7 +171,48 @@ public abstract class CloudApi
{
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>
@ -330,4 +371,46 @@ public abstract class CloudApi
CloudClientMgr.CloudClient?.SendStaHourAmountVal(req,
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 =
CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder);
if (vehicleCertificationResp == null || vehicleCertificationResp.re != 0)
{
_log.Info("cloud check vehicle error");
@ -241,6 +240,14 @@ public class CarPrepareState : IState
if (isConnect)
{
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>
public class StaticStationInfo
{
public static int StationStatus
{
get => int.Parse(Resolve(StationParamConst.StationStatus));
set => Set(StationParamConst.StationStatus, value);
}
public static int Sevstatus
{
get => int.Parse(Resolve(StationParamConst.Sevstatus));
set => Set(StationParamConst.Sevstatus, value);
}
public static string OperationStartTime
{
get => Resolve(StationParamConst.OperationStartTime);
@ -72,6 +77,22 @@ public class StaticStationInfo
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
public static bool TboxStateConnect

@ -2,7 +2,7 @@
"ConnectionStrings": {
"ConfigId": "master",
"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": {
"AutoUpdate": "false",
@ -10,7 +10,7 @@
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
"Connection": "106.12.36.89:6379,password=123456",
"Connection": "127.0.0.1:6379,password=123456",
"InstanceName": "local",
"DefaultDB": "8"
},
@ -111,7 +111,7 @@
}
},
"cloud": {
"enable": false
"enable": true
},
"plc": {
"enable": true

Loading…
Cancel
Save