using Admin.NET.Plugin.AiDOP.Dto.S8; using Admin.NET.Plugin.AiDOP.Entity.S8; namespace Admin.NET.Plugin.AiDOP.Service.S8; public class S8DecisionService : ITransient { private readonly SqlSugarRepository _timelineRep; private readonly SqlSugarRepository _decisionRep; private readonly SqlSugarRepository _evidenceRep; public S8DecisionService( SqlSugarRepository timelineRep, SqlSugarRepository decisionRep, SqlSugarRepository evidenceRep) { _timelineRep = timelineRep; _decisionRep = decisionRep; _evidenceRep = evidenceRep; } public async Task> GetTimelineAsync(long exceptionId) => await _timelineRep.AsQueryable() .Where(x => x.ExceptionId == exceptionId) .OrderBy(x => x.CreatedAt) .Select(x => new AdoS8TimelineItemDto { Id = x.Id, ActionCode = x.ActionCode, ActionLabel = x.ActionLabel, FromStatus = x.FromStatus, ToStatus = x.ToStatus, OperatorId = x.OperatorId, OperatorName = x.OperatorName, ActionRemark = x.ActionRemark, CreatedAt = x.CreatedAt }) .ToListAsync(); public async Task> GetDecisionsAsync(long exceptionId) => await _decisionRep.AsQueryable() .Where(x => x.ExceptionId == exceptionId && !x.IsDeleted) .OrderBy(x => x.DecisionTime) .Select(x => new AdoS8DecisionItemDto { Id = x.Id, DecisionType = x.DecisionType, DecisionMakerId = x.DecisionMakerId, DecisionMakerName = x.DecisionMakerName, DecisionBasis = x.DecisionBasis, DecisionResult = x.DecisionResult, DecisionRemark = x.DecisionRemark, DecisionTime = x.DecisionTime }) .ToListAsync(); public async Task> GetEvidencesAsync(long exceptionId) => await _evidenceRep.AsQueryable() .Where(x => x.ExceptionId == exceptionId && !x.IsDeleted) .OrderBy(x => x.UploadedAt) .Select(x => new AdoS8EvidenceItemDto { Id = x.Id, EvidenceType = x.EvidenceType, FileName = x.FileName, FileUrl = x.FileUrl, SourceSystem = x.SourceSystem, UploadedBy = x.UploadedBy, UploadedAt = x.UploadedAt }) .ToListAsync(); }