充电订单上传

master
smartwyy 6 months ago
parent 9986739ce8
commit 07e7077d25

@ -1,7 +1,4 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
using SqlSugar;
namespace Entity.DbModel.Station
{
@ -11,289 +8,304 @@ namespace Entity.DbModel.Station
[SugarTable("charge_order")]
public partial class ChargeOrder
{
public ChargeOrder(){
public ChargeOrder()
{
}
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="id")]
public int Id {get;set;}
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public int Id { get; set; }
/// <summary>
/// Desc:订单编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="sn")]
public string Sn {get;set;}
[SugarColumn(ColumnName = "sn")]
public string Sn { get; set; }
/// <summary>
/// Desc:电池编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="battery_no")]
public string BatteryNo {get;set;}
[SugarColumn(ColumnName = "battery_no")]
public string BatteryNo { get; set; }
/// <summary>
/// Desc:启动报文状态;0-初始化1-启动成功
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="cmd_status")]
public int? CmdStatus {get;set;}
[SugarColumn(ColumnName = "cmd_status")]
public int? CmdStatus { get; set; }
/// <summary>
/// Desc:充电机编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="charger_no")]
public string ChargerNo {get;set;}
[SugarColumn(ColumnName = "charger_no")]
public string ChargerNo { get; set; }
/// <summary>
/// Desc:充电枪编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="charger_gun_no")]
public string ChargerGunNo {get;set;}
[SugarColumn(ColumnName = "charger_gun_no")]
public string ChargerGunNo { get; set; }
/// <summary>
/// Desc:0站内充电 1站外充电
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="charge_mode")]
public int? ChargeMode {get;set;}
[SugarColumn(ColumnName = "charge_mode")]
public int? ChargeMode { get; set; }
/// <summary>
/// Desc:1站控启动 2本地启动
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_mode")]
public int? StartMode {get;set;}
[SugarColumn(ColumnName = "start_mode")]
public int? StartMode { get; set; }
/// <summary>
/// Desc:充电开始时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_time")]
public DateTime? StartTime {get;set;}
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
/// <summary>
/// Desc:充电结束时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="end_time")]
public DateTime? EndTime {get;set;}
[SugarColumn(ColumnName = "end_time")]
public DateTime? EndTime { get; set; }
/// <summary>
/// Desc:充电开始soc
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_soc")]
public int? StartSoc {get;set;}
[SugarColumn(ColumnName = "start_soc")]
public int? StartSoc { get; set; }
/// <summary>
/// Desc:充电结束soc
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="stop_soc")]
public int? StopSoc {get;set;}
[SugarColumn(ColumnName = "stop_soc")]
public int? StopSoc { get; set; }
/// <summary>
/// Desc:充电时长
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="charge_time_count")]
public int? ChargeTimeCount {get;set;}
[SugarColumn(ColumnName = "charge_time_count")]
public int? ChargeTimeCount { get; set; }
/// <summary>
/// Desc:充电电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="elec_count")]
public decimal? ElecCount {get;set;}
[SugarColumn(ColumnName = "elec_count")]
public decimal? ElecCount { get; set; }
/// <summary>
/// Desc:交流电表量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_elec_count")]
public decimal? AcElecCount {get;set;}
[SugarColumn(ColumnName = "ac_elec_count")]
public decimal? AcElecCount { get; set; }
/// <summary>
/// Desc:充电开始交流表电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_ac_elec")]
public decimal? StartAcElec {get;set;}
[SugarColumn(ColumnName = "start_ac_elec")]
public decimal? StartAcElec { get; set; }
/// <summary>
/// Desc:充电结束交流表电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="stop_ac_elec")]
public decimal? StopAcElec {get;set;}
[SugarColumn(ColumnName = "stop_ac_elec")]
public decimal? StopAcElec { get; set; }
/// <summary>
/// Desc:充电开始直流表电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_dc_elec")]
public decimal? StartDcElec {get;set;}
[SugarColumn(ColumnName = "start_dc_elec")]
public decimal? StartDcElec { get; set; }
/// <summary>
/// Desc:充电结束直流表电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="stop_dc_elec")]
public decimal? StopDcElec {get;set;}
[SugarColumn(ColumnName = "stop_dc_elec")]
public decimal? StopDcElec { get; set; }
/// <summary>
/// Desc:停止原因;0满电自动停止1-人工停止
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="stop_reason")]
public int? StopReason {get;set;}
[SugarColumn(ColumnName = "stop_reason")]
public int? StopReason { get; set; }
/// <summary>
/// Desc:尖时段电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="sharp_elec_count")]
public decimal? SharpElecCount {get;set;}
[SugarColumn(ColumnName = "sharp_elec_count")]
public decimal? SharpElecCount { get; set; }
/// <summary>
/// Desc:峰时段电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="peak_elec_count")]
public decimal? PeakElecCount {get;set;}
[SugarColumn(ColumnName = "peak_elec_count")]
public decimal? PeakElecCount { get; set; }
/// <summary>
/// Desc:平时段电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="flat_elec_count")]
public decimal? FlatElecCount {get;set;}
[SugarColumn(ColumnName = "flat_elec_count")]
public decimal? FlatElecCount { get; set; }
/// <summary>
/// Desc:谷时段电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="valley_elec_count")]
public decimal? ValleyElecCount {get;set;}
[SugarColumn(ColumnName = "valley_elec_count")]
public decimal? ValleyElecCount { get; set; }
/// <summary>
/// Desc:尖时段交流电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_sharp_elec_count")]
public decimal? AcSharpElecCount {get;set;}
[SugarColumn(ColumnName = "ac_sharp_elec_count")]
public decimal? AcSharpElecCount { get; set; }
/// <summary>
/// Desc:峰时段交流电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_peak_elec_count")]
public decimal? AcPeakElecCount {get;set;}
[SugarColumn(ColumnName = "ac_peak_elec_count")]
public decimal? AcPeakElecCount { get; set; }
/// <summary>
/// Desc:平时段交流电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_flat_elec_count")]
public decimal? AcFlatElecCount {get;set;}
[SugarColumn(ColumnName = "ac_flat_elec_count")]
public decimal? AcFlatElecCount { get; set; }
/// <summary>
/// Desc:谷时段交流电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_valley_elec_count")]
public decimal? AcValleyElecCount {get;set;}
[SugarColumn(ColumnName = "ac_valley_elec_count")]
public decimal? AcValleyElecCount { get; set; }
/// <summary>
/// Desc:电价版本号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="elec_price_model_version")]
public string ElecPriceModelVersion {get;set;}
[SugarColumn(ColumnName = "elec_price_model_version")]
public string ElecPriceModelVersion { get; set; }
/// <summary>
/// Desc:换电订单编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="swap_order_sn")]
public string SwapOrderSn {get;set;}
[SugarColumn(ColumnName = "swap_order_sn")]
public string SwapOrderSn { get; set; }
/// <summary>
/// Desc:上传云平台状态;0-未上传1-已上传
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="cloud_report_status")]
public int? CloudReportStatus {get;set;}
[SugarColumn(ColumnName = "cloud_report_status")]
public int? CloudReportStatus { get; set; }
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_by")]
public string CreatedBy {get;set;}
[SugarColumn(ColumnName = "created_by")]
public string CreatedBy { get; set; }
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_time")]
public DateTime? CreatedTime {get;set;}
[SugarColumn(ColumnName = "created_time")]
public DateTime CreatedTime { get; set; }
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_by")]
public string UpdatedBy {get;set;}
[SugarColumn(ColumnName = "updated_by")]
public string UpdatedBy { get; set; }
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_time")]
public DateTime? UpdatedTime {get;set;}
[SugarColumn(ColumnName = "updated_time")]
public DateTime? UpdatedTime { get; set; }
/// <summary>
/// Desc:云平台订单编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "cloud_charge_order")]
public string CloudChargeOrder { get; set; }
/// <summary>
/// Desc:是否可以上传云平台
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "can_upload")]
public int? CanUpload { get; set; }
}
}

