入库单-接口
This commit is contained in:
@@ -43,5 +43,38 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public List<InStockDetails> Details = new List<InStockDetails>();
|
||||
|
||||
/// <summary>
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(int creatorId)
|
||||
{
|
||||
this.CreatorId = creatorId;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成单据号
|
||||
/// </summary>
|
||||
public void GenerateNo()
|
||||
{
|
||||
//用户手动输入了 就不自动生成了
|
||||
if (!string.IsNullOrEmpty(this.BillNo)) return;
|
||||
|
||||
if (this.Id.ToString().Length >= 8)
|
||||
{
|
||||
this.BillNo = "RK" + this.Id.ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
string idStr = this.Id.ToString();
|
||||
while (true)
|
||||
{
|
||||
idStr = "0" + idStr;
|
||||
if (idStr.Length >= 8) break;
|
||||
}
|
||||
this.BillNo = "RK" + idStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
src/WMS.Web.Domain/IService/IInStockService.cs
Normal file
32
src/WMS.Web.Domain/IService/IInStockService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.InStock;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
|
||||
namespace WMS.Web.Domain.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 入库单服务接口
|
||||
/// </summary>
|
||||
public interface IInStockService
|
||||
{
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Save(List<SaveInStockRequest> dto, LoginInDto loginInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 同步金蝶
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Sync(OperateRequest dto);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
|
||||
namespace WMS.Web.Domain.Infrastructure
|
||||
{
|
||||
@@ -18,5 +19,13 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
Task<ResultPagedList<InStockQueryResponse>> GetPagedList(InStockQueryRequest dto);
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<InStock> Add(InStock entity, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
|
||||
82
src/WMS.Web.Domain/Services/InStockService.cs
Normal file
82
src/WMS.Web.Domain/Services/InStockService.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.InStock;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
namespace WMS.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 入库单服务
|
||||
/// </summary>
|
||||
public class InStockService: IInStockService
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly ILoginService _loginService;
|
||||
public readonly ITransactionRepositories _transactionRepositories;
|
||||
private readonly IInStockRepositories _inStockRepositories;
|
||||
private readonly IInStockTaskRepositories _inStockTaskRepositories;
|
||||
public InStockService(IMapper mapper, ILoginService loginService,
|
||||
ITransactionRepositories transactionRepositories,
|
||||
IInStockRepositories inStockRepositories, IInStockTaskRepositories inStockTaskRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_loginService = loginService;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_inStockRepositories = inStockRepositories;
|
||||
_inStockTaskRepositories = inStockTaskRepositories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 出库单
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Save(List<SaveInStockRequest> dto, LoginInDto loginInfo)
|
||||
{
|
||||
var entity = new InStock();
|
||||
entity.Details = _mapper.Map<List<InStockDetails>>(dto);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
//需要同步金蝶
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isSuccess = true;
|
||||
entity = await _inStockRepositories.Add(entity, true);
|
||||
if (entity == null) isRollback = true;
|
||||
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步金蝶
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public Task<Result> Sync(OperateRequest dto)
|
||||
{
|
||||
//调用同步服务方法
|
||||
|
||||
return Task.FromResult(Result.ReSuccess());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user