收货接口

This commit is contained in:
tongfei
2023-11-06 12:34:39 +08:00
parent 79484c24ee
commit 784c5cf27e
10 changed files with 38 additions and 43 deletions

View File

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using WMS.Web.Core;
using WMS.Web.Core.Dto;
using WMS.Web.Core.Dto.InStockTask;
using WMS.Web.Core.Help;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Entitys;
using WMS.Web.Domain.Infrastructure;
@@ -125,9 +126,12 @@ namespace WMS.Web.Repositories
/// <returns></returns>
public async Task<InStockTask> Get(int id)
{
return await _context.InStockTask
var entity =await _context.InStockTask
.Include(x=>x.Boxs)
.Include(s => s.Details)
.FirstOrDefaultAsync(f => f.Id == id);
return entity.Clone();
}
/// <summary>
@@ -137,11 +141,13 @@ namespace WMS.Web.Repositories
/// <returns></returns>
public async Task<InStockTask> GetBy(string boxBillNo)
{
return await _context.InStockTask
var entity= await _context.InStockTask
.Include(s => s.Boxs.Where(b => b.BoxBillNo == boxBillNo))
.Include(s => s.Details)
.Where(w => w.Boxs.Where(b => b.BoxBillNo == boxBillNo).Count() > 0).FirstOrDefaultAsync();
return entity.Clone();
}
/// <summary>
@@ -152,10 +158,10 @@ namespace WMS.Web.Repositories
public async Task<bool> IsExist(string boxBillNo)
{
return await _context.InStockTask
.AsNoTracking()
.Include(s => s.Boxs.Where(b => b.BoxBillNo == boxBillNo))
.Include(s => s.Details)
.Where(w =>(w.Status== InstockStatus.Part || w.Status== InstockStatus.Wait) && w.Boxs.Where(b => b.BoxBillNo == boxBillNo).Count() > 0).AnyAsync();
.Where(w => (w.Status == InstockStatus.Part || w.Status == InstockStatus.Wait) && w.Boxs.Where(b => b.BoxBillNo == boxBillNo).Count() > 0).AnyAsync();
}
/// <summary>
@@ -165,10 +171,11 @@ namespace WMS.Web.Repositories
/// <returns></returns>
public async Task<List<InStockTask>> GetList(List<int> ids)
{
return await _context.InStockTask
var entitys= await _context.InStockTask
.Include(s => s.Details)
.Where(f => ids.Contains(f.Id))
.ToListAsync();
return entitys.Clone();
}
/// <summary>
@@ -178,10 +185,12 @@ namespace WMS.Web.Repositories
/// <returns></returns>
public async Task<List<InStockTask>> GetListBy(List<string> sourceBillNos)
{
return await _context.InStockTask
var entitys= await _context.InStockTask
.Include(s => s.Details)
.Where(w => sourceBillNos.Contains(w.SourceBillNo))
.ToListAsync();
return entitys.Clone();
}
/// <summary>
@@ -301,8 +310,8 @@ namespace WMS.Web.Repositories
try
{
List<int> list = entitys.Select(s => s.Id).ToList();
var res = await _context.InStockTask.Include(x => x.Details).Where(f => list.Contains(f.Id)).ToListAsync();
_mapper.Map(entitys, res);
var res = await _context.InStockTask.Include(x=>x.Boxs).Include(x => x.Details).Where(f => list.Contains(f.Id)).ToListAsync();
_mapper.ToMapList(entitys, res);
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
@@ -330,18 +339,20 @@ namespace WMS.Web.Repositories
try
{
var model = await _context.InStockTask
.AsNoTracking()
.Include(s=>s.Boxs)
.Include(s => s.Details)
.FirstOrDefaultAsync(f => f.Id == entity.Id);
if (model == null)
return null;
_mapper.Map(entity, model);
await _context.SaveChangesAsync();
_mapper.ToMapList(entity.Boxs, model.Boxs);
_mapper.ToMapList(entity.Details, model.Details);
var result= await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
return model;
}
catch (Exception)
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();