调整接口
This commit is contained in:
@@ -41,12 +41,12 @@ namespace WMS.Web.Domain.Entitys
|
||||
[Column("StockCode")]
|
||||
public string StockCode { get; set; }
|
||||
/// <summary>
|
||||
/// 原仓位编码
|
||||
/// 原仓位Id
|
||||
/// </summary>
|
||||
[Column("SrcSubStockId")]
|
||||
public int SrcSubStockId { get; set; }
|
||||
/// <summary>
|
||||
/// 目标仓位编码
|
||||
/// 目标仓位Id
|
||||
/// </summary>
|
||||
[Column("DestSubStockId")]
|
||||
public int DestSubStockId { get; set; }
|
||||
@@ -75,10 +75,11 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(MoveBoxType type, int boxId, string stockCode, int subStockId, int creatorId)
|
||||
public void Create(MoveBoxType type, int boxId,string orgCode, string stockCode, int subStockId, int creatorId)
|
||||
{
|
||||
this.BoxId = boxId;
|
||||
this.Type = type;
|
||||
this.OrgCode = orgCode;
|
||||
this.StockCode = stockCode;
|
||||
SrcSubStockId = type == MoveBoxType.Up ? 0 : subStockId;//上架 原仓位是0 目标仓位有值
|
||||
DestSubStockId = type == MoveBoxType.Up ? subStockId : 0; //下架 原仓位有值 目标仓位是0
|
||||
|
||||
@@ -19,9 +19,7 @@ namespace WMS.Web.Domain.Mappers
|
||||
|
||||
CreateMap<SaveChangeBoxRecordRequest, BoxInventoryChangeGenerateDto>()
|
||||
.ForMember(x => x.BoxId, ops => ops.MapFrom(x => x.SrcBoxId))
|
||||
.ForMember(x => x.TargetBoxId, ops => ops.MapFrom(x => x.DestBoxId))
|
||||
.ForMember(x => x.BoxOrgCode, ops => ops.MapFrom(x => x.SrcBoxOrgCode))
|
||||
.ForMember(x => x.TargetBoxOrgCode, ops => ops.MapFrom(x => x.DestBoxOrgCode));
|
||||
.ForMember(x => x.TargetBoxId, ops => ops.MapFrom(x => x.DestBoxId));
|
||||
CreateMap<SaveChangeBoxRecordDetailsRequest, BoxInventoryDetailsChangeGenerateDto>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,31 +75,29 @@ namespace WMS.Web.Domain.Services
|
||||
if (destBox != null)
|
||||
boxList.Add(destBox);
|
||||
|
||||
//2.修改库存时需要区别 有原箱和没有原箱的情况
|
||||
var subStock= await _basbicsRepositories.GetSubUcStockAsync(dto.SubStockId, loginInfo.UserInfo.CompanyId);
|
||||
//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);
|
||||
entity.DestSubStockId = dto.SubStockId;
|
||||
entity.DestBoxOrgCode = subStock.ErpOrgCode;
|
||||
entity.DestStockCode = subStock.StockCode;
|
||||
list.Add(entity);
|
||||
entity.SrcSubStockId = 0;//原乡仓位需要去拉一下库存获取
|
||||
if (subStock != null)
|
||||
{
|
||||
entity.DestSubStockId = dto.SubStockId;
|
||||
entity.DestBoxOrgCode = subStock.ErpOrgCode;
|
||||
entity.DestStockCode = subStock.StockCode;
|
||||
}
|
||||
list.Add(entity);
|
||||
}
|
||||
var inventoryList = new List<BoxInventoryChangeGenerateDto>();
|
||||
inventoryList.Add(_mapper.Map<BoxInventoryChangeGenerateDto>(dto));
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _basbicsRepositories.GetTransaction();
|
||||
Result res_Rollback = Result.ReSuccess();
|
||||
bool isSuccess = true;
|
||||
var res_Inventory = await _boxInventoryService.GenerateChangeBox(inventoryList, false);
|
||||
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
||||
|
||||
if (res_Rollback.IsSuccess)
|
||||
{
|
||||
isSuccess = await _changeBoxRecordRepositories.AddRange(list, false);
|
||||
@@ -115,6 +113,11 @@ namespace WMS.Web.Domain.Services
|
||||
isSuccess = await _boxRepositories.EditEntityList(boxList, false);
|
||||
if (!isSuccess) res_Rollback= Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
if(res_Rollback.IsSuccess)
|
||||
{
|
||||
var res_Inventory = await _boxInventoryService.GenerateChangeBox(list, false);
|
||||
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
||||
}
|
||||
//提交事务
|
||||
if (isTransaction)
|
||||
{
|
||||
@@ -134,12 +137,12 @@ namespace WMS.Web.Domain.Services
|
||||
public async Task<Result> MoveBoxSave(List<SaveMoveBoxRecordRequest> dto, bool IsUp, LoginInDto loginInfo)
|
||||
{
|
||||
//1.下架时 需要验证箱是否在库存里
|
||||
|
||||
List<MoveBoxRecord> entityList = new List<MoveBoxRecord>();
|
||||
foreach (var d in dto)
|
||||
{
|
||||
var subStock = await _basbicsRepositories.GetSubUcStockAsync(d.SubStockId, loginInfo.UserInfo.CompanyId);
|
||||
var entity = new MoveBoxRecord();
|
||||
entity.Create(IsUp == true ? MoveBoxType.Up : MoveBoxType.Down, d.BoxId, d.StockCode, d.SubStockId, loginInfo.UserInfo.StaffId);
|
||||
entity.Create(IsUp == true ? MoveBoxType.Up : MoveBoxType.Down, d.BoxId, subStock ?.ErpOrgCode, subStock?.StockCode, d.SubStockId, loginInfo.UserInfo.StaffId);
|
||||
entityList.Add(entity);
|
||||
}
|
||||
var inventoryList = _mapper.Map<List<BoxInventoryMoveGenerateDto>>(dto);
|
||||
|
||||
@@ -64,7 +64,12 @@ namespace WMS.Web.Domain.Services
|
||||
{
|
||||
List<TakeStock> list = _mapper.Map<List<TakeStock>>(dto);
|
||||
foreach (var entity in list)
|
||||
{
|
||||
var subStock = await _transactionRepositories.GetSubUcStockAsync(entity.SubStockId, loginInfo.UserInfo.CompanyId);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
entity.OrgCode = subStock?.ErpOrgCode;
|
||||
entity.StockCode = subStock?.StockCode;
|
||||
}
|
||||
|
||||
#region 组装库存dto
|
||||
List<BoxInventoryGenerateDto> inventoryList = new List<BoxInventoryGenerateDto>();
|
||||
|
||||
Reference in New Issue
Block a user