云平台请求回复处理

zw
smartwyy 6 months ago
parent 6fb13e5686
commit b483add4d5

@ -0,0 +1,67 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace Entity.DbModel.Station
{
///<summary>
///电池运营模型
///</summary>
[SugarTable("battery_op_model")]
public partial class BatteryOpModel
{
public BatteryOpModel(){
}
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="id")]
public int Id {get;set;}
/// <summary>
/// Desc:模型id
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="model_id")]
public int? ModelId {get;set;}
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_by")]
public string CreatedBy {get;set;}
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_time")]
public DateTime? CreatedTime {get;set;}
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_by")]
public string UpdatedBy {get;set;}
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_time")]
public DateTime? UpdatedTime {get;set;}
}
}

@ -0,0 +1,99 @@
using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace Entity.DbModel.Station
{
///<summary>
///电池运营模型详情
///</summary>
[SugarTable("battery_op_model_detail")]
public partial class BatteryOpModelDetail
{
public BatteryOpModelDetail(){
}
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey=true,ColumnName="id")]
public int Id {get;set;}
/// <summary>
/// Desc:模型Id
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="model_id")]
public int? ModelId {get;set;}
/// <summary>
/// Desc:开始时间06:00:00
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_time")]
public string StartTime {get;set;}
/// <summary>
/// Desc:结束时间06:00:01
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="end_time")]
public string EndTime {get;set;}
/// <summary>
/// Desc:需要电池数量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="battery_count")]
public int? BatteryCount {get;set;}
/// <summary>
/// Desc:需要电池类型
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="battery_type")]
public string BatteryType {get;set;}
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_by")]
public string CreatedBy {get;set;}
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="created_time")]
public DateTime? CreatedTime {get;set;}
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_by")]
public string UpdatedBy {get;set;}
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="updated_time")]
public DateTime? UpdatedTime {get;set;}
}
}

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

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

@ -7,8 +7,8 @@ namespace Service.BusinessTask.MyTask;
/// </summary>
public class SwapOrderReportCloudTask : AbstractTaskHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(SwapOrderReportCloudTask));
private static readonly ILog _log = LogManager.GetLogger(typeof(SwapOrderReportCloudTask));
protected override int Interval()
{
return 20 * 1000;
@ -16,12 +16,10 @@ public class SwapOrderReportCloudTask : AbstractTaskHandler
protected override void Handle()
{
}
protected override string Name()
{
return "SwapOrderReportCloudTask";
}
}

@ -0,0 +1,68 @@
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("InstancePerDependency")]
public class BatteryOperatingModelHandler: IBaseHandler
{
private readonly BatteryOpModelRepository _batteryOpModelRepository;
private readonly BatteryOpModelDetailRepository _batteryOpModelDetailRepository;
public BatteryOperatingModelHandler(BatteryOpModelRepository batteryOpModelRepository,
BatteryOpModelDetailRepository batteryOpModelDetailRepository)
{
_batteryOpModelRepository = batteryOpModelRepository;
_batteryOpModelDetailRepository = batteryOpModelDetailRepository;
}
public bool CanHandle(string cmd)
{
return CloudConst.setOpModel == cmd;
}
public void Handle(string t)
{
BatteryOperatingModel? req = JsonConvert.DeserializeObject<BatteryOperatingModel>(t);
if (req != null)
{
BatteryOpModel batteryOpModel = new BatteryOpModel()
{
ModelId = req.oid,
CreatedTime = req.ut
};
_batteryOpModelRepository.Insert(batteryOpModel);
if (req.seg is {Count: > 0})
{
List<BatteryOpModelDetail> list = new();
foreach (var d in req.seg)
{
list.Add(new BatteryOpModelDetail()
{
ModelId = req.oid,
BatteryType = d.btc,
BatteryCount = d.bc,
StartTime = d.st,
EndTime = d.et
});
}
_batteryOpModelDetailRepository.Insert(list);
}
BatteryOperatingModelResp resp = new BatteryOperatingModelResp();
CloudClientMgr.CloudClient?.Publish(resp);
}
}
}

