Browse Source

生产退库测试完成

dev_DY_CC
刘云峰 1 year ago
parent
commit
65f55cc2b0
  1. 41
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ProductionReturnNotes/ProductionReturnNoteAppService.cs
  2. 85
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ProductionReturnRequests/ProductionReturnRequestAppService.cs
  3. 15
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ProductionReturnJobEventHandler.cs
  4. 94
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductionReturnRequestEventHandler.cs
  5. 3
      build/src/docker/publish/conf/settings/appsettings.Development.json

41
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ProductionReturnNotes/ProductionReturnNoteAppService.cs

@ -1,6 +1,10 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Domain.Shared;
@ -18,13 +22,19 @@ public class ProductionReturnNoteAppService :
IProductionReturnNoteAppService
{
private readonly IProductionReturnNoteManager _ProductionReturnNoteManager;
private readonly ILocationAppService _locationAppService;
private readonly IItemStoreRelationAppService _itemStoreRelationAppService;
public ProductionReturnNoteAppService(
IProductionReturnNoteRepository repository
, IProductionReturnNoteManager ProductionReturnNoteManager
, ILocationAppService locationAppService
, IItemStoreRelationAppService itemStoreRelationAppService
) : base(repository)
{
_ProductionReturnNoteManager = ProductionReturnNoteManager;
_locationAppService = locationAppService;
_itemStoreRelationAppService = itemStoreRelationAppService;
}
/// <summary>
@ -42,6 +52,37 @@ public class ProductionReturnNoteAppService :
return dto;
}
/// <summary>
/// 新增实体(原材料生产退库)
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("create-yl")]
//[Authorize(ProductionReturnNotePermissions.Create)]
public async Task<ProductionReturnNoteDTO> CreateYLAsync(ProductionReturnNoteEditInput input)
{
//校验目标库位
var locCodeLst = input.Details.Select(itm => itm.ToLocationCode).ToList();
var locLst = await _locationAppService.GetByCodesAsync(locCodeLst).ConfigureAwait(false);
bool allIsBCP = locLst.All(itm => itm.Type == EnumLocationType.RAW);
if (allIsBCP == false)
{
throw new UserFriendlyException("目标库位必须是原材料库位,不允许存在其它类型库位!");
}
//校验物料和库存关系
foreach (var item in input.Details)
{
var obj = await _itemStoreRelationAppService.GetFirstAsync(item.ItemCode, item.ToLocationCode).ConfigureAwait(false);
if (obj == null)
{
throw new UserFriendlyException($"物料{item.ItemCode}不能存在目标库位{item.ToLocationCode},物料库存关系表不存在!");
}
}
var entity = ObjectMapper.Map<ProductionReturnNoteEditInput, ProductionReturnNote>(input);
await _ProductionReturnNoteManager.CreateAsync(entity).ConfigureAwait(false);
var dto = ObjectMapper.Map<ProductionReturnNote, ProductionReturnNoteDTO>(entity);
return dto;
}
}

85
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ProductionReturnRequests/ProductionReturnRequestAppService.cs

@ -33,7 +33,7 @@ public class ProductionReturnRequestAppService :
private readonly IItemBasicAppService _itemBasicAppService;
private readonly ILocationAppService _locationAppService;
private readonly IBalanceAppService _balanceAppservice;
private readonly IItemStoreRelationAppService _itemStoreRelationAppService;
@ -45,8 +45,7 @@ public class ProductionReturnRequestAppService :
IItemBasicAppService itemBasicAppService,
ILocationAppService locationAppService,
IBalanceAppService _balanceAppservice
,IItemStoreRelationAppService itemStoreRelationAppService
)
: base(repository, productionRequestReturnManager)
{
@ -55,10 +54,13 @@ public class ProductionReturnRequestAppService :
_purchaseOrderApp = purchaseOrderApp;
_itemBasicAppService = itemBasicAppService;
_locationAppService = locationAppService;
_itemStoreRelationAppService = itemStoreRelationAppService;
}
/// <summary>
/// 【创建】生成退料申请
/// 【创建】生成退料申请(半成品生产退库)
/// 立库生产退库调用CreateLiKuAsync
/// 原材料生产退库调用ProductionReturnNote的CreateYLAsync
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
@ -66,22 +68,75 @@ public class ProductionReturnRequestAppService :
//[Authorize(ProductionReturnRequestPermissions.Create)]
public override async Task<ProductionReturnRequestDTO> CreateAsync(ProductionReturnRequestEditInput input)
{
//校验目标库位
var locCodeLst = input.Details.Select(itm => itm.ToLocationCode).ToList();
var locLst = await _locationAppService.GetByCodesAsync(locCodeLst).ConfigureAwait(false);
bool allIsBCP = locLst.All(itm => itm.Type == EnumLocationType.SEMI);
if (allIsBCP == false)
{
throw new UserFriendlyException("目标库位必须是半成品库位,不允许存在其它类型库位!");
}
//校验物料和库存关系
foreach (var item in input.Details)
{
var obj = await _itemStoreRelationAppService.GetFirstAsync(item.ItemCode, item.ToLocationCode).ConfigureAwait(false);
if (obj == null)
{
throw new UserFriendlyException($"物料{item.ItemCode}不能存在目标库位{item.ToLocationCode},物料库存关系表不存在!");
}
}
var entity = ObjectMapper.Map<ProductionReturnRequestEditInput, ProductionReturnRequest>(input);
//var subType = Enum.Parse<EnumTransSubType>(input.Type);
//var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.TransferLib, subType).ConfigureAwait(false);
//entity.Type = ((int)subType).ToString();
//entity.AutoCompleteJob = tranType.AutoCompleteJob;
//entity.AutoSubmit = tranType.AutoSubmitRequest;
//entity.AutoAgree = tranType.AutoAgreeRequest;
//entity.AutoHandle = tranType.AutoHandleRequest;
//entity.DirectCreateNote = tranType.DirectCreateNote;
await _productionReturnRequestManager.CreateAsync(entity).ConfigureAwait(false);
var dto = ObjectMapper.Map<ProductionReturnRequest, ProductionReturnRequestDTO>(entity);
return dto;
}
//SfsInventoryRequestInputBase sfsRequestInput = new SfsInventoryRequestInputBase();
//sfsRequestInput.Condition
/// <summary>
/// 【创建】生成退料申请(立库生产退库)
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("create-liku")]
//[Authorize(ProductionReturnRequestPermissions.Create)]
public async Task<ProductionReturnRequestDTO> CreateLiKuAsync(ProductionReturnRequestEditInput input)
{
//校验目标库位 //??没有立库类型
//var locCodeLst = input.Details.Select(itm => itm.ToLocationCode).ToList();
//var locLst = await _locationAppService.GetByCodesAsync(locCodeLst).ConfigureAwait(false);
//bool allIsBCP = locLst.All(itm => itm.Type == EnumLocationType.立库);
//if (allIsBCP == false)
//{
// throw new UserFriendlyException("目标库位必须是立库,不允许存在其它类型库位!");
//}
//校验物料和库存关系
foreach (var item in input.Details)
{
var obj = await _itemStoreRelationAppService.GetFirstAsync(item.ItemCode, item.ToLocationCode).ConfigureAwait(false);
if (obj == null)
{
throw new UserFriendlyException($"物料{item.ItemCode}不能存在目标库位{item.ToLocationCode},物料库存关系表不存在!");
}
}
var entity = ObjectMapper.Map<ProductionReturnRequestEditInput, ProductionReturnRequest>(input);
//var subType = Enum.Parse<EnumTransSubType>(input.Type);
//var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.TransferLib, subType).ConfigureAwait(false);
//entity.Type = ((int)subType).ToString();
//entity.AutoCompleteJob = tranType.AutoCompleteJob;
//entity.AutoSubmit = tranType.AutoSubmitRequest;
//entity.AutoAgree = tranType.AutoAgreeRequest;
//entity.AutoHandle = tranType.AutoHandleRequest;
//entity.DirectCreateNote = tranType.DirectCreateNote;
await _productionReturnRequestManager.CreateAsync(entity).ConfigureAwait(false);
var dto = ObjectMapper.Map<ProductionReturnRequest, ProductionReturnRequestDTO>(entity);
return dto;
}

15
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ProductionReturnJobEventHandler.cs

@ -62,12 +62,23 @@ public class ProductionReturnJobEventHandler :
input.ReturnTime=DateTime.Now;
input.Details = new List<ProductionReturnNoteDetailInput>();
foreach (var detail in entity.Details.Where(detail => detail.HandledQty != 0))
foreach (var detail in entity.Details) //.Where(detail => detail.HandledQty != 0)
{
var inputDetail = ObjectMapper.Map<ProductionReturnJobDetail, ProductionReturnNoteDetailInput>(detail);
inputDetail.FromWarehouseCode = entity.WarehouseCode;
inputDetail.ToWarehouseCode = entity.WarehouseCode;
inputDetail.ToLocationArea = detail.HandledToLocationArea;
inputDetail.ToLocationCode = detail.HandledToLocationCode;
inputDetail.ToLocationErpCode = detail.HandledToLocationErpCode;
inputDetail.ToLocationGroup = detail.HandledToLocationGroup;
inputDetail.ToLot = detail.HandledLot;
inputDetail.ToPackingCode = detail.HandledPackingCode;
inputDetail.ToWarehouseCode = detail.HandledToWarehouseCode;
inputDetail.Qty = detail.HandledQty;
inputDetail.HandledQty = detail.HandledQty;
inputDetail.StdPackQty = detail.StdPackQty;
inputDetail.ToStatus = detail.Status;
input.Details.Add(inputDetail);
}

