Browse Source

派单量统计

田爽 4 months ago
parent
commit
ab71f19d41

+ 14 - 9
src/Hotline.Application/Orders/OrderApplication.cs

@@ -94,8 +94,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
     private readonly IRepository<OrderPublishHistory> _orderPublishHistoryRepository;
     private readonly IOrderDelayRepository _orderDelayRepository;
     private readonly IRepository<OrderSecondaryHandling> _orderSecondaryHandlingRepository;
+    private readonly IRepository<SchedulingUser> _schedulingUserRepository;
 
-    public OrderApplication(
+	public OrderApplication(
         IOrderDomainService orderDomainService,
         IOrderRepository orderRepository,
         IWorkflowDomainService workflowDomainService,
@@ -133,7 +134,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         IOrderTerminateRepository orderTerminateRepository,
         IRepository<OrderPublishHistory> orderPublishHistoryRepository,
         IRepository<OrderSecondaryHandling> orderSecondaryHandlingRepository,
-        IOrderDelayRepository orderDelayRepository)
+        IRepository<SchedulingUser> schedulingUserRepository,
+		IOrderDelayRepository orderDelayRepository)
     {
         _orderDomainService = orderDomainService;
         _workflowDomainService = workflowDomainService;
@@ -173,6 +175,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         _sessionContext = sessionContext;
         _orderDelayRepository = orderDelayRepository;
         _orderSecondaryHandlingRepository = orderSecondaryHandlingRepository;
+        _schedulingUserRepository = schedulingUserRepository;
     }
 
     /// <summary>
@@ -3301,15 +3304,17 @@ public class OrderApplication : IOrderApplication, IScopeDependency
                 SendOrderNum = 0,
                 NoSendOrderNum = SqlFunc.AggregateDistinctCount(w.ExternalId),
             });
-        var items = await itemsHandled.LeftJoin(itemsNo, (hand, nohand) => hand.UserId == nohand.UserId)
-            .GroupBy((hand, nohand) => new { hand.UserId, hand.UserName })
-            .Select((hand, nohand) => new BiOrderSendVo
-            {
-                UserId = hand.UserId,
-                UserName = hand.UserName,
+        var items = await _schedulingUserRepository.Queryable()
+		    .LeftJoin(itemsHandled,(all, hand)=> all.UserId == hand.UserId)
+			.LeftJoin(itemsNo, (all, hand, nohand) => hand.UserId == nohand.UserId)
+            .GroupBy((all, hand, nohand) => new { all.UserId, all.UserName })
+            .Select((all, hand, nohand) => new BiOrderSendVo
+            {
+                UserId = all.UserId,
+                UserName = all.UserName,
                 SendOrderNum = SqlFunc.AggregateSum(hand.SendOrderNum),
                 NoSendOrderNum = SqlFunc.AggregateSum(nohand.NoSendOrderNum),
-            }).ToListAsync();
+            }).MergeTable().Where(vo=> vo.SendOrderNum > 0 || vo.NoSendOrderNum > 0).ToListAsync();
 
         var items2 = await _workflowTraceRepository.Queryable()
             .LeftJoin<Workflow>((x, w) => x.WorkflowId == w.Id)

+ 5 - 3
src/Hotline.Repository.SqlSugar/Orders/OrderRepository.cs

@@ -522,7 +522,8 @@ namespace Hotline.Repository.SqlSugar.Orders
 						{
 							var num = string.IsNullOrEmpty(list.Rows[i][j].ToString()) ? 0 : int.Parse(list.Rows[i][j].ToString());
 							var oldRow = oldData.AsEnumerable().Where(x => x.Field<string>("_Hour") == list.Rows[i]["hour"]).FirstOrDefault();
-							var allNum = oldRow == null ? num : oldRow.Field<int>(dtList.Columns[i].ColumnName) + num;
+							var oldColName = "_" + dtList.Columns[i].ColumnName;
+							var allNum = oldRow == null ? num : oldRow.Field<int>(oldColName) + num;
 							newRow[j] = allNum;
 						}
 					}
@@ -596,10 +597,10 @@ namespace Hotline.Repository.SqlSugar.Orders
               .Select((x, p) => new
               {
                   Hour = x.ColumnName.ToString() + ":00 - " + x.ColumnName.ToString() + ":59",
-                  p.DicDataName,
+                  p.DicDataValue,
                   p.count
               })
-               .ToPivotTableAsync(p => p.DicDataName, p => p.Hour, p => p.Sum(x => x.count));
+               .ToPivotTableAsync(p => p.DicDataValue, p => p.Hour, p => p.Sum(x => x.count));
 			var dtList = list.Clone();
 
 			if (await Db.Queryable<StatisticsPurTypeSatisfied>().Where(x => x.Time >= dto.StartTime && x.Time <= dto.EndTime).AnyAsync())
@@ -644,6 +645,7 @@ namespace Hotline.Repository.SqlSugar.Orders
 						{
 							var num = string.IsNullOrEmpty(list.Rows[i][j].ToString()) ? 0 : int.Parse(list.Rows[i][j].ToString());
 							var oldRow = oldData.AsEnumerable().Where(x => x.Field<string>("_Hour") == list.Rows[i]["hour"]).FirstOrDefault();
+							var oldColName = "_" + dtList.Columns[i].ColumnName;
 							var allNum = oldRow == null ? num : oldRow.Field<int>(dtList.Columns[i].ColumnName) + num;
 							newRow[j] = allNum;
 						}