|
@@ -1,24 +1,23 @@
|
|
|
-using Hotline.Orders;
|
|
|
+using Hotline.Caching.Interfaces;
|
|
|
+using Hotline.CallCenter.Calls;
|
|
|
+using Hotline.FlowEngine.Workflows;
|
|
|
+using Hotline.Orders;
|
|
|
using Hotline.Repository.SqlSugar.Extensions;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Settings.Hotspots;
|
|
|
using Hotline.Share.Dtos;
|
|
|
+using Hotline.Share.Dtos.CallCenter;
|
|
|
using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Share.Enums.Order;
|
|
|
-using Microsoft.AspNetCore.Mvc;
|
|
|
-using SqlSugar;
|
|
|
using Hotline.Share.Requests;
|
|
|
-using XF.Domain.Repository;
|
|
|
-using Hotline.Caching.Interfaces;
|
|
|
-using Hotline.FlowEngine.Workflows;
|
|
|
-using Hotline.Share.Dtos.CallCenter;
|
|
|
using MapsterMapper;
|
|
|
-using XF.Domain.Exceptions;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
-using Hotline.CallCenter.Calls;
|
|
|
-using Hotline.Share.Enums.CallCenter;
|
|
|
-using Org.BouncyCastle.Utilities;
|
|
|
-using Polly.Caching;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using SharpCompress.Archives;
|
|
|
+using SqlSugar;
|
|
|
+using XF.Domain.Exceptions;
|
|
|
+using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Api.Controllers.Bi
|
|
|
{
|
|
@@ -34,6 +33,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
private readonly IRepository<OrderSpecial> _orderSpecialRepository;
|
|
|
private readonly IRepository<OrderVisit> _orderVisitRepository;
|
|
|
private readonly IRepository<TrCallRecord> _trCallRecordRepository;
|
|
|
+ private readonly IRepository<OrderPublish> _orderPublishRepository;
|
|
|
|
|
|
|
|
|
public BiOrderController(
|
|
@@ -46,7 +46,8 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
IRepository<OrderSpecial> orderSpecialRepository,
|
|
|
IMapper mapper,
|
|
|
IRepository<OrderVisit> orderVisitRepository,
|
|
|
- IRepository<TrCallRecord> trCallRecordRepository
|
|
|
+ IRepository<TrCallRecord> trCallRecordRepository,
|
|
|
+ IRepository<OrderPublish> orderPublishRepository
|
|
|
)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
@@ -59,6 +60,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
_mapper = mapper;
|
|
|
_orderVisitRepository = orderVisitRepository;
|
|
|
_trCallRecordRepository = trCallRecordRepository;
|
|
|
+ _orderPublishRepository = orderPublishRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -667,7 +669,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
CenterReportStatisticsDto centerReportStatisticsDto = new();
|
|
|
|
|
|
//信件总量
|
|
|
- int sourceChannelCount = await _orderRepository.Queryable(false, false, false).Where(p => p.CreationTime >= StartDate && p.CreationTime <= EndDate).CountAsync();
|
|
|
+ int sourceChannelCount = await _orderRepository.Queryable().Where(p => p.CreationTime >= StartDate && p.CreationTime <= EndDate).CountAsync();
|
|
|
|
|
|
#region 通话记录
|
|
|
//通话记录
|
|
@@ -687,7 +689,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
|
|
|
#region 工单
|
|
|
//工单
|
|
|
- var orderData = await _orderRepository.Queryable(false, false, false)
|
|
|
+ var orderData = await _orderRepository.Queryable()
|
|
|
.Where(p => p.CreationTime >= StartDate && p.CreationTime <= EndDate)
|
|
|
.Select(x => new CenterReportOrderDto
|
|
|
{
|
|
@@ -703,7 +705,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
|
|
|
#region 信件来源
|
|
|
//信件来源
|
|
|
- var sourceChannelData = await _orderRepository.Queryable(false, false, false)
|
|
|
+ var sourceChannelData = await _orderRepository.Queryable()
|
|
|
.Where(p => p.CreationTime >= StartDate && p.CreationTime <= EndDate)
|
|
|
.Select(it => new
|
|
|
{
|
|
@@ -919,7 +921,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- ///
|
|
|
+ /// 部门受理类型统计周期--明细列表
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -936,5 +938,135 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
|
|
|
return new PagedDto<OrderDto>(total, _mapper.Map<IReadOnlyList<OrderDto>>(items));
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 部门办件统计表-----未完成
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="StartDate"></param>
|
|
|
+ /// <param name="EndDate"></param>
|
|
|
+ /// <param name="OrgCode"></param>
|
|
|
+ /// <param name="OrgName"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("departmental_processing_statistics")]
|
|
|
+ [AllowAnonymous]
|
|
|
+ public async Task<object> DepartmentalProcessingStatistics(DateTime StartDate, DateTime EndDate, string? OrgCode, string? OrgName)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ EndDate = EndDate.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ var handeOrgDownNum = 0;
|
|
|
+ if (!string.IsNullOrEmpty(OrgCode) && OrgCode != "001")
|
|
|
+ {
|
|
|
+ handeOrgDownNum = OrgCode.Length + 3;
|
|
|
+ }
|
|
|
+
|
|
|
+ //工单
|
|
|
+ var query = _orderRepository.Queryable()
|
|
|
+ .Where(it => it.CreationTime >= StartDate && it.CreationTime <= EndDate)
|
|
|
+ .Select(it => new
|
|
|
+ {
|
|
|
+ it.Id,
|
|
|
+ OrgLevelOneCode = SqlFunc.IIF(it.ActualHandleOrgCode != "001", SqlFunc.Substring(it.ActualHandleOrgCode, 0, 6), it.ActualHandleOrgCode),
|
|
|
+
|
|
|
+ OrgLevelDownCode = SqlFunc.IIF(!string.IsNullOrEmpty(OrgCode) && OrgCode != "001" && it.ActualHandleOrgCode.Length >= handeOrgDownNum
|
|
|
+ , SqlFunc.Substring(it.ActualHandleOrgCode, 0, handeOrgDownNum), it.ActualHandleOrgCode),
|
|
|
+
|
|
|
+ it.ActualHandleOrgCode,
|
|
|
+ it.Status,//工单状态
|
|
|
+ it.ExpiredTime,//期满时间
|
|
|
+ it.ActualHandleTime,//办理时间
|
|
|
+ it.CounterSignType,//会签
|
|
|
+ }).MergeTable()
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode == "001", it => it.OrgLevelOneCode == OrgCode)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode != "001", it => it.OrgLevelDownCode.Contains(OrgCode))
|
|
|
+ .MergeTable()
|
|
|
+ .Select(it => new DepartmentalProcessingStatisticsDto
|
|
|
+ {
|
|
|
+ Id = it.Id,
|
|
|
+ OrgCode = SqlFunc.IIF(!string.IsNullOrEmpty(OrgCode), it.OrgLevelDownCode, it.OrgLevelOneCode),
|
|
|
+ ActualHandleOrgCode = it.ActualHandleOrgCode,
|
|
|
+ Status = it.Status,//工单状态
|
|
|
+ ExpiredTime = it.ExpiredTime,//期满时间
|
|
|
+ ActualHandleTime = it.ActualHandleTime,//办理时间
|
|
|
+ CounterSignType = it.CounterSignType,//会签
|
|
|
+
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+ //发布
|
|
|
+ var queryPublish = _orderPublishRepository.Queryable()
|
|
|
+ .Where(p => p.CreationTime >= StartDate && p.CreationTime <= EndDate)
|
|
|
+ .GroupBy(it => new
|
|
|
+ {
|
|
|
+ it.OrderId,
|
|
|
+ it.PublishState
|
|
|
+ })
|
|
|
+ .Select(it => new DepartmentalProcessingStatisticsDto
|
|
|
+ {
|
|
|
+ Id = it.OrderId,
|
|
|
+ PublishState = it.PublishState
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ //会签
|
|
|
+ var queryCountersign = _workflowCountersignRepository.Queryable()
|
|
|
+ .LeftJoin<WorkflowCountersignMember>((x, o) => x.Id == o.WorkflowCountersignId)
|
|
|
+ .Where(x => x.CreationTime >= StartDate && x.CreationTime <= EndDate)
|
|
|
+ .GroupBy((x, o) => o.Key)
|
|
|
+ .Select((x, o) => new OrderBiOrgDataListVo
|
|
|
+ {
|
|
|
+ OrgId = o.Key,
|
|
|
+ CounterHandlerExtendedNum = SqlFunc.AggregateSum(SqlFunc.IIF(o.IsHandled, 1, 0)),
|
|
|
+ CounterNoHandlerExtendedNum = SqlFunc.AggregateSum(SqlFunc.IIF(!o.IsHandled, 1, 0)),
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var queryPush = query.LeftJoin(queryPublish, (it, o) => it.Id == o.Id).Where(it => it.OrgCode != null);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return await queryPush.GroupBy((it, o) => new
|
|
|
+ {
|
|
|
+ it.OrgCode
|
|
|
+ })
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ //办件信息完整
|
|
|
+ OrgCode = it.OrgCode,
|
|
|
+ OrderCountNum = SqlFunc.AggregateCount(it.OrgCode),//总量
|
|
|
+ YBOrderCountNum = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status >= 300, 1, 0)),//已办
|
|
|
+ ZBOrderCountNum = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status < 300, 1, 0)),//在办
|
|
|
+
|
|
|
+
|
|
|
+ YBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status >= 300 && it.ActualHandleTime > it.ExpiredTime, 1, 0)),//已办超期
|
|
|
+ ZBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status < 300 && it.ExpiredTime < SqlFunc.GetDate(), 1, 0)),//待办超期
|
|
|
+
|
|
|
+ HQYBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status >= 300 && it.CounterSignType != null && it.ActualHandleTime > it.ExpiredTime, 1, 0)),//会签已办超期
|
|
|
+ HQZBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status < 300 && it.CounterSignType != null && it.ExpiredTime < SqlFunc.GetDate(), 1, 0)),//会签待办超期
|
|
|
+
|
|
|
+ //归档完整
|
|
|
+ Archived = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status >= 300, 1, 0)),//已归档
|
|
|
+ ToBeArchived = 0,//待归档
|
|
|
+
|
|
|
+ //发布完整
|
|
|
+ WaitPublished = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status == 300, 1, 0)),//待发布 --已归档的就是待发布
|
|
|
+ PublishedOpen = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status >= 400 && o.PublishState, 1, 0)),//已发布公开
|
|
|
+ PublishedNoOpen = SqlFunc.AggregateSum(SqlFunc.IIF((int)it.Status >= 400 && !o.PublishState, 1, 0)),//已发布不公开
|
|
|
+ }).ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|