using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.AutoTask; using HybirdFrameworkCore.Entity; using log4net; using Repository.Station; using Service.Init; 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 { Log.Info("auto move battery task start-------------------------"); 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 && i.AmtLock == 0 && i.Status == 1, "battery_enter_seq asc"); if (queryListByClause.Count <= 0) { return; } /*//不能进行移仓 if (PlcMgr.PlcClient?.ReadTaskNo() != 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) { // PlcMgr.PlcClient?.ExChangeTaskNo(0); Log.Error($" SwapOrderReportCloudTask err e={e}"); } Log.Info("auto move battery task end-------------------------"); } public bool Stoped() { return _stop; } public void Stop() { _stop = true; } public void ResetStop() { _stop = false; } }