From 27e52554a66290663e0a3742e6262123806eece4 Mon Sep 17 00:00:00 2001
From: xjl <2595686544@qq.com>
Date: Wed, 24 Jul 2024 09:06:14 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Entity/Constant/StationParamConst.cs | 7 +-
Service/Cloud/Client/CloudClientMgr.cs | 120 ++++++++++++------
.../Cloud/Msg/Host/Req/ChargeDevDataInfo.cs | 16 ++-
.../Cloud/Msg/Host/Req/StaDayOpeEnergyVal.cs | 4 +-
Service/Execute/Api/CloudApi.cs | 83 ++++++++++++
Service/Execute/Step/CarPrepareState.cs | 11 +-
Service/Init/StaticStationInfo.cs | 23 +++-
WebStarter/appsettings.dev.json | 6 +-
8 files changed, 214 insertions(+), 56 deletions(-)
diff --git a/Entity/Constant/StationParamConst.cs b/Entity/Constant/StationParamConst.cs
index 500c9ac..a3d6fb9 100644
--- a/Entity/Constant/StationParamConst.cs
+++ b/Entity/Constant/StationParamConst.cs
@@ -118,7 +118,7 @@ public class StationParamConst
///
/// 总体故障等级
///
- public static readonly string? Faultlevel = "Station.Faultlevel";
+ public static readonly string Faultlevel = "Station.Faultlevel";
///
/// 加解锁方式
@@ -148,7 +148,7 @@ public class StationParamConst
///
/// 配电容量(kVA)
///
- public static readonly string? DistributionCapacity = "Station.DistributionCapacity";
+ public static readonly string DistributionCapacity = "Station.DistributionCapacity";
///
/// 总功率(kW)
@@ -204,6 +204,9 @@ public class StationParamConst
//电价模型
public static readonly string Ceid = "Station.Ceid";
+ ///
+ /// 运营状态
+ ///
public static readonly string StationStatus = "Station.StationStatus";
public static readonly string StationWay = "Station.StationWay";
public static readonly string StationModel = "Station.StationModel";
diff --git a/Service/Cloud/Client/CloudClientMgr.cs b/Service/Cloud/Client/CloudClientMgr.cs
index a0ad68d..ae2961a 100644
--- a/Service/Cloud/Client/CloudClientMgr.cs
+++ b/Service/Cloud/Client/CloudClientMgr.cs
@@ -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();
BinInfoRepository binInfoRepository = AppInfo.Container.Resolve();
+
+ #region 遥测合并上报
+ req.datainfo = new List();
redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) =>
{
try
{
- Log.Info($"receive UploadTelemetryData={value}");
+
if (value.HasValue)
{
+
UploadTelemetryData? data = JsonConvert.DeserializeObject(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();
+
+ }
+ 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(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();
- var EquipAlarm = equipAlarmRecordRepository.Query();
- var ErrorLevel = Convert.ToInt32(EquipAlarm.Min(x => x.ErrorLevel));
+
+ //EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve();
+ //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,
diff --git a/Service/Cloud/Msg/Host/Req/ChargeDevDataInfo.cs b/Service/Cloud/Msg/Host/Req/ChargeDevDataInfo.cs
index ddaa624..c74b1c4 100644
--- a/Service/Cloud/Msg/Host/Req/ChargeDevDataInfo.cs
+++ b/Service/Cloud/Msg/Host/Req/ChargeDevDataInfo.cs
@@ -12,6 +12,17 @@ namespace Service.Cloud.Msg.Host.Req
///
public string sn { get; set; }
+ public List datainfo { get; set; }
+
+
+ public string GetCmd()
+ {
+ return CloudConst.chargeDevDataInfo;
+ }
+ }
+
+ public class DataInfo
+ {
///
/// 设备编号 设备编号
///
@@ -154,10 +165,5 @@ namespace Service.Cloud.Msg.Host.Req
/// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ”
///
public DateTime bt { get; set; }
-
- public string GetCmd()
- {
- return CloudConst.chargeDevDataInfo;
- }
}
}
\ No newline at end of file
diff --git a/Service/Cloud/Msg/Host/Req/StaDayOpeEnergyVal.cs b/Service/Cloud/Msg/Host/Req/StaDayOpeEnergyVal.cs
index a48c0e4..0f6ac27 100644
--- a/Service/Cloud/Msg/Host/Req/StaDayOpeEnergyVal.cs
+++ b/Service/Cloud/Msg/Host/Req/StaDayOpeEnergyVal.cs
@@ -35,12 +35,12 @@ public class StaDayOpeEnergyVal : ICmd
///
/// 首次换电时刻 格式 ”yyyy-MM-dd HH:mm:ss ”
///
- public DateTime ft { get; set; }
+ public string ft { get; set; }
///
/// 结束换电时刻 格式 ”yyyy-MM-dd HH:mm:ss ”
///
- public DateTime sp { get; set; }
+ public string sp { get; set; }
///
/// 换电总时长 单位: 秒
diff --git a/Service/Execute/Api/CloudApi.cs b/Service/Execute/Api/CloudApi.cs
index 5774f8b..46f6d4c 100644
--- a/Service/Execute/Api/CloudApi.cs
+++ b/Service/Execute/Api/CloudApi.cs
@@ -171,7 +171,48 @@ public abstract class CloudApi
{
return;
}
+ ///
+ /// 换电车辆数据上报
+ ///
+ ///
+ 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));
+ }
///
/// 云平台下发换电指令
///
@@ -330,4 +371,46 @@ public abstract class CloudApi
CloudClientMgr.CloudClient?.SendStaHourAmountVal(req,
global::System.TimeSpan.FromSeconds(TimeSpan));
}
+
+ ///
+ /// 换电站进行签到认证
+ ///
+ ///
+ 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));
+ }
}
\ No newline at end of file
diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs
index 4ce1ec5..12680b4 100644
--- a/Service/Execute/Step/CarPrepareState.cs
+++ b/Service/Execute/Step/CarPrepareState.cs
@@ -72,7 +72,7 @@ public class CarPrepareState : IState
return SwappingStateMachine.ReturnWithInvokeErr(checkTBoxVelLocal, ExceptionReason.None);
}
-
+
//云端数据上报
// InvokeStatus cloudTBox = CloudTBoxFlag(machine);
/*if (cloudTBox != InvokeStatus.Done)
@@ -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();
+ var vet = _swapOrderRepository.QueryListByClause(u => u.SwapResult == 1&&u.VehicleVin== machine.SwapOrder.VehicleVin).Count;
+ CloudApi.SendVehicleDataReporting(machine, vet);
+ }
+
}
}, () =>
{
diff --git a/Service/Init/StaticStationInfo.cs b/Service/Init/StaticStationInfo.cs
index 152d66c..283cbf4 100644
--- a/Service/Init/StaticStationInfo.cs
+++ b/Service/Init/StaticStationInfo.cs
@@ -10,12 +10,17 @@ namespace Service.Init;
///
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
diff --git a/WebStarter/appsettings.dev.json b/WebStarter/appsettings.dev.json
index f1b11aa..b1967b4 100644
--- a/WebStarter/appsettings.dev.json
+++ b/WebStarter/appsettings.dev.json
@@ -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