|
@@ -27,6 +27,7 @@ using Hotline.Share.Requests;
|
|
|
using Hotline.Tools;
|
|
|
using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using Org.BouncyCastle.Utilities.Collections;
|
|
|
using SqlSugar;
|
|
|
using System.Data;
|
|
|
using XF.Domain.Authentications;
|
|
@@ -1100,17 +1101,17 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
/// <param name="TypeId">0:全部 ,1:市民,2:企业</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpGet("hotspot-statistics")]
|
|
|
- public async Task<object> HotspotStatistics(DateTime StartTime, DateTime EndTime, int TypeId, string? HotspotCode)
|
|
|
+ public async Task<object> HotspotStatistics([FromQuery] HotspotStatisticsRep dto)
|
|
|
{
|
|
|
var IsCenter = _sessionContext.OrgIsCenter;
|
|
|
|
|
|
- if (string.IsNullOrEmpty(HotspotCode))
|
|
|
+ if (string.IsNullOrEmpty(dto.HotspotCode))
|
|
|
{
|
|
|
var list = await _hotspotTypeRepository.Queryable()
|
|
|
.LeftJoin<Order>((it, o) => it.Id == o.HotspotId)
|
|
|
- .Where((it, o) => o.CreationTime >= StartTime && o.CreationTime <= EndTime && o.Id != null)
|
|
|
- .WhereIF(TypeId == 1, (it, o) => o.IdentityType == EIdentityType.Citizen)
|
|
|
- .WhereIF(TypeId == 2, (it, o) => o.IdentityType == EIdentityType.Enterprise)
|
|
|
+ .Where((it, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && o.Id != null)
|
|
|
+ .WhereIF(dto.TypeId == 1, (it, o) => o.IdentityType == EIdentityType.Citizen)
|
|
|
+ .WhereIF(dto.TypeId == 2, (it, o) => o.IdentityType == EIdentityType.Enterprise)
|
|
|
.WhereIF(IsCenter == false, (it, o) => o.ActualHandleOrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
.GroupBy((it, o) => new { Id = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")) })
|
|
|
.Select((it, o) => new
|
|
@@ -1133,13 +1134,13 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- string count = (HotspotCode.Length + 2).ToString();
|
|
|
- string countx = HotspotCode.Length.ToString();
|
|
|
+ string count = (dto.HotspotCode.Length + 2).ToString();
|
|
|
+ string countx = dto.HotspotCode.Length.ToString();
|
|
|
var list = await _hotspotTypeRepository.Queryable()
|
|
|
.LeftJoin<Order>((it, o) => it.Id == o.HotspotId)
|
|
|
- .Where((it, o) => o.CreationTime >= StartTime && o.CreationTime <= EndTime && it.ParentId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(countx)) == HotspotCode)
|
|
|
- .WhereIF(TypeId == 1, (it, o) => o.IdentityType == EIdentityType.Citizen)
|
|
|
- .WhereIF(TypeId == 2, (it, o) => o.IdentityType == EIdentityType.Enterprise)
|
|
|
+ .Where((it, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && it.ParentId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(countx)) == dto.HotspotCode)
|
|
|
+ .WhereIF(dto.TypeId == 1, (it, o) => o.IdentityType == EIdentityType.Citizen)
|
|
|
+ .WhereIF(dto.TypeId == 2, (it, o) => o.IdentityType == EIdentityType.Enterprise)
|
|
|
.WhereIF(IsCenter == false, (it, o) => o.ActualHandleOrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
.GroupBy((it, o) => new { Id = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(count)) })
|
|
|
.Select((it, o) => new
|
|
@@ -1162,12 +1163,91 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 部门满意度统计
|
|
|
- /// </summary>
|
|
|
- /// <param name="dto"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [HttpGet("visit-org-satisfaction-statistics")]
|
|
|
+ /// <summary>
|
|
|
+ /// 热点类型小类统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="StartTime"></param>
|
|
|
+ /// <param name="EndTime"></param>
|
|
|
+ /// <param name="TypeId">0:全部 ,1:市民,2:企业</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("hotspot-statistics/export")]
|
|
|
+ public async Task<FileStreamResult> HotspotStatisticsExprot([FromQuery] HotspotStatisticsRep dto)
|
|
|
+ {
|
|
|
+ var IsCenter = _sessionContext.OrgIsCenter;
|
|
|
+ DataTable data = new DataTable();
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(dto.HotspotCode))
|
|
|
+ {
|
|
|
+ data = await _hotspotTypeRepository.Queryable()
|
|
|
+ .LeftJoin<Order>((it, o) => it.Id == o.HotspotId)
|
|
|
+ .Where((it, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && o.Id != null)
|
|
|
+ .WhereIF(dto.TypeId == 1, (it, o) => o.IdentityType == EIdentityType.Citizen)
|
|
|
+ .WhereIF(dto.TypeId == 2, (it, o) => o.IdentityType == EIdentityType.Enterprise)
|
|
|
+ .WhereIF(IsCenter == false, (it, o) => o.ActualHandleOrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .GroupBy((it, o) => new { Id = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")) })
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ HotspotCode = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")),
|
|
|
+ SumCount = SqlFunc.AggregateCount(it.HotSpotName)
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .LeftJoin<Hotspot>((x, q) => x.HotspotCode == q.Id)
|
|
|
+ .Select((x, q) => new
|
|
|
+ {
|
|
|
+ SumCount = x.SumCount,
|
|
|
+ HotspotName = q.HotSpotName
|
|
|
+ })
|
|
|
+ .ToDataTableAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string count = (dto.HotspotCode.Length + 2).ToString();
|
|
|
+ string countx = dto.HotspotCode.Length.ToString();
|
|
|
+ data = await _hotspotTypeRepository.Queryable()
|
|
|
+ .LeftJoin<Order>((it, o) => it.Id == o.HotspotId)
|
|
|
+ .Where((it, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && it.ParentId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(countx)) == dto.HotspotCode)
|
|
|
+ .WhereIF(dto.TypeId == 1, (it, o) => o.IdentityType == EIdentityType.Citizen)
|
|
|
+ .WhereIF(dto.TypeId == 2, (it, o) => o.IdentityType == EIdentityType.Enterprise)
|
|
|
+ .WhereIF(IsCenter == false, (it, o) => o.ActualHandleOrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .GroupBy((it, o) => new { Id = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(count)) })
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ HotspotCode = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(count)),
|
|
|
+ SumCount = SqlFunc.AggregateCount(it.HotSpotName)
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .LeftJoin<Hotspot>((x, q) => x.HotspotCode == q.Id)
|
|
|
+ .Select((x, q) => new
|
|
|
+ {
|
|
|
+ SumCount = x.SumCount,
|
|
|
+ HotspotName = q.HotSpotName,
|
|
|
+ })
|
|
|
+ .ToDataTableAsync();
|
|
|
+
|
|
|
+ }
|
|
|
+ data.Columns["SumCount"].ColumnName = "分类统计";
|
|
|
+ data.Columns["HotspotName"].ColumnName = "热点名称";
|
|
|
+ //合计
|
|
|
+ DataRow sumRow = data.NewRow();
|
|
|
+ sumRow["热点名称"] = "合计";
|
|
|
+ decimal totalAmount = 0;
|
|
|
+ foreach (DataRow row in data.Rows)
|
|
|
+ {
|
|
|
+ totalAmount += Convert.ToDecimal(row["分类统计"]);
|
|
|
+ }
|
|
|
+ sumRow["分类统计"] = totalAmount;
|
|
|
+ data.Rows.Add(sumRow);
|
|
|
+
|
|
|
+ var stream = ExcelHelper.CreateStream(data);
|
|
|
+ return ExcelStreamResult(stream, "热点类型小类统计");
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 部门满意度统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("visit-org-satisfaction-statistics")]
|
|
|
public async Task<VisitAndOrgSatisfactionStatisticsResultDto> VisitAndOrgSatisfactionStatistics([FromQuery] PagedKeywordSonRequest dto)
|
|
|
{
|
|
|
var data = await _orderApplication.VisitAndOrgSatisfactionStatistics(dto);
|