Parcourir la source

自贡任务 568 调整【坐席小休统计表】各时间统计结果下的显示

tangjiang il y a 1 semaine
Parent
commit
3c3b13ade1

+ 72 - 0
src/Hotline.Api/Controllers/Bi/BiCallController.cs

@@ -29,6 +29,7 @@ using Hotline.Application.StatisticalReport.CallReport;
 using DocumentFormat.OpenXml.Spreadsheet;
 using DocumentFormat.OpenXml.Wordprocessing;
 using NPOI.SS.Formula.Functions;
+using static System.Runtime.InteropServices.JavaScript.JSType;
 
 namespace Hotline.Api.Controllers.Bi;
 
@@ -470,6 +471,77 @@ public class BiCallController : BaseController
             "坐席话务统计分析明细");
     }
 
+    /// <summary>
+    /// 小休统计
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpGet("restsday")]
+    [AllowAnonymous]
+    public async Task<IReadOnlyList<BiSeatRestDto>> QuerySeatRestDay([FromQuery] QuerySeatRestRequest dto)
+    {
+        return await _telRestRepository.Queryable()
+            .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
+            .WhereIF(!string.IsNullOrEmpty(dto.StaffNo), x => x.StaffNo.Contains(dto.StaffNo))
+            .Where(x => x.CreationTime >= dto.StartTime)
+            .Where(x => x.CreationTime <= dto.EndTime)
+            .GroupBy(x => new { DayTime = x.CreationTime.ToString("yyyy-MM-dd"), x.UserId, x.StaffNo, x.UserName })
+            .Select(x => new BiSeatRestDto
+            {
+                DayTime= x.CreationTime.ToString("yyyy-MM-dd"),
+                UserId = x.UserId,
+                StaffNo = x.StaffNo,
+                UserName = x.UserName,
+                RestCount = SqlFunc.AggregateCount(x.Id),
+                RestDuration = SqlFunc.AggregateSum(x.RestDuration / 60) / SqlFunc.AggregateCount(x.Id),
+                CumulativeDuration = SqlFunc.AggregateSum(x.RestDuration / 60)
+            })
+            .OrderByIF(dto.SortRule is 0, a => a.RestDuration, OrderByType.Asc)
+            .OrderByIF(dto.SortRule is 1, a => a.RestDuration, OrderByType.Desc)
+            .MergeTable()
+            .ToListAsync(HttpContext.RequestAborted);
+    }
+
+    /// <summary>
+    /// 小休统计
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpPost("restsday/export")]
+    [LogFilterAlpha("导出日志")]
+    public async Task<FileStreamResult> QuerySeatRestDayExport([FromBody] ExportExcelDto<QuerySeatRestRequest> dto)
+    {
+        var query = await _telRestRepository.Queryable()
+            .WhereIF(!string.IsNullOrEmpty(dto.QueryDto.UserName), x => x.UserName.Contains(dto.QueryDto.UserName))
+            .WhereIF(!string.IsNullOrEmpty(dto.QueryDto.StaffNo), x => x.StaffNo.Contains(dto.QueryDto.StaffNo))
+            .Where(x => x.CreationTime >= dto.QueryDto.StartTime)
+            .Where(x => x.CreationTime <= dto.QueryDto.EndTime)
+             .GroupBy(x => new { DayTime = x.CreationTime.ToString("yyyy-MM-dd"), x.UserId, x.StaffNo, x.UserName })
+            .Select(x => new BiSeatRestDto
+            {
+                DayTime = x.CreationTime.ToString("yyyy-MM-dd"),
+                UserId = x.UserId,
+                StaffNo = x.StaffNo,
+                UserName = x.UserName,
+                RestCount = SqlFunc.AggregateCount(x.Id),
+                RestDuration = SqlFunc.AggregateSum(x.RestDuration / 60) / SqlFunc.AggregateCount(x.Id),
+                CumulativeDuration = SqlFunc.AggregateSum(x.RestDuration / 60)
+            })
+            .OrderByIF(dto.QueryDto.SortRule is 0, a => a.RestDuration, OrderByType.Asc)
+            .OrderByIF(dto.QueryDto.SortRule is 1, a => a.RestDuration, OrderByType.Desc)
+            .MergeTable()
+            .ToListAsync(HttpContext.RequestAborted);
+
+        dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass<BiSeatRestDto>(dto.ColumnInfos);
+
+        var dtos = _mapper.Map<ICollection<BiSeatRestDto>>(query)
+                          .Select(stu => _mapper.Map(stu, typeof(BiSeatRestDto), dynamicClass))
+                          .Cast<object>()
+                          .ToList();
+
+        var stream = ExcelHelper.CreateStream(dtos);
+        return ExcelStreamResult(stream, "座席小休统计表");
+    }
 
     /// <summary>
     /// 小休统计

+ 2 - 0
src/Hotline.Share/Dtos/CallCenter/BiSeatCallsDto.cs

@@ -141,6 +141,8 @@ public class BiSeatCallsDto
 
 public class BiSeatRestDto
 {
+    public string DayTime { get; set; }
+
     public string UserId { get; set; }
     public string? StaffNo { get; set; }