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

master
CZ 5 months ago
parent 156b49ab9d
commit afcc3bc11f

@ -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;
}
}
}
}
}
Loading…
Cancel
Save