|
|
|
@ -26,35 +26,41 @@ namespace Service.Charger.Handler
|
|
|
|
|
|
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, RemoteStartChargingRes msg)
|
|
|
|
|
{
|
|
|
|
|
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"receive {msg} from {sn}");
|
|
|
|
|
if (msg.Result == 0)
|
|
|
|
|
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
Log.Info($"receive {msg} from {sn}");
|
|
|
|
|
if (msg.Result == 0)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
if (chargeOrders.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ChargeOrder one = chargeOrders[0];
|
|
|
|
|
ChargeOrderRepository.Update(
|
|
|
|
|
i => new ChargeOrder()
|
|
|
|
|
{
|
|
|
|
|
CmdStatus = 1,
|
|
|
|
|
StartTime = client.ChargingStartTime
|
|
|
|
|
},
|
|
|
|
|
it => it.Id == one.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
client.ChargingStatus = (int)ChargingStatus.StartChargingFailed;
|
|
|
|
|
client.ChargingStartTime = Convert.ToDateTime("2000-1-1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
client.ChargingStatus = (int)ChargingStatus.StartChargingFailed;
|
|
|
|
|
client.ChargingStartTime = Convert.ToDateTime("2000-1-1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
client.ChargingStatus = (int)ChargingStatus.StartChargingFailed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|