DelegationVisaRepository.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using OASystem.Domain.Dtos.Groups;
  2. using OASystem.Domain.Entities.Groups;
  3. using OASystem.Domain.ViewModels.Groups;
  4. using OASystem.Domain.ViewModels.Resource;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace OASystem.Infrastructure.Repositories.Groups
  11. {
  12. public class DelegationVisaRepository : BaseRepository<Grp_VisaProgress, Grp_DelegationVisaView>
  13. {
  14. public DelegationVisaRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
  15. {
  16. }
  17. public DelegationVisaViewList GetDelegationList(IOS_VisaDto _dto)
  18. {
  19. string sqlWhere = string.Format(" Where IsDel=0 ");
  20. int currPIndex = (((_dto.PageIndex > 0) ? (_dto.PageIndex - 1) : 0) * _dto.PageSize) + 1;
  21. int currPSize = (((_dto.PageIndex > 0) ? (_dto.PageIndex - 1) : 0) + 1) * _dto.PageSize;
  22. ChangeDataBase(DBEnum.OA2014DB);
  23. string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By Id desc) as RowNumber, Id as DiId,
  24. TeamName,ClientUnit,ClientName,TeamLev,VisitDate,VisitDays,VisitPNumber
  25. From DelegationInfo With(Nolock) {2}
  26. ) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
  27. DelegationVisaViewList rst = new DelegationVisaViewList();
  28. rst.CurrPageIndex = currPIndex;
  29. rst.CurrPageSize = currPSize;
  30. List<Grp_DelegationVisaView> dataSource = _sqlSugar.SqlQueryable<Grp_DelegationVisaView>(sql).ToList();
  31. foreach (var item in dataSource)
  32. {
  33. string sql2 = string.Format(@" Select * From Grp_VisaProgressCustomer With(Nolock) Where DiId={0} And IsDel=0 ", item.DiId);
  34. List<Grp_VisaProgressCustomer> listComplete = _sqlSugar.SqlQueryable<Grp_VisaProgressCustomer>(sql2).ToList();
  35. item.CompletePNumber = string.Format(@"已完成{0}人", listComplete.Count);
  36. }
  37. rst.DataList = new List<Grp_DelegationVisaView>(dataSource);
  38. if (rst.DataList.Count > 0)
  39. {
  40. string sqlCount = string.Format(@" Select Id as DiId From DelegationInfo With(Nolock) {0} ", sqlWhere);
  41. int dataCount = _sqlSugar.SqlQueryable<Grp_DelegationVisaView>(sqlCount).Count();
  42. rst.DataCount = dataCount;
  43. }
  44. return rst;
  45. }
  46. }
  47. }