调整金蝶同步

This commit is contained in:
18942506660
2023-11-06 14:56:17 +08:00
parent 78db8b7f24
commit c4e4b1a59b
9 changed files with 158 additions and 12 deletions

View File

@@ -225,7 +225,7 @@ namespace WMS.Web.Repositories
if (!string.IsNullOrEmpty(dto.SourceBillNo))
query = query.Where(w => EF.Functions.Like(w.order.SourceBillNo, "%" + dto.SourceBillNo + "%"));
if (dto.Type != null)
query = query.Where(w => w.order.Type == (OrderType)dto.Type);
query = query.Where(w => w.order.Type == (OutStockType)dto.Type);
if (dto.Status != null)
query = query.Where(w => w.order.Status == (OutStockStatus)dto.Status);
if (dto.DeliveryOrgId != null)
@@ -273,5 +273,55 @@ namespace WMS.Web.Repositories
var mIds = entity.Details.Select(s => s.MaterialId).ToList();
return response;
}
/// <summary>
/// 根据来源单号搜索
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<List<OutStockTask>> GetListBySourceBillNo(List<string> sourceBillNos)
{
var entitys = await _context.OutStockTask
.Include(s => s.Details)
.Where(w => sourceBillNos.Contains(w.SourceBillNo))
.ToListAsync();
return entitys.Clone();
}
/// <summary>
/// 批量添加
/// </summary>
/// <param name="entitys"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<bool> AddRange(List<OutStockTask> entitys, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
if (entitys != null && entitys.Count != 0)
{
await _context.OutStockTask.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;
}
}
}
}