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

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

View File

@ -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
/// </summary>
public int CustomerId { get; set; }
/// <summary>
/// 通知方式
/// </summary>
public NotifyMode NotifyMode { get; set; }
/// <summary>
/// 通知模板
/// </summary>
public string NotifyTemplate { get; set; } = null!;
/// <summary>
/// 通知列表
/// </summary>
@ -41,7 +30,7 @@ public class EditWarningOutput
public List<WarningFactorWithIdDto> WarningFactors { get; set; } = new();
}
public class WarningNotifyWithIdDto : WarningNitifyDto
public class WarningNotifyWithIdDto : WarningNotifyDto
{
/// <summary>
/// 通知id

View File

@ -14,17 +14,6 @@ public class UpdateWarningInput
/// </summary>
public string Name { get; set; } = null!;
/// <summary>
/// 通知方式
/// </summary>
public NotifyMode NotifyMode { get; set; }
/// <summary>
/// 通知模板
/// </summary>
public string NotifyTemplate { get; set; } = null!;
/// <summary>
/// 通知列表
/// </summary>
@ -41,5 +30,10 @@ public class NotifyDto
/// <summary>
/// 通知人id
/// </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>
/// 起始轨迹状态id
@ -25,5 +27,10 @@ public class WarningNitifyDto
/// <summary>
/// 通知人id
/// </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="factors"></param>
/// <returns></returns>
public static List<WarningRuleEntity> CalcRuleList(List<WarningNitifyDto> statusSpans,
public static List<WarningRuleEntity> CalcRuleList(List<WarningNotifyDto> statusSpans,
List<WarningFactorDto> factors)
{
if (statusSpans.Count == 0 || factors.Count == 0)
@ -52,7 +52,7 @@ public class ForewarningHelper
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;
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<NotifyMode>).ToList(),
}).ToList(),
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
{
Id = x.Id,
NotifyMode = input.NotifyMode,
NotifyUserId = x.NotifyUserId
NotifyMode = x.NotifyModes.JoinAsString(","),
NotifyUserId = x.NotifyUserIds.JoinAsString(","),
}).ToList();
await _warningRepository.UpdateForewarningAsync(warning);

View File

@ -10,9 +10,6 @@ public class CreateRuleFactorValidation : AbstractValidator<CreateWarningInput>
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
}
}

View File

@ -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<WarningNitifyDto>
public class RuleTrackStateDtoValidator : AbstractValidator<WarningNotifyDto>
{
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("通知对象不能为空");
}
}

View File

@ -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; }
/// <summary>
/// 通知方式
/// 通知方式,多个逗号分隔
/// </summary>
[SugarColumn(ColumnName = "NotifyMode")]
public NotifyMode NotifyMode { get; set; }
public string NotifyMode { get; set; }
/// <summary>
/// 通知人
/// 通知人,多个逗号分隔
/// </summary>
[SugarColumn(ColumnName = "NotifyUserId")]
public int NotifyUserId { get; set; }
public string NotifyUserId { get; set; }
}

View File

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

View File

@ -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<List<GetWarningNotifiesVo>> GetWarningNotifyRulesAsync(List<int> 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<NotifyMode>).ToList();
x.NotifyUserIds = x.NotifyUserId.Split(',').Select(int.Parse).ToList();
})
.ToListAsync();
}