出入库功能模块
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using DOAN.Model.BZFM;
|
||||
using DOAN.Model.BZFM.Dto;
|
||||
using DOAN.Model.System;
|
||||
using DOAN.Model.System.Dto;
|
||||
|
||||
namespace DOAN.Service.BZFM.IBZFMService
|
||||
{
|
||||
@@ -26,7 +27,9 @@ namespace DOAN.Service.BZFM.IBZFMService
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
(string, object, object) Importmaterial(List<MmMaterial> material);
|
||||
ImportResultDto Importmaterial(List<MmMaterial> material);
|
||||
|
||||
public PagedInfo<MmMaterial> SelectMaterialList(MmMaterialQueryDto material, PagerInfo pager);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using DOAN.Common;
|
||||
using DOAN.Model.BZFM;
|
||||
using DOAN.Model.BZFM.Dto;
|
||||
using DOAN.Model.System;
|
||||
using DOAN.Model.System.Dto;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.BZFM.IBZFMService;
|
||||
using Infrastructure;
|
||||
@@ -118,14 +119,27 @@ namespace DOAN.Service.BZFM
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) Importmaterial(List<MmMaterialQueryDto> material)
|
||||
public ImportResultDto Importmaterial(List<MmMaterial> material)
|
||||
{
|
||||
// normalize and set defaults, do not overwrite provided values
|
||||
material.ForEach(x =>
|
||||
{
|
||||
x.CreatedTime = DateTime.Now;
|
||||
x.Status = "启用";
|
||||
x.MaterialCode = "";
|
||||
x.MaterialName = "E10ADC3949BA59ABBE56E057F20F883E";
|
||||
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.Remark = x.Remark.IsEmpty() ? "数据导入" : x.Remark;
|
||||
});
|
||||
var x = Context.Storageable(material)
|
||||
@@ -137,27 +151,45 @@ namespace DOAN.Service.BZFM
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand();//插入可插入部分;
|
||||
|
||||
string msg = string.Format(" 插入{0} 更新{1} 错误数据{2} 不计算数据{3} 删除数据{4} 总共{5}",
|
||||
x.InsertList.Count,
|
||||
x.UpdateList.Count,
|
||||
x.ErrorList.Count,
|
||||
x.IgnoreList.Count,
|
||||
x.DeleteList.Count,
|
||||
x.TotalList.Count);
|
||||
var importResult = new ImportResultDto
|
||||
{
|
||||
Message = "导入完成",
|
||||
Inserted = x.InsertList.Count,
|
||||
Updated = x.UpdateList.Count,
|
||||
ErrorCount = x.ErrorList.Count,
|
||||
IgnoredCount = x.IgnoreList.Count,
|
||||
Deleted = x.DeleteList.Count,
|
||||
Total = x.TotalList.Count
|
||||
};
|
||||
//输出统计
|
||||
Console.WriteLine(msg);
|
||||
Console.WriteLine(importResult);
|
||||
|
||||
//输出错误信息
|
||||
// 收集错误与忽略信息
|
||||
foreach (var item in x.ErrorList)
|
||||
{
|
||||
Console.WriteLine("MaterialCode为" + item.Item.MaterialCode + " : " + item.StorageMessage);
|
||||
importResult.Errors.Add(new ImportErrorDto { MaterialCode = item.Item.MaterialCode, Message = item.StorageMessage });
|
||||
}
|
||||
foreach (var item in x.IgnoreList)
|
||||
{
|
||||
Console.WriteLine("MaterialCode为" + item.Item.MaterialCode + " : " + item.StorageMessage);
|
||||
importResult.Ignored.Add(new ImportErrorDto { MaterialCode = item.Item.MaterialCode, Message = item.StorageMessage });
|
||||
}
|
||||
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
return importResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出物料表列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<MmMaterial> SelectMaterialList(MmMaterialQueryDto material, PagerInfo pager)
|
||||
{
|
||||
// Use the same predicate builder as GetList to support consistent filtering
|
||||
var predicate = QueryExp(material);
|
||||
|
||||
var query = Queryable()
|
||||
.Where(predicate.ToExpression());
|
||||
|
||||
return query.ToPage(pager);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user