使用DataHash验证消息重复
This commit is contained in:
parent
10ca96e5c1
commit
510cde319f
|
|
@ -195,7 +195,7 @@ namespace Waste.Application
|
||||||
public int Len { get; set; } = 0;
|
public int Len { get; set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IMEI
|
/// IMEI/设备编号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string IMEI { get; set; } = string.Empty;
|
public string IMEI { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
@ -337,6 +337,7 @@ namespace Waste.Application
|
||||||
public string ID6 { get; set; } = string.Empty;
|
public string ID6 { get; set; } = string.Empty;
|
||||||
public string ID7 { get; set; } = string.Empty;
|
public string ID7 { get; set; } = string.Empty;
|
||||||
public string ID8 { get; set; } = string.Empty;
|
public string ID8 { get; set; } = string.Empty;
|
||||||
|
public string DataHash { get; set; } = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -468,6 +468,9 @@ namespace Waste.Application
|
||||||
ID6 = myPackage.ID6,
|
ID6 = myPackage.ID6,
|
||||||
ID7 = myPackage.ID7,
|
ID7 = myPackage.ID7,
|
||||||
ID8 = myPackage.ID8,
|
ID8 = myPackage.ID8,
|
||||||
|
|
||||||
|
CreatedTime = DateTime.Now,
|
||||||
|
DataHash = myPackage.DataHash
|
||||||
}).ExecuteCommandAsync();
|
}).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
await SendMessageToThird(new SendThirdMessageSubscribeS2SDto
|
await SendMessageToThird(new SendThirdMessageSubscribeS2SDto
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,9 @@ namespace Waste.Application.SubscribeInfo
|
||||||
var services = scope.ServiceProvider;
|
var services = scope.ServiceProvider;
|
||||||
var mresultrep = services.GetService<ISqlSugarRepository<W_MeasureResult>>();
|
var mresultrep = services.GetService<ISqlSugarRepository<W_MeasureResult>>();
|
||||||
//如果uuid不为空,并且以存在记录,则忽略
|
//如果uuid不为空,并且以存在记录,则忽略
|
||||||
if (!myPackage.IsHeart && !myPackage.UUID.IsEmpty() && await mresultrep.AnyAsync(x => x.UUID == myPackage.UUID))
|
if (!myPackage.IsHeart && !myPackage.UUID.IsEmpty() && await mresultrep
|
||||||
|
.Where(x => x.CreatedTime > DateTime.Now.AddMinutes(-1) && x.DataHash == myPackage.DataHash)//1分钟内不能重复
|
||||||
|
.AnyAsync())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1764,7 +1764,7 @@
|
||||||
</member>
|
</member>
|
||||||
<member name="P:Waste.Application.MyPackage.IMEI">
|
<member name="P:Waste.Application.MyPackage.IMEI">
|
||||||
<summary>
|
<summary>
|
||||||
IMEI
|
IMEI/设备编号
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:Waste.Application.MyPackage.ICCID">
|
<member name="P:Waste.Application.MyPackage.ICCID">
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,11 @@ namespace Waste.Domain
|
||||||
[SugarColumn(ColumnDescription = "操作员", ColumnDataType = "nvarchar(100)")]
|
[SugarColumn(ColumnDescription = "操作员", ColumnDataType = "nvarchar(100)")]
|
||||||
public string OpUser { get; set; }
|
public string OpUser { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 唯一消息ID
|
/// 消息ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "唯一消息ID", ColumnDataType = "varchar(50)",IndexGroupNameList =new string[] { "index_uuid"})]
|
[SugarColumn(ColumnDescription = "消息ID", ColumnDataType = "varchar(50)",IndexGroupNameList =new string[] { "index_uuid"})]
|
||||||
public string UUID { get; set; }
|
public string UUID { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备出厂序列号/设备出厂编号
|
/// 设备出厂序列号/设备出厂编号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -73,5 +72,7 @@ namespace Waste.Domain
|
||||||
public string ID6 { get; set; }
|
public string ID6 { get; set; }
|
||||||
public string ID7 { get; set; }
|
public string ID7 { get; set; }
|
||||||
public string ID8 { get; set; }
|
public string ID8 { get; set; }
|
||||||
|
public DateTime? CreatedTime { get; set; }
|
||||||
|
public string DataHash { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Waste.SocketService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Len { get; set; } = 0;
|
public int Len { get; set; } = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IMEI
|
/// IMEI/设备编号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string IMEI { get; set; } = "";
|
public string IMEI { get; set; } = "";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -146,5 +146,6 @@ namespace Waste.SocketService
|
||||||
public string ID6 { get; set; }
|
public string ID6 { get; set; }
|
||||||
public string ID7 { get; set; }
|
public string ID7 { get; set; }
|
||||||
public string ID8 { get; set; }
|
public string ID8 { get; set; }
|
||||||
|
public string DataHash { get; set; } = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Furion.DataEncryption.Extensions;
|
||||||
|
|
||||||
namespace Waste.SocketService
|
namespace Waste.SocketService
|
||||||
{
|
{
|
||||||
|
|
@ -144,6 +145,7 @@ namespace Waste.SocketService
|
||||||
_logger.Information(msg);
|
_logger.Information(msg);
|
||||||
if (package.Key == "A8")
|
if (package.Key == "A8")
|
||||||
{
|
{
|
||||||
|
package.DataHash = $"{package.Str}".ToMD5Encrypt();
|
||||||
await _capBus.PublishAsync("result.service.inserta84g", package);
|
await _capBus.PublishAsync("result.service.inserta84g", package);
|
||||||
if (!session.Channel.IsClosed)
|
if (!session.Channel.IsClosed)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,11 @@ namespace Waste.Web.Entry
|
||||||
new string('-', 50);//输出模板
|
new string('-', 50);//输出模板
|
||||||
///1.输出所有restrictedToMinimumLevel:LogEventLevel类型
|
///1.输出所有restrictedToMinimumLevel:LogEventLevel类型
|
||||||
config
|
config
|
||||||
|
.Enrich.WithProperty("Application", typeof(Program).Assembly.GetName().Name)
|
||||||
|
.Enrich.WithProcessId()
|
||||||
|
.Enrich.WithProcessName()
|
||||||
|
.Enrich.WithMachineName()
|
||||||
|
.Enrich.WithEnvironmentUserName()
|
||||||
.WriteTo.Seq("http://localhost:5341/")
|
.WriteTo.Seq("http://localhost:5341/")
|
||||||
//.MinimumLevel.Debug() // 所有Sink的最小记录级别
|
//.MinimumLevel.Debug() // 所有Sink的最小记录级别
|
||||||
//.MinimumLevel.Override("Microsoft", LogEventLevel.Fatal)
|
//.MinimumLevel.Override("Microsoft", LogEventLevel.Fatal)
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,13 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
||||||
|
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Waste.Web.Core\Waste.Web.Core.csproj" />
|
<ProjectReference Include="..\Waste.Web.Core\Waste.Web.Core.csproj" />
|
||||||
|
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue