|
|
@ -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<List<OutgoingToExternal>> 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> { 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<CountAdjustNoteExchangeDto> BuildPurchaseReceiptExchangeDtoAsync( |
|
|
|
CountAdjustNoteDTO wmsCountAdjust, CountAdjustNoteDetailExchangeDto wmsCountAdjustDetail) |
|
|
|
{ |
|
|
|