S8DecisionService.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Admin.NET.Plugin.AiDOP.Dto.S8;
  2. using Admin.NET.Plugin.AiDOP.Entity.S8;
  3. namespace Admin.NET.Plugin.AiDOP.Service.S8;
  4. public class S8DecisionService : ITransient
  5. {
  6. private readonly SqlSugarRepository<AdoS8ExceptionTimeline> _timelineRep;
  7. private readonly SqlSugarRepository<AdoS8DecisionRecord> _decisionRep;
  8. private readonly SqlSugarRepository<AdoS8Evidence> _evidenceRep;
  9. public S8DecisionService(
  10. SqlSugarRepository<AdoS8ExceptionTimeline> timelineRep,
  11. SqlSugarRepository<AdoS8DecisionRecord> decisionRep,
  12. SqlSugarRepository<AdoS8Evidence> evidenceRep)
  13. {
  14. _timelineRep = timelineRep;
  15. _decisionRep = decisionRep;
  16. _evidenceRep = evidenceRep;
  17. }
  18. public async Task<List<AdoS8TimelineItemDto>> GetTimelineAsync(long exceptionId) =>
  19. await _timelineRep.AsQueryable()
  20. .Where(x => x.ExceptionId == exceptionId)
  21. .OrderBy(x => x.CreatedAt)
  22. .Select(x => new AdoS8TimelineItemDto
  23. {
  24. Id = x.Id,
  25. ActionCode = x.ActionCode,
  26. ActionLabel = x.ActionLabel,
  27. FromStatus = x.FromStatus,
  28. ToStatus = x.ToStatus,
  29. OperatorId = x.OperatorId,
  30. OperatorName = x.OperatorName,
  31. ActionRemark = x.ActionRemark,
  32. CreatedAt = x.CreatedAt
  33. })
  34. .ToListAsync();
  35. public async Task<List<AdoS8DecisionItemDto>> GetDecisionsAsync(long exceptionId) =>
  36. await _decisionRep.AsQueryable()
  37. .Where(x => x.ExceptionId == exceptionId && !x.IsDeleted)
  38. .OrderBy(x => x.DecisionTime)
  39. .Select(x => new AdoS8DecisionItemDto
  40. {
  41. Id = x.Id,
  42. DecisionType = x.DecisionType,
  43. DecisionMakerId = x.DecisionMakerId,
  44. DecisionMakerName = x.DecisionMakerName,
  45. DecisionBasis = x.DecisionBasis,
  46. DecisionResult = x.DecisionResult,
  47. DecisionRemark = x.DecisionRemark,
  48. DecisionTime = x.DecisionTime
  49. })
  50. .ToListAsync();
  51. public async Task<List<AdoS8EvidenceItemDto>> GetEvidencesAsync(long exceptionId) =>
  52. await _evidenceRep.AsQueryable()
  53. .Where(x => x.ExceptionId == exceptionId && !x.IsDeleted)
  54. .OrderBy(x => x.UploadedAt)
  55. .Select(x => new AdoS8EvidenceItemDto
  56. {
  57. Id = x.Id,
  58. EvidenceType = x.EvidenceType,
  59. FileName = x.FileName,
  60. FileUrl = x.FileUrl,
  61. SourceSystem = x.SourceSystem,
  62. UploadedBy = x.UploadedBy,
  63. UploadedAt = x.UploadedAt
  64. })
  65. .ToListAsync();
  66. }