|
@@ -790,19 +790,15 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
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>
|
|
@@ -811,13 +807,11 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
["OrgCode"] = orgGroup.Key.OrgCode
|
|
|
};
|
|
|
|
|
|
- // 初始化 SpecialReasonId 列
|
|
|
foreach (var reason in specialReasons)
|
|
|
{
|
|
|
- row[reason] = 0; // 先默认 0
|
|
|
+ row[reason] = 0;
|
|
|
}
|
|
|
|
|
|
- // 填充对应的 OrderCountNum
|
|
|
foreach (var item in orgGroup)
|
|
|
{
|
|
|
if (item.SpecialReasonId != null)
|
|
@@ -828,7 +822,30 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
|
|
|
pivotResult.Add(row);
|
|
|
}
|
|
|
-
|
|
|
+ pivotResult.AddSumLine("OrgName");
|
|
|
return pivotResult;
|
|
|
}
|
|
|
+
|
|
|
+ public ISugarQueryable<ReTransactStatisticsDetailsOutDto> GetReTransactStatisticsDetail(ReTransactStatisticsDetailsInDto dto)
|
|
|
+ {
|
|
|
+ var query = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
+ .LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
+ .LeftJoin<OrderSpecial>((snapshot, order, special) => special.OrderId == order.Id)
|
|
|
+ .LeftJoin<SystemOrganize>((snapshot, order, special, org) => org.Id == special.OrgId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")))
|
|
|
+ .Where((snapshot, order, special) => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime && order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == dto.OrgCode && special.Id != null && snapshot.SpecialReasonId != null && special.SpecialType == ESpecialType.ReTransact)
|
|
|
+ .WhereIF(dto.FieldName.NotNullOrEmpty(), (snapshot, order) => dto.FieldName == snapshot.SpecialReasonId)
|
|
|
+ .OrderByDescending((snapshot, order) => order.CreationTime)
|
|
|
+ .Select((snapshot, order, special, org) => new ReTransactStatisticsDetailsOutDto
|
|
|
+ {
|
|
|
+ ReTransactOrgName = special.OrgName, // 被重办部门
|
|
|
+ ReTransactOneOrgName = org.Name, // 被重办一级部门
|
|
|
+ ReTransactTime = special.CreationTime, // 重办时间
|
|
|
+ ReTransactHandlerName = special.CreatorName, // 重办操作人
|
|
|
+ ReTransactContent = special.Opinion // 重办理由
|
|
|
+ }, true);
|
|
|
+#if DEBUG
|
|
|
+ var sql = query.ToSqlString();
|
|
|
+#endif
|
|
|
+ return query;
|
|
|
+ }
|
|
|
}
|