master
rszn 5 months ago
parent 037c6fb887
commit e452ac00c7

@ -0,0 +1,129 @@
using System.Net.Sockets;
using log4net;
namespace Service.Led;
public class LedClient
{
#region msg
public static Dictionary<string, byte[]> Dictionary = new Dictionary<string, byte[]>()
{
{
"houtui",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00,
0x00, 0x0C, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3A, 0x34, 0xBA, 0xF3, 0xCD, 0xCB, 0x00, 0x00,
0x0D, 0x0A
}
},
{
"qianjin",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00,
0x00, 0x0C, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3A, 0x37, 0xC7, 0xB0, 0xBD, 0xF8, 0x00, 0x00,
0x0D, 0x0A
}
},
{
"xiangzuo",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00,
0x00, 0x0C, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3A, 0x31, 0xCF, 0xF2, 0xD7, 0xF3, 0x00, 0x00,
0x0D, 0x0A
}
},
{
"xiangyou",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00,
0x00, 0x0C, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3A, 0x31, 0xCF, 0xF2, 0xD3, 0xD2, 0x00, 0x00,
0x0D, 0x0A
}
},
{
"tingzhunle",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00,
0x00, 0x0E, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3B, 0x31, 0xCD, 0xA3, 0xD7, 0xBC, 0xC1, 0xCB,
0x00, 0x00, 0x0D, 0x0A
}
},
{
"wuche",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00,
0x00, 0x0C, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3A, 0x36, 0xCE, 0xDE, 0xB3, 0xB5, 0x00, 0x00,
0x0D, 0x0A
}
},
{
"zuoqian",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x10, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3A, 0x31, 0xCF, 0xF2, 0xD7, 0xF3, 0xC7, 0xB0,
0xB7, 0xBD, 0x00, 0x00, 0x0D, 0x0A
}
},
{
"youqian",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x10, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3A, 0x31, 0xCF, 0xF2, 0xD3, 0xD2, 0xC7, 0xB0,
0xB7, 0xBD, 0x00, 0x00, 0x0D, 0x0A
}
},
{
"zuohou",
new byte[]
{
0x55, 0xAA, 0x00, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x10, 0x00, 0x25, 0x64, 0x69, 0x73, 0x70, 0x30, 0x3A, 0x31, 0xCF, 0xF2, 0xD7, 0xF3, 0xBA, 0xF3,
0xB7, 0xBD, 0x00, 0x00, 0x0D, 0x0A
}
}
};
#endregion
private static readonly ILog Log = LogManager.GetLogger(typeof(LedClient));
private static TcpClient? _tcpClient;
public static bool Init(string ip, int port)
{
Log.Info($"begin connect {ip}:{port}");
_tcpClient = new TcpClient();
_tcpClient.Connect(ip, port);
Log.Info($"end connect {ip}:{port} {_tcpClient.Connected}");
return _tcpClient.Connected;
}
public static bool InnerSend(byte[] bytes)
{
if (_tcpClient?.Connected ?? true)
{
_tcpClient.GetStream().Write(bytes, 0, bytes.Length);
}
return false;
}
public static bool SendMsgByKey(string key)
{
Log.Info($"send by {key}");
if (Dictionary.TryGetValue(key, out var bytes))
{
return InnerSend(bytes);
}
return false;
}
}

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
using Service.Led;
namespace WebStarter.Controllers;
/// <summary>
/// led测试工具
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class LedController
{
/// <summary>
/// 发送led提示
/// </summary>
/// <param name="key">houtui,qianjin,xiangzuo</param>
/// <returns></returns>
[HttpGet("SendBy/{key}")]
public bool SendByKey(string key)
{
return LedClient.SendMsgByKey(key);
}
}

@ -1,10 +1,8 @@
using System.Text;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Common.Util;
using Entity.Dto.Resp;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Configuration;
using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Redis;
@ -13,11 +11,7 @@ using Mapster;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using Service.Charger.Client;
using Service.Cloud.Client;
using Service.Execute;
using Service.Padar.Client;
using Service.Plc.Client;
using Service.Ups;
using Service.Led;
using SqlSugar;
using SqlSugar.IOC;
@ -162,6 +156,12 @@ AppInfo.Container = app.Services.GetAutofacRoot();
//PadarMgr.InitClient();
if (AppSettingsHelper.GetBool("led", "enable"))
{
LedClient.Init(AppSettingsHelper.GetContent("led", "ip"), Convert.ToInt32(AppSettingsHelper.GetContent("led", "port")));
}
//现场调试plc连接
AppInfo.Container = app.Services.GetAutofacRoot();
ClientMgr.InitClient();
@ -171,4 +171,4 @@ ClientMgr.InitClient();
//TaskInit.Init();
app.Run();
app.Run();

