diff --git a/Common/Util/HttpUtil.cs b/Common/Util/HttpUtil.cs index db474ba..b833f87 100644 --- a/Common/Util/HttpUtil.cs +++ b/Common/Util/HttpUtil.cs @@ -21,11 +21,19 @@ public static class HttpUtil string jsonStr = JsonConvert.SerializeObject(data); var content = new StringContent(jsonStr, Encoding.UTF8, "application/json"); - HttpResponseMessage response = await httpClient.PostAsync(url, content); + try + { + HttpResponseMessage response = await httpClient.PostAsync(url, content); - if (response.IsSuccessStatusCode) + if (response.IsSuccessStatusCode) + { + await response.Content.ReadAsStringAsync(); + } + } + catch (Exception e) { - await response.Content.ReadAsStringAsync(); + } + } } \ No newline at end of file diff --git a/Repository/Station/ChargeOrderRepository.cs b/Repository/Station/ChargeOrderRepository.cs index 241b4b8..abfbf99 100644 --- a/Repository/Station/ChargeOrderRepository.cs +++ b/Repository/Station/ChargeOrderRepository.cs @@ -11,19 +11,28 @@ public class ChargeOrderRepository : BaseRepository { } + /// + /// 创建充电订单 + /// + /// 订单编号 + /// 云平台订单编号 + /// 充电机编号 + /// 充电枪编号 + /// 站外充电枪编号,站外1枪或2枪 public void SaveChargeGunOrder(string chargeOrder,string chargeOrderNo, string chargerNo, string chargerGunNo, string outChargerGunNo) { ChargeOrder order = new ChargeOrder(); order.Sn = chargeOrder; order.CmdStatus = 0; - order.ChargerNo = chargerNo; + order.ChargerNo = chargerNo.Substring(4); order.ChargerGunNo = chargerGunNo; order.OutChargerGunNo = outChargerGunNo; order.ChargeMode = 1; order.StartMode = 1; order.CloudChargeOrder = chargeOrderNo; order.CreatedTime = DateTime.Now; + Insert(order); } diff --git a/Service/Charger/Client/ChargerClient.cs b/Service/Charger/Client/ChargerClient.cs index 08b6849..1ada04d 100644 --- a/Service/Charger/Client/ChargerClient.cs +++ b/Service/Charger/Client/ChargerClient.cs @@ -176,18 +176,6 @@ public class ChargerClient : TcpClient { [1]=new ChargerPile(), [2]=new ChargerPile(), - [3]=new ChargerPile(), - [4]=new ChargerPile(), - [5]=new ChargerPile(), - [6]=new ChargerPile(), - [7]=new ChargerPile(), - [8]=new ChargerPile(), - [9]=new ChargerPile(), - [10]=new ChargerPile(), - [11]=new ChargerPile(), - [12]=new ChargerPile(), - [13]=new ChargerPile(), - [14]=new ChargerPile(), }; /// @@ -596,11 +584,11 @@ public class ChargerClient : TcpClient /// /// /// - public Result SendStopOutCharger(byte pn, byte stopReason) + public Result SendStopOutCharger(byte pn, byte stopReason) { if (!Connected) { - return Result.Fail($"充电机{BinNo}未连接"); + return Result.Fail($"充电机{BinNo}未连接"); } Log().Info( @@ -608,7 +596,7 @@ public class ChargerClient : TcpClient PileStopCharge pileStopCharge = new PileStopCharge(pn, stopReason); this.Channel.WriteAndFlushAsync(pileStopCharge); - return Result.Success(); + return Result.Success(); } /// diff --git a/Service/Charger/Codec/Decoder.cs b/Service/Charger/Codec/Decoder.cs index 6826491..dc6ecc5 100644 --- a/Service/Charger/Codec/Decoder.cs +++ b/Service/Charger/Codec/Decoder.cs @@ -244,7 +244,7 @@ public class Decoder : ByteToMessageDecoder 51 => recordType switch { 2 => ModelConvert.Decode(bytes), - 4 => ModelConvert.Decode(bytes), + 3 => ModelConvert.Decode(bytes), 5 => ModelConvert.Decode(bytes), 7 => ModelConvert.Decode(bytes), 12 => ModelConvert.Decode(bytes), diff --git a/Service/Charger/Handler/OutCharger/PileStartChargeResHandler.cs b/Service/Charger/Handler/OutCharger/PileStartChargeResHandler.cs index 33c92d2..a579b02 100644 --- a/Service/Charger/Handler/OutCharger/PileStartChargeResHandler.cs +++ b/Service/Charger/Handler/OutCharger/PileStartChargeResHandler.cs @@ -29,8 +29,9 @@ public class PileStartChargeResHandler : SimpleChannelInboundHandler.Success(true); + return chargerClient.SendStopOutCharger(chargerGunCode, 0); } ///