@ -0,0 +1,36 @@
using HybirdFrameworkCore.Autofac.Attribute;
using NewLife;
using Newtonsoft.Json;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Host.Resp;
using Service.Init;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class BusinessHourHandler : IBaseHandler
{
public bool CanHandle(string cmd)
{
return CloudConst.setOpTime == cmd;
}
public void Handle(string t)
{
BusinessHour? req = JsonConvert.DeserializeObject<BusinessHour>(t);
if (req != null)
{
List<SEG> reqSeg = req.seg;
if (reqSeg is { Count: > 0 })
{
StaticStationInfo.OperationStartTime = reqSeg.Select(i => i.st).Join();
StaticStationInfo.OperationEndTime = reqSeg.Select(i => i.et).Join();
}
BusinessHourResp resp = new BusinessHourResp();
CloudClientMgr.CloudClient?.Publish(resp);
}
}
}

@ -0,0 +1,33 @@
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Host.Resp;
using Service.Init;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class DeliverBasicInformationHandler : IBaseHandler
{
public bool CanHandle(string cmd)
{
return CloudConst.setStBaseInfo == cmd;
}
public void Handle(string t)
{
DeliverBasicInformation? deliverBasicInformation = JsonConvert.DeserializeObject<DeliverBasicInformation>(t);
if (deliverBasicInformation != null)
{
StaticStationInfo.StationNo = deliverBasicInformation.sn;
StaticStationInfo.StationName = deliverBasicInformation.Sm;
StaticStationInfo.StationSn = deliverBasicInformation.SS;
//TODO 补全StaticStationInfo后赋值
DeliverBasicInformationResp resp = new DeliverBasicInformationResp();
CloudClientMgr.CloudClient?.Publish(resp);
}
}
}

@ -0,0 +1,32 @@
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Host.Resp;
using Service.Init;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class ParameterAcquisitionHandler : IBaseHandler
{
public bool CanHandle(string cmd)
{
return CloudConst.getConfig == cmd;
}
public void Handle(string t)
{
ParameterAcquisition? req = JsonConvert.DeserializeObject<ParameterAcquisition>(t);
if (req != null)
{
ParameterAcquisitionResp resp = new ParameterAcquisitionResp();
resp.chsoc = Char.Parse(StaticStationInfo.SwapSoc);
resp.eid = StaticStationInfo.Eid;
resp.oid = StaticStationInfo.Oid;
resp.ceid = StaticStationInfo.Ceid;
CloudClientMgr.CloudClient?.Publish(resp);
}
}
}

@ -0,0 +1,30 @@
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Host.Resp;
using Service.Init;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class ServiceableStateHandler:IBaseHandler
{
public bool CanHandle(string cmd)
{
return CloudConst.setServiceRes == cmd;
}
public void Handle(string t)
{
ServiceableState? req = JsonConvert.DeserializeObject<ServiceableState>(t);
if (req != null)
{
StaticStationInfo.StationStatus = req.st;
ServiceableStateResp resp = new ServiceableStateResp();
CloudClientMgr.CloudClient?.Publish(resp);
}
}
}

@ -0,0 +1,34 @@
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Service.Cloud.Client;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Host.Resp;
using Service.Init;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class SetConfigurationParametersHandler : IBaseHandler
{
public bool CanHandle(string cmd)
{
return CloudConst.setStBaseInfo == cmd;
}
public void Handle(string t)
{
SetConfigurationParameters? setConfigurationParameters = JsonConvert.DeserializeObject<SetConfigurationParameters>(t);
if (setConfigurationParameters != null)
{
char chsoc = setConfigurationParameters.chsoc;
StaticStationInfo.SwapSoc = chsoc.ToString();
StaticStationInfo.Eid = setConfigurationParameters.eid;
StaticStationInfo.Oid = setConfigurationParameters.oid;
StaticStationInfo.Ceid = setConfigurationParameters.ceid;
SetConfigurationParametersResp resp = new SetConfigurationParametersResp();
CloudClientMgr.CloudClient?.Publish(resp);
}
}
}

