Merge remote-tracking branch 'origin/master'

# Conflicts:
#	Service/Station/EquipAlarmDefineService.cs
master
CZ 3 months ago
commit 1d2a5be261

@ -0,0 +1,29 @@
namespace Entity.Api.Req;
public class AddEquipAlarmInfoReq
{
/// <summary>
/// 设备类型编码
/// </summary>
public int EquipTypeCode { get; set; }
/// <summary>
/// 设备编码
/// </summary>
public string EquipCode { get; set; }
/// <summary>
/// 报警编码
/// </summary>
public string ErrorCode { get; set; }
/// <summary>
/// 报警等级
/// </summary>
public string ErrorLevel { get; set; }
/// <summary>
/// 报警描述
/// </summary>
public string ErrorMsg { get; set; }
/// <summary>
/// 处理方法
/// </summary>
public string ProcessMethod { get; set; }
}

@ -15,7 +15,7 @@ public class StationParamConst
public static readonly string StationName = "Station.StationName";
/// <summary>
/// 站类型
/// 站类型 01:单仓左 02:单仓右 03:双仓
/// </summary>
public static readonly string StationType = "Station.StationType";
@ -68,7 +68,7 @@ public class StationParamConst
/// <summary>
/// 投放时间
/// </summary>
public static readonly string? LaunchTime = "Station.LaunchTime";
public static readonly string LaunchTime = "Station.LaunchTime";
/// <summary>
/// 联系方式
@ -118,7 +118,7 @@ public class StationParamConst
/// <summary>
/// 总体故障等级
/// </summary>
public static readonly string? Faultlevel = "Station.Faultlevel";
public static readonly string Faultlevel = "Station.Faultlevel";
/// <summary>
/// 加解锁方式
@ -143,17 +143,17 @@ public class StationParamConst
/// <summary>
/// 修改时间
/// </summary>
public static readonly string? ModifyTime = "Station.ModifyTime";
public static readonly string ModifyTime = "Station.ModifyTime";
/// <summary>
/// 配电容量kVA
/// </summary>
public static readonly string? DistributionCapacity = "Station.DistributionCapacity";
public static readonly string DistributionCapacity = "Station.DistributionCapacity";
/// <summary>
/// 总功率kW
/// </summary>
public static readonly string? TotalPower = "Station.TotalPower";
public static readonly string TotalPower = "Station.TotalPower";
/// <summary>
/// 省份
@ -196,16 +196,26 @@ public class StationParamConst
public static readonly string ChargePower = "Station.ChargePower";
public static readonly string AutoChargeEnabled = "Station.AutoChargeEnabled";
//换电收费模型
public static readonly string Eid = "Station.Eid";
//运营模型
//电池运营模型
public static readonly string Oid = "Station.Oid";
//电价模型
public static readonly string Ceid = "Station.Ceid";
/// <summary>
/// 运营状态
/// </summary>
public static readonly string StationStatus = "Station.StationStatus";
/// <summary>
/// 自动换电 手动换电
/// </summary>
public static readonly string StationWay = "Station.StationWay";
/// <summary>
/// 本地换电 远程换电
/// </summary>
public static readonly string StationModel = "Station.StationModel";
#region Tbox

@ -38,6 +38,6 @@ public class BaseModel
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "updated_time", UpdateServerTime = true)]
public DateTime? UpdatedTime { get; set; } = DateTime.Now;
public DateTime UpdatedTime { get; set; } = DateTime.Now;
}

@ -31,12 +31,19 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="version")]
public int Version {get;set;}
/// <summary>
/// Desc:生效时间;生效时间(左开右闭)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_time")]
/// <summary>
/// Desc:云平台版本号;版本号,唯一
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "ceid")]
public string Ceid { get; set; }
/// <summary>
/// Desc:生效时间;生效时间(左开右闭)
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_time")]
public DateTime? StartTime {get;set;}
/// <summary>

@ -82,6 +82,11 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName = "process_time")]
public DateTime? ProcessTime { get; set; }
/// <summary>
/// 上传状态 0未上传 1已上传
/// </summary>
[SugarColumn(ColumnName = "upload_status")]
public int UploadStatus { get; set; }
}
}

@ -76,6 +76,10 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
/// <summary>
/// 上传状态 0未上传 1已上传
/// </summary>
[SugarColumn(ColumnName = "upload_status")]
public int UploadStatus { get; set; }
}
}

@ -68,5 +68,12 @@ namespace Entity.DbModel.Station
/// </summary>
[SugarColumn(ColumnName="charge_power")]
public float? ChargePower { get; set; }
/// <summary>
/// 安装位置编号
/// </summary>
[SugarColumn(ColumnName = "addr")]
public int? Addr { get; set; }
}
}

@ -0,0 +1,23 @@
using SqlSugar;
namespace Entity.DbModel.Station;
/// <summary>
/// 系统运行时故障记录
/// </summary>
[SugarTable("sys_running_falut")]
public class SysRunningFault: BaseModel
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public int Id { get; set; }
/// <summary>
/// 故障描述
/// </summary>
[SugarColumn(ColumnName = "fault_describe")]
public string? FaultDescribe { get; set; }
/// <summary>
/// 故障发生时间
/// </summary>
[SugarColumn(ColumnName = "falust_happen_time")]
public DateTime? FalustHappenTime { get; set; }
}

@ -0,0 +1,16 @@
using System.Linq.Expressions;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using SqlSugar;
namespace Repository.Station;
[Scope("SingleInstance")]
public class SysRunningFaultRepository: BaseRepository<SysRunningFault>
{
public SysRunningFaultRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
}

