|
@@ -46,11 +46,9 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
/// <summary>
|
|
|
/// 归档
|
|
|
/// </summary>
|
|
|
- public async Task FileAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ public async Task FileAsync(string? orderId, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var order = await _orderRepository.GetAsync(d => d.WorkflowId == workflowId, cancellationToken);
|
|
|
- if (order == null)
|
|
|
- throw new UserFriendlyException($"无效工单流程编号, workflowId: {workflowId}", "无效工单编号");
|
|
|
+ var order = await GetOrderAsync(orderId, cancellationToken);
|
|
|
if (order.Status is EOrderStatus.Filed) return;
|
|
|
order.Status = EOrderStatus.Filed;
|
|
|
await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
@@ -59,12 +57,10 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
/// <summary>
|
|
|
/// 接办工单(查看详情视为接办)
|
|
|
/// </summary>
|
|
|
- /// <param name="workflowId"></param>
|
|
|
- /// <param name="cancellationToken"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public async Task AcceptAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ public async Task AcceptAsync(string? orderId, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ var order = await GetOrderAsync(orderId, cancellationToken);
|
|
|
+ CheckOrderIfFiled(order);
|
|
|
order.Accept();
|
|
|
await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
}
|
|
@@ -74,11 +70,12 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
/// </summary>
|
|
|
public async Task ManageFlowNextAsync(FlowAssignMode assignMode,
|
|
|
bool isCountersignEnd, bool isCountersignStart,
|
|
|
- string workflowId, DateTime? currentStepTime, string? CurrentStepName, DateTime expiredTime,
|
|
|
+ string? orderId, DateTime? currentStepTime, string? CurrentStepName, DateTime expiredTime,
|
|
|
CancellationToken cancellationToken)
|
|
|
{
|
|
|
_logger.LogInformation($"{nameof(ManageFlowNextAsync)}");
|
|
|
- var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ var order = await GetOrderAsync(orderId, cancellationToken);
|
|
|
+ CheckOrderIfFiled(order);
|
|
|
|
|
|
_logger.LogInformation($"{nameof(ManageFlowNextAsync)}, before: order.AssignUserIds: {string.Join(',', order.AssignUserIds)}, order.AssignOrgs: {string.Join(',', order.AssignOrgCodes)}");
|
|
|
//更新指派信息
|
|
@@ -101,9 +98,10 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
/// 实际办理部门指:1.第一个汇总节点的前一个非汇总节点代表的办理部门 2.汇总以后如果再次开启会签需将工单回退到未办理完结的状态重新等待下一个汇总节点
|
|
|
/// </remarks>
|
|
|
/// <returns></returns>
|
|
|
- public async Task FinalManageAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ public async Task FinalManageAsync(string? orderId, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ var order = await GetOrderAsync(orderId, cancellationToken);
|
|
|
+ CheckOrderIfFiled(order);
|
|
|
order.FinalManage();
|
|
|
await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
}
|
|
@@ -112,9 +110,10 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
/// 取消最终办理(汇总以后又重新指派到非汇总汇总节点办理的场景)
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public async Task RecallFinalManageAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ public async Task RecallFinalManageAsync(string? orderId, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ var order = await GetOrderAsync(orderId, cancellationToken);
|
|
|
+ CheckOrderIfFiled(order);
|
|
|
order.RecallFinalManage();
|
|
|
await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
}
|
|
@@ -122,25 +121,30 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
/// <summary>
|
|
|
/// 工单办理流程流转到结束节点
|
|
|
/// </summary>
|
|
|
- /// <param name="workflowId"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public async Task ManageFlowEndAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ public async Task ManageFlowEndAsync(string? orderId, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ var order = await GetOrderAsync(orderId, cancellationToken);
|
|
|
+ CheckOrderIfFiled(order);
|
|
|
order.Filed();
|
|
|
await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
}
|
|
|
|
|
|
#region private
|
|
|
|
|
|
- private async Task<Order> GetOrderAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ private async Task<Order> GetOrderAsync(string? orderId, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var order = await _orderRepository.GetAsync(d => d.WorkflowId == workflowId, cancellationToken);
|
|
|
+ if (string.IsNullOrEmpty(orderId))
|
|
|
+ throw UserFriendlyException.SameMessage("无效工单编号");
|
|
|
+ var order = await _orderRepository.GetAsync(orderId, cancellationToken);
|
|
|
if (order == null)
|
|
|
- throw new UserFriendlyException($"无效工单流程编号, workflowId: {workflowId}", "无效工单编号");
|
|
|
+ throw new UserFriendlyException($"无效工单编号, orderId: {orderId}", "无效工单编号");
|
|
|
+ return order;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CheckOrderIfFiled(Order order)
|
|
|
+ {
|
|
|
if (order.Status is EOrderStatus.Filed)
|
|
|
throw UserFriendlyException.SameMessage("工单已归档");
|
|
|
- return order;
|
|
|
}
|
|
|
|
|
|
private string GenerateNewOrderNo()
|