|
@@ -5,6 +5,7 @@ using Hotline.Settings;
|
|
|
using Hotline.Settings.Hotspots;
|
|
|
using Hotline.Share.Attributes;
|
|
|
using Hotline.Share.Dtos.Snapshot;
|
|
|
+using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Share.Enums.FlowEngine;
|
|
|
using Hotline.Share.Enums.Order;
|
|
|
using Hotline.Share.Enums.Snapshot;
|
|
@@ -36,8 +37,9 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
private readonly ICommunityInfoRepository _communityInfoRepository;
|
|
|
private readonly IRepository<SystemArea> _systemAreaRepository;
|
|
|
private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
|
|
|
+ private readonly ISnapshotPointsRecordRepository _snapshotPointsRecordRepository;
|
|
|
|
|
|
- public BiSnapshotApplication(IOrderSnapshotRepository orderSnapshotRepository, IRedPackRecordRepository redPackRecordRepository, IIndustryRepository industryRepository, IIndustryCaseRepository industryCaseRepository, IRedPackAuditRepository redPackAuditRepository, IRepository<Hotspot> hotspotTypeRepository, ISessionContext sessionContext, IOrderRepository orderRepository, ICommunityInfoRepository communityInfoRepository, IRepository<SystemArea> systemAreaRepository, IOptionsSnapshot<AppConfiguration> appOptions)
|
|
|
+ public BiSnapshotApplication(IOrderSnapshotRepository orderSnapshotRepository, IRedPackRecordRepository redPackRecordRepository, IIndustryRepository industryRepository, IIndustryCaseRepository industryCaseRepository, IRedPackAuditRepository redPackAuditRepository, IRepository<Hotspot> hotspotTypeRepository, ISessionContext sessionContext, IOrderRepository orderRepository, ICommunityInfoRepository communityInfoRepository, IRepository<SystemArea> systemAreaRepository, IOptionsSnapshot<AppConfiguration> appOptions, ISnapshotPointsRecordRepository snapshotPointsRecordRepository)
|
|
|
{
|
|
|
_orderSnapshotRepository = orderSnapshotRepository;
|
|
|
_redPackRecordRepository = redPackRecordRepository;
|
|
@@ -50,6 +52,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
_communityInfoRepository = communityInfoRepository;
|
|
|
_systemAreaRepository = systemAreaRepository;
|
|
|
_appOptions = appOptions;
|
|
|
+ _snapshotPointsRecordRepository = snapshotPointsRecordRepository;
|
|
|
}
|
|
|
|
|
|
public ISugarQueryable<HotspotStatisticsOutDto> GetHotspotStatistics(HotspotStatisticsInDto dto)
|
|
@@ -734,7 +737,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
.LeftJoin<OrderSendBackAudit>((snapshot, order, back) => snapshot.Id == back.OrderId && back.State == ESendBackAuditState.End)
|
|
|
.LeftJoin<OrderVisit>((snapshot, order, back, visit) => snapshot.Id == visit.OrderId && visit.VisitState == EVisitState.Visited)
|
|
|
.LeftJoin<OrderSecondaryHandling>((snapshot, order, back, visit, second) => snapshot.Id == second.OrderId && second.State == ESecondaryHandlingState.End)
|
|
|
- .Where((snapshot, order) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime
|
|
|
+ .Where((snapshot, order) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime
|
|
|
&& order.ActualHandleOrgCode != null && order.ActualHandleOrgCode != "001")
|
|
|
.GroupBy((snapshot, order) => new
|
|
|
{
|
|
@@ -972,4 +975,23 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
.Select((snapshot, order) => new IndustryStatisticsDetailsOutDto(), true);
|
|
|
return query;
|
|
|
}
|
|
|
+
|
|
|
+ public ISugarQueryable<SnapshotCountyPointsStatisticsOutDto> GetAreaPointsStatistics(SnapshotCountyPointsStatisticsInDto dto)
|
|
|
+ {
|
|
|
+ var query = _snapshotPointsRecordRepository.Queryable(includeDeleted: true)
|
|
|
+ .LeftJoin<Order>((points, order) => points.OrderId == order.Id)
|
|
|
+ .Where((points, order) => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime && order.County != "" && order.County != null)
|
|
|
+ .GroupBy((points, order) => order.County)
|
|
|
+ .Select((points, order) => new SnapshotCountyPointsStatisticsOutDto
|
|
|
+ {
|
|
|
+ CountyName = order.County,
|
|
|
+ Points = SqlFunc.AggregateSum(SqlFunc.IIF(points.Direction == EPointsDirection.In, points.Points, 0)),
|
|
|
+ ExchangePoints = SqlFunc.AggregateSum(SqlFunc.IIF(points.Source == EPointsSource.Exchange, points.Points, 0)),
|
|
|
+ });
|
|
|
+#if DEBUG
|
|
|
+ var sql = query.ToSqlString();
|
|
|
+#endif
|
|
|
+ return query;
|
|
|
+ }
|
|
|
+
|
|
|
}
|