同步能辉充电机代码

master
lxw 4 months ago
parent 3a39ac3976
commit c6ff3cf2c4

@ -5,5 +5,6 @@ public enum EquipmentType
Charger,
Ammeter,
WaterCool,
Plc
Plc,
BMS
}

@ -3,6 +3,9 @@ using Newtonsoft.Json;
namespace Common.Util;
/// <summary>
/// http工具类
/// </summary>
public static class HttpUtil
{
private static readonly HttpClient httpClient = new HttpClient();

@ -16,7 +16,7 @@ namespace Entity.DbModel.Station
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public int Id { get; set; }
@ -37,7 +37,7 @@ namespace Entity.DbModel.Station
public string BatteryNo { get; set; }
/// <summary>
/// Desc:启动报文状态;0-初始化1-启动成功
/// Desc:启动报文状态;0-初始化1-启动成功2-启动失败
/// Default:0
/// Nullable:True
/// </summary>
@ -51,7 +51,7 @@ namespace Entity.DbModel.Station
/// </summary>
[SugarColumn(ColumnName = "charger_no")]
public string ChargerNo { get; set; }
/// <summary>
/// Desc:充电枪编号
/// Default:
@ -59,7 +59,7 @@ namespace Entity.DbModel.Station
/// </summary>
[SugarColumn(ColumnName = "charger_gun_no")]
public string ChargerGunNo { get; set; }
/// <summary>
/// Desc:站外充电枪编号,1枪或2枪
/// Default:
@ -266,9 +266,9 @@ namespace Entity.DbModel.Station
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "cloud_report_status")]
public int? CloudReportStatus { get; set; }
public int CloudReportStatus { get; set; }
/// <summary>
/// Desc:云平台订单编号
/// Default:
@ -283,6 +283,19 @@ namespace Entity.DbModel.Station
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "can_upload")]
public int? CanUpload { get; set; }
public int CanUpload { get; set; }
/// <summary>
/// 启动方式0-站控自动启动1-站控手动启动2-充电机启动
/// </summary>
[SugarColumn(ColumnName = "start_type")]
public int StartType { get; set; }
/// <summary>
/// 上报次数
/// </summary>
[SugarColumn(ColumnName = "reporting_times")]
public int ReportingTimes { get; set; }
}
}
}

@ -67,4 +67,6 @@ public partial class EquipAlarmDefine : BaseModel
/// </summary>
[SugarColumn(ColumnName = "process_method")]
public string ProcessMethod { get; set; }
}

@ -3,84 +3,84 @@
namespace Entity.DbModel.Station;
///<summary>
///设备报警处理记录
///</summary>
[SugarTable("equip_alarm_process_record")]
public partial class EquipAlarmProcessRecord : BaseModel
{
public EquipAlarmProcessRecord()
///设备报警处理记录
///</summary>
[SugarTable("equip_alarm_process_record")]
public partial class EquipAlarmProcessRecord : BaseModel
{
}
public EquipAlarmProcessRecord()
{
}
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(ColumnName = "id")]
public int Id { get; set; }
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(ColumnName = "id")]
public int Id { get; set; }
/// <summary>
/// Desc:设备类型编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "equip_type_code")]
public int EquipTypeCode { get; set; }
/// <summary>
/// Desc:设备类型编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "equip_type_code")]
public int EquipTypeCode { get; set; }
/// <summary>
/// Desc:设备编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "equip_code")]
public string EquipCode { get; set; }
/// <summary>
/// Desc:设备编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "equip_code")]
public string EquipCode { get; set; }
/// <summary>
/// Desc:报警编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "error_code")]
public string ErrorCode { get; set; }
/// <summary>
/// Desc:报警编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "error_code")]
public string ErrorCode { get; set; }
/// <summary>
/// Desc:报警等级
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "error_level")]
public string ErrorLevel { get; set; }
/// <summary>
/// Desc:报警等级
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "error_level")]
public string ErrorLevel { get; set; }
/// <summary>
/// Desc:报警描述
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "error_msg")]
public string ErrorMsg { get; set; }
/// <summary>
/// Desc:报警描述
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "error_msg")]
public string ErrorMsg { get; set; }
/// <summary>
/// Desc:处理方法
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "process_method")]
public string ProcessMethod { get; set; }
/// <summary>
/// Desc:处理方法
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "process_method")]
public string ProcessMethod { get; set; }
/// <summary>
/// Desc:开始时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
/// <summary>
/// Desc:处理时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "process_time")]
public DateTime? ProcessTime { get; set; }
/// <summary>
/// Desc:开始时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
/// <summary>
/// Desc:处理时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "process_time")]
public DateTime? ProcessTime { get; set; }
}
}

@ -75,4 +75,6 @@ public partial class EquipAlarmRecord : BaseModel
/// </summary>
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
}

@ -0,0 +1,38 @@
namespace Entity.Dto.Resp;
/// <summary>
/// 充电桩信息
/// </summary>
public class ChargerPileResp
{
public ChargerPileResp()
{
}
public string Sn { get; set; }
/// <summary>
/// 站外1枪是否充电
/// </summary>
public bool GunChargedOne { get; set; }
/// <summary>
/// 站外2枪是否充电
/// </summary>
public bool GunChargedTwo { get; set; }
/// <summary>
/// 站外1枪是否连接
/// </summary>
public bool ChargedPileOne { get; set; }
/// <summary>
/// 站外2枪是否连接
/// </summary>
public bool ChargedPileTwo { get; set; }
/// <summary>
/// 站外1枪充电功率
/// </summary>
public float? ChargePilePowerOne { get; set; }
/// <summary>
/// 站外2枪充电功率
/// </summary>
public float? ChargePilePowerTwo { get; set; }
}

@ -10,7 +10,7 @@ public class EquipAlarmDefineRepository : BaseRepository<EquipAlarmDefine>
public EquipAlarmDefineRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
/// <summary>
///
/// </summary>

@ -10,10 +10,4 @@ public class EquipAlarmRecordRepository : BaseRepository<EquipAlarmRecord>
public EquipAlarmRecordRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
public EquipAlarmRecord? SelectByEquipCodeAndErrorCode(int equipTypeCode, string equipCode, string errorCode)
{
return this.QueryByClause(it => it.EquipTypeCode == equipTypeCode &&
it.EquipCode == equipCode && it.ErrorCode == errorCode);
}
}

@ -27,7 +27,7 @@ public class EquipInfoRepository: BaseRepository<EquipInfo>
.WhereIF(isWhere1, expression1)
.WhereIF(isWhere2, expression2)
.WhereIF(isWhere3, expression3)
.OrderBuilder(input)
.OrderBuilder(input, "", "Id", false)
.WithNoLockOrNot(blUseNoLock)
.ToPageListAsync(pageNumber, pageSize, totalNumber);

@ -48,9 +48,9 @@ public class ChargerService
byte chargeSoc = StaticStationInfo.ChargeSoc;
float? chargePower = EquipInfoRepository.QueryPowerByCode(binNo);
float? chargePower = EquipInfoRepository.QueryPowerByCode(binInfo.ChargerNo);
float? power = chargePower == null ? StaticStationInfo.ChargePower : chargePower;
return chargerClient.StartCharge(chargeSoc,(float)power);
return chargerClient.StartCharge(chargeSoc,(float)power, 1);
}
/// <summary>
@ -114,30 +114,30 @@ public class ChargerService
SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime()
{
NumberTime = Convert.ToByte(elecPriceModelVersionDetails.Count),
StartHH1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartHour),
StartHH2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartHour),
StartHH3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartHour),
StartHH4 = Convert.ToByte(elecPriceModelVersionDetails[3].StartHour),
StartHH5 = Convert.ToByte(elecPriceModelVersionDetails[4].StartHour),
StartHH6 = Convert.ToByte(elecPriceModelVersionDetails[5].StartHour),
StartHH7 = Convert.ToByte(elecPriceModelVersionDetails[6].StartHour),
StartHH8 = Convert.ToByte(elecPriceModelVersionDetails[7].StartHour),
StartMM1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartMinute),
StartMM2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartMinute),
StartMM3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartMinute),
StartMM4 = Convert.ToByte(elecPriceModelVersionDetails[3].StartMinute),
StartMM5 = Convert.ToByte(elecPriceModelVersionDetails[4].StartMinute),
StartMM6 = Convert.ToByte(elecPriceModelVersionDetails[5].StartMinute),
StartMM7 = Convert.ToByte(elecPriceModelVersionDetails[6].StartMinute),
StartMM8 = Convert.ToByte(elecPriceModelVersionDetails[7].StartMinute),
TimePeak1 = Convert.ToByte(elecPriceModelVersionDetails[0].Type),
TimePeak2 = Convert.ToByte(elecPriceModelVersionDetails[1].Type),
TimePeak3 = Convert.ToByte(elecPriceModelVersionDetails[2].Type),
TimePeak4 = Convert.ToByte(elecPriceModelVersionDetails[3].Type),
TimePeak5 = Convert.ToByte(elecPriceModelVersionDetails[4].Type),
TimePeak6 = Convert.ToByte(elecPriceModelVersionDetails[5].Type),
TimePeak7 = Convert.ToByte(elecPriceModelVersionDetails[6].Type),
TimePeak8 = Convert.ToByte(elecPriceModelVersionDetails[7].Type)
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;
}
@ -153,7 +153,7 @@ public class ChargerService
if (binInfos.Count > 0)
batteryStatusInfoResp.btyTotalCount = binInfos.Count();
List<BinInfo> canSwapCounts = BinInfoRepository.QueryListByClause(i =>
i.Exists == 1 && i.Status == 1 && i.Soc > Convert.ToDecimal(StaticStationInfo.SwapSoc));
i.Exists == 1 && i.Status == 1 && i.Soc >= Convert.ToDecimal(StaticStationInfo.SwapSoc) && i.ChargeStatus!=1);
if (canSwapCounts.Count > 0)
batteryStatusInfoResp.canSwapCount = canSwapCounts.Count();
List<BinInfo> chargingCounts =
@ -162,4 +162,4 @@ public class ChargerService
batteryStatusInfoResp.chargingCount = chargingCounts.Count();
return Result<BatteryStatusInfoResp>.Success(batteryStatusInfoResp);
}
}
}

