using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.AutoTask; using HybirdFrameworkCore.Entity; using log4net; using Repository.Station; using Service.Init; using Service.Plc.Client; using Service.Station; namespace Service.MyTask; /// /// 电池移仓任务 /// [Scope] public class BatteryMoveTask : ITask { private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryMoveTask)); public BinInfoRepository _binInfoRepository { get; set; } public MonitorService _monitorService { get; set; } private volatile bool _stop; public string Name() { return "BatteryMoveTask"; } public int Interval() { return 1000 * 20; } public void Handle() { try { var cacheBin = _binInfoRepository.QueryByClause(i => i.CacheBinFlag == 1); if (cacheBin.Exists == 1) { return; } List queryListByClause = _binInfoRepository.QueryListByClause(i => i.ChargeStatus == 4 && i.CacheBinFlag == 0 && i.Soc>=StaticStationInfo.SwapSoc, "battery_enter_seq asc"); if (queryListByClause.Count <= 0) { return; } var binInfo = queryListByClause[0]; Result success = _monitorService.BatteryRelocation(ushort.Parse(binInfo.No), ushort.Parse(cacheBin.No)); //查询人物状态 if (success.IsSuccess) { Log.Info($"execute BatteryMoveTask success from binNo ={binInfo.No}"); } } catch (Exception e) { Log.Error($" SwapOrderReportCloudTask err e={e}"); } } public bool Stoped() { return _stop; } public void Stop() { _stop = true; } public void ResetStop() { _stop = false; } }