|
@@ -695,4 +695,67 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
.Select((snapshot, order) => new SnapshotDepartmentAveTimeStatisticsDetailsOutDto(), true) ;
|
|
|
return query;
|
|
|
}
|
|
|
+
|
|
|
+ public ISugarQueryable<CompliantStatisticsOutDto> GetCompliantStatistics(CompliantStatisticsInDto 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 CompliantStatisticsOutDto()
|
|
|
+ {
|
|
|
+ OrgCode = order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ OrderCountNum = SqlFunc.AggregateCount(snapshot.Id),
|
|
|
+ First = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.CompliantType == ECompliantType.First, 1, 0)),
|
|
|
+ Second = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.CompliantType == ECompliantType.Second, 1, 0)),
|
|
|
+ Third = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.CompliantType == ECompliantType.Third, 1, 0)),
|
|
|
+ Not = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.CompliantType == ECompliantType.Not, 1, 0)),
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .LeftJoin<SystemOrganize>((it, o) => it.OrgCode == o.Id)
|
|
|
+ .Select((it, o) => new CompliantStatisticsOutDto()
|
|
|
+ {
|
|
|
+ OrgName = o.Name,
|
|
|
+ OrgCode = it.OrgCode,
|
|
|
+ OrderCountNum = it.OrderCountNum,
|
|
|
+ First = it.First,
|
|
|
+ Second = it.Second,
|
|
|
+ Third = it.Third,
|
|
|
+ Not = it.Not
|
|
|
+ });
|
|
|
+
|
|
|
+ return query;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ISugarQueryable<CompliantStatisticsDetailsOutDto> GetCompliantStatisticsDetails(CompliantStatisticsDetailsInDto dto)
|
|
|
+ {
|
|
|
+ dto.FieldName = dto.FieldName.ToLower();
|
|
|
+ var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
+ .LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
+ .Where((snapshot, order) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == dto.OrgCode);
|
|
|
+
|
|
|
+ query = dto.FieldName switch
|
|
|
+ {
|
|
|
+ "ordercountnum" => query,
|
|
|
+ "first" => query.Where(snapshot => snapshot.CompliantType == ECompliantType.First),
|
|
|
+ "second" => query.Where(snapshot => snapshot.CompliantType == ECompliantType.Second),
|
|
|
+ "third" => query.Where(snapshot => snapshot.CompliantType == ECompliantType.Third),
|
|
|
+ "not" => query.Where(snapshot => snapshot.CompliantType == ECompliantType.Not),
|
|
|
+ _ => throw new UserFriendlyException($"入参: {dto.FieldName} 异常")
|
|
|
+ };
|
|
|
+ return query.Select((snapshot, order) => new CompliantStatisticsDetailsOutDto
|
|
|
+ {
|
|
|
+ }, true);
|
|
|
+ }
|
|
|
+
|
|
|
}
|