@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using System.Reflection;
using Autofac;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
@ -18,9 +19,9 @@ using Service.Charger.Msg;
using Service.Charger.Msg.Charger.OutCharger.Req;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Charger.Resp;
using Service.Charger.Msg.Host.OutCharger.Req;
using Service.Charger.Msg.Host.Req;
using Service.Charger.Msg.Host.Req.Bms;
using Service.Charger.Msg.Host.Req.OutCharger.Req;
namespace Service.Charger.Client;
@ -30,7 +31,6 @@ namespace Service.Charger.Client;
[Scope("InstancePerDependency")]
public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
{
#region 属性
/// <summary>
@ -50,9 +50,8 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// 是否已经开始充电
/// </summary>
public bool IsCharged { get; set; } = false;
/// <summary>
/// 站外两枪时是否在充电
/// </summary>
@ -61,6 +60,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
[1] = false,
[2] = false
};
/// <summary>
/// 充电桩连接状态
/// </summary>
@ -69,7 +69,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
[1] = false,
[2] = false
};
public bool IsStopped { get; set; } = false;
public bool IsCanSendStopCmd { get; set; } = true;
@ -151,30 +151,37 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// 充电机遥测数据
/// </summary>
public UploadTelemetryData UploadTelemetryData = new UploadTelemetryData();
/// <summary>
/// 充放电机上传单体动力蓄电池电压极值统计
/// </summary>
public VoltageExtremumStatistics? VoltageExtremumStatistics = new VoltageExtremumStatistics();
/// <summary>
/// 充电桩的遥测
/// </summary>
public ConcurrentDictionary<byte, PileUploadTelemetry> PileUploadTelemetry = new();
/// <summary>
/// 充电桩的遥信
/// </summary>
public ConcurrentDictionary<byte, PileUploadRemoteSignal> PileUploadRemoteSignal = new();
/// <summary>
/// 充电桩状态信息
/// </summary>
public ConcurrentDictionary<byte, ChargerPile> ChargerPile = new();
/// <summary>
/// 充电桩功率
/// </summary>
public ConcurrentDictionary<byte, float> ChargePilePower = new();
/// <summary>
///充电机实时充电功率
/// </summary>
public float RealTimeChargePower { get; set; } = 0;
/// <summary>
/// 心跳-桩状态
/// </summary>
@ -455,9 +462,20 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
return Result<bool>.Fail($"charger-{BinNo} disconnect");
}
setPeakValleyTime= GetMsgContents(setPeakValleyTime);
CurrentCmd = JsonConvert.SerializeObject(setPeakValleyTime, Formatting.Indented) + "\r\n" +
BitUtls.BytesToHexStr(setPeakValleyTime.ToBytes());
this.Channel.WriteAndFlushAsync(setPeakValleyTime);
Log().Info($"SendSetPeakValleyTime{CurrentCmd} to chargeOrderNo={BinNo}");
return Result<bool>.Success();
}
@ -494,6 +512,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
this.Channel.WriteAndFlushAsync(req);
return Result<bool>.Success();
}
/// <summary>
/// 3.7.1 监控平台远程启动充电桩充电
/// </summary>
@ -503,7 +522,8 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// <param name="changePowerCmdType">功率调节参数</param>
/// <param name="chargeOrderNo"></param>
/// <returns>充电流水号</returns>
public Result<string> SendStartOutCharger(byte pn, byte socValue, short changePower=360,byte changePowerCmdType=1 ,
public Result<string> SendStartOutCharger(byte pn, byte socValue, short changePower = 360,
byte changePowerCmdType = 1,
string? chargeOrderNo = null)
{
if (!Connected)
@ -519,12 +539,14 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
Log().Info(
$"SendStartOutCharger pn={pn}, socValue={socValue}, changePower={changePower}, changePowerCmdType={changePowerCmdType}, chargeOrderNo={chargeOrderNo}");
PileStartCharge pileStartCharge = new PileStartCharge(pn, socValue, changePowerCmdType, changePower,chargeOrderNo);
PileStartCharge pileStartCharge =
new PileStartCharge(pn, socValue, changePowerCmdType, changePower, chargeOrderNo);
this.Channel.WriteAndFlushAsync(pileStartCharge);
return Result<string>.Success(chargeOrderNo);
}
/// <summary>
/// 3.7.3 监控平台远程停止充电桩充电
/// </summary>
@ -537,14 +559,33 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
{
return Result<string>.Fail($"充电机{BinNo}未连接");
}
Log().Info(
$"SendStartOutCharger pn={pn}, stopReason={stopReason}");
PileStopCharge pileStopCharge=new PileStopCharge(pn,stopReason);
PileStopCharge pileStopCharge = new PileStopCharge(pn, stopReason);
this.Channel.WriteAndFlushAsync(pileStopCharge);
return Result<string>.Success();
}
/// <summary>
/// 3.7.9 监控平台发送充电桩功率调节指令
/// </summary>
/// <param name="pn"></param>
/// <param name="expectedOperatingPower"></param>
/// <returns></returns>
public Result<bool> SendPileAdjustPower(byte pn, float expectedOperatingPower)
{
if (!Connected)
{
return Result<bool>.Fail($"charger-{BinNo} disconnect");
}
PileAdjustPower powerRegulation = new PileAdjustPower(pn, expectedOperatingPower);
this.Channel.WriteAndFlushAsync(powerRegulation);
return Result<bool>.Success();
}
/// <summary>
///
/// </summary>
@ -570,7 +611,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// <summary>
///
/// </summary>
public Result<bool> StartCharge(byte chargeSoc, float chargePower)
public Result<bool> StartCharge(byte chargeSoc, float chargePower, int startType)
{
if (string.IsNullOrWhiteSpace(BinNo))
{
@ -589,17 +630,17 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
}
BatteryNo = binInfo.BatteryNo;
if (string.IsNullOrWhiteSpace(BatteryNo))
if (string.IsNullOrWhiteSpace(BatteryNo) || "-1" == BatteryNo)
{
return Result<bool>.Fail($"charger-{BinNo} battery not exist");
}
if (binInfo.AmtLock == 1)
if (binInfo.AmtLock == 1)
{
return Result<bool>.Fail($"仓-{BinNo} 被锁定");
}
if (binInfo.CanChargeFlag == 0)
if (binInfo.CanChargeFlag == 0)
{
return Result<bool>.Fail($"仓-{BinNo} 被禁用");
}
@ -620,6 +661,9 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
return Result<bool>.Fail(chargeOrderNo.Msg);
}
SwapOrderBatteryRepository swapOrderBatteryRepository = AppInfo.Container.Resolve<SwapOrderBatteryRepository>();
SwapOrderBattery? swapOrder = swapOrderBatteryRepository.QueryLatestOrderNoByBatterySn(BatteryNo);
ChargeOrderNo = chargeOrderNo.Data;
_chargeOrderRepository.Insert(new ChargeOrder()
{
@ -628,7 +672,9 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
CmdStatus = 0,
ChargerNo = BinNo,
ChargeMode = 1,
StartMode = 1
SwapOrderSn = swapOrder?.SwapOrderSn,
StartMode = 1,
StartType = startType
});
return Result<bool>.Success(true, "发送成功");
@ -659,4 +705,33 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
ChannelUtils.AddAttr(Channel, ChargerConst.EqmCode, sn);
ChannelUtils.AddAttr(Channel, ChargerConst.DestAddr, destAddr);
}
/// <summary>
/// 获取尖峰平谷字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private SetPeakValleyTime GetMsgContents(SetPeakValleyTime timeRng)
{
for (int i = 0; i < timeRng.NumberTime; i++)
{
PropertyInfo propertyStartTimePeriod1 = timeRng.GetType().GetProperty("StartHH" + (i + 1));
propertyStartTimePeriod1.SetValue(timeRng, BitUtls.ByteToBCD(Convert.ToByte(timeRng.GetType().GetProperty("StartHH" + (i + 1)).GetValue(timeRng))));
PropertyInfo propertyStartTimePeriod2 = timeRng.GetType().GetProperty("StartMM" + (i + 1));
propertyStartTimePeriod2.SetValue(timeRng, BitUtls.ByteToBCD(Convert.ToByte(timeRng.GetType().GetProperty("StartMM" + (i + 1)).GetValue(timeRng))));
PropertyInfo propertyTimePeriodPeakIden = timeRng.GetType().GetProperty("TimePeak" + (i + 1));
propertyTimePeriodPeakIden.SetValue(timeRng, timeRng.GetType().GetProperty("TimePeak" + (i + 1)).GetValue(timeRng));
}
return timeRng;
}
}

@ -46,5 +46,10 @@ public class ChargerPile
/// 充电枪的唯一标识码
/// </summary>
public string? pn { get; set; }
/// <summary>
/// 工作状态
/// </summary>
public byte WorkStatus { get; set; }
}

@ -250,6 +250,7 @@ public class Decoder : ByteToMessageDecoder
12 => ModelConvert.Decode<PileUploadTelemetry>(bytes),
11 => ModelConvert.Decode<PileUploadRemoteSignal>(bytes),
14 => ModelConvert.Decode<PileUploadChargeRecord>(bytes),
10 => ModelConvert.Decode<PileAdjustPowerRes>(bytes),
_ => throw new InvalidOperationException("This should never be reached"),
},
#endregion

@ -4,13 +4,15 @@ namespace Service.Charger.Common;
public static class ChargerConst
{
public static readonly AttributeKey<string> ChargerSn = AttributeKey<string>.ValueOf("charger_sn");
public static readonly AttributeKey<string> WaterCoolSn = AttributeKey<string>.ValueOf("water_cool_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";
@ -27,13 +29,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;
}
}
}

@ -0,0 +1,8 @@
using DotNetty.Common.Utilities;
namespace Service.Charger.Common;
public class WaterCoolerConst
{
public static readonly AttributeKey<string> WaterCoolSn = AttributeKey<string>.ValueOf("water_cool_sn");
}

@ -2,6 +2,7 @@
using DotNetty.Transport.Channels;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Utils;
using log4net;
using Repository.Station;
using Service.Charger.Client;
@ -28,7 +29,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 +48,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,32 +60,39 @@ 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)
{
client.IsCharged = false;
}
if (ObjUtils.IsNotNullOrWhiteSpace( client.ChargeOrderNo))
{
ChargeOrderRepository.Update(it => it.CmdStatus == (msg.Result == 0 ? 1 : 2),
it => it.Sn == client.ChargeOrderNo);
}
int update = BinInfoRepository.Update(t => t.ChargeStatus == chargeStatus, t => t.No == client.BinNo);
Log.Info($"update {update} start charge finish status {chargeStatus} for {client.BinNo}");

@ -50,7 +50,10 @@ namespace Service.Charger.Handler
if (ObjUtils.IsNotEmpty(orders))
{
List<int> list = orders.Select(it => it.Id).ToList();
ChargeOrderRepository.Update(it => it.CanUpload == 1, it => list.Contains(it.Id));
ChargeOrderRepository.Update(it => new ChargeOrder()
{CanUpload = 1 ,ReportingTimes=0 },
it => list.Contains(it.Id));
}
}
}

@ -0,0 +1,22 @@
using DotNetty.Transport.Channels;
using log4net;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.OutCharger.Resp;
namespace Service.Charger.Handler.OutCharger;
/// <summary>
/// 3.7.10 充电桩应答功率调节指令
/// </summary>
public class PileAdjustPowerHandler : SimpleChannelInboundHandler<PileAdjustPowerRes>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(PileAdjustPowerHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, PileAdjustPowerRes msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
}
}
}

@ -11,6 +11,7 @@ using Service.Charger.Msg.Charger.OutCharger.Resp;
using Service.Charger.Msg.Http.Resp;
namespace Service.Charger.Handler.OutCharger;
/// <summary>
/// 3.7.2 充电桩响应远程启动充电
/// </summary>
@ -20,7 +21,7 @@ public class PileStartChargeResHandler : SimpleChannelInboundHandler<PileStartCh
{
private static readonly ILog Log = LogManager.GetLogger(typeof(PileStartChargeResHandler));
public ChargeOrderRepository ChargeOrderRepository { get; set; }
protected override void ChannelRead0(IChannelHandlerContext ctx, PileStartChargeRes msg)
{

@ -38,7 +38,7 @@ public class PileStopChargeResHandler : SimpleChannelInboundHandler<PileStopChar
PileStopChargeHttpRes res = new PileStopChargeHttpRes();
res.pn = chargeOrder.ChargerGunNo;
res.rs = msg.rs.ToString();
HttpUtil.SendPostRequest(res, "http://127.0.0.1:5034/api/OutCharger/ResStartOutCharger");
HttpUtil.SendPostRequest(res, "http://127.0.0.1:5034/api/OutCharger/ResStopOutCharger");
}
}
}

