diff --git a/Service/MyTask/UpdateDownBatteryInfoTask.cs b/Service/MyTask/UpdateDownBatteryInfoTask.cs index cee9b90..57c6e2e 100644 --- a/Service/MyTask/UpdateDownBatteryInfoTask.cs +++ b/Service/MyTask/UpdateDownBatteryInfoTask.cs @@ -76,25 +76,31 @@ public class UpdateDownBatteryInfoTask : ITask continue; } - /*if (!info.BatteryNo.Equals(battery.DownBatteryNo)) - { - continue; - }*/ battery.DownBatteryNo = info.BatteryNo; battery.DownBatterySoc = info.Soc; battery.DownBatterySoe = info.Soe; battery.DownNominalEnergy = info.NominalEnergy; - _swapOrderBatteryRepository.Update(i => new() - { - DownBatteryNo = battery.DownBatteryNo, - DownBatterySoc = battery.DownBatterySoc, - DownBatterySoe = battery.DownBatterySoe, - DownNominalEnergy = battery.DownNominalEnergy - }, i => i.Id == battery.Id); - Log.Info( - $" UpdateDownBatteryInfoTask update DowmBatteryInfo db={JsonConvert.SerializeObject(battery)}"); + + updateDbBattery.Add(battery); + } + if (updateDbBattery.Count > 0) + { + Log.Info( + $" UpdateDownBatteryInfoTask update DowmBatteryInfo db={JsonConvert.SerializeObject(updateDbBattery)}"); + foreach (var swapOrderBattery in updateDbBattery) + { + _swapOrderBatteryRepository.Update(i => new() + { + DownBatteryNo = swapOrderBattery.DownBatteryNo, + DownBatterySoc = swapOrderBattery.DownBatterySoc, + DownBatterySoe = swapOrderBattery.DownBatterySoe, + DownNominalEnergy = swapOrderBattery.DownNominalEnergy + }, i => i.Id == swapOrderBattery.Id); + } + + } }