云平台下发尖峰平谷调试

master
xjl 3 months ago
parent e6e229fade
commit 900d7646a1

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

@ -214,43 +214,43 @@ public class CloudClientMgr
if (CloudClient.Connected) if (CloudClient.Connected)
{ {
if (StationConstant.StationModel.Remote == BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>( //if (StationConstant.StationModel.Remote == BaseEnumExtensions.GetEnumByCode<StationConstant.StationModel>(
StaticStationInfo.StationModel)) //StaticStationInfo.StationModel))
{ //{
CloudApi.SendStateLog(); // CloudApi.SendStateLog();
} //}
TaskHostStatusReported(); TaskHostStatusReported();
TaskAirConditioningData(); //TaskAirConditioningData();
TaskTemperatureHumidityData(); //TaskTemperatureHumidityData();
TaskPowerTotal(); //TaskPowerTotal();
TaskStaChargingTota(); //TaskStaChargingTota();
TaskMeterEnergyKwh(); //TaskMeterEnergyKwh();
TaskMeterDayEnergyVal(); //TaskMeterDayEnergyVal();
TaskStaHourEnergyVal(); //TaskStaHourEnergyVal();
TaskStaDayEnergyVal(); //TaskStaDayEnergyVal();
TaskStaDayOpeEnergyVal(); //TaskStaDayOpeEnergyVal();
//TaskStaHourAmountVal(); ////TaskStaHourAmountVal();
SendRealTimeFaultInfo(); //SendRealTimeFaultInfo();
SendStartLogMessage(); //SendStartLogMessage();
SendBatteryTotal(); //SendBatteryTotal();
SendChargingTotalDis(); //SendChargingTotalDis();
} }
Thread.Sleep(1000); Thread.Sleep(1000);
} }
@ -717,7 +717,7 @@ public class CloudClientMgr
} }
/// <summary> /// <summary>
/// 换电站分时用电统计信息 /// 换电站分时用电统计信息(站控不计价,这一帧不要)
/// </summary> /// </summary>
private static void TaskStaHourAmountVal() private static void TaskStaHourAmountVal()
{ {

@ -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);
}
}
}

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

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

@ -2,4 +2,8 @@ ALTER TABLE equip_alarm_record
ADD COLUMN upload_status INT DEFAULT 0 COMMENT '上报状态 0未上传 1已上传'; ADD COLUMN upload_status INT DEFAULT 0 COMMENT '上报状态 0未上传 1已上传';
ALTER TABLE equip_alarm_process_record ALTER TABLE equip_alarm_process_record
ADD COLUMN upload_status INT DEFAULT 0 COMMENT '上报状态 0未上传 1已上传'; 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