Browse Source

更新版本

dev_DY_CC
赵新宇 1 year ago
parent
commit
71ac49b66f
  1. 9
      be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/ProductionReturnRequestController .cs
  2. 6
      be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/CustomerReturnNoteController.cs
  3. 5
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs
  4. 49
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs
  5. 12
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs
  6. 31
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs
  7. 86
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs

9
be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/ProductionReturnRequestController .cs

@ -23,6 +23,7 @@ public class ProductionReturnRequestController : AbpController
{
private readonly IProductionReturnJobAppService _productionReturnJobAppService;
private readonly IProductionReturnRequestAppService _productionReturnRequestAppService;
private readonly ICustomerProductionReturnNoteAppService _customerReturnAppService;
private readonly IUserWorkGroupAppService _userWorkGroupAppService;
@ -38,9 +39,11 @@ public class ProductionReturnRequestController : AbpController
IProductionReturnJobAppService productionReturnJobAppService
, IUserWorkGroupAppService userWorkGroupAppService
, ILocationAppService locationApp
, IProductionReturnRequestAppService productionReturnRequestAppService
, IProductionReturnRequestAppService productionReturnRequestAppService,
ICustomerProductionReturnNoteAppService customerReturnAppService
)
{
_customerReturnAppService = customerReturnAppService;
_productionReturnRequestAppService = productionReturnRequestAppService;
_userWorkGroupAppService = userWorkGroupAppService;
this._productionReturnJobAppService = productionReturnJobAppService;
@ -62,9 +65,9 @@ public class ProductionReturnRequestController : AbpController
[HttpPost("")]
public virtual async Task<ProductionReturnRequestDTO> CreateAsync(ProductionReturnRequestEditInput input)
public virtual async Task<CustomerProductionReturnNoteDTO> CreateAsync(CustomerProductionReturnNoteEditInput input)
{
return await _productionReturnRequestAppService.CreateAsync(input).ConfigureAwait(false);
return await _customerReturnAppService.CreateAsync(input).ConfigureAwait(false);
}

6
be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/CustomerReturnNoteController.cs

@ -12,14 +12,14 @@ namespace Win_in.Sfs.Wms.Pda.Controllers.Stores;
[Route($"{PdaHostConst.ROOT_ROUTE}store/return-from-customer")]
public class CustomerReturnNoteController : AbpController
{
private readonly ICustomerReturnNoteAppService _customerReturnNoteAppService;
private readonly ICustomerProductionReturnNoteAppService _customerReturnNoteAppService;
/// <summary>
///
/// </summary>
/// <param name="customerReturnNoteAppService"></param>
public CustomerReturnNoteController(
ICustomerReturnNoteAppService customerReturnNoteAppService)
ICustomerProductionReturnNoteAppService customerReturnNoteAppService)
{
_customerReturnNoteAppService = customerReturnNoteAppService;
}
@ -30,7 +30,7 @@ public class CustomerReturnNoteController : AbpController
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("")]
public virtual async Task<CustomerReturnNoteDTO> CreateAsync(CustomerReturnNoteEditInput input)
public virtual async Task<CustomerProductionReturnNoteDTO> CreateAsync(CustomerProductionReturnNoteEditInput input)
{
return await _customerReturnNoteAppService.CreateAsync(input).ConfigureAwait(false);
}

5
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs

@ -324,6 +324,11 @@ public class BomManager : DomainService, IBomManager
private async Task<List<BomComponent>> GetComponentsByProduct(string product)
{
List<Bom> list=new List<Bom>();
if (Cache.Boms.Count == 0)
{
InitBomComponent();
}
list=Cache.Boms.Count > 0 ? Cache.Boms.Where(p => p.Product == product).ToList() :
await _repository.GetListAsync(p => p.Product == product).ConfigureAwait(false);
List<BomComponent> components = new List<BomComponent>();

49
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs

@ -8,6 +8,53 @@ using Win_in.Sfs.Basedata.Domain;
namespace Win_in.Sfs.Basedata.Caches;
public static class Cache
{
public static List<Bom> Boms = new List<Bom>();
public static List<Bom> Boms = new List<Bom>();
public static async void BomsLifeCycle(int lifetime)
{
var reassigner = new Reassigner(DateTime.Now,new TimeSpan(0,5,0));
await reassigner.RunAsync(() => {
Boms.Clear();
}).ConfigureAwait(false);
}
}
public class Reassigner
{
private readonly TimeSpan _interval;
private DateTime _lasttime;
public Reassigner(DateTime lasttime, TimeSpan interval)
{
_lasttime = lasttime;
_interval = interval;
}
public async Task RunAsync(Action p_action)
{
while (true)
{
// 获取当前时间
var currentTime = DateTime.Now;
// 计算上次重新赋值到现在的时间间隔
var elapsed = currentTime - _lasttime;
// 检查时间间隔是否满足条件
if (elapsed >= _interval)
{
p_action();
// 重新赋值
//_value = await GetValueAsync();
// 更新最后更新时间
_lasttime = currentTime;
}
// 等待下一刻钟
await Task.Delay(_interval);
}
}
}

12
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs

@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
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;
@ -37,6 +38,17 @@ public class CustomerProductionReturnNoteAppService :
public override async Task<CustomerProductionReturnNoteDTO> CreateAsync(CustomerProductionReturnNoteEditInput input)
{
var entity = ObjectMapper.Map<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>(input);
foreach (var itm in entity.Details)
{
itm.FromLocationCode = "HOLD";
itm.FromStatus = EnumInventoryStatus.OK;
itm.ToStatus=EnumInventoryStatus.OK;
}
await _CustomerProductionReturnNoteManager.CreateAsync(entity).ConfigureAwait(false);
var dto = ObjectMapper.Map<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO>(entity);
return dto;

31
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs

@ -1,6 +1,7 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
namespace Win_in.Sfs.Wms.Store.Event;
@ -10,14 +11,38 @@ public partial class StoreEventAutoMapperProfile : Profile
private void CustomerProductionReturnNoteAutoMapperProfile()
{
CreateMap<CustomerProductionReturnNoteDetail, TransferLogEditInput>()
.Ignore(x => x.Worker)
.Ignore(x => x.TransType)
.Ignore(x => x.DocNumber)
.Ignore(x => x.JobNumber)
.Ignore(x => x.ExtraProperties)
.Ignore(x => x.TransSubType)
;
.ForMember(x => x.DocNumber, y => y.MapFrom(t => t.Number))
.Ignore(x => x.JobNumber)
CreateMap<CustomerProductionReturnNoteDetail, TransactionEditInput>()
.ForMember(x => x.PackingCode, y => y.MapFrom(d => d.ToPackingCode))
.ForMember(x => x.ContainerCode, y => y.MapFrom(d => d.ToContainerCode))
.ForMember(x => x.Lot, y => y.MapFrom(d => d.ToLot))
.ForMember(x => x.Status, y => y.MapFrom(d => d.ToStatus))
.ForMember(x => x.LocationCode, y => y.MapFrom(d => d.ToLocationCode))
.ForMember(x => x.LocationArea, y => y.MapFrom(d => d.ToLocationArea))
.ForMember(x => x.LocationGroup, y => y.MapFrom(d => d.ToLocationGroup))
.ForMember(x => x.LocationErpCode, y => y.MapFrom(d => d.ToLocationErpCode))
.ForMember(x => x.WarehouseCode, y => y.MapFrom(d => d.ToWarehouseCode))
.Ignore(x => x.Worker)
.Ignore(x => x.TransType)
.Ignore(x => x.ExtraProperties)
.Ignore(x => x.DocNumber)
.Ignore(x => x.JobNumber)
.Ignore(x => x.ManageType)
.Ignore(x => x.TransType)
.Ignore(x => x.TransSubType)
.Ignore(x => x.TransInOut)
;
CreateMap<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO>()
.ReverseMap();
CreateMap<CustomerProductionReturnNoteDetail, CustomerProductionReturnNoteDetailDTO>();
}
}

86
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs

@ -8,6 +8,7 @@ using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Domain.Shared;
using Win_in.Sfs.Wms.Store.Event.Transaction;
namespace Win_in.Sfs.Wms.Store.Event.Transactions;
@ -17,78 +18,83 @@ public class CustomerProductionReturnNoteEventHandler
, ILocalEventHandler<SfsCreatedEntityEventData<CustomerProductionReturnNote>>
, ILocalEventHandler<SfsCreatedEntityEventData<List<CustomerProductionReturnNote>>>
{
private const EnumTransType TransType = EnumTransType.CustomerReturn;
private readonly IProductionReturnRequestAppService _productionReturnRequestApp;
public CustomerProductionReturnNoteEventHandler(IProductionReturnRequestAppService productionReturnRequestApp)
{
this._productionReturnRequestApp = productionReturnRequestApp;
}
private const EnumTransInOut TransInOut = EnumTransInOut.In;
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<CustomerProductionReturnNote> eventData)
{
var entity = eventData.Entity;
await AddTransactionsAsync(entity).ConfigureAwait(false);
if (!string.IsNullOrEmpty(entity.ProductionReturnRequestNumber))
{
await _productionReturnRequestApp.CompleteByNumberAsync(entity.ProductionReturnRequestNumber).ConfigureAwait(false);
}
await AddTransactionsAsync(entity).ConfigureAwait(false);
}
private async Task AddTransactionsAsync(CustomerProductionReturnNote CustomerProductionReturnNote)
{
var inboundTransactions = new List<TransferLogEditInput>();
////如果WMS管理客户寄售库,生成库存转移
//if (await SettingManager.IsTrueAsync(StoreSettings.Common.EnableCustomerLocation).ConfigureAwait(false))
//{
inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote));
// var transferLogs = BuildTransferLogs(CustomerProductionReturnNote);
// await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false);
//}
//else //如果WMS不管理客户寄售库,生成入库
//{
}
var transactions = BuildTransactions(CustomerProductionReturnNote);
await TransactionAppService.AddManyAsync(transactions).ConfigureAwait(false);
//}
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<CustomerProductionReturnNote>> eventData)
{
var entities = eventData.Entity;
await AddTransactionsAsync(entities).ConfigureAwait(false);
}
private async Task AddTransactionsAsync(List<CustomerProductionReturnNote> CustomerProductionReturnNotes)
/// <summary>
/// 构造 库存转移日志实体
/// </summary>
/// <param name="CustomerProductionReturnNote"></param>
/// <returns></returns>
private List<TransferLogEditInput> BuildTransferLogs(CustomerProductionReturnNote CustomerProductionReturnNote)
{
var inboundTransactions = new List<TransferLogEditInput>();
var transferLogCreateInputs = new List<TransferLogEditInput>();
//如果要做库存事务汇总,可以修改此处
foreach (var CustomerProductionReturnNote in CustomerProductionReturnNotes)
foreach (var detail in CustomerProductionReturnNote.Details.Where(detail => detail.Qty != 0))
{
inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote));
var transferLog = ObjectMapper.Map<CustomerProductionReturnNoteDetail, TransferLogEditInput>(detail);
transferLog.TransType = TransType;
transferLog.Worker = CustomerProductionReturnNote.Worker;
transferLog.DocNumber = CustomerProductionReturnNote.Number;
transferLog.JobNumber = CustomerProductionReturnNote.JobNumber;
transferLogCreateInputs.Add(transferLog);
}
await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false);
return transferLogCreateInputs;
}
private List<TransferLogEditInput> BuildTransferLogs(CustomerProductionReturnNote CustomerProductionReturnNote)
private List<TransactionEditInput> BuildTransactions(CustomerProductionReturnNote CustomerProductionReturnNote)
{
var transferLogs = new List<TransferLogEditInput>();
foreach (var detail in CustomerProductionReturnNote.Details.Where(detail => detail.Qty != 0))
var transactions = new List<TransactionEditInput>();
foreach (var detail in CustomerProductionReturnNote.Details)
{
var transferLog = ObjectMapper.Map<CustomerProductionReturnNoteDetail, TransferLogEditInput>(detail);
var transaction = ObjectMapper.Map<CustomerProductionReturnNoteDetail, TransactionEditInput>(detail);
transferLog.TransType = TransType;
transaction.TransType = TransType;
transaction.TransInOut = TransInOut;
transferLog.Worker = CustomerProductionReturnNote.Worker;
transferLog.DocNumber = CustomerProductionReturnNote.Number;
transferLog.JobNumber = CustomerProductionReturnNote.JobNumber;
transaction.Worker = CustomerProductionReturnNote.Worker;
transaction.DocNumber = CustomerProductionReturnNote.Number;
transaction.JobNumber = CustomerProductionReturnNote.JobNumber;
transaction.Status = EnumInventoryStatus.OK;
transferLogs.Add(transferLog);
transactions.Add(transaction);
}
return transferLogs;
return transactions;
}
public Task HandleEventAsync(SfsCreatedEntityEventData<List<CustomerProductionReturnNote>> eventData)
{
throw new System.NotImplementedException();
}
}

Loading…
Cancel
Save