瀏覽代碼

Merge branch 'master' of http://110.188.24.182:10023/Fengwo/hotline

田爽 1 年之前
父節點
當前提交
47bf361fb8

+ 165 - 2
src/Hotline.Api/Controllers/EnforcementOrderController.cs

@@ -8,8 +8,10 @@ using Hotline.Settings;
 using Hotline.Settings.TimeLimits;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.JudicialManagement;
+using Hotline.Share.Dtos.Order;
 using Hotline.Share.Enums.Order;
 using MapsterMapper;
+using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using SqlSugar;
 using System.Diagnostics.Eventing.Reader;
@@ -31,6 +33,7 @@ namespace Hotline.Api.Controllers
         private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
         private readonly IRepository<SystemOrganize> _systemOrganizeRepository;
         private readonly ISessionContext _sessionContext;
+        private readonly IRepository<OrderVisitDetail> _orderVisitDetailRepository;
 
         public EnforcementOrderController(IRepository<EnforcementOrderHander> enforcementOrderHanderRepository,
          IRepository<EnforcementOrders> enforcementOrdersRepository,
@@ -40,7 +43,8 @@ namespace Hotline.Api.Controllers
          IWorkflowApplication workflowApplication,
          ISystemDicDataCacheManager sysDicDataCacheManager,
          IRepository<SystemOrganize> systemOrganizeRepository,
-         ISessionContext sessionContext)
+         ISessionContext sessionContext,
+         IRepository<OrderVisitDetail> orderVisitDetailRepository)
         {
             _enforcementOrderHanderRepository = enforcementOrderHanderRepository;
             _enforcementOrdersRepository = enforcementOrdersRepository;
@@ -51,6 +55,7 @@ namespace Hotline.Api.Controllers
             _sysDicDataCacheManager = sysDicDataCacheManager;
             _systemOrganizeRepository = systemOrganizeRepository;
             _sessionContext = sessionContext;
+            _orderVisitDetailRepository = orderVisitDetailRepository;
         }
 
         /// <summary>
@@ -67,6 +72,7 @@ namespace Hotline.Api.Controllers
            .WhereIF(dto.IsEnforcementOrder.HasValue, d => d.IsEnforcementOrder == dto.IsEnforcementOrder)//是否行政执法类
            .WhereIF(dto.IsPassTheBuckOrder.HasValue, d => d.IsPassTheBuckOrder == dto.IsPassTheBuckOrder)//是否推诿
            .WhereIF(dto.IsTheClueTrue.HasValue, d => d.IsTheClueTrue == dto.IsTheClueTrue)//线索是否属实
+           .WhereIF(dto.EventTypeId.Any(), d => dto.EventTypeId.Contains(d.EventTypeId))//事项分类
            .WhereIF(!string.IsNullOrEmpty(dto.Title), d => d.Order.Title.Contains(dto.Title!)) //标题
            .WhereIF(!string.IsNullOrEmpty(dto.ProvinceNo), d => d.Order.ProvinceNo.Contains(dto.ProvinceNo)) //省本地编号
            .WhereIF(!string.IsNullOrEmpty(dto.No), d => d.Order.No.Contains(dto.No)) //工单编码
@@ -230,7 +236,7 @@ namespace Hotline.Api.Controllers
                     {
                         OrgName = d.Order.OrgLevelOneName,
                         CountNum = SqlFunc.AggregateCount(d.Order.OrgLevelOneCode),
-                        TheClueIsTrue = SqlFunc.AggregateSum(SqlFunc.IIF(d.IsTheClueTrue.HasValue && d.IsTheClueTrue.Value==true, 1, 0)),
+                        TheClueIsTrue = SqlFunc.AggregateSum(SqlFunc.IIF(d.IsTheClueTrue.HasValue && d.IsTheClueTrue.Value == true, 1, 0)),
                         TheClueIsNotTrue = SqlFunc.AggregateSum(SqlFunc.IIF(d.IsTheClueTrue.HasValue && d.IsTheClueTrue.Value == false, 1, 0)),
                         EnforcementOrder = SqlFunc.AggregateSum(SqlFunc.IIF(d.IsEnforcementOrder, 1, 0))
                     })
