|
@@ -23,6 +23,7 @@ using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
+using Org.BouncyCastle.Asn1.Pkcs;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -697,17 +698,13 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
.LeftJoin<Order>((snapshot, order) => snapshot.Id == order.Id)
|
|
|
.Where((snapshot, order) => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime && order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == dto.OrgCode)
|
|
|
- .Select((snapshot, order) => new SnapshotDepartmentAveTimeStatisticsDetailsOutDto(), true) ;
|
|
|
+ .Select((snapshot, order) => new SnapshotDepartmentAveTimeStatisticsDetailsOutDto(), true);
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
[ExportExcel("检查合规统计", "OrgName")]
|
|
|
public ISugarQueryable<CompliantStatisticsOutDto> GetCompliantStatistics(CompliantStatisticsInDto dto)
|
|
|
{
|
|
|
- bool IsCenter = _sessionContext.OrgIsCenter;
|
|
|
- var orgLevel = _sessionContext.OrgLevel;
|
|
|
- string orgLevelStr = (_sessionContext.RequiredOrgId.Length + 3).ToString();
|
|
|
-
|
|
|
var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
.LeftJoin<Order>((snapshot, order) => snapshot.Id == order.Id)
|
|
|
.LeftJoin<OrderSendBackAudit>((snapshot, order, back) => snapshot.Id == back.OrderId && back.State == ESendBackAuditState.End)
|
|
@@ -764,4 +761,74 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
}, true);
|
|
|
}
|
|
|
|
|
|
+ public List<Dictionary<string, object>> GetReTransactStatistics(ReTransactStatisticsInDto dto)
|
|
|
+ {
|
|
|
+ var rawData = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
+ .LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
+ .Where((snapshot, order) => snapshot.SpecialReasonId != null)
|
|
|
+ .GroupBy((snapshot, order) => new
|
|
|
+ {
|
|
|
+ OrgCode = order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ SpecialReasonId = snapshot.SpecialReasonId,
|
|
|
+ snapshot.SpecialReasonName
|
|
|
+ })
|
|
|
+ .Select((snapshot, order) => new
|
|
|
+ {
|
|
|
+ OrgCode = order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ OrderCountNum = SqlFunc.AggregateCount(snapshot.Id),
|
|
|
+ SpecialReasonId = snapshot.SpecialReasonId,
|
|
|
+ SpecialReasonName = snapshot.SpecialReasonName
|
|
|
+ }, true)
|
|
|
+ .MergeTable()
|
|
|
+ .LeftJoin<SystemOrganize>((it, o) => it.OrgCode == o.Id)
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ OrgName = o.Name,
|
|
|
+ OrgCode = it.OrgCode,
|
|
|
+ OrderCountNum = it.OrderCountNum,
|
|
|
+ SpecialReasonId = it.SpecialReasonId,
|
|
|
+ SpecialReasonName = it.SpecialReasonName
|
|
|
+ }).ToList();
|
|
|
+
|
|
|
+ // 2. 处理 Pivot 逻辑
|
|
|
+ var pivotResult = new List<Dictionary<string, object>>();
|
|
|
+
|
|
|
+ // 先获取所有 OrgCode 和 OrgName
|
|
|
+ var orgGroups = rawData.GroupBy(x => new { x.OrgCode, x.OrgName });
|
|
|
+
|
|
|
+ // 先获取所有可能的 SpecialReasonId(动态列)
|
|
|
+ var specialReasons = rawData
|
|
|
+ .Select(x => x.SpecialReasonId)
|
|
|
+ .Distinct()
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ // 3. 遍历 OrgCode 进行聚合转换
|
|
|
+ foreach (var orgGroup in orgGroups)
|
|
|
+ {
|
|
|
+ var row = new Dictionary<string, object>
|
|
|
+ {
|
|
|
+ ["OrgName"] = orgGroup.Key.OrgName,
|
|
|
+ ["OrgCode"] = orgGroup.Key.OrgCode
|
|
|
+ };
|
|
|
+
|
|
|
+ // 初始化 SpecialReasonId 列
|
|
|
+ foreach (var reason in specialReasons)
|
|
|
+ {
|
|
|
+ row[reason] = 0; // 先默认 0
|
|
|
+ }
|
|
|
+
|
|
|
+ // 填充对应的 OrderCountNum
|
|
|
+ foreach (var item in orgGroup)
|
|
|
+ {
|
|
|
+ if (item.SpecialReasonId != null)
|
|
|
+ {
|
|
|
+ row[item.SpecialReasonId] = item.OrderCountNum;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ pivotResult.Add(row);
|
|
|
+ }
|
|
|
+
|
|
|
+ return pivotResult;
|
|
|
+ }
|
|
|
}
|