优化
This commit is contained in:
@@ -11,6 +11,7 @@ using WMS.Web.Core.Help;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Mappers;
|
||||
using WMS.Web.Repositories.Configuration;
|
||||
|
||||
namespace WMS.Web.Repositories
|
||||
@@ -118,5 +119,46 @@ namespace WMS.Web.Repositories
|
||||
var numbers = await _context.Materials.Select(x => x.MaterialNumber).ToListAsync();
|
||||
return numbers.Clone().Distinct().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部的物料编码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Materials>> GetEntityList(List<string> materNumbers, bool isBatchManage)
|
||||
{
|
||||
var entitys = await _context.Materials.Where(x => materNumbers.Contains(x.MaterialNumber) && x.IsBatchManage == isBatchManage).ToListAsync();
|
||||
return entitys;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改物料
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateRange(List<Materials> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
{
|
||||
try
|
||||
{
|
||||
List<int> list = entitys.Select(s => s.Id).ToList();
|
||||
var res = await _context.Materials.AsNoTracking().Where(f => list.Contains(f.Id)).ToListAsync();
|
||||
_mapper.ToMapList(entitys, res);
|
||||
await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user