@ -102,8 +102,7 @@ public class PileUploadChargeRecordHandler : SimpleChannelInboundHandler<PileUpl
ChargeOrderRepository.Update(chargeOrder);
PileEndChargeReq req = new PileEndChargeReq();
req.sn = StaticStationInfo.StationNo;
req.con = chargeOrder.CloudChargeOrder;
req.cosn = chargeOrder.Sn;

@ -26,7 +26,8 @@ public class PileUploadRemoteSignalHandler: SimpleChannelInboundHandler<PileUplo
client.GunCharged[msg.Pn] = msg.WorkStatus == 1 ? true : false;
client.ChargedPile[msg.Pn] = msg.ChargeStationGunHolderStatus;
client.ChargedPile[msg.Pn] = !msg.ChargeStationGunHolderStatus;
client.ChargerPile[msg.Pn].WorkStatus = msg.WorkStatus;

@ -23,7 +23,7 @@ public class PileUploadTelemetryHandler : SimpleChannelInboundHandler<PileUpload
client.PileUploadTelemetry[msg.Pn] = msg;
client.RealTimeChargePower = msg.HighVoltageAcquisitionCurrent * msg.HighVoltageAcquisitionVoltage;
client.ChargePilePower[msg.Pn] = msg.HighVoltageAcquisitionCurrent * msg.HighVoltageAcquisitionVoltage;
}
}

@ -37,7 +37,10 @@ namespace Service.Charger.Handler
sb.Append(Convert.ToChar(msg.BatterSnBytes[i]));
}
client.BatteryNo = sb.ToString();
if (!sb.ToString().Contains("ÿ"))
{
client.BatteryNo = sb.ToString();
}
client.BatteryFactory = msg.BatterFactory;
if (_binInfoRepository.Update(t => t.BatteryNo == client.BatteryNo, t => t.No == client.BinNo) > 0)

@ -41,6 +41,8 @@ namespace Service.Charger.Handler
if(ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
float[] powersPeriods = new float[4] { 0, 0, 0, 0 }; //元素索引顺序代表值1234
if (msg.FlagOfTime1 >= 1 && msg.FlagOfTime1 <= 4){powersPeriods[msg.FlagOfTime1 - 1] += msg.ChargingPowerOfTime1;}
if (msg.FlagOfTime2 >= 1 && msg.FlagOfTime2 <= 4){powersPeriods[msg.FlagOfTime2 - 1] += msg.ChargingPowerOfTime2;}
@ -70,6 +72,7 @@ namespace Service.Charger.Handler
if (db == null)
{
TimeSpan timeSpan = endTime - startTime;
ChargeOrder chargeOrder = new ChargeOrder()
{
Sn = client.ChargeOrderNo,
@ -79,7 +82,7 @@ namespace Service.Charger.Handler
StartSoc = msg.SocBefore,
StopSoc = msg.SocAfter,
ChargeTimeCount = (int)(endTime - startTime).TotalMinutes,
ChargeTimeCount = (int)Math.Round(timeSpan.TotalMinutes),
ElecCount = Convert.ToDecimal(msg.ChargingPower),
AcElecCount = Convert.ToDecimal(msg.AcMeterElecCount),
StartAcElec = Convert.ToDecimal(msg.AcMeterDataBefore),
@ -87,15 +90,16 @@ namespace Service.Charger.Handler
StartDcElec = Convert.ToDecimal(msg.DcMeterDataBefore),
StopDcElec = Convert.ToDecimal(msg.DcMeterDataAfter),
SharpElecCount = Convert.ToDecimal(powersPeriods[0]),
PeakElecCount = Convert.ToDecimal(powersPeriods[0]),
FlatElecCount = Convert.ToDecimal(powersPeriods[0]),
ValleyElecCount = Convert.ToDecimal(powersPeriods[0]),
PeakElecCount = Convert.ToDecimal(powersPeriods[1]),
FlatElecCount = Convert.ToDecimal(powersPeriods[2]),
ValleyElecCount = Convert.ToDecimal(powersPeriods[3]),
AcSharpElecCount = Convert.ToDecimal(acPowersPeriods[0]),
AcPeakElecCount = Convert.ToDecimal(acPowersPeriods[0]),
AcFlatElecCount = Convert.ToDecimal(acPowersPeriods[0]),
AcValleyElecCount = Convert.ToDecimal(acPowersPeriods[0]),
AcPeakElecCount = Convert.ToDecimal(acPowersPeriods[1]),
AcFlatElecCount = Convert.ToDecimal(acPowersPeriods[2]),
AcValleyElecCount = Convert.ToDecimal(acPowersPeriods[3]),
ChargeMode = msg.ChargeMode,
StartMode = msg.StartMode
StartMode = msg.StartMode,
StartType = 2
};
_chargeOrderRepository.Insert(chargeOrder);
@ -107,7 +111,7 @@ namespace Service.Charger.Handler
db.StartSoc = msg.SocBefore;
db.StopSoc = msg.SocAfter;
TimeSpan? timeSpan = (db.EndTime - db.StartTime);
db.ChargeTimeCount= timeSpan?.Minutes;
db.ChargeTimeCount= (int)Math.Round(Convert.ToDecimal(timeSpan?.TotalMinutes));
db.ElecCount = Convert.ToDecimal(msg.ChargingPower);
db.AcElecCount = Convert.ToDecimal(msg.AcMeterElecCount);
db.StartAcElec = Convert.ToDecimal(msg.AcMeterDataBefore);
@ -115,19 +119,21 @@ namespace Service.Charger.Handler
db.StartDcElec = Convert.ToDecimal(msg.DcMeterDataBefore);
db.StopDcElec = Convert.ToDecimal(msg.DcMeterDataAfter);
db.SharpElecCount = Convert.ToDecimal(powersPeriods[0]);
db.PeakElecCount = Convert.ToDecimal(powersPeriods[0]);
db.FlatElecCount = Convert.ToDecimal(powersPeriods[0]);
db.ValleyElecCount = Convert.ToDecimal(powersPeriods[0]);
db.PeakElecCount = Convert.ToDecimal(powersPeriods[1]);
db.FlatElecCount = Convert.ToDecimal(powersPeriods[2]);
db.ValleyElecCount = Convert.ToDecimal(powersPeriods[3]);
db.AcSharpElecCount = Convert.ToDecimal(acPowersPeriods[0]);
db.AcPeakElecCount = Convert.ToDecimal(acPowersPeriods[0]);
db.AcFlatElecCount = Convert.ToDecimal(acPowersPeriods[0]);
db.AcValleyElecCount = Convert.ToDecimal(acPowersPeriods[0]);
db.AcPeakElecCount = Convert.ToDecimal(acPowersPeriods[1]);
db.AcFlatElecCount = Convert.ToDecimal(acPowersPeriods[2]);
db.AcValleyElecCount = Convert.ToDecimal(acPowersPeriods[3]);
db.ChargeMode = msg.ChargeMode;
db.StartMode = msg.StartMode;
_chargeOrderRepository.Update(db);
}
ctx.Channel.WriteAndFlushAsync(new RecordChargeRespData());
Log.Info($"receive {msg} from {sn}");
}
}

@ -45,8 +45,7 @@ namespace Service.Charger.Handler
ChargeOrderRepository.Update(
i => new ChargeOrder()
{
CmdStatus = 1,
StartTime = client.ChargingStartTime
CmdStatus = 1
},
it => it.Id == one.Id);
}
@ -63,4 +62,4 @@ namespace Service.Charger.Handler
}
}
}
}
}

@ -0,0 +1,34 @@
using System.Text;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Service.Charger.Client;
using Service.Charger.Handler;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Charger.Resp;
using Service.Charger.Msg.Host.Resp;
namespace HybirdFrameworkServices.Charger.Handler
{
/// <summary>
/// 3.4.10 监控网关响应尖峰平谷设置
/// <code>
/// 1保存日志到log
/// </code>
/// </summary>
[Order(8)]
[Scope("InstancePerDependency")]
public class ResponseSettingHandler : SimpleChannelInboundHandler<ResponseSetting>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(ResponseSettingHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, ResponseSetting msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
}
}
}
}

@ -8,9 +8,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common.Const;
using Entity.DbModel.Station;
using Repository.Station;
namespace Service.Charger.Handler
{
@ -20,125 +17,12 @@ namespace Service.Charger.Handler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(UpAlarmHandler));
public EquipAlarmRecordRepository EquipAlarmRecordRepository { get; set; }
public EquipAlarmDefineRepository EquipAlarmDefineRepository { get; set; }
public EquipAlarmProcessRecordRepository EquipAlarmProcessRecordRepository { get; set; }
protected override void ChannelRead0(IChannelHandlerContext ctx, UpAlarm msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
{
Log.Info($"receive {msg} from {sn}");
if (msg != null && msg.BatteryFaultCode > 4000)
{
SaveAlarmInfo(new List<string> { msg.BatteryFaultCode.ToString() }, sn);
}
}
}
private void SaveAlarmInfo(List<string> lstAlarm, string sn)
{
string charger = "charger";
if (lstAlarm.Count > 0)
{
#region 有报警比较两边差异,新出现的报警就添加,消失的报警就处理并记录
var lstEquipAlarmRecord =
EquipAlarmRecordRepository.QueryListByClause(e => e.EquipTypeCode == 0).ToList();
var sqllstAlarm = lstEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList();
// 找出实时报警中存在但数据库中不存在的元素
List<string> uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList();
// 找出数据库中存在但实时报警中不存在的元素
List<string> uniqueToList2 = sqllstAlarm.Except(lstAlarm).ToList();
if (uniqueToList1.Count > 0)
{
//这里要添加新的报警数据
foreach (var errorCode in uniqueToList1)
{
EquipAlarmDefine? alarmDefine =
EquipAlarmDefineRepository.SelectByEquipCodeAndErrorCode(0, charger,
errorCode);
if (alarmDefine != null)
{
EquipAlarmRecord record = new EquipAlarmRecord()
{
EquipTypeCode = alarmDefine.EquipTypeCode,
EquipCode = sn,
ErrorCode = alarmDefine.ErrorCode,
ErrorLevel = alarmDefine.ErrorLevel,
ErrorMsg = alarmDefine.ErrorMsg,
ProcessMethod = alarmDefine.ProcessMethod,
StartTime = DateTime.Now
};
EquipAlarmRecordRepository.Insert(record);
}
}
}
if (uniqueToList2.Count > 0)
{
//这些是要清除实时报警,并且处理记录的。
// 使用LINQ找出ErrorCode在uniqueToList2中的EquipAlarmRecord对象
List<EquipAlarmRecord> filteredObjectList = lstEquipAlarmRecord
.Where(obj => uniqueToList2.Contains(obj.ErrorCode))
.ToList();
foreach (var VARIABLE in filteredObjectList)
{
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode;
EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode;
EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode;
EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel;
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime = DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
EquipAlarmRecordRepository.Delete(filteredObjectList);
}
#endregion
}
else
{
#region 没报警把已处理记录更新并删除实时报警
var lstEquipAlarmRecord =
EquipAlarmRecordRepository.QueryListByClause(e => e.EquipTypeCode == 0).ToList();
if (lstEquipAlarmRecord.Count > 0)
{
foreach (var VARIABLE in lstEquipAlarmRecord)
{
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode;
EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode;
EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode;
EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel;
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime = DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
EquipAlarmRecordRepository.Delete(e => e.EquipTypeCode == 0);
}
#endregion
}
}
}
}
}

