This commit is contained in:
2022-11-19 16:17:44 +08:00
13 changed files with 1104 additions and 91 deletions
+34
View File
@@ -1,10 +1,13 @@
namespace BLL
{
using MiniExcelLibs;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
@@ -1161,6 +1164,37 @@ namespace BLL
dv.RowFilter = $"({filterRule})";
return dv.ToTable();
}
public static IEnumerable<dynamic> QueryWithoutEmptyRow(Stream stream, bool useHeaderRow, string sheetName, ExcelType excelType, string startCell, IConfiguration configuration)
{
var rows = stream.Query(useHeaderRow, sheetName, excelType, startCell, configuration);
foreach (IDictionary<string, object> row in rows)
{
if (row.Keys.Any(key => row[key] != null))
yield return row;
}
}
/// <summary>
/// 用于Linq的去重,扩展方法需要放到静态类中
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="TKey"></typeparam>
/// <param name="source"></param>
/// <param name="keySelector"></param>
/// <returns></returns>
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
{
if (seenKeys.Add(keySelector(element)))
{
yield return element;
}
}
}
}
}
@@ -78,6 +78,7 @@ namespace BLL
Material2Id = weldJoint.Material2Id,
Thickness = weldJoint.Thickness,
Dia = weldJoint.Dia,
DNDia=weldJoint.DNDia,
Size = weldJoint.Size,
DetectionTypeId = weldJoint.DetectionTypeId,
JointArea = weldJoint.JointArea,
@@ -107,6 +108,13 @@ namespace BLL
db.SubmitChanges();
}
public static void AddBulkWeldJoint(List<Model.HJGL_WeldJoint> weldJoints)
{
Model.SGGLDB db = Funs.DB;
db.HJGL_WeldJoint.InsertAllOnSubmit(weldJoints);
db.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
@@ -126,6 +134,7 @@ namespace BLL
newWeldJoint.Material2Id = weldJoint.Material2Id;
newWeldJoint.Thickness = weldJoint.Thickness;
newWeldJoint.Dia = weldJoint.Dia;
newWeldJoint.DNDia = weldJoint.DNDia;
newWeldJoint.Size = weldJoint.Size;
newWeldJoint.DetectionTypeId = weldJoint.DetectionTypeId;
newWeldJoint.JointArea = weldJoint.JointArea;