94
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductionReturnRequestEventHandler.cs

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Forms;
using Omu.ValueInjecter;
using Volo.Abp.EventBus;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
@ -33,53 +34,8 @@ public class ProductionReturnRequestEventHandler
{
var entity = eventData.Entity;
//CreateMap<ProductionReturnRequest, ProductionReturnNoteEditInput>()
// .ForMember(x => x.JobNumber, y => y.MapFrom(d => d.Number))
// .ForMember(x => x.ReturnTime, y => y.MapFrom(d => d.CreationTime))
// .ForMember(x => x.Worker, y => y.MapFrom(d => d.Worker))
// .ForMember(x => x.ActiveDate, y => y.MapFrom(d => DateTime.Now))
// .Ignore(x => x.Number);
//CreateMap<ProductionReturnRequestDetail, ProductionReturnNoteDetailInput>()
// .ForMember(x => x.FromPackingCode, y => y.MapFrom(d => d.FromPackingCode))
// .ForMember(x => x.ToPackingCode, y => y.MapFrom(d => d.ToPackingCode))
// .ForMember(x => x.SupplierBatch, y => y.MapFrom(d => d.SupplierBatch))
// .ForMember(x => x.ArriveDate, y => y.MapFrom(d => d.ArriveDate))
// .ForMember(x => x.ProduceDate, y => y.MapFrom(d => d.ProduceDate))
// .ForMember(x => x.ExpireDate, y => y.MapFrom(d => d.ExpireDate))
// .ForMember(x => x.FromLot, y => y.MapFrom(d => string.Empty))
// .ForMember(x => x.ToLot, y => y.MapFrom(d => d.ToLot))
// .ForMember(x => x.ToContainerCode, y => y.MapFrom(d => d.ToContainerCode))
// .ForMember(x => x.FromContainerCode, y => y.MapFrom(d => d.FromContainerCode))
// .ForMember(x => x.FromStatus, y => y.MapFrom(d => d.FromStatus))
// .ForMember(x => x.ToStatus, y => y.MapFrom(d => d.ToStatus))
// .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty))
// .ForMember(x => x.FromLocationCode, y => y.MapFrom(d => d.FromLocationCode))
// .ForMember(x => x.FromLocationArea, y => y.MapFrom(d => d.ToLocationArea))
// .ForMember(x => x.FromLocationGroup, y => y.MapFrom(d => d.ToLocationGroup))
// .ForMember(x => x.FromLocationErpCode, y => y.MapFrom(d => d.ToLocationErpCode))
// .ForMember(x => x.FromWarehouseCode, y => y.MapFrom(d => d.ToWarehouseCode))
// .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty))
// .Ignore(x => x.ArriveDate)
// .Ignore(x => x.ToLocationCode)
// .Ignore(x => x.ToLocationArea)
// .Ignore(x => x.ToLocationGroup)
// .Ignore(x => x.ToLocationErpCode)
// .Ignore(x => x.ToWarehouseCode)
// .Ignore(x => x.HandledContainerCode)
// .Ignore(x => x.HandledPackingCode)
// .Ignore(x => x.HandledToLocationCode)
// .Ignore(x => x.HandledToLocationArea)
// .Ignore(x => x.HandledToLocationGroup)
// .Ignore(x => x.HandledToLocationErpCode)
// .Ignore(x => x.HandledToWarehouseCode)
// .Ignore(x => x.HandledExpireDate)
// .Ignore(x => x.HandledLot)
// .Ignore(x => x.HandledArriveDate)
// .Ignore(x => x.HandledProduceDate)
// .Ignore(x => x.HandledQty)
// .Ignore(x => x.HandledSupplierBatch);
if (entity.DirectCreateNote)
{
ProductionReturnNoteEditInput input = new ProductionReturnNoteEditInput();
input.InjectFrom(entity);
input.ReturnTime = DateTime.Now;
@ -93,9 +49,51 @@ public class ProductionReturnRequestEventHandler
inputdetail.Add(detail);
}
input.Details = inputdetail.ToList();
//插入记录
await _productionReturnNoteApp.CreateAsync(input).ConfigureAwait(false);
}
else
{
ProductionReturnJobEditInput input = new ProductionReturnJobEditInput();
input.InjectFrom(entity);
input.ProductionReturnRequestNumber = entity.Number;
input.JobType = EnumJobType.ProductionReturnJob;
input.JobStatus = EnumJobStatus.Open;
input.IsAutoComplete = entity.AutoCompleteJob;
List<ProductionReturnJobDetailInput> inputdetail = new List<ProductionReturnJobDetailInput>();
foreach (var itm in entity.Details)
{
ProductionReturnJobDetailInput detail = new ProductionReturnJobDetailInput();
detail.InjectFrom(itm);
detail.RecommendToLocationArea = itm.ToLocationArea;
detail.RecommendToLocationCode = itm.ToLocationCode;
detail.RecommendToLocationErpCode = itm.ToLocationErpCode;
detail.RecommendToLocationGroup = itm.ToLocationGroup;
detail.RecommendToWarehouseCode = itm.ToWarehouseCode;
detail.RecommendLot = itm.ToLot;
detail.RecommendPackingCode = itm.ToPackingCode;
detail.RecommendQty = itm.Qty;
detail.HandledToLocationArea = itm.ToLocationArea;
detail.HandledToLocationCode = itm.ToLocationCode;
detail.HandledToLocationErpCode = itm.ToLocationErpCode;
detail.HandledToLocationGroup = itm.ToLocationGroup;
detail.HandledToWarehouseCode = itm.ToWarehouseCode;
detail.HandledLot = itm.ToLot;
detail.HandledPackingCode = itm.ToPackingCode;
detail.HandledQty = itm.Qty;
detail.StdPackQty = itm.StdPackQty;
detail.Status = itm.ToStatus;
inputdetail.Add(detail);
}
input.Details = inputdetail.ToList();
input.WarehouseCode = entity.Details.Count > 0 ? entity.Details[0].ToWarehouseCode : " ";
//插入任务
await _productionReturnJobApp.CreateAsync(input).ConfigureAwait(false);
}
entity.Complete();
}
public virtual async Task HandleEventAsync(SfsAbortedEntityEventData<ProductionReturnRequest> eventData)
{

3
build/src/docker/publish/conf/settings/appsettings.Development.json

@ -114,7 +114,8 @@
"BaseUrl": "http://dev.ccwin-in.com:60083/"
},
"BaseData": {
"BaseUrl": "http://localhost:59094/"
//"BaseUrl": "http://localhost:59094/"
"BaseUrl": "http://dev.ccwin-in.com:60084/"
},
"Default": {
"BaseUrl": "http://dev.ccwin-in.com:60083/"

Loading…
Cancel
Save