@ -10,6 +10,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common.Const;
using Entity.DbModel.Station;
using Repository;
using Repository.Station;
namespace Service.Charger.Handler
@ -24,10 +27,18 @@ namespace Service.Charger.Handler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(UploadRemoteSignalDataHandler));
private BinInfoRepository BinInfoRepository { get; set; }
public UploadRemoteSignalDataHandler(BinInfoRepository _binInfoRepository)
private EquipAlarmRecordRepository EquipAlarmRecordRepository { get; set; }
private EquipAlarmProcessRecordRepository EquipAlarmProcessRecordRepository { get; set; }
private EquipAlarmDefineRepository EquipAlarmDefineRepository { get; set; }
public UploadRemoteSignalDataHandler(BinInfoRepository _binInfoRepository,
EquipAlarmRecordRepository _EquipAlarmRecordRepository,
EquipAlarmProcessRecordRepository _EquipAlarmProcessRecordRepository,
EquipAlarmDefineRepository _EquipAlarmDefineRepository)
{
BinInfoRepository = _binInfoRepository;
EquipAlarmRecordRepository = _EquipAlarmRecordRepository;
EquipAlarmProcessRecordRepository = _EquipAlarmProcessRecordRepository;
EquipAlarmDefineRepository = _EquipAlarmDefineRepository;
}
protected override void ChannelRead0(IChannelHandlerContext ctx, UploadRemoteSignalData msg)
@ -45,11 +56,145 @@ namespace Service.Charger.Handler
//Desc:充电状态;0-未知1-正在充电2-无电池3-禁用4-充电完成
if (msg.WorkStatus == 1)
BinInfoRepository.Update(i => i.ChargeStatus == msg.WorkStatus, i => i.No == sn);
BinInfoRepository.Update(i => i.ChargeStatus == msg.WorkStatus, i => i.ChargerNo == sn);
else if (msg.WorkStatus == 2 || msg.WorkStatus == 0)
{
BinInfoRepository.Update(i => i.ChargeStatus == 4, i => i.No == sn);
BinInfoRepository.Update(i => i.ChargeStatus == 4, i => i.ChargerNo == sn);
}
#region 充电机故障显示
//不准确,注释
//if(sn=="C2008")
//if (msg.TotalWarning||msg.TotalError)
{
var lstEquipAlarmDefine = EquipAlarmDefineRepository.QueryListByClause(i => i.EquipCode == "充电机");
List<string> lstAlarm = new List<string>();
if (msg.EmergencyStop)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="1").ToList()[0].ErrorCode);
if (msg.SmokeFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="2").ToList()[0].ErrorCode);
if (msg.ChargeACInputCircuitBreakerFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="3").ToList()[0].ErrorCode);
if (msg.DcBusPositElecContactorRefuFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="4").ToList()[0].ErrorCode);
if (msg.DcBusNegatElecContactorRefuFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="5").ToList()[0].ErrorCode);
if (msg.DcBusPositElecFusesFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="6").ToList()[0].ErrorCode);
if (msg.DDcBusNegatElecFusesFault)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="7").ToList()[0].ErrorCode);
if (msg.ChargingInterfaceLockError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="8").ToList()[0].ErrorCode);
if (msg.ChargerFanError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="9").ToList()[0].ErrorCode);
if (msg.ArresterError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="10").ToList()[0].ErrorCode);
if (msg.InsulationDetectionAlarm)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="11").ToList()[0].ErrorCode);
if (msg.InsulationDetectionError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="12").ToList()[0].ErrorCode);
if (msg.BatteryPolarityReverseError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="13").ToList()[0].ErrorCode);
if (msg.VeConGuidanceFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="14").ToList()[0].ErrorCode);
if (msg.ChargingOverTempError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="15").ToList()[0].ErrorCode);
if (msg.InterfaceOverFaulty)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="16").ToList()[0].ErrorCode);
if (msg.ChargingGunNotHomingError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="17").ToList()[0].ErrorCode);
if (msg.BmsConnError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="18").ToList()[0].ErrorCode);
if (msg.ChargerInputOverVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="19").ToList()[0].ErrorCode);
if (msg.ChargerInputUnderVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="20").ToList()[0].ErrorCode);
if (msg.DcBusOutputOverVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="21").ToList()[0].ErrorCode);
if (msg.DcBusOutputUnderVoltageError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="22").ToList()[0].ErrorCode);
if (msg.DcBusOutputOverCurrentError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="23").ToList()[0].ErrorCode);
if (!msg.VehicleConnStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="24").ToList()[0].ErrorCode);
if (!msg.ChargeStationGunHolderStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="25").ToList()[0].ErrorCode);
if (!msg.ChargingInterfaceLockStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="26").ToList()[0].ErrorCode);
if (msg.PositiveDcTransmissionContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="27").ToList()[0].ErrorCode);
if (msg.NegativeDcTransmissionContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="28").ToList()[0].ErrorCode);
if (msg.EntranceGuardError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="29").ToList()[0].ErrorCode);
if (msg.PConA3dhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="30").ToList()[0].ErrorCode);
if (msg.NConadhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="31").ToList()[0].ErrorCode);
if (msg.ReliefCircuitError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="32").ToList()[0].ErrorCode);
if (msg.ConActivated)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="33").ToList()[0].ErrorCode);
if (msg.ConAdhesionFailure)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="34").ToList()[0].ErrorCode);
if (msg.AuxiliaryPowerError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="35").ToList()[0].ErrorCode);
if (msg.ModuleOutputReverseError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="36").ToList()[0].ErrorCode);
if (msg.AcContactorStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="37").ToList()[0].ErrorCode);
if (msg.ChargingGunOverTempWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="38").ToList()[0].ErrorCode);
if (msg.ChargerOverTempWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="39").ToList()[0].ErrorCode);
if (msg.MeterConnError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="40").ToList()[0].ErrorCode);
if (msg.MeterDataError)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="41").ToList()[0].ErrorCode);
if (msg.WaterloggingWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="42").ToList()[0].ErrorCode);
if (msg.ReversePowerWarning)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="43").ToList()[0].ErrorCode);
if (msg.BatteryPackAuxiliaryPowerStatus)lstAlarm.Add(sn+lstEquipAlarmDefine.Where(i=>i.ErrorCode=="44").ToList()[0].ErrorCode);
//查询当前充电机的实时报警信息
var lstNowEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipCode == sn);
var sqllstAlarm=lstNowEquipAlarmRecord.Select(obj => obj.ErrorCode).ToList();//当前报警列表
// 找出实时报警中存在但数据库中不存在的元素
List<string> uniqueToList1 = lstAlarm.Except(sqllstAlarm).ToList();
// 找出数据库中存在但实时报警中不存在的元素
List<string> uniqueToList2 = sqllstAlarm.Except(lstAlarm).ToList();
if (uniqueToList1.Count > 0)
{//这里要添加新的报警数据
foreach (var errorCode in uniqueToList1)
{
EquipAlarmDefine? alarmDefine = EquipAlarmDefineRepository.QueryByClause(i=>i.ErrorCode==errorCode.Replace(sn,""));
if (alarmDefine != null)
{
EquipAlarmRecord record = new EquipAlarmRecord()
{
EquipTypeCode = alarmDefine.EquipTypeCode,
EquipCode = sn,
ErrorCode = errorCode,
ErrorLevel = alarmDefine.ErrorLevel,
ErrorMsg = alarmDefine.ErrorMsg,
ProcessMethod = alarmDefine.ProcessMethod,
StartTime= DateTime.Now
};
EquipAlarmRecordRepository.Insert(record);
}
}
}
else if (uniqueToList2.Count > 0)
{
//这些是要清除实时报警,并且处理记录的。
// 使用LINQ找出ErrorCode在uniqueToList2中的EquipAlarmRecord对象
List<EquipAlarmRecord> filteredObjectList = lstNowEquipAlarmRecord
.Where(obj => uniqueToList2.Contains(obj.ErrorCode))
.ToList();
foreach (var VARIABLE in filteredObjectList)
{
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode;
EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode;
EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode;
EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel;
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime=DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
EquipAlarmRecordRepository.Delete(filteredObjectList);
}
}
//else
//{
/*var lstNowEquipAlarmRecord = EquipAlarmRecordRepository.QueryListByClause(i => i.EquipCode == sn);
if (lstNowEquipAlarmRecord.Count > 0)
{
foreach (var VARIABLE in lstNowEquipAlarmRecord)
{
EquipAlarmProcessRecord EquipAlarmProcessRecord = new EquipAlarmProcessRecord();
EquipAlarmProcessRecord.EquipTypeCode = VARIABLE.EquipTypeCode;
EquipAlarmProcessRecord.EquipCode = VARIABLE.EquipCode;
EquipAlarmProcessRecord.ErrorCode = VARIABLE.ErrorCode;
EquipAlarmProcessRecord.ErrorLevel = VARIABLE.ErrorLevel;
EquipAlarmProcessRecord.ErrorMsg = VARIABLE.ErrorMsg;
EquipAlarmProcessRecord.ProcessMethod = VARIABLE.ProcessMethod;
EquipAlarmProcessRecord.StartTime = VARIABLE.StartTime;
EquipAlarmProcessRecord.ProcessTime=DateTime.Now;
EquipAlarmProcessRecordRepository.Insert(EquipAlarmProcessRecord);
}
}
EquipAlarmRecordRepository.Delete(i=>i.Id>0);*/
//}
#endregion
}
}
}

@ -1,5 +1,6 @@
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Configuration;
using HybirdFrameworkCore.Redis;
using log4net;
using Newtonsoft.Json;
@ -17,7 +18,7 @@ namespace Service.Charger.Handler
public class UploadTelemetryDataHandler : SimpleChannelInboundHandler<UploadTelemetryData>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(UploadTelemetryDataHandler));
public RedisHelper RedisHelper { get; set; }
protected override void ChannelRead0(IChannelHandlerContext ctx, UploadTelemetryData msg)
{
@ -26,8 +27,11 @@ namespace Service.Charger.Handler
msg.ChargerNo = sn;
Log.Info($"receive {msg} from {sn}");
RedisHelper.PublishAsync("UploadTelemetryData", JsonConvert.SerializeObject(msg));
if (!AppSettingsConstVars.DisabledTask.Contains("UploadTelemetryData"))
{
RedisHelper.PublishAsync("UploadTelemetryData", JsonConvert.SerializeObject(msg));
}
client.UploadTelemetryData = msg;
//充电机实时充电功率
client.RealTimeChargePower = msg.HighVoltageAcquisitionCurrent * msg.HighVoltageAcquisitionVoltage;

@ -0,0 +1,35 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Charger.OutCharger.Resp;
/// <summary>
/// 3.7.10 充电桩应答功率调节指令
/// </summary>
public class PileAdjustPowerRes: ASDU
{
/// <summary>
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
/// 充电枪ID
/// 0x01充电枪10x02充电枪20x03双枪充电;(0x00&0xFF无效)
/// </summary>
[Property(8, 8)]
public byte Pn { get; set; }
/// <summary>
/// 启动结果
/// 0 成功 1 失败
/// </summary>
[Property(16, 8)]
public byte Result { get; set; }
/// <summary>
/// 失败原因
/// 默认 0
/// </summary>
[Property(24, 8)]
public byte FailReason { get; set; }
}

@ -7,16 +7,72 @@ namespace Service.Charger.Msg.Charger.Resp
/// </summary>
public class UpBms : ASDU
{
/// <summary>
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
///PGN码
/// </summary>
[Property(0, 3, PropertyReadConstant.Byte)]
[Property(8, 24)]
public string Pgn { get; set; }
/// <summary>
/// CAN 帧数据
/// 报警级别
/// 0正常
/// 1:1 级报警 3:3 级报警 5:5 级报警 其余保留
/// </summary>
[Property(32, 8)]
public short AlarmLevel { get; set; }
/// <summary>
/// 电池箱所在位置编号 分辨率1/位偏移量0数值范围1~250
/// </summary>
[Property(40, 8)]
public short BatteryBoxLocationNumber { get; set; }
/// <summary>
/// 电池箱能输出的最大电流值 分辨率0.05A/位,偏移量:-1600A数值范围-1600A ~ 1612.75A
/// </summary>
[Property(48, 16, scale: 0.05, offset: -1600)]
public short BatteryBoxMaximumCurrentOutput { get; set; }
/// <summary>
/// 电池箱能承受最大反馈电流值 分辨率0.05A/位,偏移量:-1600A数值范围-1600A~1612.75A
/// </summary>
[Property(64, 16, scale: 0.05, offset: -1600)]
public short BatteryMaximumFeedback { get; set; }
/// <summary>
/// 电池箱风扇状态 0关闭1开启 2不可用 3不可用
/// </summary>
[Property(80, 2)]
public byte BatteryBoxFanStatus { get; set; }
/// <summary>
/// 加热装置状态 0关闭1开启 2不可用 3不可用
/// </summary>
[Property(82, 2)]
public byte HeaterCondition { get; set; }
/// <summary>
/// 均衡状态 0关闭1开启 2不可用 3不可用
/// </summary>
[Property(84, 2)]
public byte EquilibriumState { get; set; }
/// <summary>
/// 高压互锁状态 0 断开 1 连接
/// </summary>
[Property(86, 2)]
public byte HighVoltageInterlockState { get; set; }
/// <summary>
/// 保留
/// </summary>
[Property(0, 8, PropertyReadConstant.Byte)]
public string CanData { get; set; }
[Property(88, 8)]
public short Reserve { get; set; }
}
}

