更新电表,充电机启动完成帧更新启动状态和 启动时间

master
CZ 5 months ago
parent e229aa459b
commit 73b0c361fa

@ -24,12 +24,15 @@ public static class ChargerConst
/// </summary>
public enum ChargingStatus
{
UnKnown,
Authed,
AuthFailed,
StartChargingSuccess,
StartChargingFailed,
Charging,
StopChargingSuccess,
StopChargingFailed
UnKnown=0,
StartChargingSuccess=1,
StopChargingSuccess=4,
Authed=5,
AuthFailed=6,
StartChargingFailed=7,
// Charging,
StopChargingFailed=8
}

@ -1,6 +1,8 @@
using DotNetty.Transport.Channels;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Common;
using Service.Charger.Msg.Charger.Resp;
@ -19,6 +21,9 @@ namespace Service.Charger.Handler
public class RemoteStartChargingResHandler : SimpleChannelInboundHandler<RemoteStartChargingRes>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(RemoteStartChargingResHandler));
public ChargeOrderRepository ChargeOrderRepository { get; set; }
protected override void ChannelRead0(IChannelHandlerContext ctx, RemoteStartChargingRes msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
@ -29,6 +34,16 @@ namespace Service.Charger.Handler
client.IsStopped = false;
client.ChargingStatus = (int)ChargingStatus.StartChargingSuccess;
client.ChargingStartTime = DateTime.Now;
//查找最新的充电订单
List<ChargeOrder> chargeOrders = ChargeOrderRepository.QueryListByClause(i => i.BatteryNo == client.BatteryNo, "created_time desc")
.Take(1).ToList();
if (chargeOrders.Count > 0)
{
ChargeOrder one = chargeOrders[0];
ChargeOrderRepository.Update(i => i.CmdStatus == 1 && i.StartTime == client.ChargingStartTime,
it => it.Id == one.Id);
}
}
else
{

@ -34,6 +34,8 @@ public class EmeterEnergyRecordTask : ITask
{
try
{
List<EmeterEnergy> list = new List<EmeterEnergy>();
List<EmeterEnergyChange> listEmeterEnergyChanges = new List<EmeterEnergyChange>();
foreach (var keyValuePair in ClientMgr.Dictionary)
{
var chargerClient = keyValuePair.Value;
@ -41,27 +43,43 @@ public class EmeterEnergyRecordTask : ITask
{
string id = DateTime.Now.ToString("yyyyMMddHHmmss");
string code = StaticStationInfo.StationNo + "_" + chargerClient.Sn;
id = id + "_" + chargerClientSn;
EmeterEnergy emeterEnergy = new()
{
Id = id,
UploadFlag = 0,
Value = chargerClient.UploadTelemetryData.DcMeterCurrentPower,
Code = StaticStationInfo.StationNo + "_" + chargerClient.Sn,
Code =code ,
UploadTime = DateTime.Now
};
EmeterEnergyRepository.Insert(emeterEnergy);
list.Add(emeterEnergy);
EmeterEnergyChange emeterEnergyChange = new()
{
Id = id,
UploadFlag = 0,
Value = chargerClient.UploadTelemetryData.ACMeterCurrentBatteryValue,
Code = StaticStationInfo.StationNo + "_" + chargerClient.Sn,
Code = code,
UploadTime = DateTime.Now
};
EmeterEnergyChangeRepository.Insert(emeterEnergyChange);
listEmeterEnergyChanges.Add(emeterEnergyChange);
}
}
if (list.Count > 0)
{
EmeterEnergyRepository.Insert(list);
}
if (listEmeterEnergyChanges.Count > 0)
{
EmeterEnergyChangeRepository.Insert(listEmeterEnergyChanges);
}
}
catch (Exception e)
{

Loading…
Cancel
Save