非采购上架-接口
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.ChangeBoxRecord;
|
||||
using WMS.Web.Core.Dto.Erp;
|
||||
using WMS.Web.Core.Dto.InStock;
|
||||
using WMS.Web.Core.Dto.InStockTask;
|
||||
@@ -28,19 +29,21 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly ILoginService _loginService;
|
||||
private readonly IChangeMoveBoxService _changeMoveBoxService;
|
||||
private readonly IBoxRepositories _boxRepositories;
|
||||
private readonly IBasicsRepositories _basicsRepositories;
|
||||
private readonly IInStockRepositories _inStockRepositories;
|
||||
private readonly IInStockTaskRepositories _inStockTaskRepositories;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
public InStockService(IMapper mapper, IErpService erpService, ILoginService loginService, IBoxRepositories boxRepositories,
|
||||
IBasicsRepositories basicsRepositories, IErpBasicDataExtendService erpBasicDataExtendService,
|
||||
IBasicsRepositories basicsRepositories, IErpBasicDataExtendService erpBasicDataExtendService, IChangeMoveBoxService changeMoveBoxService,
|
||||
IInStockRepositories inStockRepositories, IInStockTaskRepositories inStockTaskRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_erpService = erpService;
|
||||
_loginService = loginService;
|
||||
_boxRepositories = boxRepositories;
|
||||
_changeMoveBoxService = changeMoveBoxService;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
_inStockRepositories = inStockRepositories;
|
||||
_inStockTaskRepositories = inStockTaskRepositories;
|
||||
@@ -95,7 +98,7 @@ namespace WMS.Web.Domain.Services
|
||||
bool isRollback = false;
|
||||
bool isTransaction = false;
|
||||
//1.添加入库单:(同步金蝶在save方法里面进行)
|
||||
var save_result = await this.Save(instock, InstockType.Purchase, loginInfo.UserInfo.StaffId, isTransaction);
|
||||
var save_result = await this.ShelfSave(instock, InstockType.Purchase, loginInfo.UserInfo.StaffId, isTransaction);
|
||||
if (!save_result.IsSuccess) isRollback = true;
|
||||
{
|
||||
//2.修改入库任务单
|
||||
@@ -112,6 +115,27 @@ namespace WMS.Web.Domain.Services
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 非采购单上架-按箱
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> ShelfNoPurchase(NoPurchaseShelfRequest dto,LoginInDto loginInDto)
|
||||
{
|
||||
IDbContextTransaction _transaction = _basicsRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isTransaction = false;
|
||||
//保存非采购上架的数据
|
||||
var shelfSave_result = await this.ShelfNoPurchaseSave(dto,loginInDto.UserInfo.StaffId, isTransaction);
|
||||
if(!shelfSave_result.IsSuccess) isRollback = true;
|
||||
//提交事务
|
||||
var isSuccess = _basicsRepositories.CommitTransaction(isRollback, _transaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取任务单:根据箱号信息
|
||||
/// </summary>
|
||||
@@ -160,7 +184,7 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="staffId"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Result> Save(PurchaseShelfRequest dto, InstockType type, int staffId, bool isTransaction = true)
|
||||
private async Task<Result> ShelfSave(PurchaseShelfRequest dto, InstockType type, int staffId, bool isTransaction = true)
|
||||
{
|
||||
var entity = new InStock();
|
||||
entity.Type = type;
|
||||
@@ -178,7 +202,49 @@ namespace WMS.Web.Domain.Services
|
||||
else
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
/// <summary>
|
||||
/// 非采购上架-按箱-保存
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="staffId"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Result> ShelfNoPurchaseSave(NoPurchaseShelfRequest dto,int staffId, bool isTransaction = true)
|
||||
{
|
||||
|
||||
//1.修改-入库任务单的信息
|
||||
var updateInStockTaskRequest = new UpdateInStockTaskRequest();
|
||||
updateInStockTaskRequest.Id = dto.TaskId;
|
||||
updateInStockTaskRequest.Boxs = dto.Boxs;
|
||||
updateInStockTaskRequest.Details = dto.TaskDetails;
|
||||
//2.修改后返回当前实体
|
||||
var update_result = await this.Update(updateInStockTaskRequest, staffId, null, isTransaction, true);
|
||||
if (!update_result.IsSuccess)
|
||||
return update_result;
|
||||
|
||||
//执行保存
|
||||
var entity = new InStock();
|
||||
entity.Type = update_result.Data.Type;
|
||||
entity.Details = _mapper.Map<List<InStockDetails>>(dto.Details);
|
||||
entity.Create(staffId);
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
//需要同步金蝶
|
||||
|
||||
entity = await _inStockRepositories.Add(entity, isTransaction);
|
||||
|
||||
if (entity != null)
|
||||
return Result.ReSuccess();
|
||||
else
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
//当按产品上架:就要调用该箱的操作;
|
||||
var changeBox = new SaveChangeBoxRecordRequest();
|
||||
|
||||
//await _changeMoveBoxService.ChangeBoxSave()
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改-入库任务信息
|
||||
/// </summary>
|
||||
@@ -187,26 +253,38 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="isReceive"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Update(UpdateInStockTaskRequest dto, int staffId,bool isReceive, bool isTransaction = true)
|
||||
public async Task<Result<InStockTask>> Update(UpdateInStockTaskRequest dto, int staffId,bool? isReceive, bool isTransaction = true,bool isNoPurchaseShelf=false)
|
||||
{
|
||||
var entity = await _inStockTaskRepositories.Get(dto.Id);
|
||||
if (entity == null)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result<InStockTask>.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
entity = _mapper.Map(dto, entity);
|
||||
//子集单独映射
|
||||
entity.Boxs = _mapper.ToMapList(dto.Boxs, entity.Boxs);
|
||||
////子集单独映射:这个弃用;这个不好的地方就是,前端必须拿到全部的boxs集合一起给到后端处理;
|
||||
//entity.Boxs = _mapper.ToMapList(dto.Boxs, entity.Boxs);
|
||||
//子集单独映射:box子集单独组装获取;这个好处就是前端就只传新增的box过来;
|
||||
foreach (var item in dto.Boxs)
|
||||
{
|
||||
var box = _mapper.Map<InStockTaskBox>(item);
|
||||
entity.Boxs.Add(box);
|
||||
}
|
||||
|
||||
//子集单独映射
|
||||
entity.Details = _mapper.ToMapList(dto.Details, entity.Details);
|
||||
if (isReceive)
|
||||
entity.Receive(staffId);
|
||||
if (isNoPurchaseShelf)
|
||||
entity.NoPurchaseShelf(staffId);
|
||||
else
|
||||
entity.Shelf(staffId);
|
||||
{
|
||||
if (isReceive.HasValue && isReceive.Value)
|
||||
entity.Receive(staffId);
|
||||
else
|
||||
entity.Shelf(staffId);
|
||||
}
|
||||
var result =await _inStockTaskRepositories.Update(entity, isTransaction);
|
||||
if (result != null)
|
||||
return Result.ReSuccess();
|
||||
return Result<InStockTask>.ReSuccess(entity);
|
||||
else
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result<InStockTask>.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user