@ -0,0 +1,42 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Host.Req.OutCharger.Req;
/// <summary>
/// 3.7.9 监控平台发送充电桩功率调节指令
/// </summary>
public class PileAdjustPower: ASDU
{
/// <summary>
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
/// 充电枪ID号
/// 0x01充电枪10x02充电枪20x03双枪充电;(0x00&0xFF无效)
/// </summary>
[Property(8, 8)]
public byte Pn { get; set; }
/// <summary>
///期望运行 功率
/// </summary>
[Property(8, 16, PropertyReadConstant.Bit, 0.1, 1)]
public float ExpectPower { get; set; }
public PileAdjustPower(byte pn,float expectPower)
{
RecordType = 9;
FrameTypeNo = 51;
MsgBodyCount = 1;
TransReason = 3;
PublicAddr = 0;
MsgBodyAddr = new byte[] { 0, 0, 0 };
Pn = pn;
ExpectPower = expectPower;
}
}

@ -1,6 +1,6 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Host.OutCharger.Req;
namespace Service.Charger.Msg.Host.Req.OutCharger.Req;
/// <summary>
/// 3.7.1 监控平台远程启动充电桩充电

@ -1,6 +1,6 @@
using HybirdFrameworkCore.Autofac.Attribute;
namespace Service.Charger.Msg.Host.OutCharger.Req;
namespace Service.Charger.Msg.Host.Req.OutCharger.Req;
/// <summary>
/// 3.7.3 监控平台远程停止充电桩充电

@ -0,0 +1,45 @@
namespace Service.Charger.Msg.Http.Req;
/// <summary>
/// 9.2.1.5 站控上报充电枪实时数据上报
/// </summary>
public class PileRealtimeReq
{
/// <summary>
/// 换电站编码
/// </summary>
public string sn { get; set; }
/// <summary>
/// Desc:充电枪编号
/// Default:
/// Nullable:True
/// </summary>
public string? pn { get; set; }
/// <summary>
/// 充电枪状态
/// </summary>
public int ps { get; set; }
/// <summary>
/// 插枪状态
/// </summary>
public int con { get; set; }
/// <summary>
/// 单枪输出电压
/// </summary>
public float pov { get; set; }
/// <summary>
/// 单枪输出电流
/// </summary>
public float poe { get; set; }
/// <summary>
/// 单枪故障代码
/// </summary>
public int ec { get; set; }
}

@ -5,6 +5,7 @@ using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Utils;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Charger.Client;
using Service.Init;
@ -41,8 +42,8 @@ public class AutoChargeTask : ITask
DateTime now = DateTime.Now;
List<BinInfo> binInfos = binInfoRepository.Query();
if (binInfos.Count < 0)
List<BinInfo> allBinInfos = binInfoRepository.Query();
if (allBinInfos.Count < 0)
{
Log.Info("lack of binInfos");
return;
@ -54,7 +55,7 @@ public class AutoChargeTask : ITask
chargerList.Where(it => it.AutoCharge == 1).Select(it => it.Code).ToHashSet();
binInfos = binInfos.Where(it => autoChargeSet.Contains(it.ChargerNo)).ToList();
var binInfos = allBinInfos.Where(it => autoChargeSet.Contains(it.ChargerNo)).ToList();
if (ObjUtils.IsEmpty(binInfos))
{
@ -76,10 +77,24 @@ public class AutoChargeTask : ITask
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails =
elecPriceModelVersionDetailRepository.QueryListByClause(it =>
it.Version == elecPriceModelVersion.Version);
ElecPriceModelVersionDetail? elecPriceModelVersionDetail = elecPriceModelVersionDetails.Where(i =>
/*ElecPriceModelVersionDetail? elecPriceModelVersionDetail = elecPriceModelVersionDetails.Where(i =>
i.StartHour <= now.Hour && i.StartMinute <= now.Minute
&& i.EndHour > now.Hour &&
i.EndMinute > now.Minute).FirstOrDefault();
i.EndMinute > now.Minute).FirstOrDefault();*/
ElecPriceModelVersionDetail? elecPriceModelVersionDetail = null;
foreach (var VARIABLE in elecPriceModelVersionDetails)
{
// 构造开始和结束的DateTime对象使用当前日期的年月日
DateTime startTime = new DateTime(now.Year, now.Month, now.Day, VARIABLE.StartHour,
VARIABLE.StartMinute, 0);
DateTime endTime = new DateTime(now.Year, now.Month, now.Day, VARIABLE.EndHour, VARIABLE.EndMinute, 0);
if (DateTime.Now >= startTime && DateTime.Now <= endTime)
{
elecPriceModelVersionDetail = VARIABLE;
}
}
if (elecPriceModelVersionDetail == null)
{
Log.Info("lack of effective elecPriceModelVersionDetail");
@ -110,12 +125,12 @@ public class AutoChargeTask : ITask
now.Second >= start[2] && now.Second < end[2];
}).ToList();*/
foreach (var VARIABLE in batteryOpModelDetails)
foreach (var t in batteryOpModelDetails)
{
if (DateTime.Now >= DateTime.Parse(VARIABLE.StartTime) &&
DateTime.Now <= DateTime.Parse(VARIABLE.EndTime))
if (DateTime.Now >= DateTime.Parse(t.StartTime) &&
DateTime.Now <= DateTime.Parse(t.EndTime))
{
opModelDetails.Add(VARIABLE);
opModelDetails.Add(t);
}
}
@ -126,63 +141,70 @@ public class AutoChargeTask : ITask
}
int needBatteryCount = opModelDetails[0].BatteryCount ?? 8;
List<BinInfo> canSwapList = binInfos.Where(it =>
List<BinInfo> canSwapList = allBinInfos.Where(it =>
it.Soc != null && Convert.ToSingle(it.Soc) >= StaticStationInfo.SwapSoc && it.CanSwapFlag == 1)
.ToList();
if (canSwapList.Count == needBatteryCount)
/*if (canSwapList.Count == needBatteryCount)
{
Log.Info($"lack of needBatteryCount {needBatteryCount}");
return;
}
if (canSwapList.Count > needBatteryCount)
{
List<BinInfo> chargingList = binInfos.Where(it => it.ChargeStatus == 1).ToList();
}*/
int needStopCount = chargingList.Count - (canSwapList.Count - needBatteryCount);
if (needStopCount > 0)
{
//停电量低的
chargingList.Sort((a, b) => (a.Soc ?? 0).CompareTo(b.Soc ?? 0));
for (int i = 0; i < needStopCount; i++)
{
Log.Info($"auto stop charge {chargingList[i].No}");
ClientMgr.GetBySn(chargingList[i].No)?.SendRemoteStopCharging();
}
}
}
else
List<BinInfo> chargingList = binInfos.Where(it => it.ChargeStatus == 1).ToList();
Log.Info(
$"chargingList={JsonConvert.SerializeObject(chargingList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
if (canSwapList.Count <= needBatteryCount)
{
List<BinInfo> canChargeList = binInfos.Where(it =>
it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.ChargeSoc &&
it.CanChargeFlag == 1)
it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.SwapSoc &&
it.CanChargeFlag == 1 && it.Exists == 1)
.ToList();
//启动电量高的
canChargeList.Sort((a, b) => (b.Soc ?? 0).CompareTo(a.Soc ?? 0));
byte chargeSoc = StaticStationInfo.ChargeSoc;
int count = needBatteryCount - canSwapList.Count;
Log.Info(
$"need start count={count}, canChargeList={JsonConvert.SerializeObject(canChargeList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
int number = 0;
foreach (var binInfo in canChargeList)
{
float? chargePower = EquipInfoRepository.QueryPowerByCode(binInfo.Code);
float? chargePower = EquipInfoRepository.QueryPowerByCode(binInfo.ChargerNo);
float? power = chargePower == null ? StaticStationInfo.ChargePower : chargePower;
Result<bool>? result = ClientMgr.GetBySn(binInfo.ChargerNo)
?.StartCharge(chargeSoc, (float)power);
if (result is { IsSuccess: true })
{
Log.Info($"auto start charge {binInfo.ChargerNo}");
number++;
}
if (count == number)
if (binInfo.ChargeStatus != 1)
{
Log.Info($"auto start charge count {count}");
break;
//没有充电时候在充电
Result<bool>? result = ClientMgr.GetBySn(binInfo.ChargerNo)
?.StartCharge(chargeSoc, (float)power, 0);
if (result is { IsSuccess: true })
{
Log.Info($"auto start charge {binInfo.ChargerNo}");
number++;
}
if (count == number)
{
Log.Info($"auto start charge count {count}");
break;
}
}
}
}
#region 达到充电SOC自动停
List<BinInfo> stopList = chargingList.Where(it => it.Soc > StaticStationInfo.ChargeSoc).ToList();
Log.Info(
$"need stop count={stopList.Count}, stopList={JsonConvert.SerializeObject(stopList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
foreach (var binInfo in stopList)
{
Log.Info($"auto stop charge {binInfo.No} soc:{binInfo.Soc}");
ClientMgr.GetBySn(binInfo.ChargerNo)?.SendRemoteStopCharging();
}
#endregion
#endregion
}
catch (Exception e)
@ -205,4 +227,4 @@ public class AutoChargeTask : ITask
{
_stop = false;
}
}
}