@ -23,12 +23,18 @@
"AllowedHosts": "*",
"": null,
"Cryptogram": {
"StrongPassword": "false", //
"PasswordStrengthValidation": "(?=^.{6,16}$)(?=.*\\d)(?=.*\\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\\n).*$", // 6-16
"PasswordStrengthValidationMsg": "密码必须包含大小写字母、数字和特殊字符的组合长度在6-16之间", //
"CryptoType": "SM2", // MD5SM2SM4
"PublicKey": "0484C7466D950E120E5ECE5DD85D0C90EAA85081A3A2BD7C57AE6DC822EFCCBD66620C67B0103FC8DD280E36C3B282977B722AAEC3C56518EDCEBAFB72C5A05312", //
"PrivateKey": "8EDB615B1D48B8BE188FC0F18EC08A41DF50EA731FA28BF409E6552809E3A111" //
"StrongPassword": "false",
//
"PasswordStrengthValidation": "(?=^.{6,16}$)(?=.*\\d)(?=.*\\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\\n).*$",
// 6-16
"PasswordStrengthValidationMsg": "密码必须包含大小写字母、数字和特殊字符的组合长度在6-16之间",
//
"CryptoType": "SM2",
// MD5SM2SM4
"PublicKey": "0484C7466D950E120E5ECE5DD85D0C90EAA85081A3A2BD7C57AE6DC822EFCCBD66620C67B0103FC8DD280E36C3B282977B722AAEC3C56518EDCEBAFB72C5A05312",
//
"PrivateKey": "8EDB615B1D48B8BE188FC0F18EC08A41DF50EA731FA28BF409E6552809E3A111"
//
},
//Login
"TokenOptions": {
@ -38,34 +44,62 @@
"Issuer": "jwtIssuer"
},
"Upload": {
"Path": "Upload/{yyyy}/{MM}/{dd}", //
"MaxSize": 20480, // KB1024*20
"ContentType": [ "image/jpg", "image/png", "image/jpeg", "image/gif", "image/bmp", "text/plain", "application/pdf", "application/msword", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "video/mp4" ],
"EnableMd5": false // MDF5-
"Path": "Upload/{yyyy}/{MM}/{dd}",
//
"MaxSize": 20480,
// KB1024*20
"ContentType": [
"image/jpg",
"image/png",
"image/jpeg",
"image/gif",
"image/bmp",
"text/plain",
"application/pdf",
"application/msword",
"application/vnd.ms-excel",
"application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"video/mp4"
],
"EnableMd5": false
// MDF5-
},
//SysLogin
"JWTSettings": {
"ValidateIssuerSigningKey": true, // bool true
"IssuerSigningKey": "3c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a", // string 16
"ValidateIssuer": true, // bool true
"ValidIssuer": "Admin.NET", // string
"ValidateAudience": true, // bool true
"ValidAudience": "Admin.NET", // string
"ValidateLifetime": true, // bool truetrue
"ValidateIssuerSigningKey": true,
// bool true
"IssuerSigningKey": "3c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a",
// string 16
"ValidateIssuer": true,
// bool true
"ValidIssuer": "Admin.NET",
// string
"ValidateAudience": true,
// bool true
"ValidAudience": "Admin.NET",
// string
"ValidateLifetime": true,
// bool truetrue
//"ExpiredTime": 20, // long 20 13
"ClockSkew": 5, // long 5
"Algorithm": "HS256", // string HS256
"RequireExpirationTime": true // false
"ClockSkew": 5,
// long 5
"Algorithm": "HS256",
// string HS256
"RequireExpirationTime": true
// false
},
"SnowId": {
"WorkerId": 1, //
"WorkerIdBitLength": 6, // 6 [1, 19]
"SeqBitLength": 6, // 6 [3, 21]4Id
"WorkerPrefix": "adminnet_" //
"WorkerId": 1,
//
"WorkerIdBitLength": 6,
// 6 [1, 19]
"SeqBitLength": 6,
// 6 [3, 21]4Id
"WorkerPrefix": "adminnet_"
//
},
"HttpContextRequest": {
"Scheme": ""
},
@ -87,5 +121,10 @@
},
"task": {
"enable": false
},
"led": {
"enable": false,
"ip": "127.0.0.1",
"port": 10021
}
}
}

@ -121,5 +121,10 @@
},
"task": {
"enable": true
},
"led": {
"enable": false,
"ip": "127.0.0.1",
"port": 10021
}
}

Loading…
Cancel
Save