fix:轨迹推送事件处理:修复轨迹全量推送(最新轨迹)字段比较问题

This commit is contained in:
hardstylewyl 2025-01-13 16:11:08 +08:00
parent 8ca0adfbd3
commit a517eae81f

View File

@ -356,14 +356,22 @@ public class TrackPushEventHandler : ITransientDependency, ICapSubscribe
body = DeserializeForTextJson<TrackPushInput>(history.PushContent);
if (config.IsAllPushWithLatest)
{
//同code同比较字段保证唯一
var old = body!.Data
.Where(x => x["code"] == cur["code"])
.WhereIf(!compareFields.IsNullOrWhiteSpace(), x =>
.Where(x =>
{
//反序列化出的JsonElement和字典字符串类型做比较
var a = ((JsonElement) x["code"]!).GetString();
var b = cur["code"]!.ToString(); //tips: 需要要将object类型的字符串转为string类型,否则使用的是引用比较,反序列化出的string一定和本地string引用不同
return a == b;
}).WhereIf(!compareFields.IsNullOrWhiteSpace(), x =>
{
if (x["extra"] == null || log.Extra == null) return false;
return EqExtraByFieldForTextJson(x["extra"]!, DeserializeForTextJson<JsonElement>(log.Extra)!, compareFields!);
return EqExtraByFieldForTextJson(x["extra"]!, DeserializeForTextJson<JsonElement>(log.Extra), compareFields!);
})
.FirstOrDefault();
if (old != null)
{
body.Data.Remove(old);