@ -36,6 +36,11 @@ public class EmeterEnergyRecordTask : ITask
{
List<EmeterEnergy> list = new List<EmeterEnergy>();
List<EmeterEnergyChange> listEmeterEnergyChanges = new List<EmeterEnergyChange>();
DateTime time = DateTime.Now.AddDays(-7);
EmeterEnergyRepository.Delete(i=>i.UploadTime<time);
EmeterEnergyChangeRepository.Delete(i=>i.UploadTime<time);
foreach (var keyValuePair in ClientMgr.Dictionary)
{
var chargerClient = keyValuePair.Value;

@ -0,0 +1,103 @@
using System.Collections.Concurrent;
using Common.Util;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using log4net;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.OutCharger.Req;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Http.Req;
using Service.Init;
namespace Service.Charger.MyTask;
/// <summary>
/// 9.2.1.7 站控上报充电枪充电遥测数据
/// </summary>
[Scope]
public class PileChargeRealtimeTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger(typeof(PileChargeRealtimeTask));
private volatile bool _stop;
public string Name()
{
return "PileChargeRealtimeTask";
}
public int Interval()
{
return 1000 * 30;
}
public void Handle()
{
ConcurrentDictionary<string, ChargerClient> chargerClients = ClientMgr.Dictionary;
if (chargerClients.Values.Count <= 0)
{
return;
}
foreach (var clientPair in chargerClients)
{
ChargerClient client = clientPair.Value;
ProcessClient(client, 1);
ProcessClient(client, 2);
}
}
private void ProcessClient(ChargerClient client, byte gunNumber)
{
if (client.GunCharged[gunNumber])
{
ChargerPile chargerPile = client.ChargerPile[gunNumber];
PileUploadTelemetry telemetry = client.PileUploadTelemetry[gunNumber];
PileUploadRemoteSignal pileUploadRemoteSignal = client.PileUploadRemoteSignal[gunNumber];
PileChargeRealtimeReq req = new PileChargeRealtimeReq
{
sn = StaticStationInfo.StationNo,
con = chargerPile.con,
cosn = chargerPile.cosn,
pn = chargerPile.pn,
rv = telemetry.BmsNeedVoltage,
re = telemetry.BmsNeedCurrent,
cm = telemetry.ChargeMode,
cdv = telemetry.BmsChargingVoltage,
cde = telemetry.BmsChargingCurrent,
soc = telemetry.CurrentSoc,
tr = telemetry.EstimatedRemainingTime,
pov = telemetry.DcMeterVoltage,
poe = telemetry.DcMeterCurrent,
tct = telemetry.ChargingTime,
lbtn = telemetry.MinTempDetectionPointNo,
lbt = telemetry.MinBatteryTemp,
hbtn = telemetry.MaxTempDetectionPointNo,
hbt = telemetry.MaxBatteryTemp,
hlbva = pileUploadRemoteSignal.ChargerInputOverVoltageError ? 1 :
pileUploadRemoteSignal.ChargerInputUnderVoltageError ? 2 : 0,
bia = pileUploadRemoteSignal.InsulationDetectionAlarm ? 1 : 0
};
HttpUtil.SendPostRequest(req, "http://127.0.0.1:5034/api/OutCharger/SendPileChargeRealtime");
}
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}

@ -0,0 +1,100 @@
using System.Collections.Concurrent;
using Common.Util;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using log4net;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.OutCharger.Req;
using Service.Charger.Msg.Http.Req;
using Service.Init;
namespace Service.Charger.MyTask;
/// <summary>
/// 9.2.1.5 站控上报充电枪实时数据上报
/// </summary>
[Scope]
public class PileRealtimeTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger(typeof(PileRealtimeTask));
private volatile bool _stop;
public string Name()
{
return "PileRealtimeTask";
}
public int Interval()
{
return 1000 * 5;
}
public void Handle()
{
ConcurrentDictionary<string, ChargerClient> chargerClients = ClientMgr.Dictionary;
if (chargerClients.Values.Count <= 0)
{
return;
}
foreach (var kvp in chargerClients)
{
ChargerClient client = kvp.Value;
HandleChargerPile(client, 1);
HandleChargerPile(client, 2);
}
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
private void HandleChargerPile(ChargerClient client, byte pileIndex)
{
if (client.ChargedPile[pileIndex])
{
ChargerPile chargerPile = client.ChargerPile[pileIndex];
PileUploadTelemetry pileUploadTelemetry = client.PileUploadTelemetry[pileIndex];
PileRealtimeReq req = new PileRealtimeReq
{
sn = StaticStationInfo.StationNo,
pn = chargerPile.pn,
ps = GetPileStatus(chargerPile.WorkStatus),
pov = pileUploadTelemetry.BmsChargingVoltage,
poe = pileUploadTelemetry.BmsChargingCurrent,
ec = 0
};
HttpUtil.SendPostRequest(req, "http://127.0.0.1:5034/api/OutCharger/SendPileRealtime");
}
}
private int GetPileStatus(int workStatus)
{
return workStatus switch
{
0 => 1,
1 => 3,
2 => 4,
3 => 5,
_ => 1
};
}
}

@ -0,0 +1,32 @@
using Autofac;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Job;
using log4net;
using Repository.System;
namespace Service.Job;
[Scope]
public class TestJob : AbstractCronJob
{
private static readonly ILog Log = LogManager.GetLogger(typeof(TestJob));
private SysConfigRepository SysConfigRepository = AppInfo.Container.Resolve<SysConfigRepository>();
protected override Task Handle()
{
Log.Info("work");
return Task.CompletedTask;
}
protected override string Key()
{
return "test-job";
}
protected override string Cron()
{
return "0/2 * * * * ?";
}
}

@ -0,0 +1,93 @@
using Autofac;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Redis;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Charger.Client;
using Service.Init;
using Service.Swap.Dto;
namespace Service.MyTask;
[Scope]
public class BatteryInfoUploadTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryInfoUploadTask));
private RedisHelper RedisHelper { get; set; } = AppInfo.Container.Resolve<RedisHelper>();
private BinInfoRepository BinInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
private static bool _stop;
public string Name()
{
return nameof(BatteryInfoUploadTask);
}
public int Interval()
{
return 1000 * 1;
}
public void Handle()
{
Log.Info("begin start BatteryInfoUploadTask uoload");
DateTime now = DateTime.Now;
List<BinInfo> binInfos = BinInfoRepository.Query();
List<SingleBatInfo> batInfos = binInfos.Where(it => it.Exists == 1).Select(it =>
{
Log.Info("start BatteryInfoUploadTask uoload bininfo select");
ChargerClient? client = ClientMgr.GetBySn(it.ChargerNo);
SingleBatInfo batInfo = new SingleBatInfo()
{
bn = it.BatteryNo,
bt = now,
sd = it.ChargerNo,
cno = Convert.ToInt32(it.ChargerNo.Substring(1)),
el = 0,
hc = Convert.ToInt32(it.ChargeStatus),
hst=Convert.ToSingle(client?.BatteryPackDataVoltage?.CellTemperatureMax),
hsv = Convert.ToSingle(client?.BatteryPackDataVoltage?.CellVoltageMax),
lst = Convert.ToSingle(client?.BatteryPackDataVoltage?.CellTemperatureMin),
lsv = Convert.ToSingle(client?.BatteryPackDataVoltage?.CellVoltageMin),
soc = Convert.ToSingle(it.Soc),
soe = Convert.ToSingle(it.Soe),
soh = Convert.ToSingle(it.Soh)
};
return batInfo;
}).ToList();
BatDataInfo batDataInfo = new BatDataInfo
{
batn = batInfos.Count,
sn = StaticStationInfo.StationNo,
datainfo = batInfos
};
try
{
Log.Info("start BatteryInfoUploadTask send redis");
RedisHelper.PublishAsync("BatteryInfoUploadTask", JsonConvert.SerializeObject(batDataInfo));
}
catch (Exception e)
{
Log.Info($"BatteryInfoUploadTask send redis error{e}");
}
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}

@ -0,0 +1,9 @@
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
namespace Service.MyTask;
[Scope]
public class ZipLogTask : LogZipTask
{
}

@ -0,0 +1,90 @@
using log4net;
using Microsoft.AspNetCore.SignalR.Client;
using Newtonsoft.Json;
namespace Service.RealTime;
public class RealtimeClient
{
/// <summary>
/// 循环时用的随机数值
/// </summary>
private static UInt16 _cysSeqNum = 0;
/// <summary>
/// 计算循环用UInt16随机数值
/// </summary>
/// <returns></returns>
public static UInt16 GetUInt16SeqNum()
{
if (_cysSeqNum < 65535)
{
_cysSeqNum += 1;
}
else
{
_cysSeqNum = 1;
}
return _cysSeqNum;
}
private static readonly ILog Log = LogManager.GetLogger(typeof(RealtimeClient));
private static readonly JsonSerializerSettings settings = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
DateFormatString = "yyyy-MM-dd HH:mm:ss",
NullValueHandling = NullValueHandling.Ignore
};
private static HubConnection? hubConnection;
public static void Init()
{
hubConnection = new HubConnectionBuilder().WithUrl("http://127.0.0.1:5034/realtime").WithAutomaticReconnect()
.Build();
hubConnection.ServerTimeout = TimeSpan.FromMinutes(1);
hubConnection.KeepAliveInterval = TimeSpan.FromMinutes(1);
hubConnection.StartAsync();
hubConnection.Reconnected += (s) =>
{
Log.Info($"{s} connected");
return Task.CompletedTask;
};
hubConnection.On("ReceiveMsg", (string msg) => { Log.Info($"receive {msg}"); });
}
public static void SendMsg(string msg)
{
hubConnection?.SendAsync("SendMsg", "host", msg);
}
public static void SendWithoutResult(string msg)
{
hubConnection?.SendAsync("InvokeWithoutResult", JsonConvert.SerializeObject(new RtMsg()
{
Id = GetUInt16SeqNum(),
Cmd = "cmd",
Datetime = DateTime.Now,
FromUser = "charger",
Msg = msg
}));
}
public static string? SendWithResult(string msg)
{
var result = hubConnection?.InvokeAsync<RtMsg>("Invoke", new RtMsg()
{
Id = GetUInt16SeqNum(),
Cmd = "cmd",
Datetime = DateTime.Now,
FromUser = "charger",
Msg = msg
}).Result;
Log.Info($"result={result}");
return result.FromUser;
}
}

@ -0,0 +1,11 @@
namespace Service.RealTime;
public class RtMsg
{
public int Id { get; set; }
public string FromUser { get; set; }
public string ToUser { get; set; }
public DateTime Datetime { get; set; }
public string Cmd { get; set; }
public string Msg { get; set; }
}

@ -27,8 +27,11 @@
<PackageReference Include="HslCommunication" Version="11.1.1" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.31" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Quartz" Version="3.8.1" />
<PackageReference Include="Quartz.Serialization.Json" Version="3.8.1" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.115" />
<PackageReference Include="StackExchange.Redis" Version="2.7.33" />
</ItemGroup>
@ -47,4 +50,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Remove="Charger\MyTask\UpBatDataInfoTask.cs" />
</ItemGroup>
</Project>

@ -16,6 +16,7 @@ public class BinInfoService : BaseServices<BinInfo>
public BinInfoService(BinInfoRepository binInfoRepository)
{
_binInfoRepository = binInfoRepository;
this.BaseDal = binInfoRepository;
}
/// <summary>
/// 获取仓位数据

@ -0,0 +1,23 @@
namespace Service.Swap.Dto
{
/// <summary>
/// 4.2.11.1 换电站电池包数据信息
/// </summary>
public class BatDataInfo
{
/// <summary>
/// 场站编码 换电站唯一码
/// </summary>
public string sn { get; set; }
/// <summary>
/// 换电站电池包总 数量
/// </summary>
public int batn { get; set; }
/// <summary>
/// 电池信息
/// </summary>
public List<SingleBatInfo> datainfo { get; set; }
}
}