@ -27,6 +27,7 @@ using Service.Cloud.Msg.Cloud.Resp.OutCharger;
using Service.Cloud.Msg.Host.Req;
using Service.Cloud.Msg.Host.Req.OutCharger;
using Service.Cloud.Msg.Host.Resp;
using Service.Execute.Api;
namespace Service.Cloud.Client;
@ -65,8 +66,16 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
public int Encrypt { get; set; }
public string? AesKey { get; set; }
/// <summary>
/// 签到结果
/// </summary>
public bool Authed { get; set; }
/// <summary>
/// 设备是否上传
/// </summary>
public int EquipmentUpload { get; set; }
#endregion
@ -207,6 +216,22 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
if (result.ResultCode == MqttClientConnectResultCode.Success)
{
Connected = true;
//TODO::鉴权 是否放在这里
CloudApi.SendSignIn();
#region 0823 测试实时故障使用
/*FaultReport faultReport = new()
{
sn = "HNGX0002",
en= "EquipCode",
fc= "ErrorCode",
ft="ErrorMsg",
fl= 1,
fg= 1,
bt= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
cm=2,
};
CloudApi.SendRealTimeFaultInfo(faultReport);*/
#endregion
}
else
{
@ -509,6 +534,8 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
this.Publish(signIn);
return Sign.GetResp(timeSpan);
}
public EqmStateStartLogInfoRes? SendStartLogMessage(EqmStateStartLogInfo eqmStateStartLogInfo,
TimeSpan timeSpan)
{

@ -33,24 +33,31 @@ public class CloudClientMgr
static EmeterDayEnergyService emeterDayEnergyService = AppInfo.Container.Resolve<EmeterDayEnergyService>();
static EmeterHourEnergyService emeterHourEnergyService = AppInfo.Container.Resolve<EmeterHourEnergyService>();
static BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
private static DateTime _dateTime = DateTime.Now.AddSeconds(-30);
private static DateTime _dateTime1 = DateTime.Now.AddSeconds(-30);
private static DateTime _dateTime2 = DateTime.Now.AddSeconds(-10);
private static DateTime _dateTime3 = DateTime.Now.AddSeconds(-10);
private static DateTime _dateTime4 = DateTime.Now.AddSeconds(-10);
private static DateTime _dateTime5 = DateTime.Now.AddMinutes(-15);//15分钟
private static DateTime _dateTime6 = DateTime.Now.AddMinutes(-15);//15分钟
private static DateTime _dateTime7 = DateTime.Today.AddHours(DateTime.Now.Hour-1);//小时
private static DateTime _dateTime8 = DateTime.Now.AddDays(-1).Date;//天
private static DateTime _dateTime8 = DateTime.Now.AddDays(-1).Date.AddHours(2);//天,每天两点
private static DateTime _dateTime9 = DateTime.Today.AddHours(DateTime.Now.Hour - 1);//小时
private static DateTime _dateTime10 = DateTime.Now.AddDays(-1).Date;//天
private static DateTime _dateTime11 = DateTime.Now.AddDays(-1).Date;//天
private static DateTime _dateTime10 = DateTime.Now.AddDays(-1).Date.AddHours(2);//天,每天两点
private static DateTime _dateTime11 = DateTime.Now.AddDays(-1).Date.AddHours(2);//天,每天两点
private static DateTime _dateTime12 = DateTime.Now.AddSeconds(-30);
private static DateTime _dateTime13 = DateTime.Now.AddSeconds(-30);
private static DateTime _dateTime14 = DateTime.Now.AddSeconds(-30);
private const int TimeSpan = 5;
private static ChargeDevDataInfo req = new ChargeDevDataInfo();
public static async void Init()
{
@ -69,62 +76,89 @@ public class CloudClientMgr
CloudClient.AutoReConnect = true;
CloudClient.InitHandler();
var ddddd = CloudClient.Connected;
Task.Run(() => CloudClient.Connect());
RedisHelper? redisHelper = AppInfo.Container.Resolve<RedisHelper>();
BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
#region 遥测合并上报
req.datainfo = new List<DataInfo>();
redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) =>
{
try
{
Log.Info($"receive UploadTelemetryData={value}");
if (value.HasValue)
{
UploadTelemetryData? data = JsonConvert.DeserializeObject<UploadTelemetryData>(value.ToString());
if (data != null)
{
BinInfo? binInfo = binInfoRepository.QueryByClause(it => it.ChargerNo == data.ChargerNo);
ChargeDevDataInfo req = new ChargeDevDataInfo();
//ChargeDevDataInfo req = new ChargeDevDataInfo();
req.sn = StaticStationInfo.StationNo;
req.en = StaticStationInfo.StationNo + data.ChargerNo;
req.sd = "A" + int.Parse(binInfo.No);
req.mtp = StaticStationInfo.ChargePower;
req.mcr = 1;
req.hb = binInfo?.Exists ?? 0;
req.el = 0;
req.cno = int.Parse(binInfo.No);
req.cs = binInfo.ChargeStatus ?? 0;
req.fs = 0;
req.@as = 0;
//fc = data.,
//st = data.,
req.ct = data.ChargingTime;
//ssoc = data.,
req.csoc = data.CurrentSoc;
//ssoe = data.,
//csoe = data.,
req.cvot = data.BmsChargingVoltage;
req.ccur = data.BmsChargingCurrent;
req.nvot = data.BmsNeedVoltage;
req.ncur = data.BmsNeedCurrent;
req.lsv = data.SingleBatteryMinVoltage;
req.hsv = data.SingleBatteryMaxVoltage;
req.lst = data.MinBatteryTemp;
req.hst = data.MaxBatteryTemp;
req.ws = 0xFF;
req.it = 0xFF;
req.ot = 0xFF;
req.bt = DateTime.Now;
DataInfo dataInfo = new DataInfo();
dataInfo.en = StaticStationInfo.StationNo + data.ChargerNo;
var areNotEqual = !dataInfo.en.Equals(
req.datainfo.Select(d => d.en)
.ToList()
.Any(x => x == dataInfo.en));
if (areNotEqual)//如果没有重复的
{
dataInfo.sd = "A" + int.Parse(binInfo.No);
dataInfo.mtp = StaticStationInfo.ChargePower;
dataInfo.mcr = 1;
dataInfo.hb = binInfo?.Exists ?? 0;
dataInfo.el = 0;
dataInfo.cno = int.Parse(binInfo.No);
dataInfo.cs = binInfo.ChargeStatus ?? 0;
dataInfo.fs = 0;
dataInfo.@as = 0;
//fc = data.,
//st = data.,
dataInfo.ct = data.ChargingTime;
//ssoc = data.,
dataInfo.csoc = data.CurrentSoc;
//ssoe = data.,
//csoe = data.,
dataInfo.cvot = data.BmsChargingVoltage;
dataInfo.ccur = data.BmsChargingCurrent;
dataInfo.nvot = data.BmsNeedVoltage;
dataInfo.ncur = data.BmsNeedCurrent;
dataInfo.lsv = data.SingleBatteryMinVoltage;
dataInfo.hsv = data.SingleBatteryMaxVoltage;
dataInfo.lst = data.MinBatteryTemp;
dataInfo.hst = data.MaxBatteryTemp;
dataInfo.ws = 0xFF;
dataInfo.it = 0xFF;
dataInfo.ot = 0xFF;
dataInfo.bt = DateTime.Now;
if (req.datainfo.Count < 7)
{
req.datainfo.Add(dataInfo);
}
}
if ((DateTime.Now - _dateTime).TotalSeconds <= 30)
{
return;
}
_dateTime = DateTime.Now;
CloudClient?.SendChargeDevDataInfo(req);
if (req.datainfo.Count > 0)
{
CloudClient?.SendChargeDevDataInfo(req);
req = new ChargeDevDataInfo();
req.datainfo = new List<DataInfo>();
}
Log.Info($"receive UploadTelemetryData={value}");
}
}
}
@ -133,7 +167,9 @@ public class CloudClientMgr
Log.Info("error", e);
}
});
#endregion
redisHelper?.GetSubscriber().Subscribe("BatteryInfoUploadTask", (channel, value) =>
{
try
@ -144,6 +180,11 @@ public class CloudClientMgr
BatDataInfo? data = JsonConvert.DeserializeObject<BatDataInfo>(value.ToString());
if (data != null)
{
if ((DateTime.Now - _dateTime1).TotalSeconds <= 30)
{
return;
}
_dateTime1 = DateTime.Now;
CloudClient?.SendBatDataInfo(data);
}
}
@ -154,15 +195,13 @@ public class CloudClientMgr
}
});
StartAsyncLoop();
StartAsyncLoop();
}
private static async Task StartAsyncLoop()
{
await Task.Run(() =>
@ -173,30 +212,44 @@ public class CloudClientMgr
{
if (CloudClient.Connected)
{
//Log.Info("测试111111111111111111111111111111111111111111111111111111111111111111111111111111");
CloudApi.SendStateLog(0);
//if (StationConstant.StationModel.Remote == BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
//StaticStationInfo.StationModel))
//{
// CloudApi.SendStateLog();
//}
TaskHostStatusReported();
TaskAirConditioningData();
//TaskAirConditioningData();
//TaskTemperatureHumidityData();
//TaskPowerTotal();
//TaskStaChargingTota();
//TaskMeterEnergyKwh();
//TaskMeterDayEnergyVal();
TaskTemperatureHumidityData();
//TaskStaHourEnergyVal();
TaskPowerTotal();
//TaskStaDayEnergyVal();
TaskStaChargingTota();
//TaskStaDayOpeEnergyVal();
TaskMeterEnergyKwh();
////TaskStaHourAmountVal();
TaskMeterDayEnergyVal();
TaskStaHourEnergyVal();
//SendRealTimeFaultInfo();
TaskStaDayEnergyVal();
//SendStartLogMessage();
TaskStaDayOpeEnergyVal();
//SendBatteryTotal();
TaskStaHourAmountVal();
//SendChargingTotalDis();
}
Thread.Sleep(1000);
}
@ -225,14 +278,15 @@ public class CloudClientMgr
}
_dateTime2 = DateTime.Now;
EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
var EquipAlarm = equipAlarmRecordRepository.Query();
var ErrorLevel = Convert.ToInt32(EquipAlarm.Min(x => x.ErrorLevel));
//EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
//var EquipAlarm = equipAlarmRecordRepository.Query();
//var ErrorLevel = Convert.ToInt32(EquipAlarm.Min(x => x.ErrorLevel));
StationRunStatus stationRunStatus = new()
{
rs = StaticStationInfo.StationStatus == 1 ? 1 : 2,
rs = StaticStationInfo.Sevstatus,
os = StaticStationInfo.StationStatus,
fl = ErrorLevel,
fl =Convert.ToInt32( StaticStationInfo.Faultlevel),
};
@ -275,7 +329,7 @@ public class CloudClientMgr
/// </summary>
private static void TaskTemperatureHumidityData()
{
if ((DateTime.Now - _dateTime4).TotalSeconds <= 10)
if ((DateTime.Now - _dateTime4).TotalSeconds <= 30)
{
return;
}
@ -299,7 +353,7 @@ public class CloudClientMgr
/// <summary>
/// 电能表累计值信息 15m
/// </summary>
private static void TaskPowerTotal()//Desc记得改回来
private static void TaskPowerTotal()
{
if ((DateTime.Now - _dateTime5).TotalMinutes <= 15)
{
@ -325,7 +379,7 @@ public class CloudClientMgr
};
powerTotal.meter = new List<meter>();
for (int i = 0; i < 7; i++)
for (int i = 0; i < emeterEnergy.Count; i++)
{
meter meter = new()
{
@ -336,7 +390,7 @@ public class CloudClientMgr
};
powerTotal.meter.Add(meter);
}
for (int i = 0;i < 7; i++)
for (int i = 0; i < emeterEnergyChange.Count; i++)
{
meter meter = new()
{
@ -347,7 +401,8 @@ public class CloudClientMgr
};
powerTotal.meter.Add(meter);
}
CloudApi.SendPowerTotal(powerTotal);
@ -383,7 +438,8 @@ public class CloudClientMgr
};
staChargingTotal.meter = new List<meter2>();
for (int i = 0; i < 7; i++)
for (int i = 0; i < emeterEnergy.Count; i++)
{
meter2 meter = new()
{
@ -396,7 +452,7 @@ public class CloudClientMgr
};
staChargingTotal.meter.Add(meter);
}
for (int i = 0; i < 7; i++)
for (int i = 0; i < emeterEnergyChange.Count; i++)
{
meter2 meter = new()
{
@ -424,7 +480,7 @@ public class CloudClientMgr
return;
}
_dateTime7 = DateTime.Now;
_dateTime7 = DateTime.Today.AddHours(DateTime.Now.Hour);
var emeterEnergy = emeterHourEnergyService.QueryListByClause(u => u.UploadFlag == 0, 14, i => i.Time,
OrderByType.Desc);
@ -440,7 +496,7 @@ public class CloudClientMgr
};
meterEnergyKwh.meter = new List<meter2>();
for (int i = 0; i < 7; i++)
for (int i = 0; i < emeterEnergy1.Count; i++)
{
meter2 meter = new()
{
@ -455,7 +511,7 @@ public class CloudClientMgr
};
meterEnergyKwh.meter.Add(meter);
}
for (int i = 0; i < 7; i++)
for (int i = 0; i < emeterEnergy2.Count; i++)
{
meter2 meter = new()
{
@ -465,8 +521,8 @@ public class CloudClientMgr
mk = emeterEnergy2[i].Value,
//st = DateTime.Now.AddMinutes(-15),
//et = DateTime.Now,
st = Convert.ToDateTime(emeterEnergy1[i].Time),
et = Convert.ToDateTime(emeterEnergy1[i].Time).AddHours(1),
st = Convert.ToDateTime(emeterEnergy2[i].Time),
et = Convert.ToDateTime(emeterEnergy2[i].Time).AddHours(1),
};
meterEnergyKwh.meter.Add(meter);
}
@ -489,7 +545,7 @@ public class CloudClientMgr
{
return;
}
_dateTime8 = DateTime.Now;
_dateTime8 = DateTime.Now.Date.AddHours(2);
EmeterDayEnergyService emeterDayEnergyService = AppInfo.Container.Resolve<EmeterDayEnergyService>();
@ -507,7 +563,7 @@ public class CloudClientMgr
};
meterEnergyKwh.meter = new List<meter2>();
for (int i = 0; i < 7; i++)
for (int i = 0; i < emeterEnergy1.Count; i++)
{
meter2 meter = new()
{
@ -522,7 +578,7 @@ public class CloudClientMgr
};
meterEnergyKwh.meter.Add(meter);
}
for (int i = 0; i < 7; i++)
for (int i = 0; i < emeterEnergy2.Count; i++)
{
meter2 meter = new()
{
@ -532,8 +588,8 @@ public class CloudClientMgr
mk = emeterEnergy2[i].Value,
//st = DateTime.Now.AddDays(-1),
//et = DateTime.Now,
st = Convert.ToDateTime(emeterEnergy1[i].Time).AddDays(-1),
et = Convert.ToDateTime(emeterEnergy1[i].Time),
st = Convert.ToDateTime(emeterEnergy2[i].Time).AddDays(-1),
et = Convert.ToDateTime(emeterEnergy2[i].Time),
};
meterEnergyKwh.meter.Add(meter);
@ -558,7 +614,7 @@ public class CloudClientMgr
{
return;
}
_dateTime9 = DateTime.Now;
_dateTime9 = DateTime.Today.AddHours(DateTime.Now.Hour);
var emeterEnergy = emeterHourEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
OrderByType.Desc);
@ -591,7 +647,7 @@ public class CloudClientMgr
{
return;
}
_dateTime10 = DateTime.Now;
_dateTime10 = DateTime.Now.Date.AddHours(2);
var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
OrderByType.Desc);
@ -626,76 +682,303 @@ public class CloudClientMgr
{
return;
}
_dateTime11 = DateTime.Now;
_dateTime11 = DateTime.Now.Date.AddHours(2);
ExStationDayRunResultService exStationDayRunResultService = AppInfo.Container.Resolve<ExStationDayRunResultService>();
var exStationDayRunResult = exStationDayRunResultService.QueryByClause(u => u.Id !=0, i => i.CreatedTime,
OrderByType.Desc);
if (exStationDayRunResult!=null)
{
StaDayOpeEnergyVal staDayOpeEnergyVal = new()
{
sn = StaticStationInfo.StationNo,
sm = StaticStationInfo.StationName,
st = Convert.ToDateTime(exStationDayRunResult?.RunStartTime),
et = Convert.ToDateTime(exStationDayRunResult?.RunEndTime),
tt = Convert.ToInt32(exStationDayRunResult?.ToltalTimeCount),
ft = exStationDayRunResult?.FristSwapTime,
sp = exStationDayRunResult?.StopTime,
ts = Convert.ToSingle(exStationDayRunResult?.ToltalSwapAllTime * 60),
tc = Convert.ToInt32(exStationDayRunResult?.ToltalSwapCount),
cc = Convert.ToInt32(exStationDayRunResult?.ChgCount),
os = Convert.ToByte(exStationDayRunResult?.State),
at = Convert.ToSingle(exStationDayRunResult?.AvgRepTime),
ct = Convert.ToSingle(exStationDayRunResult?.AvgChgTime),
dt = Convert.ToDateTime(exStationDayRunResult?.SwapDate),
};
CloudApi.SendStaDayOpeEnergyVal(staDayOpeEnergyVal);
}
}
/// <summary>
/// 换电站分时用电统计信息(站控不计价,这一帧不要)
/// </summary>
private static void TaskStaHourAmountVal()
{
//if ((DateTime.Now - _dateTime2).TotalSeconds <= 30)
//{
// return;
//}
//_dateTime2 = DateTime.Now;
//var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
// OrderByType.Desc);
//float hc = emeterEnergy.Sum(e => e.Value);
//ElecPriceModelVersionDetailServices elecPriceModelVersionDetailServices = AppInfo.Container.Resolve<ElecPriceModelVersionDetailServices>();
//var elecPriceModelVersionDetail= elecPriceModelVersionDetailServices.QueryListByClause(u=>u.Version==1);
//var timeList = elecPriceModelVersionDetail.Select(u => u.StartHour).ToList();
//int targetTime = DateTime.Now.Hour;
//int index1 = timeList.FindIndex(time => time > targetTime)-1;
//index1 = index1<0? timeList.Count-1: index1;
//int index2 = timeList.FindIndex(time => time == targetTime);
//int index3 = index2 == -1 ? index1 : index2;
//var price = elecPriceModelVersionDetail[index3].Price;
//StaHourAmountVal staHourAmountVal = new()
//{
// sn = StaticStationInfo.StationNo,
// ht = Convert.ToSingle(hc * price),
// hc = Convert.ToSingle(hc * price),
// hs = 0,
// ho = 0,
// //st = DateTime.Now.AddHours(-1),
// //et = DateTime.Now,
// st = Convert.ToDateTime(emeterEnergy?.First().Time),
// et = Convert.ToDateTime(emeterEnergy?.First().Time).AddHours(1),
//};
//CloudApi.SendStaHourAmountVal(staHourAmountVal);
StaDayOpeEnergyVal staDayOpeEnergyVal = new()
}
/// <summary>
/// 换电站上报设备列表
/// </summary>
public static void SendDevList(int ot)
{
EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>();
var equipList = equipInfoRepository.Query();
DevList devList = new()
{
ot = ot,
sn = StaticStationInfo.StationNo,
sm = StaticStationInfo.StationName,
st = Convert.ToDateTime(exStationDayRunResult?.RunStartTime),
et = Convert.ToDateTime(exStationDayRunResult?.RunEndTime),
tt = Convert.ToInt32(exStationDayRunResult?.ToltalTimeCount),
//tt = 24 * 60,
ft = Convert.ToDateTime(exStationDayRunResult?.FristSwapTime),
sp = Convert.ToDateTime(exStationDayRunResult?.StopTime),
ts = Convert.ToSingle(exStationDayRunResult?.ToltalSwapAllTime * 60),
tc = exStationDayRunResult.ToltalSwapCount,
cc = exStationDayRunResult.ChgCount,
os = Convert.ToByte(exStationDayRunResult.State),
at = Convert.ToSingle(exStationDayRunResult?.AvgRepTime),
ct = Convert.ToSingle(exStationDayRunResult?.AvgChgTime),
dt = Convert.ToDateTime(exStationDayRunResult?.SwapDate),
vs = "1.0",
};
devList.d_info = new List<D_INFO>();
for (int i = 0; i < equipList.Count; i++)
{
D_INFO d_INFO = new D_INFO();
d_INFO.dn = (equipList[i].TypeCode==0?"充电机":"电表")+ equipList[i].Code;
d_INFO.dt = equipList[i].TypeCode == 0 ? "充电机" : "电表";
d_INFO.dc = equipList[i].TypeCode.ToString();
d_INFO.tc = equipList[i].Status.ToString();
d_INFO.ds = equipList[i].Id.ToString();
d_INFO.sn = equipList[i].Code;
d_INFO.en = "";
d_INFO.hv = "";
d_INFO.sv = "";
d_INFO.mn = "";
d_INFO.ns = equipList[i].Addr.ToString();
d_INFO.ti = equipList[i].CreatedTime.ToString();
devList.d_info.Add(d_INFO);
}
CloudApi.SendStaDayOpeEnergyVal(staDayOpeEnergyVal);
CloudApi.SendDevList(devList);
}
/// <summary>
/// 换电站分时用电统计信息
/// 实时故障信息上传
/// </summary>
private static void TaskStaHourAmountVal()
public static void SendRealTimeFaultInfo()
{
EquipAlarmRecordRepository equipAlarmRecordRepository = AppInfo.Container.Resolve<EquipAlarmRecordRepository>();
var AlarmList = equipAlarmRecordRepository.QueryListByClause(u => u.UploadStatus == 0);
EquipAlarmProcessRecordRepository equipAlarmProcessRecordRepository = AppInfo.Container.Resolve<EquipAlarmProcessRecordRepository>();
var AlarmProcessList = equipAlarmProcessRecordRepository.QueryListByClause(u => u.UploadStatus == 0);
//产生上传
for (int i = 0; i < AlarmList.Count; i++)
{
FaultReport faultReport = new()
{
sn = StaticStationInfo.StationNo,
en= AlarmList[i].EquipCode,
fc= AlarmList[i].ErrorCode,
ft= AlarmList[i].ErrorMsg,
fl= Convert.ToInt32( AlarmList[i].ErrorLevel),
fg= 1,
bt= AlarmList[i].StartTime.ToString(),
cm=1,
};
CloudApi.SendRealTimeFaultInfo(faultReport);
Thread.Sleep(500);
}
//消失上传
for (int i = 0; i < AlarmProcessList.Count; i++)
{
FaultReport faultReport = new()
{
sn = StaticStationInfo.StationNo,
en = AlarmProcessList[i].EquipCode,
fc = AlarmProcessList[i].ErrorCode,
ft = AlarmProcessList[i].ErrorMsg,
fl = Convert.ToInt32(AlarmProcessList[i].ErrorLevel),
fg = 2,
bt = AlarmProcessList[i].ProcessTime.ToString(),
cm = 1,
};
CloudApi.SendRealTimeFaultInfo(faultReport);
Thread.Sleep(500);
}
}
static List<EquipInfo> equipInfos;
static bool variation = false;
/// <summary>
/// 换电站设备状态开始和结束日志信息
/// </summary>
public static void SendStartLogMessage()
{
if ((DateTime.Now - _dateTime2).TotalSeconds <= 30)
if ((DateTime.Now - _dateTime12).TotalSeconds <= 30)
{
return;
}
_dateTime2 = DateTime.Now;
_dateTime12 = DateTime.Now;
var emeterEnergy = emeterDayEnergyService.QueryListByClause(u => u.Type == 1, 7, i => i.Time,
OrderByType.Desc);
float hc = emeterEnergy.Sum(e => e.Value);
EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>();
var equipList = equipInfoRepository.Query();
if (equipInfos == null) { equipInfos = equipList; }
ElecPriceModelVersionDetailServices elecPriceModelVersionDetailServices = AppInfo.Container.Resolve<ElecPriceModelVersionDetailServices>();
if (variation)
{
for (int i = 0; i < equipList.Count; i++)
{
if (equipInfos[i].UpdatedTime != equipList[i].UpdatedTime)
{
EqmStateEndLogInfo req = new()
{
en = StaticStationInfo.StationNo + equipInfos[i].Code,
sv = Convert.ToByte(equipInfos[i].Status),
sm = equipInfos[i].Status == 1 ? "启用" : "停用",
st = equipInfos[i].UpdatedTime,
et = equipList[i].UpdatedTime,
ke= (int)(equipList[i].UpdatedTime- equipInfos[i].UpdatedTime).TotalSeconds,
cm = 1,
};
CloudApi.SendEndLogMessage(req);
variation = false;
}
}
}
for (int i = 0; i < equipList.Count; i++)
{
if (equipInfos[i].UpdatedTime != equipList[i].UpdatedTime)
{
EqmStateStartLogInfo req = new()
{
en = StaticStationInfo.StationNo + equipInfos[i].Code,
SV = Convert.ToByte(equipInfos[i].Status),
sm = equipInfos[i].Status == 1 ? "启用": "停用" ,
st = equipList[i].UpdatedTime,
cm = 1,
};
CloudApi.SendStartLogMessage(req);
variation= true;
}
var elecPriceModelVersionDetail= elecPriceModelVersionDetailServices.QueryListByClause(u=>u.Version==1);
var timeList = elecPriceModelVersionDetail.Select(u => u.StartHour).ToList();
int targetTime = DateTime.Now.Hour;
int index1 = timeList.FindIndex(time => time > targetTime)-1;
index1 = index1<0? timeList.Count-1: index1;
int index2 = timeList.FindIndex(time => time == targetTime);
int index3 = index2 == -1 ? index1 : index2;
}
var price = elecPriceModelVersionDetail[index3].Price;
StaHourAmountVal staHourAmountVal = new()
equipInfos = equipList;
}
/// <summary>
/// 换电站上报电池状态分布统计信息 2分钟
/// </summary>
public static void SendBatteryTotal()
{
if ((DateTime.Now - _dateTime13).TotalMinutes <= 2)
{
sn = StaticStationInfo.StationNo,
ht = Convert.ToSingle(hc * price),
hc = Convert.ToSingle(hc * price),
hs = 0,
ho = 0,
//st = DateTime.Now.AddHours(-1),
//et = DateTime.Now,
st = Convert.ToDateTime(emeterEnergy?.First().Time),
et = Convert.ToDateTime(emeterEnergy?.First().Time).AddHours(1),
return;
}
_dateTime13 = DateTime.Now;
var binList = binInfoRepository.Query();
int bt = binList.Select(u => u.Exists == 1).Count();
int ct = binList.Select(u => u.Soc >= StaticStationInfo.SwapSoc).Count();
int cc = binList.Select(u => u.ChargeStatus ==1).Count();
int ca = binList.Select(u => u.Soc < StaticStationInfo.SwapSoc).Count();
BatteryTotal devList = new()
{
sn= StaticStationInfo.StationNo,
btc=1,
sm="99999999",
bn="默认型号",
bc= bt,
ct= ct,
cc=cc,
ca=ca,
ut=DateTime.Now,
};
CloudApi.SendBatteryTotal(devList);
}
/// <summary>
/// 换电站充电电池电量分布统计信息 2分钟
/// </summary>
public static void SendChargingTotalDis()
{
if ((DateTime.Now - _dateTime14).TotalMinutes <= 2)
{
return;
}
_dateTime14 = DateTime.Now;
var binList = binInfoRepository.Query();
int hc = binList.Select(u => u.Soc >= 90).Count();
int mc = binList.Select(u => u.Soc >= 80&& u.Soc<90).Count();
int lc = binList.Select(u => u.Soc >= 0&& u.Soc<80).Count();
ChargingTotalDis req = new()
{
sn = StaticStationInfo.StationNo,
bs = "99999999",
bn = "默认型号",
hc = hc,
mc = mc,
lc = lc,
};
CloudApi.SendStaHourAmountVal(staHourAmountVal);
CloudApi.SendChargingTotalDis(req);
}
}

