diff --git a/Entity/DbModel/Station/BinInfo.cs b/Entity/DbModel/Station/BinInfo.cs
index 73e1c19..9d0df00 100644
--- a/Entity/DbModel/Station/BinInfo.cs
+++ b/Entity/DbModel/Station/BinInfo.cs
@@ -144,7 +144,7 @@ namespace Entity.DbModel.Station
public int? BatteryEnterSeq {get;set;}
///
- /// Desc:充电状态;0-未知;1-正在充电;2-无电池;3-禁用
+ /// Desc:充电状态;0-未知;1-正在充电;2-无电池;3-禁用;4-充电停止
/// Default:0
/// Nullable:True
///
diff --git a/Service/Charger/Codec/Decoder.cs b/Service/Charger/Codec/Decoder.cs
index a29420e..c6612f5 100644
--- a/Service/Charger/Codec/Decoder.cs
+++ b/Service/Charger/Codec/Decoder.cs
@@ -124,7 +124,7 @@ public class Decoder : ByteToMessageDecoder
45 => recordType switch
{
1 => ModelConvert.Decode(bytes),
- 3 => ModelConvert.Decode(bytes),
+ 3 => ModelConvert.Decode(bytes),
6 => ModelConvert.Decode(bytes),
10 => ModelConvert.Decode(bytes),
11 => ModelConvert.Decode(bytes),
diff --git a/Service/Charger/Handler/FinishStartChargingHandler.cs b/Service/Charger/Handler/FinishStartChargingHandler.cs
index c0dfc31..951631f 100644
--- a/Service/Charger/Handler/FinishStartChargingHandler.cs
+++ b/Service/Charger/Handler/FinishStartChargingHandler.cs
@@ -2,6 +2,7 @@
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
+using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
@@ -22,6 +23,8 @@ namespace HybirdFrameworkServices.Charger.Handler
[Scope("InstancePerDependency")]
public class FinishStartChargingHandler : SimpleChannelInboundHandler, IBaseHandler
{
+ public BinInfoRepository BinInfoRepository { get; set; }
+
private static readonly ILog Log = LogManager.GetLogger(typeof(FinishStartChargingHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, FinishStartCharging msg)
{
@@ -29,23 +32,23 @@ namespace HybirdFrameworkServices.Charger.Handler
{
Log.Info($"receive {msg} from {sn}");
msg.VehIdeNum = Encoding.ASCII.GetString(msg.Vin);
+ int chargeStatus = 0;
if (msg.Result == 0)
{
client.IsCharged = true;
+ chargeStatus = 1;
}
else if (msg.Result == 1)
{
client.IsCharged = false;
}
-
+
+ int update = BinInfoRepository.Update(t => t.ChargeStatus == chargeStatus, t => t.No == client.BinNo);
+ Log.Info($"update {update} start charge finish status {chargeStatus} for {client.BinNo}");
+
StartChargingFinishedRes msgRespond = new StartChargingFinishedRes(0, 0);
ctx.Channel.WriteAndFlushAsync(msgRespond);
}
- else
- {
- StartChargingFinishedRes msgRespond = new StartChargingFinishedRes(1, 2);
- ctx.Channel.WriteAndFlushAsync(msgRespond);
- }
}
}
}
diff --git a/Service/Charger/Handler/StopChargingHandler.cs b/Service/Charger/Handler/FinishStopChargingHandler.cs
similarity index 54%
rename from Service/Charger/Handler/StopChargingHandler.cs
rename to Service/Charger/Handler/FinishStopChargingHandler.cs
index a765414..8e4b768 100644
--- a/Service/Charger/Handler/StopChargingHandler.cs
+++ b/Service/Charger/Handler/FinishStopChargingHandler.cs
@@ -1,6 +1,7 @@
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
+using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
@@ -16,15 +17,33 @@ namespace Service.Charger.Handler
///
[Order(8)]
[Scope("InstancePerDependency")]
- public class StopChargingHandler : SimpleChannelInboundHandler, IBaseHandler
+ public class FinishStopChargingHandler : SimpleChannelInboundHandler, IBaseHandler
{
- private static readonly ILog Log = LogManager.GetLogger(typeof(StopChargingHandler));
- protected override void ChannelRead0(IChannelHandlerContext ctx, StopCharging msg)
+
+ public BinInfoRepository BinInfoRepository { get; set; }
+
+ private static readonly ILog Log = LogManager.GetLogger(typeof(FinishStopChargingHandler));
+ protected override void ChannelRead0(IChannelHandlerContext ctx, FinishStopCharging msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
client.IsCanSendStopCmd = false;
+ int chargeStatus = 0;
+ if (msg.Result == 0)
+ {
+ client.IsStopped = true;
+ chargeStatus = 4;
+ }
+ else
+ {
+ client.IsStopped = false;
+ }
+
+ int update = BinInfoRepository.Update(t => t.ChargeStatus == chargeStatus, t => t.No == client.BinNo);
+ Log.Info($"update {update} start charge finish status {chargeStatus} for {client.BinNo}");
+
+
ChargingStopFsdRes stopFsdRes = new ChargingStopFsdRes(0);
ctx.Channel.WriteAndFlushAsync(stopFsdRes);
}
diff --git a/Service/Charger/Msg/Charger/Req/StopCharging.cs b/Service/Charger/Msg/Charger/Req/FinishStopCharging.cs
similarity index 99%
rename from Service/Charger/Msg/Charger/Req/StopCharging.cs
rename to Service/Charger/Msg/Charger/Req/FinishStopCharging.cs
index ee8e140..1a56d54 100644
--- a/Service/Charger/Msg/Charger/Req/StopCharging.cs
+++ b/Service/Charger/Msg/Charger/Req/FinishStopCharging.cs
@@ -5,7 +5,7 @@ namespace Service.Charger.Msg.Charger.Req
///
/// 3.3.11 充放电机上送充电停止帧
///
- public class StopCharging : ASDU
+ public class FinishStopCharging : ASDU
{
///
/// 记录类型