|
@@ -2,6 +2,7 @@
|
|
|
using Hotline.FlowEngine.Workflows;
|
|
|
using Hotline.Orders;
|
|
|
using Hotline.Share.Dtos.Snapshot;
|
|
|
+using Hotline.Share.Enums.Snapshot;
|
|
|
using Hotline.Snapshot;
|
|
|
using Hotline.Snapshot.Interfaces;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
@@ -12,6 +13,8 @@ using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using XF.Domain.Dependency;
|
|
|
+using XF.Domain.Exceptions;
|
|
|
+using static NPOI.SS.Format.CellNumberFormatter;
|
|
|
|
|
|
namespace Hotline.Application.Snapshot;
|
|
|
public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
@@ -27,8 +30,12 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
{
|
|
|
var query = _orderSnapshotRepository.Queryable()
|
|
|
.LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
+ .LeftJoin<RedPackAudit>((snapshot, order, redPackAudit) => snapshot.Id == redPackAudit.OrderId)
|
|
|
+ .LeftJoin<SpecialRedPackAudit>((snapshot, order, redPackAudit, special) => snapshot.Id == special.OrderId)
|
|
|
+ .LeftJoin<RedPackGuiderAudit>((snapshot, order, redPackAudit, special, guiderAudit) => snapshot.Id == guiderAudit.OrderId)
|
|
|
+ .LeftJoin<RedPackRecord>((snapshot, order, redPackAudit, special, guiderAudit, record) => redPackAudit.Id == record.RedPackAuditId)
|
|
|
.Where((snapshot) => snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime)
|
|
|
- .Select((snapshot, order) => new SnapshotStatisticsOutDto
|
|
|
+ .Select((snapshot, order, redPackAudit, special, guiderAudit, record) => new SnapshotStatisticsOutDto
|
|
|
{
|
|
|
WZSLFWNJS = 0, // 未在受理范围内件数,
|
|
|
SSPZ12345JS = SqlFunc.AggregateSum(SqlFunc.IIF(order.SourceChannelCode != "SSP", 1, 0)), // 随手拍转12345件数,
|
|
@@ -38,25 +45,25 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
SLFWNPGWGYWHFJS = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.IsGuidSystemCallBack == false, 1, 0)), // 受理范围内派给网格员未回复件数
|
|
|
SLFWNA12345ZPGGBMJS = 0, //受理范围内按12345直派给各部门件数,
|
|
|
SLFWNA12345ZPGGQXJS = 0, //受理范围内按12345直派给各区县件数
|
|
|
- ZXYB = 0, // 中心已办
|
|
|
- BMYB = 0, // 部门已办
|
|
|
+ ZXYB = SqlFunc.AggregateSum(SqlFunc.IIF(order.FileOrgIsCenter == true, 1, 0)), // 中心已办
|
|
|
+ BMYB = SqlFunc.AggregateSum(SqlFunc.IIF(order.FileOrgIsCenter == false, 1, 0)), // 部门已办
|
|
|
SLFWMYD = 0, //受理范围满意度
|
|
|
- MYL = 0, // 满意量
|
|
|
- BMYL = 0, // 不满意量
|
|
|
- SPBTYHBGS = 0, // 审批不同意红包个数
|
|
|
- SPTYHBGS = 0, // 审批同意红包个数
|
|
|
+ MYL = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "1") || SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "2"), 0, 1)), // 满意量
|
|
|
+ BMYL = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "1") || SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "2"), 1, 0)), // 不满意量
|
|
|
+ SPBTYHBGS = SqlFunc.AggregateSum(SqlFunc.IIF(redPackAudit.Status == ERedPackAuditStatus.Refuse, 1, 0)), // 审批不同意红包个数
|
|
|
+ SPTYHBGS = SqlFunc.AggregateSum(SqlFunc.IIF(redPackAudit.Status == ERedPackAuditStatus.Agree, 1, 0)), // 审批同意红包个数
|
|
|
TSHBSP = 0, //特殊红包审批统计
|
|
|
- SPTYGS = 0, //审批同意个数
|
|
|
- YFJE = 0, // 已发金额
|
|
|
+ SPTYGS = SqlFunc.AggregateSum(SqlFunc.IIF(special.Status == ERedPackAuditStatus.Agree, 1, 0)), //审批同意个数
|
|
|
+ YFJE = SqlFunc.AggregateSum(SqlFunc.IIF(special.IsSend == true, special.AcutalAmount, 0)), // 已发金额
|
|
|
JSHFFWGJLGS = 0, //局审核发放网格员奖励个数
|
|
|
- SPTYWGYHBGS = 0, //审批同意(网格员)红包个数
|
|
|
- SPBTYWGYHBGS = 0, //审批不同意(网格员)红包个数
|
|
|
- SMJLZE = 0, // 市民奖励总额
|
|
|
- SMYFFJLZE = 0, // 市民已发放奖励总额
|
|
|
- SMDFFJLZE = 0, // 市民待发奖励总额
|
|
|
- YFG = 0, //已发(个)
|
|
|
+ SPTYWGYHBGS = SqlFunc.AggregateSum(SqlFunc.IIF(guiderAudit.LevelTwoStatus == ERedPackAuditStatus.Agree, 1, 0)), //审批同意(网格员)红包个数
|
|
|
+ SPBTYWGYHBGS = SqlFunc.AggregateSum(SqlFunc.IIF(guiderAudit.LevelOneStatus == ERedPackAuditStatus.Refuse || guiderAudit.LevelTwoStatus == ERedPackAuditStatus.Refuse, 1, 0)), //审批不同意(网格员)红包个数
|
|
|
+ SMJLZE = SqlFunc.AggregateSum(redPackAudit.AcutalAmount), // 市民奖励总额
|
|
|
+ SMYFFJLZE = SqlFunc.AggregateSum(SqlFunc.IIF(redPackAudit.IsSend == true, redPackAudit.AcutalAmount, 0)), // 市民已发放奖励总额
|
|
|
+ SMDFFJLZE = SqlFunc.AggregateSum(SqlFunc.IIF(redPackAudit.IsSend == false, redPackAudit.ApprovedAmount, 0)), // 市民待发奖励总额
|
|
|
+ YFG = SqlFunc.AggregateSum(SqlFunc.IIF(redPackAudit.IsSend == true, 1, 0)), //已发(个)
|
|
|
WFLXG = 0, // 无法联系(个)
|
|
|
- WJHBG = 0, // 婉拒红包(个)
|
|
|
+ WJHBG = SqlFunc.AggregateSum(SqlFunc.IIF(record.FailCase == ERedPackPickupFailCase.Excuse, 1, 0)), // 婉拒红包(个)
|
|
|
WGYYFJLJE = 0, //网格员应发奖励金额
|
|
|
WGYYFFJLZE = 0, // 网格员已发放奖励总额
|
|
|
WGYDFFJLZE = 0, // 网格员待发放奖励总额
|
|
@@ -86,19 +93,33 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
public ISugarQueryable<SnapshotStatisticsDetailOutDto> GetSnapshotStatisticsDetail(SnapshotStatisticsDetailInDto dto, CancellationToken requestAborted)
|
|
|
{
|
|
|
dto.FieldName = dto.FieldName.ToUpper();
|
|
|
- var query = _orderSnapshotRepository.Queryable()
|
|
|
+ var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
.LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
+ .LeftJoin<RedPackAudit>((snapshot, order, redPackAudit) => snapshot.Id == redPackAudit.OrderId)
|
|
|
+ .LeftJoin<SpecialRedPackAudit>((snapshot, order, redPackAudit, special) => snapshot.Id == special.OrderId)
|
|
|
+ .LeftJoin<RedPackGuiderAudit>((snapshot, order, redPackAudit, special, guiderAudit) => snapshot.Id == guiderAudit.OrderId)
|
|
|
.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);
|
|
|
+ query = dto.FieldName switch
|
|
|
+ {
|
|
|
+ "WZSLFWNJS" => query.Where((snapshot, order) => order.SourceChannelCode != "SSP"),
|
|
|
+ "SSPZ12345JS" => query.Where((snapshot, order) => order.SourceChannelCode != "SSP"),
|
|
|
+ "SLFWNPGWGYSXSNHFJS" => query.Where((snapshot, order) => snapshot.IsGuidSystemCallBack == true && snapshot.GuidSystemCallBackTime!.Value.AddHours(-4) <= snapshot.SendGuidSystemTime),
|
|
|
+ "SLFWNPGWGYCGSXSHFJS" => query.Where((snapshot, order) => snapshot.IsGuidSystemCallBack == true && snapshot.GuidSystemCallBackTime!.Value.AddHours(-4) <= snapshot.SendGuidSystemTime),
|
|
|
+ "SLFWNPGWGYWHFJS" => query.Where((snapshot, order) => snapshot.IsGuidSystemCallBack == false),
|
|
|
+ "ZXYB" => query.Where((snapshop, order) => order.FileOrgIsCenter == true),
|
|
|
+ "BMYB" => query.Where((snapshop, order) => order.FileOrgIsCenter == false),
|
|
|
+ "MYL" => query.Where((snapshot, order) => SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "-1") || SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "3") || SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "4") || SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "5")),
|
|
|
+ "BMYL" => query.Where((snapshot, order) => SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "1") || SqlFunc.JsonListObjectAny(order.OrgProcessingResults, "key", "2")),
|
|
|
+ "SPBTYHBGS" => query.Where((snapshot, order, redPackAudit) => redPackAudit.Status == ERedPackAuditStatus.Refuse),
|
|
|
+ "SPTYHBGS" => query.Where((snapshot, order, redPackAudit) => redPackAudit.Status == ERedPackAuditStatus.Agree),
|
|
|
+ "SPTYGS" => query.Where((snapshot, order, redPackAudit, special) => special.Status == ERedPackAuditStatus.Agree),
|
|
|
+ "YFJE" => query.Where((snapshot, order, redPackAudit, special) => special.IsSend == true),
|
|
|
+ "SPTYWGYHBGS" => query.Where((snapshot, order, redPackAudit, special, guiderAudit) => guiderAudit.LevelTwoStatus == ERedPackAuditStatus.Agree),
|
|
|
+ "SPBTYWGYHBGS" => query.Where((snapshot, order, redPackAudit, special, guiderAudit) => guiderAudit.LevelOneStatus == ERedPackAuditStatus.Refuse || guiderAudit.LevelTwoStatus == ERedPackAuditStatus.Refuse),
|
|
|
+ _ => throw new UserFriendlyException("入参错误:" + dto.FieldName + " 未实现")
|
|
|
+ };
|
|
|
|
|
|
- return query.Select((snapshot, order) => new SnapshotStatisticsDetailOutDto
|
|
|
+ return query.Select((snapshot, order, redPackAudit, special, guiderAudit) => new SnapshotStatisticsDetailOutDto
|
|
|
{
|
|
|
CreationTime = order.CreationTime
|
|
|
}, true);
|