using System.ComponentModel.DataAnnotations; namespace MilitaryTrainingManagement.Models.DTOs; /// /// 分配请求项 /// public class DistributionRequestItem { public int TargetUnitId { get; set; } public decimal UnitQuota { get; set; } } /// /// 创建物资配额请求 /// public class CreateAllocationRequest { /// /// 类别 /// [Required(ErrorMessage = "类别为必填项")] [MaxLength(100, ErrorMessage = "类别长度不能超过100个字符")] public string Category { get; set; } = string.Empty; /// /// 物资名称 /// [Required(ErrorMessage = "物资名称为必填项")] [MaxLength(200, ErrorMessage = "物资名称长度不能超过200个字符")] public string MaterialName { get; set; } = string.Empty; /// /// 计量单位 /// [Required(ErrorMessage = "计量单位为必填项")] [MaxLength(50, ErrorMessage = "计量单位长度不能超过50个字符")] public string Unit { get; set; } = string.Empty; /// /// 总配额 /// [Range(0.01, double.MaxValue, ErrorMessage = "总配额必须大于0")] public decimal TotalQuota { get; set; } /// /// 分配记录 /// public List Distributions { get; set; } = new(); /// /// 转换为字典格式 /// public Dictionary GetDistributionsDictionary() { return Distributions .Where(d => d.TargetUnitId > 0) .ToDictionary(d => d.TargetUnitId, d => d.UnitQuota); } } /// /// 更新物资配额请求 /// public class UpdateAllocationRequest { /// /// 类别 /// [Required(ErrorMessage = "类别为必填项")] [MaxLength(100, ErrorMessage = "类别长度不能超过100个字符")] public string Category { get; set; } = string.Empty; /// /// 物资名称 /// [Required(ErrorMessage = "物资名称为必填项")] [MaxLength(200, ErrorMessage = "物资名称长度不能超过200个字符")] public string MaterialName { get; set; } = string.Empty; /// /// 计量单位 /// [Required(ErrorMessage = "计量单位为必填项")] [MaxLength(50, ErrorMessage = "计量单位长度不能超过50个字符")] public string Unit { get; set; } = string.Empty; /// /// 总配额 /// [Range(0.01, double.MaxValue, ErrorMessage = "总配额必须大于0")] public decimal TotalQuota { get; set; } } /// /// 更新配额分配实际完成数量请求(上报消耗) /// public class UpdateDistributionRequest { /// /// 实际完成数量 /// [Required(ErrorMessage = "实际完成数量为必填项")] [Range(0, double.MaxValue, ErrorMessage = "实际完成数量不能为负数")] public decimal ActualCompletion { get; set; } } /// /// 物资配额响应 /// public class AllocationResponse { public int Id { get; set; } public string Category { get; set; } = string.Empty; public string MaterialName { get; set; } = string.Empty; public string Unit { get; set; } = string.Empty; public decimal TotalQuota { get; set; } public int CreatedByUnitId { get; set; } public string CreatedByUnitName { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } public List Distributions { get; set; } = new(); } /// /// 配额分配响应 /// public class AllocationDistributionResponse { public int Id { get; set; } public int TargetUnitId { get; set; } public string TargetUnitName { get; set; } = string.Empty; public decimal UnitQuota { get; set; } public decimal? ActualCompletion { get; set; } public decimal CompletionRate { get; set; } public DateTime? ReportedAt { get; set; } public string? ReportedByUserName { get; set; } }