From bec8253218bab296ac46ee9f6995ffc93f137a8c Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Tue, 4 Jul 2023 10:09:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=98=E7=82=B9=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E5=BA=93=E4=BD=8D=E7=B1=BB=E5=9E=8B=E6=98=AF?= =?UTF-8?q?=E7=BA=BF=E8=BE=B9=E4=BB=93=E7=9A=84=E4=BC=A0=E7=BA=BF=E8=BE=B9?= =?UTF-8?q?=E4=BB=93=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Outgoing/CountAdjustNoteConverter.cs | 62 +++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs index 197b5796d..a5990abd1 100644 --- a/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs +++ b/be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent/Outgoing/CountAdjustNoteConverter.cs @@ -5,6 +5,7 @@ using System.Text.Json; using System.Threading.Tasks; using Volo.Abp.ObjectMapping; using Win_in.Sfs.Auth.Application.Contracts; +using Win_in.Sfs.Basedata.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; @@ -21,6 +22,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter private readonly ISupplierAsnAppService _supplierAsnAppService; private readonly IDepartmentAppService _departmentAppService; private readonly IObjectMapper _objectMapper; + private readonly ILocationAppService _locationAppService; public CountAdjustNoteConverter( IOutgoingFromWmsManager outgoingFromWmsManager @@ -28,6 +30,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter , ISupplierAsnAppService supplierAsnAppService , IDepartmentAppService departmentAppService , IObjectMapper objectMapper + , ILocationAppService locationAppService ) { _outgoingFromWmsManager = outgoingFromWmsManager; @@ -35,6 +38,7 @@ public class CountAdjustNoteConverter : IOutgoingConverter _supplierAsnAppService = supplierAsnAppService; _departmentAppService = departmentAppService; _objectMapper = objectMapper; + _locationAppService= locationAppService; } public virtual async Task> ConvertAsync() @@ -47,9 +51,41 @@ public class CountAdjustNoteConverter : IOutgoingConverter 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.LocationErpCode }).Select(p => new CountAdjustNoteDetailExchangeDto { CountQty = p.Sum(itm => itm.CountQty), InventoryQty = p.Sum(itm => itm.InventoryQty), ItemCode = p.Key.ItemCode, LocationErpCode = p.Key.LocationErpCode }); - var detal = details.ToList(); - foreach (var detail in detal) + + var locs =await _locationAppService.GetListByTypesAsync(new List { EnumLocationType.WIP }).ConfigureAwait(false); + var locationCodes = locs.Select(p => p.Code); + var wipItems=wmsCountAdjust.Details.Where(p => locationCodes.Contains(p.LocationCode));//库位类型是线边,传线边仓调整 + var Items = wmsCountAdjust.Details.Where(p => !locationCodes.Contains(p.LocationCode));//盘点 + var WipDetails = wipItems.GroupBy(r => new { r.ItemCode, r.LocationErpCode }).Select(p => new CountAdjustNoteDetailExchangeDto { CountQty = p.Sum(itm => itm.CountQty), InventoryQty = p.Sum(itm => itm.InventoryQty), ItemCode = p.Key.ItemCode, LocationErpCode = p.Key.LocationErpCode }); + foreach (var detail in WipDetails) + { + //判断盘点数与库存数是否相等 + if (detail.CountQty != detail.InventoryQty) + { + var outgoingToExternal = new OutgoingToExternal() + { + DataType = outgoingFromWms.DataType, + DataAction = outgoingFromWms.DataAction, + SourceSystem = EnumSystemType.WMS.ToString(), + SourceDataId = wmsCountAdjust.Number, + SourceDataGroupCode = wmsCountAdjust.Number, + SourceDataDetailCode = WipDetails.FirstOrDefault().ItemCode, + Writer = nameof(TyrpOutgoingBackgroundWorker), + DestinationSystem = EnumSystemType.ERP.ToString(), + DestinationDataId = "", + }; + outgoingToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate); + var exchangeIssue = await BuildPurchaseReceiptExchangeDtoAsync(wmsCountAdjust, detail).ConfigureAwait(false); + outgoingToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeIssue); + var arrive = BuildWip(exchangeIssue, departmentCode); + outgoingToExternal.DestinationDataContent = JsonSerializer.Serialize(arrive); + + outgoingToExternalList.Add(outgoingToExternal); + } + } + + var details = Items.GroupBy(r => new { r.ItemCode, r.LocationErpCode }).Select(p => new CountAdjustNoteDetailExchangeDto { CountQty = p.Sum(itm => itm.CountQty), InventoryQty = p.Sum(itm => itm.InventoryQty), ItemCode = p.Key.ItemCode, LocationErpCode = p.Key.LocationErpCode }); + foreach (var detail in details) { //判断盘点数与库存数是否相等 if (detail.CountQty != detail.InventoryQty) @@ -104,7 +140,25 @@ public class CountAdjustNoteConverter : IOutgoingConverter return counta; } - + private CountAdjust BuildWip(CountAdjustNoteExchangeDto exchangeCountAdjust, string departmentCode) + { + var detail = exchangeCountAdjust.Detail; + var counta = new CountAdjust() + { + mesout_asd_refc = departmentCode, + mesout_asd_dt_w = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"), + mesout_asd_type = "4041", + mesout_asd_part = detail.ItemCode, + mesout_asd_date = exchangeCountAdjust.ActiveDate.ToString("yyyyMMdd"), + mesout_asd_loc = string.Empty, + mesout_asd_code = detail.ReasonCode, + mesout_asd_qty = detail.CountQty + detail.InventoryQty, + mesout_asd_user = "WMS", + mesout_asd_k = string.Empty, + mesout_asd_stat = "Y" + }; + return counta; + } private async Task BuildPurchaseReceiptExchangeDtoAsync( CountAdjustNoteDTO wmsCountAdjust, CountAdjustNoteDetailExchangeDto wmsCountAdjustDetail) {