充电机测试,接收充电启动完成帧handler更新sql更改

zw
CZ 5 months ago
parent 156b49ab9d
commit afcc3bc11f

@ -26,35 +26,41 @@ namespace Service.Charger.Handler
protected override void ChannelRead0(IChannelHandlerContext ctx, RemoteStartChargingRes msg) protected override void ChannelRead0(IChannelHandlerContext ctx, RemoteStartChargingRes msg)
{ {
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client)) if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
if (msg.Result == 0)
{ {
client.IsStopped = false; Log.Info($"receive {msg} from {sn}");
client.ChargingStatus = (int)ChargingStatus.StartChargingSuccess; if (msg.Result == 0)
client.ChargingStartTime = DateTime.Now; {
//查找最新的充电订单 client.IsStopped = false;
List<ChargeOrder> chargeOrders = ChargeOrderRepository.QueryListByClause(i => i.BatteryNo == client.BatteryNo, "created_time desc") client.ChargingStatus = (int)ChargingStatus.StartChargingSuccess;
.Take(1).ToList(); client.ChargingStartTime = DateTime.Now;
//查找最新的充电订单
List<ChargeOrder> chargeOrders = ChargeOrderRepository
.QueryListByClause(i => i.BatteryNo == client.BatteryNo, "created_time desc")
.Take(1).ToList();
if (chargeOrders.Count > 0) if (chargeOrders.Count > 0)
{ {
ChargeOrder one = chargeOrders[0]; ChargeOrder one = chargeOrders[0];
ChargeOrderRepository.Update(i => i.CmdStatus == 1 && i.StartTime == client.ChargingStartTime, ChargeOrderRepository.Update(
it => it.Id == one.Id); 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 else
{ {
client.ChargingStatus = (int)ChargingStatus.StartChargingFailed; client.ChargingStatus = (int)ChargingStatus.StartChargingFailed;
client.ChargingStartTime = Convert.ToDateTime("2000-1-1");
} }
}
else
{
client.ChargingStatus = (int)ChargingStatus.StartChargingFailed;
}
} }
} }
} }
Loading…
Cancel
Save