@ -0,0 +1,240 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace Entity.DbModel.Station
{
///<summary>
///换电订单电池
///</summary>
[SugarTable("swap_order_battery")]
public partial class SwapOrderBattery
{
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public int Id { get; set; }
/// <summary>
/// Desc:换电订单编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "swap_order_sn")]
public string? SwapOrderSn { get; set; }
/// <summary>
/// Desc:亏电包编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_no")]
public string? DownBatteryNo { get; set; }
/// <summary>
/// Desc:亏电包soc
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_soc")]
public decimal? DownBatterySoc { get; set; }
/// <summary>
/// Desc:亏电包soe
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_soe")]
public decimal? DownBatterySoe { get; set; }
/// <summary>
/// Desc:亏电包真实soc
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_real_soc")]
public decimal? DownBatteryRealSoc { get; set; }
/// <summary>
/// Desc:亏电包上次换电结算时soc
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_last_soc")]
public decimal? DownBatteryLastSoc { get; set; }
/// <summary>
/// Desc:亏电包上次换电结算时soe
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_last_soe")]
public decimal? DownBatteryLastSoe { get; set; }
/// <summary>
/// Desc:亏电包站内充电能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_in_chage_elec_count")]
public decimal? DownBatteryInChageElecCount { get; set; }
/// <summary>
/// Desc:亏电包站外插枪充电能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_out_chage_elec_count")]
public decimal? DownBatteryOutChageElecCount { get; set; }
/// <summary>
/// Desc:亏电包站外回充能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_out_re_chagre_count")]
public decimal? DownBatteryOutReChagreCount { get; set; }
/// <summary>
/// Desc:亏电包站外放电能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_in_dischage_elec_count")]
public decimal? DownBatteryInDischageElecCount { get; set; }
/// <summary>
/// Desc:亏电包站内放电电能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_out_dischage_elec_count")]
public decimal? DownBatteryOutDischageElecCount { get; set; }
/// <summary>
/// Desc:放电池仓位号 亏电包仓号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "down_battery_bin_no")]
public int? DownBatteryBinNo { get; set; }
/// <summary>
/// Desc:满电包编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_no")]
public string? UpBatteryNo { get; set; }
/// <summary>
/// Desc:满电包soc
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_soc")]
public decimal? UpBatterySoc { get; set; }
/// <summary>
/// Desc:满电包soe
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_soe")]
public decimal? UpBatterySoe { get; set; }
/// <summary>
/// Desc:满电包真实soc
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_real_soc")]
public decimal? UpBatteryRealSoc { get; set; }
/// <summary>
/// Desc:满电包站内充电能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_in_chage_elec_count")]
public decimal? UpBatteryInChageElecCount { get; set; }
/// <summary>
/// Desc:满电包站外插枪充电能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_out_chage_elec_count")]
public decimal? UpBatteryOutChageElecCount { get; set; }
/// <summary>
/// Desc:满电包站外回充能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_out_re_chagre_count")]
public decimal? UpBatteryOutReChagreCount { get; set; }
/// <summary>
/// Desc:满电包站外放电能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_in_dischage_elec_count")]
public decimal? UpBatteryInDischageElecCount { get; set; }
/// <summary>
/// Desc:满电包站内放电电能量(累计)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_out_dischage_elec_count")]
public decimal? UpBatteryOutDischageElecCount { get; set; }
/// <summary>
/// Desc:取电池仓位号 满电包仓号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "up_battery_bin_no")]
public int? UpBatteryBinNo { get; set; }
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "created_by")]
public string? CreatedBy { get; set; }
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "created_time")]
public DateTime CreatedTime { get; set; }
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "updated_by")]
public string? UpdatedBy { get; set; }
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "updated_time")]
public DateTime? UpdatedTime { get; set; }
}
}

