改箱调整

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;
}
}
}

View File

@@ -71,6 +71,34 @@ namespace WMS.Web.Repositories
}
}
/// <summary>
/// 批量添加
/// </summary>
/// <param name="entity"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<bool> AddRange(List<ChangeBoxRecord> list, bool isTransaction = true)
{
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _context.Database.BeginTransaction();
try
{
_context.ChangeBoxRecord.AddRange(list);
await _context.SaveChangesAsync();
if (_transaction != null)
_transaction.Commit();
return true;
}
catch (Exception ex)
{
if (_transaction != null)
_transaction.Rollback();
return false;
}
}
/// <summary>
/// 列表
/// </summary>
@@ -99,12 +127,12 @@ namespace WMS.Web.Repositories
query = query.Where(w => EF.Functions.Like(w.srcBox.BoxBillNo, "%" + dto.SrcBox + "%"));
if (!string.IsNullOrEmpty(dto.DestBox))
query = query.Where(w => EF.Functions.Like(w.destBox.BoxBillNo, "%" + dto.DestBox + "%"));
if (dto.StockId != null)
query = query.Where(w => w.changeBox.StockId == dto.StockId);
if (dto.SrcSubStockId != null)
query = query.Where(w => w.changeBox.SrcSubStockId == dto.SrcSubStockId);
if (dto.DestSubStockId != null)
query = query.Where(w => w.changeBox.DestSubStockId == dto.DestSubStockId);
//if (dto.StockId != null)
// query = query.Where(w => w.changeBox.StockId == dto.StockId);
//if (dto.SrcSubStockId != null)
// query = query.Where(w => w.changeBox.SrcSubStockId == dto.SrcSubStockId);
//if (dto.DestSubStockId != null)
// query = query.Where(w => w.changeBox.DestSubStockId == dto.DestSubStockId);
if (dto.CreateBeginDate != null)
query = query.Where(w => w.changeBox.CreateTime >= dto.CreateBeginDate);
if (dto.CreateEndDate != null)
@@ -117,12 +145,12 @@ namespace WMS.Web.Repositories
MaterialName = "",
MaterialNumber = "",
Specifications = "",
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.changeBox.StockId),
//Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.changeBox.StockId),
SerialNumbers = JsonConvert.SerializeObject(s.changeBox.SerialNumbers),
SrcBox = s.srcBox.BoxBillNo,
DestBox = s.destBox.BoxBillNo,
SrcSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.SrcSubStockId),
DestSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.DestSubStockId),
//SrcSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.SrcSubStockId),
//DestSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.DestSubStockId),
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.changeBox.CreatorId),
CreateTime = s.changeBox.CreateTime.DateToStringSeconds()
#endregion