using Autofac; using Entity.Constant; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Entity; using log4net; using Repository.Station; using Service.Execute; using Service.Execute.Api; using Service.Execute.Model; using Service.Plc.Client; using Service.Station; namespace Service.BusinessTask.MyTask; /// /// 电池移仓任务 /// public class BatteryMoveTask : AbstractTaskHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryMoveTask)); private readonly BinInfoRepository _binInfoRepository = AppInfo.Container.Resolve(); private readonly MonitorService _monitorService = AppInfo.Container.Resolve(); protected override int Interval() { return 20 * 1000; } /// /// 自动移仓 当缓存仓没有电池的时候 如果有电池充满了 就移仓 /// protected override void Handle() { var cacheBin = _binInfoRepository.QueryByClause(i => i.CacheBinFlag == 1); if (cacheBin.Exists == 1) { return; } List queryListByClause = _binInfoRepository.QueryListByClause(i => i.ChargeStatus == 4 && i.CacheBinFlag==0, "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) { bool readPlcTaskStatus9000 = false; while (!readPlcTaskStatus9000) { Thread.Sleep(1000); readPlcTaskStatus9000 = PlcMgr.ReadPlcTaskStatus() == 9000; } Log.Info($"execute BatteryMoveTask success from binNo ={binInfo.No}"); } } protected override string Name() { return "SwapOrderReportCloudTask"; } }