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