From 510cde319fa7caba1d215afd753fa15175ed79fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E9=B9=8F?= <304594656@qq.com>
Date: Fri, 20 Dec 2024 17:12:42 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8DataHash=E9=AA=8C=E8=AF=81?=
=?UTF-8?q?=E6=B6=88=E6=81=AF=E9=87=8D=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Waste.Application/ResultInfos/Dtos/ResultDto.cs | 3 ++-
Waste.Application/ResultInfos/ResultService.cs | 3 +++
Waste.Application/SubscribeInfo/SubscribeService.cs | 4 +++-
Waste.Application/Waste.Application.xml | 2 +-
Waste.Domain/DataModel/W_MeasureResult.cs | 7 ++++---
Waste.SocketService.cs/MyPackage.cs | 3 ++-
Waste.SocketService.cs/Program.cs | 2 ++
Waste.Web.Entry/Program.cs | 5 +++++
Waste.Web.Entry/Waste.Web.Entry.csproj | 3 +++
9 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/Waste.Application/ResultInfos/Dtos/ResultDto.cs b/Waste.Application/ResultInfos/Dtos/ResultDto.cs
index d55274c..5697cee 100644
--- a/Waste.Application/ResultInfos/Dtos/ResultDto.cs
+++ b/Waste.Application/ResultInfos/Dtos/ResultDto.cs
@@ -195,7 +195,7 @@ namespace Waste.Application
public int Len { get; set; } = 0;
///
- /// IMEI
+ /// IMEI/设备编号
///
public string IMEI { get; set; } = string.Empty;
@@ -337,6 +337,7 @@ namespace Waste.Application
public string ID6 { get; set; } = string.Empty;
public string ID7 { get; set; } = string.Empty;
public string ID8 { get; set; } = string.Empty;
+ public string DataHash { get; set; } = "";
}
///
diff --git a/Waste.Application/ResultInfos/ResultService.cs b/Waste.Application/ResultInfos/ResultService.cs
index 6a81cec..803d54a 100644
--- a/Waste.Application/ResultInfos/ResultService.cs
+++ b/Waste.Application/ResultInfos/ResultService.cs
@@ -468,6 +468,9 @@ namespace Waste.Application
ID6 = myPackage.ID6,
ID7 = myPackage.ID7,
ID8 = myPackage.ID8,
+
+ CreatedTime = DateTime.Now,
+ DataHash = myPackage.DataHash
}).ExecuteCommandAsync();
}
await SendMessageToThird(new SendThirdMessageSubscribeS2SDto
diff --git a/Waste.Application/SubscribeInfo/SubscribeService.cs b/Waste.Application/SubscribeInfo/SubscribeService.cs
index 81442a4..79b5cde 100644
--- a/Waste.Application/SubscribeInfo/SubscribeService.cs
+++ b/Waste.Application/SubscribeInfo/SubscribeService.cs
@@ -308,7 +308,9 @@ namespace Waste.Application.SubscribeInfo
var services = scope.ServiceProvider;
var mresultrep = services.GetService>();
//如果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;
}
diff --git a/Waste.Application/Waste.Application.xml b/Waste.Application/Waste.Application.xml
index bb7ac0f..c32341e 100644
--- a/Waste.Application/Waste.Application.xml
+++ b/Waste.Application/Waste.Application.xml
@@ -1764,7 +1764,7 @@
- IMEI
+ IMEI/设备编号
diff --git a/Waste.Domain/DataModel/W_MeasureResult.cs b/Waste.Domain/DataModel/W_MeasureResult.cs
index 3f52799..58cfafb 100644
--- a/Waste.Domain/DataModel/W_MeasureResult.cs
+++ b/Waste.Domain/DataModel/W_MeasureResult.cs
@@ -39,12 +39,11 @@ namespace Waste.Domain
[SugarColumn(ColumnDescription = "操作员", ColumnDataType = "nvarchar(100)")]
public string OpUser { get; set; }
///
- /// 唯一消息ID
+ /// 消息ID
///
- [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; }
-
///
/// 设备出厂序列号/设备出厂编号
///
@@ -73,5 +72,7 @@ namespace Waste.Domain
public string ID6 { get; set; }
public string ID7 { get; set; }
public string ID8 { get; set; }
+ public DateTime? CreatedTime { get; set; }
+ public string DataHash { get; set; }
}
}
diff --git a/Waste.SocketService.cs/MyPackage.cs b/Waste.SocketService.cs/MyPackage.cs
index 35e22f5..4de9eb5 100644
--- a/Waste.SocketService.cs/MyPackage.cs
+++ b/Waste.SocketService.cs/MyPackage.cs
@@ -21,7 +21,7 @@ namespace Waste.SocketService
///
public int Len { get; set; } = 0;
///
- /// IMEI
+ /// IMEI/设备编号
///
public string IMEI { get; set; } = "";
///
@@ -146,5 +146,6 @@ namespace Waste.SocketService
public string ID6 { get; set; }
public string ID7 { get; set; }
public string ID8 { get; set; }
+ public string DataHash { get; set; } = "";
}
}
diff --git a/Waste.SocketService.cs/Program.cs b/Waste.SocketService.cs/Program.cs
index 8508d01..3f4c0c2 100644
--- a/Waste.SocketService.cs/Program.cs
+++ b/Waste.SocketService.cs/Program.cs
@@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Furion.DataEncryption.Extensions;
namespace Waste.SocketService
{
@@ -144,6 +145,7 @@ namespace Waste.SocketService
_logger.Information(msg);
if (package.Key == "A8")
{
+ package.DataHash = $"{package.Str}".ToMD5Encrypt();
await _capBus.PublishAsync("result.service.inserta84g", package);
if (!session.Channel.IsClosed)
{
diff --git a/Waste.Web.Entry/Program.cs b/Waste.Web.Entry/Program.cs
index d81e7a2..4920f1f 100644
--- a/Waste.Web.Entry/Program.cs
+++ b/Waste.Web.Entry/Program.cs
@@ -37,6 +37,11 @@ namespace Waste.Web.Entry
new string('-', 50);//ģ
///1.restrictedToMinimumLevelLogEventLevel
config
+ .Enrich.WithProperty("Application", typeof(Program).Assembly.GetName().Name)
+ .Enrich.WithProcessId()
+ .Enrich.WithProcessName()
+ .Enrich.WithMachineName()
+ .Enrich.WithEnvironmentUserName()
.WriteTo.Seq("http://localhost:5341/")
//.MinimumLevel.Debug() // SinkС¼
//.MinimumLevel.Override("Microsoft", LogEventLevel.Fatal)
diff --git a/Waste.Web.Entry/Waste.Web.Entry.csproj b/Waste.Web.Entry/Waste.Web.Entry.csproj
index 26406a3..c09d8ce 100644
--- a/Waste.Web.Entry/Waste.Web.Entry.csproj
+++ b/Waste.Web.Entry/Waste.Web.Entry.csproj
@@ -18,10 +18,13 @@
+
+
+