GrpScheduleRepository.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using OASystem.Domain.Dtos.Groups;
  2. using OASystem.Domain.Entities.Groups;
  3. using OASystem.Domain.ViewModels.Groups;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace OASystem.Infrastructure.Repositories.Groups
  10. {
  11. public class GrpScheduleRepository : BaseRepository<Grp_ScheduleInfo, Grp_ScheduleInfo>
  12. {
  13. public GrpScheduleRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
  14. {
  15. }
  16. public string SetSqlWhere_GrpScheduleDto(Grp_ScheduleDto _dto)
  17. {
  18. string sqlWhere = string.Empty;
  19. if (_dto.SysUserId > 0)
  20. {
  21. sqlWhere += string.Format(@" And s.Id in ( Select Id From Grp_SchedulePerson With(Nolock) Where SysUserId = '{0}' ) ", _dto.SysUserId);
  22. }
  23. if (_dto.ScheduleId > 0)
  24. {
  25. sqlWhere += string.Format(@" And s.Id = '{0}' ", _dto.ScheduleId);
  26. }
  27. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  28. {
  29. Regex r = new Regex("And");
  30. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  31. }
  32. return sqlWhere;
  33. }
  34. /// <summary>
  35. /// 获取团组流程数据单个对象
  36. /// </summary>
  37. /// <typeparam name="T"></typeparam>
  38. /// <param name="_dto"></param>
  39. /// <returns></returns>
  40. public async Task<Grp_ScheduleView> GetView_GrpSchedule(Grp_ScheduleDto _dto)
  41. {
  42. Grp_ScheduleView _view = null;
  43. string sqlWhere = this.SetSqlWhere_GrpScheduleDto(_dto);
  44. string sql = string.Format(@" Select s.Id,s.DiId,di.TeamName as DeleName,s.PrimaryStep,s.ExpectBeginDt,s.ExpectEndDt,s.Leader,s.Exception,u.CnName as LeaderName
  45. From Grp_Schedule as s With(Nolock) Inner Join Grp_DelegationInfo as di With(Nolock) On s.DiId=di.Id
  46. Inner Join Sys_Users as u With(Nolock) On s.Leader=u.Id
  47. {0} ", sqlWhere);
  48. _view = await _sqlSugar.SqlQueryable<Grp_ScheduleView>(sql).FirstAsync();
  49. return _view;
  50. }
  51. }
  52. }