|
@@ -56,6 +56,7 @@ using XF.Domain.Entities;
|
|
|
using XF.Domain.Exceptions;
|
|
|
using XF.Domain.Repository;
|
|
|
using WordInfo = PanGu.WordInfo;
|
|
|
+using Hotline.Repository.SqlSugar.Orders;
|
|
|
|
|
|
namespace Hotline.Application.Orders;
|
|
|
|
|
@@ -848,7 +849,20 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
public async Task<(int, IList<PublishedOrderStatisticsDto>)> QueryPublishedOrderAsync(QueryOrderPublishStatisticsDto dto, bool isFull)
|
|
|
{
|
|
|
- var query = _orderRepository.Queryable()
|
|
|
+ var orders = await _orderRepository.Queryable()
|
|
|
+ .LeftJoin<User>((order, user) => order.WaitForPublisherId == user.Id)
|
|
|
+ .Where((order, user) => !string.IsNullOrEmpty(order.WaitForPublisherId))
|
|
|
+ .WhereIF(dto.ProcessType != null && dto.ProcessType == EProcessType.Zhiban, (order, user) => order.FileOrgIsCenter == true)
|
|
|
+ .WhereIF(dto.ProcessType != null && dto.ProcessType == EProcessType.Jiaoban, (order, user) => order.FileOrgIsCenter == false)
|
|
|
+ .GroupBy((order, user) => new { order.WaitForPublisherId, user.Name })
|
|
|
+ .Select((order, user) => new PublishedOrderStatisticsDto
|
|
|
+ {
|
|
|
+ Id = order.WaitForPublisherId,
|
|
|
+ Name = user.Name,
|
|
|
+ WaitCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.Status == EOrderStatus.Filed, 1, 0)),
|
|
|
+ }).ToListAsync();
|
|
|
+
|
|
|
+ var query = _orderRepository.Queryable()
|
|
|
.Includes(order => order.OrderPublish)
|
|
|
.LeftJoin<User>((order, user) => order.WaitForPublisherId == user.Id)
|
|
|
.Where((order, user) => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime &&
|
|
@@ -878,7 +892,19 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
(total, items) = await query.ToPagedListAsync(dto.PageIndex, dto.PageSize);
|
|
|
}
|
|
|
|
|
|
- return (total, items);
|
|
|
+ var res = (from t1 in items
|
|
|
+ join t2 in orders on t1.Name equals t2.Name into t1_t2
|
|
|
+ from item in t1_t2.DefaultIfEmpty()
|
|
|
+ select new PublishedOrderStatisticsDto
|
|
|
+ {
|
|
|
+ Name = t1.Name,
|
|
|
+ PublishTime = t1.PublishTime,
|
|
|
+ WaitCount = t1_t2.Select(x => x.WaitCount).FirstOrDefault(),
|
|
|
+ PublicCount = t1.PublicCount,
|
|
|
+ PrivateCount = t1.PrivateCount
|
|
|
+ }).ToList();
|
|
|
+
|
|
|
+ return (total, res);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -893,9 +919,18 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
var total = 0;
|
|
|
var items = new List<PublishedOrderStatisticsDto>();
|
|
|
|
|
|
- var query = _orderRepository.Queryable()
|
|
|
+ var orders = await _orderRepository.Queryable()
|
|
|
+ .Where(order => order.ActualHandleOrgName != null)
|
|
|
+ .GroupBy(order => new { Name = order.ActualHandleOrgName })
|
|
|
+ .Select(order => new PublishedOrderStatisticsDto
|
|
|
+ {
|
|
|
+ Name = order.ActualHandleOrgName,
|
|
|
+ WaitCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.Status == EOrderStatus.Filed, 1, 0)),
|
|
|
+ }).ToListAsync();
|
|
|
+
|
|
|
+ var query = _orderRepository.Queryable()
|
|
|
.Includes(order => order.OrderPublish)
|
|
|
- .Where(order => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime && order.ActualHandleOrgName != null)
|
|
|
+ .Where(order => order.OrderPublish.CreationTime >= dto.StartTime && order.OrderPublish.CreationTime <= dto.EndTime && order.ActualHandleOrgName != null)
|
|
|
.GroupBy(order => new { Name = order.ActualHandleOrgName, PublishTime = order.CreationTime.ToString("YYYY-MM-DD") })
|
|
|
.Select(order => new PublishedOrderStatisticsDto
|
|
|
{
|
|
@@ -906,16 +941,28 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
PublicCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.OrderPublish.PublishState == true, 1, 0)),
|
|
|
PrivateCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.OrderPublish.PublishState == false, 1, 0))
|
|
|
});
|
|
|
- if (isFull)
|
|
|
- {
|
|
|
- items = await query.ToListAsync();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- (total, items) = await query.ToPagedListAsync(dto.PageIndex, dto.PageSize);
|
|
|
- }
|
|
|
-
|
|
|
- return (total, items);
|
|
|
+ if (isFull)
|
|
|
+ {
|
|
|
+ items = await query.ToListAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (total, items) = await query.ToPagedListAsync(dto.PageIndex, dto.PageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ var res = (from t1 in items
|
|
|
+ join t2 in orders on t1.Name equals t2.Name into t1_t2
|
|
|
+ from item in t1_t2.DefaultIfEmpty()
|
|
|
+ select new PublishedOrderStatisticsDto
|
|
|
+ {
|
|
|
+ Name = t1.Name,
|
|
|
+ PublishTime = t1.PublishTime,
|
|
|
+ WaitCount = t1_t2.Select(x => x.WaitCount).FirstOrDefault(),
|
|
|
+ PublicCount = t1.PublicCount,
|
|
|
+ PrivateCount = t1.PrivateCount
|
|
|
+ }).ToList();
|
|
|
+
|
|
|
+ return (total, res);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|