|
@@ -28,9 +28,9 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
|
|
|
public async Task<string> AddAsync(Order order, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- if (order.AcceptType == EAcceptType.Complain && order.OrderComplain == null)
|
|
|
+ if (order.OrderType == EOrderType.MarketSupervisionBy12315 && order.AcceptType == EAcceptType.Complain && order.OrderComplain == null)
|
|
|
throw UserFriendlyException.SameMessage("非法投诉参数");
|
|
|
- if (order.AcceptType == EAcceptType.Report && order.OrderReport == null)
|
|
|
+ if (order.OrderType == EOrderType.MarketSupervisionBy12315 && order.AcceptType == EAcceptType.Report && order.OrderReport == null)
|
|
|
throw UserFriendlyException.SameMessage("非法举报参数");
|
|
|
|
|
|
order.Init(_sessionContext.RequiredUserId);
|
|
@@ -42,53 +42,100 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
/// <summary>
|
|
|
/// 归档
|
|
|
/// </summary>
|
|
|
- public async Task FileAsync(string orderId, CancellationToken cancellationToken)
|
|
|
+ public async Task FileAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var order = await _orderRepository.GetAsync(orderId, cancellationToken);
|
|
|
+ var order = await _orderRepository.GetAsync(d => d.WorkflowId == workflowId, cancellationToken);
|
|
|
if (order == null)
|
|
|
- throw UserFriendlyException.SameMessage("无效的工单编号");
|
|
|
+ throw new UserFriendlyException($"无效工单流程编号, workflowId: {workflowId}", "无效工单编号");
|
|
|
+ if (order.Status is EOrderStatus.Filed) return;
|
|
|
order.Status = EOrderStatus.Filed;
|
|
|
await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 接办工单(查看详情视为接办)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="workflowId"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task AcceptAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ order.Accept();
|
|
|
+ await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 工单办理(每个节点都会触发)
|
|
|
/// </summary>
|
|
|
- public async Task OrderManageAsync(EOrderStatus status, FlowAssignMode assignMode,
|
|
|
+ public async Task ManageFlowNextAsync(FlowAssignMode assignMode,
|
|
|
bool isCountersignEnd, bool isCountersignStart,
|
|
|
string workflowId, DateTime? currentStepTime, string? CurrentStepName, DateTime expiredTime,
|
|
|
CancellationToken cancellationToken)
|
|
|
{
|
|
|
- var order = await _orderRepository.GetAsync(d => d.WorkflowId == workflowId, cancellationToken);
|
|
|
- if (order == null)
|
|
|
- throw new UserFriendlyException($"无效工单流程编号, workflowId: {workflowId}", "无效工单编号");
|
|
|
- if (order.Status is EOrderStatus.Filed) return;
|
|
|
+ var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
|
|
|
//更新指派信息
|
|
|
order.Assign(assignMode.FlowAssignType, assignMode.Handlers);
|
|
|
|
|
|
- //1.如果order未处于会签中,则判断是否发起会签(isstartCountersign) 2.如果处于会签中,则判断会签是否结束(isCountersignEnd)
|
|
|
- if (order.Status is EOrderStatus.Countersigning && isCountersignEnd)
|
|
|
- {
|
|
|
- order.Status = EOrderStatus.WaitForSign;
|
|
|
- }
|
|
|
- else if (order.Status is not EOrderStatus.Countersigning && isCountersignStart)
|
|
|
- {
|
|
|
- order.Status = EOrderStatus.Countersigning;
|
|
|
- }
|
|
|
+ //更新流转信息
|
|
|
+ order.ManageFlow(isCountersignStart, isCountersignEnd, currentStepTime, CurrentStepName, expiredTime);
|
|
|
+
|
|
|
+ await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
+
|
|
|
+ //todo push msg to next step handler
|
|
|
+ }
|
|
|
|
|
|
- order.CurrentStepTime = currentStepTime;
|
|
|
- order.CurrentStepName = CurrentStepName;
|
|
|
- order.ExpiredTime = expiredTime;
|
|
|
- order.Status = status;
|
|
|
+ /// <summary>
|
|
|
+ /// 工单最终办理(此完结流程并未结束)
|
|
|
+ /// </summary>
|
|
|
+ /// <remarks>
|
|
|
+ /// 需求:工单实际办理部门办理完成视为工单最终办理完结,
|
|
|
+ /// 实际办理部门指:1.第一个汇总节点的前一个非汇总节点代表的办理部门 2.汇总以后如果再次开启会签需将工单回退到未办理完结的状态重新等待下一个汇总节点
|
|
|
+ /// </remarks>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task FinalManageAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ order.FinalManage();
|
|
|
+ await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
+ }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 取消最终办理(汇总以后又重新指派到非汇总汇总节点办理的场景)
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task RecallFinalManageAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ order.RecallFinalManage();
|
|
|
await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
+ }
|
|
|
|
|
|
- //todo push msg
|
|
|
+ /// <summary>
|
|
|
+ /// 工单办理流程流转到结束节点
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="workflowId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task ManageFlowEndAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var order = await GetOrderAsync(workflowId, cancellationToken);
|
|
|
+ order.Filed();
|
|
|
+ await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
}
|
|
|
|
|
|
#region private
|
|
|
|
|
|
+ private async Task<Order> GetOrderAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var order = await _orderRepository.GetAsync(d => d.WorkflowId == workflowId, cancellationToken);
|
|
|
+ if (order == null)
|
|
|
+ throw new UserFriendlyException($"无效工单流程编号, workflowId: {workflowId}", "无效工单编号");
|
|
|
+ if (order.Status is EOrderStatus.Filed)
|
|
|
+ throw UserFriendlyException.SameMessage("工单已归档");
|
|
|
+ return order;
|
|
|
+ }
|
|
|
+
|
|
|
private string GenerateNewOrderNo()
|
|
|
{
|
|
|
var today = DateTime.Today;
|