using Autofac; using Entity.Constant; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.AutoTask; 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 : 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, "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}"); } } catch (Exception e) { Log.Error($" SwapOrderReportCloudTask err e={e}"); } } public bool Stoped() { return _stop; } public void Stop() { _stop = true; } public void ResetStop() { _stop = false; } }