@ -0,0 +1,84 @@
namespace Service.Swap.Dto;
public class SingleBatInfo
{
/// <summary>
/// 电池序列号
/// </summary>
public string bn { get; set; }
/// <summary>
/// 充电架 ID 按电池架的编号 A1A2…
/// </summary>
public string sd { get; set; }
/// <summary>
/// 所在充电机序号 从 1 开始递增
/// </summary>
public int cno { get; set; }
/// <summary>
/// 是否在充电 0未知 1正在充电 2未电池
/// </summary>
public int hc { get; set; }
/// <summary>
/// 电接头连接状态 0未知 1已经连接 2未连接
/// </summary>
public int el { get; set; }
/// <summary>
/// 剩余能量 单位 0.1 kwh
/// </summary>
public float soe { get; set; }
/// <summary>
/// 当前 SOC 0-100 单位 0.1 ,没有充电填 0
/// </summary>
public float soc { get; set; }
/// <summary>
/// 当前 SOH 0-100 单位 0.1 ,没有充电填 0
/// </summary>
public float soh { get; set; }
/// <summary>
/// 最低单体电压 单位 0.01V
/// </summary>
public float lsv { get; set; }
/// <summary>
/// 最高单体电压 单位 0.01V
/// </summary>
public float hsv { get; set; }
/// <summary>
/// 最低单体温度 单位 0.1℃
/// </summary>
public float lst { get; set; }
/// <summary>
/// 最高单体温度 单位 0.1℃
/// </summary>
public float hst { get; set; }
/// <summary>
/// 单体电池号 从 1 开始递增
/// </summary>
public int sl { get; set; }
/// <summary>
/// 单体电压 每一节电芯的单体电压 单位 0.1V 如果没有该节电芯的数据填65535.0 无效值
/// </summary>
public float sv { get; set; }
/// <summary>
/// 单体温度 每一节电芯的单体温度 单位 0.1℃ ,如果没有该节电芯的数据填65535.0 无效值
/// </summary>
public float st { get; set; }
/// <summary>
/// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary>
public DateTime bt { get; set; }
}

@ -46,7 +46,7 @@ public class WaterCoolClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// <param name="destAddr"></param>
public void SessionAttr(string sn, string destAddr)
{
ChannelUtils.AddAttr(Channel, ChargerConst.WaterCoolSn, sn);
ChannelUtils.AddAttr(Channel, WaterCoolerConst.WaterCoolSn, sn);
ChannelUtils.AddAttr(Channel, ChargerConst.EqmTypeNo, sn);
ChannelUtils.AddAttr(Channel, ChargerConst.EqmCode, sn);
ChannelUtils.AddAttr(Channel, ChargerConst.DestAddr, destAddr);

@ -43,7 +43,7 @@ public class WaterCoolClientMgr
/// <returns></returns>
public static bool TryGetClient(IChannel channel, out string sn, out WaterCoolClient? client)
{
string? snt = ChannelUtils.GetAttr(channel, ChargerConst.WaterCoolSn);
string? snt = ChannelUtils.GetAttr(channel, WaterCoolerConst.WaterCoolSn);
if (!string.IsNullOrWhiteSpace(snt))
{

@ -77,13 +77,14 @@ public class ChargeController : ControllerBase
return Result<bool>.Fail("功率值范围1到360");
}
ChargerClient? chargerClient = ClientMgr.GetBySn(code);
string _code = _binInfoService.QueryByClause(i => i.Code == code).ChargerNo;
ChargerClient? chargerClient = ClientMgr.GetBySn(_code);
if (chargerClient != null)
{
chargerClient.SendPowerRegulation(power);
_equipInfoRepository.Update(i => i.ChargePower == power, it => it.Code == code);
_equipInfoRepository.Update(i => i.ChargePower == power, it => it.Code == _code);
return Result<bool>.Success(true);
}

@ -1,4 +1,5 @@
using HybirdFrameworkCore.Entity;
using Entity.Dto.Resp;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Repository.Station;
using Service.Charger.Client;
@ -32,6 +33,7 @@ public class OutChargerController
[Route("SendStartOutCharger")]
public Result<bool> SendStartOutCharger([FromBody] PileStartChargeHttpReq httpReq)
{
string chargerCode = ChargerUtils.GetOutChargerCode(httpReq.pn);
byte chargerGunCode = ChargerUtils.GetTheGun(httpReq.pn);
@ -92,4 +94,64 @@ public class OutChargerController
return Result<bool>.Success(true);
}
/// <summary>
/// 给充电枪发送功率调节指令
/// </summary>
/// <param name="code">充电机code</param>
/// <param name="pn">1枪 or 2枪</param>
/// <param name="power">功率</param>
/// <returns></returns>
[HttpGet]
[Route("SendPowerRegulation/{code}/{pn}/{power}")]
public Result<bool> SendPowerRegulation(string code,byte pn, float power)
{
if (power <=0 || power > 280)
{
return Result<bool>.Fail("功率值范围1到360");
}
if (pn != 1 && pn != 2)
{
return Result<bool>.Fail("请选择1枪或者2枪");
}
ChargerClient? chargerClient = ClientMgr.GetBySn(code);
if (chargerClient != null)
{
chargerClient.SendPileAdjustPower(pn,power);
return Result<bool>.Success(true);
}
return Result<bool>.Fail("充电机未连接");
}
/// <summary>
/// 获取充电桩信息
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("GetChargerPile")]
public Result<List<ChargerPileResp>> GetChargerPile()
{
var chargerClients = ClientMgr.Dictionary;
if (chargerClients.IsEmpty)
{
return Result<List<ChargerPileResp>>.Fail("没有充电机连接");
}
var list = chargerClients.Values.Select(client => new ChargerPileResp
{
Sn = client.Sn,
GunChargedOne = client.GunCharged[1],
GunChargedTwo = client.GunCharged[2],
ChargedPileOne = client.ChargedPile[1],
ChargedPileTwo = client.ChargedPile[2],
ChargePilePowerOne = client.ChargePilePower[1],
ChargePilePowerTwo = client.ChargePilePower[2]
}).ToList();
return Result<List<ChargerPileResp>>.Success(list);
}
}

@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Repository.Station;
using Service.RealTime;
using SqlSugar;
namespace WebStarter.Controllers.Test;
@ -13,7 +13,7 @@ public class GenController : ControllerBase
public GenController(ISqlSugarClient sqlSugarClient)
{
_sqlSugarClient = sqlSugarClient;
}
/// <summary>
@ -35,8 +35,28 @@ public class GenController : ControllerBase
Console.WriteLine("生成完毕");
}
/// <summary>
/// 测试发送
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
[HttpGet("send/{msg}")]
public string? Send(string msg)
{
return RealtimeClient.SendWithResult(msg);
}
/// <summary>
/// 测试发送
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
[HttpGet("send3/{msg}")]
public void Send3(string msg)
{
RealtimeClient.SendMsg(msg);
}
static string ToPascalCase(string input)
@ -54,4 +74,6 @@ public class GenController : ControllerBase
return res;
}
}
}

@ -4,9 +4,11 @@ using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Configuration;
using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Job;
using HybirdFrameworkCore.Redis;
using log4net;
using Service.Charger.Client;
using Service.RealTime;
using Service.WaterCool.Client;
using SqlSugar;
using SqlSugar.IOC;
@ -22,10 +24,17 @@ builder.Host.ConfigureContainer<ContainerBuilder>(cb =>
var db = new SqlSugarScope(new ConnectionConfig
{
ConfigId = AppSettingsConstVars.ConfigId,
ConnectionString = AppSettingsConstVars.DbSqlConnection, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
ConnectionString = AppSettingsConstVars.DbSqlConnection,
DbType = AppSettingsConstVars.DbDbType == IocDbType.MySql.ToString() ? DbType.MySql : DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute // <20><><EFBFBD>ʹ<EFBFBD><CAB9>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ InitKeyType.Attribute
InitKeyType = InitKeyType.Attribute
}, c =>
{
c.Aop.OnLogExecuting = (sql, pars) =>
{
string nativeSql = UtilMethods.GetNativeSql(sql, pars);
log.Info(nativeSql);
};
});
return db;
}).As<ISqlSugarClient>().InstancePerLifetimeScope();
@ -75,7 +84,6 @@ builder.Services.AddControllers().AddJsonOptions(configure =>
});
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseSwagger();
app.UseSwaggerUI();
@ -97,6 +105,16 @@ AppInfo.Container = app.Services.GetAutofacRoot();
ClientMgr.InitClient();
TaskInit.Init();
QuartzSchedulerFactory.Init();
app.Lifetime.ApplicationStopping.Register(QuartzSchedulerFactory.Shutdown);
bool.TryParse(AppSettingsHelper.GetContent("SignalR", "Enabled"), out var signalrEnabled);
if (signalrEnabled)
{
RealtimeClient.Init();
}
// 水冷连接
WaterCoolClientMgr.InitClient();

@ -15,6 +15,7 @@
<PackageReference Include="Autofac" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Quartz" Version="3.8.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.Text.Json" Version="7.0.4" />
</ItemGroup>

@ -10,7 +10,7 @@
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
"Connection": "192.168.2.2:6379,password=123456",
"Connection": "192.168.2.2:6379,password=dev",
"InstanceName": "local",
"DefaultDB": "8"
},
@ -27,5 +27,13 @@
}
}
},
"Log": {
"Src": "D:\\RiderProjects\\hn_back_charger\\WebStarter\\bin\\Debug\\net6.0\\logs",
"Dest": "D:\\zip",
"Days": 7
},
"Job": {
"Enabled": false
},
"AllowedHosts": "*"
}

@ -27,5 +27,16 @@
}
}
},
"Log": {
"Src": "D:\\RiderProjects\\hn_back_charger\\WebStarter\\bin\\Debug\\net6.0\\logs",
"Dest": "D:\\zip",
"Days": 7
},
"Job": {
"Enabled": false
},
"Task": {
"Disabled": "UploadTelemetryData"
},
"AllowedHosts": "*"
}

