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.

91 lines
2.3 KiB

using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using log4net;
using Repository.Station;
using Service.Cloud.Client;
using Service.Cloud.Msg.Host.Req;
using Service.Init;
namespace Service.MyTask;
/// <summary>
/// 仓位上传至云平台
/// </summary>
[Scope]
public class BinInfoReportCloudTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger(typeof(BinInfoReportCloudTask));
private volatile bool _stop;
public BinInfoReportCloudTask(BinInfoRepository binInfoRepository)
{
BinInfoRepository = binInfoRepository;
}
private BinInfoRepository BinInfoRepository { get; set; }
public string Name()
{
return "BinInfoReportCloudTask";
}
public int Interval()
{
return 1000 * 3;
}
public void Handle()
{
List<BinInfo> binInfList = BinInfoRepository.Query();
if (binInfList.Count <= 0)
{
return;
}
BinDataInfo binDataInfo = new BinDataInfo
{
stationNo = StaticStationInfo.StationNo,
binInfoList = binInfList.Select(binInfo => new BinData
{
binCode = binInfo.No,
existsFlag = binInfo.Exists,
batteryNo = binInfo.BatteryNo,
chargerNo = binInfo.ChargerNo,
waterCoolNo = binInfo.WaterCoolNo,
elecPluginFlag = binInfo.ElecPluginFlag,
elecPluginStatus = Convert.ToInt32(binInfo.ElecPluginStatus),
waterPluginFlag = Convert.ToInt32(binInfo.WaterPluginFlag),
amtLock = binInfo.AmtLock,
chargeStatus = binInfo.ChargeStatus,
status = binInfo.Status,
lastChargeFinishTime = binInfo.LastChargeFinishTime,
cacheBinFlag = binInfo.CacheBinFlag,
canSwapFlag = binInfo.CanSwapFlag,
canChargeFlag = binInfo.CanChargeFlag,
inTime = binInfo.InTime
}).ToList()
};
CloudClientMgr.CloudClient?.Publish(binDataInfo);
Log.Info("上报仓位数据到云平台成功");
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}