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