【通知方式通知人单选变多选】

https://www.tapd.cn/60863849/prong/tasks/view/1160863849001028431
This commit is contained in:
xiaolipro 2024-09-06 17:32:53 +08:00
parent bb7a3c2312
commit 42bae65d38
11 changed files with 46 additions and 71 deletions

View File

@ -1,5 +1,4 @@
using SJZY.Track.Domain.Dtos.Forewarning; using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Application.Contract.Dtos.Forewarning; namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
@ -20,20 +19,10 @@ public class CreateWarningInput
/// </summary> /// </summary>
public int CustomerId { get; set; } public int CustomerId { get; set; }
/// <summary>
/// 通知方式
/// </summary>
public NotifyMode NotifyMode { get; set; }
/// <summary>
/// 通知模板
/// </summary>
public string NotifyTemplate { get; set; } = null!;
/// <summary> /// <summary>
/// 轨迹状态跨度列表 /// 轨迹状态跨度列表
/// </summary> /// </summary>
public List<WarningNitifyDto> TrackStatusSpans { get; set; } = new(); public List<WarningNotifyDto> TrackStatusSpans { get; set; } = new();
/// <summary> /// <summary>
/// 预警因素列表。 /// 预警因素列表。

View File

@ -1,5 +1,4 @@
using SJZY.Track.Domain.Dtos.Forewarning; using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Application.Contract.Dtos.Forewarning; namespace SJZY.Track.Application.Contract.Dtos.Forewarning;
@ -20,16 +19,6 @@ public class EditWarningOutput
/// </summary> /// </summary>
public int CustomerId { get; set; } public int CustomerId { get; set; }
/// <summary>
/// 通知方式
/// </summary>
public NotifyMode NotifyMode { get; set; }
/// <summary>
/// 通知模板
/// </summary>
public string NotifyTemplate { get; set; } = null!;
/// <summary> /// <summary>
/// 通知列表 /// 通知列表
/// </summary> /// </summary>
@ -41,7 +30,7 @@ public class EditWarningOutput
public List<WarningFactorWithIdDto> WarningFactors { get; set; } = new(); public List<WarningFactorWithIdDto> WarningFactors { get; set; } = new();
} }
public class WarningNotifyWithIdDto : WarningNitifyDto public class WarningNotifyWithIdDto : WarningNotifyDto
{ {
/// <summary> /// <summary>
/// 通知id /// 通知id

View File

@ -14,17 +14,6 @@ public class UpdateWarningInput
/// </summary> /// </summary>
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
/// <summary>
/// 通知方式
/// </summary>
public NotifyMode NotifyMode { get; set; }
/// <summary>
/// 通知模板
/// </summary>
public string NotifyTemplate { get; set; } = null!;
/// <summary> /// <summary>
/// 通知列表 /// 通知列表
/// </summary> /// </summary>
@ -41,5 +30,10 @@ public class NotifyDto
/// <summary> /// <summary>
/// 通知人id /// 通知人id
/// </summary> /// </summary>
public int NotifyUserId { get; set; } public List<int> NotifyUserIds { get; set; }
/// <summary>
/// 通知方式
/// </summary>
public List<NotifyMode> NotifyModes { get; set; }
} }

View File

@ -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
{ {
/// <summary> /// <summary>
/// 起始轨迹状态id /// 起始轨迹状态id
@ -25,5 +27,10 @@ public class WarningNitifyDto
/// <summary> /// <summary>
/// 通知人id /// 通知人id
/// </summary> /// </summary>
public int NotifyUserId { get; set; } public List<int> NotifyUserIds { get; set; }
/// <summary>
/// 通知方式
/// </summary>
public List<NotifyMode> NotifyModes { get; set; }
} }

View File

@ -18,7 +18,7 @@ public class ForewarningHelper
/// <param name="statusSpans"></param> /// <param name="statusSpans"></param>
/// <param name="factors"></param> /// <param name="factors"></param>
/// <returns></returns> /// <returns></returns>
public static List<WarningRuleEntity> CalcRuleList(List<WarningNitifyDto> statusSpans, public static List<WarningRuleEntity> CalcRuleList(List<WarningNotifyDto> statusSpans,
List<WarningFactorDto> factors) List<WarningFactorDto> factors)
{ {
if (statusSpans.Count == 0 || factors.Count == 0) if (statusSpans.Count == 0 || factors.Count == 0)
@ -52,7 +52,7 @@ public class ForewarningHelper
return rules; return rules;
} }
private static void FillStatus(List<WarningNitifyDto> statusSpans, List<WarningRuleEntity> rules, int repeat) private static void FillStatus(List<WarningNotifyDto> statusSpans, List<WarningRuleEntity> rules, int repeat)
{ {
var row = 0; var row = 0;
foreach (var span in statusSpans) foreach (var span in statusSpans)
@ -158,8 +158,8 @@ public class ForewarningHelper
{ {
StartTrackStatusId = x.StartTrackStatusId, StartTrackStatusId = x.StartTrackStatusId,
EndTrackStatusId = x.EndTrackStatusId, EndTrackStatusId = x.EndTrackStatusId,
NotifyMode = input.NotifyMode, NotifyMode = x.NotifyModes.JoinAsString(","),
NotifyUserId = x.NotifyUserId NotifyUserId = x.NotifyUserIds.JoinAsString(","),
}).ToList(); }).ToList();
} }
@ -171,7 +171,6 @@ public class ForewarningHelper
Name = warning.Name, Name = warning.Name,
SubSystemId = warning.SubSystemId, SubSystemId = warning.SubSystemId,
CustomerId = warning.CustomerId, CustomerId = warning.CustomerId,
NotifyMode = warning.WarningNotifies.First().NotifyMode,
TrackStatusSpans = warning.WarningNotifies.Select(x => new WarningNotifyWithIdDto TrackStatusSpans = warning.WarningNotifies.Select(x => new WarningNotifyWithIdDto
{ {
Id = x.Id, Id = x.Id,
@ -179,7 +178,8 @@ public class ForewarningHelper
StartTrackStatus = statusDic.TryGetValue(x.StartTrackStatusId, out var start) ? start : "", StartTrackStatus = statusDic.TryGetValue(x.StartTrackStatusId, out var start) ? start : "",
EndTrackStatusId = x.EndTrackStatusId, EndTrackStatusId = x.EndTrackStatusId,
EndTrackStatus = statusDic.TryGetValue(x.EndTrackStatusId, out var end) ? end : "", 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<NotifyMode>).ToList(),
}).ToList(), }).ToList(),
WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto WarningFactors = warning.WarningFactors.Select(x => new WarningFactorWithIdDto
{ {

View File

@ -112,8 +112,8 @@ public class ForewarningService : ApplicationService
warning.WarningNotifies = input.Notifies.Select(x => new WarningNotifyEntity warning.WarningNotifies = input.Notifies.Select(x => new WarningNotifyEntity
{ {
Id = x.Id, Id = x.Id,
NotifyMode = input.NotifyMode, NotifyMode = x.NotifyModes.JoinAsString(","),
NotifyUserId = x.NotifyUserId NotifyUserId = x.NotifyUserIds.JoinAsString(","),
}).ToList(); }).ToList();
await _warningRepository.UpdateForewarningAsync(warning); await _warningRepository.UpdateForewarningAsync(warning);

View File

@ -10,9 +10,6 @@ public class CreateRuleFactorValidation : AbstractValidator<CreateWarningInput>
RuleFor(x => x.WarningFactors).NotNull().WithMessage("因素列表不能为空"); RuleFor(x => x.WarningFactors).NotNull().WithMessage("因素列表不能为空");
RuleFor(x => x.TrackStatusSpans).NotNull().WithMessage("轨迹状态列表不能为空"); RuleFor(x => x.TrackStatusSpans).NotNull().WithMessage("轨迹状态列表不能为空");
RuleFor(x => x.NotifyTemplate).NotEmpty().WithMessage("通知模板必填")
.MaximumLength(256).WithMessage("通知模板长度不能超过256");
// todo: more validation // todo: more validation
} }
} }

View File

@ -1,14 +1,15 @@
using FluentValidation; using FluentValidation;
using SJZY.Track.Domain.Dtos.Forewarning; using SJZY.Track.Application.Contract.Dtos.Forewarning;
namespace SJZY.Track.Application.Validations.Forewarning; namespace SJZY.Track.Application.Validations.Forewarning;
public class RuleTrackStateDtoValidator : AbstractValidator<WarningNitifyDto> public class RuleTrackStateDtoValidator : AbstractValidator<WarningNotifyDto>
{ {
public RuleTrackStateDtoValidator() public RuleTrackStateDtoValidator()
{ {
RuleFor(x => x.StartTrackStatusId).GreaterThan(0).WithMessage("起始轨迹状态id必须大于0"); RuleFor(x => x.StartTrackStatusId).GreaterThan(0).WithMessage("起始轨迹状态id必须大于0");
RuleFor(x => x.EndTrackStatusId).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("通知对象不能为空");
} }
} }

View File

@ -1,5 +1,3 @@
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate; namespace SJZY.Track.Domain.Aggregates.ForewarningAggregate;
[SugarTable("t_warning_notify")] [SugarTable("t_warning_notify")]
@ -30,14 +28,14 @@ public class WarningNotifyEntity : IFullAuditedBasicEntitys, IEntity
public int EndTrackStatusId { get; set; } public int EndTrackStatusId { get; set; }
/// <summary> /// <summary>
/// 通知方式 /// 通知方式,多个逗号分隔
/// </summary> /// </summary>
[SugarColumn(ColumnName = "NotifyMode")] [SugarColumn(ColumnName = "NotifyMode")]
public NotifyMode NotifyMode { get; set; } public string NotifyMode { get; set; }
/// <summary> /// <summary>
/// 通知人 /// 通知人,多个逗号分隔
/// </summary> /// </summary>
[SugarColumn(ColumnName = "NotifyUserId")] [SugarColumn(ColumnName = "NotifyUserId")]
public int NotifyUserId { get; set; } public string NotifyUserId { get; set; }
} }

View File

@ -74,17 +74,16 @@ public class GetWarningNotifiesVo
/// <summary> /// <summary>
/// 通知方式 /// 通知方式
/// </summary> /// </summary>
public NotifyMode NotifyMode { get; set; } public string NotifyMode { get; set; }
/// <summary> public List<NotifyMode> NotifyModes { get; set; }
/// 通知模板
/// </summary>
public string NotifyTemplate { get; set; } = null!;
/// <summary> /// <summary>
/// 通知人 /// 通知人
/// </summary> /// </summary>
public int NotifyUserId { get; set; } public string NotifyUserId { get; set; }
public List<int> NotifyUserIds { get; set; }
/// <summary> /// <summary>
/// 因素类型排序 /// 因素类型排序

View File

@ -2,18 +2,14 @@ using SJZY.Track.Domain.Aggregates.ForewarningAggregate;
using SJZY.Track.Domain.Aggregates.KPIAreaAggregate; using SJZY.Track.Domain.Aggregates.KPIAreaAggregate;
using SJZY.Track.Domain.Dtos.Forewarning; using SJZY.Track.Domain.Dtos.Forewarning;
using SJZY.Track.Domain.Queries; using SJZY.Track.Domain.Queries;
using SJZY.Track.Share.Enums;
namespace SJZY.Track.Repository.Queries; namespace SJZY.Track.Repository.Queries;
public class WarningQueries : ISugarRepository, IWarningQueries, public class WarningQueries : ISugarRepository, IWarningQueries,
ITransientDependency ITransientDependency
{ {
public WarningQueries() public ISqlSugarClient Context { get; set; } = SqlsugarScopeBasic.GetContextSafely("default");
{
Context = SqlsugarScopeBasic.GetContextSafely("default");
}
public ISqlSugarClient Context { get; set; }
public async Task<List<GetWarningNotifiesVo>> GetWarningNotifyRulesAsync(List<int> ruleIds) public async Task<List<GetWarningNotifiesVo>> GetWarningNotifyRulesAsync(List<int> ruleIds)
{ {
@ -44,6 +40,11 @@ public class WarningQueries : ISugarRepository, IWarningQueries,
NotifyUserId = wn.NotifyUserId, NotifyUserId = wn.NotifyUserId,
FactorTypeSort = w.FactorTypeSort FactorTypeSort = w.FactorTypeSort
}) })
.Mapper(x =>
{
x.NotifyModes = x.NotifyMode.Split(',').Select(Enum.Parse<NotifyMode>).ToList();
x.NotifyUserIds = x.NotifyUserId.Split(',').Select(int.Parse).ToList();
})
.ToListAsync(); .ToListAsync();
} }