Dun.Jason 4 днів тому
батько
коміт
713f958280

+ 14 - 25
src/Hotline.Application/Handlers/FlowEngine/WorkflowEndHandler.cs

@@ -70,7 +70,8 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
         ILogger<WorkflowEndHandler> logger,
         ICalcExpireTime expireTime,
         IRepository<OrderTerminate> orderTerminateRepository,
-        IRepository<OrderSecondaryHandling> orderSecondaryHandlingRepository)
+        IRepository<OrderSecondaryHandling> orderSecondaryHandlingRepository,
+        IRepository<Scheduling> schedulingRepository)
     {
         _mapper = mapper;
         _knowledgeDomainService = knowledgeDomainService;
@@ -89,6 +90,7 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
         _expireTime = expireTime;
         _orderTerminateRepository = orderTerminateRepository;
         _orderSecondaryHandlingRepository = orderSecondaryHandlingRepository;
+        _schedulingRepository = schedulingRepository;
     }
 
     /// <summary>Handles a notification</summary>
@@ -224,31 +226,18 @@ public class WorkflowEndHandler : INotificationHandler<EndWorkflowNotify>
                         //随机派单员(市中心综合办)
                         if (order.FileUserOrgId == "001175")
                         {
-                            //try
-                            //{
-                            //    var schedulingList = await _schedulingRepository.Queryable().Includes(x => x.SchedulingUser).Where(x => x.SchedulingTime!.Value.Date == DateTime.Now.Date).ToListAsync();
-                            //    if (schedulingList != null && schedulingList.Count > 0)
-                            //    {
-                            //        int randomNum = Random.Shared.Next(schedulingList.Count);
-                            //        var userId = schedulingList[randomNum].SchedulingUser.UserId;
-                            //        order.WaitForPublisherId = userId;
-                            //    }
-                            //}
-                            //catch (Exception ex)
-                            //{
-                            //    throw UserFriendlyException.SameMessage(ex.Message);
-                            //}
-                            //finally
-                            //{
-                            //    _logger.LogInformation("进入了");
-                            //}
-
-                            var schedulingList = await _schedulingRepository.Queryable().Includes(x => x.SchedulingUser).Where(x => x.SchedulingTime!.Value.Date == DateTime.Now.Date).ToListAsync();
-                            if (schedulingList != null && schedulingList.Count > 0)
+                            try
+                            {
+                                var schedulingList = await _schedulingRepository.Queryable().Includes(x => x.SchedulingUser).Where(x => x.SchedulingTime!.Value.Date == DateTime.Now.Date).ToListAsync();
+                                if (schedulingList != null && schedulingList.Count > 0)
+                                {
+                                    int randomNum = Random.Shared.Next(schedulingList.Count);
+                                    var userId = schedulingList[randomNum].SchedulingUser.UserId;
+                                    order.WaitForPublisherId = userId;
+                                }
+                            }
+                            catch
                             {
-                                int randomNum = Random.Shared.Next(schedulingList.Count);
-                                var userId = schedulingList[randomNum].SchedulingUser.UserId;
-                                order.WaitForPublisherId = userId;
                             }
                         }
                     }