using System; using System.Collections.Generic; using System.Linq; namespace NPP.SmartSchedue.Api.Contracts.Services.Notification.Output; /// /// 批量发送系统消息输出模型 /// public class BatchSendSystemMessageOutput { /// /// 总发送数量 /// public int TotalCount { get; set; } /// /// 成功发送数量 /// public int SuccessCount { get; set; } /// /// 失败发送数量 /// public int FailureCount { get; set; } /// /// 详细发送结果 /// Key: 人员ID, Value: 发送结果 /// public Dictionary Results { get; set; } = new Dictionary(); /// /// 批量发送时间 /// public DateTime SentTime { get; set; } /// /// 是否全部发送成功 /// public bool AllSuccess => FailureCount == 0; /// /// 成功率(百分比) /// public double SuccessRate => TotalCount > 0 ? (double)SuccessCount / TotalCount * 100 : 0; /// /// 创建批量发送结果 /// public static BatchSendSystemMessageOutput Create(Dictionary results) { var output = new BatchSendSystemMessageOutput { Results = results, TotalCount = results.Count, SuccessCount = results.Values.Count(r => r.Success), SentTime = DateTime.Now }; output.FailureCount = output.TotalCount - output.SuccessCount; return output; } }