@ -24,8 +24,24 @@ public class DeliverBasicInformationHandler : IBaseHandler
StaticStationInfo.StationNo = deliverBasicInformation.sn;
StaticStationInfo.StationName = deliverBasicInformation.Sm;
StaticStationInfo.StationSn = deliverBasicInformation.SS;
//TODO 补全StaticStationInfo后赋值
StaticStationInfo.StationLocation = deliverBasicInformation.sl;
StaticStationInfo.StationType = deliverBasicInformation.st;
StaticStationInfo.Longitude = deliverBasicInformation.ld;
StaticStationInfo.Latitude = deliverBasicInformation.lt;
StaticStationInfo.AreaCode = deliverBasicInformation.ac;
StaticStationInfo.AreaName = deliverBasicInformation.am;
StaticStationInfo.OperationStartTime = deliverBasicInformation.ot.ToString();
StaticStationInfo.LaunchTime = deliverBasicInformation.lm.ToString();
StaticStationInfo.ContactWay = deliverBasicInformation.cw;
StaticStationInfo.Principal = deliverBasicInformation.pp;
StaticStationInfo.StationCompany = deliverBasicInformation.sc;
StaticStationInfo.SocialCreditCode = deliverBasicInformation.cc;
StaticStationInfo.StationSftVer = deliverBasicInformation.sv;
StaticStationInfo.SupplierCode = deliverBasicInformation.sp;
StaticStationInfo.Cover = deliverBasicInformation.cb.ToString();
StaticStationInfo.StationVersion = deliverBasicInformation.bs;
SetStBaseInfoRes resp = new SetStBaseInfoRes();
CloudClientMgr.CloudClient?.Publish(resp);
}

