【修复】修复识别非顶层多行记录的bug
parent
dd582a37ee
commit
79d684dca4
|
|
@ -69,6 +69,26 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
|||
return new TitleRow(title, fields);
|
||||
}
|
||||
|
||||
private static bool IsMultiRowsExtendRow(List<Cell> row, Title title)
|
||||
{
|
||||
if (title.HasSubTitle)
|
||||
{
|
||||
foreach (var t in title.SubTitleList)
|
||||
{
|
||||
if (!t.SelfMultiRows && !IsMultiRowsExtendRow(row, t))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//return title.SubTitleList.All(t => t.SelfMultiRows || IsMultiRowsExtendRow(row, t));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IsBlankRow(row, title.FromIndex, title.ToIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<List<List<Cell>>> SplitRows(Title title, List<List<Cell>> rows)
|
||||
{
|
||||
List<List<Cell>> oneRecordRows = null;
|
||||
|
|
@ -84,7 +104,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
|||
}
|
||||
else
|
||||
{
|
||||
if (title.SubTitleList.All(t => t.SelfMultiRows || IsBlankRow(row, t.FromIndex, t.ToIndex)))
|
||||
if (IsMultiRowsExtendRow(row, title))
|
||||
{
|
||||
oneRecordRows.Add(row);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
|||
var fields = new Dictionary<string, FieldInfo>();
|
||||
foreach (var subTitle in title.SubTitleList)
|
||||
{
|
||||
if (subTitle.Name.StartsWith("__"))
|
||||
if (!DefUtil.IsNormalFieldName(subTitle.Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Bright.Collections;
|
||||
using Luban.Job.Common.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -71,9 +72,13 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
|||
if (SubTitleList.Count > 0)
|
||||
{
|
||||
if (Root)
|
||||
{
|
||||
var firstField = SubTitleList.FirstOrDefault(f => DefUtil.IsNormalFieldName(f.Name));
|
||||
if (firstField != null)
|
||||
{
|
||||
// 第一个字段一般为key,为了避免失误将空单元格当作key=0的数据,默认非空
|
||||
SubTitleList[0].Tags.TryAdd("non_empty", "1");
|
||||
firstField.Tags.TryAdd("non_empty", "1");
|
||||
}
|
||||
}
|
||||
foreach (var sub in SubTitleList)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,5 +81,10 @@ namespace Luban.Job.Common.Utils
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsNormalFieldName(string name)
|
||||
{
|
||||
return !name.StartsWith("__");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue