|
@@ -46,8 +46,9 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
private readonly ICommunityInfoRepository _communityInfoRepository;
|
|
|
+ private readonly IRepository<SystemArea> _systemAreaRepository;
|
|
|
|
|
|
- public BiSnapshotApplication(IOrderSnapshotRepository orderSnapshotRepository, IRedPackRecordRepository redPackRecordRepository, IIndustryRepository industryRepository, IIndustryCaseRepository industryCaseRepository, IRedPackAuditRepository redPackAuditRepository, IRepository<Hotspot> hotspotTypeRepository, ISessionContext sessionContext, IOrderRepository orderRepository, ICommunityInfoRepository communityInfoRepository)
|
|
|
+ public BiSnapshotApplication(IOrderSnapshotRepository orderSnapshotRepository, IRedPackRecordRepository redPackRecordRepository, IIndustryRepository industryRepository, IIndustryCaseRepository industryCaseRepository, IRedPackAuditRepository redPackAuditRepository, IRepository<Hotspot> hotspotTypeRepository, ISessionContext sessionContext, IOrderRepository orderRepository, ICommunityInfoRepository communityInfoRepository, IRepository<SystemArea> systemAreaRepository)
|
|
|
{
|
|
|
_orderSnapshotRepository = orderSnapshotRepository;
|
|
|
_redPackRecordRepository = redPackRecordRepository;
|
|
@@ -58,6 +59,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
_sessionContext = sessionContext;
|
|
|
_orderRepository = orderRepository;
|
|
|
_communityInfoRepository = communityInfoRepository;
|
|
|
+ _systemAreaRepository = systemAreaRepository;
|
|
|
}
|
|
|
|
|
|
public ISugarQueryable<HotspotStatisticsOutDto> GetHotspotStatistics(HotspotStatisticsInDto dto)
|
|
@@ -534,7 +536,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
CommunityCode = it.Id,
|
|
|
CommunityName = it.Name,
|
|
|
CommunityFullName = it.FullName,
|
|
|
- SumCount = SqlFunc.Subqueryable<OrderSnapshot>().Where(snapshot => snapshot.CommunityFullName.Contains(it.FullName)).Count(),
|
|
|
+ SumCount = SqlFunc.Subqueryable<OrderSnapshot>().Where(snapshot => snapshot.CommunityFullName!.Contains(it.FullName)).Count(),
|
|
|
HasChild = SqlFunc.Subqueryable<CommunityInfo>().Where(c => c.ParentCode == it.Id).Any()
|
|
|
});
|
|
|
#if DEBUG
|
|
@@ -547,7 +549,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
{
|
|
|
var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
.LeftJoin<Order>((snapshot, order) => snapshot.Id == order.Id)
|
|
|
- .Where((snapshot, order) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && snapshot.CommunityFullName.Contains(dto.CommunityFullName))
|
|
|
+ .Where((snapshot, order) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime && snapshot.CommunityFullName!.Contains(dto.CommunityFullName))
|
|
|
.WhereIF(dto.IndustryId.NotNullOrEmpty(), (snapshot, order) => snapshot.IndustryId == dto.IndustryId)
|
|
|
.Select((snapshot, order) => new CommunityStatisticsDetailsOutDto(), true);
|
|
|
#if DEBUG
|
|
@@ -555,4 +557,42 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
#endif
|
|
|
return query;
|
|
|
}
|
|
|
+
|
|
|
+ public async Task<IList<CountyRedPackStatisticsOutDto>> GetCountyRedPackStatistics(CountyRedPackStatisticsInDto dto)
|
|
|
+ {
|
|
|
+ var query = _systemAreaRepository.Queryable(includeDeleted: true)
|
|
|
+ .LeftJoin<Order>((area, order) => order.County == area.AreaName && order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime && order.County != null)
|
|
|
+ .LeftJoin<OrderSnapshot>((area, order, snapshot) => snapshot.Id == order.Id && (dto.IndustryId.IsNullOrEmpty() || snapshot.IndustryId == dto.IndustryId))
|
|
|
+ .LeftJoin<RedPackAudit>((area, order, snapshot, audit) => snapshot.Id == audit.OrderId)
|
|
|
+ .LeftJoin<RedPackRecord>((area, order, snapshot, audit, record) => audit.Id == record.RedPackAuditId)
|
|
|
+ .LeftJoin<SupplementRecord>((area, order, snapshot, audit, record, supplement) => supplement.RedPackAuditId == audit.Id)
|
|
|
+ .LeftJoin<RedPackGuiderAudit>((area, order, snapshot, audit, record, supplement, guiderAudit) => guiderAudit.OrderId == snapshot.Id)
|
|
|
+ .LeftJoin<RedPackRecord>((area, order, snapshot, audit, record, supplement, guiderAudit, guiderRecord) => guiderAudit.Id == guiderRecord.RedPackAuditId)
|
|
|
+ .LeftJoin<Industry>((area, order, snapshot, audit, record, supplement, guiderAudit, guiderRecord, industry) => snapshot.IndustryId == industry.Id)
|
|
|
+ .Where((area, order, snapshot, audit, record, supplement, guiderAudit, guiderRecord) => area.ParentId == "510300" || area.AreaName == "外地")
|
|
|
+ .GroupBy((area, order, snapshot, audit, record, supplement, guiderAudit, guiderRecord) => new { area.AreaName, order.County })
|
|
|
+ .Select((area, order, snapshot, audit, record, supplement, guiderAudit, guiderRecord, industry) => new CountyRedPackStatisticsOutDto
|
|
|
+ {
|
|
|
+ County = area.AreaName,
|
|
|
+ JuBaoZongShu = SqlFunc.AggregateSum(SqlFunc.IIF(industry.IndustryType == EIndustryType.Clue, 1, 0)),
|
|
|
+ YiBanJieShu = SqlFunc.AggregateSum(SqlFunc.IIF(order.Status >= EOrderStatus.Filed && industry.IndustryType == EIndustryType.Clue, 1, 0)),
|
|
|
+ ShiMinShenHeTongGuoShu = SqlFunc.AggregateSum(SqlFunc.IIF(record.PeopleType == EReadPackUserType.Citizen && audit.Status == ERedPackAuditStatus.Agree, 1, 0)),
|
|
|
+ ShiMinZongJinE = SqlFunc.AggregateSum(SqlFunc.IIF(record.PeopleType == EReadPackUserType.Citizen && audit.Status == ERedPackAuditStatus.Agree, audit.ApprovedAmount, 0)),
|
|
|
+ ShiMinYiLing = SqlFunc.AggregateSum(SqlFunc.IIF(record.PeopleType == EReadPackUserType.Citizen && record.PickupStatus == ERedPackPickupStatus.Received, record.Amount, 0)),
|
|
|
+ ShiMinDaiLing = SqlFunc.AggregateSum(SqlFunc.IIF(record.PeopleType == EReadPackUserType.Citizen && record.PickupStatus == ERedPackPickupStatus.Unreceived, record.Amount, 0)),
|
|
|
+ ShiMinDaiBuLing = SqlFunc.AggregateSum(SqlFunc.IIF(record.PeopleType == EReadPackUserType.Citizen && supplement.Id != null, supplement.ReplenishAmount, 0)),
|
|
|
+ WangGeYuanZongJianShu = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.IsDeal == true, 1, 0)),
|
|
|
+ WangGeYuanShenHeTongGuoShu = SqlFunc.AggregateSum(SqlFunc.IIF(guiderAudit.LevelTwoStatus == ERedPackAuditStatus.Agree, 1, 0)),
|
|
|
+ WangGeYuanZongJinE = SqlFunc.AggregateSum(SqlFunc.IIF(guiderAudit.LevelTwoStatus == ERedPackAuditStatus.Agree, guiderAudit.ApprovedAmount, 0)),
|
|
|
+ WangGeYuanYiLing = SqlFunc.AggregateSum(SqlFunc.IIF(guiderRecord.PickupStatus == ERedPackPickupStatus.Received, guiderRecord.Amount, 0)),
|
|
|
+ WangGeYuanDaiLing = SqlFunc.AggregateSum(SqlFunc.IIF(guiderRecord.PickupStatus == ERedPackPickupStatus.Unreceived, guiderRecord.Amount, 0)),
|
|
|
+ });
|
|
|
+
|
|
|
+#if DEBUG
|
|
|
+ var sql = query.ToSqlString();
|
|
|
+#endif
|
|
|
+ var outDto = await query.ToListAsync();
|
|
|
+ outDto.AddSumLine("County");
|
|
|
+ return outDto;
|
|
|
+ }
|
|
|
}
|