入库单-接口
This commit is contained in:
@@ -5,8 +5,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.InStock;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
@@ -20,10 +22,12 @@ namespace WMS.Web.Api.Controllers
|
||||
public class InStockController : ControllerBase
|
||||
{
|
||||
private readonly ILoginService _loginService;
|
||||
private readonly IInStockService _inStockService;
|
||||
private readonly IInStockRepositories _inStockRepositories;
|
||||
public InStockController(ILoginService loginService, IInStockRepositories inStockRepositories)
|
||||
public InStockController(ILoginService loginService, IInStockRepositories inStockRepositories, IInStockService inStockService)
|
||||
{
|
||||
this._loginService = loginService;
|
||||
this._inStockService = inStockService;
|
||||
this._inStockRepositories = inStockRepositories;
|
||||
}
|
||||
|
||||
@@ -42,5 +46,37 @@ namespace WMS.Web.Api.Controllers
|
||||
var result= await _inStockRepositories.GetPagedList(dto);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("Save")]
|
||||
public async Task<Result> Save(List<SaveInStockRequest> dto)
|
||||
{
|
||||
var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
|
||||
if (loginInfo == null || loginInfo.UserInfo == null)
|
||||
return Result.ReFailure(ResultCodes.Token_Invalid_Error);
|
||||
|
||||
return await _inStockService.Save(dto, loginInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步金蝶
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("Sync")]
|
||||
public async Task<Result> Sync(OperateRequest dto)
|
||||
{
|
||||
var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
|
||||
if (loginInfo == null || loginInfo.UserInfo == null)
|
||||
return Result.ReFailure(ResultCodes.Token_Invalid_Error);
|
||||
|
||||
return await _inStockService.Sync(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace WMS.Web.Api.Controllers
|
||||
{
|
||||
response.TakeStockType.Add(enumv.ToString(), enumv.GetRemark());
|
||||
}
|
||||
foreach (InstockType enumv in Enum.GetValues(typeof(InstockType)))
|
||||
{
|
||||
response.InstockType.Add(enumv.ToString(), enumv.GetRemark());
|
||||
}
|
||||
//2
|
||||
//1
|
||||
return Task.FromResult(Result<EnumStatusResponse>.ReSuccess(response));
|
||||
|
||||
@@ -35,6 +35,20 @@
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Api.Controllers.InStockController.Save(System.Collections.Generic.List{WMS.Web.Core.Dto.InStock.SaveInStockRequest})">
|
||||
<summary>
|
||||
保存
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Api.Controllers.InStockController.Sync(WMS.Web.Core.Dto.OperateRequest)">
|
||||
<summary>
|
||||
同步金蝶
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Api.Controllers.InStockTaskController">
|
||||
<summary>
|
||||
入库任务单-接口
|
||||
|
||||
@@ -475,6 +475,51 @@
|
||||
同步成功或者失败
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.InStock.SaveInStockRequest">
|
||||
<summary>
|
||||
保存入库单-请求对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockRequest.Type">
|
||||
<summary>
|
||||
入库类型
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockRequest.SourceBillNo">
|
||||
<summary>
|
||||
来源单号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockRequest.SupplierId">
|
||||
<summary>
|
||||
供应商
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockRequest.OrgId">
|
||||
<summary>
|
||||
组织
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockRequest.MaterialId">
|
||||
<summary>
|
||||
物料Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockRequest.StockId">
|
||||
<summary>
|
||||
仓库ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockRequest.SubStockId">
|
||||
<summary>
|
||||
仓位ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStock.SaveInStockRequest.Qty">
|
||||
<summary>
|
||||
入库数量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.Login.AccessTokenDto.Token">
|
||||
<summary>
|
||||
授权token -- 给前端用的验证token
|
||||
@@ -980,6 +1025,11 @@
|
||||
单据Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.OutStockTask.OutStockTaskQueryInfoResponse.DetailId">
|
||||
<summary>
|
||||
明细Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.OutStockTask.OutStockTaskQueryInfoResponse.BillNo">
|
||||
<summary>
|
||||
单据编号
|
||||
@@ -1070,6 +1120,11 @@
|
||||
出库单任务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.OutStockTask.OutStockTaskQueryRequest.Ids">
|
||||
<summary>
|
||||
刷新 明细Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.OutStockTask.OutStockTaskQueryRequest.Type">
|
||||
<summary>
|
||||
单据类型(出库单下拉列表)
|
||||
|
||||
@@ -300,6 +300,17 @@
|
||||
明细
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.InStock.Create(System.Int32)">
|
||||
<summary>
|
||||
创建
|
||||
</summary>
|
||||
<param name="creatorId"></param>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.InStock.GenerateNo">
|
||||
<summary>
|
||||
生成单据号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InStockDetails">
|
||||
<summary>
|
||||
wms入库单明细
|
||||
@@ -964,6 +975,14 @@
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockRepositories.Add(WMS.Web.Domain.Entitys.InStock,System.Boolean)">
|
||||
<summary>
|
||||
添加
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories">
|
||||
<summary>
|
||||
入库任务-仓储接口
|
||||
@@ -1045,6 +1064,26 @@
|
||||
改箱 移箱服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.IService.IInStockService">
|
||||
<summary>
|
||||
入库单服务接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.IInStockService.Save(System.Collections.Generic.List{WMS.Web.Core.Dto.InStock.SaveInStockRequest},WMS.Web.Core.Dto.Login.LoginInDto)">
|
||||
<summary>
|
||||
保存
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<param name="loginInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.IInStockService.Sync(WMS.Web.Core.Dto.OperateRequest)">
|
||||
<summary>
|
||||
同步金蝶
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.IService.IOutStockService">
|
||||
<summary>
|
||||
出库服务
|
||||
@@ -1538,6 +1577,26 @@
|
||||
<param name="loginInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Services.InStockService">
|
||||
<summary>
|
||||
入库单服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Save(System.Collections.Generic.List{WMS.Web.Core.Dto.InStock.SaveInStockRequest},WMS.Web.Core.Dto.Login.LoginInDto)">
|
||||
<summary>
|
||||
出库单
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<param name="loginInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Sync(WMS.Web.Core.Dto.OperateRequest)">
|
||||
<summary>
|
||||
同步金蝶
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Services.OutStockService">
|
||||
<summary>
|
||||
出库服务
|
||||
|
||||
@@ -22,6 +22,12 @@ namespace WMS.Web.Core.Dto
|
||||
/// 盘点结果类型
|
||||
/// </summary>
|
||||
public Dictionary<string, string> TakeStockType { get; set; } = new Dictionary<string, string>();
|
||||
/// <summary>
|
||||
/// 入库单类型
|
||||
/// </summary>
|
||||
public Dictionary<string, string> InstockType { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
60
src/WMS.Web.Core/Dto/InStock/SaveInStockRequest.cs
Normal file
60
src/WMS.Web.Core/Dto/InStock/SaveInStockRequest.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Core.Dto.InStock
|
||||
{
|
||||
/// <summary>
|
||||
/// 保存入库单-请求对象
|
||||
/// </summary>
|
||||
public class SaveInStockRequest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 入库类型
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "入库类型不能为空")]
|
||||
public int Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源单号
|
||||
///</summary>
|
||||
[Required(ErrorMessage = "来源单号不能为空")]
|
||||
public string SourceBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 供应商
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "供应商不能为空")]
|
||||
public int SupplierId { get; set; }
|
||||
/// <summary>
|
||||
/// 组织
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "组织不能为空")]
|
||||
public int OrgId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
///</summary>
|
||||
[Required(ErrorMessage = "物料不能为空")]
|
||||
public int MaterialId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓库ID
|
||||
///</summary>
|
||||
[Required(ErrorMessage = "仓库不能为空")]
|
||||
public int StockId { get; set; }
|
||||
/// <summary>
|
||||
/// 仓位ID
|
||||
///</summary>
|
||||
[Required(ErrorMessage = " 仓位不能为空")]
|
||||
public int SubStockId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库数量
|
||||
///</summary>
|
||||
[Required(ErrorMessage = "入库数量不能为空")]
|
||||
public decimal Qty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,8 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
Services.AddTransient<IChangeMoveBoxService, ChangeMoveBoxService>();
|
||||
Services.AddTransient<ITakeStockService, TakeStockService>();
|
||||
Services.AddTransient<IOutStockService, OutStockService>();
|
||||
|
||||
Services.AddTransient<IInStockService, InStockService>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -8,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using WMS.Web.Core;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Values.Single;
|
||||
@@ -77,5 +79,40 @@ namespace WMS.Web.Repositories
|
||||
response.Data = list;
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<InStock> Add(InStock entity, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
await _context.Instock.AddAsync(entity);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
if (string.IsNullOrEmpty(entity.BillNo))
|
||||
{
|
||||
entity.GenerateNo();
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return entity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user