充电订单云平台订单号生成规则修改

master
rszn 5 months ago
parent a7262b5d37
commit e5af38ef5e

@ -4,12 +4,13 @@ namespace Service.Charger.Common;
public static class ChargerConst
{
public static readonly AttributeKey<string> ChargerSn = AttributeKey<string>.ValueOf("charger_sn");
public static readonly AttributeKey<string> EqmTypeNo = AttributeKey<string>.ValueOf("eqm_type_no");
public static readonly AttributeKey<string> EqmCode = AttributeKey<string>.ValueOf("eqm_code");
public static readonly AttributeKey<string> DestAddr = AttributeKey<string>.ValueOf("dest_addr");
public static readonly string DateFormat = "yyMMddHHmmss";
public static readonly string yyyyMMddHHmmss = "yyyyMMddHHmmss";
public static readonly byte[] StartChar = { 0x68 /* ,0xEE*/ };
public static readonly string AuthCode = "szhckj01";
@ -26,13 +27,13 @@ public enum ChargingStatus
{
UnKnown=0,
StartChargingSuccess=1,
StopChargingSuccess=4,
Authed=5,
AuthFailed=6,
StartChargingFailed=7,
// Charging,
StopChargingFailed=8
}
}

@ -58,6 +58,12 @@ public static class ChargerUtils
return StaticStationInfo.StationNo + DateTime.Now.ToString(ChargerConst.DateFormat) +
GetRandomNumLimit99();
}
public static string GenChargeOrderNo(string chargerSn)
{
return StaticStationInfo.StationNo +chargerSn + DateTime.Now.ToString(ChargerConst.yyyyMMddHHmmss) +
GetRandomNumLimit99();
}
/// <summary>
/// 根据云平台下发,计算本地充电机枪号
/// </summary>
@ -84,7 +90,7 @@ public static class ChargerUtils
throw new ArgumentException("转换失败");
}
}
public static string GetOutChargerCode(string number)
{
int parsedNumber;
@ -99,10 +105,10 @@ public static class ChargerUtils
{
throw new ArgumentException("转换失败");
}
}
/// <summary>
/// 根据本地充电枪编号,充电机code,计算云平台下发充电枪编号
/// </summary>
@ -185,4 +191,4 @@ public static class ChargerUtils
return results;
}
}
}

@ -28,7 +28,7 @@ namespace HybirdFrameworkServices.Charger.Handler
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)
{
@ -47,7 +47,7 @@ namespace HybirdFrameworkServices.Charger.Handler
{
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)
@ -59,26 +59,26 @@ namespace HybirdFrameworkServices.Charger.Handler
{
cloudChargeOrder = order.CloudChargeOrder;
}
}
if (string.IsNullOrWhiteSpace(cloudChargeOrder))
{
cloudChargeOrder = ChargerUtils.GenChargeOrderSn();
cloudChargeOrder = ChargerUtils.GenChargeOrderNo(sn);
}
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)
{

Loading…
Cancel
Save