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.
77 lines
2.0 KiB
77 lines
2.0 KiB
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;
|
|
|
|
/// <summary>
|
|
/// 电池移仓任务
|
|
/// </summary>
|
|
public class BatteryMoveTask : AbstractTaskHandler
|
|
{
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryMoveTask));
|
|
|
|
|
|
|
|
private readonly BinInfoRepository _binInfoRepository =
|
|
AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
private readonly MonitorService _monitorService =
|
|
AppInfo.Container.Resolve<MonitorService>();
|
|
|
|
protected override int Interval()
|
|
{
|
|
return 20 * 1000;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 自动移仓 当缓存仓没有电池的时候 如果有电池充满了 就移仓
|
|
/// </summary>
|
|
protected override void Handle()
|
|
{
|
|
var cacheBin = _binInfoRepository.QueryByClause(i => i.CacheBinFlag == 1);
|
|
if (cacheBin.Exists == 1)
|
|
{
|
|
return;
|
|
}
|
|
|
|
List<BinInfo> queryListByClause = _binInfoRepository.QueryListByClause(i => i.ChargeStatus == 4 && i.CacheBinFlag==0, "battery_enter_seq asc");
|
|
|
|
|
|
if (queryListByClause.Count<=0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var binInfo = queryListByClause[0];
|
|
|
|
Result<bool> 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";
|
|
}
|
|
} |