换点订单增加启动方式

实时通讯
zw
rszn 4 months ago
parent a8ff577ab1
commit 2682bd343d

@ -12,7 +12,7 @@ namespace Entity.Api.Resp
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
/// </summary>
public int Id { get; set; }
/// <summary>
@ -253,8 +253,14 @@ namespace Entity.Api.Resp
/// Nullable:True
/// </summary>
public int? CanUpload { get; set; }
/// <summary>
/// 启动方式0-站控自动启动1-站控手动启动2-充电机启动
/// Default:
/// Nullable:True
/// </summary>
public int StartType { get; set; }
/// <summary>
/// Desc:交流电表量
/// Default:

@ -282,5 +282,11 @@ namespace Entity.DbModel.Station
/// </summary>
[SugarColumn(ColumnName = "can_upload")]
public int CanUpload { get; set; }
/// <summary>
/// 启动方式0-站控自动启动1-站控手动启动2-充电机启动
/// </summary>
[SugarColumn(ColumnName = "start_type")]
public int StartType { get; set; }
}
}

@ -0,0 +1,77 @@
using System.Collections.Concurrent;
using HybirdFrameworkCore.Utils;
using log4net;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;
namespace Service.RealTime;
public class MyHub : Hub
{
private static readonly JsonSerializerSettings settings = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
DateFormatString = "yyyy-MM-dd HH:mm:ss",
NullValueHandling = NullValueHandling.Ignore
};
private static readonly ILog Log = LogManager.GetLogger(typeof(MyHub));
private static readonly ConcurrentDictionary<string, string>
Dictionary = new ConcurrentDictionary<string, string>();
#region rpc
public async Task SendMsg(string toUser, string msg)
{
Log.Info($"receive {msg}");
await Clients.All.SendAsync("ReceiveMsg", toUser +":"+msg);
}
public void Login(string uid)
{
if (!Dictionary.ContainsKey(uid))
{
Dictionary[uid] = Context.ConnectionId;
}
}
public void Logout(string uid)
{
if (ObjUtils.IsNotNullOrWhiteSpace(uid))
{
Dictionary.Remove(uid);
}
}
public void InvokeWithoutResult(string s)
{
RtMsg? rtMsg = JsonConvert.DeserializeObject<RtMsg>(s, settings);
if (rtMsg != null)
{
}
}
public RtMsg? Invoke(RtMsg rtMsg)
{
if (rtMsg != null)
{
object result = new object();
RtMsg msg = new RtMsg()
{
Id = rtMsg.Id,
Cmd = rtMsg.Cmd,
Datetime = DateTime.Now,
FromUser = "swap",
Msg = JsonConvert.SerializeObject(result, settings)
};
//TODO 根据cmd执行业务
return msg;
}
return null;
}
#endregion
}

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

@ -15,6 +15,7 @@ using Microsoft.IdentityModel.Tokens;
using Service.Cloud.Client;
using Service.Execute;
using Service.Plc.Client;
using Service.RealTime;
using SqlSugar;
using SqlSugar.IOC;
@ -97,10 +98,16 @@ builder.Services.AddSwaggerGen(c =>
c.IncludeXmlComments(Path.Combine(basePath, "HybirdFrameworkCore.xml"), true);
});
builder.Services.AddControllers().AddJsonOptions(configure =>
bool.TryParse(AppSettingsHelper.GetContent("SignalR", "Enabled"), out var signalrEnabled);
if (signalrEnabled)
{
configure.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
});
builder.Services.AddSignalR(options =>
{
options.EnableDetailedErrors = true;
options.KeepAliveInterval = TimeSpan.FromMinutes(1);
});
}
// 添加jwt验证
@ -135,6 +142,10 @@ app.UseStaticFiles();
app.UseAuthorization();
app.UseCors("myCors");
app.MapControllers();
if (signalrEnabled)
{
app.MapHub<MyHub>("/realtime");
}
var list = AppSettingsHelper.GetContent("Kestrel", "Endpoints", "http", "Url");
foreach (var s in list.Split(";"))
@ -164,7 +175,6 @@ if (AppSettingsHelper.GetBool("swap", "enable"))
StationSoftMgr.SwappingStateMachineStart();
}
TaskInit.Init();
QuartzSchedulerFactory.Init();

@ -129,5 +129,8 @@
},
"Job": {
"Enabled": true
},
"SignalR": {
"Enabled": false
}
}

@ -0,0 +1 @@
alter table charge_order add COLUMN start_type int comment '0-站控自启1-站控手动启动2-充电机自启';
Loading…
Cancel
Save