40 changed files with 519 additions and 353 deletions
@ -1,142 +0,0 @@ |
|||
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.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.PCK; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Outgoing; |
|||
|
|||
public class AssembleIssueNoteConverter : IOutgoingConverter |
|||
{ |
|||
private readonly string billtype = "4026"; |
|||
private readonly IOutgoingFromWmsManager _outgoingFromWmsManager; |
|||
private readonly IOutgoingToExternalManager _outgoingToExternalManager; |
|||
private readonly IObjectMapper _objectMapper; |
|||
|
|||
public AssembleIssueNoteConverter( |
|||
IOutgoingFromWmsManager outgoingFromWmsManager |
|||
, IOutgoingToExternalManager outgoingToExternalManager |
|||
, IObjectMapper objectMapper |
|||
) |
|||
{ |
|||
_outgoingFromWmsManager = outgoingFromWmsManager; |
|||
_outgoingToExternalManager = outgoingToExternalManager; |
|||
_objectMapper = objectMapper; |
|||
} |
|||
|
|||
public virtual async Task<List<OutgoingToExternal>> ConvertAsync() |
|||
{ |
|||
var outgoingToExternalList = new List<OutgoingToExternal>(); |
|||
//获取要同步得数据
|
|||
var outgoingFromWmsList = await _outgoingFromWmsManager.GetToBeProcessedListAsync(EnumOutgoingDataType.AssembleIssue, EnumSystemType.ERP).ConfigureAwait(false); |
|||
foreach (var outgoingFromWms in outgoingFromWmsList) |
|||
{ |
|||
string tyrpNumber = outgoingFromWms.TyrpNumber; |
|||
#region 主表
|
|||
var wmsReceipt = JsonSerializer.Deserialize<AssembleIssueNoteDTO>(outgoingFromWms.DataContent); |
|||
var exchangeReceipt = _objectMapper.Map<AssembleIssueNoteDTO, AssembleIssueNoteExchangeDto>(wmsReceipt); |
|||
var putawayNote = BuildDataInterface(exchangeReceipt); |
|||
var outgoingToExternal = new OutgoingToExternal() |
|||
{ |
|||
DataType = EnumOutgoingDataType.Issue.ToString(), |
|||
TableType = EnumExchangeTableType.MainTable, |
|||
DataAction = outgoingFromWms.DataAction, |
|||
SerialNumber = tyrpNumber, |
|||
SourceSystem = EnumSystemType.WMS.ToString(), |
|||
SourceDataId = wmsReceipt.Id.ToString(), |
|||
SourceDataGroupCode = wmsReceipt.Number, |
|||
SourceDataDetailCode = wmsReceipt.Number, |
|||
Writer = nameof(TyrpOutgoingBackgroundWorker), |
|||
DestinationSystem = EnumSystemType.ERP.ToString(), |
|||
DestinationDataId = "", |
|||
}; |
|||
outgoingToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate); |
|||
outgoingToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeReceipt); |
|||
outgoingToExternal.DestinationDataContent = JsonSerializer.Serialize(putawayNote); |
|||
outgoingToExternalList.Add(outgoingToExternal); |
|||
#endregion
|
|||
var sumDetails = wmsReceipt.Details.GroupBy(r => new { r.ItemCode, r.HandledFromLocationErpCode, r.HandledToLocationErpCode }).Select(p => new AssembleIssueNoteDetailDTO { ItemCode = p.Key.ItemCode, HandledFromLocationErpCode = p.Key.HandledFromLocationErpCode, HandledToLocationErpCode = p.Key.HandledToLocationErpCode, HandledToQty = p.Sum(x => x.HandledToQty) }).ToList(); |
|||
#region 明细
|
|||
foreach (var detail in sumDetails) |
|||
{ |
|||
var outgoingDetailToExternal = new OutgoingToExternal() |
|||
{ |
|||
DataType = EnumOutgoingDataType.Issue.ToString(), |
|||
TableType = EnumExchangeTableType.DetailTable, |
|||
DataAction = outgoingFromWms.DataAction, |
|||
SerialNumber = tyrpNumber, |
|||
SourceSystem = EnumSystemType.WMS.ToString(), |
|||
SourceDataId = detail.Id.ToString(), |
|||
SourceDataGroupCode = wmsReceipt.Number, |
|||
SourceDataDetailCode = detail.ItemCode, |
|||
Writer = nameof(TyrpOutgoingBackgroundWorker), |
|||
DestinationSystem = EnumSystemType.ERP.ToString(), |
|||
DestinationDataId = "", |
|||
}; |
|||
outgoingDetailToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate); |
|||
var exchangeReceiptDetail = _objectMapper.Map<AssembleIssueNoteDetailDTO, AssembleIssueNoteDetailExchangeDto>(detail); |
|||
outgoingDetailToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeReceiptDetail); |
|||
var putawayNoteDetail = BuildDataInterfaceDetail(exchangeReceipt, exchangeReceiptDetail, putawayNote.scontrol_dt_w); |
|||
outgoingDetailToExternal.DestinationDataContent = JsonSerializer.Serialize(putawayNoteDetail); |
|||
outgoingToExternalList.Add(outgoingDetailToExternal); |
|||
} |
|||
#endregion
|
|||
} |
|||
//插入到中间表OutgoingToExternal
|
|||
await _outgoingToExternalManager.CreateManyAsync(outgoingToExternalList).ConfigureAwait(false); |
|||
//将outgoingFromWms数据归档
|
|||
await _outgoingFromWmsManager.ArchiveManyAsync(outgoingFromWmsList).ConfigureAwait(false); |
|||
|
|||
return outgoingToExternalList; |
|||
} |
|||
/// <summary>
|
|||
/// 构建主表
|
|||
/// </summary>
|
|||
/// <param name="exchangeOrder"></param>
|
|||
/// <returns></returns>
|
|||
private Scontrol BuildDataInterface(AssembleIssueNoteExchangeDto exchangeOrder) |
|||
{ |
|||
var ret = new Scontrol() |
|||
{ |
|||
scontrol_nbr = exchangeOrder.Number, |
|||
scontrol_dt_w = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"), |
|||
scontrol_stat = "Y", |
|||
scontrol_dt_k = "", |
|||
scontrol_type = billtype, |
|||
scontrol_id = 0,//明细中最大scmsend_id
|
|||
}; |
|||
return ret; |
|||
} |
|||
/// <summary>
|
|||
/// 构建明细
|
|||
/// </summary>
|
|||
/// <param name="exchangeOrder"></param>
|
|||
/// <param name="exchangeDetailOrder"></param>
|
|||
/// <returns></returns>
|
|||
private Scmsend BuildDataInterfaceDetail(AssembleIssueNoteExchangeDto exchangeOrder, AssembleIssueNoteDetailExchangeDto exchangeDetailOrder, string dt_w) |
|||
{ |
|||
var ret = new Scmsend() |
|||
{ |
|||
scmsend_type = billtype, |
|||
scmsend_dt_w = dt_w, |
|||
scmsend_nbr = exchangeOrder.Number, |
|||
scmsend_stat1 = "1", |
|||
scmsend_part = exchangeDetailOrder.ItemCode, |
|||
scmsend_delv_date = "", |
|||
scmsend_orderno = "", |
|||
scmsend_loc = exchangeDetailOrder.FromLocationErpCode, |
|||
//scmsend_date = exchangeOrder.ActiveDate.ToString("yyyyMMdd"),
|
|||
scmsend_date = DateTime.Now.ToString("yyyyMMdd"), |
|||
scmsend_qty = exchangeDetailOrder.Qty, |
|||
scmsend_wipd_loc = exchangeDetailOrder.ToLocationErpCode, |
|||
scmsend_userid = "WMS" |
|||
}; |
|||
return ret; |
|||
} |
|||
} |
@ -1,36 +0,0 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Win_in.Sfs.Shared.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.WMS.PCK; |
|||
|
|||
public class AssembleIssueNoteDetailExchangeDto |
|||
|
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 目标ERP库位
|
|||
/// </summary>
|
|||
[Display(Name = "目标ERP库位")] |
|||
public string ToLocationErpCode { get; set; } |
|||
|
|||
public string FromPackingCode { get; set; } |
|||
/// <summary>
|
|||
/// 来源ERP库位
|
|||
/// </summary>
|
|||
public string FromLocationErpCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 数量
|
|||
/// </summary>
|
|||
[Display(Name = "数量")] |
|||
public decimal Qty { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物品代码
|
|||
/// </summary>
|
|||
[Display(Name = "物品代码")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
[Required(ErrorMessage = "{0}是必填项")] |
|||
public string ItemCode { get; set; } |
|||
|
|||
} |
@ -1,29 +0,0 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.WMS.PCK; |
|||
|
|||
public class AssembleIssueNoteExchangeDto |
|||
{ |
|||
/// <summary>
|
|||
/// 发料记录号
|
|||
/// </summary>
|
|||
[Display(Name = "发料记录号")] |
|||
public string Number { get; set; } |
|||
/// <summary>
|
|||
/// 生效日期
|
|||
/// </summary>
|
|||
[Display(Name = "生效日期")] |
|||
public DateTime ActiveDate { get; set; } = DateTime.Now.Date; |
|||
|
|||
/// <summary>
|
|||
/// 操作员
|
|||
/// </summary>
|
|||
[Display(Name = "操作员")] |
|||
public string Worker { get; set; } |
|||
/// <summary>
|
|||
/// 明细
|
|||
/// </summary>
|
|||
[Display(Name = "明细")] |
|||
public AssembleIssueNoteDetailExchangeDto Detail { get; set; } = new(); |
|||
} |
@ -1,28 +1,23 @@ |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
using Win_in.Sfs.Wms.Store.Jobs.IssueJobs; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
public static class CoatingIssueJobPermissions |
|||
{ |
|||
|
|||
public const string Default = StorePermissions.GroupName + "." + nameof(IssueJob); |
|||
public const string Default = StorePermissions.GroupName + "." + nameof(CoatingIssueJob); |
|||
public const string Create = Default + "." + StorePermissions.CreateStr; |
|||
public const string Update = Default + "." + StorePermissions.UpdateStr; |
|||
public const string Delete = Default + "." + StorePermissions.DeleteStr; |
|||
|
|||
//自动发料任务
|
|||
public const string AutoIssueJob = StorePermissions.GroupName + "." + nameof(AutoIssueJob); |
|||
|
|||
public static void AddCoatingIssueJobPermission(this PermissionGroupDefinition permissionGroup) |
|||
{ |
|||
var IssueJobPermission = permissionGroup.AddPermission(Default, StorePermissionDefinitionProvider.L(nameof(IssueJob))); |
|||
IssueJobPermission.AddChild(Create, StorePermissionDefinitionProvider.L(StorePermissions.CreateStr)); |
|||
IssueJobPermission.AddChild(Update, StorePermissionDefinitionProvider.L(StorePermissions.UpdateStr)); |
|||
IssueJobPermission.AddChild(Delete, StorePermissionDefinitionProvider.L(StorePermissions.DeleteStr)); |
|||
|
|||
permissionGroup.AddPermission(AutoIssueJob, StorePermissionDefinitionProvider.L(nameof(AutoIssueJob))); |
|||
|
|||
} |
|||
} |
|||
|
@ -0,0 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
public interface IProductReceiptNoteDetailAppService : ISfsStoreAppServiceBase<ProductReceiptNoteDetailDTO, SfsStoreRequestInputBase, ProductReceiptNoteDetailInput> |
|||
{ |
|||
Task<ProductReceiptNoteDetailDTO> GetItemCodeByMesBarCode(string mesBarCode); |
|||
} |
@ -0,0 +1,25 @@ |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
public static class ProductReceiptNoteDetailPermissions |
|||
{ |
|||
public const string Default = StorePermissions.GroupName + "." + nameof(ProductReceiptNoteDetail); |
|||
public const string Create = Default + "." + StorePermissions.CreateStr; |
|||
public const string Update = Default + "." + StorePermissions.UpdateStr; |
|||
public const string Delete = Default + "." + StorePermissions.DeleteStr; |
|||
|
|||
//线边完工收货记录
|
|||
public const string WipProductReceiptNoteDetail = StorePermissions.GroupName + "." + nameof(WipProductReceiptNoteDetail); |
|||
|
|||
public static void AddProductReceiptNoteDetailPermission(this PermissionGroupDefinition permissionGroup) |
|||
{ |
|||
var productReceiptNotePermission = permissionGroup.AddPermission(Default, StorePermissionDefinitionProvider.L(nameof(ProductReceiptNoteDetail))); |
|||
productReceiptNotePermission.AddChild(Create, StorePermissionDefinitionProvider.L(StorePermissions.CreateStr)); |
|||
productReceiptNotePermission.AddChild(Update, StorePermissionDefinitionProvider.L(StorePermissions.UpdateStr)); |
|||
productReceiptNotePermission.AddChild(Delete, StorePermissionDefinitionProvider.L(StorePermissions.DeleteStr)); |
|||
|
|||
permissionGroup.AddPermission(WipProductReceiptNoteDetail, StorePermissionDefinitionProvider.L(nameof(WipProductReceiptNoteDetail))); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
using Volo.Abp.Application.Services; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|||
using Win_in.Sfs.Wms.Store.Application; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Notes.ProductReceiptNotes; |
|||
[Authorize] |
|||
[Route($"{StoreConsts.RootPath}product-receipt-note-detail")] |
|||
|
|||
public class ProductReceiptNoteDetailAppService : SfsStoreAppServiceBase<ProductReceiptNoteDetail, ProductReceiptNoteDetailDTO, SfsStoreRequestInputBase, ProductReceiptNoteDetailInput, ProductReceiptNoteImportInput>, IProductReceiptNoteDetailAppService |
|||
{ |
|||
private readonly IProductReceiptNoteDetailRepository _productReceiptNoteDetailRepository; |
|||
public ProductReceiptNoteDetailAppService( |
|||
IProductReceiptNoteDetailRepository repository |
|||
) : base(repository) |
|||
{ |
|||
_productReceiptNoteDetailRepository = repository; |
|||
} |
|||
|
|||
|
|||
[HttpGet("get-itemcode-by-mesbarcode")] |
|||
public virtual async Task<ProductReceiptNoteDetailDTO> GetItemCodeByMesBarCode(string mesBarCode) |
|||
{ |
|||
var entity = await _productReceiptNoteDetailRepository.FirstOrDefaultAsync(r => r.MesBarCode == mesBarCode).ConfigureAwait(false); |
|||
var dto = ObjectMapper.Map<ProductReceiptNoteDetail, ProductReceiptNoteDetailDTO>(entity); |
|||
return dto; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,4 @@ |
|||
namespace Win_in.Sfs.Wms.Store.Domain; |
|||
public interface IProductReceiptNoteDetailRepository : ISfsStoreRepositoryBase<ProductReceiptNoteDetail> |
|||
{ |
|||
} |
@ -0,0 +1,10 @@ |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.EntityFrameworkCore; |
|||
public class ProductReceiptNoteDetailEfCoreRepository : SfsStoreEfCoreRepositoryBase<StoreDbContext, ProductReceiptNoteDetail>, IProductReceiptNoteDetailRepository |
|||
{ |
|||
public ProductReceiptNoteDetailEfCoreRepository(IDbContextProvider<StoreDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,107 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.EventBus; |
|||
using Volo.Abp.Uow; |
|||
using Win_in.Sfs.Shared.Domain; |
|||
using Win_in.Sfs.Shared.Event; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
using Win_in.Sfs.Wms.Store.Notes.IssueNotes; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Event.DataExchanges; |
|||
|
|||
/// <summary>
|
|||
/// Kitting区=>装配线边库移记录传给TYRP(线边仓领料单)
|
|||
/// </summary>
|
|||
public class KittingIssueNoteEventHandler |
|||
: StoreDataExchangeEventHandlerBase<KittingIssueNote> |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<KittingIssueNote>> |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<List<KittingIssueNote>>> |
|||
{ |
|||
//Kitting区 线边仓领料单
|
|||
private const EnumExchangeDataType ExchangeDataType = EnumExchangeDataType.Issue; |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<KittingIssueNote> eventData) |
|||
{ |
|||
var entity = eventData.Entity; |
|||
await AddExchangeDataAsync(entity).ConfigureAwait(false); |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<KittingIssueNote>> eventData) |
|||
{ |
|||
var entities = eventData.Entity; |
|||
await AddExchangeDataAsync(entities).ConfigureAwait(false); |
|||
} |
|||
|
|||
protected override async Task AddExchangeDataAsync(List<KittingIssueNote> entities) |
|||
{ |
|||
var dtos = ObjectMapper.Map<List<KittingIssueNote>, List<KittingIssueNoteDTO>>(entities); |
|||
foreach (var detail in dtos.SelectMany(dto => dto.Details)) |
|||
{ |
|||
if (string.IsNullOrEmpty(detail.HandledFromLocationErpCode)) |
|||
{ |
|||
var location = await LocationAclService.GetByCodeAsync(detail.HandledFromLocationCode).ConfigureAwait(false); |
|||
if (location != null) |
|||
{ |
|||
detail.HandledFromLocationErpCode = location.ErpLocationCode; |
|||
detail.HandledFromLocationGroup = location.LocationGroupCode; |
|||
detail.HandledFromLocationArea = location.AreaCode; |
|||
|
|||
if (string.IsNullOrEmpty(detail.HandledFromWarehouseCode)) |
|||
{ |
|||
detail.HandledFromWarehouseCode = location.WarehouseCode; |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (string.IsNullOrEmpty(detail.HandledToLocationErpCode)) |
|||
{ |
|||
var location = await LocationAclService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); |
|||
if (location != null) |
|||
{ |
|||
detail.HandledToLocationErpCode = location.ErpLocationCode; |
|||
detail.HandledToLocationGroup = location.LocationGroupCode; |
|||
detail.HandledToLocationArea = location.AreaCode; |
|||
|
|||
if (string.IsNullOrEmpty(detail.HandledToWarehouseCode)) |
|||
{ |
|||
detail.HandledToWarehouseCode = location.WarehouseCode; |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
var toErpDto = new List<KittingIssueNoteDTO>(); |
|||
foreach (var item in dtos) |
|||
{ |
|||
if (item.Details != null && item.Details.Count != 0) |
|||
{ |
|||
toErpDto.Add(item); |
|||
} |
|||
} |
|||
|
|||
//2023-12-6要求同储位不传入接口 按历史规则
|
|||
var result = new List<KittingIssueNoteDTO>(); |
|||
foreach (var kittingIssueNoteDto in toErpDto) |
|||
{ |
|||
kittingIssueNoteDto.Details.RemoveAll(p => p.HandledFromLocationErpCode == p.HandledToLocationErpCode); |
|||
if (kittingIssueNoteDto.Details.Count > 0) |
|||
{ |
|||
result.Add(kittingIssueNoteDto); |
|||
} |
|||
} |
|||
|
|||
if (result.Count > 0) |
|||
{ |
|||
var exchangeDataerp = |
|||
await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, ExchangeDataType, result) |
|||
.ConfigureAwait(false); |
|||
await AddManyAsync(exchangeDataerp).ConfigureAwait(false); |
|||
} |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue