Merge branch 'master' of https://codeup.aliyun.com/62ce7bca487c500c27f70a79/OPS/WMS-Api
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using WMS.Web.Core;
|
||||
using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
@@ -11,12 +15,12 @@ namespace WMS.Web.Domain.Entitys
|
||||
|
||||
[Serializable]
|
||||
[Table("t_ops_box")]
|
||||
public class Box
|
||||
public class Box : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
public override int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对应老OPS的箱ID
|
||||
@@ -37,5 +41,41 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 明细
|
||||
/// </summary>
|
||||
public List<BoxDetails> Details = new List<BoxDetails>();
|
||||
|
||||
//移出
|
||||
public Result Out(List<(int MaterialId, decimal Qty, List<string> SerialNumbers)> list)
|
||||
{
|
||||
foreach(var l in list)
|
||||
{
|
||||
var d = this.Details.FirstOrDefault(f => f.MaterialId == l.MaterialId);
|
||||
if (d == null) return Result.ReFailure(ResultCodes.BoxMateriaNoData);
|
||||
d.Qty = d.Qty - l.Qty;
|
||||
if (d.Qty <= 0) this.Details.Remove(d);
|
||||
foreach (var s in l.SerialNumbers) d.SerialNumbers.Remove(s);
|
||||
}
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
//移入
|
||||
public Result In(List<(int MaterialId, decimal Qty, List<string> SerialNumbers)> list)
|
||||
{
|
||||
foreach (var l in list)
|
||||
{
|
||||
var d = this.Details.FirstOrDefault(f => f.MaterialId == l.MaterialId);
|
||||
if (d == null)
|
||||
{
|
||||
this.Details.Add(new BoxDetails()
|
||||
{
|
||||
MaterialId = l.MaterialId,
|
||||
Qty=l.Qty,
|
||||
SerialNumbers=l.SerialNumbers
|
||||
});
|
||||
continue;
|
||||
}
|
||||
d.Qty = d.Qty + l.Qty;
|
||||
d.SerialNumbers.AddRange(l.SerialNumbers);
|
||||
}
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using WMS.Web.Core;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
@@ -11,12 +12,12 @@ namespace WMS.Web.Domain.Entitys
|
||||
|
||||
[Serializable]
|
||||
[Table("t_ops_box_details")]
|
||||
public class BoxDetails
|
||||
public class BoxDetails : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
public override int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据头ID
|
||||
@@ -37,6 +38,6 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// <summary>
|
||||
/// 序列号集
|
||||
/// </summary>
|
||||
public string SerialNumbers { get; set; }
|
||||
public List<string> SerialNumbers { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,36 +25,26 @@ 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("SerialNumbers")]
|
||||
public string SerialNumbers { get; set; }
|
||||
public List<string> SerialNumbers { get; set; } = new List<string>();
|
||||
/// <summary>
|
||||
/// 原箱子ID
|
||||
/// </summary>
|
||||
[Column("SrcBoxId")]
|
||||
public int SrcBoxId { get; set; }
|
||||
/// <summary>
|
||||
/// 数量
|
||||
///</summary>
|
||||
[Column("Qty")]
|
||||
public decimal Qty { get; set; }
|
||||
/// <summary>
|
||||
/// 目标箱子ID
|
||||
/// </summary>
|
||||
[Column("DestBoxId")]
|
||||
public int DestBoxId { get; set; }
|
||||
/// <summary>
|
||||
/// 原仓位ID
|
||||
/// </summary>
|
||||
[Column("SrcSubStockId")]
|
||||
public int SrcSubStockId { get; set; }
|
||||
/// <summary>
|
||||
/// 目标仓位ID
|
||||
/// </summary>
|
||||
[Column("DestSubStockId")]
|
||||
public int DestSubStockId { get; set; }
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
[Column("CreatorId")]
|
||||
@@ -68,8 +58,16 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(int creatorId)
|
||||
/// <param name="qty"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <param name="serialNumbers"></param>
|
||||
public void Create(int creatorId,decimal qty,int materialId, List<string> serialNumbers,int srcBoxId,int destBoxId)
|
||||
{
|
||||
this.SrcBoxId = srcBoxId;
|
||||
this.DestBoxId = destBoxId;
|
||||
this.SerialNumbers = serialNumbers;
|
||||
this.MaterialId = materialId;
|
||||
this.Qty = qty;
|
||||
this.CreatorId = creatorId;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// </summary>
|
||||
public interface IBoxRepositories
|
||||
{
|
||||
Task<Box> Get(string BoxBillNo);
|
||||
//根据箱号查询物料信息
|
||||
Task<List<BoxDetailResponse>> GetDetails(string BoxBillNo);
|
||||
Task<Box> Get(int id);
|
||||
//根据箱号查询明细信息
|
||||
Task<BoxResponse> GetBox(string BoxBillNo);
|
||||
//批量修改
|
||||
Task<bool> EditEntityList(List<Box> entitys, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
{
|
||||
// 新增
|
||||
Task<ChangeBoxRecord> Add(ChangeBoxRecord entity, bool isTransaction = true);
|
||||
// 批量新增
|
||||
Task<bool> AddRange(List<ChangeBoxRecord> list, bool isTransaction = true);
|
||||
|
||||
// 获取列表
|
||||
Task<(List<ChangeBoxRecordQueryInfoResponse> list,int total)> GetListAsync(ChangeBoxRecordQueryRequest dto);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto.ChangeBoxRecord;
|
||||
@@ -24,15 +25,17 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly IChangeBoxRecordRepositories _changeBoxRecordRepositories;
|
||||
public readonly ITransactionRepositories _transactionRepositories;
|
||||
private readonly IMoveBoxRecordRepositories _moveBoxRecordRepositories;
|
||||
public ChangeMoveBoxService(IMapper mapper, ILoginService loginService,
|
||||
private readonly IBoxRepositories _boxRepositories;
|
||||
public ChangeMoveBoxService(IMapper mapper, ILoginService loginService,
|
||||
IChangeBoxRecordRepositories changeBoxRecordRepositories, ITransactionRepositories transactionRepositories,
|
||||
IMoveBoxRecordRepositories moveBoxRecordRepositories)
|
||||
IMoveBoxRecordRepositories moveBoxRecordRepositories, IBoxRepositories boxRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_loginService = loginService;
|
||||
_changeBoxRecordRepositories = changeBoxRecordRepositories;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_moveBoxRecordRepositories = moveBoxRecordRepositories;
|
||||
_boxRepositories = boxRepositories;
|
||||
}
|
||||
/// <summary>
|
||||
/// 改箱保存
|
||||
@@ -40,10 +43,32 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
|
||||
public async Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
var entity = _mapper.Map<ChangeBoxRecord>(dto);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
List<Box> boxList = new List<Box>();
|
||||
var srcBox = await _boxRepositories.Get(dto.SrcBoxId);
|
||||
var destBox = await _boxRepositories.Get(dto.DestBoxId);
|
||||
if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
|
||||
if (destBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
|
||||
var l = dto.Details.Select(s => (s.MaterialId, s.Qty, s.SerialNumbers)).ToList();
|
||||
//原箱移出
|
||||
var res = srcBox.Out(l);
|
||||
if (!res.IsSuccess) return res;
|
||||
//目标箱移入
|
||||
res = destBox.In(l);
|
||||
if (!res.IsSuccess) return res;
|
||||
|
||||
boxList.Add(srcBox);
|
||||
boxList.Add(destBox);
|
||||
|
||||
//var entity = _mapper.Map<ChangeBoxRecord>(dto);\
|
||||
List<ChangeBoxRecord> list = new List<ChangeBoxRecord>();
|
||||
foreach (var d in dto.Details)
|
||||
{
|
||||
ChangeBoxRecord entity = new ChangeBoxRecord();
|
||||
entity.Create(loginInfo.UserInfo.StaffId, d.Qty, d.MaterialId, d.SerialNumbers, dto.SrcBoxId, dto.DestBoxId);
|
||||
list.Add(entity);
|
||||
}
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
@@ -51,8 +76,12 @@ namespace WMS.Web.Domain.Services
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isSuccess = true;
|
||||
entity = await _changeBoxRecordRepositories.Add(entity, true);
|
||||
if (entity == null) isRollback = true;
|
||||
isSuccess = await _changeBoxRecordRepositories.AddRange(list, false);
|
||||
if (!isSuccess) isRollback = true;
|
||||
|
||||
isSuccess = await _boxRepositories.EditEntityList(boxList, false);
|
||||
if (!isSuccess) isRollback = true;
|
||||
|
||||
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||
|
||||
@@ -24,5 +24,8 @@ namespace WMS.Web.Domain.Values
|
||||
|
||||
//出库任务单
|
||||
public static ValueTuple<int, string> MergeStatusError = (70000, "所选单据数据不一致,不能合并");
|
||||
|
||||
public static ValueTuple<int, string> BoxNoData = (80000, "箱信息不存在");
|
||||
public static ValueTuple<int, string> BoxMateriaNoData = (800010, "箱对应物料信息不存在");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user