@ -0,0 +1,214 @@
/*
Navicat Premium Data Transfer
Source Server : rszn
Source Server Type : MySQL
Source Server Version : 80034 (8.0.34-0ubuntu0.22.04.1)
Source Host : 180.76.133.253:16306
Source Schema : huanneng_dev
Target Server Type : MySQL
Target Server Version : 80034 (8.0.34-0ubuntu0.22.04.1)
File Encoding : 65001
Date: 27/06/2024 17:23:00
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for qrtz_blob_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_blob_triggers`;
CREATE TABLE `qrtz_blob_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`BLOB_DATA` blob NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
INDEX `SCHED_NAME`(`SCHED_NAME` ASC, `TRIGGER_NAME` ASC, `TRIGGER_GROUP` ASC) USING BTREE,
CONSTRAINT `qrtz_blob_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) REFERENCES `qrtz_triggers` (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_calendars
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_calendars`;
CREATE TABLE `qrtz_calendars` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`CALENDAR_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`CALENDAR` blob NOT NULL,
PRIMARY KEY (`SCHED_NAME`, `CALENDAR_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_cron_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_cron_triggers`;
CREATE TABLE `qrtz_cron_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`CRON_EXPRESSION` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TIME_ZONE_ID` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
CONSTRAINT `qrtz_cron_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) REFERENCES `qrtz_triggers` (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_fired_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_fired_triggers`;
CREATE TABLE `qrtz_fired_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`ENTRY_ID` varchar(140) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`INSTANCE_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`FIRED_TIME` bigint NOT NULL,
`SCHED_TIME` bigint NOT NULL,
`PRIORITY` int NOT NULL,
`STATE` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`JOB_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`JOB_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`IS_NONCONCURRENT` tinyint(1) NULL DEFAULT NULL,
`REQUESTS_RECOVERY` tinyint(1) NULL DEFAULT NULL,
PRIMARY KEY (`SCHED_NAME`, `ENTRY_ID`) USING BTREE,
INDEX `IDX_QRTZ_FT_TRIG_INST_NAME`(`SCHED_NAME` ASC, `INSTANCE_NAME` ASC) USING BTREE,
INDEX `IDX_QRTZ_FT_INST_JOB_REQ_RCVRY`(`SCHED_NAME` ASC, `INSTANCE_NAME` ASC, `REQUESTS_RECOVERY` ASC) USING BTREE,
INDEX `IDX_QRTZ_FT_J_G`(`SCHED_NAME` ASC, `JOB_NAME` ASC, `JOB_GROUP` ASC) USING BTREE,
INDEX `IDX_QRTZ_FT_JG`(`SCHED_NAME` ASC, `JOB_GROUP` ASC) USING BTREE,
INDEX `IDX_QRTZ_FT_T_G`(`SCHED_NAME` ASC, `TRIGGER_NAME` ASC, `TRIGGER_GROUP` ASC) USING BTREE,
INDEX `IDX_QRTZ_FT_TG`(`SCHED_NAME` ASC, `TRIGGER_GROUP` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_job_details
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_job_details`;
CREATE TABLE `qrtz_job_details` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`JOB_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`JOB_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`DESCRIPTION` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`JOB_CLASS_NAME` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`IS_DURABLE` tinyint(1) NOT NULL,
`IS_NONCONCURRENT` tinyint(1) NOT NULL,
`IS_UPDATE_DATA` tinyint(1) NOT NULL,
`REQUESTS_RECOVERY` tinyint(1) NOT NULL,
`JOB_DATA` blob NULL,
PRIMARY KEY (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_J_REQ_RECOVERY`(`SCHED_NAME` ASC, `REQUESTS_RECOVERY` ASC) USING BTREE,
INDEX `IDX_QRTZ_J_GRP`(`SCHED_NAME` ASC, `JOB_GROUP` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_locks
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_locks`;
CREATE TABLE `qrtz_locks` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`LOCK_NAME` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
PRIMARY KEY (`SCHED_NAME`, `LOCK_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_paused_trigger_grps
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_paused_trigger_grps`;
CREATE TABLE `qrtz_paused_trigger_grps` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_GROUP`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_scheduler_state
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_scheduler_state`;
CREATE TABLE `qrtz_scheduler_state` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`INSTANCE_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`LAST_CHECKIN_TIME` bigint NOT NULL,
`CHECKIN_INTERVAL` bigint NOT NULL,
PRIMARY KEY (`SCHED_NAME`, `INSTANCE_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_simple_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_simple_triggers`;
CREATE TABLE `qrtz_simple_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`REPEAT_COUNT` bigint NOT NULL,
`REPEAT_INTERVAL` bigint NOT NULL,
`TIMES_TRIGGERED` bigint NOT NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
CONSTRAINT `qrtz_simple_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) REFERENCES `qrtz_triggers` (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_simprop_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_simprop_triggers`;
CREATE TABLE `qrtz_simprop_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`STR_PROP_1` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`STR_PROP_2` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`STR_PROP_3` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`INT_PROP_1` int NULL DEFAULT NULL,
`INT_PROP_2` int NULL DEFAULT NULL,
`LONG_PROP_1` bigint NULL DEFAULT NULL,
`LONG_PROP_2` bigint NULL DEFAULT NULL,
`DEC_PROP_1` decimal(13, 4) NULL DEFAULT NULL,
`DEC_PROP_2` decimal(13, 4) NULL DEFAULT NULL,
`BOOL_PROP_1` tinyint(1) NULL DEFAULT NULL,
`BOOL_PROP_2` tinyint(1) NULL DEFAULT NULL,
`TIME_ZONE_ID` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
CONSTRAINT `qrtz_simprop_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) REFERENCES `qrtz_triggers` (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_triggers`;
CREATE TABLE `qrtz_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`JOB_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`JOB_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`DESCRIPTION` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`NEXT_FIRE_TIME` bigint NULL DEFAULT NULL,
`PREV_FIRE_TIME` bigint NULL DEFAULT NULL,
`PRIORITY` int NULL DEFAULT NULL,
`TRIGGER_STATE` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`TRIGGER_TYPE` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`START_TIME` bigint NOT NULL,
`END_TIME` bigint NULL DEFAULT NULL,
`CALENDAR_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`MISFIRE_INSTR` smallint NULL DEFAULT NULL,
`JOB_DATA` blob NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_T_J`(`SCHED_NAME` ASC, `JOB_NAME` ASC, `JOB_GROUP` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_JG`(`SCHED_NAME` ASC, `JOB_GROUP` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_C`(`SCHED_NAME` ASC, `CALENDAR_NAME` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_G`(`SCHED_NAME` ASC, `TRIGGER_GROUP` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_STATE`(`SCHED_NAME` ASC, `TRIGGER_STATE` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_N_STATE`(`SCHED_NAME` ASC, `TRIGGER_NAME` ASC, `TRIGGER_GROUP` ASC, `TRIGGER_STATE` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_N_G_STATE`(`SCHED_NAME` ASC, `TRIGGER_GROUP` ASC, `TRIGGER_STATE` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_NEXT_FIRE_TIME`(`SCHED_NAME` ASC, `NEXT_FIRE_TIME` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_NFT_ST`(`SCHED_NAME` ASC, `TRIGGER_STATE` ASC, `NEXT_FIRE_TIME` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_NFT_MISFIRE`(`SCHED_NAME` ASC, `MISFIRE_INSTR` ASC, `NEXT_FIRE_TIME` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_NFT_ST_MISFIRE`(`SCHED_NAME` ASC, `MISFIRE_INSTR` ASC, `NEXT_FIRE_TIME` ASC, `TRIGGER_STATE` ASC) USING BTREE,
INDEX `IDX_QRTZ_T_NFT_ST_MISFIRE_GRP`(`SCHED_NAME` ASC, `MISFIRE_INSTR` ASC, `NEXT_FIRE_TIME` ASC, `TRIGGER_GROUP` ASC, `TRIGGER_STATE` ASC) USING BTREE,
CONSTRAINT `qrtz_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) REFERENCES `qrtz_job_details` (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

@ -18,7 +18,7 @@
<!-- 每个文件的大小 -->
<maximumFileSize value="100MB" />
<!-- 保存文件数量 -->
<maxSizeRollBackups value="2" />
<maxSizeRollBackups value="20" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!-- 日志输出格式 -->
<layout type="log4net.Layout.PatternLayout">
@ -26,144 +26,144 @@
</layout>
</appender>
<logger name="Charger1" additivity="true">
<logger name="ChargerC2001" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger1" />
<appender-ref ref="ChargerC2001" />
</logger>
<appender name="Charger1" type="log4net.Appender.RollingFileAppender">
<appender name="ChargerC2001" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger1.log&quot;" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;ChargerC2001.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger2" additivity="true">
<logger name="ChargerC2002" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger2" />
<appender-ref ref="ChargerC2002" />
</logger>
<appender name="Charger2" type="log4net.Appender.RollingFileAppender">
<appender name="ChargerC2002" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger2.log&quot;" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;ChargerC2002.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger3" additivity="true">
<logger name="ChargerC2003" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger3" />
<appender-ref ref="ChargerC2003" />
</logger>
<appender name="Charger3" type="log4net.Appender.RollingFileAppender">
<appender name="ChargerC2003" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger3.log&quot;" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;ChargerC2003.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger4" additivity="true">
<logger name="ChargerC2004" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger4" />
<appender-ref ref="ChargerC2004" />
</logger>
<appender name="Charger4" type="log4net.Appender.RollingFileAppender">
<appender name="ChargerC2004" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger4.log&quot;" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;ChargerC2004.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger5" additivity="true">
<logger name="ChargerC2005" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger5" />
<appender-ref ref="ChargerC2005" />
</logger>
<appender name="Charger5" type="log4net.Appender.RollingFileAppender">
<appender name="ChargerC2005" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger5.log&quot;" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;ChargerC2005.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger6" additivity="true">
<logger name="ChargerC2006" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger6" />
<appender-ref ref="ChargerC2006" />
</logger>
<appender name="Charger6" type="log4net.Appender.RollingFileAppender">
<appender name="ChargerC2006" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger6.log&quot;" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;ChargerC2006.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger7" additivity="true">
<logger name="ChargerC2007" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger7" />
<appender-ref ref="ChargerC2007" />
</logger>
<appender name="Charger7" type="log4net.Appender.RollingFileAppender">
<appender name="ChargerC2007" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger7.log&quot;" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;ChargerC2007.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<logger name="Charger8" additivity="true">
<logger name="ChargerC2008" additivity="false">
<level value="ALL" />
<appender-ref ref="Charger8" />
<appender-ref ref="ChargerC2008" />
</logger>
<appender name="Charger8" type="log4net.Appender.RollingFileAppender">
<appender name="ChargerC2008" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\Charger\" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<Encoding value="UTF-8" />
<param name="StaticLogFileName" value="false" />
<param name="RollingStyle" value="Composite" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;Charger8.log&quot;" />
<param name="DatePattern" value="yyyyMMdd/HH&quot;ChargerC2008.log&quot;" />
<param name="maximumFileSize" value="200MB" />
<param name="MaxSizeRollBackups" value="5" />
<layout type="log4net.Layout.PatternLayout">
@ -172,7 +172,7 @@
</appender>
<root>
<level value="ALL" />
<level value="INFO" />
<appender-ref ref="Console" />
<appender-ref ref="RollingFile" />
</root>

@ -3,6 +3,7 @@
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)system.text.json\7.0.4\buildTransitive\net6.0\System.Text.Json.targets" Condition="Exists('$(NuGetPackageRoot)system.text.json\7.0.4\buildTransitive\net6.0\System.Text.Json.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.apidescription.server\6.0.5\build\Microsoft.Extensions.ApiDescription.Server.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.apidescription.server\6.0.5\build\Microsoft.Extensions.ApiDescription.Server.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.logging.abstractions\6.0.4\buildTransitive\netcoreapp3.1\Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.logging.abstractions\6.0.4\buildTransitive\netcoreapp3.1\Microsoft.Extensions.Logging.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)sqlitepclraw.lib.e_sqlite3\2.1.4\buildTransitive\net6.0\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('$(NuGetPackageRoot)sqlitepclraw.lib.e_sqlite3\2.1.4\buildTransitive\net6.0\SQLitePCLRaw.lib.e_sqlite3.targets')" />
</ImportGroup>
</Project>

@ -2,6 +2,7 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)system.text.json\7.0.0\buildTransitive\net6.0\System.Text.Json.targets" Condition="Exists('$(NuGetPackageRoot)system.text.json\7.0.0\buildTransitive\net6.0\System.Text.Json.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.logging.abstractions\6.0.4\buildTransitive\netcoreapp3.1\Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.logging.abstractions\6.0.4\buildTransitive\netcoreapp3.1\Microsoft.Extensions.Logging.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)sqlitepclraw.lib.e_sqlite3\2.1.4\buildTransitive\net6.0\SQLitePCLRaw.lib.e_sqlite3.targets" Condition="Exists('$(NuGetPackageRoot)sqlitepclraw.lib.e_sqlite3\2.1.4\buildTransitive\net6.0\SQLitePCLRaw.lib.e_sqlite3.targets')" />
</ImportGroup>
</Project>
</Project>

Loading…
Cancel
Save