TANG JIANG há 1 ano atrás
pai
commit
62f86affea

+ 78 - 26
src/Hotline.Api/Controllers/Bi/BiOrderController.cs

@@ -1498,7 +1498,6 @@ namespace Hotline.Api.Controllers.Bi
             #region 工单
             var queryOrder = _orderRepository.Queryable()
                          .Where(it => it.CreationTime >= StartDate && it.CreationTime <= EndDate && it.Status > EOrderStatus.WaitForAccept)
-                          .WhereIF(!string.IsNullOrEmpty(OrgName), it => it.ActualHandleOrgName.Contains(OrgName))
                          .Select(it => new
                          {
                              it.Id,
@@ -1548,7 +1547,6 @@ namespace Hotline.Api.Controllers.Bi
             var queryPublish = _orderPublishRepository.Queryable()
                 .LeftJoin<Order>((x, o) => x.OrderId == o.Id)
                 .Where((x, o) => x.CreationTime >= StartDate && x.CreationTime <= EndDate)
-                .WhereIF(!string.IsNullOrEmpty(OrgName), (x, o) => o.ActualHandleOrgName.Contains(OrgName))
                 .Select((x, o) => new
                 {
                     o.Id,
@@ -1590,9 +1588,8 @@ namespace Hotline.Api.Controllers.Bi
             #region 会签(已办超期、待办超期)
             //会签(已办超期、待办超期)
             var queryCountersign = _workflowStepHandleRepository.Queryable()
-           .LeftJoin<WorkflowTrace>((x, o) => x.WorkflowStepId == o.StepId)
+             .LeftJoin<WorkflowTrace>((x, o) => x.WorkflowStepId == o.StepId)
              .Where((x, o) => o.ModuleCode == WorkflowModuleConsts.OrderHandle && o.CountersignPosition == ECountersignPosition.Multi && o.CountersignPosition == ECountersignPosition.Single && o.CreationTime >= StartDate && o.CreationTime <= EndDate)
-               .WhereIF(!string.IsNullOrEmpty(OrgName), (x, o) => x.OrgName.Contains(OrgName))
              .Select((x, o) => new
              {
                  OrgCode = IsCenter == true ? x.OrgId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : x.OrgId.Substring(0, _sessionContext.RequiredOrgId.Length + 3),// d.OrgId,
@@ -1634,9 +1631,7 @@ namespace Hotline.Api.Controllers.Bi
             #region 延期
             //延期
             var orderDelay = _orderDelayRepository.Queryable()
-                .Where(x => x.CreationTime >= StartDate)
-                .Where(x => x.CreationTime <= EndDate)
-                .WhereIF(!string.IsNullOrEmpty(OrgName), x => x.ApplyOrgName.Contains(OrgName))
+                .Where(x => x.CreationTime >= StartDate&& x.CreationTime <= EndDate)
                 .Select(x => new
                 {
                     OrgCode = IsCenter == true ? x.ApplyOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : x.ApplyOrgCode.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
@@ -1676,8 +1671,7 @@ namespace Hotline.Api.Controllers.Bi
             #region 甄别
             //甄别
             var orderScreen = _orderScreenRepository.Queryable()
-                .Where(x => x.CreationTime >= StartDate)
-                .Where(x => x.CreationTime <= EndDate)
+                .Where(x => x.CreationTime >= StartDate&& x.CreationTime <= EndDate)
                 .WhereIF(!string.IsNullOrEmpty(OrgName), x => x.CreatorOrgId.Contains(OrgName))
                 .Select(x => new
                 {
@@ -1720,7 +1714,6 @@ namespace Hotline.Api.Controllers.Bi
             //满意度
             var orderVisit = _orderVisitDetailRepository.Queryable()
             .Where(x => x.OrderVisit.VisitTime >= StartDate && x.OrderVisit.VisitTime <= EndDate && x.VisitTarget == EVisitTarget.Org && x.OrderVisit.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(x.VisitOrgCode))
-            .WhereIF(string.IsNullOrEmpty(OrgName) == false, x => x.VisitOrgName.Contains(OrgName))
             .Select(x => new
             {
                 OrgCode = IsCenter == true ? x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : x.VisitOrgCode.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
@@ -1757,7 +1750,39 @@ namespace Hotline.Api.Controllers.Bi
           .MergeTable();
             #endregion
 
-            var items = await _orderRepository.OrderUnionAll(queryOrder, queryPublish, queryCountersign, orderDelay, orderScreen, orderVisit);
+            //联合查询
+            var items = await _orderRepository.OrderUnionAll(queryOrder, queryPublish, queryCountersign, orderDelay, orderScreen, orderVisit)
+                 .LeftJoin<SystemOrganize>((p, o) => p.OrgCode == o.Id)
+                .Select((p, o) => new DepartmentalProcessingStatisticsDataDto
+                {
+                    OrgCode = p.OrgCode,
+                    OrgName = o.Name,
+                    OrgType = o.OrgType,
+                    OrderCountNum = p.OrderCountNum,
+                    YBOrderCountNum = p.YBOrderCountNum,
+                    ZBOrderCountNum = p.ZBOrderCountNum,
+                    Archived = p.Archived,
+                    ToBeArchived = p.ToBeArchived,
+                    WaitPublished = p.WaitPublished,
+                    PublishedOpen = p.PublishedOpen,
+                    PublishedNoOpen = p.PublishedNoOpen,
+                    YBOverdue = p.YBOverdue,
+                    ZBOverdue = p.ZBOverdue,
+                    HQYBOverdue = p.HQYBOverdue,
+                    HQZBOverdue = p.HQZBOverdue,
+                    DelayEnd = p.DelayEnd,
+                    DelayWait = p.DelayWait,
+                    OrderDelayCount = p.OrderDelayCount,
+                    ScreenCount = p.ScreenCount,
+                    ScreenApproval = p.ScreenApproval,
+                    ScreenPass = p.ScreenPass,
+                    ScreenNotPass = p.ScreenNotPass,
+                    SatisfactionCount = p.SatisfactionCount,
+                    NotSatisfactionCount = p.NotSatisfactionCount
+                })
+                .MergeTable()
+                .WhereIF(string.IsNullOrEmpty(OrgName) == false, x => x.OrgName.Contains(OrgName))
+                .ToListAsync();
 
             var total = new DepartmentalProcessingStatisticsDataDto
             {
@@ -1806,7 +1831,6 @@ namespace Hotline.Api.Controllers.Bi
             //工单
             var queryOrder = _orderRepository.Queryable()
                       .Where(it => it.CreationTime >= StartDate && it.CreationTime <= EndDate && it.Status > EOrderStatus.WaitForAccept)
-                       .WhereIF(!string.IsNullOrEmpty(OrgName), it => it.ActualHandleOrgName.Contains(OrgName))
                       .WhereIF(OrgCode == "001", it => it.ActualHandleOrgCode == OrgCode)
                       .WhereIF(OrgCode != "001", it => it.ActualHandleOrgCode.StartsWith(OrgCode))
                       .Select(it => new
@@ -1857,7 +1881,6 @@ namespace Hotline.Api.Controllers.Bi
             var queryPublish = _orderPublishRepository.Queryable()
                 .LeftJoin<Order>((x, o) => x.OrderId == o.Id)
                 .Where((x, o) => x.CreationTime >= StartDate && x.CreationTime <= EndDate)
-                .WhereIF(!string.IsNullOrEmpty(OrgName), (x, o) => o.ActualHandleOrgName.Contains(OrgName))
                 .WhereIF(OrgCode == "001", (x, o) => o.ActualHandleOrgCode == OrgCode)
                 .WhereIF(OrgCode != "001", (x, o) => o.ActualHandleOrgCode.StartsWith(OrgCode))
                 .Select((x, o) => new
@@ -1900,11 +1923,10 @@ namespace Hotline.Api.Controllers.Bi
             #region 会签(已办超期、待办超期)
             //会签(已办超期、待办超期)
             var queryCountersign = _workflowStepHandleRepository.Queryable()
-           .LeftJoin<WorkflowTrace>((x, o) => x.WorkflowStepId == o.StepId)
+             .LeftJoin<WorkflowTrace>((x, o) => x.WorkflowStepId == o.StepId)
              .Where((x, o) => o.ModuleCode == WorkflowModuleConsts.OrderHandle && o.CountersignPosition == ECountersignPosition.Multi && o.CountersignPosition == ECountersignPosition.Single && o.CreationTime >= StartDate && o.CreationTime <= EndDate)
-               .WhereIF(!string.IsNullOrEmpty(OrgName), (x, o) => x.OrgName.Contains(OrgName))
-               .WhereIF(OrgCode == "001", (x, o) => x.OrgId == OrgCode)
-                .WhereIF(OrgCode != "001", (x, o) => x.OrgId.StartsWith(OrgCode))
+             .WhereIF(OrgCode == "001", (x, o) => x.OrgId == OrgCode)
+             .WhereIF(OrgCode != "001", (x, o) => x.OrgId.StartsWith(OrgCode))
              .Select((x, o) => new
              {
                  OrgCode = x.OrgId.Substring(0, OrgCode.Length + 3),
@@ -1945,9 +1967,7 @@ namespace Hotline.Api.Controllers.Bi
             #region 延期
             //延期
             var orderDelay = _orderDelayRepository.Queryable()
-                .Where(x => x.CreationTime >= StartDate)
-                .Where(x => x.CreationTime <= EndDate)
-                .WhereIF(!string.IsNullOrEmpty(OrgName), x => x.ApplyOrgName.Contains(OrgName))
+                .Where(x => x.CreationTime >= StartDate&&  x.CreationTime <= EndDate)
                 .WhereIF(OrgCode == "001", x => x.ApplyOrgCode == OrgCode)
                 .WhereIF(OrgCode != "001", x => x.ApplyOrgCode.StartsWith(OrgCode))
                 .Select(x => new
@@ -1988,8 +2008,7 @@ namespace Hotline.Api.Controllers.Bi
             #region 甄别
             //甄别
             var orderScreen = _orderScreenRepository.Queryable()
-                .Where(x => x.CreationTime >= StartDate)
-                .Where(x => x.CreationTime <= EndDate)
+                .Where(x => x.CreationTime >= StartDate&& x.CreationTime <= EndDate)
                 .WhereIF(!string.IsNullOrEmpty(OrgName), x => x.CreatorOrgId.Contains(OrgName))
                   .WhereIF(OrgCode == "001", x => x.CreatorOrgId == OrgCode)
                 .WhereIF(OrgCode != "001", x => x.CreatorOrgId.StartsWith(OrgCode))
@@ -2032,10 +2051,9 @@ namespace Hotline.Api.Controllers.Bi
             #region 满意度
             //满意度
             var orderVisit = _orderVisitDetailRepository.Queryable()
-            .Where(x => x.OrderVisit.VisitTime >= StartDate && x.OrderVisit.VisitTime <= EndDate && x.VisitTarget == EVisitTarget.Org && x.OrderVisit.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(x.VisitOrgCode))
-            .WhereIF(string.IsNullOrEmpty(OrgName) == false, x => x.VisitOrgName.Contains(OrgName))
+              .Where(x => x.OrderVisit.VisitTime >= StartDate && x.OrderVisit.VisitTime <= EndDate && x.VisitTarget == EVisitTarget.Org && x.OrderVisit.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(x.VisitOrgCode))
               .WhereIF(OrgCode == "001", x => x.VisitOrgCode == OrgCode)
-                .WhereIF(OrgCode != "001", x => x.VisitOrgCode.StartsWith(OrgCode))
+              .WhereIF(OrgCode != "001", x => x.VisitOrgCode.StartsWith(OrgCode))
             .Select(x => new
             {
                 OrgCode = x.VisitOrgCode.Substring(0, OrgCode.Length + 3),
@@ -2071,7 +2089,41 @@ namespace Hotline.Api.Controllers.Bi
           .MergeTable();
             #endregion
 
-            var items = await _orderRepository.OrderUnionAll(queryOrder, queryPublish, queryCountersign, orderDelay, orderScreen, orderVisit);
+            //联合查询
+            var items = await _orderRepository.OrderUnionAll(queryOrder, queryPublish, queryCountersign, orderDelay, orderScreen, orderVisit)
+                 .LeftJoin<SystemOrganize>((p, o) => p.OrgCode == o.Id)
+                .Select((p, o) => new DepartmentalProcessingStatisticsDataDto
+                {
+                    OrgCode = p.OrgCode,
+                    OrgName = o.Name,
+                    OrgType = o.OrgType,
+                    OrderCountNum = p.OrderCountNum,
+                    YBOrderCountNum = p.YBOrderCountNum,
+                    ZBOrderCountNum = p.ZBOrderCountNum,
+                    Archived = p.Archived,
+                    ToBeArchived = p.ToBeArchived,
+                    WaitPublished = p.WaitPublished,
+                    PublishedOpen = p.PublishedOpen,
+                    PublishedNoOpen = p.PublishedNoOpen,
+                    YBOverdue = p.YBOverdue,
+                    ZBOverdue = p.ZBOverdue,
+                    HQYBOverdue = p.HQYBOverdue,
+                    HQZBOverdue = p.HQZBOverdue,
+                    DelayEnd = p.DelayEnd,
+                    DelayWait = p.DelayWait,
+                    OrderDelayCount = p.OrderDelayCount,
+                    ScreenCount = p.ScreenCount,
+                    ScreenApproval = p.ScreenApproval,
+                    ScreenPass = p.ScreenPass,
+                    ScreenNotPass = p.ScreenNotPass,
+                    SatisfactionCount = p.SatisfactionCount,
+                    NotSatisfactionCount = p.NotSatisfactionCount
+                })
+                .MergeTable()
+                .WhereIF(string.IsNullOrEmpty(OrgName) == false, x => x.OrgName.Contains(OrgName))
+                .ToListAsync();
+
+           //计算合计
             var total = new DepartmentalProcessingStatisticsDataDto
             {
                 OrgCode = "",

+ 5 - 32
src/Hotline.Repository.SqlSugar/Orders/OrderRepository.cs

@@ -113,14 +113,14 @@ namespace Hotline.Repository.SqlSugar.Orders
             return new { HotSpot = hotSpotList, Data = listReturn };
         }
 
-        public async Task<List<DepartmentalProcessingStatisticsDataDto>> OrderUnionAll(ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t1,
+        public ISugarQueryable<DepartmentalProcessingStatisticsDataDto> OrderUnionAll(ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t1,
             ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t2,
             ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t3,
             ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t4,
             ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t5,
             ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t6)
         {
-            return await Db.UnionAll(t1, t2, t3, t4, t5, t6)
+            return Db.UnionAll(t1, t2, t3, t4, t5, t6)
                        .GroupBy(p => new { p.OrgCode })
                        .Select(p => new DepartmentalProcessingStatisticsDataDto
                        {
@@ -147,36 +147,9 @@ namespace Hotline.Repository.SqlSugar.Orders
                            SatisfactionCount = SqlFunc.AggregateSum(p.SatisfactionCount),
                            NotSatisfactionCount = SqlFunc.AggregateSum(p.NotSatisfactionCount)
                        })
-                       .MergeTable()
-                       .LeftJoin<SystemOrganize>((p, o) => p.OrgCode == o.Id)
-                       .Select((p, o) => new DepartmentalProcessingStatisticsDataDto
-                       {
-                           OrgCode = p.OrgCode,
-                           OrgName = o.Name,
-                           OrgType = o.OrgType,
-                           OrderCountNum = p.OrderCountNum,
-                           YBOrderCountNum = p.YBOrderCountNum,
-                           ZBOrderCountNum = p.ZBOrderCountNum,
-                           Archived = p.Archived,
-                           ToBeArchived = p.ToBeArchived,
-                           WaitPublished = p.WaitPublished,
-                           PublishedOpen = p.PublishedOpen,
-                           PublishedNoOpen = p.PublishedNoOpen,
-                           YBOverdue = p.YBOverdue,
-                           ZBOverdue = p.ZBOverdue,
-                           HQYBOverdue = p.HQYBOverdue,
-                           HQZBOverdue = p.HQZBOverdue,
-                           DelayEnd = p.DelayEnd,
-                           DelayWait = p.DelayWait,
-                           OrderDelayCount = p.OrderDelayCount,
-                           ScreenCount = p.ScreenCount,
-                           ScreenApproval = p.ScreenApproval,
-                           ScreenPass = p.ScreenPass,
-                           ScreenNotPass = p.ScreenNotPass,
-                           SatisfactionCount = p.SatisfactionCount,
-                           NotSatisfactionCount = p.NotSatisfactionCount
-                       })
-                       .ToListAsync();
+                       .MergeTable();
+
+                      
         }
 
         public ISugarQueryable<SelectOrderId> OrderListUnionAll(ISugarQueryable<SelectOrderId> t1, ISugarQueryable<SelectOrderId> t2)

+ 1 - 1
src/Hotline/Orders/IOrderRepository.cs

@@ -15,7 +15,7 @@ namespace Hotline.Orders
 
         Task<object> HotPortJoinOrgStatistics(DateTime StartTime, DateTime EndTime, bool IsCenter, string? OrgCode);
 
-        Task<List<DepartmentalProcessingStatisticsDataDto>> OrderUnionAll(ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t1,
+        ISugarQueryable<DepartmentalProcessingStatisticsDataDto> OrderUnionAll(ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t1,
          ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t2,
          ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t3,
          ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t4,