|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text.Json;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Volo.Abp.BackgroundWorkers;
|
|
|
|
using Win_in.Sfs.Auth.Application.Contracts;
|
|
|
|
using Win_in.Sfs.Auth.Users;
|
|
|
|
using Win_in.Sfs.Auth.Users.Inputs;
|
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts;
|
|
|
|
using Win_in.Sfs.Label.Application.Contracts;
|
|
|
|
using Win_in.Sfs.Wms.DataExchange.Domain;
|
|
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
|
|
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts;
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Agent;
|
|
|
|
public static class IncomingToWmsExtensions
|
|
|
|
{
|
|
|
|
public static async Task HandlePurchaseOrdersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var purchaseOrder = JsonSerializer.Deserialize<PurchaseOrderEditInput>(incomingConverted.DataContent);
|
|
|
|
var purchaseOrderAppService = workerContext.ServiceProvider.GetRequiredService<IPurchaseOrderAppService>();
|
|
|
|
await purchaseOrderAppService.CreateAsync(purchaseOrder).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleAsnsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var supplierAsn = JsonSerializer.Deserialize<SupplierAsnEditInput>(incomingConverted.DataContent);
|
|
|
|
var supplierAsnAppService = workerContext.ServiceProvider.GetRequiredService<ISupplierAsnAppService>();
|
|
|
|
await supplierAsnAppService.CreateAsync(supplierAsn).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
public static async Task HandleDictsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var Dict = JsonSerializer.Deserialize<DictEditInput>(incomingConverted.DataContent);
|
|
|
|
var DictBasicAppService = workerContext.ServiceProvider.GetRequiredService<IDictAppService>();
|
|
|
|
await DictBasicAppService.UpdateAsync(Dict).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
public static async Task HandleUsersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var user = JsonSerializer.Deserialize<IdentityUserInputDto>(incomingConverted.DataContent);
|
|
|
|
var userBasicAppService = workerContext.ServiceProvider.GetRequiredService<ISfsUserAppService>();
|
|
|
|
await userBasicAppService.UpdateByNmaeAsync(user).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
public static async Task HandleDepartmentsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var Department = JsonSerializer.Deserialize<DepartmentCreateInput>(incomingConverted.DataContent);
|
|
|
|
var DepartmentBasicAppService = workerContext.ServiceProvider.GetRequiredService<IDepartmentAppService>();
|
|
|
|
await DepartmentBasicAppService.UpdateAsync(Department).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static async Task HandleItemsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var item = JsonSerializer.Deserialize<ItemBasicEditInput>(incomingConverted.DataContent);
|
|
|
|
var itemBasicAppService = workerContext.ServiceProvider.GetRequiredService<IItemBasicAppService>();
|
|
|
|
await itemBasicAppService.UpsertAsyncByInterface(item).ConfigureAwait(false);
|
|
|
|
|
|
|
|
//try
|
|
|
|
//{
|
|
|
|
// Thread thread = new Thread(thead);
|
|
|
|
|
|
|
|
// thread.Start();
|
|
|
|
// var BalanceAppService = workerContext.ServiceProvider.GetRequiredService<IBalanceAppService>();
|
|
|
|
// BalanceUpdateItemBasicInfoDto balan = new BalanceUpdateItemBasicInfoDto();
|
|
|
|
// List<BalanceUpdateItemBasicInfo> bala = new List<BalanceUpdateItemBasicInfo>();
|
|
|
|
// BalanceUpdateItemBasicInfo ba = new BalanceUpdateItemBasicInfo();
|
|
|
|
// ba.ItemCode = item.Code;
|
|
|
|
// ba.ItemDesc1 = item.Desc1;
|
|
|
|
// ba.ItemDesc2 = item.Desc2;
|
|
|
|
// ba.ItemName = item.Name;
|
|
|
|
// bala.Add(ba);
|
|
|
|
// balan.BalanceUpdateItemBasicInfos = bala;
|
|
|
|
// await BalanceAppService.UpdateItemBasicInfoAsync(balan).ConfigureAwait(false);
|
|
|
|
//}
|
|
|
|
//catch (Exception ex)
|
|
|
|
//{
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
}
|
|
|
|
public static void thead()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
public static async Task HandleErpLocationsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var erpLocation = JsonSerializer.Deserialize<ErpLocationEditInput>(incomingConverted.DataContent);
|
|
|
|
var erpLocationAppService = workerContext.ServiceProvider.GetRequiredService<IErpLocationAppService>();
|
|
|
|
await erpLocationAppService.UpsertAsync(erpLocation).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleBomsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var bom = JsonSerializer.Deserialize<BomEditInput>(incomingConverted.DataContent);
|
|
|
|
var bomAppService = workerContext.ServiceProvider.GetRequiredService<IBomAppService>();
|
|
|
|
await bomAppService.UpsertAsyncByInterface(bom).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleSuppliersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var supplier = JsonSerializer.Deserialize<SupplierEditInput>(incomingConverted.DataContent);
|
|
|
|
var supplierAppService = workerContext.ServiceProvider.GetRequiredService<ISupplierAppService>();
|
|
|
|
await supplierAppService.UpsertAsyncByInterface(supplier).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleSupplierItemsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var supplierItem = JsonSerializer.Deserialize<SupplierItemEditInput>(incomingConverted.DataContent);
|
|
|
|
var supplierItemAppService = workerContext.ServiceProvider.GetRequiredService<ISupplierItemAppService>();
|
|
|
|
await supplierItemAppService.UpsertAsync(supplierItem).ConfigureAwait(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
public static async Task HandleItemPacksAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var itemPack = JsonSerializer.Deserialize<ItemPackEditInput>(incomingConverted.DataContent);
|
|
|
|
var itemPackAppService = workerContext.ServiceProvider.GetRequiredService<IItemPackAppService>();
|
|
|
|
var itemBasicAppService = workerContext.ServiceProvider.GetRequiredService<IItemBasicAppService>();
|
|
|
|
await itemPackAppService.UpsertAsync(itemPack).ConfigureAwait(false);
|
|
|
|
await itemBasicAppService.UpsertStdPackQtyAsync(itemPack.ItemCode, itemPack.Qty).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleCustomersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var customer = JsonSerializer.Deserialize<CustomerEditInput>(incomingConverted.DataContent);
|
|
|
|
var customerAppService = workerContext.ServiceProvider.GetRequiredService<ICustomerAppService>();
|
|
|
|
await customerAppService.UpsertAsyncByInterface(customer).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleCustomerItemsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var customerItem = JsonSerializer.Deserialize<CustomerItemEditInput>(incomingConverted.DataContent);
|
|
|
|
var customerItemAppService = workerContext.ServiceProvider.GetRequiredService<ICustomerItemAppService>();
|
|
|
|
await customerItemAppService.UpsertAsync(customerItem).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
public static async Task HandleInterfaceCalendarsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var interfaceCalendar = JsonSerializer.Deserialize<InterfaceCalendarEditInput>(incomingConverted.DataContent);
|
|
|
|
var interfaceCalendarAppService = workerContext.ServiceProvider.GetRequiredService<IInterfaceCalendarAppService>();
|
|
|
|
await interfaceCalendarAppService.UpsertAsync(interfaceCalendar).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
public static async Task HandleSaleOrdersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var saleOrder = JsonSerializer.Deserialize<SaleOrderEditInput>(incomingConverted.DataContent);
|
|
|
|
var saleOrderAppService = workerContext.ServiceProvider.GetRequiredService<ISaleOrderAppService>();
|
|
|
|
await saleOrderAppService.UpsertAsync(saleOrder).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleProductReceiptsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var productReceipt = JsonSerializer.Deserialize<ProductReceiptNoteEditInput>(incomingConverted.DataContent);
|
|
|
|
var productReceiptAppService = workerContext.ServiceProvider.GetRequiredService<IProductReceiptNoteAppService>();
|
|
|
|
await productReceiptAppService.CreateAsync(productReceipt).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleMaterialRequestsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var materialRequest = JsonSerializer.Deserialize<MaterialRequestEditInput>(incomingConverted.DataContent);
|
|
|
|
var materialRequestAppService = workerContext.ServiceProvider.GetRequiredService<IMaterialRequestAppService>();
|
|
|
|
await materialRequestAppService.CreateAndHandleByAPIAsync(materialRequest).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleScrapsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var scrap = JsonSerializer.Deserialize<ScrapNoteEditInput>(incomingConverted.DataContent);
|
|
|
|
var scrapAppService = workerContext.ServiceProvider.GetRequiredService<IScrapNoteAppService>();
|
|
|
|
await scrapAppService.CreateAsync(scrap).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async Task HandleIssueNoteConfirmAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var number = incomingConverted.DataIdentityCode;
|
|
|
|
var issueNoteAppService = workerContext.ServiceProvider.GetRequiredService<IIssueNoteAppService>();
|
|
|
|
await issueNoteAppService.ConfirmAsync(number).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static async Task HandleInventoryLabelsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var inventoryLabel = JsonSerializer.Deserialize<InventoryLabelEditInput>(incomingConverted.DataContent);
|
|
|
|
var inventoryLabelAppService = workerContext.ServiceProvider.GetRequiredService<IInventoryLabelAppService>();
|
|
|
|
await inventoryLabelAppService.CreateManyByNoCodeAsync(new List<InventoryLabelEditInput> { inventoryLabel }).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
public static async Task HandleBackFlushsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
var backFlush = JsonSerializer.Deserialize<BackFlushNoteEditInput>(incomingConverted.DataContent);
|
|
|
|
var backFlushAppService = workerContext.ServiceProvider.GetRequiredService<IBackFlushNoteAppService>();
|
|
|
|
List<BackFlushNoteEditInput> back = new List<BackFlushNoteEditInput>();
|
|
|
|
back.Add(backFlush);
|
|
|
|
await backFlushAppService.CreateManyAsync(back).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|