@ -0,0 +1,83 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Repository.Station;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Host.Resp;
namespace Service.Cloud.Handler;
[Scope]
public class ElectricityPriceModelHandler : IBaseHandler
{
private ElecPriceModelVersionRepository _versionRepository;
private ElecPriceModelVersionDetailRepository _detailRepository;
public ElectricityPriceModelHandler(ElecPriceModelVersionRepository elecPriceModelVersionRepository,
ElecPriceModelVersionDetailRepository elecPriceModelVersionDetailRepository)
{
this._versionRepository = elecPriceModelVersionRepository;
this._detailRepository = elecPriceModelVersionDetailRepository;
}
//两个电价帧用这个,另一个不用
public bool CanHandle(string cmd)
{
return CloudConst.setStaPrice == cmd;
}
public void Handle(string t)
{
SetStaPrice? priceModel = JsonConvert.DeserializeObject<SetStaPrice>(t);
if (priceModel != null)
{
if (priceModel.priceTemp.Count>0)
{
ElecPriceModelVersion version = _versionRepository.QueryByClause(d => d.Ceid == priceModel.priceTemp[0].ceid);
if (version == null)
{
var version01 = _versionRepository.QueryListByClause(d => d.Ceid != null, 1, "desc");
version = new ElecPriceModelVersion
{
Version = version01 == null ? 1:version01[0].Version + 1,
Ceid = priceModel.priceTemp[0].ceid,
};
}
version.StartTime = DateTime.Now;
version.EndTime = DateTime.Now.AddYears(10);
_versionRepository.InsertOrUpdate(version);
List<PriceTemp>? segs = priceModel.priceTemp;
if (segs is { Count: > 0 })
{
List<ElecPriceModelVersionDetail> versionDetails = segs.Select(d => new ElecPriceModelVersionDetail()
{
Version = version.Version,
Price = (int)d.ep,//* 10000
Type = d.pr,
StartHour = d.st.Hour,
StartMinute = d.st.Minute,
StartSecond = d.st.Second,
EndHour = d.et.Hour,
EndMinute = d.et.Minute,
EndSecond = d.et.Second
}).ToList();
//先删除同模型ID的数据
_detailRepository.Delete(u=>u.Version== version.Version);
_detailRepository.Insert(versionDetails);
}
}
SetStaPriceRes resp = new SetStaPriceRes();
CloudClientMgr.CloudClient?.Publish(resp);
}
}
}

