From 1a1660644344d953f8a4dd2fd11246ede4bb9c0b Mon Sep 17 00:00:00 2001
From: xiaolipro <2357729423@qq.com>
Date: Fri, 20 Sep 2024 15:07:58 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E5=89=8D=E7=AB=AF=E8=BD=A8?=
=?UTF-8?q?=E8=BF=B9=E9=A2=84=E8=AD=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dtos/Forewarning/UpdateWarningInput.cs | 4 +-
.../Dtos/Forewarning/WarningNitifyDto.cs | 20 ++++---
.../Forewarning/WarningNotifyCacheEntry.cs | 2 +-
.../EventHandlers/TrackDeleteEventHandler.cs | 6 ++-
.../Helpers/ForewarningHelper.cs | 6 +--
.../Options/TrackAppOptions.cs | 5 ++
.../ForewarningNotifyService.cs | 52 ++++++++++++-------
.../ForewarningServices/ForewarningService.cs | 3 +-
.../TrackOrders/OrderWarningService.cs | 9 ++--
.../Forewarning/RuleTrackStateDtoValidator.cs | 2 +-
.../WarningNotifyEntity.cs | 8 +--
.../WarningRecordIndex.cs | 26 ++++++++--
.../ITrackDetailsEsRepository.cs | 2 +-
.../Forewarning/GetOrderWarningPageListVo.cs | 8 +--
.../Forewarning/GetOrderWarningPageOutput.cs | 10 ++++
.../Dtos/Forewarning/GetWarningNotifiesVo.cs | 34 ++++++++----
.../Queries/WarningQueries.cs | 13 ++---
.../Repositories/TrackDetailsEsRepository.cs | 4 +-
.../Repositories/WarningRecordEsRepository.cs | 9 ++--
.../Repositories/WarningRepository.cs | 2 +-
20 files changed, 146 insertions(+), 79 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/UpdateWarningInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/UpdateWarningInput.cs
index 6cc4f428..c8db8908 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/UpdateWarningInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/UpdateWarningInput.cs
@@ -26,9 +26,9 @@ public class NotifyDto
public int Id { get; set; }
///
- /// 通知人id
+ /// 通知人
///
- public List NotifyUserIds { get; set; }
+ public List NotifyUsers { get; set; }
///
/// 通知方式(1站内信,2飞书)
diff --git a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNitifyDto.cs b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNitifyDto.cs
index 9c148ec4..995a76f2 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNitifyDto.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNitifyDto.cs
@@ -22,18 +22,26 @@ public class WarningNotifyDto
///
public string EndTrackStatus { get; set; } = null!;
- ///
- /// 通知人id
- ///
- public List NotifyUserIds { get; set; }
-
///
/// 通知人
///
- public List NotifyUsers { get; set; }
+ public List NotifyUsers { get; set; }
///
/// 通知方式(1站内信,2飞书)
///
public List NotifyModes { get; set; }
}
+
+public class NotifyUser
+{
+ ///
+ /// 用户id
+ ///
+ public int UserId { get; set; }
+
+ ///
+ /// 用户名
+ ///
+ public string UserName { get; set; }
+}
diff --git a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNotifyCacheEntry.cs b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNotifyCacheEntry.cs
index 835d3aea..feb0de06 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNotifyCacheEntry.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNotifyCacheEntry.cs
@@ -28,7 +28,7 @@ public class WarningNotifyCacheEntry
public int OrderId { get; set; }
///
- /// 预警次数
+ /// 预警次数(第几次)
///
public int Counter { get; set; }
diff --git a/src/SJZY.Track.Application/CAP/EventHandlers/TrackDeleteEventHandler.cs b/src/SJZY.Track.Application/CAP/EventHandlers/TrackDeleteEventHandler.cs
index 8d4298a9..127305ac 100644
--- a/src/SJZY.Track.Application/CAP/EventHandlers/TrackDeleteEventHandler.cs
+++ b/src/SJZY.Track.Application/CAP/EventHandlers/TrackDeleteEventHandler.cs
@@ -107,9 +107,11 @@ public class TrackDeleteEventHandler : ITransientDependency, ICapSubscribe
// 删除轨迹(删的是同子系统下的单,所以code是统一的)
var tracks = await _trackDetailsEsRepository.GetLatestListAsync(@event.OrderIds, @event.TrackCodes);
- await _trackDetailsEsRepository.DeleteTrackAsync(@event.OrderIds, @event.TrackCodes);
+ var orderIds = await _trackDetailsEsRepository.DeleteTrackAsync(@event.OrderIds, @event.TrackCodes);
- var orders = await _orderRepository.GetListAsync(x => @event.OrderIds.Contains(x.Id),
+ if (orderIds.Count == 0) return;
+
+ var orders = await _orderRepository.GetListAsync(x => orderIds.Contains(x.Id),
x => new OrderEntity
{
Id = x.Id,
diff --git a/src/SJZY.Track.Application/Helpers/ForewarningHelper.cs b/src/SJZY.Track.Application/Helpers/ForewarningHelper.cs
index 74a9dcc2..455392c6 100644
--- a/src/SJZY.Track.Application/Helpers/ForewarningHelper.cs
+++ b/src/SJZY.Track.Application/Helpers/ForewarningHelper.cs
@@ -160,8 +160,7 @@ public class ForewarningHelper
StartTrackStatusId = x.StartTrackStatusId,
EndTrackStatusId = x.EndTrackStatusId,
NotifyMode = x.NotifyModes.JoinAsString(","),
- NotifyUser = x.NotifyUsers.JoinAsString(","),
- NotifyUserId = x.NotifyUserIds.JoinAsString(","),
+ NotifyUser = x.NotifyUsers.ToJson(),
}).ToList();
}
@@ -180,8 +179,7 @@ public class ForewarningHelper
StartTrackStatus = statusDic.TryGetValue(x.StartTrackStatusId, out var start) ? start : "",
EndTrackStatusId = x.EndTrackStatusId,
EndTrackStatus = statusDic.TryGetValue(x.EndTrackStatusId, out var end) ? end : "",
- NotifyUserIds = x.NotifyUserId.Split(',').Select(int.Parse).ToList(),
- NotifyUsers = x.NotifyUser.Split(',').ToList(),
+ NotifyUsers = JsonConvert.DeserializeObject>(x.NotifyUser) ?? new List(),
NotifyModes = x.NotifyMode.Split(',').Select(int.Parse).ToList(),
}).ToList(),
WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto
diff --git a/src/SJZY.Track.Application/Options/TrackAppOptions.cs b/src/SJZY.Track.Application/Options/TrackAppOptions.cs
index 423e3fc2..12b93bf8 100644
--- a/src/SJZY.Track.Application/Options/TrackAppOptions.cs
+++ b/src/SJZY.Track.Application/Options/TrackAppOptions.cs
@@ -16,4 +16,9 @@ public class TrackAppOptions
/// 轨迹兜底扫描间隔(秒)
///
public int TrackButtomUpScanInterval { get; set; }
+
+ ///
+ /// 轨迹运输时效预警通知跳转地址
+ ///
+ public string WarningNotifyUrl { get; set; }
}
diff --git a/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningNotifyService.cs b/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningNotifyService.cs
index ebde1321..a92e45c2 100644
--- a/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningNotifyService.cs
+++ b/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningNotifyService.cs
@@ -1,9 +1,11 @@
using System.Text;
using FreeRedis;
+using Microsoft.Extensions.Options;
using SJZY.Expand.ABP.Core;
using SJZY.Expand.ABP.Core.Logger;
using SJZY.Track.Application.Contract.Dtos.Forewarning;
using SJZY.Track.Application.Contract.Services;
+using SJZY.Track.Application.Options;
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Domain.Enums;
@@ -22,6 +24,7 @@ namespace SJZY.Track.Application.Services.ForewarningServices;
public class ForewarningNotifyService : IForewarningNotifyService, ITransientDependency
{
private readonly IForewarningCacheService _forewarningCacheService;
+ private readonly IOptionsSnapshot _options;
private readonly IHttpClientProxy _requestSendMessageService;
private readonly IWarningQueries _warningQueries;
private readonly IWarningRecordEsRepository _warningRecordEsRepository;
@@ -29,12 +32,13 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
public ForewarningNotifyService(IWarningQueries warningQueries,
IWarningRecordEsRepository warningRecordEsRepository,
IHttpClientProxy requestSendMessageService,
- IForewarningCacheService forewarningCacheService)
+ IForewarningCacheService forewarningCacheService, IOptionsSnapshot options)
{
_warningQueries = warningQueries;
_warningRecordEsRepository = warningRecordEsRepository;
_requestSendMessageService = requestSendMessageService;
_forewarningCacheService = forewarningCacheService;
+ _options = options;
}
@@ -147,19 +151,26 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
{
var rule = notifyRules.FirstOrDefault(x => x.RuleId == entry.RuleId);
if (rule == null) continue;
- warningRecords.Add(new WarningRecordIndex
+
+ foreach (var notifyUser in rule.NotifyUsers)
{
- SubSystemId = rule.SubSystemId,
- WarningName = rule.WarningName,
- CustomName = rule.CustomName,
- RuleId = entry.RuleId,
- Rule = rule.ToString(),
- Counter = entry.Counter,
- OrderId = entry.OrderId,
- WarningStatus = WarningStatus.UnProcessed,
- NotifyUser = rule.NotifyUser,
- CreateTime = DateTime.Now,
- });
+ warningRecords.Add(new WarningRecordIndex
+ {
+ SubSystemId = rule.SubSystemId,
+ SubSystemName = rule.SubSystemName,
+ WarningName = rule.WarningName,
+ CustomName = rule.CustomName,
+ RuleId = entry.RuleId,
+ Rule = rule.ToString(),
+ Counter = entry.Counter,
+ IsLast = rule.WarnCount == entry.Counter,
+ OrderId = entry.OrderId,
+ WarningStatus = WarningStatus.UnProcessed,
+ NotifyUserId = notifyUser.UserId,
+ NotifyUserName = notifyUser.UserName,
+ CreateTime = DateTime.Now,
+ });
+ }
}
await _warningRecordEsRepository.BulkInsertAsync(warningRecords);
@@ -172,20 +183,20 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
var userRules = new Dictionary>();
foreach (var rule in notifyRules)
{
- foreach (var userId in rule.NotifyUserIds)
+ foreach (var notifyUser in rule.NotifyUsers)
{
- if (!userRules.ContainsKey(userId))
+ if (!userRules.ContainsKey(notifyUser.UserId))
{
- userRules[userId] = new List();
+ userRules[notifyUser.UserId] = new List();
}
- userRules[userId].Add(rule);
+ userRules[notifyUser.UserId].Add(rule);
}
}
+ // 以人的维度发送通知,异步
foreach (var userRule in userRules)
{
- // 以人的维度发送通知,异步
_ = DoNotifyAsync(subSystemId, userRule.Key, userRule.Value, entries,
NotifyMode.SiteInternal);
_ = DoNotifyAsync(subSystemId, userRule.Key, userRule.Value, entries, NotifyMode.FeiShu);
@@ -214,7 +225,8 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
*/
var notifyContent = new StringBuilder();
- foreach (var warningGroup in rules.Where(x => x.NotifyModes.Contains(mode))
+ foreach (var warningGroup in rules
+ .Where(x => x.NotifyMode.Split(',').Select(Enum.Parse).Contains(mode))
.GroupBy(x => x.WarningName))
{
notifyContent.AppendLine($"预警名称:{warningGroup.Key}");
@@ -224,7 +236,7 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
{
var cnt = entries.Count(x => x.RuleId == rule.RuleId);
notifyContent.AppendLine(
- $"{rule.ToString()} 命中订单总数:{cnt},详情点击https://middlebusiness.pet.shijizhongyun.com/trajectoryCenter/trajectoryOrder");
+ $"{rule.ToString()} 命中订单总数:{cnt},详情点击{_options.Value.WarningNotifyUrl}?userId={userId}");
}
}
diff --git a/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningService.cs b/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningService.cs
index d0698568..6a1a2a9d 100644
--- a/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningService.cs
+++ b/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningService.cs
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
+using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.Forewarning;
using SJZY.Track.Application.Contract.Services;
using SJZY.Track.Application.Helpers;
@@ -114,7 +115,7 @@ public class ForewarningService : ApplicationService
{
Id = x.Id,
NotifyMode = x.NotifyModes.JoinAsString(","),
- NotifyUserId = x.NotifyUserIds.JoinAsString(","),
+ NotifyUser = x.NotifyUsers.ToJson(),
}).ToList();
await _warningRepository.UpdateForewarningAsync(warning);
diff --git a/src/SJZY.Track.Application/Services/TrackOrders/OrderWarningService.cs b/src/SJZY.Track.Application/Services/TrackOrders/OrderWarningService.cs
index ccedce6c..06decd7c 100644
--- a/src/SJZY.Track.Application/Services/TrackOrders/OrderWarningService.cs
+++ b/src/SJZY.Track.Application/Services/TrackOrders/OrderWarningService.cs
@@ -33,11 +33,13 @@ public class OrderWarningService : ApplicationService
/// 获取订单运输时效预警分页列表
///
///
+ ///
///
[HttpPost("GetOrderWarningPageList")]
public async Task> GetOrderWarningPageListAsync(
- GetOrderWarningPageListVo inputVo)
+ [FromBody] GetOrderWarningPageListVo inputVo, [FromQuery] int? userId)
{
+ if (userId != null) inputVo.NotifyUserId = userId;
var result = await _warningRecordEsRepository.GetOrderWarningPageListAsync(inputVo);
var orderIds = result.list.Select(x => x.OrderId).ToList();
var orders = await _orderRepository.GetListAsync(x => orderIds.Contains(x.Id), x => new
@@ -51,17 +53,18 @@ public class OrderWarningService : ApplicationService
var list = new List();
-
result.list.ForEach(x =>
{
var item = new GetOrderWarningPageOutput
{
+ SubSystemName = x.SubSystemName,
Rule = x.Rule,
Counter = x.Counter,
+ IsLast = x.IsLast,
WarningName = x.WarningName,
WarningStatus = x.WarningStatus,
CreateTime = x.CreateTime,
- NotifyUser = x.NotifyUser,
+ NotifyUser = x.NotifyUserName,
CustomName = x.CustomName,
};
var order = orders.FirstOrDefault(o => o.Id == x.OrderId);
diff --git a/src/SJZY.Track.Application/Validations/Forewarning/RuleTrackStateDtoValidator.cs b/src/SJZY.Track.Application/Validations/Forewarning/RuleTrackStateDtoValidator.cs
index 6bfa03d9..cde7aee8 100644
--- a/src/SJZY.Track.Application/Validations/Forewarning/RuleTrackStateDtoValidator.cs
+++ b/src/SJZY.Track.Application/Validations/Forewarning/RuleTrackStateDtoValidator.cs
@@ -10,6 +10,6 @@ public class RuleTrackStateDtoValidator : AbstractValidator
RuleFor(x => x.StartTrackStatusId).GreaterThan(0).WithMessage("起始轨迹状态id必须大于0");
RuleFor(x => x.EndTrackStatusId).GreaterThan(0).WithMessage("终止轨迹状态id必须大于0");
RuleFor(x => x.NotifyModes).NotEmpty().WithMessage("通知方式不能为空");
- RuleFor(x => x.NotifyUserIds).NotEmpty().WithMessage("通知对象不能为空");
+ RuleFor(x => x.NotifyUsers).NotEmpty().WithMessage("通知对象不能为空");
}
}
diff --git a/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningNotifyEntity.cs b/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningNotifyEntity.cs
index b26722fe..d0de3ab7 100644
--- a/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningNotifyEntity.cs
+++ b/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningNotifyEntity.cs
@@ -34,13 +34,7 @@ public class WarningNotifyEntity : IFullAuditedBasicEntitys, IEntity
public string NotifyMode { get; set; }
///
- /// 通知人id,多个逗号分隔
- ///
- [SugarColumn(ColumnName = "NotifyUserId")]
- public string NotifyUserId { get; set; }
-
- ///
- /// 通知人,多个逗号分隔
+ /// 通知人,json格式 多个
///
[SugarColumn(ColumnName = "NotifyUser")]
public string NotifyUser { get; set; }
diff --git a/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningRecordIndex.cs b/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningRecordIndex.cs
index 50bfbb37..c7305d1c 100644
--- a/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningRecordIndex.cs
+++ b/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningRecordIndex.cs
@@ -8,10 +8,15 @@ namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
public class WarningRecordIndex : IdBaseIndex
{
///
- /// 子系统
+ /// 子系统id
///
public int SubSystemId { get; set; }
+ ///
+ /// 子系统name
+ ///
+ public string SubSystemName { get; set; }
+
///
/// 索引名称
///
@@ -22,6 +27,11 @@ public class WarningRecordIndex : IdBaseIndex
///
public string WarningName { get; set; } = null!;
+ ///
+ /// 客户id
+ ///
+ public int CustomId { get; set; }
+
///
/// 客户简称
///
@@ -47,15 +57,25 @@ public class WarningRecordIndex : IdBaseIndex
///
public int Counter { get; set; }
+ ///
+ /// 是否最后一次
+ ///
+ public bool IsLast { get; set; }
+
///
/// 预警状态
///
public WarningStatus WarningStatus { get; set; }
///
- /// 通知用户
+ /// 通知用户name
///
- public string NotifyUser { get; set; }
+ public string NotifyUserName { get; set; }
+
+ ///
+ /// 通知用户id
+ ///
+ public int NotifyUserId { get; set; }
///
/// 创建时间
diff --git a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsEsRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsEsRepository.cs
index 37e3d1d2..b52f5f20 100644
--- a/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsEsRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/TrackDetailsAggregate/ITrackDetailsEsRepository.cs
@@ -22,7 +22,7 @@ public interface ITrackDetailsEsRepository : IElasticsearchClientService> GetListAsync(int orderId);
- Task DeleteTrackAsync(int[] orderIds, List trackCodes);
+ Task> DeleteTrackAsync(int[] orderIds, List trackCodes);
Task DeleteTrackByIdAsync(string id, string indexName);
}
diff --git a/src/SJZY.Track.Domain/Dtos/Forewarning/GetOrderWarningPageListVo.cs b/src/SJZY.Track.Domain/Dtos/Forewarning/GetOrderWarningPageListVo.cs
index 0378857f..557fddca 100644
--- a/src/SJZY.Track.Domain/Dtos/Forewarning/GetOrderWarningPageListVo.cs
+++ b/src/SJZY.Track.Domain/Dtos/Forewarning/GetOrderWarningPageListVo.cs
@@ -22,9 +22,9 @@ public class GetOrderWarningPageListVo : PageInfoInput
public WarningStatus? WarningStatus { get; set; }
///
- /// 客户简称
+ /// 客户id
///
- public string? CustomName { get; set; }
+ public int? CustomId { get; set; }
///
/// 预警名称
@@ -32,9 +32,9 @@ public class GetOrderWarningPageListVo : PageInfoInput
public string? WarningName { get; set; }
///
- /// 通知用户
+ /// 通知用户id
///
- public string? NotifyUser { get; set; }
+ public int? NotifyUserId { get; set; }
///
/// 创建时间开始
diff --git a/src/SJZY.Track.Domain/Dtos/Forewarning/GetOrderWarningPageOutput.cs b/src/SJZY.Track.Domain/Dtos/Forewarning/GetOrderWarningPageOutput.cs
index 511e2cbc..9528a056 100644
--- a/src/SJZY.Track.Domain/Dtos/Forewarning/GetOrderWarningPageOutput.cs
+++ b/src/SJZY.Track.Domain/Dtos/Forewarning/GetOrderWarningPageOutput.cs
@@ -4,6 +4,11 @@ namespace SJZY.Track.Domain.Dtos.Forewarning;
public class GetOrderWarningPageOutput
{
+ ///
+ /// 子系统name
+ ///
+ public string SubSystemName { get; set; }
+
///
/// 预警名称
///
@@ -24,6 +29,11 @@ public class GetOrderWarningPageOutput
///
public int Counter { get; set; }
+ ///
+ /// 是否最后一次
+ ///
+ public bool IsLast { get; set; }
+
///
/// 预警状态
///
diff --git a/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs b/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs
index 793f526a..e5bf5290 100644
--- a/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs
+++ b/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs
@@ -7,10 +7,15 @@ namespace SJZY.Track.Domain.Dtos.Forewarning;
public class GetWarningNotifiesVo
{
///
- /// 子系统
+ /// 子系统id
///
public int SubSystemId { get; set; }
+ ///
+ /// 子系统name
+ ///
+ public string SubSystemName { get; set; }
+
///
/// 规则 id
///
@@ -37,7 +42,7 @@ public class GetWarningNotifiesVo
public float WarnTimeSpan { get; set; }
///
- /// 提醒次数
+ /// 提醒次数(总次数)
///
public int WarnCount { get; set; }
@@ -82,21 +87,17 @@ public class GetWarningNotifiesVo
public string? ProductCode { get; set; }
///
- /// 通知方式
+ /// 通知方式(多个逗号拼接)
///
public string NotifyMode { get; set; }
- public List NotifyModes { get; set; }
-
///
- /// 通知人
+ /// 通知用户(json多个)
///
- public string NotifyUserId { get; set; }
-
- public List NotifyUserIds { get; set; }
-
public string NotifyUser { get; set; }
+ public List NotifyUsers { get; set; }
+
///
/// 因素类型排序
///
@@ -140,3 +141,16 @@ public class GetWarningNotifiesVo
return res.ToString();
}
}
+
+public class NotifyUserVo
+{
+ ///
+ /// 用户id
+ ///
+ public int UserId { get; set; }
+
+ ///
+ /// 用户名
+ ///
+ public string UserName { get; set; }
+}
diff --git a/src/SJZY.Track.Repository/Queries/WarningQueries.cs b/src/SJZY.Track.Repository/Queries/WarningQueries.cs
index fa7ecc09..dbc92f75 100644
--- a/src/SJZY.Track.Repository/Queries/WarningQueries.cs
+++ b/src/SJZY.Track.Repository/Queries/WarningQueries.cs
@@ -1,7 +1,7 @@
+using Newtonsoft.Json;
using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
using SJZY.Track.Domain.Dtos.Forewarning;
-using SJZY.Track.Domain.Enums;
using SJZY.Track.Domain.Queries;
using SJZY.Track.Domain.VEntities;
@@ -21,11 +21,13 @@ public class WarningQueries : ISugarRepository, IWarningQueries,
wr.WarningId == wn.WarningId && wr.StartTrackStatusId == wn.StartTrackStatusId &&
wr.EndTrackStatusId == wn.EndTrackStatusId)
.LeftJoin((w, wr, a, wn, cus) => w.CustomerId == cus.Id)
+ .LeftJoin((w, wr, a, wn, cus, system) => w.SubSystemId == system.Id)
.Filter(null, true) // 支持历史规则
.Where((w, wr) => ruleIds.Contains(wr.Id))
- .Select((w, wr, a, wn, cus) => new GetWarningNotifiesVo
+ .Select((w, wr, a, wn, cus, system) => new GetWarningNotifiesVo
{
SubSystemId = w.SubSystemId,
+ SubSystemName = system.CnName,
RuleId = wr.Id,
WarningName = w.Name,
CustomName = cus.Name,
@@ -42,13 +44,12 @@ public class WarningQueries : ISugarRepository, IWarningQueries,
ProductCode = wr.ProductCode,
NotifyMode = wn.NotifyMode,
NotifyUser = wn.NotifyUser,
- NotifyUserId = wn.NotifyUserId,
FactorTypeSort = w.FactorTypeSort
})
- .Mapper(x =>
+ .Mapper(rule =>
{
- x.NotifyModes = x.NotifyMode.Split(',').Select(Enum.Parse).ToList();
- x.NotifyUserIds = x.NotifyUserId.Split(',').Select(int.Parse).ToList();
+ rule.NotifyUsers = JsonConvert.DeserializeObject>(rule.NotifyUser) ??
+ new List();
})
.ToListAsync();
}
diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsEsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsEsRepository.cs
index 09644e01..d7775fd8 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackDetailsEsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsEsRepository.cs
@@ -296,7 +296,7 @@ public class TrackDetailsEsRepository : ElasticSearchContextAbstract trackCodes)
+ public async Task> DeleteTrackAsync(int[] orderIds, List trackCodes)
{
// var deleteResponse = await Context.DeleteByQueryAsync(d => d
// .Index($"{GlobalConst.TrackDetailsIndex}-*") // 使用通配符匹配所有相关索引
@@ -345,6 +345,8 @@ public class TrackDetailsEsRepository : ElasticSearchContextAbstract x.OrderId).ToList();
}
public async Task DeleteTrackByIdAsync(string id, string indexName)
diff --git a/src/SJZY.Track.Repository/Repositories/WarningRecordEsRepository.cs b/src/SJZY.Track.Repository/Repositories/WarningRecordEsRepository.cs
index a3ffd54e..04db2769 100644
--- a/src/SJZY.Track.Repository/Repositories/WarningRecordEsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/WarningRecordEsRepository.cs
@@ -78,15 +78,11 @@ public class WarningRecordEsRepository : ElasticSearchContextAbstract f.WarningStatus, input.WarningStatus) : null)
- && (!input.CustomName.IsNullOrWhiteSpace()
- ? q.Wildcard(w => w.CustomName, $"*{input.CustomName}*")
- : null)
+ && (input.CustomId.HasValue ? q.Term(f => f.CustomId, input.CustomId) : null)
&& (!input.WarningName.IsNullOrWhiteSpace()
? q.Wildcard(w => w.WarningName, $"*{input.WarningName}*")
: null)
- && (!input.NotifyUser.IsNullOrWhiteSpace()
- ? q.Wildcard(w => w.NotifyUser, $"*{input.NotifyUser}*")
- : null)
+ && (input.NotifyUserId.HasValue ? q.Term(f => f.NotifyUserId, input.NotifyUserId) : null)
&& (input.StartTime.HasValue
? q.DateRange(r => r.Field(f => f.CreateTime).GreaterThanOrEquals(input.StartTime))
: null)
@@ -97,6 +93,7 @@ public class WarningRecordEsRepository : ElasticSearchContextAbstract(x => x
.Index(GlobalConst.TrackWarningRecordIndex)
.Source()
+ .Query(query)
.Sort(s => s.Field(f => f.CreateTime, SortOrder.Descending))
.From((input.PageIndex - 1) * input.PageSize)
.Size(input.PageSize)
diff --git a/src/SJZY.Track.Repository/Repositories/WarningRepository.cs b/src/SJZY.Track.Repository/Repositories/WarningRepository.cs
index ef384d6c..c5fc88a2 100644
--- a/src/SJZY.Track.Repository/Repositories/WarningRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/WarningRepository.cs
@@ -87,7 +87,7 @@ public class WarningRepository : BasicRepository, IWarningReposit
.UpdateColumns(x => new
{
x.NotifyMode,
- x.NotifyUserId,
+ x.NotifyUser,
x.UpdateTime,
x.UpdateUserId
})