From 42bae65d384d9c873e66a8d6f2bbfa951ddb0ada Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Fri, 6 Sep 2024 17:32:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E9=80=9A=E7=9F=A5=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E4=BA=BA=E5=8D=95=E9=80=89=E5=8F=98=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E3=80=91=20https://www.tapd.cn/60863849/prong/tasks/v?= =?UTF-8?q?iew/1160863849001028431?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/Forewarning/CreateWarningInput.cs | 13 +------------ .../Dtos/Forewarning/EditWarningOutput.cs | 13 +------------ .../Dtos/Forewarning/UpdateWarningInput.cs | 18 ++++++------------ .../Dtos/Forewarning/WarningNitifyDto.cs | 13 ++++++++++--- .../Helpers/ForewarningHelper.cs | 12 ++++++------ .../ForewarningServices/ForewarningService.cs | 4 ++-- .../Forewarning/CreateRuleFactorValidation.cs | 3 --- .../Forewarning/RuleTrackStateDtoValidator.cs | 7 ++++--- .../WarningNotifyEntity.cs | 10 ++++------ .../Dtos/Forewarning/GetWarningNotifiesVo.cs | 11 +++++------ .../Queries/WarningQueries.cs | 13 +++++++------ 11 files changed, 46 insertions(+), 71 deletions(-) diff --git a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/CreateWarningInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/CreateWarningInput.cs index 1e6bb896..5bccbe1b 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/CreateWarningInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/CreateWarningInput.cs @@ -1,5 +1,4 @@ using SJZY.Track.Domain.Dtos.Forewarning; -using SJZY.Track.Share.Enums; namespace SJZY.Track.Application.Contract.Dtos.Forewarning; @@ -20,20 +19,10 @@ public class CreateWarningInput /// public int CustomerId { get; set; } - /// - /// 通知方式 - /// - public NotifyMode NotifyMode { get; set; } - - /// - /// 通知模板 - /// - public string NotifyTemplate { get; set; } = null!; - /// /// 轨迹状态跨度列表 /// - public List TrackStatusSpans { get; set; } = new(); + public List TrackStatusSpans { get; set; } = new(); /// /// 预警因素列表。 diff --git a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/EditWarningOutput.cs b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/EditWarningOutput.cs index e6dc14ec..644b78c6 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/EditWarningOutput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/EditWarningOutput.cs @@ -1,5 +1,4 @@ using SJZY.Track.Domain.Dtos.Forewarning; -using SJZY.Track.Share.Enums; namespace SJZY.Track.Application.Contract.Dtos.Forewarning; @@ -20,16 +19,6 @@ public class EditWarningOutput /// public int CustomerId { get; set; } - /// - /// 通知方式 - /// - public NotifyMode NotifyMode { get; set; } - - /// - /// 通知模板 - /// - public string NotifyTemplate { get; set; } = null!; - /// /// 通知列表 /// @@ -41,7 +30,7 @@ public class EditWarningOutput public List WarningFactors { get; set; } = new(); } -public class WarningNotifyWithIdDto : WarningNitifyDto +public class WarningNotifyWithIdDto : WarningNotifyDto { /// /// 通知id diff --git a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/UpdateWarningInput.cs b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/UpdateWarningInput.cs index cbc0a97e..d542ce1c 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/UpdateWarningInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/UpdateWarningInput.cs @@ -14,17 +14,6 @@ public class UpdateWarningInput /// public string Name { get; set; } = null!; - /// - /// 通知方式 - /// - public NotifyMode NotifyMode { get; set; } - - /// - /// 通知模板 - /// - public string NotifyTemplate { get; set; } = null!; - - /// /// 通知列表 /// @@ -41,5 +30,10 @@ public class NotifyDto /// /// 通知人id /// - public int NotifyUserId { get; set; } + public List NotifyUserIds { get; set; } + + /// + /// 通知方式 + /// + public List NotifyModes { get; set; } } diff --git a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNitifyDto.cs b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNitifyDto.cs index 6c89f28f..e743ae68 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNitifyDto.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/Forewarning/WarningNitifyDto.cs @@ -1,6 +1,8 @@ -namespace SJZY.Track.Domain.Dtos.Forewarning; +using SJZY.Track.Share.Enums; -public class WarningNitifyDto +namespace SJZY.Track.Application.Contract.Dtos.Forewarning; + +public class WarningNotifyDto { /// /// 起始轨迹状态id @@ -25,5 +27,10 @@ public class WarningNitifyDto /// /// 通知人id /// - public int NotifyUserId { get; set; } + public List NotifyUserIds { get; set; } + + /// + /// 通知方式 + /// + public List NotifyModes { get; set; } } diff --git a/src/SJZY.Track.Application/Helpers/ForewarningHelper.cs b/src/SJZY.Track.Application/Helpers/ForewarningHelper.cs index 835c9a32..9755e1a9 100644 --- a/src/SJZY.Track.Application/Helpers/ForewarningHelper.cs +++ b/src/SJZY.Track.Application/Helpers/ForewarningHelper.cs @@ -18,7 +18,7 @@ public class ForewarningHelper /// /// /// - public static List CalcRuleList(List statusSpans, + public static List CalcRuleList(List statusSpans, List factors) { if (statusSpans.Count == 0 || factors.Count == 0) @@ -52,7 +52,7 @@ public class ForewarningHelper return rules; } - private static void FillStatus(List statusSpans, List rules, int repeat) + private static void FillStatus(List statusSpans, List rules, int repeat) { var row = 0; foreach (var span in statusSpans) @@ -158,8 +158,8 @@ public class ForewarningHelper { StartTrackStatusId = x.StartTrackStatusId, EndTrackStatusId = x.EndTrackStatusId, - NotifyMode = input.NotifyMode, - NotifyUserId = x.NotifyUserId + NotifyMode = x.NotifyModes.JoinAsString(","), + NotifyUserId = x.NotifyUserIds.JoinAsString(","), }).ToList(); } @@ -171,7 +171,6 @@ public class ForewarningHelper Name = warning.Name, SubSystemId = warning.SubSystemId, CustomerId = warning.CustomerId, - NotifyMode = warning.WarningNotifies.First().NotifyMode, TrackStatusSpans = warning.WarningNotifies.Select(x => new WarningNotifyWithIdDto { Id = x.Id, @@ -179,7 +178,8 @@ public class ForewarningHelper StartTrackStatus = statusDic.TryGetValue(x.StartTrackStatusId, out var start) ? start : "", EndTrackStatusId = x.EndTrackStatusId, EndTrackStatus = statusDic.TryGetValue(x.EndTrackStatusId, out var end) ? end : "", - NotifyUserId = x.NotifyUserId, + NotifyUserIds = x.NotifyUserId.Split(',').Select(int.Parse).ToList(), + NotifyModes = x.NotifyMode.Split(',').Select(Enum.Parse).ToList(), }).ToList(), WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto { diff --git a/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningService.cs b/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningService.cs index 05c49b65..a0131e04 100644 --- a/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningService.cs +++ b/src/SJZY.Track.Application/Services/ForewarningServices/ForewarningService.cs @@ -112,8 +112,8 @@ public class ForewarningService : ApplicationService warning.WarningNotifies = input.Notifies.Select(x => new WarningNotifyEntity { Id = x.Id, - NotifyMode = input.NotifyMode, - NotifyUserId = x.NotifyUserId + NotifyMode = x.NotifyModes.JoinAsString(","), + NotifyUserId = x.NotifyUserIds.JoinAsString(","), }).ToList(); await _warningRepository.UpdateForewarningAsync(warning); diff --git a/src/SJZY.Track.Application/Validations/Forewarning/CreateRuleFactorValidation.cs b/src/SJZY.Track.Application/Validations/Forewarning/CreateRuleFactorValidation.cs index 5c7fa156..b79a7bbd 100644 --- a/src/SJZY.Track.Application/Validations/Forewarning/CreateRuleFactorValidation.cs +++ b/src/SJZY.Track.Application/Validations/Forewarning/CreateRuleFactorValidation.cs @@ -10,9 +10,6 @@ public class CreateRuleFactorValidation : AbstractValidator RuleFor(x => x.WarningFactors).NotNull().WithMessage("因素列表不能为空"); RuleFor(x => x.TrackStatusSpans).NotNull().WithMessage("轨迹状态列表不能为空"); - RuleFor(x => x.NotifyTemplate).NotEmpty().WithMessage("通知模板必填") - .MaximumLength(256).WithMessage("通知模板长度不能超过256"); - // todo: more validation } } diff --git a/src/SJZY.Track.Application/Validations/Forewarning/RuleTrackStateDtoValidator.cs b/src/SJZY.Track.Application/Validations/Forewarning/RuleTrackStateDtoValidator.cs index b90b4b37..6bfa03d9 100644 --- a/src/SJZY.Track.Application/Validations/Forewarning/RuleTrackStateDtoValidator.cs +++ b/src/SJZY.Track.Application/Validations/Forewarning/RuleTrackStateDtoValidator.cs @@ -1,14 +1,15 @@ using FluentValidation; -using SJZY.Track.Domain.Dtos.Forewarning; +using SJZY.Track.Application.Contract.Dtos.Forewarning; namespace SJZY.Track.Application.Validations.Forewarning; -public class RuleTrackStateDtoValidator : AbstractValidator +public class RuleTrackStateDtoValidator : AbstractValidator { public RuleTrackStateDtoValidator() { RuleFor(x => x.StartTrackStatusId).GreaterThan(0).WithMessage("起始轨迹状态id必须大于0"); RuleFor(x => x.EndTrackStatusId).GreaterThan(0).WithMessage("终止轨迹状态id必须大于0"); - RuleFor(x => x.NotifyUserId).NotEmpty().WithMessage("通知对象不能为空"); + RuleFor(x => x.NotifyModes).NotEmpty().WithMessage("通知方式不能为空"); + RuleFor(x => x.NotifyUserIds).NotEmpty().WithMessage("通知对象不能为空"); } } diff --git a/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningNotifyEntity.cs b/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningNotifyEntity.cs index ba601062..8d3bb8ac 100644 --- a/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningNotifyEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/ForewarningAggregate/WarningNotifyEntity.cs @@ -1,5 +1,3 @@ -using SJZY.Track.Share.Enums; - namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate; [SugarTable("t_warning_notify")] @@ -30,14 +28,14 @@ public class WarningNotifyEntity : IFullAuditedBasicEntitys, IEntity public int EndTrackStatusId { get; set; } /// - /// 通知方式 + /// 通知方式,多个逗号分隔 /// [SugarColumn(ColumnName = "NotifyMode")] - public NotifyMode NotifyMode { get; set; } + public string NotifyMode { get; set; } /// - /// 通知人 + /// 通知人,多个逗号分隔 /// [SugarColumn(ColumnName = "NotifyUserId")] - public int NotifyUserId { get; set; } + public string NotifyUserId { get; set; } } diff --git a/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs b/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs index 5e2494cd..12014a8b 100644 --- a/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs +++ b/src/SJZY.Track.Domain/Dtos/Forewarning/GetWarningNotifiesVo.cs @@ -74,17 +74,16 @@ public class GetWarningNotifiesVo /// /// 通知方式 /// - public NotifyMode NotifyMode { get; set; } + public string NotifyMode { get; set; } - /// - /// 通知模板 - /// - public string NotifyTemplate { get; set; } = null!; + public List NotifyModes { get; set; } /// /// 通知人 /// - public int NotifyUserId { get; set; } + public string NotifyUserId { get; set; } + + public List NotifyUserIds { get; set; } /// /// 因素类型排序 diff --git a/src/SJZY.Track.Repository/Queries/WarningQueries.cs b/src/SJZY.Track.Repository/Queries/WarningQueries.cs index 4cd8acb8..f561e785 100644 --- a/src/SJZY.Track.Repository/Queries/WarningQueries.cs +++ b/src/SJZY.Track.Repository/Queries/WarningQueries.cs @@ -2,18 +2,14 @@ using SJZY.Track.Domain.Aggregates.ForewarningAggregate; using SJZY.Track.Domain.Aggregates.KPIAreaAggregate; using SJZY.Track.Domain.Dtos.Forewarning; using SJZY.Track.Domain.Queries; +using SJZY.Track.Share.Enums; namespace SJZY.Track.Repository.Queries; public class WarningQueries : ISugarRepository, IWarningQueries, ITransientDependency { - public WarningQueries() - { - Context = SqlsugarScopeBasic.GetContextSafely("default"); - } - - public ISqlSugarClient Context { get; set; } + public ISqlSugarClient Context { get; set; } = SqlsugarScopeBasic.GetContextSafely("default"); public async Task> GetWarningNotifyRulesAsync(List ruleIds) { @@ -44,6 +40,11 @@ public class WarningQueries : ISugarRepository, IWarningQueries, NotifyUserId = wn.NotifyUserId, FactorTypeSort = w.FactorTypeSort }) + .Mapper(x => + { + x.NotifyModes = x.NotifyMode.Split(',').Select(Enum.Parse).ToList(); + x.NotifyUserIds = x.NotifyUserId.Split(',').Select(int.Parse).ToList(); + }) .ToListAsync(); }