|
@@ -45,8 +45,9 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
private readonly IRepository<Hotspot> _hotspotTypeRepository;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
+ private readonly ICommunityInfoRepository _communityInfoRepository;
|
|
|
|
|
|
- public BiSnapshotApplication(IOrderSnapshotRepository orderSnapshotRepository, IRedPackRecordRepository redPackRecordRepository, IIndustryRepository industryRepository, IIndustryCaseRepository industryCaseRepository, IRedPackAuditRepository redPackAuditRepository, IRepository<Hotspot> hotspotTypeRepository, ISessionContext sessionContext, IOrderRepository orderRepository)
|
|
|
+ public BiSnapshotApplication(IOrderSnapshotRepository orderSnapshotRepository, IRedPackRecordRepository redPackRecordRepository, IIndustryRepository industryRepository, IIndustryCaseRepository industryCaseRepository, IRedPackAuditRepository redPackAuditRepository, IRepository<Hotspot> hotspotTypeRepository, ISessionContext sessionContext, IOrderRepository orderRepository, ICommunityInfoRepository communityInfoRepository)
|
|
|
{
|
|
|
_orderSnapshotRepository = orderSnapshotRepository;
|
|
|
_redPackRecordRepository = redPackRecordRepository;
|
|
@@ -56,6 +57,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
_hotspotTypeRepository = hotspotTypeRepository;
|
|
|
_sessionContext = sessionContext;
|
|
|
_orderRepository = orderRepository;
|
|
|
+ _communityInfoRepository = communityInfoRepository;
|
|
|
}
|
|
|
|
|
|
public ISugarQueryable<HotspotStatisticsOutDto> GetHotspotStatistics(HotspotStatisticsInDto dto)
|
|
@@ -434,7 +436,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
public ISugarQueryable<GuiderWorkStatisticsOutDto> GetGuiderWorkStatisticsAsync(GuiderWorkStatisticsInDto dto)
|
|
|
{
|
|
|
var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
- .Where(snapshot => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && snapshot.MemberName != null )
|
|
|
+ .Where(snapshot => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && snapshot.MemberName != null)
|
|
|
.GroupBy(snapshot => new { snapshot.MemberName, snapshot.MemberMobile })
|
|
|
.Select(snapshot => new GuiderWorkStatisticsOutDto
|
|
|
{
|
|
@@ -463,7 +465,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
_ => throw new UserFriendlyException($"入参: {dto.FieldName} 异常")
|
|
|
};
|
|
|
return query.Select((snapshot, order) => new GuiderWorkStatisticsDetailsOutDto
|
|
|
- {
|
|
|
+ {
|
|
|
}, true);
|
|
|
}
|
|
|
|
|
@@ -490,7 +492,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
.Where((snapshot, order) => snapshot.IsGuidSystemCallBack == true)
|
|
|
.WhereIF(dto.MemberMobile.NotNullOrEmpty(), snapshot => snapshot.MemberMobile.Contains(dto.MemberMobile))
|
|
|
.WhereIF(dto.BeginCreationTime != null && dto.EndCreationTime != null, snapshot => snapshot.CreationTime >= dto.BeginCreationTime && snapshot.CreationTime <= dto.EndCreationTime)
|
|
|
- .WhereIF(dto.MemberName.NotNullOrEmpty(), snapshot => snapshot.MemberName.Contains( dto.MemberName))
|
|
|
+ .WhereIF(dto.MemberName.NotNullOrEmpty(), snapshot => snapshot.MemberName.Contains(dto.MemberName))
|
|
|
.WhereIF(dto.No.NotNullOrEmpty(), (snapshot, order) => order.No.Contains(dto.No))
|
|
|
.WhereIF(dto.Title.NotNullOrEmpty(), (snapshot, order) => order.Title.Contains(dto.Title))
|
|
|
.WhereIF(dto.NetworkENumber.NotNullOrEmpty(), (snapshot, order) => snapshot.NetworkENumber.Contains(dto.NetworkENumber))
|
|
@@ -518,4 +520,39 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
.Select((snapshot, order) => new DuplicateItemsOutDto(), true);
|
|
|
return query;
|
|
|
}
|
|
|
+
|
|
|
+ public ISugarQueryable<CountyStatisticsOutDto> GetCountyStatistics(CountyStatisticsInDto dto)
|
|
|
+ {
|
|
|
+ var IsCenter = _sessionContext.OrgIsCenter;
|
|
|
+ string count = "2";
|
|
|
+ string countx = string.Empty;
|
|
|
+ if (dto.CountyCode.NotNullOrEmpty())
|
|
|
+ {
|
|
|
+ count = (dto.CountyCode.Length + 2).ToString();
|
|
|
+ countx = dto.CountyCode.Length.ToString();
|
|
|
+ }
|
|
|
+ return _communityInfoRepository.Queryable()
|
|
|
+ .LeftJoin<Order>((it, o) => it.Id == o.HotspotId)
|
|
|
+ .LeftJoin<OrderSnapshot>((it, o, s) => o.Id == s.Id)
|
|
|
+ .Where((it, o, s) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && s.Id != null)
|
|
|
+ .WhereIF(dto.CountyCode.IsNullOrEmpty(), (it, o) => o.Id != null)
|
|
|
+ .WhereIF(dto.CountyCode.NotNullOrEmpty(), (it, o) => it.ParentCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(countx)) == dto.CountyCode)
|
|
|
+ .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
|
|
|
+ {
|
|
|
+ CommunityCode = it.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(count)),
|
|
|
+ SumCount = SqlFunc.AggregateCount(it.FullName)
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .LeftJoin<CommunityInfo>((x, q) => x.CommunityCode == q.Id)
|
|
|
+ .Select((x, q) => new CountyStatisticsOutDto
|
|
|
+ {
|
|
|
+ CountyCode = x.CommunityCode,
|
|
|
+ SumCount = x.SumCount,
|
|
|
+ CountyName = q.Name,
|
|
|
+ HasChild = SqlFunc.Subqueryable<Hotspot>().Where(d => d.ParentId == x.CommunityCode).Any()
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
}
|