LevelStatistics.razor.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using AntDesign;
  2. using Microsoft.AspNetCore.Components;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.Threading.Tasks;
  7. using wispro.sp.share;
  8. using wispro.sp.web.Services;
  9. using System.Linq;
  10. namespace wispro.sp.web.Pages.AppCase
  11. {
  12. public partial class LevelStatistics
  13. {
  14. CultureInfo CiEn = CultureInfo.GetCultureInfo("en-US");
  15. CultureInfo CiCn = CultureInfo.GetCultureInfo("zh-CN");
  16. DatePicker<DateTime?> refDate;
  17. DateTime? SelectedTime;
  18. [Inject]
  19. public MessageService MessageService { get; set; }
  20. DatePickerLocale CN = new DatePickerLocale
  21. {
  22. FirstDayOfWeek = DayOfWeek.Sunday,
  23. Lang = new DateLocale
  24. {
  25. YearFormat = "yyyy年",
  26. MonthFormat = "M月",
  27. DateSelect = "选择日期",
  28. WeekSelect = "选择周",
  29. MonthSelect = "选择月份",
  30. YearSelect = "选择年份",
  31. QuarterSelect = "选择季度",
  32. Today = "今天"
  33. }
  34. };
  35. [Inject]
  36. PerformanceItemServices pService { get; set; }
  37. private async Task ShowSelectedDate()
  38. {
  39. if (SelectedTime != null)
  40. {
  41. int year = SelectedTime.Value.Year;
  42. int quartar = 1;
  43. if (SelectedTime.Value.Month <= 3)
  44. {
  45. quartar = 1;
  46. }
  47. else
  48. {
  49. if (SelectedTime.Value.Month <= 6)
  50. {
  51. quartar = 2;
  52. }
  53. else
  54. {
  55. if (SelectedTime.Value.Month <= 9)
  56. {
  57. quartar = 3;
  58. }
  59. else
  60. {
  61. quartar = 4;
  62. }
  63. }
  64. }
  65. //await pService.StatisticsLevelCount(year, 1);
  66. //await pService.StatisticsLevelCount(year, 2);
  67. //await pService.StatisticsLevelCount(year, 3);
  68. try
  69. {
  70. AResult = await pService.CalAgentLevel(SelectedTime.Value.Year, quartar, "A");
  71. BResult = await pService.CalAgentLevel(SelectedTime.Value.Year, quartar, "B");
  72. CResult = await pService.CalAgentLevel(SelectedTime.Value.Year, quartar, "C");
  73. DResult = await pService.CalAgentLevel(SelectedTime.Value.Year, quartar, "D");
  74. }
  75. catch (Exception ex)
  76. {
  77. AResult = new LevelStatisticsResult();
  78. BResult = new LevelStatisticsResult();
  79. CResult = new LevelStatisticsResult();
  80. DResult = new LevelStatisticsResult();
  81. await MessageService.Error($"【{SelectedTime.Value.Year}】年【{quartar}】季度等级数据还没有汇总!");
  82. }
  83. StateHasChanged();
  84. }
  85. }
  86. [Inject] protected IAuthService _authService { get; set; }
  87. LevelStatisticsResult AResult;
  88. LevelStatisticsResult BResult;
  89. LevelStatisticsResult CResult;
  90. LevelStatisticsResult DResult;
  91. protected override async Task OnInitializedAsync()
  92. {
  93. await _authService.CanVisitResource();
  94. if (SelectedTime == null)
  95. {
  96. SelectedTime = DateTime.Now.AddMonths(-3);
  97. }
  98. //AResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "A");
  99. //BResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "B");
  100. //CResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "C");
  101. //DResult = await pService.CalAgentLevel(SelectedTime.Value.Year, 1, "D");
  102. await base.OnInitializedAsync();
  103. await ShowSelectedDate();
  104. }
  105. }
  106. }