You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.7 KiB
58 lines
1.7 KiB
5 months ago
|
using DotNetty.Transport.Channels;
|
||
5 months ago
|
using Entity.DbModel.Station;
|
||
5 months ago
|
using HybirdFrameworkCore.Autofac.Attribute;
|
||
|
using log4net;
|
||
5 months ago
|
using Repository.Station;
|
||
5 months ago
|
using Service.Charger.Msg.Charger.Req;
|
||
|
|
||
|
namespace Service.Charger.Handler;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 电池状态上报 处理器
|
||
|
/// </summary>
|
||
|
[Order(8)]
|
||
|
[Scope("InstancePerDependency")]
|
||
|
public class BatteryStatusReportedReqHandler : SimpleChannelInboundHandler<BatteryStatusReportedReq>, IBaseHandler
|
||
|
{
|
||
|
|
||
5 months ago
|
private static readonly ILog Log =LogManager.GetLogger(typeof(BatteryStatusReportedReqHandler));
|
||
|
|
||
|
public BinInfoRepository BinInfoRepository { get; set; }
|
||
5 months ago
|
|
||
|
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
protected override void ChannelRead0(IChannelHandlerContext ctx, BatteryStatusReportedReq msg)
|
||
|
{
|
||
5 months ago
|
UpdateBinInfo(msg.granary01, "1");
|
||
|
UpdateBinInfo(msg.granary02, "2");
|
||
|
UpdateBinInfo(msg.granary03, "3");
|
||
|
UpdateBinInfo(msg.granary04, "4");
|
||
|
UpdateBinInfo(msg.granary05, "5");
|
||
|
UpdateBinInfo(msg.granary06, "6");
|
||
|
UpdateBinInfo(msg.granary07, "7");
|
||
|
UpdateBinInfo(msg.granary08, "8");
|
||
|
}
|
||
|
|
||
|
private void UpdateBinInfo(int exists, string binNo)
|
||
|
{
|
||
|
if (exists == 0)
|
||
|
BinInfoRepository.Update(
|
||
|
it =>
|
||
|
new BinInfo(){
|
||
|
Exists = 0,
|
||
|
BatteryNo = "-1",
|
||
|
Soc = (decimal)-1,
|
||
|
Soe = (decimal)-1,
|
||
|
Soh = (decimal)-1,
|
||
|
},
|
||
|
it => it.No == binNo);
|
||
|
else
|
||
|
|
||
|
BinInfoRepository.Update(it => it.Exists == 1,
|
||
|
it => it.No == binNo);
|
||
|
|
||
5 months ago
|
}
|
||
|
}
|