@ -54,7 +54,7 @@
/// </summary>
/// <param name="msg">消息</param>
/// <returns></returns>
public static Result<T> Fail(string msg = "失败")
public static Result<T> Fail(string? msg = "失败")
{
return Message(false, msg, default);
}

@ -0,0 +1,71 @@
namespace HybirdFrameworkCore.Utils;
/// <summary>
///
/// </summary>
public static class ObjUtils
{
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public static bool IsNull(object? o)
{
return o == null;
}
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public static bool IsNotNull(object? o)
{
return o != null;
}
/// <summary>
///
/// </summary>
/// <param name="list"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static bool IsEmpty<T>(List<T>? list)
{
return list == null || list.Count == 0;
}
/// <summary>
///
/// </summary>
/// <param name="list"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static bool IsNotEmpty<T>(List<T>? list)
{
return list is { Count: >= 0 };
}
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public static bool IsNullOrWhiteSpace(string? o)
{
return string.IsNullOrWhiteSpace(o);
}
/// <summary>
///
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public static bool IsNotNullOrWhiteSpace(string? o)
{
return !string.IsNullOrWhiteSpace(o);
}
public static readonly List<object> EmptyList = new List<object>(0);
}

@ -3,10 +3,37 @@ using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Station;
[Scope("SingleInstance")]
public class ChargeOrderRepository:BaseRepository<ChargeOrder>
public class ChargeOrderRepository : BaseRepository<ChargeOrder>
{
public ChargeOrderRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
public ChargeOrder? QueryLatestByBatterySn(string? batterySn)
{
if (string.IsNullOrWhiteSpace(batterySn))
{
return null;
}
return QueryByClause(it => it.BatteryNo == batterySn, it => it.CreatedTime, OrderByType.Desc);
}
/// <summary>
///
/// </summary>
/// <param name="swapOrderNo"></param>
/// <param name="batteryNo"></param>
/// <returns></returns>
public List<ChargeOrder> QueryBySwapOrderAndBatterySn(string? swapOrderNo, string? batteryNo)
{
if (string.IsNullOrWhiteSpace(swapOrderNo) || string.IsNullOrWhiteSpace(batteryNo))
{
return new List<ChargeOrder>(0);
}
return QueryListByClause(it => it.SwapOrderSn == swapOrderNo && it.BatteryNo == batteryNo, it => it.CreatedTime,
OrderByType.Asc);
}
}

