|
@@ -766,20 +766,20 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
{
|
|
|
var rawData = _orderSnapshotRepository.Queryable(includeDeleted: true)
|
|
|
.LeftJoin<Order>((snapshot, order) => order.Id == snapshot.Id)
|
|
|
- .Where((snapshot, order) => snapshot.SpecialReasonId != null)
|
|
|
+ .Where((snapshot, order) => snapshot.SpecialReasonId != null && snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime)
|
|
|
.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
|
|
|
- {
|
|
|
+ .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)
|
|
|
+ }, true)
|
|
|
.MergeTable()
|
|
|
.LeftJoin<SystemOrganize>((it, o) => it.OrgCode == o.Id)
|
|
|
.Select((it, o) => new
|
|
@@ -810,7 +810,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
|
|
|
foreach (var reason in specialReasons)
|
|
|
{
|
|
|
- row[reason] = 0;
|
|
|
+ row[reason] = 0;
|
|
|
}
|
|
|
|
|
|
foreach (var item in orgGroup)
|
|
@@ -837,7 +837,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
.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
|
|
|
+ .Select((snapshot, order, special, org) => new ReTransactStatisticsDetailsOutDto
|
|
|
{
|
|
|
ReTransactOrgName = special.OrgName, // 被重办部门
|
|
|
ReTransactOneOrgName = org.Name, // 被重办一级部门
|
|
@@ -853,17 +853,81 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
|
|
|
|
|
|
public List<Dictionary<string, object>> GetIndustryStatistics(IndustryStatisticsInDto dto)
|
|
|
{
|
|
|
- var query = _industryRepository.Queryable(includeDeleted: true)
|
|
|
- .LeftJoin<OrderSnapshot>((industry, snapshot) => snapshot.IndustryId == industry.Id && snapshot.CreationTime >= dto.StartTime && snapshot.CreationTime <= dto.EndTime)
|
|
|
- .LeftJoin<Order>((industry, snapshot, order) => order.Id == snapshot.Id)
|
|
|
- .Where((industry) => industry.IsEnable == true)
|
|
|
- .Select((industry, snapshot, order) => new
|
|
|
- {
|
|
|
- OrderCount = SqlFunc.AggregateSum(snapshot.Id),
|
|
|
- order.AllDuration,
|
|
|
+ var parentId = _appOptions.Value.AreaCode;
|
|
|
+ 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) => order.Id == snapshot.Id)
|
|
|
+ .Where((area, order, snapshot) => area.ParentId == parentId)
|
|
|
+ .GroupBy((area, order, snapshot) => new
|
|
|
+ {
|
|
|
+ //OrgCode = order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ IndustryId = snapshot.IndustryId,
|
|
|
+ snapshot.IndustryName,
|
|
|
+ area.AreaName
|
|
|
+ })
|
|
|
+ .Select((area, order, snapshot) => new
|
|
|
+ {
|
|
|
+ //OrgCode = order.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ OrgName = area.AreaName,
|
|
|
+ OrderCountNum = SqlFunc.AggregateCount(snapshot.Id),
|
|
|
+ AllDuration = SqlFunc.AggregateSum(order.AllDuration),
|
|
|
IsEmphasis = SqlFunc.AggregateSum(SqlFunc.IIF(snapshot.IsEmphasis == true, 1, 0)),
|
|
|
+ IndustryName = snapshot.IndustryName,
|
|
|
+ IndustryId = snapshot.IndustryId,
|
|
|
+ })
|
|
|
+ .LeftJoin<Industry>((it, o) => it.IndustryId == o.Id)
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ IndustryName = o.Name,
|
|
|
+ IndustryId = it.IndustryId,
|
|
|
+ OrderCountNum = it.OrderCountNum,
|
|
|
+ AllDuration = it.AllDuration,
|
|
|
+ OrgName = it.OrgName,
|
|
|
+ //OrgCode = it.OrgCode
|
|
|
});
|
|
|
- var outDto = new List<Dictionary<string, object>>();
|
|
|
- return outDto;
|
|
|
+#if DEBUG
|
|
|
+ var sql = query.ToSqlString();
|
|
|
+#endif
|
|
|
+ var rawData = query.ToList(); ;
|
|
|
+ var pivotResult = new List<Dictionary<string, object>>();
|
|
|
+
|
|
|
+ var industryGroups = rawData.GroupBy(x => new { x.IndustryId, x.IndustryName });
|
|
|
+
|
|
|
+ var orgNames = rawData
|
|
|
+ .Select(x => x.OrgName)
|
|
|
+ .Distinct()
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ foreach (var industryItem in industryGroups)
|
|
|
+ {
|
|
|
+ if (industryItem.Key.IndustryName == null) continue;
|
|
|
+ var row = new Dictionary<string, object>
|
|
|
+ {
|
|
|
+ ["IndustryName"] = industryItem.Key.IndustryName,
|
|
|
+ ["IndustryId"] = industryItem.Key.IndustryId,
|
|
|
+ ["AllDuration"] = 0,
|
|
|
+ };
|
|
|
+
|
|
|
+ foreach (var orgCode in orgNames)
|
|
|
+ {
|
|
|
+ if (orgCode != null)
|
|
|
+ {
|
|
|
+ row[orgCode] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach (var item in industryItem)
|
|
|
+ {
|
|
|
+ if (item.IndustryId != null)
|
|
|
+ {
|
|
|
+ row[item.OrgName] = item.OrderCountNum;
|
|
|
+ row["AllDuration"] = item.AllDuration;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ pivotResult.Add(row);
|
|
|
+ }
|
|
|
+ pivotResult.AddSumLine("IndustryName");
|
|
|
+ return pivotResult;
|
|
|
}
|
|
|
}
|