|
|
@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
using Common.Const;
|
|
|
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
|
|
|
using HybirdFrameworkCore.AutoTask;
|
|
|
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
|
|
|
|
using HybirdFrameworkCore.Utils;
|
|
|
|
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
|
|
|
using Service.Charger.Client;
|
|
|
|
|
|
|
|
using Service.Init;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Service.Charger.MyTask;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Scope]
|
|
|
|
|
|
|
|
public class EmeterEnergyRecordTask : ITask
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(EmeterEnergyRecordTask));
|
|
|
|
|
|
|
|
private volatile bool _stop;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EmeterEnergyRepository EmeterEnergyRepository { get; set; }
|
|
|
|
|
|
|
|
public EmeterEnergyChangeRepository EmeterEnergyChangeRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string Name()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "EmeterEnergyRecordTask";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int Interval()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 1000 * 15;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Handle()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (var keyValuePair in ClientMgr.Dictionary)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var chargerClient = keyValuePair.Value;
|
|
|
|
|
|
|
|
if (chargerClient.Connected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//充电机工作中,正在充电中
|
|
|
|
|
|
|
|
if (chargerClient.Workstate == 2 && chargerClient.ChargingStatus == 5)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string id = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
|
|
|
|
|
EmeterEnergy emeterEnergy = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = id,
|
|
|
|
|
|
|
|
UploadFlag = 0,
|
|
|
|
|
|
|
|
Value = chargerClient.UploadTelemetryData.DcMeterCurrentPower,
|
|
|
|
|
|
|
|
Code = StaticStationInfo.StationNo + "_" + chargerClient.Sn,
|
|
|
|
|
|
|
|
UploadTime = DateTime.Now
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
EmeterEnergyRepository.Insert(emeterEnergy);
|
|
|
|
|
|
|
|
EmeterEnergyChange emeterEnergyChange = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = id,
|
|
|
|
|
|
|
|
UploadFlag = 0,
|
|
|
|
|
|
|
|
Value = chargerClient.UploadTelemetryData.ACMeterCurrentBatteryValue,
|
|
|
|
|
|
|
|
Code = StaticStationInfo.StationNo + "_" + chargerClient.Sn,
|
|
|
|
|
|
|
|
UploadTime = DateTime.Now
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
EmeterEnergyChangeRepository.Insert(emeterEnergyChange);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Error("handle with error", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool Stoped()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return _stop;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Stop()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_stop = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ResetStop()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_stop = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|