盘盈盘亏同步
This commit is contained in:
@@ -70,6 +70,86 @@ namespace WMS.Web.Repositories
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddRange(List<TakeStock> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (entitys != null && entitys.Count != 0)
|
||||
{
|
||||
await _context.TakeStock.AddRangeAsync(entitys);
|
||||
await _context.SaveChangesAsync();
|
||||
foreach (var item in entitys)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.BillNo))
|
||||
//自动生成单据编号
|
||||
item.GenerateNo();
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<TakeStock> Edit(TakeStock entity, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _context.TakeStock
|
||||
.FirstOrDefaultAsync(f => f.Id == entity.Id);
|
||||
if (res == null) return null;
|
||||
|
||||
_mapper.Map(entity, res);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
|
||||
return res;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<TakeStock>> GetEntityList(List<int> ids)
|
||||
{
|
||||
var res = await _context.TakeStock
|
||||
.Where(f => ids.Contains(f.Id))
|
||||
.ToListAsync();
|
||||
|
||||
return res.Clone();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 盘点单列表
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user