@ -0,0 +1,53 @@
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Resp;
using System.Drawing;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class FaultReportResHandler : IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(FaultReportResHandler));
public EquipAlarmRecordRepository equipAlarmRecordRepository { get; set; }
EquipAlarmProcessRecordRepository equipAlarmProcessRecordRepository { get; set; }
public void Handle(string t)
{
FaultReportRes? resp = JsonConvert.DeserializeObject<FaultReportRes>(t);
if (resp != null)
{
if (CloudClientMgr.CloudClient != null)
{
CloudClientMgr.CloudClient.RealTimeFault.SetResp(resp);
string? reqFc = CloudClientMgr.CloudClient.RealTimeFault.Req?.fc;
int? reqFg = CloudClientMgr.CloudClient.RealTimeFault.Req?.fg;
Log.Info($"receive FaultReportRes fc={reqFc} {JsonConvert.SerializeObject(resp)}");
if (!string.IsNullOrWhiteSpace(reqFc) && resp.re == 0)
{
if (reqFg == 1)
{
equipAlarmRecordRepository.Update(it => it.UploadStatus == 1, it => it.ErrorCode == reqFc);
}
else
{
equipAlarmProcessRecordRepository.Update(it => it.UploadStatus == 1, it => it.ErrorCode == reqFc);
}
}
}
}
}
public bool CanHandle(string cmd)
{
return CloudConst.faultReportRes == cmd;
}
}

@ -22,7 +22,8 @@ public class ServiceableStateHandler:IBaseHandler
SetService? req = JsonConvert.DeserializeObject<SetService>(t);
if (req != null)
{
StaticStationInfo.StationStatus = req.st;
StaticStationInfo.Sevstatus = req.st;
SetServiceRes resp = new SetServiceRes();
CloudClientMgr.CloudClient?.Publish(resp);
}

@ -1,4 +1,7 @@
using HybirdFrameworkCore.Autofac.Attribute;
using Autofac;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Service.Cloud.Client;
using Service.Cloud.Common;
@ -16,6 +19,13 @@ public class SignInRespHandler : IBaseHandler
if (signInResp != null)
{
CloudClientMgr.CloudClient.Authed = signInResp.re == 0;
CloudClientMgr.CloudClient.EquipmentUpload = signInResp.dl_up;
if (CloudClientMgr.CloudClient.EquipmentUpload != 0)
{
//上传设备列表
CloudClientMgr.SendDevList(1);
}
}
}

@ -12,36 +12,50 @@ namespace Service.Cloud.Msg.Cloud.Req
/// </summary>
public class SetStaPrice : ICmd
{
/// <summary>
/// 计费模型ID
/// 唯一的计费 id由服务器统一进行分配
/// </summary>
public int eid { get; set; }
/// <summary>
/// 更新时间
/// 格 yyyy-MM-ddHH:mm:ss”
/// 格式”yyyy-MM-dd HH:mm:ss”
/// </summary>
public string ut { get; set; }
public List<PriceTemp>? priceTemp { get; set; }
public string GetCmd()
{
return CloudConst.setStaPrice;
}
}
public class PriceTemp
{
/// <summary>
/// 电价模型id
/// 由服务器统一进行分配
/// </summary>
public string ceid { get; set; }
/// <summary>
/// 电价
/// 精度 0.0001 元
/// </summary>
public float ep { get; set; }
/// <summary>
/// 开始时段
/// 格式”HH:mm:ss”精确到小时
/// </summary>
public string st { get; set; }
public DateTime st { get; set; }
/// <summary>
/// 结束时段
/// 格式“HH:mm:ss” 精确到小时
/// </summary>
public string et { get; set; }
public DateTime et { get; set; }
/// <summary>
/// 换电服务单价
/// 0.001
/// 时段序号
/// 对应尖峰平谷序号1:尖; 2:峰; 3:平; 4
/// <see cref="Entity.Constant.CloudEnum.PeriodNumber"/>
/// </summary>
public double pr { get; set; }
public string GetCmd()
{
return CloudConst.setStaPrice;
}
public int pr { get; set; }
}
}

