From 82865d4e5150791d0c761832de469a4709ff1fea Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Thu, 11 Apr 2024 13:40:41 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=B8=8D=E5=90=88=E6=A0=BC=E8=BD=AC?= =?UTF-8?q?=E5=90=88=E6=A0=BCbug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Requests/DeliverRequests/DeliverRequestAppService.cs | 2 ++ .../Notes/NoOkConvertOKNoteAutoMapperProfile.cs | 6 +++--- .../Transactions/NoOkConvertOKNoteEventHandler.cs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs index 39849fe91..1ecfa8ea9 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs @@ -248,7 +248,9 @@ public class DeliverRequestAppService : private async Task SetRequestAutoPropertiesAsync(DeliverRequest entity) { + //普通件 var transType = EnumTransSubType.Deliver_Standard; + //jis件 if (entity.DeliverRequestType == EnumDeliverRequestType.FIS) { transType = EnumTransSubType.Deliver_FIS; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/NoOkConvertOKNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/NoOkConvertOKNoteAutoMapperProfile.cs index 141698ecf..4057fecc2 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/NoOkConvertOKNoteAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/NoOkConvertOKNoteAutoMapperProfile.cs @@ -14,10 +14,10 @@ public partial class StoreEventAutoMapperProfile : Profile .ForMember(x => x.DocNumber, y => y.MapFrom(d => d.Number)) .Ignore(x => x.SupplierBatch) - .Ignore(x => x.ProduceDate) + // .Ignore(x => x.ProduceDate) .Ignore(x => x.Worker) - .Ignore(x => x.ArriveDate) - .Ignore(x => x.ExpireDate) + // .Ignore(x => x.ArriveDate) + //.Ignore(x => x.ExpireDate) .Ignore(x => x.ExtraProperties) .Ignore(x => x.TransType) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/NoOkConvertOKNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/NoOkConvertOKNoteEventHandler.cs index 233deef2e..1c2b416a6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/NoOkConvertOKNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/NoOkConvertOKNoteEventHandler.cs @@ -11,7 +11,7 @@ using Win_in.Sfs.Wms.Store.Event.Transaction; namespace Win_in.Sfs.Wms.Store.Event.Transactions; -public class NoOkConvertOkNoteEventHandler +public class NoOkConvertOkNoteEventHandler : StoreInventoryEventHandlerBase , ILocalEventHandler> { From 8f5d372050e8941686f51611a68e857732d54b80 Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Thu, 11 Apr 2024 13:51:20 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9MES=E5=86=BB=E7=BB=93\?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomerItems/ICustomerItemAppService.cs | 5 +- .../CustomerItems/CustomerItemAppService.cs | 12 +++- .../Enums/Inventory/EnumTransSubType.cs | 7 +-- .../Enums/Inventory/EnumTransType.cs | 16 +++++ .../Enums/Store/Statuses/EnumRequestStatus.cs | 22 +++---- .../Store/Types/EnumInjectionModelType.cs | 35 +++++++++++ .../DTOs/CustomerProductionReturnNoteDTO.cs | 8 +++ .../CustomerProductionReturnNoteEditInput.cs | 8 +++ ...CustomerProductionReturnNoteImportInput.cs | 8 +++ .../Notes/MesNotes/DTOs/MesNoteDTO.cs | 3 +- .../Notes/MesNotes/Inputs/MesNoteEditInput.cs | 8 ++- .../DTOs/InjectioModelPlanDTO.cs | 17 +++++ .../Inputs/InjectioModelPlanEditInput.cs | 15 +++++ .../CustomerProductionReturnNoteAppService.cs | 62 +++++++++++++++++-- .../Notes/MesNotes/MesNoteAppService.cs | 36 +++++------ .../InjectioModelPlanAppService.cs | 13 +--- .../CustomerProductionReturnNote.cs | 8 +++ .../Notes/MesNotes/MesNote.cs | 5 +- .../InjectioModelPlans/InjectioModelPlan.cs | 13 ++++ ...urnNoteDbContextModelCreatingExtensions.cs | 2 + ...delPlanDbContextModelCreatingExtensions.cs | 3 + .../Transactions/MesNoteEventHandler.cs | 57 ++++++++--------- 22 files changed, 280 insertions(+), 83 deletions(-) create mode 100644 be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumInjectionModelType.cs diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs index edfc88258..ef35579a0 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Win_in.Sfs.Basedata.Domain; using Win_in.Sfs.Shared.Application.Contracts; namespace Win_in.Sfs.Basedata.Application.Contracts; @@ -7,5 +10,5 @@ public interface ICustomerItemAppService , ISfsUpsertAppService { - + Task> GetListByPartsAsync(List inputs); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs index fc5c14b67..ce6566077 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs @@ -1,8 +1,11 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Volo.Abp.Caching; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain; @@ -36,7 +39,6 @@ public class CustomerItemAppService : SfsBaseDataAppServiceBase(input); @@ -48,4 +50,12 @@ public class CustomerItemAppService : SfsBaseDataAppServiceBase> GetListByPartsAsync(List inputs) + { + return await _repository.WithDetails().Where(p => inputs.Contains(p.ItemCode)).ToListAsync().ConfigureAwait(false); + } + + + } diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs index 1748f2fcf..d29f32c3a 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs @@ -214,12 +214,7 @@ public enum EnumTransSubType /// [Display(Name = "导入盘点计划")] ExcelInCountPlan = 6002, - [Display(Name = "MES冻结")] - MesFreeze = 10001, - [Display(Name = "MES解冻")] - MesUnFreeze = 10002, - [Display(Name = "MES不合格")] - MesUnQualified = 10003 + 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 567d76ef7..e3f777c6d 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 @@ -160,5 +160,21 @@ public enum EnumTransType + /// + /// MES冻结 + /// + [Display(Name = "Mes冻结")] + MesFreezed= 40, + + /// + /// MES冻结 + /// + [Display(Name = "Mes解冻")] + MesUnFreezed = 41, + + + + + } 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 397d7354c..24d08bde0 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 @@ -65,17 +65,17 @@ public enum EnumRequestStatus Partial = 9, - /// - /// 部分完成 - /// - [Display(Name = "已过时")] - Deprecated = 10, - - /// - /// 有更新 - /// - [Display(Name = "有更新")] - Updated = 10, + ///// + ///// 部分完成 + ///// + //[Display(Name = "已过时")] + //Deprecated = 11, + + ///// + ///// 有更新 + ///// + //[Display(Name = "有更新")] + //Updated = 10, diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumInjectionModelType.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumInjectionModelType.cs new file mode 100644 index 000000000..46c97b927 --- /dev/null +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumInjectionModelType.cs @@ -0,0 +1,35 @@ +using System.ComponentModel.DataAnnotations; + +namespace Win_in.Sfs.Shared.Domain.Shared; + +public enum EnumInjectionModelStatus +{ + /// + /// 有更新 + /// + [Display(Name = "有更新")] + Updated = 10, + + + /// + /// 执行中 + /// + [Display(Name = "执行中")] + Handling = 5, +/// +/// 部分完成 +/// + [Display(Name = "已过时")] + Deprecated = 11, + /// + /// 已完成 + /// + [Display(Name = "已完成")] + Completed = 6, + + /// + /// 新增 + /// + [Display(Name = "新增")] + New = 1 +} 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 index a2bdba696..eccb90065 100644 --- 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 @@ -15,6 +15,14 @@ public class CustomerProductionReturnNoteDTO : SfsStoreDTOBase + ///客户编码 + /// + [Display(Name = "客户编码")] + public string CustomerCode { get; set; } + + /// /// 退料单号 /// 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 index 55b2ebbfa..68d41a658 100644 --- 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 @@ -23,6 +23,14 @@ public class CustomerProductionReturnNoteEditInput : SfsStoreCreateOrUpdateInput [Display(Name = "退料时间")] public DateTime ReturnTime { get; set; } + + /// + ///客户编码 + /// + [Display(Name = "客户编码")] + public string CustomerCode { get; set; } + + /// /// 退料申请单号 /// 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 index 7a307acb5..328f28171 100644 --- 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 @@ -26,6 +26,14 @@ public class CustomerProductionReturnNoteImportInput : SfsStoreImportInputBase [Display(Name = "退料单号")] public string ProductionReturnRequestNumber { get; set; } + + /// + ///客户编码 + /// + [Display(Name = "客户编码")] + public string CustomerCode { get; set; } + + /// /// 采购订单号 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs index 24ca29a90..2279a842b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using Win_in.Sfs.Shared.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -12,7 +13,7 @@ public class MesNoteDTO : SfsStoreDTOBase, IHasNumber public string JobNumber { get; set; } /// - /// 类型 + /// Mes类型(40-冻结、41-解冻 ) /// [Display(Name = "类型")] public string Type { get; set; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs index ee271489d..e853ee4cb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Types; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -28,7 +29,7 @@ public class MesNoteEditInput : SfsStoreCreateOrUpdateInputBase public string MesRequestNumber { get; set; } /// - /// 报废类型 + /// Mes类型(40-冻结、41-解冻 ) /// [Display(Name = "类型")] public string Type { get; set; } @@ -38,5 +39,10 @@ public class MesNoteEditInput : SfsStoreCreateOrUpdateInputBase /// [Display(Name = "明细列表")] public List Details { get; set; } + + + + + #endregion } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/InjectioModelPlans/DTOs/InjectioModelPlanDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/InjectioModelPlans/DTOs/InjectioModelPlanDTO.cs index a1ef41be7..0c404f3a1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/InjectioModelPlans/DTOs/InjectioModelPlanDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/InjectioModelPlans/DTOs/InjectioModelPlanDTO.cs @@ -2,6 +2,7 @@ using System; using System.ComponentModel.DataAnnotations; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -10,6 +11,22 @@ namespace Win_in.Sfs.Wms.Store.Application.Contracts; /// public class InjectioModelPlanDTO : SfsStoreRequestDTOBase, IHasNumber { + + + [ExporterHeader(DisplayName = "状态")] + public EnumInjectionModelStatus Status { get; set; } + + + [ExporterHeader(DisplayName = "版本号")] + /// + /// 版本号 + /// + public string Version { get; set; } + + + + + /// /// 车间 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/InjectioModelPlans/Inputs/InjectioModelPlanEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/InjectioModelPlans/Inputs/InjectioModelPlanEditInput.cs index b73556b51..5642d7c2f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/InjectioModelPlans/Inputs/InjectioModelPlanEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/InjectioModelPlans/Inputs/InjectioModelPlanEditInput.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -67,6 +69,19 @@ public class InjectioModelPlanEditInput : SfsStoreRequestCreateOrUpdateInputBase [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] public string Number { get; set; } + [Display(Name = "状态")] + public EnumInjectionModelStatus Status { get; set; } + + + [Display(Name = "版本号")] + /// + /// 版本号 + /// + public string Version { 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 index 18cd05414..3a3ea6b86 100644 --- 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 @@ -1,6 +1,10 @@ +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Omu.ValueInjecter; +using Volo.Abp; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; @@ -20,11 +24,21 @@ public class CustomerProductionReturnNoteAppService : { private readonly ICustomerProductionReturnNoteManager _CustomerProductionReturnNoteManager; + + private readonly ICustomerItemAppService _customerItemAppService; + public CustomerProductionReturnNoteAppService( ICustomerProductionReturnNoteRepository repository , ICustomerProductionReturnNoteManager CustomerProductionReturnNoteManager + , ICustomerItemAppService customerItemAppService ) : base(repository) { + + + _customerItemAppService = customerItemAppService; + + + _CustomerProductionReturnNoteManager = CustomerProductionReturnNoteManager; } @@ -37,16 +51,56 @@ public class CustomerProductionReturnNoteAppService : //[Authorize(CustomerProductionReturnNotePermissions.Create)] public override async Task CreateAsync(CustomerProductionReturnNoteEditInput input) { - var entity = ObjectMapper.Map(input); + var entity = ObjectMapper.Map(input); + + + var parts= input.Details.Select(itm => itm.ItemCode).Distinct(); + + var custitmDetail = await _customerItemAppService.GetListByPartsAsync(parts.ToList()).ConfigureAwait(false); + + var checkPart= from itm in entity.Details.ToList() + join itm1 in custitmDetail + on itm.ItemCode equals itm1.ItemCode + into temp + from tm in temp.DefaultIfEmpty() + where tm == null + select itm; + + var partErr = checkPart.Select(x => x.ItemCode).Distinct().ToList(); + if (partErr.Count > 0) + { + throw new UserFriendlyException($"客户零件{string.Join(",",partErr)}不在零件关系表中,不能退货!"); + } + var checkCustomer= from itm in entity.Details.ToList() + join itm1 in custitmDetail + on itm.ItemCode equals itm1.ItemCode + select itm1; + + var custErr= checkCustomer.Select(x => x.CustomerCode).Distinct().ToList(); + if (custErr.Count > 1) + { + throw new UserFriendlyException($"提交客户退货零件{string.Join(",", custErr)}存在多个客户,不能退货!"); + } + if(entity.Details.Count>0) + { + entity.CustomerCode = checkCustomer.FirstOrDefault().CustomerCode; + } foreach (var itm in entity.Details) { - itm.FromLocationCode = "HOLD"; + itm.FromLocationCode = "OK"; itm.FromStatus = EnumInventoryStatus.OK; itm.ToStatus=EnumInventoryStatus.OK; + itm.FromLocationArea = "OK"; + itm.FromLocationErpCode= "OK"; + itm.FromLot = "NONE"; + itm.FromPackingCode = "NONE"; + itm.FromWarehouseCode = "OK"; + itm.FromLocationGroup = "OK"; + itm.FromContainerCode = "OK"; + itm.ToContainerCode =string.IsNullOrEmpty(itm.ToContainerCode)? "OK": itm.ToContainerCode; + itm.ToWarehouseCode= string.IsNullOrEmpty(itm.ToWarehouseCode)? "OK": itm.ToContainerCode; } - - 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/MesNotes/MesNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/MesNotes/MesNoteAppService.cs index 66fcf43a8..6761b6b39 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 @@ -83,24 +83,24 @@ public class MesNoteAppService : #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) - // { - // throw new UserFriendlyException($"库存数量不足"); - // } - //} - //else - //{ - // throw new UserFriendlyException($"库存数量不足"); - //} + 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) + { + throw new UserFriendlyException($"库存数量不足"); + } + } + else + { + throw new UserFriendlyException($"库存数量不足"); + } #endregion } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/InjectioModelPlans/InjectioModelPlanAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/InjectioModelPlans/InjectioModelPlanAppService.cs index 60b7e77a5..0301212a3 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/InjectioModelPlans/InjectioModelPlanAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/InjectioModelPlans/InjectioModelPlanAppService.cs @@ -29,24 +29,17 @@ public class InjectioModelPlanAppService : { private readonly IBomAppService _bomAppService; private readonly IInjectioModelPlanManager _InjectioModelPlanManager; - //private readonly IWorkShopAppService _workShopApp; -/* private readonly IProductionLineAppService _productionLineApp*/ - //private readonly ITeamAppService _teamApp; - //private readonly IShiftAppService _shiftApp; + public InjectioModelPlanAppService(IInjectioModelPlanRepository repository, IInjectioModelPlanManager InjectioModelPlanManager , IWorkShopAppService workShopApp , IBomAppService bomAppService , IProductionLineAppService productionLineApp - //, ITeamAppService teamApp - //, IShiftAppService shiftApp + ) : base(repository, InjectioModelPlanManager) { - //_workShopApp = workShopApp; - //_productionLineApp = productionLineApp; - //_teamApp = teamApp; - //_shiftApp = shiftApp; + _InjectioModelPlanManager = InjectioModelPlanManager; _bomAppService=bomAppService; base.CreatePolicyName = InjectioModelPlanPermissions.Create; 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 index fccb34c56..19dc19e07 100644 --- 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 @@ -20,6 +20,14 @@ public class CustomerProductionReturnNote : SfsStoreAggregateRootBase public string ProductionReturnRequestNumber { get; set; } + + /// + ///客户编码 + /// + public string CustomerCode { get; set; } + + + /// /// 退料时间 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs index 8f08e2041..646af7ad9 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs @@ -1,11 +1,12 @@ using System.Collections.Generic; using Win_in.Sfs.Shared.Domain.Entities; +using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Types; namespace Win_in.Sfs.Wms.Store.Domain; /// -/// 报废记录 +/// MES冻结记录 /// public class MesNote : SfsStoreAggregateRootBase, IHasJobNumber { @@ -22,7 +23,7 @@ public class MesNote : SfsStoreAggregateRootBase, IHasJobNumber public string MesRequestNumber { get; set; } /// - /// Mes类型 + /// Mes类型(40-冻结、41-解冻 ) /// [IgnoreUpdate] public string Type { get; set; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/InjectioModelPlans/InjectioModelPlan.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/InjectioModelPlans/InjectioModelPlan.cs index 2cdbb99ae..a90b9a1c7 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/InjectioModelPlans/InjectioModelPlan.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Plans/InjectioModelPlans/InjectioModelPlan.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using Win_in.Sfs.Shared.Domain.Entities; +using Win_in.Sfs.Shared.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Domain; @@ -41,6 +42,18 @@ public class InjectioModelPlan : SfsStoreRequestAggregateRootBase public DateTime PlanTime { get; set; } + /// + /// 版本号 + /// + public string Version { get; set; } + + /// + /// 状态 + /// + public EnumInjectionModelStatus Status { get; set; } + + + /// /// 明细列表 /// 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 index 889790ab7..c1837a8a2 100644 --- 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 @@ -20,6 +20,8 @@ public static class CustomerProductionReturnNoteDbContextModelCreatingExtensions b.ConfigureSfsStoreBase(); //Properties b.Property(q => q.JobNumber).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.CustomerCode).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.ProductionReturnRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength); //Relations b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Plans/InjectioModelPlans/InjectioModelPlanDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Plans/InjectioModelPlans/InjectioModelPlanDbContextModelCreatingExtensions.cs index ec79d5edd..5fe030413 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Plans/InjectioModelPlans/InjectioModelPlanDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Plans/InjectioModelPlans/InjectioModelPlanDbContextModelCreatingExtensions.cs @@ -26,6 +26,9 @@ public static class InjectioModelPlanDbContextModelCreatingExtensions b.Property(q => q.PlanDate).IsRequired(); b.Property(q => q.PlanTime).IsRequired(); + + b.Property(q => q.Version).HasMaxLength(SfsPropertyConst.NameLength); + b.Property(q => q.RequestStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion(); //Relations 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 index 52ef2f6a6..ec09b362f 100644 --- 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 @@ -19,7 +19,9 @@ public class MesNoteEventHandler , ILocalEventHandler>> { - private const EnumTransType TransType = EnumTransType.Scrap; + //private const EnumTransType FreezedTransType = EnumTransType.MesFreezed; + + //private const EnumTransType UnFreezedTransType = EnumTransType.MesUnFreezed; [UnitOfWork] public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) @@ -52,9 +54,6 @@ public class MesNoteEventHandler //else //{ - - - var transferLogs = new List(); foreach (var MesNote in MesNotes) @@ -63,24 +62,26 @@ public class MesNoteEventHandler } await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); - var transactions = new List(); - foreach (var MesNote in MesNotes) - { - transactions.AddRange(BuildTransactions(MesNote)); - } + //var transactions = new List(); + //foreach (var MesNote in MesNotes) + //{ + // transactions.AddRange(BuildTransactions(MesNote)); + //} - await TransactionAppService.AddManyAsync(transactions).ConfigureAwait(false); + //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.TransType = Enum.Parse(MesNote.Type); ; + transferLog.TransSubType = EnumTransSubType.None; transferLog.Worker = MesNote.Worker; transferLog.DocNumber = MesNote.Number; transferLog.JobNumber = MesNote.JobNumber; @@ -90,24 +91,24 @@ public class MesNoteEventHandler return transferLogs; } - private List BuildTransactions(MesNote deliverNote) - { - var transactions = new List(); + //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); - } + // foreach (var detail in deliverNote.Details) + // { + // var transaction = ObjectMapper.Map(detail); + // transaction.TransType = deliverNote.Type; + // transaction.TransInOut = EnumTransInOut.Out; + // transaction.Worker = deliverNote.Worker; + // transaction.DocNumber = deliverNote.Number; + // transaction.JobNumber = deliverNote.JobNumber; - return transactions; - } + // transactions.Add(transaction); + // } + + // return transactions; + //} #endregion } From 6e9f907b4fc2a338afb126644394fee2785401af Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Thu, 11 Apr 2024 15:14:25 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E9=80=80=E6=8B=86?= =?UTF-8?q?=E4=B8=AD=E6=AD=A2=E7=94=B3=E8=AF=B7=E5=AE=8C=E6=88=90=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IProductRecycleJobAppService.cs | 2 +- .../Bases/SfsStoreRequestAppServiceBase.cs | 2 +- .../ProductRecycleJobAppService.cs | 29 ++++++++++++++++--- .../ProductRecycleRequestEventHandler.cs | 18 ++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/ProductRecycleJobs/IProductRecycleJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/ProductRecycleJobs/IProductRecycleJobAppService.cs index 3af319f51..f41ed94ed 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/ProductRecycleJobs/IProductRecycleJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/ProductRecycleJobs/IProductRecycleJobAppService.cs @@ -7,5 +7,5 @@ public interface IProductRecycleJobAppService : ISfsJobAppServiceBase { - + Task CompleteByRequestNumberAsync(string number); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsStoreRequestAppServiceBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsStoreRequestAppServiceBase.cs index 36465700c..e7b150b70 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsStoreRequestAppServiceBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Bases/SfsStoreRequestAppServiceBase.cs @@ -129,7 +129,7 @@ public abstract class SfsStoreRequestAppServiceBase [HttpPost("abort/{id}")] public virtual async Task AbortAsync(Guid id) - { + { var entity = await _repository.FindAsync(id).ConfigureAwait(false); Check.NotNull(entity, typeof(TEntity).Name); var result = await _requestManager.AbortAsync(entity).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/ProductRecycleJobs/ProductRecycleJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/ProductRecycleJobs/ProductRecycleJobAppService.cs index 241b1b062..76d29157b 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/ProductRecycleJobs/ProductRecycleJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/ProductRecycleJobs/ProductRecycleJobAppService.cs @@ -8,6 +8,10 @@ using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; +using Volo.Abp.Domain.Entities; +using static Volo.Abp.Identity.Settings.IdentitySettingNames; +using Volo.Abp.Users; +using Volo.Abp.Domain.Repositories; namespace Win_in.Sfs.Wms.Store.Application; @@ -19,13 +23,14 @@ public class ProductRecycleJobAppService , IProductRecycleJobAppService { private readonly IProductRecycleJobManager _productRecycleJobManager; - + private readonly IProductRecycleJobRepository _repository; private readonly IProductRecycleRequestAppService _productRecycleRequestAppService; public ProductRecycleJobAppService( IProductRecycleJobRepository repository, IProductRecycleJobManager productRecycleJobManager, IProductRecycleRequestAppService productRecycleRequestAppService) : base(repository, productRecycleJobManager) { + _repository = repository; _productRecycleJobManager = productRecycleJobManager; _productRecycleRequestAppService = productRecycleRequestAppService; } @@ -37,7 +42,7 @@ public class ProductRecycleJobAppService /// [HttpPost("handle/{id}")] [UnitOfWork] - public override async Task CompleteAsync(Guid id, ProductRecycleJobDTO dto) + public override async Task CompleteAsync(Guid id, ProductRecycleJobDTO dto) { var handleEntity = ObjectMapper.Map(dto); var job = await _repository.GetAsync(id).ConfigureAwait(false); @@ -48,11 +53,27 @@ public class ProductRecycleJobAppService var handleResult = await _productRecycleJobManager.CompleteAsync(handleEntity, job, CurrentUser).ConfigureAwait(false); //判断申请是否执行完成 - if(job.JobStatus== EnumJobStatus.Done) + if (job.JobStatus == EnumJobStatus.Done) { - await _productRecycleRequestAppService.UpdateStatusByNumberAsync(job.RequestNumber).ConfigureAwait(false); + await _productRecycleRequestAppService.UpdateStatusByNumberAsync(job.RequestNumber).ConfigureAwait(false); } var handleDto = ObjectMapper.Map(handleResult); return handleDto; } + /// + /// 根据请求号完成任务 + /// + /// + /// + [HttpPost("complete-by-request-number")] + public async Task CompleteByRequestNumberAsync(string number) + { + var entity = await _repository.FirstOrDefaultAsync(r => r.RequestNumber == number).ConfigureAwait(false); + await entity.CompleteAsync(CurrentUser.Id, CurrentUser.Name, Clock.Now).ConfigureAwait(false); + + var updatejob = await _repository.UpdateAsync(entity).ConfigureAwait(false); + var dto = ObjectMapper.Map(updatejob); + + return dto; + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductRecycleRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductRecycleRequestEventHandler.cs index 9b82cb14f..8631f3045 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductRecycleRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductRecycleRequestEventHandler.cs @@ -21,6 +21,7 @@ public class ProductRecycleRequestEventHandler , ILocalEventHandler> , ILocalEventHandler> , ILocalEventHandler>> + , ILocalEventHandler> { private readonly IProductRecycleJobAppService _productRecycleJobAppService; private readonly IProductRecycleNoteAppService _productRecycleNoteApp; @@ -50,6 +51,21 @@ public class ProductRecycleRequestEventHandler } + /// + /// 中止 + /// + /// + /// + /// + [UnitOfWork] + public async Task HandleEventAsync(SfsAbortedEntityEventData eventData) + { + var number = eventData.Entity?.Number; + if (!string.IsNullOrEmpty(number)) + { + await _productRecycleJobAppService.CompleteByRequestNumberAsync(number).ConfigureAwait(false); + } + } /// /// 创建后 /// @@ -278,6 +294,8 @@ public class ProductRecycleRequestEventHandler return detailInput; } + + #endregion From 003b58990e492de3bb3f6cb3db8ce5c89dc994a3 Mon Sep 17 00:00:00 2001 From: liuyunfeng Date: Thu, 11 Apr 2024 15:16:26 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=8F=8D=E5=B0=84?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TransferLibJobAppService.cs | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs index 16fc0eacd..2cf35fe22 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/TransferLibJobs/TransferLibJobAppService.cs @@ -35,13 +35,8 @@ public class TransferLibJobAppService /// public override async Task CompleteAsync(Guid id, TransferLibJobDTO dto) { - var str = "Win_in.Sfs.Wms.Store.Application.InjectionJobAppService"; - var implementation=_serviceProvider.GetService(Type.GetType("Win_in.Sfs.Wms.Store.Application.InjectionJobAppService")); - MethodInfo methodInfo=implementation.GetType().GetMethod("Test"); - methodInfo.Invoke(implementation, null); - + //var str = "Win_in.Sfs.Wms.Store.Application.InjectionJobAppService"; string methodPrefix = "TransferLibJobAppService.CompleteAsync - "; - if (dto.CallServerName.IsNullOrEmpty()) { throw new UserFriendlyException($"{methodPrefix}CallServerName 不能为空"); @@ -62,18 +57,17 @@ public class TransferLibJobAppService var ret = await base.CompleteAsync(id, dto).ConfigureAwait(false); if (ret != null) { - var assembly = Assembly.GetExecutingAssembly(); - var ty = assembly.GetType(dto.CallServerName); + Type ty = Type.GetType(dto.CallServerName); if (ty == null) { throw new UserFriendlyException($"{methodPrefix}没有找到类型为{dto.CallServerName}的对象"); } - var instance = Activator.CreateInstance(ty); + var instance = _serviceProvider.GetService(ty); if (instance == null) { throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象创建失败"); } - ITransferLibCallback transferLibCallback = (ITransferLibCallback)instance; + ITransferLibCallback transferLibCallback = (Win_in.Sfs.Wms.Store.Notes.ITransferLibCallback)instance; if (transferLibCallback == null) { throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象没有实现ITransferLibCallback接口"); @@ -83,6 +77,27 @@ public class TransferLibJobAppService { throw new UserFriendlyException($"{methodPrefix}执行回调服务{dto.CallServerName}出错,返回错误信息:{callbackRet.Item2}"); } + //var assembly = Assembly.GetExecutingAssembly(); + //var ty = assembly.GetType(dto.CallServerName); + //if (ty == null) + //{ + // throw new UserFriendlyException($"{methodPrefix}没有找到类型为{dto.CallServerName}的对象"); + //} + //var instance = Activator.CreateInstance(ty); + //if (instance == null) + //{ + // throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象创建失败"); + //} + //ITransferLibCallback transferLibCallback = (ITransferLibCallback)instance; + //if (transferLibCallback == null) + //{ + // throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象没有实现ITransferLibCallback接口"); + //} + //Tuple callbackRet = transferLibCallback.DoTransferLibCallback(dto.CallServerName, dto.CallRequestNumber, dto.CallJobNumber); + //if (callbackRet != null && callbackRet.Item1 == false) + //{ + // throw new UserFriendlyException($"{methodPrefix}执行回调服务{dto.CallServerName}出错,返回错误信息:{callbackRet.Item2}"); + //} } return ret; } From d012d72d5983d5175daa4c67695d2d6864bbce7a Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Fri, 12 Apr 2024 09:25:26 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=B8=89=E6=96=B9=E5=BA=93=E5=BA=93?= =?UTF-8?q?=E7=A7=BB=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTOs/ThirdLocationRequestDTO.cs | 31 +--- .../DTOs/ThirdLocationRequestDetailDTO.cs | 24 +++ .../ThirdLocationRequestAppService.cs | 24 +++ .../ThirdLocationRequestDetail.cs | 10 +- ...RequestDbContextModelCreatingExtensions.cs | 1 + .../ThirdLocationRequestAutoMapperProfile.cs | 24 +++ .../Jobs/ThirdLocationJobEventHandler.cs | 9 + .../ThirdLocationRequestEventHandler.cs | 125 +++++++++++++- .../ThirdLocationNoteEventHandler.cs | 157 ++++++++++++++++++ 9 files changed, 373 insertions(+), 32 deletions(-) create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ThirdLocationNoteEventHandler.cs diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDTO.cs index 6d2ed2559..93fe43f89 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDTO.cs @@ -5,41 +5,22 @@ namespace Win_in.Sfs.Wms.Store.Application.Contracts; public class ThirdLocationRequestDTO : SfsStoreRequestDTOBase, IHasNumber { /// - /// 叫料类型 + /// 类型 /// - [Display(Name = "叫料类型")] + [Display(Name = "类型")] public string Type { get; set; } /// - /// 生产线 + /// 生产线 /// [Display(Name = "生产线")] public string ProdLine { get; set; } /// - /// 是否使用在途库 + /// 是否使用在途库 /// [Display(Name = "是否使用在途库")] - public bool IsUseOnTheWayLocation { get; set; } + public bool IsUseOnTheWayLocation { get; set; } - /// - /// 可用来源库位Json集合 - /// - public string FromLocationCodeJsonList { get; set; } - - /// - /// 叫料库位 - /// - public string ToLocationCode { get; set; } - - /// - /// 目标ERP储位 - /// - [Display(Name = "目标ERP储位")] - public string ToLocationErpCode { get; set; } - - /// - /// 来源库区 - /// - public string FromLocationArea { get; set; } + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDetailDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDetailDTO.cs index bd0610ac6..92b149911 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDetailDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDetailDTO.cs @@ -8,6 +8,30 @@ namespace Win_in.Sfs.Wms.Store.Application.Contracts; public class ThirdLocationRequestDetailDTO : SfsStoreDetailWithQtyDTOBase { + /// + /// 目标库位 + /// + [Display(Name = "目标库位")] + public string ToLocationCode { get; set; } + + /// + /// 目标ERP储位 + /// + [Display(Name = "目标ERP储位")] + public string ToLocationErpCode { get; set; } + + /// + /// 来源库位 + /// + [Display(Name = "来源库位")] + public string FromLocationCode { get; set; } + + /// + /// 来源库区 + /// + [Display(Name = "来源库区")] + public string FromLocationArea { get; set; } + /// /// 已发数量 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAppService.cs index 11983f745..27aa94ea5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAppService.cs @@ -20,6 +20,7 @@ using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain; 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.Domain.Shared; @@ -44,6 +45,8 @@ public class ThirdLocationRequestAppService : SfsStoreRequestAppServiceBase realityBalance) + { + throw new UserFriendlyException($"{detailInput.ItemCode} 物品的库存为 {realityBalance} ,库存不够"); + } detailInput.ProdLine = detailInput.ToLocationCode; detailInput.ToLocationErpCode = toLocationDto.ErpLocationCode; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestDetail.cs index c8e5b798b..f3f221923 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestDetail.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestDetail.cs @@ -44,13 +44,13 @@ public class ThirdLocationRequestDetail : SfsStoreDetailWithQtyEntityBase, IHasT /// 来源库区 /// public string FromLocationArea { get; set; } - - // /// - // /// 在途库库位 - // /// - // public string OnTheWayLocationCode { get; set; } + + /// + /// 在途库库位 + /// + public string OnTheWayLocationCode { get; set; } /// /// 生产线 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ThirdLocationRequests/ThirdLocationRequestDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ThirdLocationRequests/ThirdLocationRequestDbContextModelCreatingExtensions.cs index 087829cc1..f6a4a922f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ThirdLocationRequests/ThirdLocationRequestDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ThirdLocationRequests/ThirdLocationRequestDbContextModelCreatingExtensions.cs @@ -48,6 +48,7 @@ public static class ThirdLocationRequestDbContextModelCreatingExtensions b.Property(q => q.ToLocationGroup).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.FromLocationCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.FromLocationArea).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.OnTheWayLocationCode).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.ExpiredTime).IsRequired(); b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.WorkStation).HasMaxLength(SfsPropertyConst.CodeLength); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/ThirdLocationRequestAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/ThirdLocationRequestAutoMapperProfile.cs index b336d5613..1dcf048bb 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/ThirdLocationRequestAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/ThirdLocationRequestAutoMapperProfile.cs @@ -11,6 +11,30 @@ public partial class StoreEventAutoMapperProfile : Profile { private void ThirdLocationRequestAutoMapperProfile() { + CreateMap() + .Ignore(x => x.DocNumber) + .Ignore(x => x.JobNumber) + .Ignore(x => x.Worker) + .Ignore(x => x.TransType) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.TransSubType) + .Ignore(x => x.FromPackingCode) + .Ignore(x => x.ToPackingCode) + .Ignore(x => x.FromLot) + .Ignore(x => x.FromStatus) + .Ignore(x => x.FromWarehouseCode) + .Ignore(x => x.FromLocationGroup) + .Ignore(x => x.FromLocationErpCode) + .Ignore(x => x.FromContainerCode) + .Ignore(x => x.ToLot) + .Ignore(x => x.SupplierBatch) + .Ignore(x => x.ArriveDate) + .Ignore(x => x.ProduceDate) + .Ignore(x => x.ExpireDate) + .Ignore(x => x.ToStatus) + .Ignore(x => x.ToContainerCode) + ; + CreateMap() .ForMember(x => x.RequestNumber, y => y.MapFrom(d => d.Number)) .ForMember(x => x.RequestType, y => y.MapFrom(d => d.Type)) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ThirdLocationJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ThirdLocationJobEventHandler.cs index 1e19d26bc..23151e7ad 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ThirdLocationJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ThirdLocationJobEventHandler.cs @@ -37,6 +37,15 @@ public class ThirdLocationJobEventHandler : public virtual async Task HandleEventAsync(SfsCompletedEntityEventData eventData) { var entity = eventData.Entity; + + entity.CompleteTime = Clock.Now; + entity.JobStatus = EnumJobStatus.Done; + + foreach (var detail in eventData.Entity.Details) + { + detail.SetHandledFromRecommend(); + } + var thirdLocationNote = await BuildThirdLocationNoteAsync(entity).ConfigureAwait(false); await _thirdLocationNoteAppService.CreateAsync(thirdLocationNote).ConfigureAwait(false); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ThirdLocationRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ThirdLocationRequestEventHandler.cs index ca4800d8d..ec4586e0c 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ThirdLocationRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ThirdLocationRequestEventHandler.cs @@ -1,8 +1,10 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using FluentValidation.Validators; +using IdentityServer4.Models; using Volo.Abp; using Volo.Abp.EventBus; using Volo.Abp.SettingManagement; @@ -13,6 +15,7 @@ using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; +using Win_in.Sfs.Wms.Store.Event.Transactions; namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; @@ -30,11 +33,16 @@ public class ThirdLocationRequestEventHandler private readonly ILocationAppService _locationAppService; private readonly IBalanceAppService _balanceAppService; + private const EnumTransType TransType = EnumTransType.TransferLib; + + private readonly ITransferLogAppService _transferLogAppService; + public ThirdLocationRequestEventHandler( IThirdLocationJobAppService thirdLocationJobAppService , IProductionLineAppService productionLineAppService , IThirdLocationRequestManager thirdLocationRequestManager , ILocationAppService locationAppService + , ITransferLogAppService transferLogAppService , IBalanceAppService balanceAppService) { _thirdLocationJobAppService = thirdLocationJobAppService; @@ -42,6 +50,7 @@ public class ThirdLocationRequestEventHandler _thirdLocationRequestManager = thirdLocationRequestManager; _locationAppService = locationAppService; _balanceAppService = balanceAppService; + _transferLogAppService = transferLogAppService; } /// @@ -88,8 +97,108 @@ public class ThirdLocationRequestEventHandler { await _thirdLocationJobAppService.CreateManyAsync(thirdLocationJobs).ConfigureAwait(false); } + + //来源库位更新为在途库位 + var transferLogs = new List(); + var route = entity.UseOnTheWayLocation + ? EnumTransferRoute.SourceToOnTheWay + : EnumTransferRoute.SourceToDestination; + transferLogs.AddRange(await BuildTransferLogsAsync(entity, route).ConfigureAwait(false)); + + + await _transferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + + } + + private async Task> BuildTransferLogsAsync(ThirdLocationRequest thirdLocationRequest, EnumTransferRoute route) + { + var transferLogs = new List(); + foreach (var detail in thirdLocationRequest.Details.Where(detail => detail.Qty != 0)) + { + var transferLog = ObjectMapper.Map(detail); + + LocationDTO fromLocationDTO = null; + LocationDTO toLocationDTO = null; + var transportLocation = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.TRANSPORT).ConfigureAwait(false); + if (transportLocation != null) + { + detail.OnTheWayLocationCode = transportLocation.Code; + } + else + { + throw new UserFriendlyException($"未获取到在途库代码"); + } + + + if (thirdLocationRequest.UseOnTheWayLocation) + { + var location = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + switch (route) + { + case EnumTransferRoute.SourceToOnTheWay: + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); + + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + break; + case EnumTransferRoute.OnTheWayToDestination: + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + + await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog).ConfigureAwait(false); + break; + case EnumTransferRoute.SourceToDestination: + default: + throw new ArgumentOutOfRangeException(nameof(route), route, null); + } + } + else + { + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + } + + transferLog.FromLocationCode = fromLocationDTO.Code; + transferLog.FromLocationArea = fromLocationDTO.AreaCode; + transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode; + transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode; + transferLog.FromWarehouseCode = fromLocationDTO.WarehouseCode; + + transferLog.ToLocationCode = toLocationDTO.Code; + transferLog.ToLocationArea = toLocationDTO.AreaCode; + transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode; + transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode; + transferLog.ToWarehouseCode = toLocationDTO.WarehouseCode; + transferLog.TransSubType = Enum.Parse(thirdLocationRequest.Type); + transferLog.TransType = TransType; + transferLog.DocNumber = thirdLocationRequest.Number; + transferLog.JobNumber = ""; + + transferLog.FromPackingCode = ""; + transferLog.FromLot = ""; + transferLog.ToPackingCode = ""; + transferLog.ToLot = ""; + transferLog.FromStatus = EnumInventoryStatus.OK; + transferLog.ToStatus = EnumInventoryStatus.OK; + transferLogs.Add(transferLog); + } + + return transferLogs; + } + + private async Task RemovePackingCodeAndContainerCodeAndLotAsync(TransferLogEditInput transferLogCreateInput) + { + transferLogCreateInput.ToPackingCode = ""; + transferLogCreateInput.ToLot = ""; + transferLogCreateInput.ToContainerCode = ""; + + transferLogCreateInput.FromPackingCode = ""; + transferLogCreateInput.FromLot = ""; + transferLogCreateInput.FromContainerCode = ""; + } + /// /// 驳回后 /// @@ -245,7 +354,7 @@ public class ThirdLocationRequestEventHandler //ProductionLineDTO prodLine = await _productionLineAppService.GetByLocationGroupCodeAsync(toLocationGroupCode).ConfigureAwait(false); var detail = ObjectMapper.Map(balance); - detail.FromLocationCode = thirdLocationRequestDetail.FromLocationCode; + detail.WorkStation = thirdLocationRequestDetail.WorkStation; detail.ExpiredTime = thirdLocationRequestDetail.ExpiredTime; detail.PositionCode = thirdLocationRequestDetail.PositionCode; @@ -271,7 +380,19 @@ public class ThirdLocationRequestEventHandler detail.ToLocationErpCode = thirdLocationRequestDetail.ToLocationErpCode; detail.ToLocationArea = thirdLocationRequestDetail.ToLocationArea; detail.ToWarehouseCode = thirdLocationRequestDetail.ToWarehouseCode; - detail.FromLocationArea = thirdLocationRequestDetail.FromLocationArea; + + var transportLocation = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.TRANSPORT).ConfigureAwait(false); + if (transportLocation != null) + { + detail.FromLocationCode = transportLocation.Code; + detail.FromLocationArea = transportLocation.AreaCode; + } + else + { + throw new UserFriendlyException($"未获取到在途库代码"); + } + + //detail.ProdLine = prodLine == null ? toLocationGroupCode : prodLine.Code; detail.ProdLine = toLocationGroupCode; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ThirdLocationNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ThirdLocationNoteEventHandler.cs new file mode 100644 index 000000000..2199cfc75 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ThirdLocationNoteEventHandler.cs @@ -0,0 +1,157 @@ +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.Basedata.Application.Contracts; +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.Event.Transaction; + +namespace Win_in.Sfs.Wms.Store.Event.Transactions; + +public class ThirdLocationNoteEventHandler + : StoreInventoryEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> + , ILocalEventHandler> +{ + private const EnumTransType TransType = EnumTransType.TransferLib; + + private readonly ILocationAppService _locationAppService; + + public ThirdLocationNoteEventHandler(ILocationAppService locationAppService) + { + _locationAppService = locationAppService; + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + var transferLogs = new List(); + var route = EnumTransferRoute.OnTheWayToDestination; + + transferLogs.AddRange(await BuildTransferLogsAsync(entity, route).ConfigureAwait(false)); + + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + var transferLogs = new List(); + //如果要做库存事务汇总,可以修改此处 + foreach (var thirdLocationNote in entities) + { + var route = EnumTransferRoute.OnTheWayToDestination; + + transferLogs.AddRange(await BuildTransferLogsAsync(thirdLocationNote, route).ConfigureAwait(false)); + } + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } + + [UnitOfWork] + + public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData eventData) + { + var entity = eventData.Entity; + + var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination).ConfigureAwait(false); + await AddTransferLogsAsync(inputList).ConfigureAwait(false); + } + + private async Task AddTransferLogsAsync(List inputList) + { + var transferLogs = new List(); + + transferLogs.AddRange(inputList); + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + + } + + private async Task> BuildTransferLogsAsync(ThirdLocationNote thirdLocationNote, EnumTransferRoute route) + { + var transferLogs = new List(); + foreach (var detail in thirdLocationNote.Details.Where(detail => detail.Qty != 0)) + { + var transferLog = ObjectMapper.Map(detail); + + LocationDTO fromLocationDTO = null; + LocationDTO toLocationDTO = null; + + if (thirdLocationNote.UseOnTheWayLocation) + { + var location = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + switch (route) + { + case EnumTransferRoute.SourceToOnTheWay: + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); + + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + break; + case EnumTransferRoute.OnTheWayToDestination: + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + + await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog).ConfigureAwait(false); + break; + case EnumTransferRoute.SourceToDestination: + default: + throw new ArgumentOutOfRangeException(nameof(route), route, null); + } + } + else + { + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + } + + transferLog.FromLocationCode = fromLocationDTO.Code; + transferLog.FromLocationArea = fromLocationDTO.AreaCode; + transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode; + transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode; + + transferLog.ToLocationCode = toLocationDTO.Code; + transferLog.ToLocationArea = toLocationDTO.AreaCode; + transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode; + transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode; + transferLog.TransSubType = Enum.Parse(thirdLocationNote.RequestType); + transferLog.TransType = TransType; + transferLog.DocNumber = thirdLocationNote.Number; + transferLog.JobNumber = thirdLocationNote.JobNumber; + + transferLog.FromPackingCode = ""; + transferLog.FromLot = ""; + transferLog.ToPackingCode = ""; + transferLog.ToLot = ""; + transferLog.FromStatus = EnumInventoryStatus.OK; + transferLog.ToStatus = EnumInventoryStatus.OK; + + transferLogs.Add(transferLog); + } + + return transferLogs; + } + + private async Task RemovePackingCodeAndContainerCodeAndLotAsync(TransferLogEditInput transferLogCreateInput) + { + transferLogCreateInput.ToPackingCode = ""; + transferLogCreateInput.ToLot = ""; + transferLogCreateInput.ToContainerCode = ""; + + transferLogCreateInput.FromPackingCode = ""; + transferLogCreateInput.FromLot = ""; + transferLogCreateInput.FromContainerCode = ""; + + } + +} From cb9ac524a3e33b979f54eb56623027b4c0c76284 Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Fri, 12 Apr 2024 10:55:56 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E7=8A=B6=E6=80=81=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PublishProfiles/FolderProfile1.pubxml | 6 +- .../DTOs/ThirdLocationRequestDetailDTO.cs | 7 +- .../Inputs/ThirdLocationRequestDetailInput.cs | 7 +- .../ThirdLocationRequestAutoMapperProfile.cs | 3 +- .../ThirdLocationRequestDetail.cs | 5 +- .../ThirdLocationRequestManager.cs | 77 ++++++++++--------- ...RequestDbContextModelCreatingExtensions.cs | 3 +- .../ThirdLocationRequestEventHandler.cs | 32 +------- .../ThirdLocationNoteEventHandler.cs | 11 ++- 9 files changed, 62 insertions(+), 89 deletions(-) diff --git a/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/Properties/PublishProfiles/FolderProfile1.pubxml b/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/Properties/PublishProfiles/FolderProfile1.pubxml index 36847ea03..2cc64724c 100644 --- a/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/Properties/PublishProfiles/FolderProfile1.pubxml +++ b/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/Properties/PublishProfiles/FolderProfile1.pubxml @@ -10,8 +10,12 @@ https://go.microsoft.com/fwlink/?LinkID=208121. Release Any CPU FileSystem - bin\Release\net6.0\publish\ + D:\发布\WMS\store FileSystem <_TargetId>Folder + + net6.0 + 488eeada-cfed-4016-9884-7a1dcbe5eb9c + false \ No newline at end of file diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDetailDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDetailDTO.cs index 92b149911..7b205cdaa 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDetailDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/DTOs/ThirdLocationRequestDetailDTO.cs @@ -43,12 +43,7 @@ public class ThirdLocationRequestDetailDTO : SfsStoreDetailWithQtyDTOBase /// [Display(Name = "已收数量")] public decimal ReceivedQty { get; set; } - - /// - /// 明细状态 - /// - [Display(Name = "明细状态")] - public EnumStatus Status { get; set; } + /// /// 请求未发 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/Inputs/ThirdLocationRequestDetailInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/Inputs/ThirdLocationRequestDetailInput.cs index b6294d8cd..aec149364 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/Inputs/ThirdLocationRequestDetailInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/ThirdLocationRequests/Inputs/ThirdLocationRequestDetailInput.cs @@ -71,12 +71,7 @@ public class ThirdLocationRequestDetailInput : SfsStoreDetailWithQtyInputBase /// [Display(Name = "已收数量")] public decimal ReceivedQty { get; set; } - - /// - /// 明细状态 - /// - [Display(Name = "明细状态")] - public EnumStatus Status { get; set; } + /// /// 位置码 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAutoMapperProfile.cs index 856be3ddf..e8965b174 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ThirdLocationRequests/ThirdLocationRequestAutoMapperProfile.cs @@ -42,8 +42,7 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.Remark); CreateMap() - .IgnoreAuditedObjectProperties() - .ForMember(x => x.Status, y => y.MapFrom(t => EnumStatus.Open)) + .IgnoreAuditedObjectProperties() .Ignore(x => x.ToLocationErpCode) .Ignore(x => x.ToWarehouseCode) .Ignore(x => x.ToLocationArea) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestDetail.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestDetail.cs index f3f221923..dbea45ed9 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestDetail.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestDetail.cs @@ -77,10 +77,7 @@ public class ThirdLocationRequestDetail : SfsStoreDetailWithQtyEntityBase, IHasT /// public decimal ReceivedQty { get; set; } - /// - /// 明细状态 - /// - public EnumStatus Status { get; set; } + /// /// 请求未发 还未发送的数量 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestManager.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestManager.cs index c9d45a6dc..1586bfcf3 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestManager.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/ThirdLocationRequests/ThirdLocationRequestManager.cs @@ -73,48 +73,49 @@ public class ThirdLocationRequestManager private void SetMaterialRequestDetailStatus(ThirdLocationRequestDetail detail) { - if (detail.ReceivedQty >= detail.Qty)//执行的时候 实际收料 多余 要料数 - { - detail.Status = EnumStatus.Close; - } - else - { - detail.Status = EnumStatus.Open; - } + //if (detail.ReceivedQty >= detail.Qty)//执行的时候 实际收料 多余 要料数 + //{ + // detail.Status = EnumStatus.Close; + //} + //else + //{ + // detail.Status = EnumStatus.Open; + //} } private async Task SetMaterialRequestStatusAsync(ThirdLocationRequest materialRequest) { - if (materialRequest.Details.All(p => p.Status == EnumStatus.Close)) - { - materialRequest.RequestStatus = EnumRequestStatus.Completed; - } - else - { - var issueJobs = await _issueJobRepository.GetListAsync(t => t.MaterialRequestNumber == materialRequest.Number).ConfigureAwait(false); - if (issueJobs.Count > 0) - { - if (issueJobs.All(t => t.JobStatus is EnumJobStatus.Done or EnumJobStatus.Closed or EnumJobStatus.Cancelled)) - { - if (materialRequest.Details.All(p => p.ReceivedQty >= p.Qty)) - { - materialRequest.RequestStatus = EnumRequestStatus.Completed; - } - else - { - materialRequest.RequestStatus = EnumRequestStatus.Partial; - } - } - else - { - materialRequest.RequestStatus = EnumRequestStatus.Partial; - } - } - else - { - materialRequest.RequestStatus = EnumRequestStatus.Partial; - } - } + //if (materialRequest.Details.All(p => p.Status == EnumStatus.Close)) + //{ + // materialRequest.RequestStatus = EnumRequestStatus.Completed; + //} + //else + //{ + // var issueJobs = await _issueJobRepository.GetListAsync(t => t.MaterialRequestNumber == materialRequest.Number).ConfigureAwait(false); + // if (issueJobs.Count > 0) + // { + // if (issueJobs.All(t => t.JobStatus is EnumJobStatus.Done or EnumJobStatus.Closed or EnumJobStatus.Cancelled)) + // { + // if (materialRequest.Details.All(p => p.ReceivedQty >= p.Qty)) + // { + // materialRequest.RequestStatus = EnumRequestStatus.Completed; + // } + // else + // { + // materialRequest.RequestStatus = EnumRequestStatus.Partial; + // } + // } + // else + // { + // materialRequest.RequestStatus = EnumRequestStatus.Partial; + // } + // } + // else + // { + // materialRequest.RequestStatus = EnumRequestStatus.Partial; + // } + //} + } public virtual async Task CompleteAsync(string number) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ThirdLocationRequests/ThirdLocationRequestDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ThirdLocationRequests/ThirdLocationRequestDbContextModelCreatingExtensions.cs index f6a4a922f..ea0364046 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ThirdLocationRequests/ThirdLocationRequestDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ThirdLocationRequests/ThirdLocationRequestDbContextModelCreatingExtensions.cs @@ -53,8 +53,7 @@ public static class ThirdLocationRequestDbContextModelCreatingExtensions b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.WorkStation).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.IssuedQty).HasPrecision(18, 6); - b.Property(q => q.ReceivedQty).HasPrecision(18, 6); - b.Property(q => q.Status).HasMaxLength(SfsPropertyConst.NameLength).HasConversion(); + b.Property(q => q.ReceivedQty).HasPrecision(18, 6); b.Property(q => q.PositionCode).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.RecommendType).HasMaxLength(SfsPropertyConst.NameLength).HasConversion(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ThirdLocationRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ThirdLocationRequestEventHandler.cs index ec4586e0c..d5d1702be 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ThirdLocationRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ThirdLocationRequestEventHandler.cs @@ -256,38 +256,12 @@ public class ThirdLocationRequestEventHandler jobs.Add(job); } job.Details.AddRange(jobDetails); - if (thirdLocationRequestDetail.ToBeIssuedQty < 0) - { - thirdLocationRequestDetail.Status = EnumStatus.Close; - } + } jobs = jobs.Where(p => p.Details.Any()).ToList(); - - var openRequestDetails = - thirdLocationRequest.Details.Where(p => p.Status != EnumStatus.Close).ToList(); - - if (!openRequestDetails.Any()) - { - return jobs; - } - - - var enableMultipleCreateThirdLocationJob = await SettingManager.IsTrueAsync(StoreSettings.MaterialRequest.EnableMultipleCreateIssueJob).ConfigureAwait(false); - if (enableMultipleCreateThirdLocationJob) - { - - //thirdLocationRequest.Partial(); - } - else - { - var sb = new StringBuilder(); - foreach (var openRequestDetail in openRequestDetails) - { - sb.AppendLine($"{openRequestDetail.ItemCode}请求数量 {openRequestDetail.Qty},可用库存数量 {openRequestDetail.IssuedQty}"); - } - throw new UserFriendlyException($"{sb} 可用库存数量不足, 无法生成发料任务"); - } + + return jobs; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ThirdLocationNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ThirdLocationNoteEventHandler.cs index 2199cfc75..c46ab6697 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ThirdLocationNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ThirdLocationNoteEventHandler.cs @@ -22,10 +22,13 @@ public class ThirdLocationNoteEventHandler private const EnumTransType TransType = EnumTransType.TransferLib; private readonly ILocationAppService _locationAppService; + private readonly IThirdLocationRequestManager _thirdLocationRequestManager; - public ThirdLocationNoteEventHandler(ILocationAppService locationAppService) + public ThirdLocationNoteEventHandler(ILocationAppService locationAppService + , IThirdLocationRequestManager thirdLocationRequestManager) { _locationAppService = locationAppService; + _thirdLocationRequestManager = thirdLocationRequestManager; } [UnitOfWork] @@ -39,6 +42,12 @@ public class ThirdLocationNoteEventHandler await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + + if (!string.IsNullOrEmpty(entity.RequestNumber)) + { + var thirdLocationRequest = await _thirdLocationRequestManager.GetByNumberAsync(entity.RequestNumber).ConfigureAwait(false); + await _thirdLocationRequestManager.CompleteAsync(thirdLocationRequest).ConfigureAwait(false); + } } [UnitOfWork]