部分判断提交

zw
CZ 5 months ago
parent bb83d2086d
commit a949cdb432

@ -290,5 +290,12 @@ namespace Entity.DbModel.Station
/// </summary> /// </summary>
[SugarColumn(ColumnName = "start_type")] [SugarColumn(ColumnName = "start_type")]
public int StartType { get; set; } public int StartType { get; set; }
/// <summary>
/// 上报次数
/// </summary>
[SugarColumn(ColumnName = "reporting_times")]
public int ReportingTimes { get; set; }
} }
} }

@ -50,7 +50,8 @@ namespace Service.Charger.Handler
if (ObjUtils.IsNotEmpty(orders)) if (ObjUtils.IsNotEmpty(orders))
{ {
List<int> list = orders.Select(it => it.Id).ToList(); List<int> 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));
} }
} }
} }

@ -37,7 +37,10 @@ namespace Service.Charger.Handler
sb.Append(Convert.ToChar(msg.BatterSnBytes[i])); sb.Append(Convert.ToChar(msg.BatterSnBytes[i]));
} }
client.BatteryNo = sb.ToString(); if (!sb.ToString().Contains("ÿ"))
{
client.BatteryNo = sb.ToString();
}
client.BatteryFactory = msg.BatterFactory; client.BatteryFactory = msg.BatterFactory;
if (_binInfoRepository.Update(t => t.BatteryNo == client.BatteryNo, t => t.No == client.BinNo) > 0) if (_binInfoRepository.Update(t => t.BatteryNo == client.BatteryNo, t => t.No == client.BinNo) > 0)

@ -1,8 +1,10 @@
using Autofac; using Autofac;
using Entity.DbModel.Station; using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask; using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Redis; using HybirdFrameworkCore.Redis;
using log4net;
using Newtonsoft.Json; using Newtonsoft.Json;
using Repository.Station; using Repository.Station;
using Service.Charger.Client; using Service.Charger.Client;
@ -10,9 +12,10 @@ using Service.Init;
using Service.Swap.Dto; using Service.Swap.Dto;
namespace Service.MyTask; namespace Service.MyTask;
[Scope]
public class BatteryInfoUploadTask : ITask public class BatteryInfoUploadTask : ITask
{ {
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryInfoUploadTask));
private RedisHelper RedisHelper { get; set; } = AppInfo.Container.Resolve<RedisHelper>(); private RedisHelper RedisHelper { get; set; } = AppInfo.Container.Resolve<RedisHelper>();
private BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>(); private BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
@ -25,16 +28,17 @@ public class BatteryInfoUploadTask : ITask
public int Interval() public int Interval()
{ {
return 1000 * 30; return 1000 * 1;
} }
public void Handle() public void Handle()
{ {
Log.Info("begin start BatteryInfoUploadTask uoload");
DateTime now = DateTime.Now; DateTime now = DateTime.Now;
List<BinInfo> binInfos = BinInfoRepository.Query(); List<BinInfo> binInfos = BinInfoRepository.Query();
List<SingleBatInfo> batInfos = binInfos.Where(it => it.Exists == 1).Select(it => List<SingleBatInfo> batInfos = binInfos.Where(it => it.Exists == 1).Select(it =>
{ {
Log.Info("start BatteryInfoUploadTask uoload bininfo select");
ChargerClient? client = ClientMgr.GetBySn(it.ChargerNo); ChargerClient? client = ClientMgr.GetBySn(it.ChargerNo);
SingleBatInfo batInfo = new SingleBatInfo() SingleBatInfo batInfo = new SingleBatInfo()
{ {
@ -61,8 +65,15 @@ public class BatteryInfoUploadTask : ITask
datainfo = batInfos datainfo = batInfos
}; };
try
RedisHelper.PublishAsync("BatteryInfoUploadTask", JsonConvert.SerializeObject(batDataInfo)); {
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() public bool Stoped()

@ -50,4 +50,8 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Remove="Charger\MyTask\UpBatDataInfoTask.cs" />
</ItemGroup>
</Project> </Project>

Loading…
Cancel
Save