From e6e229fade551a10d659a0800daae0898d57e1ae Mon Sep 17 00:00:00 2001 From: xjl <2595686544@qq.com> Date: Thu, 1 Aug 2024 13:22:47 +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 --- Service/Cloud/Client/CloudClientMgr.cs | 91 ++++++++++++++------------ Service/Execute/Api/CloudApi.cs | 34 +++++----- 2 files changed, 68 insertions(+), 57 deletions(-) diff --git a/Service/Cloud/Client/CloudClientMgr.cs b/Service/Cloud/Client/CloudClientMgr.cs index b1471f4..8d6b436 100644 --- a/Service/Cloud/Client/CloudClientMgr.cs +++ b/Service/Cloud/Client/CloudClientMgr.cs @@ -44,10 +44,10 @@ public class CloudClientMgr 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); @@ -213,6 +213,7 @@ public class CloudClientMgr { if (CloudClient.Connected) { + if (StationConstant.StationModel.Remote == BaseEnumExtensions.GetEnumByCode( StaticStationInfo.StationModel)) { @@ -379,7 +380,7 @@ public class CloudClientMgr }; powerTotal.meter = new List(); - for (int i = 0; i < 7; i++) + for (int i = 0; i < emeterEnergy.Count; i++) { meter meter = new() { @@ -390,7 +391,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() { @@ -401,7 +402,8 @@ public class CloudClientMgr }; powerTotal.meter.Add(meter); } - + + CloudApi.SendPowerTotal(powerTotal); @@ -437,7 +439,8 @@ public class CloudClientMgr }; staChargingTotal.meter = new List(); - for (int i = 0; i < 7; i++) + + for (int i = 0; i < emeterEnergy.Count; i++) { meter2 meter = new() { @@ -450,7 +453,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() { @@ -478,7 +481,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); @@ -494,7 +497,7 @@ public class CloudClientMgr }; meterEnergyKwh.meter = new List(); - for (int i = 0; i < 7; i++) + for (int i = 0; i < emeterEnergy1.Count; i++) { meter2 meter = new() { @@ -509,7 +512,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() { @@ -519,8 +522,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); } @@ -543,7 +546,7 @@ public class CloudClientMgr { return; } - _dateTime8 = DateTime.Now; + _dateTime8 = DateTime.Now.Date.AddHours(2); EmeterDayEnergyService emeterDayEnergyService = AppInfo.Container.Resolve(); @@ -561,7 +564,7 @@ public class CloudClientMgr }; meterEnergyKwh.meter = new List(); - for (int i = 0; i < 7; i++) + for (int i = 0; i < emeterEnergy1.Count; i++) { meter2 meter = new() { @@ -576,7 +579,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() { @@ -586,8 +589,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); @@ -612,7 +615,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); @@ -645,7 +648,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); @@ -680,33 +683,36 @@ public class CloudClientMgr { return; } - _dateTime11 = DateTime.Now; + _dateTime11 = DateTime.Now.Date.AddHours(2); ExStationDayRunResultService exStationDayRunResultService = AppInfo.Container.Resolve(); + var exStationDayRunResult = exStationDayRunResultService.QueryByClause(u => u.Id !=0, i => i.CreatedTime, OrderByType.Desc); - - StaDayOpeEnergyVal staDayOpeEnergyVal = new() + if (exStationDayRunResult!=null) { - 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 = exStationDayRunResult?.FristSwapTime, - sp = 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), - }; + 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); + CloudApi.SendStaDayOpeEnergyVal(staDayOpeEnergyVal); + } + } @@ -849,6 +855,7 @@ public class CloudClientMgr static List equipInfos; + static bool variation = false; /// /// 换电站设备状态开始和结束日志信息 /// @@ -863,7 +870,7 @@ public class CloudClientMgr EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve(); var equipList = equipInfoRepository.Query(); if (equipInfos == null) { equipInfos = equipList; } - bool variation = false; + if (variation) { @@ -881,6 +888,8 @@ public class CloudClientMgr ke= (int)(equipList[i].UpdatedTime- equipInfos[i].UpdatedTime).TotalSeconds, cm = 1, }; + CloudApi.SendEndLogMessage(req); + variation = false; } } } diff --git a/Service/Execute/Api/CloudApi.cs b/Service/Execute/Api/CloudApi.cs index a3e30a4..da41b67 100644 --- a/Service/Execute/Api/CloudApi.cs +++ b/Service/Execute/Api/CloudApi.cs @@ -212,8 +212,8 @@ public abstract class CloudApi ltfc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceKgce), wsec = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ElectricityToBeSettled), }; - CloudClientMgr.CloudClient?.SendVehicleDataReporting(cardataReport, - global::System.TimeSpan.FromSeconds(TimeSpan)); + //CloudClientMgr.CloudClient?.SendVehicleDataReporting(cardataReport, + // global::System.TimeSpan.FromSeconds(TimeSpan)); } /// @@ -375,6 +375,8 @@ public abstract class CloudApi global::System.TimeSpan.FromSeconds(TimeSpan)); } + //TODO 未调试,先注释上传 + /// /// 换电站进行签到认证 /// @@ -403,8 +405,8 @@ public abstract class CloudApi }; - CloudClientMgr.CloudClient?.SendSignIn(signIn, - global::System.TimeSpan.FromSeconds(TimeSpan)); + //CloudClientMgr.CloudClient?.SendSignIn(signIn, + // global::System.TimeSpan.FromSeconds(TimeSpan)); } /// @@ -413,8 +415,8 @@ public abstract class CloudApi /// public static void SendDevList(DevList req) { - CloudClientMgr.CloudClient?.SendReportingDeviceList(req, - global::System.TimeSpan.FromSeconds(TimeSpan)); + // CloudClientMgr.CloudClient?.SendReportingDeviceList(req, + // global::System.TimeSpan.FromSeconds(TimeSpan)); } /// /// 实时故障上报 @@ -422,8 +424,8 @@ public abstract class CloudApi /// public static void SendRealTimeFaultInfo(FaultReport req) { - CloudClientMgr.CloudClient?.SendRealTimeFaultInfo(req, - global::System.TimeSpan.FromSeconds(TimeSpan)); + //CloudClientMgr.CloudClient?.SendRealTimeFaultInfo(req, + // global::System.TimeSpan.FromSeconds(TimeSpan)); } /// @@ -432,8 +434,8 @@ public abstract class CloudApi /// public static void SendStartLogMessage(EqmStateStartLogInfo req) { - CloudClientMgr.CloudClient?.SendStartLogMessage(req, - global::System.TimeSpan.FromSeconds(TimeSpan)); + // CloudClientMgr.CloudClient?.SendStartLogMessage(req, + // global::System.TimeSpan.FromSeconds(TimeSpan)); } /// /// 换电站设备状态结束日志信息 @@ -441,19 +443,19 @@ public abstract class CloudApi /// public static void SendEndLogMessage(EqmStateEndLogInfo req) { - CloudClientMgr.CloudClient?.SendEndLogMessage(req, - global::System.TimeSpan.FromSeconds(TimeSpan)); + //CloudClientMgr.CloudClient?.SendEndLogMessage(req, + // global::System.TimeSpan.FromSeconds(TimeSpan)); } public static void SendBatteryTotal(BatteryTotal req) { - CloudClientMgr.CloudClient?.SendBatteryTotal(req, - global::System.TimeSpan.FromSeconds(TimeSpan)); + // CloudClientMgr.CloudClient?.SendBatteryTotal(req, + // global::System.TimeSpan.FromSeconds(TimeSpan)); } public static void SendChargingTotalDis(ChargingTotalDis req) { - CloudClientMgr.CloudClient?.SendChargingTotalDis(req, - global::System.TimeSpan.FromSeconds(TimeSpan)); + // CloudClientMgr.CloudClient?.SendChargingTotalDis(req, + // global::System.TimeSpan.FromSeconds(TimeSpan)); } } \ No newline at end of file