|
@@ -172,6 +172,10 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
if (dto.Files.Any()) complement.FileJson = await _fileRepository.AddFileAsync(dto.Files, complement.Id, "", cancellationToken);
|
|
|
return await _orderComplementRepository.AddAsync(complement, cancellationToken);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region 平均派单
|
|
|
/// <summary>
|
|
|
/// 平均派单
|
|
@@ -188,53 +192,54 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
if (scheduling != null)
|
|
|
{
|
|
|
user = await _userRepository.GetAsync(x => x.Id == scheduling.SchedulingUser.UserId);
|
|
|
- scheduling.SendOrderNum++;
|
|
|
- await _schedulingRepository.UpdateAsync(scheduling);
|
|
|
+ scheduling.SendOrderNum++;
|
|
|
+ await _schedulingRepository.UpdateAsync(scheduling);
|
|
|
}
|
|
|
- List<Kv> res = new List<Kv>();
|
|
|
- res.Add(new Kv { Key = user.Id, Value = user.Name });
|
|
|
+ List<Kv> res = new List<Kv>();
|
|
|
+ res.Add(new Kv { Key = user.Id, Value = user.Name });
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 登录平均派单
|
|
|
- /// </summary>
|
|
|
- /// <param name="userId"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public async Task LogAverageOrder(string userId, CancellationToken cancellationToken)
|
|
|
- {
|
|
|
+ /// <summary>
|
|
|
+ /// 登录平均派单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="userId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task LogAverageOrder(string userId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
//1.获取默认派单员所属的工单
|
|
|
//2.获取今天上班的人员
|
|
|
//3.给当前这个用户平均派单
|
|
|
var steps = await _workflowDomainService.GetUnhandleStepIdsFromSendPoolAsync(OrderDefaults.SourceChannel.SendPoolId, cancellationToken);
|
|
|
- var stepsList = steps.ToList();
|
|
|
+ var stepsList = steps.ToList();
|
|
|
|
|
|
- var user = await _userRepository.GetAsync(userId,cancellationToken);
|
|
|
+ var user = await _userRepository.GetAsync(userId, cancellationToken);
|
|
|
DateTime time = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
|
|
|
var schedulings = await _schedulingRepository.Queryable().Includes(x => x.SchedulingUser)
|
|
|
.Where(x => x.SchedulingTime == time && x.WorkingTime <= DateTime.Now.TimeOfDay && x.OffDutyTime >= DateTime.Now.TimeOfDay).CountAsync(cancellationToken);
|
|
|
-
|
|
|
- if (schedulings > 0)
|
|
|
- {
|
|
|
+
|
|
|
+ if (schedulings > 0)
|
|
|
+ {
|
|
|
List<string> stepIds = new List<string>();
|
|
|
var sendNum = stepsList.Count() / schedulings;
|
|
|
- for (int i = 0; i < sendNum; i++)
|
|
|
- {
|
|
|
- stepIds.Add(stepsList[i]);
|
|
|
- stepsList.Remove(stepsList[i]);
|
|
|
+ for (int i = 0; i < sendNum; i++)
|
|
|
+ {
|
|
|
+ stepIds.Add(stepsList[i]);
|
|
|
+ stepsList.Remove(stepsList[i]);
|
|
|
}
|
|
|
- List<(string userId, string username, IReadOnlyList<string> stepIds)> handlers = new();
|
|
|
-; handlers.Add(new ValueTuple<string, string, IReadOnlyList<string>>(user.Id, user.Name, stepIds));
|
|
|
- await _workflowDomainService.ChangeHandlerRangeAsync(OrderDefaults.SourceChannel.SendPoolId ,handlers, cancellationToken);
|
|
|
+ List<(string userId, string username, IReadOnlyList<string> stepIds)> handlers = new();
|
|
|
+ ; handlers.Add(new ValueTuple<string, string, IReadOnlyList<string>>(user.Id, user.Name, stepIds));
|
|
|
+ await _workflowDomainService.ChangeHandlerRangeAsync(OrderDefaults.SourceChannel.SendPoolId, handlers, cancellationToken);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 触发平均派单
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- public async Task TriggerAverageOrder(CancellationToken cancellationToken) {
|
|
|
+ /// <summary>
|
|
|
+ /// 触发平均派单
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task TriggerAverageOrder(CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
//1.从排班里面获取今天上班的人
|
|
|
//2.获取默认派单员剩下的工单
|
|
|
//3.平均分配剩下的工单给今天上班的人
|
|
@@ -285,8 +290,6 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- #endregion
|
|
|
-
|
|
|
#region SchedulingSendOrder
|
|
|
|
|
|
|