导入导出
This commit is contained in:
@@ -138,33 +138,33 @@ namespace DOAN.Service.BZFM
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
public ImportResultDto Importmaterial(List<MmMaterialExcelDto2> material)
|
||||
public ImportResultDto Importmaterial(List<MmMaterialExcelDto> material)
|
||||
{
|
||||
// normalize and set defaults, do not overwrite provided values
|
||||
//material.ForEach(x =>
|
||||
//{
|
||||
// if (x.CreatedTime == null)
|
||||
// {
|
||||
// x.CreatedTime = DateTime.Now;
|
||||
// }
|
||||
// if (string.IsNullOrWhiteSpace(x.Status))
|
||||
// {
|
||||
// x.Status = "启用";
|
||||
// }
|
||||
// if (!string.IsNullOrWhiteSpace(x.MaterialCode))
|
||||
// {
|
||||
// x.MaterialCode = x.MaterialCode.Trim();
|
||||
// }
|
||||
// if (!string.IsNullOrWhiteSpace(x.MaterialName))
|
||||
// {
|
||||
// x.MaterialName = x.MaterialName.Trim();
|
||||
// }
|
||||
// x.Description = x.Description.IsEmpty() ? "数据导入" : x.Description;
|
||||
//});
|
||||
material.ForEach(x =>
|
||||
{
|
||||
if (x.CreatedTime == null)
|
||||
{
|
||||
x.CreatedTime = DateTime.Now;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(x.Status))
|
||||
{
|
||||
x.Status = "启用";
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(x.MaterialCode))
|
||||
{
|
||||
x.MaterialCode = x.MaterialCode.Trim();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(x.MaterialName))
|
||||
{
|
||||
x.MaterialName = x.MaterialName.Trim();
|
||||
}
|
||||
x.Description = x.Description.IsEmpty() ? "数据导入" : x.Description;
|
||||
});
|
||||
var x = Context
|
||||
.Storageable(material)
|
||||
.SplitInsert(it => !it.Any())
|
||||
.WhereColumns(it => new { it.Id, it.物料编码 }) //如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.WhereColumns(it => new { it.Id, it.MaterialCode }) //如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand(); //插入可插入部分;
|
||||
|
||||
@@ -182,26 +182,26 @@ namespace DOAN.Service.BZFM
|
||||
Console.WriteLine(importResult);
|
||||
|
||||
// 收集错误与忽略信息
|
||||
//foreach (var item in x.ErrorList)
|
||||
//{
|
||||
// importResult.Errors.Add(
|
||||
// new ImportErrorDto
|
||||
// {
|
||||
// MaterialCode = item.Item.MaterialCode,
|
||||
// Message = item.StorageMessage,
|
||||
// }
|
||||
// );
|
||||
//}
|
||||
//foreach (var item in x.IgnoreList)
|
||||
//{
|
||||
// importResult.Ignored.Add(
|
||||
// new ImportErrorDto
|
||||
// {
|
||||
// MaterialCode = item.Item.MaterialCode,
|
||||
// Message = item.StorageMessage,
|
||||
// }
|
||||
// );
|
||||
//}
|
||||
foreach (var item in x.ErrorList)
|
||||
{
|
||||
importResult.Errors.Add(
|
||||
new ImportErrorDto
|
||||
{
|
||||
MaterialCode = item.Item.MaterialCode,
|
||||
Message = item.StorageMessage,
|
||||
}
|
||||
);
|
||||
}
|
||||
foreach (var item in x.IgnoreList)
|
||||
{
|
||||
importResult.Ignored.Add(
|
||||
new ImportErrorDto
|
||||
{
|
||||
MaterialCode = item.Item.MaterialCode,
|
||||
Message = item.StorageMessage,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return importResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user