From 265f4ea3bc335e78d3a3000003ea6a4a1c01e0e3 Mon Sep 17 00:00:00 2001 From: rszn <645583145@qq.com> Date: Mon, 3 Jun 2024 14:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0soh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Handler/VoltageCurrentSocHandler.cs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Service/Charger/Handler/VoltageCurrentSocHandler.cs b/Service/Charger/Handler/VoltageCurrentSocHandler.cs index 7acebdd..e16f4e7 100644 --- a/Service/Charger/Handler/VoltageCurrentSocHandler.cs +++ b/Service/Charger/Handler/VoltageCurrentSocHandler.cs @@ -1,14 +1,10 @@ using DotNetty.Transport.Channels; +using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Repository.Station; using Service.Charger.Client; using Service.Charger.Msg.Charger.Req; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Service.Charger.Handler { @@ -32,14 +28,14 @@ namespace Service.Charger.Handler if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client)) { Log.Info($"receive {msg} from {sn}"); - if (_binInfoRepository.Update(t => t.Soc == (decimal)msg.SOC, t => t.No == client.BinNo) > 0) + bool update = _binInfoRepository.Update(it => new BinInfo() { - Log.Info($"succeed update battery soc {msg.SOC} for {client.BinNo}"); - } - else - { - Log.Info($"fail update battery soc {msg.SOC} for {client.BinNo}"); - } + Soc = (decimal)msg.SOC, + Soh = (decimal)msg.SOH + }, t => t.No == client.BinNo); + Log.Info(update + ? $"succeed update battery soc {msg.SOC} for {client.BinNo}" + : $"fail update battery soc {msg.SOC} for {client.BinNo}"); } } }