@ -1,9 +1,4 @@
using Service.Cloud.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service.Cloud.Msg.Cloud.Req
{
@ -16,29 +11,40 @@ namespace Service.Cloud.Msg.Cloud.Req
/// 运营模型ID
/// </summary>
public int oid { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public string ut { get; set; }
public DateTime ut { get; set; }
public List<Detail>? seg { get; set; }
public string GetCmd()
{
return CloudConst.setOpModel;
}
}
public class Detail
{
/// <summary>
/// 开始时段
/// </summary>
public string st { get; set; }
/// <summary>
/// 结束时段
/// </summary>
public string et { get; set; }
/// <summary>
/// 该时段需要的电池类型编 号
/// </summary>
public string btc { get; set; }
/// <summary>
/// 该时段需要的电池数量
/// </summary>
public int bc { get; set; }
public string GetCmd()
{
return CloudConst.setOpModel;
}
}
}
}

@ -1,9 +1,4 @@
using Service.Cloud.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service.Cloud.Msg.Cloud.Req
{
@ -15,10 +10,16 @@ namespace Service.Cloud.Msg.Cloud.Req
/// <summary>
/// 自定义
/// </summary>
public string param { get; set; }
public List<Parameter>? Data { get; set; }
public string GetCmd()
{
return CloudConst.getConfig;
}
}
}
public class Parameter
{
public string param { get; set; }
}
}

@ -1,9 +1,4 @@
using Service.Cloud.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service.Cloud.Msg.Cloud.Req
{
@ -16,79 +11,98 @@ namespace Service.Cloud.Msg.Cloud.Req
/// 电站编码
/// </summary>
public string sn { get; set; }
/// <summary>
/// 换电站名称
/// </summary>
public string Sm { get; set; }
/// <summary>
/// 换电站识别号
/// </summary>
public string SS { get; set; }
/// <summary>
/// 地理位置
/// </summary>
public string sl { get; set; }
/// <summary>
/// 换电站类型
/// </summary>
public string st { get; set; }
/// <summary>
/// 经度
/// </summary>
public string ld { get; set; }
/// <summary>
/// 纬度
/// </summary>
public string lt { get; set; }
/// <summary>
/// 区域编号
/// </summary>
public string ac { get; set; }
/// <summary>
/// 区域名称
/// </summary>
public string am { get; set; }
/// <summary>
/// 营运时间
/// </summary>
public DateTime ot { get; set; }
///投放时间
public DateTime lm { get; set; }
/// <summary>
/// 联系方式
/// </summary>
public string cw { get; set; }
/// <summary>
/// 负责人
/// </summary>
public string pp { get; set; }
/// <summary>
/// 所属运营企业
/// </summary>
public string sc { get; set; }
/// <summary>
/// 所属运营企业统一社 会信用代码
/// </summary>
public string cc { get; set; }
/// <summary>
/// 站控主机软件版本号
/// </summary>
public string sv { get; set; }
/// <summary>
/// 供应商代码
/// </summary>
public string sp { get; set; }
/// <summary>
/// 封面图片文件id
/// </summary>
public long cb { get; set; }
/// <summary>
/// 换电站基础信息版本号
/// </summary>
public string bs { get; set; }
public string GetCmd()
{
return CloudConst.setStBaseInfo;
}
}
}
}

@ -1,9 +1,4 @@
using Service.Cloud.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service.Cloud.Msg.Host.Resp
{
@ -15,11 +10,11 @@ namespace Service.Cloud.Msg.Host.Resp
/// <summary>
/// 应答结果
/// </summary>
public int re { get; set; }
public int re { get; set; } = 0;
public string GetCmd()
{
return CloudConst.setStBaseInfoRes;
}
}
}
}

