|
@@ -2222,25 +2222,47 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
/// <returns></returns>
|
|
|
public async Task<List<SendOrderReportOutDto>> SendOrderReportAsync(QuerySendOrderRequest dto)
|
|
|
{
|
|
|
- var items = await _workflowTraceRepository.Queryable()
|
|
|
+ var itemsHandled = _workflowTraceRepository.Queryable()
|
|
|
.LeftJoin<Workflow>((x, w) => x.WorkflowId == w.Id)
|
|
|
- //.LeftJoin<WorkflowStepHandler>((x, w, wsh) => x.StepId == wsh.WorkflowStepId && wsh.IsActualHandler == true)
|
|
|
.InnerJoin<SchedulingUser>((x, w, su) => x.HandlerId == su.UserId)
|
|
|
.Where((x, w, su) => w.ModuleCode == "OrderHandle" && x.BusinessType == EBusinessType.Send && x.Status == EWorkflowStepStatus.Handled)
|
|
|
.Where((x, w, su) => x.CreationTime >= dto.StartTime.Value)
|
|
|
.Where((x, w, su) => x.CreationTime <= dto.EndTime.Value)
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.UserName), (x, w, su) => su.UserName == dto.UserName)
|
|
|
.GroupBy((x, w, su) => new { su.UserId, su.UserName })
|
|
|
- //.Having((x, w, wsh, su) => SqlFunc.AggregateCount(x.WorkflowId) == 1)
|
|
|
.Select((x, w, su) => new BiOrderSendVo
|
|
|
{
|
|
|
UserId = su.UserId,
|
|
|
UserName = su.UserName,
|
|
|
SendOrderNum = SqlFunc.AggregateDistinctCount(w.ExternalId),
|
|
|
- NoSendOrderNum = SqlFunc.AggregateSum(SqlFunc.IIF(x.HandlerId == null || x.HandlerId == "", 1, 0)),
|
|
|
+ NoSendOrderNum = 0,
|
|
|
+ });
|
|
|
+ var itemsNo = _workflowTraceRepository.Queryable()
|
|
|
+ .LeftJoin<Workflow>((x, w) => x.WorkflowId == w.Id)
|
|
|
+ .InnerJoin<SchedulingUser>((x, w, su) => x.HandlerId == su.UserId)
|
|
|
+ .Where((x, w, su) => w.ModuleCode == "OrderHandle" && x.BusinessType == EBusinessType.Send && x.Status != EWorkflowStepStatus.Handled)
|
|
|
+ .Where((x, w, su) => x.CreationTime >= dto.StartTime.Value)
|
|
|
+ .Where((x, w, su) => x.CreationTime <= dto.EndTime.Value)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UserName), (x, w, su) => su.UserName == dto.UserName)
|
|
|
+ .GroupBy((x, w, su) => new { su.UserId, su.UserName })
|
|
|
+ .Select((x, w, su) => new BiOrderSendVo
|
|
|
+ {
|
|
|
+ UserId = su.UserId,
|
|
|
+ UserName = su.UserName,
|
|
|
+ SendOrderNum = 0,
|
|
|
+ NoSendOrderNum = SqlFunc.AggregateDistinctCount(w.ExternalId),
|
|
|
+ });
|
|
|
+ var items = await itemsHandled.LeftJoin(itemsNo, (hand, nohand) => hand.UserId == nohand.UserId)
|
|
|
+ .GroupBy((hand, nohand) => new { hand.UserId , hand.UserName } )
|
|
|
+ .Select((hand, nohand) => new BiOrderSendVo
|
|
|
+ {
|
|
|
+ UserId = hand.UserId,
|
|
|
+ UserName = hand.UserName,
|
|
|
+ SendOrderNum = SqlFunc.AggregateSum(hand.SendOrderNum),
|
|
|
+ NoSendOrderNum = SqlFunc.AggregateSum(nohand.NoSendOrderNum),
|
|
|
}).ToListAsync();
|
|
|
|
|
|
- var items2 = await _workflowTraceRepository.Queryable()
|
|
|
+ var items2 = await _workflowTraceRepository.Queryable()
|
|
|
.LeftJoin<Workflow>((x, w) => x.WorkflowId == w.Id)
|
|
|
//.LeftJoin<WorkflowStepHandler>((x, w, wfsh) => x.StepId == wfsh.WorkflowStepId && wfsh.IsActualHandler == true)
|
|
|
.InnerJoin<SchedulingUser>((x, w, su) => x.HandlerId == su.UserId)
|