出入库回退上下架

This commit is contained in:
tongfei
2023-10-31 10:42:11 +08:00
parent bcedfe0189
commit ddd67065dc
17 changed files with 439 additions and 12 deletions

View File

@@ -16,11 +16,7 @@ namespace WMS.Web.Domain.Entitys
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 所属箱号ID
/// </summary>
public int BoxId { get; set; }
public int Id { get; set; }
/// <summary>
/// 类型1为入库回退下架2为出库回退上架
/// </summary>
@@ -39,5 +35,15 @@ namespace WMS.Web.Domain.Entitys
/// </summary>
[NotMapped]
public List<BackRecordDetails> Details = new List<BackRecordDetails>();
/// <summary>
/// 创建
/// </summary>
/// <param name="creatorId"></param>
public void Create(int creatorId)
{
this.CreatorId = creatorId;
this.CreateTime = DateTime.Now;
}
}
}

View File

@@ -21,6 +21,10 @@ namespace WMS.Web.Domain.Entitys
/// </summary>
public int Fid { get; set; }
/// <summary>
/// 所属箱号ID
/// </summary>
public int BoxId { get; set; }
/// <summary>
/// 物料ID
/// </summary>
public int MaterialId { get; set; }

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.BackRecord;
using WMS.Web.Core.Dto.Login;
using WMS.Web.Core.Internal.Results;
namespace WMS.Web.Domain.IService
{
/// <summary>
/// 出入库回退上下架:服务接口
/// </summary>
public interface IBackRecordService
{
/// <summary>
/// 回退上下架
/// </summary>
/// <param name="dto"></param>
/// <param name="loginInfo"></param>
/// <returns></returns>
Task<Result> BackShelf(SaveBackRecordRequest dto, LoginInDto loginInfo);
}
}

View File

@@ -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<BackRecordQueryResponse>> GetPagedList(BackRecordQueryRequest dto);
/// <summary>
/// 新增
/// </summary>
/// <param name="entity"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
Task<BackRecord> Add(BackRecord entity, bool isTransaction = true);
}
}

View File

@@ -0,0 +1,17 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;
using WMS.Web.Core.Dto.BackRecord;
using WMS.Web.Domain.Entitys;
namespace WMS.Web.Domain.Mappers
{
public class BackRecordMapper : Profile
{
public BackRecordMapper()
{
CreateMap<SaveBackRecordDetailsRequest, BackRecordDetails>().ReverseMap();
}
}
}

View File

@@ -13,7 +13,7 @@ using WMS.Web.Domain.Options;
namespace WMS.Web.Domain.QuartzJob
{
/// <summary>
/// erp入库单-获取定时任务
/// erp入库任务单-获取定时任务
/// </summary>
public class InStockOrderQuartzJob : IJob
{

View File

@@ -0,0 +1,66 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.BackRecord;
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 BackRecordService: IBackRecordService
{
private readonly IMapper _mapper;
private readonly ILoginService _loginService;
public readonly ITransactionRepositories _transactionRepositories;
private readonly IBackRecordRepositories _backRecordRepositories;
public BackRecordService(IMapper mapper, ILoginService loginService,
ITransactionRepositories transactionRepositories,
IBackRecordRepositories backRecordRepositories)
{
_mapper = mapper;
_loginService = loginService;
_transactionRepositories = transactionRepositories;
_backRecordRepositories = backRecordRepositories;
}
/// <summary>
/// 回退上下架
/// </summary>
/// <param name="dto"></param>
/// <param name="loginInfo"></param>
/// <returns></returns>
public async Task<Result> BackShelf(SaveBackRecordRequest dto, LoginInDto loginInfo)
{
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isTransaction = false;
var entity = new BackRecord();
entity.Type = (BackRecordType)dto.Type;
entity.Details = _mapper.Map<List<BackRecordDetails>>(dto.Details);
entity.Create(loginInfo.UserInfo.StaffId);
entity = await _backRecordRepositories.Add(entity, isTransaction);
//提交事务
var isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
if (entity != null)
return Result.ReSuccess();
else
return Result.ReFailure(ResultCodes.DateWriteError);
}
}
}