From 062fab0067e34485a73aef53b833b832e15c2696 Mon Sep 17 00:00:00 2001 From: "mingliang.tang" Date: Fri, 14 Apr 2023 13:36:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?WMS-TYRP=E5=9B=9E=E6=94=B6=E6=96=99?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Outgoing/ItemTransformNoteConverter.cs | 139 ++++++++++++++++++ .../Outgoing/TyrpOutgoingBackgroundWorker.cs | 4 + ...s.Wms.DataExchange.Fawtyg.TyrpAgent.csproj | 1 + .../Enums/EnumOutgoingDataType.cs | 1 + .../ItemTransformNoteDetailExchangeDto.cs | 45 ++++++ .../ItemTransformNoteExchangeDto.cs | 30 ++++ .../DTOs/ItemTransformNoteDTO.cs | 5 +- .../DTOs/ItemTransformNoteDetailDTO.cs | 6 +- .../Transactions/ScrapNoteEventHandler.cs | 1 - 9 files changed, 229 insertions(+), 3 deletions(-) create mode 100644 be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/ItemTransformNoteConverter.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemTransformNote/ItemTransformNoteDetailExchangeDto.cs create mode 100644 be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemTransformNote/ItemTransformNoteExchangeDto.cs diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/ItemTransformNoteConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/ItemTransformNoteConverter.cs new file mode 100644 index 000000000..8e25bb6a7 --- /dev/null +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/ItemTransformNoteConverter.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using Volo.Abp.ObjectMapping; +using Win_in.Sfs.Auth.Application.Contracts; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.DataExchange.Domain; +using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; +using Win_in.Sfs.Wms.DataExchange.Domain.Shared; +using Win_in.Sfs.Wms.DataExchange.WMS.ItemTransformNote; +using Win_in.Sfs.Wms.Store.Application.Contracts; + +namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Outgoing; + + public class ItemTransformNoteConverter : IOutgoingConverter + { + private readonly IOutgoingFromWmsManager _outgoingFromWmsManager; + private readonly IOutgoingToExternalManager _outgoingToExternalManager; + private readonly ISupplierAsnAppService _supplierAsnAppService; + private readonly IDepartmentAppService _departmentAppService; + private readonly IObjectMapper _objectMapper; + + public ItemTransformNoteConverter( + IOutgoingFromWmsManager outgoingFromWmsManager + , IOutgoingToExternalManager outgoingToExternalManager + , ISupplierAsnAppService supplierAsnAppService + , IDepartmentAppService departmentAppService + , IObjectMapper objectMapper + ) + { + _outgoingFromWmsManager = outgoingFromWmsManager; + _outgoingToExternalManager = outgoingToExternalManager; + _supplierAsnAppService = supplierAsnAppService; + _departmentAppService = departmentAppService; + _objectMapper = objectMapper; + } + + public virtual async Task> ConvertAsync() + { + var outgoingToExternalList = new List(); + var outgoingFromWmsList = await _outgoingFromWmsManager.GetToBeProcessedListAsync(EnumOutgoingDataType.Item_Transform, EnumSystemType.ERP).ConfigureAwait(false); + foreach (var outgoingFromWms in outgoingFromWmsList) + { + var wmsCountAdjust = JsonSerializer.Deserialize(outgoingFromWms.DataContent); + if (Enum.Parse(wmsCountAdjust.Type) == EnumTransSubType.Item_Transform) + { + var department = await _departmentAppService.GetByUsernameAsync(wmsCountAdjust.Worker).ConfigureAwait(false); + var departmentCode = department == null ? "" : department.Code; + var details = wmsCountAdjust.Details.GroupBy(r => new { r.ItemCode, r.ToItemCode, r.LocationErpCode, r.ToLocationCode }).Select(p => new ItemTransformNoteDetailExchangeDto { ToQty = p.Sum(itm => itm.ToQty), FromQty = p.Sum(itm => itm.FromQty), ItemCode = p.Key.ItemCode, ToItemCode = p.Key.ToItemCode, LocationErpCode = p.Key.LocationErpCode, ReasonCode = String.Join("、", p.Select(x => x.ReasonCode).ToArray()) }); + foreach (var detail in details) + { + List ItemTransform = new List(); + ItemTransformNoteDetailExchangeDto ItemTrans = new ItemTransformNoteDetailExchangeDto(); + ItemTrans.ItemCode = detail.ItemCode; + ItemTrans.LocationErpCode = detail.LocationErpCode; + ItemTrans.FromQty = detail.FromQty - detail.FromQty - detail.FromQty; + ItemTrans.ReasonCode = detail.ReasonCode; + ItemTransform.Add(ItemTrans); + ItemTransformNoteDetailExchangeDto ItemTranss = new ItemTransformNoteDetailExchangeDto(); + ItemTranss.ItemCode = detail.ToItemCode; + ItemTranss.LocationErpCode = detail.LocationErpCode; + ItemTranss.FromQty = detail.ToQty; + ItemTranss.ReasonCode = detail.ReasonCode; + ItemTransform.Add(ItemTranss); + foreach (var Item in ItemTransform) + { + var outgoingToExternal = new OutgoingToExternal() + { + DataType = outgoingFromWms.DataType, + DataAction = outgoingFromWms.DataAction, + SourceSystem = EnumSystemType.WMS.ToString(), + SourceDataId = wmsCountAdjust.Number, + SourceDataGroupCode = wmsCountAdjust.Number, + SourceDataDetailCode = Item.ItemCode, + Writer = nameof(TyrpOutgoingBackgroundWorker), + DestinationSystem = EnumSystemType.ERP.ToString(), + DestinationDataId = "", + }; + outgoingToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate); + var exchangeIssue = await BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, Item).ConfigureAwait(false); + outgoingToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeIssue); + var arrive = BuildIssue(exchangeIssue, departmentCode); + outgoingToExternal.DestinationDataContent = JsonSerializer.Serialize(arrive); + + outgoingToExternalList.Add(outgoingToExternal); + } + + } + } + } + await _outgoingToExternalManager.CreateManyAsync(outgoingToExternalList).ConfigureAwait(false); ; + //将outgoingFromWms数据归档 + await _outgoingFromWmsManager.ArchiveManyAsync(outgoingFromWmsList).ConfigureAwait(false); ; + return outgoingToExternalList; + //插入到中间表OutgoingToExternal + } + + private CountAdjust BuildIssue(ItemTransformNoteExchangeDto exchangeCountAdjust, string departmentCode) + { + var detail = exchangeCountAdjust.Detail; + string asdtype = ""; + if (Enum.Parse(exchangeCountAdjust.Type) == EnumTransSubType.Item_Transform) + { + asdtype = "4003"; + } + var counta = new CountAdjust() + { + mesout_asd_refc = departmentCode, + mesout_asd_dt_w = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"), + mesout_asd_type = asdtype, + mesout_asd_part = detail.ItemCode, + mesout_asd_date = exchangeCountAdjust.ActiveDate.ToString("yyyyMMdd"), + mesout_asd_loc = detail.LocationErpCode, + mesout_asd_code = detail.ReasonCode, + mesout_asd_qty = detail.FromQty, + mesout_asd_user = exchangeCountAdjust.Worker, + mesout_asd_k = string.Empty, + mesout_asd_stat = "Y" + + }; + + + return counta; + + } + + private async Task BuildPurchaseReceiptExchangeDtoAsync( + ItemTransformNoteDTO wmsCountAdjust, ItemTransformNoteDetailExchangeDto wmsCountAdjustDetail) + { + + var exchangeCountAdjust = _objectMapper.Map(wmsCountAdjust); + + exchangeCountAdjust.Detail = wmsCountAdjustDetail; + return exchangeCountAdjust; + } + } + diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/TyrpOutgoingBackgroundWorker.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/TyrpOutgoingBackgroundWorker.cs index 0344a59ed..52ca1123a 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/TyrpOutgoingBackgroundWorker.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/TyrpOutgoingBackgroundWorker.cs @@ -120,6 +120,10 @@ public class TyrpOutgoingBackgroundWorker : AsyncPeriodicBackgroundWorkerBase var scrapNoteList = await scrapNoteConvert.ConvertAsync().ConfigureAwait(false); await countadjustWriter.WriteAsync(scrapNoteList).ConfigureAwait(false); + Logger.LogInformation($"Write ItemTransformNote");//回收料调整单 + var ItemTransformNoteConvert = workerContext.ServiceProvider.GetRequiredService(); + var ItemTransformNoteList = await ItemTransformNoteConvert.ConvertAsync().ConfigureAwait(false); + await countadjustWriter.WriteAsync(ItemTransformNoteList).ConfigureAwait(false); Logger.LogInformation($"Completed: Handling {Outgoing}"); } diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.csproj b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.csproj index bdec28966..f7135a83a 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.csproj +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.csproj @@ -31,6 +31,7 @@ + diff --git a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Domain.Shared/Enums/EnumOutgoingDataType.cs b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Domain.Shared/Enums/EnumOutgoingDataType.cs index 798adcc81..cc783226f 100644 --- a/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Domain.Shared/Enums/EnumOutgoingDataType.cs +++ b/be/DataExchange/src/Win_in.Sfs.Wms.DataExchange.Domain.Shared/Enums/EnumOutgoingDataType.cs @@ -30,6 +30,7 @@ public enum EnumOutgoingDataType RecycledMaterialReceipt = 22, ScrapNote = 23, ProductRecycle = 24, + Item_Transform = 25 } public enum EnumExchangeTableType { diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemTransformNote/ItemTransformNoteDetailExchangeDto.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemTransformNote/ItemTransformNoteDetailExchangeDto.cs new file mode 100644 index 000000000..211d70c8c --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemTransformNote/ItemTransformNoteDetailExchangeDto.cs @@ -0,0 +1,45 @@ + +using System.ComponentModel.DataAnnotations; + +namespace Win_in.Sfs.Wms.DataExchange.WMS.ItemTransformNote; + +public class ItemTransformNoteDetailExchangeDto +{ + /// + /// 物品代码 + /// + [Display(Name = "物品代码")] + public string ItemCode { get; set; } + /// + /// ERP库位 + /// + [Display(Name = "ERP库位")] + public string LocationErpCode { get; set; } + /// + /// 原因代码 + /// + [Display(Name = "原因代码")] + public string ReasonCode { get; set; } + /// + /// 调整数量 + /// + [Display(Name = "来源数量")] + public decimal FromQty { get; set; } + /// + /// 目标数量 + /// + [Display(Name = "目标数量")] + public decimal ToQty { get; set; } + /// + /// 目标库位 + /// + [Display(Name = "目标库位")] + [Required(ErrorMessage = "{0}是必填项")] + public string ToLocationCode { get; set; } + /// + /// 目标物品代码 + /// + [Display(Name = "目标物品代码")] + public string ToItemCode { get; set; } + +} diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemTransformNote/ItemTransformNoteExchangeDto.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemTransformNote/ItemTransformNoteExchangeDto.cs new file mode 100644 index 000000000..64c529b77 --- /dev/null +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ItemTransformNote/ItemTransformNoteExchangeDto.cs @@ -0,0 +1,30 @@ +using System; +using System.ComponentModel.DataAnnotations; +namespace Win_in.Sfs.Wms.DataExchange.WMS.ItemTransformNote; + +public class ItemTransformNoteExchangeDto +{ + /// + /// 单据号 + /// + public string Number { get; set; } + /// + /// 生效日期 + /// + public DateTime ActiveDate { get; set; } = DateTime.Now.Date; + /// + /// 操作员 + /// + public string Worker { get; set; } + + /// + /// 类型 + /// + public string Type { get; set; } + + /// + /// 明细 + /// + [Display(Name = "明细")] + public ItemTransformNoteDetailExchangeDto Detail { get; set; } = new(); +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/DTOs/ItemTransformNoteDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/DTOs/ItemTransformNoteDTO.cs index 10c1b8257..bf96e9680 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/DTOs/ItemTransformNoteDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/DTOs/ItemTransformNoteDTO.cs @@ -19,5 +19,8 @@ public class ItemTransformNoteDTO : SfsStoreDTOBase, [Display(Name = "任务单号")] [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] public string JobNumber { get; set; } - + /// + /// 调整类型 + /// + public string Type { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/DTOs/ItemTransformNoteDetailDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/DTOs/ItemTransformNoteDetailDTO.cs index 12cd97405..6357fe2fd 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/DTOs/ItemTransformNoteDetailDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/DTOs/ItemTransformNoteDetailDTO.cs @@ -214,7 +214,11 @@ public class ItemTransformNoteDetailDTO : SfsStoreDetailDTOBase /// [Display(Name = "目标ERP储位")] public string ToLocationErpCode { get; set; } - + /// + /// ERP库位 + /// + [Display(Name = "ERP库位")] + public string LocationErpCode { get; set; } /// /// 目标仓库 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ScrapNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ScrapNoteEventHandler.cs index 5501481a8..981f42265 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ScrapNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ScrapNoteEventHandler.cs @@ -7,7 +7,6 @@ using Volo.Abp.Uow; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Inventory.Application.Contracts; -using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; using Win_in.Sfs.Wms.Store.Event.Transaction; From 8a0c77959a3ce68dd0cc8a33704125a3a8132d8c Mon Sep 17 00:00:00 2001 From: "rongguo.jia" Date: Fri, 14 Apr 2023 14:44:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[fix]DeliverRequestFis=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bases/SfsStoreRequestAppServiceBase.cs | 3 ++- .../DeliverRequestFisAppService.cs | 24 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) 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 e82144b3a..7bed7b52d 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 @@ -157,7 +157,8 @@ public abstract class SfsStoreRequestAppServiceBase CompleteByNumberAsync(string number) { var entity = await _repository.FindAsync(p => p.Number == number).ConfigureAwait(false); - Check.NotNull(entity, typeof(TEntity).Name); + if (entity == null) return null; + // Check.NotNull(entity, typeof(TEntity).Name); var result = await _requestManager.CompleteAsync(entity).ConfigureAwait(false); var dto = ObjectMapper.Map(result); return dto; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs index 84975add6..5dd549d4c 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs @@ -35,14 +35,14 @@ public class DeliverRequestFisAppService : public DeliverRequestFisAppService( IDeliverRequestRepository repository, - IDeliverRequestManager DeliverRequestManager, + IDeliverRequestManager deliverRequestManager, IAreaAppService areaApp, ICustomerAppService customerApp, ICustomerAddressAppService customerAddressApp ) - : base(repository, DeliverRequestManager) + : base(repository, deliverRequestManager) { - _deliverRequestManager = DeliverRequestManager; + _deliverRequestManager = deliverRequestManager; _areaApp = areaApp; _customerApp = customerApp; _customerAddressApp = customerAddressApp; @@ -60,6 +60,24 @@ public class DeliverRequestFisAppService : return base.GetPagedListByFilterAsync(sfsRequestInput, includeDetails, cancellationToken); } + + /// + /// 【创建】发货申请 + /// + /// + /// + [HttpPost("")] + //[Authorize(DeliverRequestPermissions.Create)] + public override async Task CreateAsync(DeliverRequestEditInput input) + { + var entity = ObjectMapper.Map(input); + + await _deliverRequestManager.CreateAsync(entity).ConfigureAwait(false); + + var dto = ObjectMapper.Map(entity); + return dto; + } + #region import protected virtual async Task CheckImportInputBusinessAsync(