@ -5,8 +5,6 @@ using Entity.Constant;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using log4net;
using Microsoft.OpenApi.Extensions;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using Repository.Station;
using Service.Execute.Api;
@ -156,7 +154,7 @@ public class StationReadyState : IState
{
var statusDes =
BaseEnumExtensions.GetEnumDescriptionByCode<StationConstant.StationStatus>(
int.Parse(StaticStationInfo.StationStatus));
StaticStationInfo.StationStatus);
_log.Info($"换电站处于{statusDes}状态");
var wayDes =
BaseEnumExtensions.GetEnumDescriptionByCode<StationConstant.StationWay>(
@ -164,7 +162,7 @@ public class StationReadyState : IState
_log.Info($"换电站处于{wayDes}模式");
if (StationConstant.StationStatus.Run ==
BaseEnumExtensions.GetEnumByCode<StationConstant.StationStatus>(int.Parse(StaticStationInfo.StationStatus))
BaseEnumExtensions.GetEnumByCode<StationConstant.StationStatus>(StaticStationInfo.StationStatus)
&& StationConstant.StationWay.Auto ==
BaseEnumExtensions.GetEnumByCode<StationConstant.StationWay>(int.Parse(StaticStationInfo.StationWay)))
{

@ -12,11 +12,21 @@ public class StaticStationInfo
{
public static string StationStatus
public static int StationStatus
{
get => Resolve(StationParamConst.StationStatus);
get => int.Parse(Resolve(StationParamConst.StationStatus));
set => Set(StationParamConst.StationStatus, value);
}
public static string OperationStartTime
{
get => Resolve(StationParamConst.OperationStartTime);
set => Set(StationParamConst.OperationStartTime, value);
}
public static string OperationEndTime
{
get => Resolve(StationParamConst.OperationEndTime);
set => Set(StationParamConst.OperationEndTime, value);
}
public static string StationWay
{
get => Resolve(StationParamConst.StationWay);
@ -41,6 +51,11 @@ public class StaticStationInfo
get => Resolve(StationParamConst.StationNo);
set => Set(StationParamConst.StationNo, value);
}
public static string StationSn
{
get => Resolve(StationParamConst.StationSn);
set => Set(StationParamConst.StationSn, value);
}
public static string SwapFinishChargeTime
{
@ -53,6 +68,25 @@ public class StaticStationInfo
get => Resolve(StationParamConst.SwapSoc);
set => Set(StationParamConst.SwapSoc, value);
}
public static int Eid
{
get => int.Parse(Resolve(StationParamConst.Eid));
set => Set(StationParamConst.Eid, value);
}
public static string Oid
{
get => Resolve(StationParamConst.Oid);
set => Set(StationParamConst.Oid, value);
}
public static int Ceid
{
get => int.Parse(Resolve(StationParamConst.Ceid));
set => Set(StationParamConst.Ceid, value);
}
#region cloud

@ -42,11 +42,11 @@ public class StationParamConst
/// <summary>
/// 营运开始时间
/// </summary>
public static readonly string OperatetionStartTime = "Station.OperatetionStartTime";
public static readonly string OperationStartTime = "Station.OperationStartTime";
/// <summary>
/// 营运结束时间
/// </summary>
public static readonly string OperatetionEndtime = "Station.OperatetionEndtime";
public static readonly string OperationEndTime = "Station.OperationEndTime";
/// <summary>
/// 服务状态
/// </summary>
@ -153,7 +153,11 @@ public class StationParamConst
public static readonly string SwapFinishChargeTime = "Station.SwapFinishChargeTime";
//选包策略换电Soc
public static readonly string SwapSoc = "Station.SwapSoc";
public static readonly string Eid = "Station.Eid";
public static readonly string Oid = "Station.Oid";
public static readonly string Ceid = "Station.Ceid";
public static readonly string StationStatus = "Station.StationStatus";
public static readonly string StationWay = "Station.StationWay";

@ -217,7 +217,7 @@ namespace Service.System
SysFlag = YesNoEnum.N,
Name = key
});
setResult = insertResult > 0 ? true : false;
setResult = insertResult > 0;
}
else
{

Loading…
Cancel
Save