Browse Source

新增【部门受理类型统计】

libin 1 month ago
parent
commit
4f9c403c4d

+ 140 - 1
src/Hotline.Api/Controllers/Bi/BiOrderController.cs

@@ -3181,7 +3181,7 @@ namespace Hotline.Api.Controllers.Bi
 
 
         /// <summary>
-        /// 部门受理类型统计(宜宾原始功能)
+        /// 部门受理类型统计(宜宾功能)
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
@@ -3301,6 +3301,145 @@ namespace Hotline.Api.Controllers.Bi
             return new { DataList = items, CountySumModel = countySumModel, CitySumModel = citySumModel, SumModel = sumModel };
         }
 
+        /// <summary>
+        /// 部门受理类型统计(宜宾功能)---导出
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost("department_acceptance_type_statistics_export_v1")]
+        public async Task<FileStreamResult> ExportDepartmentAcceptanceTypeStatisticsV1([FromBody] ExportExcelDto<DepartmentKeyWordRequest> dto)
+        {
+            var query = _orderReportApplication.DepartmentAcceptanceTypeStatisticsV1(dto.QueryDto);
+            List<DepartmentAcceptanceTypeStatisticsV1Dto> list;
+            if (dto.IsExportAll)
+            {
+                list = await query.ToListAsync(HttpContext.RequestAborted);
+            }
+            else
+            {
+                var (_, items) = await query.ToPagedListAsync(dto.QueryDto, HttpContext.RequestAborted);
+                list = items;
+            }
+
+            list.Add(new DepartmentAcceptanceTypeStatisticsV1Dto
+            {
+                OrgName = "区县合计",
+                OrgCode = "",
+                OrgTypeText = "",
+                ZxAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.ZxAllCount),
+                ZxAcceptanceTypeCode = "10",
+
+                JyAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.JyAllCount),
+                JyAcceptanceTypeCode = "15",
+
+                QzAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.QzAllCount),
+                QzAcceptanceTypeCode = "20",
+
+                ByAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.ByAllCount),
+                ByAcceptanceTypeCode = "25",
+
+                JbAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.JbAllCount),
+                JbAcceptanceTypeCode = "30",
+
+                TsAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.TsAllCount),
+                TsAcceptanceTypeCode = "35",
+
+                QtAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.QtAllCount),
+                QtAcceptanceTypeCode = "40",
+
+                YjAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.YjAllCount),
+                YjAcceptanceTypeCode = "1",
+
+                HmAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.HmAllCount),
+                HmAcceptanceTypeCode = "2",
+
+                DqAllCount = list.Where(x => x.OrgType == EOrgType.County).Sum(p => p.DqAllCount),
+                DqAcceptanceTypeCode = "3"
+            });
+
+            list.Add(new DepartmentAcceptanceTypeStatisticsV1Dto
+            {
+                OrgName = "市直合计",
+                OrgCode = "",
+                OrgTypeText = "",
+                ZxAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.ZxAllCount),
+                ZxAcceptanceTypeCode = "10",
+
+                JyAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.JyAllCount),
+                JyAcceptanceTypeCode = "15",
+
+                QzAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.QzAllCount),
+                QzAcceptanceTypeCode = "20",
+
+                ByAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.ByAllCount),
+                ByAcceptanceTypeCode = "25",
+
+                JbAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.JbAllCount),
+                JbAcceptanceTypeCode = "30",
+
+                TsAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.TsAllCount),
+                TsAcceptanceTypeCode = "35",
+
+                QtAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.QtAllCount),
+                QtAcceptanceTypeCode = "40",
+
+                YjAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.YjAllCount),
+                YjAcceptanceTypeCode = "1",
+
+                HmAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.HmAllCount),
+                HmAcceptanceTypeCode = "2",
+
+                DqAllCount = list.Where(x => x.OrgType == EOrgType.City && x.OrgCode != "001").Sum(p => p.DqAllCount),
+                DqAcceptanceTypeCode = "3"
+            });
+
+            list.Add(new DepartmentAcceptanceTypeStatisticsV1Dto
+            {
+                OrgName = "总计",
+                OrgCode = "",
+                OrgTypeText = "",
+                ZxAllCount = list.Sum(p => p.ZxAllCount),
+                ZxAcceptanceTypeCode = "10",
+
+                JyAllCount = list.Sum(p => p.JyAllCount),
+                JyAcceptanceTypeCode = "15",
+
+                QzAllCount = list.Sum(p => p.QzAllCount),
+                QzAcceptanceTypeCode = "20",
+
+                ByAllCount = list.Sum(p => p.ByAllCount),
+                ByAcceptanceTypeCode = "25",
+
+                JbAllCount = list.Sum(p => p.JbAllCount),
+                JbAcceptanceTypeCode = "30",
+
+                TsAllCount = list.Sum(p => p.TsAllCount),
+                TsAcceptanceTypeCode = "35",
+
+                QtAllCount = list.Sum(p => p.QtAllCount),
+                QtAcceptanceTypeCode = "40",
+
+                YjAllCount = list.Sum(p => p.YjAllCount),
+                YjAcceptanceTypeCode = "1",
+
+                HmAllCount = list.Sum(p => p.HmAllCount),
+                HmAcceptanceTypeCode = "2",
+
+                DqAllCount = list.Sum(p => p.DqAllCount),
+                DqAcceptanceTypeCode = "3"
+            });
+
+            var orderDtos = _mapper.Map<ICollection<DepartmentAcceptanceTypeStatisticsV1Dto>>(list);
+            dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass<DepartmentAcceptanceTypeStatisticsV1Dto>(dto.ColumnInfos);
+            var dtos = orderDtos
+                .Select(stu => _mapper.Map(stu, typeof(DepartmentAcceptanceTypeStatisticsV1Dto), dynamicClass))
+                .Cast<object>()
+                .ToList();
+
+            var stream = ExcelHelper.CreateStream(dtos);
+
+            return ExcelStreamResult(stream, "部门受理类型统计数据");
+        }
 
         /// <summary>
         /// 部门办件统计表

