DelegationVisaRepository.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. public List<DelegationVisaPersonView> GetDelegationPersonList(int diid)
  47. {
  48. ChangeDataBase(DBEnum.OA2014DB);
  49. string sqlDeleClient = string.Format(@" Select
  50. Id as 'PersonViewId',
  51. Diid,
  52. LastName,
  53. [Name] as 'FirstName'
  54. From DeleClient With(Nolock) Where Diid = {0} And IsDel = 0 ", diid);
  55. List<DelegationVisaPersonView> clientList = _sqlSugar.SqlQueryable<DelegationVisaPersonView>(sqlDeleClient).ToList();
  56. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", diid);
  57. OA2021_DelegationInfo delegationInfo = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  58. string countryName = delegationInfo.VisitCountry;
  59. #region 配置
  60. #endregion
  61. return null;
  62. }
  63. public int initVisitCountry(int diid)
  64. {
  65. ChangeDataBase(DBEnum.OA2023DB);
  66. string sqlCheck = string.Format(@" Select * From ");
  67. return 0;
  68. }
  69. }
  70. }