From c036718c697f2f5a486661c029e50fba5aeee46b Mon Sep 17 00:00:00 2001 From: CZ Date: Tue, 25 Jun 2024 16:11:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=BA=E4=BA=91=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Cloud/Client/CloudClient.cs | 2 +- Service/Cloud/Client/MyTask/ChargeOrderUploadTask.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Service/Cloud/Client/CloudClient.cs b/Service/Cloud/Client/CloudClient.cs index 72591b3..41bc8b4 100644 --- a/Service/Cloud/Client/CloudClient.cs +++ b/Service/Cloud/Client/CloudClient.cs @@ -571,7 +571,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR ct = 0, cn = orders.Count, sfs = op, - vin = swapOrder.VehicleVin, + vin = swapOrder?.VehicleVin, sfoc = 0, }; foreach (ChargeOrder order in orders) diff --git a/Service/Cloud/Client/MyTask/ChargeOrderUploadTask.cs b/Service/Cloud/Client/MyTask/ChargeOrderUploadTask.cs index d857912..956ec39 100644 --- a/Service/Cloud/Client/MyTask/ChargeOrderUploadTask.cs +++ b/Service/Cloud/Client/MyTask/ChargeOrderUploadTask.cs @@ -14,6 +14,7 @@ public class ChargeOrderUploadTask : ITask private volatile bool _stop; public ChargeOrderRepository _chargeOrderRepository { get; set; } + public SwapOrderRepository _swapOrder { get; set; } public int Interval() { @@ -30,11 +31,10 @@ public class ChargeOrderUploadTask : ITask Log.Info($"there are {chargeOrders?.Count ?? 0} to upload"); if (chargeOrders is { Count: > 0 }) { - var group = chargeOrders.GroupBy(it => it.CloudChargeOrder); - foreach (IGrouping grouping in group) + Dictionary> dictionary = chargeOrders.GroupBy(it => it.CloudChargeOrder).ToDictionary(i => i.Key, i=> i.ToList()); + foreach (var (k, v) in dictionary) { - List orders = grouping.ToList(); - CloudClientMgr.CloudClient?.PublishChargeOrder(orders, 1); + CloudClientMgr.CloudClient?.PublishChargeOrder(v, 1); } } }