From 89524f37ce3a242fae5de1e773526b3d7aca184a Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Mon, 8 Apr 2024 16:31:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ERP=E5=BA=93=E4=BD=8D?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataExchangeDapperFawtygModule.cs | 2 + .../ErpLocationLinq2DbRepository.cs | 13 +++ .../TyrpDb.cs | 1 + .../ErpLocation/ErpLocationManager.cs | 22 ++++ .../IErpLocationLinq2DbRepository.cs | 6 + .../ErpLocation/IErpLocationManager.cs | 9 ++ .../ErpLocation/locmout.cs | 21 ++++ .../Incoming/ErpLocationConverter.cs | 69 ++++++++++++ .../Incoming/ErpLocationReader.cs | 106 ++++++++++++++++++ .../WMS/ErpLocation/ErpLocationExchangeDto.cs | 48 ++++++++ 10 files changed, 297 insertions(+) create mode 100644 be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/ErpLocation/ErpLocationLinq2DbRepository.cs create mode 100644 be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/ErpLocationManager.cs create mode 100644 be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/IErpLocationLinq2DbRepository.cs create mode 100644 be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/IErpLocationManager.cs create mode 100644 be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/locmout.cs create mode 100644 be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationConverter.cs create mode 100644 be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationReader.cs create mode 100644 be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/ErpLocation/ErpLocationExchangeDto.cs diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/DataExchangeDapperFawtygModule.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/DataExchangeDapperFawtygModule.cs index 93c8a6cae..a7ec816a6 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/DataExchangeDapperFawtygModule.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/DataExchangeDapperFawtygModule.cs @@ -10,6 +10,7 @@ using Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.Backflushs; using Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.Boms; using Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.Customers; using Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.Dictpjs; +using Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.ErpLocations; using Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.Products; using Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.PurchasePrices; using Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.SalePrices; @@ -46,6 +47,7 @@ public class DataExchangeDapperFawtygModule : AbpModule context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); + context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/ErpLocation/ErpLocationLinq2DbRepository.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/ErpLocation/ErpLocationLinq2DbRepository.cs new file mode 100644 index 000000000..ddef90a3f --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/ErpLocation/ErpLocationLinq2DbRepository.cs @@ -0,0 +1,13 @@ +using Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp; +using Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp.Bases; +using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; + +namespace Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.ErpLocations; + +public class ErpLocationLinq2DbRepository : Linq2DbCrudRepository, IErpLocationLinq2DbRepository +{ + public ErpLocationLinq2DbRepository(TyrpDb tyrpDb) : base(tyrpDb) + { + + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/TyrpDb.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/TyrpDb.cs index e59acea0b..4c684d0f7 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/TyrpDb.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp/TyrpDb.cs @@ -18,6 +18,7 @@ public class TyrpDb : DataConnection, ITransientDependency public ITable Supplier => this.GetTable(); public ITable Dictpj => this.GetTable(); public ITable Customer => this.GetTable(); + public ITable ErpLocation => this.GetTable(); public ITable PurchasePrice => this.GetTable(); public ITable SalePrice => this.GetTable(); public ITable Backflu => this.GetTable(); diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/ErpLocationManager.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/ErpLocationManager.cs new file mode 100644 index 000000000..2565a82e5 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/ErpLocationManager.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Domain.Services; + +namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; + +public class ErpLocationManager : DomainService, IErpLocationManager +{ + private readonly IErpLocationLinq2DbRepository _repository; + + public ErpLocationManager(IErpLocationLinq2DbRepository repository) + { + _repository = repository; + } + public virtual async Task> GetToBeProcessedListAsync() + { + var products = await _repository.GetListAsync().ConfigureAwait(false); + return products.ToList(); + + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/IErpLocationLinq2DbRepository.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/IErpLocationLinq2DbRepository.cs new file mode 100644 index 000000000..8cf9d880b --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/IErpLocationLinq2DbRepository.cs @@ -0,0 +1,6 @@ +namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; + +public interface IErpLocationLinq2DbRepository : ILinq2DbRepository +{ + +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/IErpLocationManager.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/IErpLocationManager.cs new file mode 100644 index 000000000..b25390474 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/IErpLocationManager.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; + +public interface IErpLocationManager +{ + Task> GetToBeProcessedListAsync(); +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/locmout.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/locmout.cs new file mode 100644 index 000000000..c71f0d524 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp/ErpLocation/locmout.cs @@ -0,0 +1,21 @@ +using Volo.Abp.Domain.Entities; + +namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; + +public class locmout : Entity +{ + /// + /// 库位 + /// + public string locmout_loc { get; set; } + /// + /// 库位类型 + /// + public string locmout_stat2 { get; set; } + + + public override object[] GetKeys() + { + return new object[] { locmout_loc }; + } +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationConverter.cs new file mode 100644 index 000000000..10b6b2b0d --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationConverter.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Volo.Abp.ObjectMapping; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Wms.DataExchange.Domain; +using Win_in.Sfs.Wms.DataExchange.WMS.ErpLocation; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Incoming; + +public class ErpLocationConverter : IIncomingConverter +{ + private readonly IIncomingToWmsManager _incomingToWmsManager; + private readonly IObjectMapper _objectMapper; + private readonly ILogger _logger; + private readonly IIncomingFromExternalManager _incomingFromExternalManager; + + public ErpLocationConverter( + IIncomingToWmsManager incomingToWmsManager + , IObjectMapper objectMapper + , ILogger logger, + IIncomingFromExternalManager incomingFromExternalManager) + { + _incomingToWmsManager = incomingToWmsManager; + _objectMapper = objectMapper; + _logger = logger; + _incomingFromExternalManager = incomingFromExternalManager; + } + + public virtual async Task ConvertAsync(List incomingFromExternalList) + { + if (!incomingFromExternalList.Any()) + { + _logger.LogInformation("No ErpLocations"); + return; + } + + //按流水号创建单据 + var erpLocationRequestList = await BuildIncomingToWmsOfErpLocationRequestAsync(incomingFromExternalList).ConfigureAwait(false); + await _incomingToWmsManager.CreateManyAsync(erpLocationRequestList).ConfigureAwait(false); + //归档 + await _incomingFromExternalManager.ArchiveManyAsync(incomingFromExternalList).ConfigureAwait(false); + } + + private async Task> BuildIncomingToWmsOfErpLocationRequestAsync(List incomingDataList) + { + await Task.CompletedTask.ConfigureAwait(false); + var incomingToWmsList = new List(); + foreach (var item in incomingDataList) + { + var incomingToWms = new IncomingToWms() + { + DataType = item.DataType, + DataAction = item.DataAction, + SourceSystem = item.SourceSystem, + DataIdentityCode = item.SourceDataGroupCode, + }; + incomingToWms.SetEffectiveDate(item.EffectiveDate); + var exchangeErpLocationRequest = JsonSerializer.Deserialize(item.DestinationDataContent); + var wmsErpLocationRequest = _objectMapper.Map(exchangeErpLocationRequest); + incomingToWms.DataContent = JsonSerializer.Serialize(wmsErpLocationRequest); + incomingToWmsList.Add(incomingToWms); + } + return incomingToWmsList; + } + +} diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationReader.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationReader.cs new file mode 100644 index 000000000..c56546a43 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Incoming/ErpLocationReader.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Win_in.Sfs.Wms.DataExchange.Domain; +using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; +using Win_in.Sfs.Wms.DataExchange.Domain.Shared; +using Win_in.Sfs.Wms.DataExchange.WMS.ErpLocation; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Incoming; + +public class ErpLocationReader : IReader +{ + private readonly IErpLocationManager _erpLocationManager; + private readonly IIncomingFromExternalManager _incomingFromExternalManager; + private readonly ILogger _logger; + + public ErpLocationReader( + IErpLocationManager erpLocationManager + , IIncomingFromExternalManager incomingFromExternalManager + , ILogger logger + ) + { + _erpLocationManager = erpLocationManager; + _incomingFromExternalManager = incomingFromExternalManager; + _logger = logger; + } + + public virtual async Task> ReadAsync() + { + //从MES读取待处理locmout + var toBeProcessedDatas = await _erpLocationManager.GetToBeProcessedListAsync().ConfigureAwait(false); + if (!toBeProcessedDatas.Any()) + { + _logger.LogInformation("no erpLocations"); + return new List(); + } + //locmout逐一转换为ErpLocation + var incomingDataList = BuildIncomingFromExternalFromShipAsync(toBeProcessedDatas); + await _incomingFromExternalManager.CreateManyAsync(incomingDataList).ConfigureAwait(false); + + return incomingDataList; + } + + private static List BuildIncomingFromExternalFromShipAsync(List toBeProcessedDatas) + { + var incomingDataList = new List(); + foreach (var item in toBeProcessedDatas) + { + var incomingData = BuildIncomingFromExternal(item); + + incomingData.SetEffectiveDate(DateTime.Now); + incomingData.SetSuccess(); + try + { + var erpLocationNote = BuildErpLocationCreateInput(item); + incomingData.DestinationDataContent = JsonSerializer.Serialize(erpLocationNote); + } + catch (Exception ex) + { + incomingData.SetError(EnumExchangeDataErrorCode.Exception, ex.Message, ex.ToString()); + } + + incomingDataList.Add(incomingData); + + } + + return incomingDataList; + } + + private static IncomingFromExternal BuildIncomingFromExternal(locmout locmout) + { + var incomingData = new IncomingFromExternal() + { + DataType = EnumIncomingDataType.ErpLocation.ToString(), + DataAction = EnumExchangeDataAction.Add, + SourceSystem = EnumSystemType.ERP.ToString(), + SourceDataId = locmout.locmout_loc, + SourceDataGroupCode = locmout.locmout_loc, + SourceDataDetailCode = locmout.locmout_loc, + SourceDataContent = JsonSerializer.Serialize(locmout), + WriteTime = DateTime.Now, + Writer = nameof(TyrpIncomingBackgroundWorker), + + DestinationSystem = EnumSystemType.WMS.ToString(), + }; + return incomingData; + } + + private static ErpLocationExchangeDto BuildErpLocationCreateInput(locmout locmout) + { + + var erpLocation = new ErpLocationExchangeDto() + { + Code = locmout.locmout_loc, + Name = locmout.locmout_loc, + Type = locmout.locmout_stat2, + WarehouseCode = locmout.locmout_stat2, + + }; + return erpLocation; + } + +} diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/ErpLocation/ErpLocationExchangeDto.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/ErpLocation/ErpLocationExchangeDto.cs new file mode 100644 index 000000000..e9a9eb19b --- /dev/null +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Application.Contracts/WMS/ErpLocation/ErpLocationExchangeDto.cs @@ -0,0 +1,48 @@ +using System.ComponentModel.DataAnnotations; +using Win_in.Sfs.Shared.Domain; + +namespace Win_in.Sfs.Wms.DataExchange.WMS.ErpLocation; + +public class ErpLocationExchangeDto +{ + /// + /// 代码 + /// + + [Display(Name = "代码")] + [Required] + [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] + public string Code { get; set; } + + /// + /// 名称 + /// + [Display(Name = "名称")] + [Required(ErrorMessage = "{0}是必填项")] + [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] + public string Name { get; set; } + + /// + /// 描述 + /// + [Display(Name = "描述")] + [StringLength(SfsEfCorePropertyConst.NameLength, ErrorMessage = "{0}最多输入{1}个字符")] + public string Description { get; set; } + + /// + /// 类型 + /// + [Display(Name = "类型")] + [Required(ErrorMessage = "{0}是必填项")] + [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] + public string Type { get; set; } + + /// + /// 仓库代码 + /// + [Display(Name = "仓库代码")] + [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] + public string WarehouseCode { get; set; } + + +} From 891f01cf87c208a3e25bb005159672209ee58d69 Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Mon, 8 Apr 2024 17:22:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0BOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Boms/BomAppService.cs | 6 ++ .../Commons/Cache.cs | 73 ++++++++++++++ .../Win_in.Sfs.Basedata.Domain/Boms/Bom.cs | 2 + .../Boms/BomManager.cs | 91 ++++-------------- .../Caches/Cache.cs | 13 +++ .../Enums/Inventory/EnumTransType.cs | 4 + .../Enums/Store/Statuses/EnumRequestStatus.cs | 17 ++++ ...CustomerProductionReturnNotePermissions.cs | 20 ++++ .../DTOs/CustomerProductionReturnNoteDTO.cs | 29 ++++++ .../CustomerProductionReturnNoteDetailDTO.cs | 9 ++ ...ICustomerProductionReturnNoteAppService.cs | 9 ++ ...CustomerProductionReturnNoteDetailInput.cs | 9 ++ .../CustomerProductionReturnNoteEditInput.cs | 47 ++++++++++ ...CustomerProductionReturnNoteImportInput.cs | 34 +++++++ .../CustomerProductionReturnNoteAppService.cs | 47 ++++++++++ ...erProductionReturnNoteAutoMapperProfile.cs | 34 +++++++ .../StoreApplicationAutoMapperProfile.cs | 1 + .../CustomerProductionReturnNote.cs | 33 +++++++ .../CustomerProductionReturnNoteDetail.cs | 8 ++ .../CustomerProductionReturnNoteManager.cs | 12 +++ .../ICustomerProductionReturnNoteManager.cs | 5 + ...ICustomerProductionReturnNoteRepository.cs | 5 + ...urnNoteDbContextModelCreatingExtensions.cs | 49 ++++++++++ ...merProductionReturnNoteEfCoreRepository.cs | 13 +++ .../StoreDbContextModelCreatingExtensions.cs | 1 + .../StoreEntityFrameworkCoreModule.cs | 7 +- ...erProductionReturnNoteAutoMapperProfile.cs | 23 +++++ .../StoreEventAutoMapperProfile.cs | 1 + ...ustomerProductionReturnNoteEventHandler.cs | 94 +++++++++++++++++++ 29 files changed, 619 insertions(+), 77 deletions(-) create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/Cache.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNotePermissions.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDTO.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDetailDTO.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteAppService.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteDetailInput.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteEditInput.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteImportInput.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAutoMapperProfile.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNote.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDetail.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteManager.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteManager.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteRepository.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDbContextModelCreatingExtensions.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteEfCoreRepository.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Boms/BomAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Boms/BomAppService.cs index b5241d1a0..41e51c39a 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Boms/BomAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Boms/BomAppService.cs @@ -25,6 +25,8 @@ public class BomAppService : private new readonly IBomRepository _repository; private readonly IBomManager _bomManager; + List _bomList=new List(); + public BomAppService(IBomRepository repository , IBomManager bomManager , IDistributedCache cache @@ -35,8 +37,12 @@ public class BomAppService : base.CreatePolicyName = BomPermissions.Create; base.UpdatePolicyName = BomPermissions.Update; base.DeletePolicyName = BomPermissions.Delete; + } + + + diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/Cache.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/Cache.cs new file mode 100644 index 000000000..b657c4429 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain.Shared/Commons/Cache.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using System.Collections.Generic; + +namespace Win_in.Sfs.Basedata.Domain.Shared; + +public class SingletonCacheList +{ + private static volatile SingletonCacheList instance; + private static object syncRoot = new object(); + private List cacheList; + + private SingletonCacheList() + { + cacheList = new List(); + } + + public static SingletonCacheList Instance + { + get + { + if (instance == null) + { + lock (syncRoot) + { + if (instance == null) + { + instance = new SingletonCacheList(); + } + } + } + + return instance; + } + } + + public void Add(T item) + { + cacheList.Add(item); + } + + public void Remove(T item) + { + cacheList.Remove(item); + } + + public bool Contains(T item) + { + return cacheList.Contains(item); + } + + public T this[int index] + { + get + { + return cacheList[index]; + } + set + { + cacheList[index] = value; + } + } + public int Count() + { + return cacheList.Count(); + } +} + + diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/Bom.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/Bom.cs index ac2a6187e..2250c5ae8 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/Bom.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/Bom.cs @@ -83,3 +83,5 @@ public class Bom : SfsBaseDataAggregateRootBase, IHasTimeRange /// public EnumPlannedSplitRule PlannedSplitRule { get; set; } } + + diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs index d5087c034..a0f2f3978 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs @@ -10,6 +10,7 @@ using Volo.Abp; using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; using Win_in.Sfs.Basedata.Boms; +using Win_in.Sfs.Basedata.Caches; using Win_in.Sfs.Basedata.Domain.Shared; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; @@ -20,11 +21,20 @@ public class BomManager : DomainService, IBomManager { private readonly IBomRepository _repository; private readonly IItemBasicRepository _itemBasicRepository; - + public BomManager(IBomRepository repository, IItemBasicRepository itemBasicRepository) { _repository = repository; _itemBasicRepository = itemBasicRepository; + InitBomComponent(); + } + private void InitBomComponent() + { + int count = _repository.CountAsync().Result; + if (Cache.Boms.Count!=count) + { + Cache.Boms=_repository.ToListAsync().Result; + } } /// @@ -74,7 +84,6 @@ public class BomManager : DomainService, IBomManager } } - return totalBoms; } @@ -255,27 +264,7 @@ public class BomManager : DomainService, IBomManager dimensionList.Add(rs1); }).ConfigureAwait(false); - //List lastBomList = new List(); - //List dimensionBomList = new List(); - //List treeBomList = new List(); - //foreach (var itm in dimensionList) - //{ - // Bom bom = new Bom(); - // bom.InjectFrom(itm); - // dimensionBomList.Add(bom); - //} - //foreach (var itm in lastList) - //{ - // Bom bom = new Bom(); - // bom.InjectFrom(itm); - // lastBomList.Add(bom); - //} - //foreach (var itm in treeList) - //{ - // Bom bom = new Bom(); - // bom.InjectFrom(itm); - // treeBomList.Add(bom); - //} + List returnList=new List(); switch (p_type) { @@ -291,31 +280,7 @@ public class BomManager : DomainService, IBomManager } return returnList; } - //private static List BomComponents = new List(); - - - //private static List GetBomComponents() - //{ - // if(BomComponents.Any() && ) - - // var lst = await _repository.GetListAsync(p => p.Product == productCode).ConfigureAwait(false); - //} - - - - - /// - /// 层级、拆解、一维结构、树状结构 - /// - /// 上级组件(初始时为根元素) - /// 层级一般为1 - /// 累计数量 - /// 根 - /// 拆解到最终零件时 - /// 树型转成一维表用 - /// - - + /// @@ -336,17 +301,6 @@ public class BomManager : DomainService, IBomManager { List subComponents = new List(); // 假设 GetComponentsByProduct 方法可获取某个物料号下的所有子零件 - - //if (bomList != null && bomList.Count() > 0) - //{ - // = bomList.Where(p => p.Product == p_component.Component) - //} - //else - //{ - // directSubComponents = await GetComponentsByProduct(p_component.Component).ConfigureAwait(false); - //} - - List directSubComponents =await GetComponentsByProduct(p_component.Component).ConfigureAwait(false); if (!directSubComponents.Any() && level != 1)//不是根元素 @@ -367,22 +321,11 @@ public class BomManager : DomainService, IBomManager return subComponents; } - - - - - - - - - - - - private async Task> GetComponentsByProduct(string product) { - - var list= await _repository.GetListAsync(p => p.Product == product).ConfigureAwait(false); + List list=new List(); + list=Cache.Boms.Count > 0 ? Cache.Boms.Where(p => p.Product == product).ToList() : + await _repository.GetListAsync(p => p.Product == product).ConfigureAwait(false); List components = new List(); foreach (var component in list) { @@ -390,8 +333,6 @@ public class BomManager : DomainService, IBomManager bomComponent.InjectFrom(component); components.Add(bomComponent); } - - // 其他物料号的子零件信息类似添加 return components; } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs new file mode 100644 index 000000000..718bb501c --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Win_in.Sfs.Basedata.Domain; + +namespace Win_in.Sfs.Basedata.Caches; +public static class Cache +{ + public static List Boms = new List(); + +} diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransType.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransType.cs index f1259ee84..567d76ef7 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransType.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransType.cs @@ -157,4 +157,8 @@ public enum EnumTransType /// [Display(Name = "初始化")] Initial = 99, + + + + } diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumRequestStatus.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumRequestStatus.cs index 3d172e8a2..397d7354c 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumRequestStatus.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Statuses/EnumRequestStatus.cs @@ -63,4 +63,21 @@ public enum EnumRequestStatus /// [Display(Name = "部分完成")] Partial = 9, + + + /// + /// 部分完成 + /// + [Display(Name = "已过时")] + Deprecated = 10, + + /// + /// 有更新 + /// + [Display(Name = "有更新")] + Updated = 10, + + + + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNotePermissions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNotePermissions.cs new file mode 100644 index 000000000..41f8db7e8 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNotePermissions.cs @@ -0,0 +1,20 @@ +using Volo.Abp.Authorization.Permissions; +using Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +public static class CustomerProductionReturnNotePermissions +{ + public const string Default = StorePermissions.GroupName + "." + nameof(CustomerProductionReturnNote); + public const string Create = Default + "." + StorePermissions.CreateStr; + public const string Update = Default + "." + StorePermissions.UpdateStr; + public const string Delete = Default + "." + StorePermissions.DeleteStr; + + public static void AddCustomerProductionReturnNotePermission(this PermissionGroupDefinition permissionGroup) + { + var CustomerProductionReturnNotePermission = permissionGroup.AddPermission(Default, StorePermissionDefinitionProvider.L(nameof(CustomerProductionReturnNote))); + CustomerProductionReturnNotePermission.AddChild(Create, StorePermissionDefinitionProvider.L(StorePermissions.CreateStr)); + CustomerProductionReturnNotePermission.AddChild(Update, StorePermissionDefinitionProvider.L(StorePermissions.UpdateStr)); + CustomerProductionReturnNotePermission.AddChild(Delete, StorePermissionDefinitionProvider.L(StorePermissions.DeleteStr)); + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDTO.cs new file mode 100644 index 000000000..a2bdba696 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDTO.cs @@ -0,0 +1,29 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +/// +/// 退库记录-实体DTO +/// +[Display(Name = "退库记录")] +public class CustomerProductionReturnNoteDTO : SfsStoreDTOBase +{ + /// + /// 任务ID + /// + [Display(Name = "任务ID")] + public string JobNumber { get; set; } + + /// + /// 退料单号 + /// + [Display(Name = "退料单号")] + public string ProductionReturnRequestNumber { get; set; } + + /// + /// 退料时间 + /// + [Display(Name = "退料时间")] + public DateTime ReturnTime { get; set; } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDetailDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDetailDTO.cs new file mode 100644 index 000000000..83beb7578 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/DTOs/CustomerProductionReturnNoteDetailDTO.cs @@ -0,0 +1,9 @@ +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +/// +/// 退库记录-明细表-实体DTO +/// +public class CustomerProductionReturnNoteDetailDTO : SfsStoreRecommendToDetailWithFromToDTOBase +{ + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteAppService.cs new file mode 100644 index 000000000..1571600e7 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteAppService.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +public interface ICustomerProductionReturnNoteAppService : + ISfsStoreMasterReadOnlyAppServiceBase +{ + Task CreateAsync(CustomerProductionReturnNoteEditInput input); +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteDetailInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteDetailInput.cs new file mode 100644 index 000000000..e8b1ad57a --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteDetailInput.cs @@ -0,0 +1,9 @@ +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +/// +/// 退库记录-明细表-实体DTO +/// +public class CustomerProductionReturnNoteDetailInput : SfsStoreRecommendToDetailWithFromToDTOBase +{ + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteEditInput.cs new file mode 100644 index 000000000..57043a289 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteEditInput.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Win_in.Sfs.Shared.Domain; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +/// +/// 退库记录-新增和更新基础DTO +/// +public class CustomerProductionReturnNoteEditInput : SfsStoreCreateOrUpdateInputBase +{ + #region Base + /// + /// 任务ID + /// + [Display(Name = "任务ID")] + public string JobNumber { get; set; } + + /// + /// 退料时间 + /// + [Display(Name = "退料时间")] + public DateTime ReturnTime { get; set; } + + /// + /// 退料申请单号 + /// + [Display(Name = "退料申请单号")] + public string ProductionReturnRequestNumber { get; set; } + #endregion + + #region Create + /// + /// 退库记录单号 + /// + [Display(Name = "退库记录单号")] + [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] + public string Number { get; set; } + + /// + /// 明细列表 + /// + [Display(Name = "明细列表")] + public List Details { get; set; } + #endregion +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteImportInput.cs new file mode 100644 index 000000000..7a307acb5 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/CustomerProductionReturnNotes/Inputs/CustomerProductionReturnNoteImportInput.cs @@ -0,0 +1,34 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace Win_in.Sfs.Wms.Store.Application.Contracts; + +/// +/// 退库记录-实体DTO +/// +public class CustomerProductionReturnNoteImportInput : SfsStoreImportInputBase +{ + /// + /// 任务ID + /// + [Display(Name = "任务ID")] + public string JobNumber { get; set; } + + /// + /// 退料时间 + /// + [Display(Name = "退料时间")] + public DateTime ReturnTime { get; set; } + + /// + /// 退料单号 + /// + [Display(Name = "退料单号")] + public string ProductionReturnRequestNumber { get; set; } + + /// + /// 采购订单号 + /// + [Display(Name = "采购订单号")] + public string PoNumber { get; set; } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs new file mode 100644 index 000000000..5a239fbf0 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs @@ -0,0 +1,47 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; +using Win_in.Sfs.Wms.Store.Domain.Shared; + +namespace Win_in.Sfs.Wms.Store.Application; + +/// +/// 退库记录 +/// +[Authorize] +[Route($"{StoreConsts.RootPath}customer-production-return-note")] +public class CustomerProductionReturnNoteAppService : + SfsStoreWithDetailsAppServiceBase, + ICustomerProductionReturnNoteAppService +{ + private readonly ICustomerProductionReturnNoteManager _CustomerProductionReturnNoteManager; + + public CustomerProductionReturnNoteAppService( + ICustomerProductionReturnNoteRepository repository + , ICustomerProductionReturnNoteManager CustomerProductionReturnNoteManager + ) : base(repository) + { + _CustomerProductionReturnNoteManager = CustomerProductionReturnNoteManager; + } + + /// + /// 新增实体 + /// + /// + /// + [HttpPost("")] + //[Authorize(CustomerProductionReturnNotePermissions.Create)] + public override async Task CreateAsync(CustomerProductionReturnNoteEditInput input) + { + var entity = ObjectMapper.Map(input); + await _CustomerProductionReturnNoteManager.CreateAsync(entity).ConfigureAwait(false); + var dto = ObjectMapper.Map(entity); + return dto; + } + + + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAutoMapperProfile.cs new file mode 100644 index 000000000..d8a6ef92b --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAutoMapperProfile.cs @@ -0,0 +1,34 @@ +using AutoMapper; +using Volo.Abp.AutoMapper; +using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Wms.Store.Application; + +public partial class StoreApplicationAutoMapperProfile : Profile +{ + private void CustomerProductionReturnNoteAutoMapperProfile() + { + CreateMap() + .ReverseMap(); + + CreateMap(); + + CreateMap(); + + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.MasterID) + .Ignore(x => x.TenantId) + .Ignore(x => x.Number) + .Ignore(x => x.Id); + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.TenantId) + .Ignore(x => x.Number) + .Ignore(x => x.Id) + .Ignore(x=>x.Remark) + .Ignore(x=>x.ExtraProperties) + ; + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs index 73d6ae533..6ee7bf61c 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationAutoMapperProfile.cs @@ -96,6 +96,7 @@ public partial class StoreApplicationAutoMapperProfile : Profile MesNoteAutoMapperProfile(); MesRecordAutoMapperProfile(); InjectioModelPlanAutoMapperProfile(); + CustomerProductionReturnNoteAutoMapperProfile(); #endregion diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNote.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNote.cs new file mode 100644 index 000000000..fccb34c56 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNote.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using Win_in.Sfs.Shared.Domain.Entities; + +namespace Win_in.Sfs.Wms.Store.Domain; + +/// +/// 退库记录 +/// +public class CustomerProductionReturnNote : SfsStoreAggregateRootBase, IHasJobNumber +{ + /// + /// 任务ID + /// + [IgnoreUpdate] + public string JobNumber { get; set; } + + /// + /// 退料单号 + /// + public string ProductionReturnRequestNumber { get; set; } + + /// + /// 退料时间 + /// + public DateTime ReturnTime { get; set; } + + /// + /// 明细列表 + /// + [IgnoreUpdate] + public override List Details { get; set; } = new List(); +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDetail.cs new file mode 100644 index 000000000..e595e788d --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDetail.cs @@ -0,0 +1,8 @@ +namespace Win_in.Sfs.Wms.Store.Domain; + +/// +/// 退库记录-明细表 +/// +public class CustomerProductionReturnNoteDetail : SfsStoreRecommendToDetailWithFromToEntityBase +{ +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteManager.cs new file mode 100644 index 000000000..c3ba11448 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteManager.cs @@ -0,0 +1,12 @@ +namespace Win_in.Sfs.Wms.Store.Domain; + +public class CustomerProductionReturnNoteManager : SfsStoreManagerBase, + ICustomerProductionReturnNoteManager +{ + + public CustomerProductionReturnNoteManager( + ICustomerProductionReturnNoteRepository repository + ) : base(repository) + { + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteManager.cs new file mode 100644 index 000000000..8a3a7af7e --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteManager.cs @@ -0,0 +1,5 @@ +namespace Win_in.Sfs.Wms.Store.Domain; + +public interface ICustomerProductionReturnNoteManager : ISfsStoreManager +{ +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteRepository.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteRepository.cs new file mode 100644 index 000000000..1be0dbb18 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/CustomerProductionReturnNotes/ICustomerProductionReturnNoteRepository.cs @@ -0,0 +1,5 @@ +namespace Win_in.Sfs.Wms.Store.Domain; + +public interface ICustomerProductionReturnNoteRepository : ISfsStoreRepositoryBase +{ +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDbContextModelCreatingExtensions.cs new file mode 100644 index 000000000..889790ab7 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteDbContextModelCreatingExtensions.cs @@ -0,0 +1,49 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Modeling; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; + +public static class CustomerProductionReturnNoteDbContextModelCreatingExtensions +{ + public static void ConfigureCustomerProductionReturnNote(this ModelBuilder builder, StoreModelBuilderConfigurationOptions options) + { + builder.Entity(b => + { + + //Configure table & schema name + b.ToTable(options.TablePrefix + nameof(CustomerProductionReturnNote), options.Schema); + //Configure ABP properties + b.ConfigureByConvention(); + //Configure Sfs base properties + b.ConfigureSfsStoreBase(); + //Properties + b.Property(q => q.JobNumber).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.ProductionReturnRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength); + //Relations + b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); + //Indexes + b.HasIndex(q => new { q.Number }).IsUnique(); + }); + + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(options.TablePrefix + nameof(CustomerProductionReturnNoteDetail), options.Schema); + //Configure ABP properties + b.ConfigureByConvention(); + //Configure Sfs base properties + b.ConfigureSfsStoreBase(); + //Configure Sfs store detail properties + b.ConfigureSfsStoreDetailBase(); + //Properties + b.Property(q => q.FromStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion(); + b.Property(q => q.ToStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion(); + //Relations + + //Indexes + b.HasIndex(q => new { q.Number, q.ItemCode, q.FromPackingCode, q.ToPackingCode, q.FromLocationCode, q.ToLocationCode }).IsUnique(); + }); + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteEfCoreRepository.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteEfCoreRepository.cs new file mode 100644 index 000000000..4bfdb68fa --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteEfCoreRepository.cs @@ -0,0 +1,13 @@ +using Volo.Abp.EntityFrameworkCore; +using Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; + +public class CustomerProductionReturnNoteEfCoreRepository : SfsStoreEfCoreRepositoryBase, ICustomerProductionReturnNoteRepository +{ + public CustomerProductionReturnNoteEfCoreRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + + + } +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs index 5e71acb3c..d3c44634d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreDbContextModelCreatingExtensions.cs @@ -108,6 +108,7 @@ public static class StoreDbContextModelCreatingExtensions builder.ConfigureMesNote(options); builder.ConfigureMesRecord(options); builder.ConfigureInjectioModelPlan(options); + builder.ConfigureCustomerProductionReturnNote(options); #endregion #region Jobs diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs index 0b105decb..17d37a43e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/StoreEntityFrameworkCoreModule.cs @@ -124,10 +124,11 @@ public class StoreEntityFrameworkCoreModule : AbpModule context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); - + context.Services.AddTransient(); context.Services.AddTransient(); context.Services.AddTransient(); - + + #endregion #region Jobs @@ -329,6 +330,8 @@ public class StoreEntityFrameworkCoreModule : AbpModule options.Entity(orderOptions => orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Details)); + options.Entity(orderOptions => + orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Details)); #endregion #region Jobs diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs new file mode 100644 index 000000000..ae68caa23 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs @@ -0,0 +1,23 @@ +using AutoMapper; +using Volo.Abp.AutoMapper; +using Win_in.Sfs.Wms.Inventory.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; + +namespace Win_in.Sfs.Wms.Store.Event; + +public partial class StoreEventAutoMapperProfile : Profile +{ + private void CustomerProductionReturnNoteAutoMapperProfile() + { + CreateMap() + + .ForMember(x => x.DocNumber, y => y.MapFrom(t => t.Number)) + .Ignore(x => x.JobNumber) + .Ignore(x => x.Worker) + .Ignore(x => x.TransType) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.TransSubType) + ; + } + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs index e1053cf3c..dfa9b1a82 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs @@ -88,6 +88,7 @@ public partial class StoreEventAutoMapperProfile : Profile PutawayNoteAutoMapperProfile(); RecycledMaterialReceiptNoteAutoMapperProfile(); ScrapNoteAutoMapperProfile(); + CustomerProductionReturnNoteAutoMapperProfile() ; UnplannedIssueNoteAutoMapperProfile(); UnplannedIssueRequestAutoMapperProfile(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs new file mode 100644 index 000000000..bc62f87a8 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs @@ -0,0 +1,94 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.EventBus; +using Volo.Abp.Uow; +using Win_in.Sfs.Shared.Domain.Shared; +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.Event.Transaction; + +namespace Win_in.Sfs.Wms.Store.Event.Transactions; + +public class CustomerProductionReturnNoteEventHandler + : StoreInventoryEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> + + + + +{ + private const EnumTransType TransType = EnumTransType.CustomerReturn; + + private readonly IProductionReturnRequestAppService _productionReturnRequestApp; + + public CustomerProductionReturnNoteEventHandler(IProductionReturnRequestAppService productionReturnRequestApp) + { + this._productionReturnRequestApp = productionReturnRequestApp; + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + await AddTransactionsAsync(entity).ConfigureAwait(false); + + if (!string.IsNullOrEmpty(entity.ProductionReturnRequestNumber)) + { + await _productionReturnRequestApp.CompleteByNumberAsync(entity.ProductionReturnRequestNumber).ConfigureAwait(false); + } + } + + private async Task AddTransactionsAsync(CustomerProductionReturnNote CustomerProductionReturnNote) + { + var inboundTransactions = new List(); + + inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote)); + + await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); + + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + await AddTransactionsAsync(entities).ConfigureAwait(false); + } + + private async Task AddTransactionsAsync(List CustomerProductionReturnNotes) + { + var inboundTransactions = new List(); + + //如果要做库存事务汇总,可以修改此处 + foreach (var CustomerProductionReturnNote in CustomerProductionReturnNotes) + { + inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote)); + } + + await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); + } + + private List BuildTransferLogs(CustomerProductionReturnNote CustomerProductionReturnNote) + { + var transferLogs = new List(); + foreach (var detail in CustomerProductionReturnNote.Details.Where(detail => detail.Qty != 0)) + { + var transferLog = ObjectMapper.Map(detail); + + transferLog.TransType = TransType; + + transferLog.Worker = CustomerProductionReturnNote.Worker; + transferLog.DocNumber = CustomerProductionReturnNote.Number; + transferLog.JobNumber = CustomerProductionReturnNote.JobNumber; + + transferLogs.Add(transferLog); + } + + return transferLogs; + } + +}