diff --git a/Entity/DbModel/Station/ChargeOrder.cs b/Entity/DbModel/Station/ChargeOrder.cs index 76d0247..0b0dd3d 100644 --- a/Entity/DbModel/Station/ChargeOrder.cs +++ b/Entity/DbModel/Station/ChargeOrder.cs @@ -290,5 +290,12 @@ namespace Entity.DbModel.Station /// [SugarColumn(ColumnName = "start_type")] public int StartType { get; set; } + + + /// + /// 上报次数 + /// + [SugarColumn(ColumnName = "reporting_times")] + public int ReportingTimes { get; set; } } } diff --git a/Service/Charger/Handler/FinishStopChargingHandler.cs b/Service/Charger/Handler/FinishStopChargingHandler.cs index e578840..d2d61c2 100644 --- a/Service/Charger/Handler/FinishStopChargingHandler.cs +++ b/Service/Charger/Handler/FinishStopChargingHandler.cs @@ -50,7 +50,8 @@ namespace Service.Charger.Handler if (ObjUtils.IsNotEmpty(orders)) { List list = orders.Select(it => it.Id).ToList(); - ChargeOrderRepository.Update(it => it.CanUpload == 1, it => list.Contains(it.Id)); + ChargeOrderRepository.Update(it => it.CanUpload == 1 && it.ReportingTimes==0, + it => list.Contains(it.Id)); } } } diff --git a/Service/Charger/Handler/QueryBatterySnResHandler.cs b/Service/Charger/Handler/QueryBatterySnResHandler.cs index 788da46..eedc0fb 100644 --- a/Service/Charger/Handler/QueryBatterySnResHandler.cs +++ b/Service/Charger/Handler/QueryBatterySnResHandler.cs @@ -37,7 +37,10 @@ namespace Service.Charger.Handler sb.Append(Convert.ToChar(msg.BatterSnBytes[i])); } - client.BatteryNo = sb.ToString(); + if (!sb.ToString().Contains("ÿ")) + { + client.BatteryNo = sb.ToString(); + } client.BatteryFactory = msg.BatterFactory; if (_binInfoRepository.Update(t => t.BatteryNo == client.BatteryNo, t => t.No == client.BinNo) > 0) diff --git a/Service/MyTask/BatteryInfoUploadTask.cs b/Service/MyTask/BatteryInfoUploadTask.cs index 7e9a571..21f350d 100644 --- a/Service/MyTask/BatteryInfoUploadTask.cs +++ b/Service/MyTask/BatteryInfoUploadTask.cs @@ -1,8 +1,10 @@ using Autofac; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.AutoTask; using HybirdFrameworkCore.Redis; +using log4net; using Newtonsoft.Json; using Repository.Station; using Service.Charger.Client; @@ -10,9 +12,10 @@ using Service.Init; using Service.Swap.Dto; namespace Service.MyTask; - +[Scope] public class BatteryInfoUploadTask : ITask { + private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryInfoUploadTask)); private RedisHelper RedisHelper { get; set; } = AppInfo.Container.Resolve(); private BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve(); @@ -25,16 +28,17 @@ public class BatteryInfoUploadTask : ITask public int Interval() { - return 1000 * 30; + return 1000 * 1; } public void Handle() { - + Log.Info("begin start BatteryInfoUploadTask uoload"); DateTime now = DateTime.Now; List binInfos = BinInfoRepository.Query(); List batInfos = binInfos.Where(it => it.Exists == 1).Select(it => { + Log.Info("start BatteryInfoUploadTask uoload bininfo select"); ChargerClient? client = ClientMgr.GetBySn(it.ChargerNo); SingleBatInfo batInfo = new SingleBatInfo() { @@ -61,8 +65,15 @@ public class BatteryInfoUploadTask : ITask datainfo = batInfos }; - - RedisHelper.PublishAsync("BatteryInfoUploadTask", JsonConvert.SerializeObject(batDataInfo)); + try + { + Log.Info("start BatteryInfoUploadTask send redis"); + RedisHelper.PublishAsync("BatteryInfoUploadTask", JsonConvert.SerializeObject(batDataInfo)); + } + catch (Exception e) + { + Log.Info($"BatteryInfoUploadTask send redis error{e}"); + } } public bool Stoped() diff --git a/Service/Service.csproj b/Service/Service.csproj index 5ea66cc..9b3820c 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -50,4 +50,8 @@ + + + +