改箱调整

This commit is contained in:
18942506660
2023-10-31 16:06:51 +08:00
parent 4e45383532
commit c1c3ec2928
12 changed files with 205 additions and 64 deletions

View File

@@ -1,14 +1,17 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto;
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
@@ -35,10 +38,12 @@ namespace WMS.Web.Repositories
_loginRepositories = loginRepositories;
_basicsRepositories = basicsRepositories;
}
public async Task<Box> Get(string BoxBillNo)
public async Task<Box> Get(int id)
{
return await _context.Box.Include(x => x.Details)
.FirstOrDefaultAsync(f => f.BoxBillNo.Equals(BoxBillNo));
var entity= await _context.Box.Include(x => x.Details)
.FirstOrDefaultAsync(f => f.Id.Equals(id));
return entity.Clone();
}
/// <summary>
/// 根据箱号查询物料信息
@@ -71,5 +76,41 @@ namespace WMS.Web.Repositories
.ToListAsync();
return result;
}
/// <summary>
/// 批量修改
/// </summary>
/// <param name="entitys"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<bool> EditEntityList(List<Box> 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.Box
.Include(s => s.Details)
.Where(f => list.Contains(f.Id)).ToListAsync();
_mapper.ToMapList(entitys, res);
_mapper.ToMapList(entitys.SelectMany(s => s.Details).ToList(), res.SelectMany(s => s.Details).ToList());
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
return true;
}
}
}