|
@@ -596,5 +596,60 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 部门考核统计-随手拍
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <exception cref="NotImplementedException"></exception>
|
|
|
+ public ISugarQueryable<SnapshotDepartmentStatisticsOutDto> GetSnapshotDepartmentStatistics(SnapshotDepartmentStatisticsInDto dto)
|
|
|
+ {
|
|
|
+ bool IsCenter = _sessionContext.OrgIsCenter;
|
|
|
+ var orgLevel = _sessionContext.OrgLevel;
|
|
|
+ string orgLevelStr = (_sessionContext.RequiredOrgId.Length + 3).ToString();
|
|
|
+
|
|
|
+ var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
+ .LeftJoin<Order>((snapshot, order) => snapshot.Id == order.Id)
|
|
|
+ .LeftJoin<OrderSendBackAudit>((snapshot, order, back) => snapshot.Id == back.OrderId && back.State == ESendBackAuditState.End)
|
|
|
+ .LeftJoin<OrderVisit>((snapshot, order, back, visit) => snapshot.Id == visit.OrderId && visit.VisitState == EVisitState.Visited)
|
|
|
+ .LeftJoin<OrderSecondaryHandling>((snapshot, order, back, visit, second) => snapshot.Id == second.OrderId && second.State == ESecondaryHandlingState.End)
|
|
|
+ .Where((snapshot, order) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && order.ActualHandleOrgCode != null)
|
|
|
+ .GroupBy((snapshot, order) => new
|
|
|
+ {
|
|
|
+ OrgCode = order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))
|
|
|
+ })
|
|
|
+ .Select((snapshot, order, back, visit, second) => new SnapshotDepartmentStatisticsOutDto()
|
|
|
+ {
|
|
|
+ OrgCode = order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ OrderCountNum = SqlFunc.AggregateCount(snapshot.Id),
|
|
|
+ ReceiveIn4Hour = SqlFunc.AggregateCount(SqlFunc.IIF(order.ActualHandleStepCreateTime != null && order.ActualHandleStepCreateTime.Value.AddHours(-4) <= order.CreationTime, 1, 0)),
|
|
|
+ TimeOutField = SqlFunc.AggregateCount(SqlFunc.IIF(order.Status >= EOrderStatus.Filed && order.FiledTime > order.ExpiredTime, 1, 0)),
|
|
|
+ TimeOutNoField = SqlFunc.AggregateCount(SqlFunc.IIF(order.Status < EOrderStatus.Filed && DateTime.Now > order.ExpiredTime, 1, 0)),
|
|
|
+ OnTimeCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.FiledTime <= order.ExpiredTime, 1, 0)),
|
|
|
+ SatisfiedCount = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(visit.NowEvaluate, "key", "1") || SqlFunc.JsonListObjectAny(visit.NowEvaluate, "key", "2"), 1, 0)),
|
|
|
+ NoSatisfiedCount = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(visit.NowEvaluate, "key", "1") || SqlFunc.JsonListObjectAny(visit.NowEvaluate, "key", "2"), 0, 1)),
|
|
|
+ SecondNum = SqlFunc.AggregateCount(second.Id),
|
|
|
+ FirstFiledOrderCount = SqlFunc.AggregateCount(SqlFunc.IIF(order.Status >= EOrderStatus.Filed && second.Id == null, 1, 0)),
|
|
|
+ SecondSatisfied = SqlFunc.AggregateCount(SqlFunc.IIF(second.State == ESecondaryHandlingState.Handled && (SqlFunc.JsonField(order.OrgProcessingResults, "Key") == "1" || SqlFunc.JsonField(order.OrgProcessingResults, "Key") == "2"), 1, 0)),
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .LeftJoin<SystemOrganize>((it, o) => it.OrgCode == o.Id)
|
|
|
+ .Select((it, o) => new SnapshotDepartmentStatisticsOutDto()
|
|
|
+ {
|
|
|
+ OrgName = o.Name,
|
|
|
+ OrgCode = it.OrgCode,
|
|
|
+ ReceiveIn4Hour = it.ReceiveIn4Hour,
|
|
|
+ TimeOutField = it.TimeOutField,
|
|
|
+ TimeOutNoField = it.TimeOutNoField,
|
|
|
+ OnTimeCount = it.OnTimeCount,
|
|
|
+ SatisfiedCount = it.SatisfiedCount,
|
|
|
+ NoSatisfiedCount = it.NoSatisfiedCount,
|
|
|
+ SecondNum = it.SecondNum,
|
|
|
+ FirstFiledOrderCount = it.FirstFiledOrderCount,
|
|
|
+ SecondSatisfied = it.SecondSatisfied
|
|
|
+ });
|
|
|
+
|
|
|
+ return query;
|
|
|
+ }
|
|
|
|
|
|
}
|