|
@@ -1,6 +1,10 @@
|
|
|
using FluentValidation.Results;
|
|
|
+using Hotline.FlowEngine.Workflows;
|
|
|
+using Hotline.Orders;
|
|
|
using Hotline.Share.Dtos.Snapshot;
|
|
|
+using Hotline.Snapshot;
|
|
|
using Hotline.Snapshot.Interfaces;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -22,15 +26,16 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
public async Task<SnapshotStatisticsOutDto> GetSnapshotStatisticsAsync(SnapshotStatisticsInDto dto, CancellationToken token)
|
|
|
{
|
|
|
var query = _orderSnapshotRepository.Queryable()
|
|
|
- .Where((order) => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime)
|
|
|
- .Select((order) => new SnapshotStatisticsOutDto
|
|
|
+ .LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
+ .Where((snapshot) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime)
|
|
|
+ .Select((snapshot, order) => new SnapshotStatisticsOutDto
|
|
|
{
|
|
|
WZSLFWNJS = 0, // 未在受理范围内件数,
|
|
|
- SSPZ12345JS =0, // 随手拍转12345件数,
|
|
|
- SLFWNZJS = 0, // 受理范围内总件数,
|
|
|
- SLFWNPGWGYSXSNHFJS = 0, // 受理范围内派给网格员四小时内回复件数,
|
|
|
- SLFWNPGWGYCGSXSHFJS = 0, // 受理范围内派给网格员超过四小时回复件数
|
|
|
- SLFWNPGWGYWHFJS = 0, // 受理范围内派给网格员未回复件数
|
|
|
+ SSPZ12345JS = SqlFunc.AggregateSum(SqlFunc.IIF(order.SourceChannelCode != "SSP", 1, 0)), // 随手拍转12345件数,
|
|
|
+ SLFWNZJS = SqlFunc.AggregateCount(snapshot.Id), // 受理范围内总件数,
|
|
|
+ SLFWNPGWGYSXSNHFJS = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.IsGuidSystemCallBack == true && snapshot.GuidSystemCallBackTime.Value.AddHours(-4) > snapshot.SendGuidSystemTime, 1, 0)), // 受理范围内派给网格员四小时内回复件数,
|
|
|
+ SLFWNPGWGYCGSXSHFJS = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.IsGuidSystemCallBack == true && snapshot.GuidSystemCallBackTime.Value.AddHours(-4) <= snapshot.SendGuidSystemTime, 1, 0)), // 受理范围内派给网格员超过四小时回复件数
|
|
|
+ SLFWNPGWGYWHFJS = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.IsGuidSystemCallBack == false, 1, 0)), // 受理范围内派给网格员未回复件数
|
|
|
SLFWNA12345ZPGGBMJS = 0, //受理范围内按12345直派给各部门件数,
|
|
|
SLFWNA12345ZPGGQXJS = 0, //受理范围内按12345直派给各区县件数
|
|
|
ZXYB = 0, // 中心已办
|
|
@@ -80,9 +85,22 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
|
|
|
public ISugarQueryable<SnapshotStatisticsDetailOutDto> GetSnapshotStatisticsDetail(SnapshotStatisticsDetailInDto dto, CancellationToken requestAborted)
|
|
|
{
|
|
|
+ dto.FieldName = dto.FieldName.ToUpper();
|
|
|
var query = _orderSnapshotRepository.Queryable()
|
|
|
- .Where((order) => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime)
|
|
|
- .Select((order) => new SnapshotStatisticsDetailOutDto());
|
|
|
- return query;
|
|
|
+ .LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
+ .Where((snapshot, order) => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime);
|
|
|
+ if (dto.FieldName == "SSPZ12345JS")
|
|
|
+ query = query.Where((snapshot, order) => order.SourceChannelCode != "SSP");
|
|
|
+ if (dto.FieldName == "SLFWNPGWGYSXSNHFJS")
|
|
|
+ query = query.Where((snapshot, order) => snapshot.IsGuidSystemCallBack == true && snapshot.GuidSystemCallBackTime.Value.AddHours(-4) <= snapshot.SendGuidSystemTime);
|
|
|
+ if (dto.FieldName == "SLFWNPGWGYCGSXSHFJS")
|
|
|
+ query = query.Where((snapshot, order) => snapshot.IsGuidSystemCallBack == true && snapshot.GuidSystemCallBackTime.Value.AddHours(-4) <= snapshot.SendGuidSystemTime);
|
|
|
+ if (dto.FieldName == "SLFWNPGWGYWHFJS")
|
|
|
+ query = query.Where((snapshot, order) => snapshot.IsGuidSystemCallBack == false);
|
|
|
+
|
|
|
+ return query.Select((snapshot, order) => new SnapshotStatisticsDetailOutDto
|
|
|
+ {
|
|
|
+ CreationTime = order.CreationTime
|
|
|
+ }, true);
|
|
|
}
|
|
|
}
|