充电时长

master
rszn 5 months ago
parent 9f920ca6d2
commit 38b24cd5af

@ -22,23 +22,23 @@ namespace Service.Charger.Handler
[Order(8)]
[Scope("InstancePerDependency")]
public class RecordChargeHandler : SimpleChannelInboundHandler<RecordCharge>, IBaseHandler
{
{
private static readonly ILog Log = LogManager.GetLogger(typeof(RecordChargeHandler));
private ChargeOrderRepository _chargeOrderRepository;
/// <summary>
///
///
/// </summary>
/// <param name="chargeOrderRepository"></param>
public RecordChargeHandler(ChargeOrderRepository chargeOrderRepository)
{
_chargeOrderRepository = chargeOrderRepository;
}
protected override void ChannelRead0(IChannelHandlerContext ctx, RecordCharge msg)
{
if(ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
float[] powersPeriods = new float[4] { 0, 0, 0, 0 }; //元素索引顺序代表值1234
@ -50,7 +50,7 @@ namespace Service.Charger.Handler
if (msg.FlagOfTime6 >= 1 && msg.FlagOfTime6 <= 4){powersPeriods[msg.FlagOfTime6 - 1] += msg.ChargingPowerOfTime6;}
if (msg.FlagOfTime7 >= 1 && msg.FlagOfTime7 <= 4){powersPeriods[msg.FlagOfTime7 - 1] += msg.ChargingPowerOfTime7;}
if (msg.FlagOfTime8 >= 1 && msg.FlagOfTime8 <= 4){powersPeriods[msg.FlagOfTime8 - 1] += msg.ChargingPowerOfTime8;}
float[] acPowersPeriods = new float[4] { 0, 0, 0, 0 }; //元素索引顺序代表值1234
if (msg.AcFlagOfTime1 >= 1 && msg.AcFlagOfTime1 <= 4){acPowersPeriods[msg.AcFlagOfTime1 - 1] += msg.AcChargingPowerOfTime1;}
if (msg.AcFlagOfTime2 >= 1 && msg.AcFlagOfTime2 <= 4){acPowersPeriods[msg.AcFlagOfTime2 - 1] += msg.AcChargingPowerOfTime2;}
@ -101,7 +101,8 @@ namespace Service.Charger.Handler
db.EndTime = new DateTime(msg.EndYear + 2000, msg.EndMonth, msg.EndDay, msg.EndHour, msg.EndMinute, msg.EndSecond);
db.StartSoc = msg.SocBefore;
db.StopSoc = msg.SocAfter;
db.ChargeTimeCount= msg.ChargingTimeCount;
TimeSpan? timeSpan = (db.EndTime - db.StartTime);
db.ChargeTimeCount= timeSpan?.Minutes;
db.ElecCount = Convert.ToDecimal(msg.ChargingPower);
db.AcElecCount = Convert.ToDecimal(msg.AcMeterElecCount);
db.StartAcElec = Convert.ToDecimal(msg.AcMeterDataBefore);
@ -126,4 +127,4 @@ namespace Service.Charger.Handler
}
}
}
}

Loading…
Cancel
Save