diff --git a/be/Hosts/Basedata.Host/Win_in.Sfs.Basedata.HttpApi.Host/Properties/PublishProfiles/FolderProfile1.pubxml b/be/Hosts/Basedata.Host/Win_in.Sfs.Basedata.HttpApi.Host/Properties/PublishProfiles/FolderProfile1.pubxml new file mode 100644 index 000000000..36847ea03 --- /dev/null +++ b/be/Hosts/Basedata.Host/Win_in.Sfs.Basedata.HttpApi.Host/Properties/PublishProfiles/FolderProfile1.pubxml @@ -0,0 +1,17 @@ + + + + + false + false + true + Release + Any CPU + FileSystem + bin\Release\net6.0\publish\ + FileSystem + <_TargetId>Folder + + \ No newline at end of file diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentEditInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentEditInput.cs index 25ab571b3..29f3c2020 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentEditInput.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentEditInput.cs @@ -37,7 +37,7 @@ public class EquipmentEditInput : SfsBaseDataCreateOrUpdateInputBase /// 库位编号 /// [Display(Name = "库位代码")] - [Required(ErrorMessage = "{0}是必填项")] + public string LocCode { get; set; } = string.Empty; /// /// 状态 diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentImportInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentImportInput.cs index 975c20ec2..88d88bfce 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentImportInput.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/Equipments/Inputs/EquipmentImportInput.cs @@ -37,7 +37,7 @@ public class EquipmentImportInput : SfsBaseDataImportInputBase /// 库位编号 /// [Display(Name = "库位代码")] - [Required(ErrorMessage = "{0}是必填项")] + //[Required(ErrorMessage = "{0}是必填项")] public string LocCode { get; set; } = string.Empty; /// /// 状态 diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs index 37b9c9852..e45466955 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.EntityFrameworkCore/Equipments/EquipmentDbContextModelCreatingExtensions.cs @@ -23,7 +23,7 @@ public static class EquipmentDbContextModelCreatingExtensions b.Property(q => q.Code).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(true); b.Property(q => q.Model).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.LocCode).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.Type).HasMaxLength(SfsPropertyConst.CodeLength); + //Relations diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs index a93d60ac8..86d8c6e5d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs @@ -17,6 +17,7 @@ namespace Win_in.Sfs.Wms.Store.Application; using System.Collections.Generic; using System.Linq; using IdentityModel; +using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.ObjectMapping; using Win_in.Sfs.Shared.Domain; @@ -70,42 +71,25 @@ public class MesNoteAppService : detail.StdPackQty = itemBasicDto.StdPackQty; #region 添加校验 - RecommendBalanceRequestInput rInput = new RecommendBalanceRequestInput(); rInput.ItemCode = detail.ItemCode; rInput.Locations = new List() { detail.FromLocationCode }; rInput.Qty = detail.Qty; rInput.Statuses = new List { EnumInventoryStatus.OK }; var balanceLst = await _balanceAppService.GetRecommendBalancesByLocationsAsync(rInput).ConfigureAwait(false); - var first = balanceLst.FirstOrDefault(); if (first != null) { - if (detail.Qty > first.Qty) - { } - - - - - + if (detail.Qty <= first.Qty) + { + throw new UserFriendlyException($"库存数量不足"); + } } else { - - - - - + throw new UserFriendlyException($"库存数量不足"); } - - - - - #endregion - - - } entity = await _repository.InsertAsync(entity).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/MesNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/MesNoteEventHandler.cs new file mode 100644 index 000000000..e0ea1d327 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/MesNoteEventHandler.cs @@ -0,0 +1,105 @@ +using System; +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.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; + +public class MesNoteEventHandler + : StoreInventoryEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> +{ + + private const EnumTransType TransType = EnumTransType.Scrap; + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + await AddTransactionsAsync(new List() { entity }).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + await AddTransactionsAsync(entities).ConfigureAwait(false); + } + + #region 私有 + + private async Task AddTransactionsAsync(List MesNotes) + { + + //如果WMS管理报废库,生成库存转移 + if (await SettingManager.IsTrueAsync(StoreSettings.Common.EnableScrapLocation).ConfigureAwait(false)) + { + var transferLogs = new List(); + foreach (var MesNote in MesNotes) + { + transferLogs.AddRange(BuildTransferLogs(MesNote)); + } + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } + else + { + var transactions = new List(); + foreach (var MesNote in MesNotes) + { + transactions.AddRange(BuildTransactions(MesNote)); + } + + await TransactionAppService.AddManyAsync(transactions).ConfigureAwait(false); + } + } + + private List BuildTransferLogs(MesNote MesNote) + { + var transferLogs = new List(); + foreach (var detail in MesNote.Details.Where(detail => detail.Qty != 0)) + { + var transferLog = ObjectMapper.Map(detail); + + transferLog.TransType = TransType; + transferLog.TransSubType = Enum.Parse(MesNote.Type); + transferLog.Worker = MesNote.Worker; + transferLog.DocNumber = MesNote.Number; + transferLog.JobNumber = MesNote.JobNumber; + + transferLogs.Add(transferLog); + } + + return transferLogs; + } + + private List BuildTransactions(MesNote deliverNote) + { + var transactions = new List(); + + foreach (var detail in deliverNote.Details) + { + var transaction = ObjectMapper.Map(detail); + + transaction.TransType = TransType; + transaction.TransInOut = EnumTransInOut.Out; + transaction.Worker = deliverNote.Worker; + transaction.DocNumber = deliverNote.Number; + transaction.JobNumber = deliverNote.JobNumber; + + transactions.Add(transaction); + } + + return transactions; + } + + #endregion +}