@@ -238,5 +244,162 @@ namespace Hotline.Api.Controllers
 
             return data;
         }
+
+        /// <summary>
+        /// 事项分类统计
+        /// </summary>
+        /// <param name="StartDate"></param>
+        /// <param name="EndDate"></param>
+        /// <param name="Id"></param>
+        /// <param name="AreaCode"></param>
+        /// <returns></returns>
+        [HttpGet("event_classification_statistics")]
+        public async Task<object> GetEventClassificationStatisticsAsync(DateTime StartDate, DateTime EndDate, string Id, string AreaCode)
+        {
+
+            EndDate = EndDate.AddDays(1).AddSeconds(-1);
+
+            var items = await _judicialComplaintsEventTypeRepository.Queryable()
+             .LeftJoin<EnforcementOrders>((x, o) => o.EventTypeSpliceName != null && (x.EventTypeName == o.EventTypeSpliceName || o.EventTypeSpliceName.Contains(x.EventTypeName)))
+            .LeftJoin<Order>((x, o, p) => p.Id == o.Id)
+            .Where((x, o, p) => p.FiledTime >= StartDate && p.FiledTime <= EndDate)
+            .WhereIF(!string.IsNullOrEmpty(AreaCode), (x, o, p) => p.AreaCode == AreaCode)
+             .Where((x, o, p) => x.ParentId == Id)
+             .GroupBy((x, o, p) => new { x.Id, x.EventTypeName })
+             .Select((x, o, p) => new
+             {
+                 Id = x.Id,
+                 Name = x.EventTypeName,
+                 Num = SqlFunc.AggregateSum(SqlFunc.IIF(p.Id != null, 1, 0)),
+                 Sublevel = SqlFunc.AggregateSum(SqlFunc.IIF(x.EventTypeName != o.EventTypeName, 1, 0)) > 0,
+             })
+             .MergeTable()
+             .ToListAsync();
+
+            var total = new
+            {
+                Id = "0",
+                Name = "合计",
+                Num = items.Sum(x => x.Num),
+                Sublevel = false
+            };
+
+            var orderCount = new
+            {
+                TheClueIsTrue = 0,
+                TheClueIsNotTrue = 0,
+                EnforcementOrder = 0,
+                PassTheBuckOrder = 0
+            };
+
+            return new { List = items, Total = total, OrderCount = orderCount };
+        }
+
+        /// <summary>
+        /// 区域受理排行
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("regional_classification_statistics")]
+        public async Task<object> GetRegionalClassificationStatisticsAsync(DateTime StartDate, DateTime EndDate)
+        {
+            EndDate = EndDate.AddDays(1).AddSeconds(-1);
+
+            var list = await _enforcementOrdersRepository.Queryable()
+               .Includes(x => x.Order)
+               .Where(x => x.Order.Id != null)
+               .Where(x => x.Order.FiledTime >= StartDate && x.Order.FiledTime <= EndDate)
+               .LeftJoin<SystemArea>((x, o) => x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
+               .Where((x, o) => x.Order.Status >= EOrderStatus.Filed)
+               .GroupBy((x, o) => new
+               {
+                   AreaCode = x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
+                   o.AreaName,
+               })
+               .Select((x, o) => new
+               {
+                   AreaCode = x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
+                   AreaName = o.AreaName,
+                   OrderCountNum = SqlFunc.AggregateCount(x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
+                   TheClueIsTrue = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsTheClueTrue.HasValue && x.IsTheClueTrue.Value == true, 1, 0)),
+                   TheClueIsNotTrue = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsTheClueTrue.HasValue && x.IsTheClueTrue.Value == false, 1, 0)),
+                   EnforcementOrder = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsEnforcementOrder, 1, 0))
+               }).MergeTable()
+                .Where(x => x.AreaCode != "519800" && x.AreaCode != "519900")
+                .OrderByDescending(it => it.OrderCountNum)
+                .ToListAsync();
+            return list;
+        }
+
+        /// <summary>
+        /// 部门满意度统计
+        /// </summary>
+        /// <param name="StartDate"></param>
+        /// <param name="EndDate"></param>
+        /// <param name="TypeId">1:办件结果 2:办件态度</param>
+        /// <returns></returns>
+        [HttpGet("enforcement_visit_org_satisfaction_statistics")]
+        public async Task<object> GetVisitAndOrgSatisfactionStatisticsAsync(DateTime StartDate, DateTime EndDate, int TypeId)
+        {
+            EndDate = EndDate.AddDays(1).AddSeconds(-1);
+
+            var list =
+                 await _enforcementOrdersRepository.Queryable()
+                 .LeftJoin<OrderVisit>((x,o)=>x.Id==o.OrderId)
+                 .LeftJoin<OrderVisitDetail>((x, o,p) => o.Id == p.VisitId)
+                .Where((x, o, p) => o.VisitTime >= StartDate && o.VisitTime <= EndDate && p.VisitTarget == EVisitTarget.Org 
+                && o.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(p.VisitOrgCode))
+
+                .GroupBy((x, o, p) => new
+                {
+                    VisitOrgCode = p.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))
+                })
+                .Select((x, o, p) => new VisitAndOrgSatisfactionStatisticsDto()
+                {
+                    OrgCode = p.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
+                    TotalSumCount = SqlFunc.AggregateCount(p.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
+                    VerySatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "5", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "5", 1, 0))),//非常满意数
+                    SatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "4", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "4", 1, 0))), //满意数
+                    RegardedAsSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "-1", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "-1", 1, 0))),//视为满意
+                    DefaultSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "0", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "0", 1, 0))),//默认满意
+                    NoSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "2", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "2", 1, 0))),//不满意
+                    NoEvaluateCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "7", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "7", 1, 0))),//未做评价
+                    NoPutThroughCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "6", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "6", 1, 0))),//未接通
+                })
+                .MergeTable()
+                .LeftJoin<SystemOrganize>((it, o) => it.OrgCode == o.Id)
+                .Select((it, o) => new VisitAndOrgSatisfactionStatisticsDto()
+                {
+                    OrgName = o.Name,
+                    OrgCode = it.OrgCode,
+                    OrgType = o.OrgType,
+                    TotalSumCount = it.TotalSumCount,
+                    VerySatisfiedCount = it.VerySatisfiedCount,//非常满意数
+                    SatisfiedCount = it.SatisfiedCount, //满意数
+                    RegardedAsSatisfiedCount = it.RegardedAsSatisfiedCount,//视为满意
+                    DefaultSatisfiedCount = it.DefaultSatisfiedCount,//默认满意
+                    NoSatisfiedCount = it.NoSatisfiedCount,//不满意
+                    NoEvaluateCount = it.NoEvaluateCount,//未做评价
+                    NoPutThroughCount = it.NoPutThroughCount,//未接通
+                })
+                .ToListAsync();
+
+
+            var sumModel = new VisitAndOrgSatisfactionStatisticsDto()
+            {
+                OrgName = "总计",
+                TotalSumCount = list.Sum(x => x.TotalSumCount),
+                VerySatisfiedCount = list.Sum(x => x.VerySatisfiedCount),
+                SatisfiedCount = list.Sum(x => x.SatisfiedCount),
+                RegardedAsSatisfiedCount = list.Sum(x => x.RegardedAsSatisfiedCount),
+                DefaultSatisfiedCount = list.Sum(x => x.DefaultSatisfiedCount),
+                NoSatisfiedCount = list.Sum(x => x.NoSatisfiedCount),
+                NoEvaluateCount = list.Sum(x => x.NoEvaluateCount),
+                NoPutThroughCount = list.Sum(x => x.NoPutThroughCount),
+            };
+
+
+            return new { DataList = list, SumModel = sumModel };
+        }
+
     }
 }

+ 1 - 1
src/Hotline.Api/Controllers/SettingController.cs

@@ -164,7 +164,7 @@ namespace Hotline.Api.Controllers
         /// <param name="year"></param>
         /// <param name="month"></param>
         /// <returns></returns>
-        [Permission(EPermission.DaySetingsList)]
+        //[Permission(EPermission.DaySetingsList)]
         [HttpGet("getdaysettings-month/{year}/{month}")]
         public async Task<List<DaySetting>> GetDaySettingsByMonth(int year,int month)
         {