diff --git a/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql b/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql index 1b200382c..6d4052e60 100644 --- a/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql +++ b/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql @@ -4159,7 +4159,7 @@ CREATE TABLE [Store_PurchaseOrderDetail] ( [ReceivedQty] decimal(18,6) NOT NULL, [ReturnedQty] decimal(18,6) NOT NULL, [PutAwayQty] decimal(18,6) NOT NULL, - [ContactUserCode] nvarchar(max) NULL, + [PlanUserCode] nvarchar(max) NULL, [Lot] nvarchar(max) NULL, [PlanArriveDate] datetime2 NOT NULL, [Ctype] nvarchar(max) NULL, diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/WorkCenters/WorkCenter.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/WorkCenters/WorkCenter.cs index 82936e912..b44f3cea8 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/WorkCenters/WorkCenter.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/WorkCenters/WorkCenter.cs @@ -10,7 +10,7 @@ namespace Win_in.Sfs.Basedata.Domain; /// public class WorkStation : SfsBaseDataAggregateRootBase, IHasCode, IHasName { - [Display(Name = "编码")] + [Display(Name = "工作中心代码")] [Required(ErrorMessage = "{0}是必填项")] [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] [IgnoreUpdate] diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Event/appsettings.json b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Event/appsettings.json index 60875d3e3..2802826c1 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Event/appsettings.json +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Event/appsettings.json @@ -1,17 +1,17 @@ { - "RabbitMQ": { - "Connections": { - "Default": { - "HostName": "127.0.0.1", - "Port": 5672, - "UserName": "admin", - "Password": "admin", - "VirtualHost": "my_vhost" - } - }, - "EventBus": { - "ClientName": "Inventory", - "ExchangeName": "InventoryMessages" - } - } + //"RabbitMQ": { + // "Connections": { + // "Default": { + // "HostName": "127.0.0.1", + // "Port": 5672, + // "UserName": "admin", + // "Password": "admin", + // "VirtualHost": "my_vhost" + // } + // }, + // "EventBus": { + // "ClientName": "Inventory", + // "ExchangeName": "InventoryMessages" + // } + //} } diff --git a/be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/InventoryLabelEditInput.cs b/be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/InventoryLabelEditInput.cs index 0a13f50ad..a6330a941 100644 --- a/be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/InventoryLabelEditInput.cs +++ b/be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/InventoryLabelEditInput.cs @@ -203,6 +203,7 @@ public class InventoryLabelEditInput : SfsLabelCreateOrUpdateInputBase /// [Display(Name = "供应商零件名")] public string SupplierItemName { get; set; } + #endregion #region Create @@ -219,5 +220,6 @@ public class InventoryLabelEditInput : SfsLabelCreateOrUpdateInputBase [Display(Name = "标签类型")] [Required(ErrorMessage = "{0}是必填项")] public EnumLabelType LabelType { get; set; } + #endregion } diff --git a/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs b/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs index 7daf50de2..13e0832f9 100644 --- a/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs +++ b/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs @@ -60,17 +60,14 @@ public class InventoryLabelAppService [HttpPost("many")] public virtual async Task> CreateManyAsync(List inputs) { - var codes = inputs.Select(p => p.Code).ToList(); - var existEntities = await GetByCodesAsync(codes).ConfigureAwait(false); - if (existEntities.Any()) + List inventoryLabelDtos = new List(); + + foreach (var input in inputs) { - var existCodes = existEntities.Select(p => p.Code).ToList(); - throw new UserFriendlyException($"{existCodes.JoinAsString(",")} 已存在"); + inventoryLabelDtos.Add(await CreateAsync(input)); } - var entities = ObjectMapper.Map, List>(inputs); - await Repository.InsertManyAsync(entities).ConfigureAwait(false); - var dtos = ObjectMapper.Map, List>(entities); - return dtos; + + return inventoryLabelDtos; } [HttpPost("generate-and-create")] diff --git a/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAutoMapperProfile.cs b/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAutoMapperProfile.cs index 49447549c..a9050e8f8 100644 --- a/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAutoMapperProfile.cs +++ b/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAutoMapperProfile.cs @@ -22,6 +22,16 @@ public class InventoryLabelAutoMapperProfile : Profile .Ignore(x => x.Remark) .Ignore(x => x.ExtraProperties); + CreateMap() + .IgnoreAuditedObjectProperties() + .MapQualityInfoDto() + .MapPurchaseInfoDto() + .MapProductionInfoDto() + .Ignore(x=>x.Id) + .Ignore(x => x.ConcurrencyStamp) + ; + + CreateMap() .IgnoreAuditedObjectProperties() .MapPurchaseInfoDto() diff --git a/be/Modules/Message/src/Win_in.Sfs.Message.Event/appsettings.json b/be/Modules/Message/src/Win_in.Sfs.Message.Event/appsettings.json index 0ce50b653..5639c71d2 100644 --- a/be/Modules/Message/src/Win_in.Sfs.Message.Event/appsettings.json +++ b/be/Modules/Message/src/Win_in.Sfs.Message.Event/appsettings.json @@ -1,20 +1,20 @@ { - "RabbitMQ": { - "Connections": { - "Default": { - "HostName": "127.0.0.1", - "Port": 5672, - "UserName": "admin", - "Password": "admin", - "VirtualHost": "my_vhost" - } - }, - "EventBus": { - "ClientName": "Store", - "ExchangeName": "StoreMessages" - } - }, + //"RabbitMQ": { + // "Connections": { + // "Default": { + // "HostName": "127.0.0.1", + // "Port": 5672, + // "UserName": "admin", + // "Password": "admin", + // "VirtualHost": "my_vhost" + // } + // }, + // "EventBus": { + // "ClientName": "Store", + // "ExchangeName": "StoreMessages" + // } + //}, "Settings": { "CreateMessageJob": true } -} \ No newline at end of file +} diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs index cec935fa0..30991de35 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs @@ -12,8 +12,10 @@ using System.Threading; using System.Threading.Tasks; using AutoMapper.Internal; using DocumentFormat.OpenXml.Math; +using DocumentFormat.OpenXml.Office2010.ExcelAc; using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml.Vml.Office; +using DocumentFormat.OpenXml.Wordprocessing; using EFCore.BulkExtensions; using JetBrains.Annotations; using Microsoft.AspNetCore.Http; @@ -329,12 +331,13 @@ public abstract class SfsCrudWithDetailsAppServiceBase [HttpPost("import")] [Consumes("multipart/form-data")] + [UnitOfWork] public virtual async Task ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) { using var ms = new MemoryStream(); await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); var inputFileBytes = ms.GetAllBytes(); - var result = await ImportInternalAsync(requestInput, inputFileBytes).ConfigureAwait(false); + var result = await ImportInternalAsync(requestInput, inputFileBytes); var bytes = result.FileContents; result.FileContents = null; @@ -507,6 +510,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase /// 导入数据具体实现,可重写 /// + [UnitOfWork] protected virtual async Task ImportInternalAsync(SfsImportRequestInput requestInput, byte[] inputFileBytes) { IList modelList = null; @@ -552,18 +556,20 @@ public abstract class SfsCrudWithDetailsAppServiceBase p.Value == EntityState.Added).Select(p => p.Key).ToList(); + //一定要 先发布 在导入 否则没有事务性了 只针对于导入 + await PublishCreatedAsync(addList).ConfigureAwait(false); await SaveImportAsync(entityDict).ConfigureAwait(false); } } - - await PublishCreatedAsync(entityDict.Keys.ToList()); - // 创建导入报告 var reportFile = ExportImportService.GetImportReport(inputFileBytes, modelDict); // 创建返回值 @@ -620,7 +626,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase - /// 导入数据后 发布事件 + /// 发布新增事件 /// /// /// @@ -628,7 +634,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase>(entities),true).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData>(entities),false).ConfigureAwait(false); } catch (Exception ex) { @@ -651,6 +657,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase /// 导入保存到数据库,可重写 /// + protected virtual async Task SaveImportAsync(Dictionary dict) { var entityList = dict.Keys.ToList(); @@ -675,6 +682,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase [Display(Name = "明细-筹措员代码")] - public string ContactUserCode { get; set; } + public string PlanUserCode { get; set; } /// /// 生产批次 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderDetailInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderDetailInput.cs index a54d56ae1..d5b491f69 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderDetailInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderDetailInput.cs @@ -66,7 +66,7 @@ public class PurchaseOrderDetailInput : SfsStoreDetailWithQtyInputBase /// 筹措员代码 /// [Display(Name = "明细-筹措员代码")] - public string ContactUserCode { get; set; } + public string PlanUserCode { get; set; } /// /// 生产批次 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderImportInput.cs index ecc63d30b..c3d4b92a8 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderImportInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/Inputs/PurchaseOrderImportInput.cs @@ -21,6 +21,7 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase [Display(Name = "采购订单号")] [Key] public string Number { get; set; } + /// /// 供应商代码 /// @@ -31,7 +32,6 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase /// 订单类型 /// [Display(Name = "订单类型")] - public string PoType { get; set; } /// @@ -68,8 +68,8 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase /// 版本 /// [Display(Name = "版本")] - public string Version { get; set; } + /// /// 税率 /// @@ -82,6 +82,7 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase /// [Display(Name = "仓库代码")] public string WarehouseCode { get; set; } + /// /// 明细-订单行 /// @@ -106,6 +107,7 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase /// [Display(Name = "明细-数量计量单位")] public string Uom { get; set; } + /// /// 明细-标准包装数量 /// @@ -133,11 +135,18 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase [Required(ErrorMessage = "{0}是必填项")] public decimal ConvertRate { get; set; } + /// + /// ERP库位 + /// + [Display(Name = "明细-ERP库位")] + [Required(ErrorMessage = "{0}是必填项")] + public string LocationErpCode { get; set; } + /// /// 筹措员代码 /// [Display(Name = "明细-筹措员代码")] - public string ContactUserCode { get; set; } + public string PlanUserCode { get; set; } /// /// 生产批次 @@ -204,5 +213,4 @@ public class PurchaseOrderImportInput : SfsStoreImportInputBase /// [Display(Name = "联系人邮箱")] public string ContactEmail { get; set; } - } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs index 0ff9ec094..b18648ddb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs @@ -24,4 +24,11 @@ public interface ISupplierAsnAppService Task> GetForTodayUnReceivedListAsync(); Task> GetByStartTimeEndTimeAsync(DateTime startTime, DateTime endTime); + + /// + /// 生成ASN订单号 + /// + /// + /// + Task GenerateSupplierAsnNumberAsync(DateTime activeDate); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobAppServiceBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobAppServiceBase.cs index 45c35d0e5..aa9cc4b2c 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobAppServiceBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsJobAppServiceBase.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; +using Volo.Abp.Uow; using Volo.Abp.Validation; using Win_in.Sfs.Shared.Application; using Win_in.Sfs.Shared.Application.Contracts; @@ -51,6 +52,7 @@ public abstract class SfsJobAppServiceBase任务Input /// [HttpPost("")] + [UnitOfWork] public override async Task CreateAsync(TCreateInput input) { var entity = input.ToObject(); @@ -66,6 +68,7 @@ public abstract class SfsJobAppServiceBase任务Input列表 /// [HttpPost("add-many")] + [UnitOfWork] public virtual async Task> CreateManyAsync(List inputs) { var entities = inputs.ToObject>(); @@ -80,6 +83,7 @@ public abstract class SfsJobAppServiceBase /// [HttpPost("cancel/{id}")] + [UnitOfWork] public virtual async Task CancelAsync(Guid id) { var entity = await GetEntityAsync(id).ConfigureAwait(false); @@ -92,6 +96,7 @@ public abstract class SfsJobAppServiceBase /// [HttpPost("accept/{id}")] + [UnitOfWork] public virtual async Task AcceptAsync(Guid id) { var entity = await GetEntityAsync(id).ConfigureAwait(false); @@ -104,6 +109,7 @@ public abstract class SfsJobAppServiceBase /// [HttpPost("open/{id}")] + [UnitOfWork] public virtual async Task OpenAsync(Guid id) { var entity = await GetEntityAsync(id).ConfigureAwait(false); @@ -116,6 +122,7 @@ public abstract class SfsJobAppServiceBase /// [HttpPost("close/{id}")] + [UnitOfWork] public virtual async Task CloseAsync(Guid id) { var entity = await GetEntityAsync(id).ConfigureAwait(false); @@ -128,6 +135,7 @@ public abstract class SfsJobAppServiceBase /// [HttpPost("cancel-accept/{id}")] + [UnitOfWork] public virtual async Task CancelAcceptAsync(Guid id) { var entity = await GetEntityAsync(id).ConfigureAwait(false); @@ -141,6 +149,7 @@ public abstract class SfsJobAppServiceBase /// [HttpPost("handle/{id}")] + [UnitOfWork] public virtual async Task CompleteAsync(Guid id, TEntityDto dto) { var handleEntity = ObjectMapper.Map(dto); @@ -157,6 +166,7 @@ public abstract class SfsJobAppServiceBase /// [HttpPost("check")] + [UnitOfWork] public virtual async Task CheckAsync(string jobNumber, TEntityDto dto, TCheckInput input) { await Task.CompletedTask.ConfigureAwait(false); @@ -182,6 +192,7 @@ public abstract class SfsJobAppServiceBase /// [HttpGet("check-job-exist-by-packing")] + [UnitOfWork] public virtual async Task> CheckJobExistByPackingCode(string packingCode, string itemCode) { var entities = await _jobManager.GetWorkingListByPackingAsync(packingCode).ConfigureAwait(false); @@ -196,6 +207,7 @@ public abstract class SfsJobAppServiceBase /// [HttpGet("check-job-exist-by-container")] + [UnitOfWork] public virtual async Task> CheckJobExistByContainerCode(string containerCode, string itemCode) { var entities = await _jobManager.GetWorkingListByContainerAsync(containerCode).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/Project/FuWeiDongYang/FuWeiDongYang_PurchaseOrderAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/Project/FuWeiDongYang/FuWeiDongYang_PurchaseOrderAppService.cs deleted file mode 100644 index e77181e18..000000000 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/Project/FuWeiDongYang/FuWeiDongYang_PurchaseOrderAppService.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Win_in.Sfs.Basedata.Application.Contracts; -using Win_in.Sfs.Wms.Store.Application; -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.Project; - -namespace Win_in.Sfs.Wms.Store.Orders.PurchaseOrders.Project.FuWeiDongYang; -[Route($"{ProjectStoreConsts.RootPath}purchase-order-fuweidongyang")] -public class FuWeiDongYang_PurchaseOrderAppService:PurchaseOrderAppService -{ - public FuWeiDongYang_PurchaseOrderAppService(IPurchaseOrderRepository repository, IPurchaseOrderManager purchaseOrderManager, ISupplierAppService supplierAppService) : base(repository, purchaseOrderManager, supplierAppService) - { - - } -} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs index f2fb1e64e..69c77441b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs @@ -3,14 +3,19 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; +using DocumentFormat.OpenXml.Office2010.ExcelAc; +using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Volo.Abp; +using Volo.Abp.Uow; +using Volo.Abp.Users; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts; 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; using Win_in.Sfs.Wms.Store.Domain.Shared; @@ -28,21 +33,57 @@ public class PurchaseOrderAppService : private new readonly IPurchaseOrderRepository _repository; private readonly IPurchaseOrderManager _purchaseOrderManager; private readonly ISupplierAppService _supplierAppService; + private readonly IItemBasicAppService _itemBasicAppService; public PurchaseOrderAppService( IPurchaseOrderRepository repository, - IPurchaseOrderManager purchaseOrderManager - , ISupplierAppService supplierAppService - ) : base(repository) + IPurchaseOrderManager purchaseOrderManager, + ISupplierAppService supplierAppService, + IItemBasicAppService itemBasicAppService) : base(repository) { _repository = repository; _purchaseOrderManager = purchaseOrderManager; _supplierAppService = supplierAppService; + _itemBasicAppService = itemBasicAppService; base.CreatePolicyName = PurchaseOrderPermissions.Create; base.UpdatePolicyName = PurchaseOrderPermissions.Update; base.DeletePolicyName = PurchaseOrderPermissions.Delete; } + #region 东阳使用 + + /// + /// 用来重写 导入数据时可以加工数据 + /// + /// + /// + protected override async Task> ImportProcessingEntityAsync( + Dictionary dictionary) + { + var addList= dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); + + foreach (var PurchaseOrder in addList) + { + PurchaseOrder.CreatorId = CurrentUser.Id; + PurchaseOrder.Worker = CurrentUser.Name; + + foreach (var detail in PurchaseOrder.Details) + { + var itemBasicDto= await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + + detail.ItemName= itemBasicDto.Name; + detail.ItemDesc1 = itemBasicDto.Desc1; + detail.ItemDesc2 = itemBasicDto.Desc2; + } + } + + return dictionary; + } + + #endregion + + + /// /// 【创建】采购订单 /// @@ -88,23 +129,6 @@ public class PurchaseOrderAppService : return ObjectMapper.Map, List>(entityList); } - - /// - /// 用来重写 导入数据时可以加工数据 - /// - /// - /// - protected override Task> ImportProcessingEntityAsync( - Dictionary dictionary) - { - return base.ImportProcessingEntityAsync(dictionary); - } - - - - - - [HttpPost("{id}/detail")] public virtual async Task UpdateDetailsAsync(string number, List inputs) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAutoMapperProfile.cs index 33303b1c1..8caa93937 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAutoMapperProfile.cs @@ -28,7 +28,8 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.MasterID) .Ignore(x => x.TenantId) .Ignore(x => x.Number) - .Ignore(x => x.Id); + .Ignore(x => x.Id) + ; CreateMap() .IgnoreAuditedObjectProperties() @@ -46,16 +47,13 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.ReceivedQty) .Ignore(x => x.ReturnedQty) .Ignore(x => x.PutAwayQty) - .Ignore(x => x.ItemName).Ignore(x => x.ItemDesc1).Ignore(x => x.ItemDesc2) - .Ignore(x => x.LocationErpCode) + .Ignore(x => x.ItemName) + .Ignore(x => x.ItemDesc1) + .Ignore(x => x.ItemDesc2) .Ignore(x => x.ProjectCode) .Ignore(x => x.LineStatus) .Ignore(x => x.TenantId) .Ignore(x => x.MasterID) - .Ignore(x => x.ShippedQty) - .Ignore(x => x.ReceivedQty) - .Ignore(x => x.ReturnedQty) - .Ignore(x => x.PutAwayQty) .Ignore(x => x.Id); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs index bc8da32bf..ec4be9b99 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Label.Application.Contracts; using Win_in.Sfs.Label.Domain.Shared; @@ -35,13 +36,12 @@ public class SupplierAsnAppService : private readonly ISupplierItemAppService _supplierItemAppService; public SupplierAsnAppService( - ISupplierAsnRepository repository - , ISupplierAsnManager supplierAsnManager - , ISupplierAppService supplierAppService - , IDockAppService dockAppService - , ILabelDefinitionAppService labelDefinitionAppService - , ISupplierItemAppService supplierItemAppService - ) : base(repository) + ISupplierAsnRepository repository, + ISupplierAsnManager supplierAsnManager, + ISupplierAppService supplierAppService, + IDockAppService dockAppService, + ILabelDefinitionAppService labelDefinitionAppService, + ISupplierItemAppService supplierItemAppService) : base(repository) { _repository = repository; _supplierAsnManager = supplierAsnManager; @@ -50,12 +50,16 @@ public class SupplierAsnAppService : _labelDefinitionAppService = labelDefinitionAppService; _supplierItemAppService = supplierItemAppService; } + + #region 东阳使用 + /// /// 【创建】收货请求 (到货单、到货通知) /// /// /// [HttpPost("")] + [UnitOfWork] public override async Task CreateAsync(SupplierAsnEditInput input) { var inputEntity = ObjectMapper.Map(input); @@ -65,6 +69,20 @@ public class SupplierAsnAppService : return ObjectMapper.Map(resultEntity); } + #endregion + + /// + /// 生成ASN订单号 + /// + /// + /// + [HttpPost("generate-supplierasn-number")] + public async Task GenerateSupplierAsnNumberAsync(DateTime activeDate) + { + return await _supplierAsnManager.GenerateNumberAsync(nameof(SupplierAsn), Clock.Normalize(activeDate)) + .ConfigureAwait(false); + } + private async Task CreateFromFileAsync(SupplierAsnEditInput input) { var entity = ObjectMapper.Map(input); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAutoMapperProfile.cs index fd052f4bc..2b2161fcf 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAutoMapperProfile.cs @@ -42,5 +42,19 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.CreatorId) .Ignore(x => x.TenantId) .Ignore(x => x.Id); + + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.ConcurrencyStamp) + .Ignore(x => x.Id) + .Ignore(x => x.TenantId) + ; + + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.Id) + .Ignore(x => x.TenantId) + ; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreManagerBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreManagerBase.cs index 50e6c6a1b..69d0a8a46 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreManagerBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreManagerBase.cs @@ -121,7 +121,7 @@ public abstract class SfsStoreManagerBase { try { - await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData(entity),false).ConfigureAwait(false); } catch (Exception ex) { @@ -136,7 +136,7 @@ public abstract class SfsStoreManagerBase { try { - await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData>(entities)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData>(entities), false).ConfigureAwait(false); } catch (Exception ex) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreRequestManagerBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreRequestManagerBase.cs index 193ab2591..00246f61e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreRequestManagerBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Bases/SfsStoreRequestManagerBase.cs @@ -25,6 +25,7 @@ public abstract class SfsStoreRequestManagerBase /// /// /// + [UnitOfWork] public override async Task CreateAsync(TEntity entity) { entity.SetIdAndNumberWithDetails(GuidGenerator, await GenerateNumberAsync(typeof(TEntity).Name, entity.ActiveDate).ConfigureAwait(false)); @@ -40,6 +41,7 @@ public abstract class SfsStoreRequestManagerBase } } + [UnitOfWork] public override async Task> CreateManyAsync(List entities) { var results = new List(); @@ -83,11 +85,12 @@ public abstract class SfsStoreRequestManagerBase } } + [UnitOfWork] private async Task PublishSubmittedAsync(TEntity entity) { try { - await LocalEventBus.PublishAsync(new SfsSubmittedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsSubmittedEntityEventData(entity),false).ConfigureAwait(false); } catch (Exception ex) { @@ -118,11 +121,12 @@ public abstract class SfsStoreRequestManagerBase } } + [UnitOfWork] private async Task PublishAgreedAsync(TEntity entity) { try { - await LocalEventBus.PublishAsync(new SfsAgreedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsAgreedEntityEventData(entity),false).ConfigureAwait(false); } catch (Exception ex) { @@ -146,11 +150,12 @@ public abstract class SfsStoreRequestManagerBase return await Repository.UpdateAsync(entity).ConfigureAwait(false); } + [UnitOfWork] private async Task PublishRefusedAsync(TEntity entity) { try { - await LocalEventBus.PublishAsync(new SfsRefusedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsRefusedEntityEventData(entity),false).ConfigureAwait(false); } catch (Exception ex) { @@ -174,11 +179,12 @@ public abstract class SfsStoreRequestManagerBase return await AddOrUpdateAsync(entity).ConfigureAwait(false); } + [UnitOfWork] protected virtual async Task PublishHandledAsync(TEntity entity) { try { - await LocalEventBus.PublishAsync(new SfsHandledEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsHandledEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { @@ -197,11 +203,12 @@ public abstract class SfsStoreRequestManagerBase return await Repository.UpdateAsync(entity).ConfigureAwait(false); } + [UnitOfWork] private async Task PublishCompletedAsync(TEntity entity) { try { - await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { @@ -220,11 +227,12 @@ public abstract class SfsStoreRequestManagerBase return await Repository.UpdateAsync(entity).ConfigureAwait(false); } + [UnitOfWork] private async Task PublishCancelledAsync(TEntity entity) { try { - await LocalEventBus.PublishAsync(new SfsCancelledEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCancelledEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { @@ -235,6 +243,7 @@ public abstract class SfsStoreRequestManagerBase } } + [UnitOfWork] public virtual async Task AbortAsync(TEntity entity) { entity.Abort(); @@ -242,11 +251,12 @@ public abstract class SfsStoreRequestManagerBase return await Repository.UpdateAsync(entity).ConfigureAwait(false); } + [UnitOfWork] private async Task PublishAbortedAsync(TEntity entity) { try { - await LocalEventBus.PublishAsync(new SfsAbortedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsAbortedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { @@ -257,6 +267,7 @@ public abstract class SfsStoreRequestManagerBase } } + [UnitOfWork] protected async Task AddOrUpdateAsync(TEntity entity) { var isExist = await Repository.AnyAsync(p => p.Id == entity.Id).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs index 737929db0..7f62cdaa6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/InspectJobs/InspectJobManager.cs @@ -174,7 +174,7 @@ public class InspectJobManager : SfsJobManagerBase #endregion - await LocalEventBus.PublishAsync(new SfsUpdateEntitySummaryDetailEventData(CopyJob)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsUpdateEntitySummaryDetailEventData(CopyJob),false).ConfigureAwait(false); return summaryDetailEntity; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs index 98a100505..611416e0d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs @@ -288,7 +288,7 @@ public abstract class SfsJobManagerBase { try { - await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { @@ -302,7 +302,7 @@ public abstract class SfsJobManagerBase { try { - await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData>(entities)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData>(entities), false).ConfigureAwait(false); } catch (Exception ex) { @@ -316,7 +316,7 @@ public abstract class SfsJobManagerBase { try { - await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { @@ -330,7 +330,7 @@ public abstract class SfsJobManagerBase { try { - await LocalEventBus.PublishAsync(new SfsCancelledEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsCancelledEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { @@ -344,7 +344,7 @@ public abstract class SfsJobManagerBase { try { - await LocalEventBus.PublishAsync(new SfsOpenedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsOpenedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { @@ -358,7 +358,7 @@ public abstract class SfsJobManagerBase { try { - await LocalEventBus.PublishAsync(new SfsClosedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsClosedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/InspectNotes/InspectNoteManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/InspectNotes/InspectNoteManager.cs index bc06d14f4..37e88d411 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/InspectNotes/InspectNoteManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/InspectNotes/InspectNoteManager.cs @@ -54,7 +54,7 @@ public class InspectNoteManager : SfsStoreManagerBase(inspectNote)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsUpdateEntityDetailEventData(inspectNote), false).ConfigureAwait(false); return entity; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/IssueNotes/IssueNoteManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/IssueNotes/IssueNoteManager.cs index 530717a4d..d66fff5ad 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/IssueNotes/IssueNoteManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/IssueNotes/IssueNoteManager.cs @@ -30,7 +30,7 @@ public class IssueNoteManager : SfsStoreManagerBase, { try { - await LocalEventBus.PublishAsync(new SfsConfirmedEntityEventData(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsConfirmedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNoteManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNoteManager.cs index 66a161ef1..05cbf08fd 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNoteManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNoteManager.cs @@ -53,7 +53,7 @@ public class PurchaseReceiptNoteManager : SfsStoreManagerBase(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsConfirmedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Orders/PurchaseOrders/PurchaseOrderDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Orders/PurchaseOrders/PurchaseOrderDetail.cs index ddba44bf3..66d0e5e00 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Orders/PurchaseOrders/PurchaseOrderDetail.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Orders/PurchaseOrders/PurchaseOrderDetail.cs @@ -72,7 +72,7 @@ public class PurchaseOrderDetail : SfsStoreDetailWithQtyEntityBase /// 筹措员代码 /// [Display(Name = "明细-筹措员代码")] - public string ContactUserCode { get; set; } + public string PlanUserCode { get; set; } /// /// 生产批次 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs index e8cf031d4..bebfabce1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/CountPlans/CountPlanManager.cs @@ -75,7 +75,7 @@ public class CountPlanManager : SfsStoreRequestManagerBase(entity)).ConfigureAwait(false); + await LocalEventBus.PublishAsync(new SfsStageChangedEntityEventData(entity), false).ConfigureAwait(false); } catch (Exception ex) { diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.Designer.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.Designer.cs index a99fc1901..a44e6e7c8 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.Designer.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.Designer.cs @@ -1,4 +1,4 @@ -// +// using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -12461,7 +12461,7 @@ namespace Win_in.Sfs.Wms.Store.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); - b.Property("ContactUserCode") + b.Property("PlanUserCode") .HasColumnType("nvarchar(max)"); b.Property("ConvertRate") diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.cs index 340c68d92..c673fa53d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/20230401163806_Added_AddPurchaseOrder.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -1856,7 +1856,7 @@ namespace Win_in.Sfs.Wms.Store.Migrations oldNullable: true); migrationBuilder.AddColumn( - name: "ContactUserCode", + name: "PlanUserCode", table: "Store_PurchaseOrderDetail", type: "nvarchar(max)", nullable: true); @@ -4337,7 +4337,7 @@ namespace Win_in.Sfs.Wms.Store.Migrations table: "Store_PurchaseReceiptNoteDetail"); migrationBuilder.DropColumn( - name: "ContactUserCode", + name: "PlanUserCode", table: "Store_PurchaseOrderDetail"); migrationBuilder.DropColumn( diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/StoreDbContextModelSnapshot.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/StoreDbContextModelSnapshot.cs index 7ace72a30..e4e053ff6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/StoreDbContextModelSnapshot.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Migrations/StoreDbContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -12459,7 +12459,7 @@ namespace Win_in.Sfs.Wms.Store.Migrations b.Property("Id") .HasColumnType("uniqueidentifier"); - b.Property("ContactUserCode") + b.Property("PlanUserCode") .HasColumnType("nvarchar(max)"); b.Property("ConvertRate") diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs index 2bc2d8145..371d07d05 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Orders/PurchaseOrderAutoMapperProfile.cs @@ -33,12 +33,11 @@ public partial class StoreEventAutoMapperProfile : Profile CreateMap() .Ignore(x => x.PoNumber) - .Ignore(x => x.RecommendErpCode) - .Ignore(x => x.PlanUserCode) .Ignore(x => x.PackingCode) .Ignore(x => x.ContainerCode) .Ignore(x => x.SupplierBatch) .Ignore(x => x.ArriveDate) + .Ignore(x=>x.RecommendErpCode) ; #endregion diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs index c316d8ee7..71c23f6ff 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs @@ -1,7 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Threading.Tasks; +using Castle.Components.DictionaryAdapter; +using Volo.Abp; using Volo.Abp.EventBus; using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; @@ -13,6 +16,8 @@ using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Inventory.Domain.Acl.ItemBasic; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; +using static Win_in.Sfs.Wms.Store.Domain.Shared.StoreSettings; +using SupplierAsn = Win_in.Sfs.Wms.Store.Domain.SupplierAsn; namespace Win_in.Sfs.Wms.Store.Event.Orders; @@ -27,13 +32,21 @@ public class PurchaseOrderEventHandler private readonly IItemPackAppService _itemPackAppService; private readonly ISupplierItemAppService _supplierItemAppService; private readonly IDockAppService _dockAppService; + private readonly IInventoryLabelAppService _inventoryLabelAppService; + private readonly ISupplierAppService _supplierAppService; + private readonly ISupplierTimeWindowAppService _supplierTimeWindowAppService; + public PurchaseOrderEventHandler(ISupplierAsnAppService supplierAsnAppService, ILabelDefinitionAppService labelDefinitionAppService, IItemBasicAppService itemBasicAppService, IItemPackAppService itemPackAppService, ISupplierItemAppService supplierItemAppService, - IDockAppService dockAppService) + IDockAppService dockAppService, + IInventoryLabelAppService inventoryLabelAppService, + IPurchaseOrderManager purchaseOrderManager, + ISupplierAppService supplierAppService, + ISupplierTimeWindowAppService supplierTimeWindowAppService) { _supplierAsnAppService = supplierAsnAppService; _labelDefinitionAppService = labelDefinitionAppService; @@ -41,6 +54,9 @@ public class PurchaseOrderEventHandler _itemPackAppService = itemPackAppService; _supplierItemAppService = supplierItemAppService; _dockAppService = dockAppService; + _inventoryLabelAppService = inventoryLabelAppService; + _supplierAppService = supplierAppService; + _supplierTimeWindowAppService = supplierTimeWindowAppService; } //创建采购订单 @@ -81,19 +97,30 @@ public class PurchaseOrderEventHandler //收货口 //todo 处理有问题是否要和供应商关联 var dock = await _dockAppService.GetAllListByFilterAsync( - new SfsBaseDataRequestInputBase() { Condition = new Condition(), MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false); + new SfsBaseDataRequestInputBase() { Condition = new Condition(){Filters = new List()}, MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false); supplierAsnEditInput.DockCode = dock.First().Code; + //赋值采购订单编号 + supplierAsnEditInput.PoNumber = purchaseOrder.Number; + //要货单号 supplierAsnEditInput.RpNumber = "无"; + //创建方式 //todo 后期修改为 采购订单中的参数 + supplierAsnEditInput.CreateType = EnumSupplierAsnCreateType.Import; + + //供应商时间窗口 + var supplierTimeWindowDtos=await _supplierTimeWindowAppService.GetListBySupplierCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false); + var dayOfWeek = new List() { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; + var chineseWeek= dayOfWeek[Clock.Now.DayOfWeek.GetHashCode()]; //中文星期 + var dateTimeWindowDto=supplierTimeWindowDtos.First(p => p.Week == chineseWeek); + supplierAsnEditInput.TimeWindow = dateTimeWindowDto.TimeSlot; + //生效日期 supplierAsnEditInput.ActiveDate = Clock.Now; - //一次性返回所有箱码 - var generateManyAsync =await _labelDefinitionAppService - .GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat), - supplierAsnEditInput.Details.Count).ConfigureAwait(false); + //发货单号 + supplierAsnEditInput.Number = await _supplierAsnAppService.GenerateSupplierAsnNumberAsync(supplierAsnEditInput.ActiveDate).ConfigureAwait(false); //所有的物品Code var itemCodes = purchaseOrder.Details.GroupBy(p => p.ItemCode).Select(p => p.Key); @@ -103,6 +130,11 @@ public class PurchaseOrderEventHandler var ItemPacks = new List();//一次性返回所有物品包装信息 var supplierItemDtos = new List();//一次性返回所有供应商物品信息 + //一次性返回所有箱码 + var generateManyAsync = await _labelDefinitionAppService + .GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat), + supplierAsnEditInput.Details.Count).ConfigureAwait(false); + foreach (var itemCode in itemCodes)//查询 { var itemPackDtos = await _itemPackAppService.GetListByItemCodeAsync(itemCode).ConfigureAwait(false); @@ -115,8 +147,10 @@ public class PurchaseOrderEventHandler //赋值 详情表 supplierAsnEditInput.Details.ForEach(detail => { + var purchaseOrderDetail= purchaseOrder.Details.First(p => p.ItemCode == detail.ItemCode); + //添加箱码 - var pakcingCode=generateManyAsync.First(); + var pakcingCode = generateManyAsync.First(); detail.PackingCode = pakcingCode; generateManyAsync.Remove(pakcingCode); @@ -135,6 +169,12 @@ public class PurchaseOrderEventHandler p.ItemCode == detail.ItemCode && p.SupplierCode == supplierAsnEditInput.SupplierCode); detail.SupplierPackQty = supplierItemDto.SupplierPackQty; detail.SupplierPackUom= supplierItemDto.SupplierPackUom; + + //订单行 + detail.PoLine = purchaseOrderDetail.PoLine; + + //推荐ERP库位 + detail.RecommendErpCode = purchaseOrderDetail.LocationErpCode; }); return supplierAsnEditInput; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs index ba415296d..55e886f10 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Plans/SupplierAsnEventHandler.cs @@ -13,6 +13,7 @@ using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; +using static Win_in.Sfs.Wms.Store.Domain.Shared.StoreSettings; using SupplierAsn = Win_in.Sfs.Wms.Store.Domain.SupplierAsn; namespace Win_in.Sfs.Wms.Store.Event.Stores; @@ -54,22 +55,11 @@ public class SupplierAsnEventHandler { var entity = eventData.Entity; - switch (entity.CreateType) - { - case EnumSupplierAsnCreateType.Import: - //创建标签 - await CreateLabelAsync(entity).ConfigureAwait(false); - break; - case EnumSupplierAsnCreateType.AppService: - case EnumSupplierAsnCreateType.ExternalInterface: - default: - //更新订单已收货数量 - await UpdatePurchaseOrderAsync(entity).ConfigureAwait(false); - break; - } + //更新采购订单收货数量 + await UpdatePurchaseOrderAsync(entity).ConfigureAwait(false); //创建收货请求(到货通知) - //await CreatePurchaseReceiptRequestAsync(entity).ConfigureAwait(false); + await CreatePurchaseReceiptRequestAsync(entity).ConfigureAwait(false); } /// @@ -84,23 +74,8 @@ public class SupplierAsnEventHandler foreach (var supplierAsn in entityList) { - switch (supplierAsn.CreateType) - { - case EnumSupplierAsnCreateType.Import: - - //创建采购订单 - await CreatePurchaseOrderAsync(supplierAsn).ConfigureAwait(false); - - //创建标签 - await CreateLabelAsync(supplierAsn).ConfigureAwait(false); - break; - case EnumSupplierAsnCreateType.AppService: - case EnumSupplierAsnCreateType.ExternalInterface: - default: - //更新订单已收货数量 - await UpdatePurchaseOrderAsync(supplierAsn).ConfigureAwait(false); - break; - } + //更新采购订单收货数量 + await UpdatePurchaseOrderAsync(supplierAsn).ConfigureAwait(false); //创建收货请求(到货通知) await CreatePurchaseReceiptRequestAsync(supplierAsn).ConfigureAwait(false); @@ -109,12 +84,7 @@ public class SupplierAsnEventHandler #region 私有 - #region 收货请求 - - /// - /// 创建 收货请求(到货通知) - /// - /// + // 创建 收货请求(到货通知) private async Task CreatePurchaseReceiptRequestAsync(SupplierAsn supplierAsn) { //开关控制 创建收货请求(到货通知) @@ -126,205 +96,33 @@ public class SupplierAsnEventHandler } } - /// - /// 构造 收货请求 - /// - /// - /// + // 构造 收货请求 private PurchaseReceiptRequestEditInput BuildPurchaseReceiptRequestCreateInput(SupplierAsn supplierAsn) { var input = ObjectMapper.Map(supplierAsn); return input; } - #endregion - - #region 采购订单 - - /// - /// 创建 采购订单 - /// - /// - private async Task CreatePurchaseOrderAsync(SupplierAsn supplierAsn) - { - //开关控制 创建采购订单 - if (await SettingManager.IsTrueAsync(StoreSettings.SupplierAsn.AutoCreatePurchaseOrder).ConfigureAwait(false)) - { - var createInput = await BulidPurchaseOrderAsync(supplierAsn).ConfigureAwait(false); - - return await _purchaseOrderAppService.CreateAsync(createInput).ConfigureAwait(false); - } - - return null; - } - - /// - /// 构造 采购订单 - /// - /// - /// - private async Task BulidPurchaseOrderAsync(SupplierAsn inputEntity) + // 更新采购订单中的发货数量 + private async Task UpdatePurchaseOrderAsync(SupplierAsn entity) { - await Task.CompletedTask.ConfigureAwait(false); - //创建采购订单 - var purchaseOrderCreateInput = ObjectMapper.Map(inputEntity); + var purchaseOrderDetailUpdateInputs = new List(); - var group = inputEntity.Details.GroupBy(p => new { p.ItemCode, p.RecommendErpCode, p.PoLine, p.ProjectCode }); - foreach (var groupKey in group) + foreach (var detail in entity.Details) { - //样板数据 - var templateData = inputEntity.Details.First(p => - groupKey.Key.ItemCode == p.ItemCode && - groupKey.Key.RecommendErpCode == p.RecommendErpCode && - p.PoLine == groupKey.Key.PoLine && - p.ProjectCode == groupKey.Key.ProjectCode); - //汇总数量 - var sumQty = inputEntity.Details.Where(p => - groupKey.Key.ItemCode == p.ItemCode && - groupKey.Key.RecommendErpCode == p.RecommendErpCode && - p.PoLine == groupKey.Key.PoLine && - p.ProjectCode == groupKey.Key.ProjectCode) - .Sum(p => p.Qty); - //创建明细 - var purchaseOrderDetailInput = new PurchaseOrderDetailInput() + var purchaseOrderDetailUpdateInput=new PurchaseOrderDetailUpdateInput() { - ItemCode = groupKey.Key.ItemCode, - Qty = sumQty, - Uom = templateData.Uom, - ItemName = templateData.ItemName, - Remark = templateData.Remark, - ItemDesc2 = templateData.ItemDesc2, - ItemDesc1 = templateData.ItemDesc1, - LocationErpCode = groupKey.Key.RecommendErpCode, - StdPackQty = templateData.StdPackQty, - ConvertRate = 0, - IsConsignment = true, - LineStatus = EnumOrderStatus.Open, - PoLine = templateData.PoLine, - ProjectCode = templateData.ProjectCode, - SupplierPackQty = templateData.SupplierPackQty, - SupplierPackUom = templateData.SupplierPackUom, - ShippedQty = sumQty, + PoLine = detail.PoLine, + ItemCode = detail.ItemCode, + ShippedQty = detail.Qty, }; - purchaseOrderCreateInput.Details.Add(purchaseOrderDetailInput); - } - - return purchaseOrderCreateInput; - } - - #endregion - - #region 创建标签 - - /// - /// 创建 采购收货标签 - /// - /// - private async Task> CreateLabelAsync(SupplierAsn supplierAsn) - { - List inventoryLabelDtos = new List(); - - foreach (var supplierAsnDetail in supplierAsn.Details) - { - var inputLabel = await BuildInventoryLabelCreateInputAsync(supplierAsn, supplierAsnDetail).ConfigureAwait(false); - var labelDto = await _inventoryLabelService.CreateAsync(inputLabel).ConfigureAwait(false); - inventoryLabelDtos.Add(labelDto); - } - - return inventoryLabelDtos; - } - - /// - /// 创建 构造标签 - /// - /// - /// - /// - private async Task BuildInventoryLabelCreateInputAsync(SupplierAsn supplierAsn, SupplierAsnDetail supplierAsnDetail) - { - var itemDto = await ItemBasicAclService.GetByCodeAsync(supplierAsnDetail.ItemCode).ConfigureAwait(false); - var supplierItem = - await _supplierItemAppService.GetBySupplierCodeAndItemCodeAsync(supplierAsn.SupplierCode, - itemDto.Code).ConfigureAwait(false); - var supplier = await _supplierAppService.GetByCodeAsync(supplierAsn.SupplierCode).ConfigureAwait(false); - - if (itemDto == null) - { - throw new UserFriendlyException($"{supplierAsnDetail.ItemCode}零件信息为空"); - } - - if (supplier == null) - { - throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商为空"); - } - - if (supplierItem == null) - { - throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商零件或{itemDto.Code}零件信息为空"); + purchaseOrderDetailUpdateInputs.Add(purchaseOrderDetailUpdateInput); } - var inputLabel = new InventoryLabelEditInput() - { - LabelType = EnumLabelType.PurchaseLabel, - ArriveDate = DateTime.Now, - Qty = supplierAsnDetail.Qty, - PoNumber = supplierAsnDetail.PoNumber, - Uom = supplierAsnDetail.Uom, - ItemDesc2 = itemDto.Desc2, - AsnNumber = supplierAsnDetail.Number, - ItemCode = supplierAsnDetail.ItemCode, - ItemName = supplierAsnDetail.ItemName, - ItemDesc1 = itemDto.Desc1, - SupplierBatch = supplierAsnDetail.SupplierBatch, - ProduceDate = supplierAsnDetail.ProduceDate, - ExpireDate = DateTime.Now.AddDays(itemDto.GetValidateDays()), - FullBarcodeString = supplierAsnDetail.PackingCode, - ExtraProperties = { }, - LabelStatus = LabelStatus.Enable, - LocationErpCode = supplierAsnDetail.RecommendErpCode, - Lot = supplierAsnDetail.Lot, - RecommendLocationCode = supplierAsnDetail.RecommendErpCode, - Remark = supplierAsnDetail.Remark, - Specifications = itemDto.Color, - StdPackQty = supplierAsnDetail.StdPackQty, - SupplierCode = supplierAsn.SupplierCode, - SupplierItemCode = supplierItem.SupplierItemCode, - SupplierItemName = supplierItem.ItemName, - SupplierName = supplier.Name, - SupplierSimpleName = supplier.ShortName, - Team = null, - ProdLine = null, - QLevel = null, - QualityFile = null, - RpNumber = null, - Shift = null, - ContainerCode = null, - Code = supplierAsnDetail.PackingCode - }; - return inputLabel; - } - - #endregion - - private async Task UpdatePurchaseOrderAsync(SupplierAsn entity) - { - var purchaseOrderDetailUpdateInputs = entity.Details - .Select(BuildPurchaseOrderDetailUpdateInput).ToList(); - await _purchaseOrderAppService.UpdateDetailsAsync(entity.PoNumber, purchaseOrderDetailUpdateInputs).ConfigureAwait(false); } - private static PurchaseOrderDetailUpdateInput BuildPurchaseOrderDetailUpdateInput(SupplierAsnDetail supplierAsnDetail) - { - return new PurchaseOrderDetailUpdateInput() - { - PoLine = supplierAsnDetail.PoLine, - ItemCode = supplierAsnDetail.ItemCode, - ShippedQty = supplierAsnDetail.Qty, - }; - } - #endregion } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs index 2b86a2a7f..0669292d5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.EventBus; using Volo.Abp.SettingManagement; +using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Event; @@ -35,6 +36,7 @@ public class PurchaseReceiptRequestEventHandler /// /// /// + [UnitOfWork] public virtual async Task HandleEventAsync(SfsCancelledEntityEventData eventData) { var entity = eventData.Entity; @@ -46,6 +48,7 @@ public class PurchaseReceiptRequestEventHandler /// /// /// + [UnitOfWork] public virtual async Task HandleEventAsync(SfsAgreedEntityEventData eventData) { await CreatePurchaseReceiptJob(eventData.Entity).ConfigureAwait(false);