+ 26 - 8
src/Hotline.Application/StatisticalReport/OrderReportApplication.cs

@@ -2316,32 +2316,49 @@ namespace Hotline.Application.StatisticalReport
             var IsCenter = _sessionContext.OrgIsCenter;
             var centerOrgName = _systemSettingCacheManager.GetSetting(SettingConstants.CenterOrgName)?.SettingValue[0];
 
+            int endIndex = 6;
+
+            if (!IsCenter && string.IsNullOrEmpty(dto.OrgCode))
+            {
+                dto.OrgCode = _sessionContext.OrgId;
+            }
+
+            if (!string.IsNullOrEmpty(dto.OrgCode))
+            {
+                switch (dto.OrgCode.Length)
+                {
+                    case 6: endIndex = 9; break;
+                    case 9: endIndex = 12; break;
+                    case 12: endIndex = 15; break;
+                }
+            }
 
             var orderData = _orderRepository.Queryable()
               .WhereIF(dto.StartTime.HasValue, it => it.StartTime >= dto.StartTime)
               .WhereIF(dto.EndTime.HasValue, it => it.StartTime <= dto.EndTime)
               .WhereIF(dto.TypeId != null && dto.TypeId == 1, it => it.IdentityType == EIdentityType.Citizen)
               .WhereIF(dto.TypeId != null && dto.TypeId == 2, it => it.IdentityType == EIdentityType.Enterprise)
+              .WhereIF(!string.IsNullOrEmpty(dto.OrgCode), it => it.ActualHandleOrgCode.StartsWith(dto.OrgCode))
               .Select(it => new
               {
-                  OrgCode = string.IsNullOrEmpty(dto.OrgCode) ? it.ActualHandleOrgCode.Substring(0, 6) : it.ActualHandleOrgCode.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
+                  OrgCode = it.ActualHandleOrgCode.Substring(0, endIndex),
                   AcceptTypeCode = it.AcceptTypeCode
               })
               .MergeTable()
-
-              //.WhereIF(!IsCenter, p => p.OrgCode.StartsWith(_sessionContext.RequiredOrgId))
-
-              .LeftJoin<SystemOrganize>((it, o) => it.OrgCode == o.Id)
+              .LeftJoin<SystemOrganize>((it, o) => o.Id == it.OrgCode)
               .GroupBy((it, o) => new
               {
-                  it.OrgCode,
+                  o.Id,
                   o.Name,
                   o.OrgType
               })
+              .WhereIF(dto.OrgType == 1, (it, o) => o.OrgType != EOrgType.County)
+              .WhereIF(dto.OrgType == 2, (it, o) => o.OrgType == EOrgType.County)
+              .WhereIF(!string.IsNullOrEmpty(dto.OrgName), (it, o) => o.Name.StartsWith(dto.OrgName))
               .Select((it, o) => new DepartmentAcceptanceTypeStatisticsV1Dto
               {
-                  OrgName = it.OrgCode == "001" ? centerOrgName : o.Name,
-                  OrgCode = it.OrgCode,
+                  OrgName = o.Id == "001" ? centerOrgName : o.Name,
+                  OrgCode = o.Id,
                   OrgType = o.OrgType,
                   OrgTypeText = o.OrgType == EOrgType.County ? "区县部门" : "市直部门",
                   ZxAllCount = SqlFunc.AggregateSum(SqlFunc.IIF(it.AcceptTypeCode == "10", 1, 0)),
@@ -2374,6 +2391,7 @@ namespace Hotline.Application.StatisticalReport
                   DqAllCount = SqlFunc.AggregateSum(SqlFunc.IIF(it.AcceptTypeCode == "3", 1, 0)),
                   DqAcceptanceTypeCode = "3"
               }).MergeTable();
+
             return orderData;
         }
 

+ 13 - 1
src/Hotline.Share/Requests/DepartmentKeyWordRequest.cs

@@ -1,4 +1,6 @@
-namespace Hotline.Share.Requests
+using Hotline.Settings;
+
+namespace Hotline.Share.Requests
 {
     public record DepartmentKeyWordRequest : PagedRequest
     {
@@ -36,5 +38,15 @@
         /// 1:受理时间 2:办结时间  默认:2
         /// </summary>
         public int TimeType { get; set; } = 2;
+
+        /// <summary>
+        /// 部门类型 1市直部门 2区县部门
+        /// </summary>
+        public int OrgType { get; set; }
+
+        /// <summary>
+        /// 部门名称
+        /// </summary>
+        public string OrgName { get; set; }
     }
 }