parent
575d0b2533
commit
3612d4e2d8
|
|
@ -7,6 +7,7 @@ using Luban.Job.Cfg.l10n;
|
|||
using Luban.Job.Cfg.RawDefs;
|
||||
using Luban.Job.Cfg.TypeVisitors;
|
||||
using Luban.Job.Common.Defs;
|
||||
using Luban.Job.Common.Types;
|
||||
using Luban.Server.Common;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
|
@ -140,6 +141,29 @@ namespace Luban.Job.Cfg.Defs
|
|||
}
|
||||
}
|
||||
|
||||
public static List<Record> ToSortByKeyDataList(DefTable table, List<Record> originRecords)
|
||||
{
|
||||
var sortedRecords = new List<Record>(originRecords);
|
||||
|
||||
DefField keyField = table.IndexField;
|
||||
if (keyField != null && (keyField.CType is TInt || keyField.CType is TLong))
|
||||
{
|
||||
string keyFieldName = keyField.Name;
|
||||
sortedRecords.Sort((a, b) =>
|
||||
{
|
||||
DType keya = a.Data.GetField(keyFieldName);
|
||||
DType keyb = b.Data.GetField(keyFieldName);
|
||||
switch (keya)
|
||||
{
|
||||
case DInt ai: return ai.Value.CompareTo((keyb as DInt).Value);
|
||||
case DLong al: return al.Value.CompareTo((keyb as DLong).Value);
|
||||
default: throw new NotSupportedException();
|
||||
}
|
||||
});
|
||||
}
|
||||
return sortedRecords;
|
||||
}
|
||||
|
||||
public TableDataInfo GetTableDataInfo(DefTable table)
|
||||
{
|
||||
return _recordsByTables[table.FullName];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using ClosedXML.Excel;
|
||||
using Luban.Job.Cfg.Cache;
|
||||
using Luban.Job.Cfg.DataConverts;
|
||||
using Luban.Job.Cfg.Defs;
|
||||
using Luban.Job.Cfg.Utils;
|
||||
using Luban.Job.Common.Types;
|
||||
using Luban.Job.Common.TypeVisitors;
|
||||
|
|
@ -25,7 +26,8 @@ namespace Luban.Job.Cfg.Generate
|
|||
{
|
||||
ctx.Tasks.Add(Task.Run(() =>
|
||||
{
|
||||
var records = ctx.Assembly.GetTableAllDataList(table);
|
||||
var records = DefAssembly.ToSortByKeyDataList(table, ctx.Assembly.GetTableAllDataList(table));
|
||||
|
||||
string dirName = table.FullName;
|
||||
var fileName = table.FullName;
|
||||
var filePath = $"{dirName}/{fileName}.xlsx";
|
||||
|
|
|
|||
|
|
@ -195,24 +195,7 @@ namespace LubanAssistant
|
|||
|
||||
//int nextRowIndex = titleRowNum + 2;
|
||||
|
||||
// 对于 int和long类型记录,按值排序
|
||||
var records = tableDataInfo.MainRecords;
|
||||
DefField keyField = tableDataInfo.Table.IndexField;
|
||||
if (keyField != null && (keyField.CType is TInt || keyField.CType is TLong))
|
||||
{
|
||||
string keyFieldName = keyField.Name;
|
||||
records.Sort((a, b) =>
|
||||
{
|
||||
DType keya = a.Data.GetField(keyFieldName);
|
||||
DType keyb = b.Data.GetField(keyFieldName);
|
||||
switch (keya)
|
||||
{
|
||||
case DInt ai: return ai.Value.CompareTo((keyb as DInt).Value);
|
||||
case DLong al: return al.Value.CompareTo((keyb as DLong).Value);
|
||||
default: throw new NotSupportedException();
|
||||
}
|
||||
});
|
||||
}
|
||||
var records = DefAssembly.ToSortByKeyDataList(tableDataInfo.Table, tableDataInfo.MainRecords);
|
||||
|
||||
int totalRowCount = 0;
|
||||
var dataRangeArray = new List<object[]>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue