|
@@ -528,52 +528,54 @@ public class TestController : BaseController
|
|
|
public async Task TestExportExcel()
|
|
|
{
|
|
|
var orders = await _orderRepository.Queryable()
|
|
|
- .Includes(d => d.Workflow, x => x.Steps.Where(d => d.BusinessType == EBusinessType.Send))
|
|
|
- .Where(d=>SqlFunc.Exists(d.Workflow.Steps.Any(d=>d.BusinessType == EBusinessType.Send)))
|
|
|
+ //.Includes(d => d.Workflow, x => x.Steps.Where(d => d.BusinessType == EBusinessType.Send))
|
|
|
+ //.Where(d=>d.Workflow.Steps.Any(d=>d.BusinessType == EBusinessType.Send))
|
|
|
.Where(d => d.Status != EOrderStatus.WaitForAccept && d.CenterToOrgTime == null)
|
|
|
.ToListAsync(HttpContext.RequestAborted);
|
|
|
|
|
|
+ var orderIds = orders.Select(d => d.Id).ToList();
|
|
|
+ var steps = await _workflowStepRepository.Queryable()
|
|
|
+ .Where(d => orderIds.Contains(d.ExternalId) &&
|
|
|
+ d.BusinessType == EBusinessType.Send &&
|
|
|
+ d.Status == EWorkflowStepStatus.Handled)
|
|
|
+ .OrderBy(d=>d.CreationTime)
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
+
|
|
|
var updateOrders = new List<Order>();
|
|
|
+ foreach (var order in orders)
|
|
|
+ {
|
|
|
+ var step = steps.Where(d => d.ExternalId == order.Id)
|
|
|
+ .OrderBy(d => d.CreationTime)
|
|
|
+ .FirstOrDefault();
|
|
|
+ if(step is null) continue;
|
|
|
|
|
|
+ order.CenterToOrgTime = step.HandleTime;
|
|
|
+ order.CenterToOrgHandlerId = step.HandlerId;
|
|
|
+ order.CenterToOrgHandlerName = step.HandlerName;
|
|
|
+ order.CenterToOrgOpinion = step.Opinion;
|
|
|
|
|
|
- //var items = await _orderRepository.Queryable()
|
|
|
- // .LeftJoin<WorkflowStep>((o, s) => o.Id == s.ExternalId)
|
|
|
- // .Where((o, s) => o.CenterToOrgTime == null && s.BusinessType == EBusinessType.Send)
|
|
|
- // .Select((o, s) => new { o, s })
|
|
|
- // .ToListAsync(HttpContext.RequestAborted);
|
|
|
+ var handleDuration = order.CenterToOrgTime.HasValue && order.ActualHandleTime.HasValue
|
|
|
+ ? _timeLimitDomainService.CalcWorkTime(order.CenterToOrgTime.Value,
|
|
|
+ order.ActualHandleTime.Value, order.ProcessType is EProcessType.Zhiban)
|
|
|
+ : 0;
|
|
|
+ var fileDuration = order.CenterToOrgTime.HasValue && order.FiledTime.HasValue
|
|
|
+ ? _timeLimitDomainService.CalcWorkTime(order.CenterToOrgTime.Value,
|
|
|
+ order.FiledTime.Value, order.ProcessType is EProcessType.Zhiban)
|
|
|
+ : 0;
|
|
|
+ //var allDuration = order.StartTime.HasValue
|
|
|
+ // ? _timeLimitDomainService.CalcWorkTime(order.StartTime.Value, order.FiledTime.Value,
|
|
|
+ // order.ProcessType is EProcessType.Zhiban)
|
|
|
+ // : 0;
|
|
|
+ order.SetHandleDuration();
|
|
|
+ order.SetFileDuration();
|
|
|
|
|
|
- //var orders = new List<Order>();
|
|
|
- //foreach (var item in items)
|
|
|
- //{
|
|
|
- // if (item.o.CenterToOrgTime is not null) continue;
|
|
|
-
|
|
|
- // item.o.CenterToOrgTime = item.s.HandleTime;
|
|
|
- // item.o.CenterToOrgHandlerId = item.s.HandlerId;
|
|
|
- // item.o.CenterToOrgHandlerName = item.s.HandlerName;
|
|
|
- // item.o.CenterToOrgOpinion = item.s.Opinion;
|
|
|
-
|
|
|
- // var handleDuration = item.o.CenterToOrgTime.HasValue && item.o.ActualHandleTime.HasValue
|
|
|
- // ? _timeLimitDomainService.CalcWorkTime(item.o.CenterToOrgTime.Value,
|
|
|
- // item.o.ActualHandleTime.Value, item.o.ProcessType is EProcessType.Zhiban)
|
|
|
- // : 0;
|
|
|
- // var fileDuration = item.o.CenterToOrgTime.HasValue
|
|
|
- // ? _timeLimitDomainService.CalcWorkTime(item.o.CenterToOrgTime.Value,
|
|
|
- // item.o.FiledTime.Value, item.o.ProcessType is EProcessType.Zhiban)
|
|
|
- // : 0;
|
|
|
- // //var allDuration = item.o.StartTime.HasValue
|
|
|
- // // ? _timeLimitDomainService.CalcWorkTime(item.o.StartTime.Value, item.o.FiledTime.Value,
|
|
|
- // // item.o.ProcessType is EProcessType.Zhiban)
|
|
|
- // // : 0;
|
|
|
- // item.o.SetHandleDuration();
|
|
|
- // item.o.SetFileDuration();
|
|
|
-
|
|
|
- // item.o.HandleDurationWorkday = handleDuration;
|
|
|
- // item.o.FileDurationWorkday = fileDuration;
|
|
|
-
|
|
|
- // orders.Add(item.o);
|
|
|
- //}
|
|
|
+ order.HandleDurationWorkday = handleDuration;
|
|
|
+ order.FileDurationWorkday = fileDuration;
|
|
|
|
|
|
- await _orderRepository.UpdateRangeAsync(orders, HttpContext.RequestAborted);
|
|
|
+ updateOrders.Add(order);
|
|
|
+ }
|
|
|
+
|
|
|
+ await _orderRepository.UpdateRangeAsync(updateOrders, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|