|
|
@ -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()
|
|
|
|