|
|
@ -22,6 +22,7 @@ using Service.Charger.Msg.Charger.Resp;
|
|
|
|
using Service.Charger.Msg.Host.Req;
|
|
|
|
using Service.Charger.Msg.Host.Req;
|
|
|
|
using Service.Charger.Msg.Host.Req.Bms;
|
|
|
|
using Service.Charger.Msg.Host.Req.Bms;
|
|
|
|
using Service.Charger.Msg.Host.Req.OutCharger.Req;
|
|
|
|
using Service.Charger.Msg.Host.Req.OutCharger.Req;
|
|
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Service.Charger.Client;
|
|
|
|
namespace Service.Charger.Client;
|
|
|
|
|
|
|
|
|
|
|
@ -228,13 +229,15 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
|
|
|
|
|
|
|
|
private ChargeOrderRepository _chargeOrderRepository;
|
|
|
|
private ChargeOrderRepository _chargeOrderRepository;
|
|
|
|
private BinInfoRepository _binInfoRepository;
|
|
|
|
private BinInfoRepository _binInfoRepository;
|
|
|
|
|
|
|
|
private ElecPriceModelVersionDetailRepository _elecPriceModelVersionDetailRepository;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public ChargerClient(ChargeOrderRepository chargeOrderRepository, BinInfoRepository binInfoRepository)
|
|
|
|
public ChargerClient(ChargeOrderRepository chargeOrderRepository, BinInfoRepository binInfoRepository,ElecPriceModelVersionDetailRepository elecPriceModelVersionDetailRepository)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_chargeOrderRepository = chargeOrderRepository;
|
|
|
|
_chargeOrderRepository = chargeOrderRepository;
|
|
|
|
_binInfoRepository = binInfoRepository;
|
|
|
|
_binInfoRepository = binInfoRepository;
|
|
|
|
|
|
|
|
_elecPriceModelVersionDetailRepository = elecPriceModelVersionDetailRepository;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ILog Log()
|
|
|
|
private ILog Log()
|
|
|
@ -289,11 +292,30 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(auth, Formatting.Indented) + "\r\n" +
|
|
|
|
CurrentCmd = JsonConvert.SerializeObject(auth, Formatting.Indented) + "\r\n" +
|
|
|
|
BitUtls.BytesToHexStr(auth.ToBytes());
|
|
|
|
BitUtls.BytesToHexStr(auth.ToBytes());
|
|
|
|
this.Channel.WriteAndFlushAsync(auth);
|
|
|
|
this.Channel.WriteAndFlushAsync(auth);
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetPeakValleyTime SetPeakValleyTime = new SetPeakValleyTime();
|
|
|
|
try
|
|
|
|
SendSetPeakValleyTime(SetPeakValleyTime);
|
|
|
|
{
|
|
|
|
|
|
|
|
Log().Info("Auth after send SetPeakValleyTime");
|
|
|
|
|
|
|
|
ConcurrentDictionary<string, ChargerClient> chargerClients = ClientMgr.Dictionary;
|
|
|
|
|
|
|
|
if (chargerClients.Values.Count <= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Result<bool>.Fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var chargerClientsValue in chargerClients.Values)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (chargerClientsValue.Connected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
chargerClientsValue.SendSetPeakValleyTime(BulidSetPeakValleyTimeObj(1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log().Info($"Auth after send SetPeakValleyTime deeor:{e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -738,4 +760,42 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
return timeRng;
|
|
|
|
return timeRng;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails =
|
|
|
|
|
|
|
|
_elecPriceModelVersionDetailRepository.QueryListByClause(u => u.Version == version, u => u.StartHour,
|
|
|
|
|
|
|
|
OrderByType.Asc);
|
|
|
|
|
|
|
|
SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NumberTime = Convert.ToByte(elecPriceModelVersionDetails.Count),
|
|
|
|
|
|
|
|
StartHH1 = (byte)(elecPriceModelVersionDetails.Count > 0?Convert.ToByte(elecPriceModelVersionDetails[0].StartHour) :0),
|
|
|
|
|
|
|
|
StartHH2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].StartHour) : 0),
|
|
|
|
|
|
|
|
StartHH3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].StartHour):0),
|
|
|
|
|
|
|
|
StartHH4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].StartHour):0),
|
|
|
|
|
|
|
|
StartHH5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].StartHour):0),
|
|
|
|
|
|
|
|
StartHH6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].StartHour):0),
|
|
|
|
|
|
|
|
StartHH7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].StartHour):0),
|
|
|
|
|
|
|
|
StartHH8 = (byte)(elecPriceModelVersionDetails.Count > 7?Convert.ToByte(elecPriceModelVersionDetails[7].StartHour) : 0),
|
|
|
|
|
|
|
|
StartMM1 = (byte)(elecPriceModelVersionDetails.Count > 0?Convert.ToByte(elecPriceModelVersionDetails[0].StartMinute):0),
|
|
|
|
|
|
|
|
StartMM2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].StartMinute):0),
|
|
|
|
|
|
|
|
StartMM3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].StartMinute):0),
|
|
|
|
|
|
|
|
StartMM4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].StartMinute):0),
|
|
|
|
|
|
|
|
StartMM5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].StartMinute):0),
|
|
|
|
|
|
|
|
StartMM6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].StartMinute):0),
|
|
|
|
|
|
|
|
StartMM7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].StartMinute) : 0),
|
|
|
|
|
|
|
|
StartMM8 = (byte)(elecPriceModelVersionDetails.Count > 7 ? Convert.ToByte(elecPriceModelVersionDetails[7].StartMinute) : 0),
|
|
|
|
|
|
|
|
TimePeak1 = (byte)(elecPriceModelVersionDetails.Count > 0 ? Convert.ToByte(elecPriceModelVersionDetails[0].Type):0),
|
|
|
|
|
|
|
|
TimePeak2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].Type):0),
|
|
|
|
|
|
|
|
TimePeak3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].Type):0),
|
|
|
|
|
|
|
|
TimePeak4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].Type):0),
|
|
|
|
|
|
|
|
TimePeak5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].Type):0),
|
|
|
|
|
|
|
|
TimePeak6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].Type):0),
|
|
|
|
|
|
|
|
TimePeak7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].Type):0),
|
|
|
|
|
|
|
|
TimePeak8 = (byte)(elecPriceModelVersionDetails.Count > 7?Convert.ToByte(elecPriceModelVersionDetails[7].Type):0)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return setPeakValleyTime;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|