|
|
|
@ -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<RedisHelper>();
|
|
|
|
|
private BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
|
|
|
|
|
@ -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<BinInfo> binInfos = BinInfoRepository.Query();
|
|
|
|
|
List<SingleBatInfo> 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()
|
|
|
|
|