改箱调整
This commit is contained in:
@@ -275,9 +275,9 @@
|
||||
单据头ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.BoxResponse.BoxId">
|
||||
<member name="P:WMS.Web.Core.Dto.BoxResponse.BoxBillNo">
|
||||
<summary>
|
||||
箱Id
|
||||
箱号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:WMS.Web.Core.Dto.BoxResponse.Details">
|
||||
@@ -395,11 +395,6 @@
|
||||
保存改箱
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordRequest.MaterialId">
|
||||
<summary>
|
||||
物料ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordRequest.SrcBoxId">
|
||||
<summary>
|
||||
原箱子ID
|
||||
@@ -410,11 +405,26 @@
|
||||
目标箱子ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordRequest.Qty">
|
||||
<member name="T:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordDetailsRequest">
|
||||
<summary>
|
||||
明细
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordDetailsRequest.MaterialId">
|
||||
<summary>
|
||||
物料ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordDetailsRequest.Qty">
|
||||
<summary>
|
||||
数量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordDetailsRequest.SerialNumbers">
|
||||
<summary>
|
||||
序列号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.EnumStatusResponse">
|
||||
<summary>
|
||||
所有枚举信息
|
||||
|
||||
@@ -220,11 +220,6 @@
|
||||
物料ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.StockId">
|
||||
<summary>
|
||||
仓库Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.SerialNumbers">
|
||||
<summary>
|
||||
序列号
|
||||
@@ -245,16 +240,6 @@
|
||||
目标箱子ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.SrcSubStockId">
|
||||
<summary>
|
||||
原仓位ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.DestSubStockId">
|
||||
<summary>
|
||||
目标仓位ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.CreatorId">
|
||||
<summary>
|
||||
操作人
|
||||
@@ -265,11 +250,14 @@
|
||||
操作时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.ChangeBoxRecord.Create(System.Int32)">
|
||||
<member name="M:WMS.Web.Domain.Entitys.ChangeBoxRecord.Create(System.Int32,System.Decimal,System.Int32,System.Collections.Generic.List{System.String},System.Int32,System.Int32)">
|
||||
<summary>
|
||||
创建
|
||||
</summary>
|
||||
<param name="creatorId"></param>
|
||||
<param name="qty"></param>
|
||||
<param name="materialId"></param>
|
||||
<param name="serialNumbers"></param>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InStock">
|
||||
<summary>
|
||||
|
||||
@@ -38,5 +38,9 @@ namespace WMS.Web.Core.Dto.ChangeBoxRecord
|
||||
///</summary>
|
||||
[Required(ErrorMessage = "数量不能为空")]
|
||||
public decimal Qty { get; set; }
|
||||
/// <summary>
|
||||
/// 序列号
|
||||
/// </summary>
|
||||
public List<string> SerialNumbers { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using WMS.Web.Core;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
@@ -11,12 +15,12 @@ namespace WMS.Web.Domain.Entitys
|
||||
|
||||
[Serializable]
|
||||
[Table("t_ops_box")]
|
||||
public class Box
|
||||
public class Box : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
public override int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对应老OPS的箱ID
|
||||
@@ -37,5 +41,41 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 明细
|
||||
/// </summary>
|
||||
public List<BoxDetails> Details = new List<BoxDetails>();
|
||||
|
||||
//移出
|
||||
public Result Out(List<(int MaterialId, decimal Qty, List<string> SerialNumbers)> list)
|
||||
{
|
||||
foreach(var l in list)
|
||||
{
|
||||
var d = this.Details.FirstOrDefault(f => f.MaterialId == l.MaterialId);
|
||||
if (d == null) return Result.ReFailure(ResultCodes.BoxMateriaNoData);
|
||||
d.Qty = d.Qty - l.Qty;
|
||||
if (d.Qty <= 0) this.Details.Remove(d);
|
||||
foreach (var s in l.SerialNumbers) d.SerialNumbers.Remove(s);
|
||||
}
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
//移入
|
||||
public Result In(List<(int MaterialId, decimal Qty, List<string> SerialNumbers)> list)
|
||||
{
|
||||
foreach (var l in list)
|
||||
{
|
||||
var d = this.Details.FirstOrDefault(f => f.MaterialId == l.MaterialId);
|
||||
if (d == null)
|
||||
{
|
||||
this.Details.Add(new BoxDetails()
|
||||
{
|
||||
MaterialId = l.MaterialId,
|
||||
Qty=l.Qty,
|
||||
SerialNumbers=l.SerialNumbers
|
||||
});
|
||||
continue;
|
||||
}
|
||||
d.Qty = d.Qty + l.Qty;
|
||||
d.SerialNumbers.AddRange(l.SerialNumbers);
|
||||
}
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using WMS.Web.Core;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
@@ -11,12 +12,12 @@ namespace WMS.Web.Domain.Entitys
|
||||
|
||||
[Serializable]
|
||||
[Table("t_ops_box_details")]
|
||||
public class BoxDetails
|
||||
public class BoxDetails : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
public override int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据头ID
|
||||
|
||||
@@ -25,11 +25,6 @@ namespace WMS.Web.Domain.Entitys
|
||||
[Column("MaterialId")]
|
||||
public int MaterialId { get; set; }
|
||||
/// <summary>
|
||||
/// 仓库Id
|
||||
/// </summary>
|
||||
[Column("StockId")]
|
||||
public int StockId { get; set; }
|
||||
/// <summary>
|
||||
/// 序列号
|
||||
/// </summary>
|
||||
[Column("SerialNumbers")]
|
||||
@@ -50,16 +45,6 @@ namespace WMS.Web.Domain.Entitys
|
||||
[Column("DestBoxId")]
|
||||
public int DestBoxId { get; set; }
|
||||
/// <summary>
|
||||
/// 原仓位ID
|
||||
/// </summary>
|
||||
[Column("SrcSubStockId")]
|
||||
public int SrcSubStockId { get; set; }
|
||||
/// <summary>
|
||||
/// 目标仓位ID
|
||||
/// </summary>
|
||||
[Column("DestSubStockId")]
|
||||
public int DestSubStockId { get; set; }
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
[Column("CreatorId")]
|
||||
@@ -73,8 +58,16 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(int creatorId)
|
||||
/// <param name="qty"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <param name="serialNumbers"></param>
|
||||
public void Create(int creatorId,decimal qty,int materialId, List<string> serialNumbers,int srcBoxId,int destBoxId)
|
||||
{
|
||||
this.SrcBoxId = srcBoxId;
|
||||
this.DestBoxId = destBoxId;
|
||||
this.SerialNumbers = serialNumbers;
|
||||
this.MaterialId = materialId;
|
||||
this.Qty = qty;
|
||||
this.CreatorId = creatorId;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// </summary>
|
||||
public interface IBoxRepositories
|
||||
{
|
||||
Task<Box> Get(string BoxBillNo);
|
||||
Task<Box> Get(int id);
|
||||
//根据箱号查询明细信息
|
||||
Task<BoxResponse> GetBox(string BoxBillNo);
|
||||
//批量修改
|
||||
Task<bool> EditEntityList(List<Box> entitys, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
{
|
||||
// 新增
|
||||
Task<ChangeBoxRecord> Add(ChangeBoxRecord entity, bool isTransaction = true);
|
||||
// 批量新增
|
||||
Task<bool> AddRange(List<ChangeBoxRecord> list, bool isTransaction = true);
|
||||
|
||||
// 获取列表
|
||||
Task<(List<ChangeBoxRecordQueryInfoResponse> list,int total)> GetListAsync(ChangeBoxRecordQueryRequest dto);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
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.ChangeBoxRecord;
|
||||
@@ -24,15 +25,17 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly IChangeBoxRecordRepositories _changeBoxRecordRepositories;
|
||||
public readonly ITransactionRepositories _transactionRepositories;
|
||||
private readonly IMoveBoxRecordRepositories _moveBoxRecordRepositories;
|
||||
public ChangeMoveBoxService(IMapper mapper, ILoginService loginService,
|
||||
private readonly IBoxRepositories _boxRepositories;
|
||||
public ChangeMoveBoxService(IMapper mapper, ILoginService loginService,
|
||||
IChangeBoxRecordRepositories changeBoxRecordRepositories, ITransactionRepositories transactionRepositories,
|
||||
IMoveBoxRecordRepositories moveBoxRecordRepositories)
|
||||
IMoveBoxRecordRepositories moveBoxRecordRepositories, IBoxRepositories boxRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_loginService = loginService;
|
||||
_changeBoxRecordRepositories = changeBoxRecordRepositories;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_moveBoxRecordRepositories = moveBoxRecordRepositories;
|
||||
_boxRepositories = boxRepositories;
|
||||
}
|
||||
/// <summary>
|
||||
/// 改箱保存
|
||||
@@ -40,10 +43,32 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
|
||||
public async Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
var entity = _mapper.Map<ChangeBoxRecord>(dto);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
List<Box> boxList = new List<Box>();
|
||||
var srcBox = await _boxRepositories.Get(dto.SrcBoxId);
|
||||
var destBox = await _boxRepositories.Get(dto.DestBoxId);
|
||||
if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
|
||||
if (destBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
|
||||
var l = dto.Details.Select(s => (s.MaterialId, s.Qty, s.SerialNumbers)).ToList();
|
||||
//原箱移出
|
||||
var res = srcBox.Out(l);
|
||||
if (!res.IsSuccess) return res;
|
||||
//目标箱移入
|
||||
res = destBox.In(l);
|
||||
if (!res.IsSuccess) return res;
|
||||
|
||||
boxList.Add(srcBox);
|
||||
boxList.Add(destBox);
|
||||
|
||||
//var entity = _mapper.Map<ChangeBoxRecord>(dto);\
|
||||
List<ChangeBoxRecord> list = new List<ChangeBoxRecord>();
|
||||
foreach (var d in dto.Details)
|
||||
{
|
||||
ChangeBoxRecord entity = new ChangeBoxRecord();
|
||||
entity.Create(loginInfo.UserInfo.StaffId, d.Qty, d.MaterialId, d.SerialNumbers, dto.SrcBoxId, dto.DestBoxId);
|
||||
list.Add(entity);
|
||||
}
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
@@ -51,8 +76,12 @@ namespace WMS.Web.Domain.Services
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isSuccess = true;
|
||||
entity = await _changeBoxRecordRepositories.Add(entity, true);
|
||||
if (entity == null) isRollback = true;
|
||||
isSuccess = await _changeBoxRecordRepositories.AddRange(list, false);
|
||||
if (!isSuccess) isRollback = true;
|
||||
|
||||
isSuccess = await _boxRepositories.EditEntityList(boxList, false);
|
||||
if (!isSuccess) isRollback = true;
|
||||
|
||||
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||
|
||||
@@ -24,5 +24,8 @@ namespace WMS.Web.Domain.Values
|
||||
|
||||
//出库任务单
|
||||
public static ValueTuple<int, string> MergeStatusError = (70000, "所选单据数据不一致,不能合并");
|
||||
|
||||
public static ValueTuple<int, string> BoxNoData = (80000, "箱信息不存在");
|
||||
public static ValueTuple<int, string> BoxMateriaNoData = (800010, "箱对应物料信息不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user