This commit is contained in:
tongfei
2023-10-26 17:49:01 +08:00
18 changed files with 477 additions and 18 deletions

View File

@@ -25,6 +25,16 @@ 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("SerialNumber")]
public string SerialNumber { get; set; }
/// <summary>
/// 原箱子ID
/// </summary>
[Column("SrcBoxId")]
@@ -54,5 +64,14 @@ namespace WMS.Web.Domain.Entitys
/// </summary>
[Column("CreateTime")]
public DateTime CreateTime { get; set; } = DateTime.Now;
/// <summary>
/// 创建
/// </summary>
/// <param name="creatorId"></param>
public void Create(int creatorId)
{
this.CreatorId = creatorId;
this.CreateTime = DateTime.Now;
}
}
}

View File

@@ -31,11 +31,6 @@ namespace WMS.Web.Domain.Entitys
[Column("BoxId")]
public int BoxId { get; set; }
/// <summary>
/// 序号
/// </summary>
[Column("Seq")]
public int Seq { get; set; }
/// <summary>
/// 物料ID
/// </summary>
[Column("MaterialId")]

View File

@@ -0,0 +1,20 @@

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.ChangeBoxRecord;
using WMS.Web.Core.Dto.Login;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Services;
namespace WMS.Web.Domain.IService
{
/// <summary>
/// 改箱 移箱服务
/// </summary>
public interface IChangeMoveBoxService
{
Task<Result> Save(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo);
}
}

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.Text;
namespace WMS.Web.Domain.Infrastructure
{
public interface ITransactionRepositories
{
/// <summary>
/// 获取事务 用来处理即时库存
/// </summary>
/// <returns></returns>
IDbContextTransaction GetTransaction();
/// <summary>
/// 获取事务 用来处理即时库存
/// </summary>
/// <returns></returns>
bool CommitTransaction(bool isRollback, IDbContextTransaction transaction);
}
}

View File

@@ -0,0 +1,20 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;
using WMS.Web.Core.Dto.ChangeBoxRecord;
using WMS.Web.Domain.Entitys;
namespace WMS.Web.Domain.Mappers
{
/// <summary>
/// 改箱
/// </summary>
public class ChangeBoxRecordMapper : Profile
{
public ChangeBoxRecordMapper()
{
CreateMap<SaveChangeBoxRecordRequest, ChangeBoxRecord>();
}
}
}

View File

@@ -0,0 +1,56 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.ChangeBoxRecord;
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
{
///改箱 移箱服务
public class ChangeMoveBoxService : IChangeMoveBoxService
{
private readonly IMapper _mapper;
private readonly ILoginService _loginService;
private readonly IChangeBoxRecordRepositories _changeBoxRecordRepositories;
public readonly ITransactionRepositories _transactionRepositories;
public ChangeMoveBoxService(IMapper mapper, ILoginService loginService,
IChangeBoxRecordRepositories changeBoxRecordRepositories, ITransactionRepositories transactionRepositories)
{
_mapper = mapper;
_loginService = loginService;
_changeBoxRecordRepositories = changeBoxRecordRepositories;
_transactionRepositories = transactionRepositories;
}
public async Task<Result> Save(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
{
var entity = _mapper.Map<ChangeBoxRecord>(dto);
entity.Create(loginInfo.UserInfo.StaffId);
//需要填写序列号
//需要修改库存
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isSuccess = true;
entity = await _changeBoxRecordRepositories.Add(entity, true);
if (entity == null) isRollback = true;
//提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
}
}

View File

@@ -16,5 +16,9 @@ namespace WMS.Web.Domain.Values
/// 无效
/// </summary>
public static ValueTuple<int, string> Token_Invalid_Error = (401, "验证Token无效请重新登录");
/// <summary>
/// 数据操作失败
/// </summary>
public static ValueTuple<int, string> DateWriteError = (40004, "数据操作失败");
}
}