@ -12,6 +12,17 @@ namespace Service.Cloud.Msg.Host.Req
/// </summary>
public string sn { get; set; }
public List<DataInfo> datainfo { get; set; }
public string GetCmd()
{
return CloudConst.chargeDevDataInfo;
}
}
public class DataInfo
{
/// <summary>
/// 设备编号 设备编号
/// </summary>
@ -154,10 +165,5 @@ namespace Service.Cloud.Msg.Host.Req
/// 更新时间 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary>
public DateTime bt { get; set; }
public string GetCmd()
{
return CloudConst.chargeDevDataInfo;
}
}
}

@ -42,7 +42,7 @@ namespace Service.Cloud.Msg.Host.Req
/// 发生时间
/// 格式”yyyy-MM-dd HH:mm:ss”
/// </summary>
public DateTime bt { get; set; }
public string bt { get; set; }
/// <summary>
/// 采集模式
/// 1自动2人工录入

@ -35,12 +35,12 @@ public class StaDayOpeEnergyVal : ICmd
/// <summary>
/// 首次换电时刻 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary>
public DateTime ft { get; set; }
public string ft { get; set; }
/// <summary>
/// 结束换电时刻 格式 ”yyyy-MM-dd HH:mm:ss ”
/// </summary>
public DateTime sp { get; set; }
public string sp { get; set; }
/// <summary>
/// 换电总时长 单位: 秒

@ -13,36 +13,42 @@ namespace Service.Cloud.Msg.Host.Resp
public class SetStaPriceRes : ICmd
{
/// <summary>
/// 更新时间
/// 格式”yyyy-MM-dd HH:mm:ss”
/// 应答结果
/// 0:成功 1:失败
/// <see cref="Entity.Constant.CloudEnum.ResultInt"/>
/// </summary>
public string ut { get; set; }
/// <summary>
/// 电价模型 id
/// 由服务器统一进行分配
/// </summary>
public int ceid { get; set; }
/// <summary>
/// 电价
/// 精度 0.0001 元
/// </summary>
public float ep { get; set; }
/// <summary>
/// 开始时段
/// 格式”HH:mm:ss”精确到小时
/// </summary>
public string st { get; set; }
/// <summary>
/// 结束时段
/// 格式“HH:mm:ss” 精确到小时
/// </summary>
public string et { get; set; }
/// <summary>
/// 时段序号
/// 对应尖峰平谷序号1:尖; 2:峰; 3:平; 4
/// <see cref="Entity.Constant.CloudEnum.PeriodNumber"/>
/// </summary>
public int pr { get; set; }
public int re { get; set; }
///// <summary>
///// 更新时间
///// 格式”yyyy-MM-dd HH:mm:ss”
///// </summary>
//public string ut { get; set; }
///// <summary>
///// 电价模型 id
///// 由服务器统一进行分配
///// </summary>
//public int ceid { get; set; }
///// <summary>
///// 电价
///// 精度 0.0001 元
///// </summary>
//public float ep { get; set; }
///// <summary>
///// 开始时段
///// 格式”HH:mm:ss”精确到小时
///// </summary>
//public string st { get; set; }
///// <summary>
///// 结束时段
///// 格式“HH:mm:ss” 精确到小时
///// </summary>
//public string et { get; set; }
///// <summary>
///// 时段序号
///// 对应尖峰平谷序号1:尖; 2:峰; 3:平; 4
///// <see cref="Entity.Constant.CloudEnum.PeriodNumber"/>
///// </summary>
//public int pr { get; set; }
public string GetCmd()
{

@ -1,7 +1,9 @@
using Entity.Constant;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Cloud.Client;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Cloud.Resp;
@ -10,6 +12,7 @@ using Service.Cloud.Msg.Host.Req.OutCharger;
using Service.Execute.Model;
using Service.Execute.Model.Tbox;
using Service.Init;
using System.Security.Cryptography;
namespace Service.Execute.Api;
@ -113,15 +116,15 @@ public abstract class CloudApi
/// <summary>
/// 上报换电步序到云端
/// </summary>
/// <param name="state"></param>
/// <param name="daad">是否空闲</param>
public static void SendStateLog( int state)
public static void SendStateLog( )
{
if (BusinessSwappingForCloudState!= StationSoftMgr.SwappingStateMachine.BusinessSwappingForCloudState)
{
StationChnRunStatus stationChnRunStatus = null;
if (state == 1)
if (StationSoftMgr.SwappingStateMachine.BusinessSwappingForCloudState != InfoEnum.BusinessSwappingForCloudState.Idle||
StationSoftMgr.SwappingStateMachine.BusinessSwappingForCloudState != InfoEnum.BusinessSwappingForCloudState.UnKnown)
{
stationChnRunStatus = new()
{
@ -130,12 +133,12 @@ public abstract class CloudApi
cs = (int)StationSoftMgr.SwappingStateMachine.BusinessSwappingForCloudState,
iv = StationSoftMgr.SwappingStateMachine.RadarInFlag == true ? 1 : 2,
ls = StationSoftMgr.SwappingStateMachine.VelUnlockFlag == true ? 2 : 1,
fl = 0,
fl = Convert.ToInt32(StaticStationInfo.Faultlevel),
ut = DateTime.Now,
};
}
else
else//空闲
{
stationChnRunStatus = new()
@ -145,7 +148,7 @@ public abstract class CloudApi
cs = 1,
iv = 2,
ls = 0,
fl = 0,
fl = Convert.ToInt32(StaticStationInfo.Faultlevel),
ut = DateTime.Now,
};
@ -171,7 +174,48 @@ public abstract class CloudApi
{
return;
}
/// <summary>
/// 换电车辆数据上报
/// </summary>
/// <param name="req"></param>
public static void SendVehicleDataReporting(SwappingStateMachine machine,int vet)
{
var carInfoBatteryInfos = machine.BoxCarInfoModel?.CarInfo?.BatteryInfos;
CardataReport cardataReport = new()
{
on = machine.SwapOrder.Sn,
ct = DateTime.Now,
cn = machine.SwapOrder.VehicleNo,
rfid = "",
Vi = machine.SwapOrder.VehicleVin,
mc = "",
bn = carInfoBatteryInfos.Count > 0 ? carInfoBatteryInfos[0].BatteryNo : "",
ec = 0,
soc = carInfoBatteryInfos.Count > 0 ? Convert.ToSingle(carInfoBatteryInfos[0].Soc) : 0,
bskm = Convert.ToSingle(machine.BoxCarInfoModel?.ElecMsg?.SubMile),
btkm = Convert.ToSingle(machine.BoxCarInfoModel?.ElecMsg?.TotalMile),
soh = carInfoBatteryInfos.Count > 0 ? Convert.ToSingle(carInfoBatteryInfos[0].Soh) : 0,
soe = carInfoBatteryInfos.Count > 0 ? Convert.ToSingle(carInfoBatteryInfos[0].Soe) : 0,
vtm = Convert.ToSingle(machine.BoxCarInfoModel?.ElecMsg?.TotalMile),
vet = vet,
vtdc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.AccDischargeCount),
vtfe = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.AccFallbackCount),
vtcc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.AccChargeCount),
vtec = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.AccKgce),
rtdc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ThisTimeRealDischarge),
lsdc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceDischarge),
rtfc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ThisTimeRealFeedbackPower),
lsfc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceFeedbackPower),
rtcc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ThisTimeRealChargeCount),
lscc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceChargeCount),
rtec = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ThisTimeRealKgce),
ltfc = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.LastTimeBalanceKgce),
wsec = Convert.ToInt32(machine.BoxCarInfoModel?.ElecMsg?.ElectricityToBeSettled),
};
//CloudClientMgr.CloudClient?.SendVehicleDataReporting(cardataReport,
// global::System.TimeSpan.FromSeconds(TimeSpan));
}
/// <summary>
/// 云平台下发换电指令
/// </summary>
@ -330,4 +374,88 @@ public abstract class CloudApi
CloudClientMgr.CloudClient?.SendStaHourAmountVal(req,
global::System.TimeSpan.FromSeconds(TimeSpan));
}
//TODO 未调试,先注释上传
/// <summary>
/// 换电站进行签到认证
/// </summary>
/// <param name="req"></param>
public static void SendSignIn()
{
SignIn signIn = new()
{
sn = StaticStationInfo.StationNo,
ky = StaticStationInfo.StationSn,
st = "02",
dv = "",
sv = StaticStationInfo.StationSftVer,
ss = StaticStationInfo.Sevstatus,
ca = Convert.ToSingle(StaticStationInfo.DistributionCapacity),
VS = "1.0",
cp = Convert.ToInt32(StaticStationInfo.TotalPower),
bs= StaticStationInfo.StationVersion,
lo= StaticStationInfo.Longitude,
la= StaticStationInfo.Latitude,
en=1,
cn=7,
eid= Convert.ToInt32(StaticStationInfo.Ceid),
oid = Convert.ToInt32(StaticStationInfo.Oid),
};
//CloudClientMgr.CloudClient?.SendSignIn(signIn,
// global::System.TimeSpan.FromSeconds(TimeSpan));
}
/// <summary>
/// 换电站上报设备列表
/// </summary>
/// <param name="req"></param>
public static void SendDevList(DevList req)
{
// CloudClientMgr.CloudClient?.SendReportingDeviceList(req,
// global::System.TimeSpan.FromSeconds(TimeSpan));
}
/// <summary>
/// 实时故障上报
/// </summary>
/// <param name="req"></param>
public static void SendRealTimeFaultInfo(FaultReport req)
{
//CloudClientMgr.CloudClient?.SendRealTimeFaultInfo(req,
// global::System.TimeSpan.FromSeconds(TimeSpan));
}
/// <summary>
/// 换电站设备状态开始日志信息
/// </summary>
/// <param name="req"></param>
public static void SendStartLogMessage(EqmStateStartLogInfo req)
{
// CloudClientMgr.CloudClient?.SendStartLogMessage(req,
// global::System.TimeSpan.FromSeconds(TimeSpan));
}
/// <summary>
/// 换电站设备状态结束日志信息
/// </summary>
/// <param name="req"></param>
public static void SendEndLogMessage(EqmStateEndLogInfo req)
{
//CloudClientMgr.CloudClient?.SendEndLogMessage(req,
// global::System.TimeSpan.FromSeconds(TimeSpan));
}
public static void SendBatteryTotal(BatteryTotal req)
{
// CloudClientMgr.CloudClient?.SendBatteryTotal(req,
// global::System.TimeSpan.FromSeconds(TimeSpan));
}
public static void SendChargingTotalDis(ChargingTotalDis req)
{
// CloudClientMgr.CloudClient?.SendChargingTotalDis(req,
// global::System.TimeSpan.FromSeconds(TimeSpan));
}
}

@ -1,4 +1,10 @@
using Autofac;
using Entity.Attr;
using Entity.Constant;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using log4net;
using Service.Station;
namespace Service.Execute.Api;
@ -6,14 +12,18 @@ public class SoundApi
{
private static readonly string BASE_URL = "http://localhost:5038";
private static readonly ILog Log = LogManager.GetLogger("SoundApi");
static SysRunningFaultService sysRunningFaultService = AppInfo.Container.Resolve<SysRunningFaultService>();
private static readonly HttpClient _httpClient = new HttpClient()
{
Timeout = TimeSpan.FromSeconds(5)
};
public static void PlayOneSound(int soundNo)
{
SaveSysRunningFault(soundNo);
string url = BASE_URL + "/Api/PlayOneSound?soundcode=" + soundNo;
try
{
@ -24,4 +34,22 @@ public class SoundApi
Log.Error($" SoundApi PlayOneSound e = {e}");
}
}
private static void SaveSysRunningFault(int soundNo)
{
if (Enum.TryParse<InfoEnum.SwapInfo>(soundNo.ToString(), out InfoEnum.SwapInfo enumMember))
{
string soundContent= InfoExtend.GetSound(enumMember);
if (InfoExtend.GetSound(enumMember).Contains("失败")||InfoExtend.GetLed(enumMember).Contains("失败"))
{
sysRunningFaultService.InsertAsync(new SysRunningFault()
{
FaultDescribe=soundContent,
FalustHappenTime=DateTime.Now,
});
}
}
}
}

@ -72,7 +72,7 @@ public class CarPrepareState : IState
return SwappingStateMachine.ReturnWithInvokeErr(checkTBoxVelLocal, ExceptionReason.None);
}
//云端数据上报
// InvokeStatus cloudTBox = CloudTBoxFlag(machine);
/*if (cloudTBox != InvokeStatus.Done)
@ -196,7 +196,6 @@ public class CarPrepareState : IState
{
CarAuthRes? vehicleCertificationResp =
CloudApi.VehicleCheck(machine.RfidReadModel, machine.SwapOrder);
if (vehicleCertificationResp == null || vehicleCertificationResp.re != 0)
{
_log.Info("cloud check vehicle error");
@ -241,6 +240,14 @@ public class CarPrepareState : IState
if (isConnect)
{
machine.BoxConnectFlag = true;
//上报车辆数据
if (!machine.CloudTBoxFlag)
{
SwapOrderRepository _swapOrderRepository = AppInfo.Container.Resolve<SwapOrderRepository>();
var vet = _swapOrderRepository.QueryListByClause(u => u.SwapResult == 1&&u.VehicleVin== machine.SwapOrder.VehicleVin).Count;
CloudApi.SendVehicleDataReporting(machine, vet);
}
}
}, () =>
{

@ -10,12 +10,17 @@ namespace Service.Init;
/// </summary>
public class StaticStationInfo
{
public static int StationStatus
{
get => int.Parse(Resolve(StationParamConst.StationStatus));
set => Set(StationParamConst.StationStatus, value);
}
public static int Sevstatus
{
get => int.Parse(Resolve(StationParamConst.Sevstatus));
set => Set(StationParamConst.Sevstatus, value);
}
public static string OperationStartTime
{
get => Resolve(StationParamConst.OperationStartTime);
@ -27,7 +32,12 @@ public class StaticStationInfo
get => Resolve(StationParamConst.OperationEndTime);
set => Set(StationParamConst.OperationEndTime, value);
}
public static string LaunchTime
{
get => Resolve(StationParamConst.LaunchTime);
set => Set(StationParamConst.LaunchTime, value);
}
public static int StationWay
{
get => int.Parse(Resolve(StationParamConst.StationWay));
@ -59,7 +69,17 @@ public class StaticStationInfo
get => Resolve(StationParamConst.StationSn);
set => Set(StationParamConst.StationSn, value);
}
public static string StationLocation
{
get => Resolve(StationParamConst.StationLocation);
set => Set(StationParamConst.StationLocation, value);
}
public static string StationType
{
get => Resolve(StationParamConst.StationType);
set => Set(StationParamConst.StationType, value);
}
public static int SwapFinishChargeTime
{
get => int.Parse(Resolve(StationParamConst.SwapFinishChargeTime));
@ -72,6 +92,89 @@ public class StaticStationInfo
set => Set(StationParamConst.SwapSoc, value);
}
public static string StationSftVer
{
get => Resolve(StationParamConst.StationSftVer);
set => Set(StationParamConst.StationSftVer, value);
}
public static string Faultlevel
{
get => Resolve(StationParamConst.Faultlevel);
set => Set(StationParamConst.Faultlevel, value);
}
public static string DistributionCapacity
{
get => Resolve(StationParamConst.DistributionCapacity);
set => Set(StationParamConst.DistributionCapacity, value);
}
public static string TotalPower
{
get => Resolve(StationParamConst.TotalPower);
set => Set(StationParamConst.TotalPower, value);
}
public static string ModifyTime
{
get => Resolve(StationParamConst.ModifyTime);
set => Set(StationParamConst.ModifyTime, value);
}
public static string StationVersion
{
get => Resolve(StationParamConst.StationVersion);
set => Set(StationParamConst.StationVersion, value);
}
public static string Longitude
{
get => Resolve(StationParamConst.Longitude);
set => Set(StationParamConst.Longitude, value);
}
public static string Latitude
{
get => Resolve(StationParamConst.Latitude);
set => Set(StationParamConst.Latitude, value);
}
public static string AreaCode
{
get => Resolve(StationParamConst.AreaCode);
set => Set(StationParamConst.AreaCode, value);
}
public static string AreaName
{
get => Resolve(StationParamConst.AreaName);
set => Set(StationParamConst.AreaName, value);
}
public static string ContactWay
{
get => Resolve(StationParamConst.ContactWay);
set => Set(StationParamConst.ContactWay, value);
}
public static string Principal
{
get => Resolve(StationParamConst.Principal);
set => Set(StationParamConst.Principal, value);
}
public static string StationCompany
{
get => Resolve(StationParamConst.StationCompany);
set => Set(StationParamConst.StationCompany, value);
}
public static string SocialCreditCode
{
get => Resolve(StationParamConst.SocialCreditCode);
set => Set(StationParamConst.SocialCreditCode, value);
}
public static string SupplierCode
{
get => Resolve(StationParamConst.SupplierCode);
set => Set(StationParamConst.SupplierCode, value);
}
public static string Cover
{
get => Resolve(StationParamConst.Cover);
set => Set(StationParamConst.Cover, value);
}
#region Tbox
public static bool TboxStateConnect

@ -1,4 +1,4 @@
using AutoMapper;
using AutoMapper;
using Entity.Api.Req;
using Entity.DbModel.Station;
using Entity.Dto;

@ -210,6 +210,11 @@ public class MonitorService
MoveBinRecord moveBinRecord = null;
try
{
if (!PlcApi.IsRemote())
{
return Result<bool>.Fail("PLC不是远程模式");
}
//校验:出仓位
BinInfo? removeBin = BinInfoRepository.QueryByClause(i =>
i.No.Equals(removeBinNo) && (i.ChargeStatus != 1) && i.Exists == 1 &&

@ -0,0 +1,55 @@
using Entity.Ammeter;
using Entity.DbModel;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using Repository.Ammeter;
using Repository.Station;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using Entity.Dto.Req;
using Entity.Dto.Resp;
using HybirdFrameworkCore.Entity;
using Mapster;
using SqlSugar;
namespace Service.Station;
[Scope("SingleInstance")]
public class SysRunningFaultService : BaseServices<SysRunningFault>
{
private SysRunningFaultRepository _sysRunningFaultRep;
public SysRunningFaultService(SysRunningFaultRepository sysRunningFaultRep)
{
_sysRunningFaultRep = sysRunningFaultRep;
this.BaseDal = sysRunningFaultRep;
}
/// <summary>
/// 获取系统运行时故障信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PageResult<SysRunningFault>> Page(int pageSize)
{
PageResult<SysRunningFault> pageResult = new PageResult<SysRunningFault>();
List<SysRunningFault> sysRunningFaultList = await _sysRunningFaultRep.QueryListByClauseAsync(i=>i.FaultDescribe!="");
if (sysRunningFaultList.Count > 0)
{
pageResult.PageNum = sysRunningFaultList.Count/pageSize+1;
pageResult.ToTal = sysRunningFaultList.Count;
pageResult.Rows = sysRunningFaultList;
}
else
{
pageResult.PageNum = 0;
pageResult.ToTal = 0;
}
pageResult.PageSize = pageSize;
return pageResult;
}
}

@ -0,0 +1,135 @@
using System.Data;
using Entity.Api.Req;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using log4net;
using Service.Station;
using Magicodes.ExporterAndImporter.Excel;
using OfficeOpenXml;
namespace WebStarter.Controllers.Test;
[ApiController]
[Route("api/[controller]")]
public class EquipAlarmDefineController : ControllerBase
{
private static readonly ILog Log = LogManager.GetLogger(typeof(EquipAlarmDefineController));
private readonly EquipAlarmDefineService _equipAlarmDefineService;
public EquipAlarmDefineController(EquipAlarmDefineService equipAlarmDefineService)
{
this._equipAlarmDefineService = equipAlarmDefineService;
}
/// <summary>
/// 导出
/// </summary>
/// <returns></returns>
[HttpPost("export")]
public async Task<IActionResult> ExportSwapOrder()
{
List<EquipAlarmDefine> list = await _equipAlarmDefineService.QueryAllEquipAlarm();
IExcelExporter excelExporter = new ExcelExporter();
var res = await excelExporter.ExportAsByteArray(list);
return new FileStreamResult(new MemoryStream(res), "application/octet-stream")
{ FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "设备报警基础信息.xlsx" };
}
/// <summary>
/// 文件导入
/// </summary>
/// <param name="filePath">文件路径</param>
[HttpPost("fileImport")]
public void ImportDataFromExcel(string filePath)
{
var fileInfo = new FileInfo(filePath);
using (var package = new ExcelPackage(fileInfo))
{
// 操作第一个工作表
ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
int rowCount = worksheet.Dimension.End.Row;
int colCount = worksheet.Dimension.End.Column;
DataTable dt = new DataTable();
// 初始化一个列表来存储第一行的所有名称
List<string> rowNames = new List<string>();
// 遍历第一行的所有单元格
// 注意Excel的索引通常是从1开始的所以第一行是1第一列也是1
for (int col = 1; col <= worksheet.Dimension.End.Column; col++)
{
string cellValue = worksheet.Cells[1, col].Value?.ToString() ?? string.Empty;
rowNames.Add(cellValue);
}
for (int col = 1; col <= colCount; col++)
{
dt.Columns.Add(worksheet.Cells[1, col].Value.ToString());
}
// 跳过标题行,从第二行开始读取数据
for (int row = 2; row <= rowCount; row++)
{
DataRow dr = dt.NewRow();
for (int col = 1; col <= colCount; col++)
{
dr[col - 1] = worksheet.Cells[row, col].Value ?? DBNull.Value;
}
dt.Rows.Add(dr);
}
//TODO::数据入库
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids">ids id列表</param>
/// <returns></returns>
[HttpPost("DeleteByIds")]
public async Task<Result<bool>> DeleteByIds([FromBody] List<long> ids)
{
if (_equipAlarmDefineService.DeleteByIds(ids))
{
return Result<bool>.Success(true, "删除成功");
}
else
{
return Result<bool>.Fail("删除失败");
}
}
/// <summary>
/// 新增
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost("Add")]
public async Task<Result<string>> Add([FromBody] AddEquipAlarmInfoReq req)
{
return await _equipAlarmDefineService.NewAddEquipAlarm(req);
}
/// <summary>
/// 查询所有设备报警基础信息
/// </summary>
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpPost("QueryPage/{pageSize}")]
public async Task<Result<PageResult<EquipAlarmDefine>>> QueryPage(int pageSize)
{
return await _equipAlarmDefineService.VagueQueryResult(pageSize, null);
}
/// <summary>
/// 模糊查询 设备报警基础信息
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost("VagueQueryPage/{pageSize}/{keyValue}")]
public async Task<Result<PageResult<EquipAlarmDefine>>> QueryPage(int pageSize, string keyValue)
{
return await _equipAlarmDefineService.VagueQueryResult(pageSize, keyValue);
}
}

@ -0,0 +1,34 @@
using Entity.DbModel.Station;
using Entity.Dto.Req;
using Entity.Dto.Resp;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Station;
namespace WebStarter.Controllers.Test;
[ApiController]
[Route("api/[controller]")]
public class SysRunningFaultController
{
private readonly SysRunningFaultService _sysRunningFaultService;
public SysRunningFaultController(SysRunningFaultService sysRunningFaultService)
{
_sysRunningFaultService = sysRunningFaultService;
}
/// <summary>
/// 查询系统设备运行时故障
/// </summary>
/// <param name="inputPage">每页显示多少条</param>
/// <returns></returns>
[HttpPost]
[Route("page")]
public async Task<Result<PageResult<SysRunningFault>>> Page(int inputPage)
{
return Result<PageResult<SysRunningFault>>.Success(await _sysRunningFaultService.Page(inputPage));
}
}

@ -2,7 +2,7 @@
"ConnectionStrings": {
"ConfigId": "master",
"DbType": "MySql",
"SqlConnection": "server=192.168.2.2;Port=3306;Database=huanneng_dev;Uid=root;Pwd=Rszn123;Charset=utf8;"
"SqlConnection": "server=127.0.0.1;Port=3306;Database=huanneng_dev1;Uid=root;Pwd=123456;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
@ -10,7 +10,7 @@
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
"Connection": "106.12.36.89:6379,password=123456",
"Connection": "127.0.0.1:6379,password=123456",
"InstanceName": "local",
"DefaultDB": "8"
},
@ -111,7 +111,7 @@
}
},
"cloud": {
"enable": false
"enable": true
},
"plc": {
"enable": true

@ -0,0 +1,9 @@
ALTER TABLE equip_alarm_record
ADD COLUMN upload_status INT DEFAULT 0 COMMENT '上报状态 0未上传 1已上传';
ALTER TABLE equip_alarm_process_record
ADD COLUMN upload_status INT DEFAULT 0 COMMENT '上报状态 0未上传 1已上传';
ALTER TABLE elec_price_model_version
ADD COLUMN ceid VARCHAR(50) COMMENT '云平台模型ID';
Loading…
Cancel
Save