You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.0 KiB

using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Mgr;
namespace Service.MyTask;
///// <summary>
///// 充电结束上报云平台task
///// </summary>
//[Scope]
//public class UpdateDownBatteryInfoTask : ITask
//{
// private static readonly ILog Log = LogManager.GetLogger(typeof(UpdateDownBatteryInfoTask));
// private volatile bool _stop;
// public SwapOrderBatteryRepository _swapOrderBatteryRepository { get; set; }
// public BinInfoRepository _BinInfoRepository { get; set; }
// public string Name()
// {
// return "UpdateDownBatteryInfoTask";
// }
// public int Interval()
// {
// return 1000 * 2;
// }
// public void Handle()
// {
// try
// {
// List<SwapOrderBattery> batterys =
// _swapOrderBatteryRepository.QueryListByClause(
// i => (i.DownBatteryNo == null || i.DownBatterySoc<0) && i.DownBatteryBinNo != null);
// if (batterys.Count <= 0)
// {
// return;
// }
// List<string> downBatteryBinNos = batterys.Select(i => i.DownBatteryBinNo.ToString()).ToList();
// Dictionary<string, BinInfo> binInfosMap = _BinInfoRepository
// .QueryListByClause(i => downBatteryBinNos.Contains(i.No) && i.Exists==1).ToDictionary(i => i.No);
// List<SwapOrderBattery> updateDbBattery = new List<SwapOrderBattery>();
// foreach (var battery in batterys)
// {
// //更新换下电池包
// binInfosMap.TryGetValue(battery.DownBatteryBinNo.ToString(), out BinInfo info);
// if (info.BatteryNo == null || info.BatteryNo == "" || info.BatteryNo == "-1")
// {
// continue;
// }
// if (info.Soc == null || info.Soc <=0)
// {
// continue;
// }
// /*if (!info.BatteryNo.Equals(battery.DownBatteryNo))
// {
// continue;
// }*/
// battery.DownBatteryNo = info.BatteryNo;
// battery.DownBatterySoc = info.Soc;
// battery.DownBatterySoe = info.Soe;
// updateDbBattery.Add(battery);
// }
// if (updateDbBattery.Count > 0)
// {
// Log.Info(
// $" UpdateDownBatteryInfoTask update DowmBatteryInfo db={JsonConvert.SerializeObject(updateDbBattery)}");
// _swapOrderBatteryRepository.Update(updateDbBattery);
// }
// }
// catch (Exception e)
// {
// Log.Error($" UpdateDownBatteryInfoTask err e={e}");
// }
// }
// public bool Stoped()
// {
// return _stop;
// }
// public void Stop()
// {
// _stop = true;
// }
// public void ResetStop()
// {
// _stop = false;
// }
//}