非采购上架接口优化

This commit is contained in:
tongfei
2023-11-17 15:35:06 +08:00
parent 50246572d6
commit d25336ba7e
5 changed files with 181 additions and 88 deletions

View File

@@ -1790,16 +1790,61 @@
上架方式 上架方式
</summary> </summary>
</member> </member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfRequest.StockCode">
<summary>
仓库编码
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfRequest.SubStockId">
<summary>
仓位ID
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfRequest.Boxs"> <member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfRequest.Boxs">
<summary> <summary>
箱信息 箱信息
</summary> </summary>
</member> </member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfRequest.Details"> <member name="T:WMS.Web.Core.Dto.InStock.NoPurchaseShelfBoxRequest">
<summary>
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfBoxRequest.BoxId">
<summary>
箱信息ID
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfBoxRequest.BoxBillNo">
<summary>
箱号
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfBoxRequest.Details">
<summary> <summary>
入库单明细 入库单明细
</summary> </summary>
</member> </member>
<member name="T:WMS.Web.Core.Dto.InStock.NoPurchaseShelfDetailsRequest">
<summary>
明细
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfDetailsRequest.MaterialId">
<summary>
物料Id
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfDetailsRequest.Qty">
<summary>
入库数量
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.InStock.NoPurchaseShelfDetailsRequest.SerialNumbers">
<summary>
序列号集
</summary>
</member>
<member name="T:WMS.Web.Core.Dto.InStock.PurchaseShelfRequest"> <member name="T:WMS.Web.Core.Dto.InStock.PurchaseShelfRequest">
<summary> <summary>
采购上架-请求对象 采购上架-请求对象

View File

@@ -23,14 +23,64 @@ namespace WMS.Web.Core.Dto.InStock
[Required(ErrorMessage = "上架方式不能为空")] [Required(ErrorMessage = "上架方式不能为空")]
public int ShelfMethod { get; set; } public int ShelfMethod { get; set; }
/// <summary>
/// 仓库编码
///</summary>
[Required(ErrorMessage = "仓库不能为空")]
public string StockCode { get; set; }
/// <summary>
/// 仓位ID
///</summary>
[Required(ErrorMessage = " 仓位不能为空")]
public int SubStockId { get; set; }
/// <summary> /// <summary>
/// 箱信息 /// 箱信息
/// </summary> /// </summary>
public List<UpdateInStockTaskBoxRequest> Boxs { get; set; } = new List<UpdateInStockTaskBoxRequest>(); public List<NoPurchaseShelfBoxRequest> Boxs { get; set; } = new List<NoPurchaseShelfBoxRequest>();
}
/// <summary>
/// 箱
/// </summary>
public class NoPurchaseShelfBoxRequest
{
/// <summary>
/// 箱信息ID
/// </summary>
public int BoxId { get; set; }
/// <summary>
/// 箱号
/// </summary>
public string BoxBillNo { get; set; }
/// <summary> /// <summary>
/// 入库单明细 /// 入库单明细
/// </summary> /// </summary>
public List<SaveInStockDetailsRequest> Details { get; set; } = new List<SaveInStockDetailsRequest>(); public List<NoPurchaseShelfDetailsRequest> Details { get; set; } = new List<NoPurchaseShelfDetailsRequest>();
}
/// <summary>
/// 明细
/// </summary>
public class NoPurchaseShelfDetailsRequest
{
/// <summary>
/// 物料Id
///</summary>
[Required(ErrorMessage = "物料不能为空")]
public int MaterialId { get; set; }
/// <summary>
/// 入库数量
///</summary>
[Required(ErrorMessage = "入库数量不能为空")]
public decimal Qty { get; set; }
/// <summary>
/// 序列号集
/// </summary>
public List<string> SerialNumbers { get; set; } = new List<string>();
} }
} }

View File

@@ -5,6 +5,7 @@ using System.Text;
using WMS.Web.Core.Dto.Erp; using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.InStock; using WMS.Web.Core.Dto.InStock;
using WMS.Web.Core.Dto.InStockTask; using WMS.Web.Core.Dto.InStockTask;
using WMS.Web.Core.Dto.Inventory;
using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Entitys;
namespace WMS.Web.Domain.Mappers namespace WMS.Web.Domain.Mappers
@@ -30,6 +31,9 @@ namespace WMS.Web.Domain.Mappers
CreateMap<SaveInStockDetailsRequest, InStockDetails>().ReverseMap(); CreateMap<SaveInStockDetailsRequest, InStockDetails>().ReverseMap();
CreateMap<NoPurchaseShelfDetailsRequest, InStockDetails>().ReverseMap();
CreateMap<NoPurchaseShelfDetailsRequest, BoxInventoryGenerateDetailsDto>();
CreateMap<InStockTask, InStockTaskInfoDto>() CreateMap<InStockTask, InStockTaskInfoDto>()
.ForMember(x => x.Details, ops => ops.Ignore()); .ForMember(x => x.Details, ops => ops.Ignore());