@ -0,0 +1,28 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Station;
[Scope]
public class SwapOrderBatteryRepository:BaseRepository<SwapOrderBattery>
{
public SwapOrderBatteryRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
/// <summary>
///
/// </summary>
/// <param name="batterySn"></param>
/// <returns></returns>
public SwapOrderBattery? QueryLatestOrderNoByBatterySn(string? batterySn)
{
if (string.IsNullOrWhiteSpace(batterySn))
{
return null;
}
return QueryByClause(it => it.DownBatteryNo == batterySn, it => it.CreatedTime, OrderByType.Desc);
}
}

@ -245,7 +245,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
{
if (!Connected)
{
return Result<string>.Fail($"charger-{BinNo} disconnect");
return Result<string>.Fail($"充电机{BinNo}未连接");
}
if (string.IsNullOrWhiteSpace(chargeOrderNo))
@ -511,10 +511,15 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
byte chargeSoc = StaticStationInfo.ChargeSoc;
float chargePower = StaticStationInfo.ChargePower;
Result<string> chargeOrderNo = SendRemoteStartCharging(chargeSoc, chargePower);
if (!chargeOrderNo.IsSuccess)
{
return Result<bool>.Fail(chargeOrderNo.Msg);
}
ChargeOrderNo = chargeOrderNo.Data;
_chargeOrderRepository.Insert(new ChargeOrder()
{
Sn = chargeOrderNo.Data,
Sn = ChargeOrderNo,
BatteryNo = BatteryNo,
CmdStatus = 0,
ChargerNo = BinNo,

@ -1,9 +1,11 @@
using System.Text;
using DotNetty.Transport.Channels;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Common;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
@ -24,6 +26,8 @@ namespace HybirdFrameworkServices.Charger.Handler
public class FinishStartChargingHandler : SimpleChannelInboundHandler<FinishStartCharging>, IBaseHandler
{
public BinInfoRepository BinInfoRepository { get; set; }
public ChargeOrderRepository ChargeOrderRepository { get; set; }
public SwapOrderBatteryRepository SwapOrderBatteryRepository { get; set; }
private static readonly ILog Log = LogManager.GetLogger(typeof(FinishStartChargingHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, FinishStartCharging msg)
@ -36,7 +40,45 @@ namespace HybirdFrameworkServices.Charger.Handler
if (msg.Result == 0)
{
client.IsCharged = true;
client.IsStopped = false;
chargeStatus = 1;
SwapOrderBattery? swapOrderBattery = SwapOrderBatteryRepository.QueryLatestOrderNoByBatterySn(client.BatteryNo);
if (swapOrderBattery != null)
{
ChargeOrderRepository.Update(it => it.SwapOrderSn == swapOrderBattery.SwapOrderSn,
it => it.Sn == client.ChargeOrderNo);
List<ChargeOrder> orders = ChargeOrderRepository.QueryBySwapOrderAndBatterySn(swapOrderBattery.SwapOrderSn,
client.BatteryNo);
if (orders.Count > 0)
{
string? cloudChargeOrder = null;
foreach (ChargeOrder order in orders)
{
if (!string.IsNullOrWhiteSpace(order.CloudChargeOrder))
{
cloudChargeOrder = order.CloudChargeOrder;
}
}
if (string.IsNullOrWhiteSpace(cloudChargeOrder))
{
cloudChargeOrder = ChargerUtils.GenChargeOrderSn();
}
HashSet<int> hashSet = orders.Select(it => it.Id).ToHashSet();
ChargeOrderRepository.Update(it => it.CloudChargeOrder == cloudChargeOrder,
it => hashSet.Contains(it.Id));
}
}
else
{
Log.Error($"can not find swapOrderBattery by {client.BatteryNo}");
}
}
else if (msg.Result == 1)
{

@ -1,10 +1,13 @@
using DotNetty.Transport.Channels;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Utils;
using log4net;
using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
using Service.Init;
namespace Service.Charger.Handler
{
@ -22,6 +25,8 @@ namespace Service.Charger.Handler
public BinInfoRepository BinInfoRepository { get; set; }
public ChargeOrderRepository ChargeOrderRepository { get; set; }
private static readonly ILog Log = LogManager.GetLogger(typeof(FinishStopChargingHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, FinishStopCharging msg)
{
@ -33,7 +38,22 @@ namespace Service.Charger.Handler
if (msg.Result == 0)
{
client.IsStopped = true;
client.IsCharged = false;
chargeStatus = 4;
if (msg.SuspendTheStateOfCharge >= StaticStationInfo.SwapSoc)
{
ChargeOrder? chargeOrder = ChargeOrderRepository.QueryLatestByBatterySn(client.BatteryNo);
if (chargeOrder != null)
{
List<ChargeOrder> orders = ChargeOrderRepository.QueryBySwapOrderAndBatterySn(chargeOrder.SwapOrderSn,
chargeOrder.BatteryNo);
if (ObjUtils.IsNotEmpty(orders))
{
List<int> list = orders.Select(it => it.Id).ToList();
ChargeOrderRepository.Update(it => it.CanUpload == 1, it => list.Contains(it.Id));
}
}
}
}
else
{

Loading…
Cancel
Save