View File

@@ -246,51 +246,55 @@ namespace WMS.Web.Domain.Services
/// <returns></returns> /// <returns></returns>
private async Task<Result> ShelfNoPurchaseSave(NoPurchaseShelfRequest dto, LoginInDto loginInfo, bool isTransaction = true) private async Task<Result> ShelfNoPurchaseSave(NoPurchaseShelfRequest dto, LoginInDto loginInfo, bool isTransaction = true)
{ {
//1.修改-入库任务单的信息 //1.获取来源单
var updateInStockTaskRequest = new UpdateInStockTaskRequest(); var task = await _inStockTaskRepositories.Get(dto.TaskId);
updateInStockTaskRequest.Id = dto.TaskId; if (task == null)
updateInStockTaskRequest.Boxs = dto.Boxs; return Result.ReFailure(ResultCodes.SourceBillNoDateError);
updateInStockTaskRequest.Details = new List<UpdateInStockTaskDetailsRequest>();
foreach (var item in dto.Details)
{
var updateInStockTaskDetailsRequest = new UpdateInStockTaskDetailsRequest();
updateInStockTaskDetailsRequest.MaterialId = item.MaterialId;
updateInStockTaskDetailsRequest.ReceiveQty = item.Qty;
updateInStockTaskRequest.Details.Add(updateInStockTaskDetailsRequest);
}
//1.1.先找到箱IDs获取箱基本信息
var boxIds = dto.Details.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
//var boxInfos= await _boxRepositories.GetEntityList(boxIds);
//foreach (var item in boxInfos)
//{
// var task_box = new UpdateInStockTaskBoxRequest();
// task_box.BoxId = item.Id;
// task_box.BoxBillNo = item.BoxBillNo;
// updateInStockTaskRequest.Boxs.Add(task_box);
//}
//1.2.修改入库任务 //2.生成:入库
var update_result = await this.Update(updateInStockTaskRequest, loginInfo.UserInfo.StaffId, null, isTransaction, true);
if (!update_result.IsSuccess)
return update_result;
//2.入库单生成
var entity = new InStock(); var entity = new InStock();
entity.Type = update_result.Data.Type; entity.Type = task.Type;
entity.Details = _mapper.Map<List<InStockDetails>>(dto.Details); entity.Details = new List<InStockDetails>();
var temps=new List<InStockDetails>();
//3.遍历box信息,并拼装入库单明细
foreach (var box in dto.Boxs)
{
//3.1先数据映射
var dets = _mapper.Map<List<InStockDetails>>(box.Details);
//3.2遍历赋值boxID和仓库和仓位和来源单和供应商和组织
dets.ForEach(item =>
{
item.TaskId = dto.TaskId;
item.SourceBillNo = task.SourceBillNo;
item.BoxId = box.BoxId;
item.SubStockId = dto.SubStockId;
item.StockCode = dto.StockCode;
var taskDet= task.Details.Where(x => x.MaterialId == item.MaterialId).FirstOrDefault();
item.SupplierId = taskDet.SupplierId;
item.OrgId = taskDet.OrgId;
});
//3.3添加到临时集合中
temps.AddRange(dets);
}
//3.4给对象明细赋值
entity.Details = temps;
//4.创建
entity.Create(loginInfo.UserInfo.StaffId); entity.Create(loginInfo.UserInfo.StaffId);
//2.1保存入库单信息 //5.1保存入库单信息
entity = await _inStockRepositories.Add(entity, isTransaction); entity = await _inStockRepositories.Add(entity, isTransaction);
if (entity == null) if (entity == null)
return Result.ReFailure(ResultCodes.DateWriteError); return Result.ReFailure(ResultCodes.DateWriteError);
//2.2当按产品上架:就要调用改箱的操作; //6.当按产品上架:就要调用改箱的操作;
if (dto.ShelfMethod == (int)ShelfMethod.Product) if (dto.ShelfMethod == (int)ShelfMethod.Product)
{ {
var dto_box = dto.Boxs.FirstOrDefault();
var changeBox = new SaveChangeBoxRecordRequest(); var changeBox = new SaveChangeBoxRecordRequest();
changeBox.DestBoxId = boxIds.FirstOrDefault(); changeBox.DestBoxId = dto_box.BoxId;
foreach (var item in dto.Details) foreach (var item in dto_box.Details)
{ {
var changeBoxRD = new SaveChangeBoxRecordDetailsRequest(); var changeBoxRD = new SaveChangeBoxRecordDetailsRequest();
changeBoxRD.MaterialId = item.MaterialId; changeBoxRD.MaterialId = item.MaterialId;
@@ -303,35 +307,24 @@ namespace WMS.Web.Domain.Services
return changeBoxSave_Result; return changeBoxSave_Result;
} }
//2.3序列号跟踪流程添加;备注:和上面的改箱操作后会记录序列号轨迹不冲突; //6.1序列号跟踪流程添加;备注:和上面的改箱操作后会记录序列号轨迹不冲突;
var serialNumber_result = await _serialNumberService.InStock(entity, loginInfo, isTransaction); var serialNumber_result = await _serialNumberService.InStock(entity, loginInfo, isTransaction);
if (!serialNumber_result.IsSuccess) if (!serialNumber_result.IsSuccess)
return serialNumber_result; return serialNumber_result;
//3.箱库存的变更 //7.箱库存的变更
//3.1组装头部 //7.1组装头部和明细
var boxInventoryGenerateDto = dto.Details.GroupBy(x => new { x.BoxId, x.StockCode, x.SubStockId }).Select(x => new BoxInventoryGenerateDto() var boxInventoryGenerateDto = dto.Boxs.Select(item => new BoxInventoryGenerateDto()
{ {
InventoryInOutMethod = dto.ShelfMethod == (int)ShelfMethod.Product ? (int)InventoryInOutMethod.Box : (int)InventoryInOutMethod.Product, InventoryInOutMethod = dto.ShelfMethod == (int)ShelfMethod.Product ? (int)InventoryInOutMethod.Box : (int)InventoryInOutMethod.Product,
InventoryInOutType = (int)InventoryInOutType.In, InventoryInOutType = (int)InventoryInOutType.In,
BoxId = x.Key.BoxId, BoxId = item.BoxId,
StockCode = x.Key.StockCode, StockCode = dto.StockCode,
SubStockId = x.Key.SubStockId SubStockId = dto.SubStockId,
Details = _mapper.Map<List<BoxInventoryGenerateDetailsDto>>(item.Details)
}).ToList(); }).ToList();
//3.2组装明细
foreach (var item in dto.Details) //7.2执行处理箱库存
{
var current = boxInventoryGenerateDto.Where(x => x.BoxId == item.BoxId).FirstOrDefault();
if (current != null)
{
var detail = new BoxInventoryGenerateDetailsDto();
detail.MaterialId = item.MaterialId;
detail.Qty = item.Qty;
detail.SerialNumbers = item.SerialNumbers;
current.Details.Add(detail);
}
}
//3.3执行处理箱库存
var boxInventoryResult = await _boxInventoryService.HandlBoxInventory(boxInventoryGenerateDto, isTransaction); var boxInventoryResult = await _boxInventoryService.HandlBoxInventory(boxInventoryGenerateDto, isTransaction);
if (!boxInventoryResult.IsSuccess) if (!boxInventoryResult.IsSuccess)
return boxInventoryResult; return boxInventoryResult;

View File

@@ -21,6 +21,7 @@ namespace WMS.Web.Domain.Values
/// </summary> /// </summary>
public static ValueTuple<int, string> DateWriteError = (40004, "数据操作失败"); public static ValueTuple<int, string> DateWriteError = (40004, "数据操作失败");
public static ValueTuple<int, string> NoDateError = (40005, "数据不存在"); public static ValueTuple<int, string> NoDateError = (40005, "数据不存在");
public static ValueTuple<int, string> SourceBillNoDateError = (40005, "来源单不存在,请核对后再试");
//出库任务单 //出库任务单
public static ValueTuple<int, string> MergeStatusError = (70000, "所选单据数据不一致,不能合并"); public static ValueTuple<int, string> MergeStatusError = (70000, "所选单据数据不一致,不能合并");