Warehouses #1

Merged
trent merged 159 commits from Warehouses into master 2026-01-10 20:24:17 +00:00
8 changed files with 125 additions and 59 deletions
Showing only changes of commit da1eae8ca9 - Show all commits

View File

@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Services;
namespace FaKrosnoApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class WzClientController(IWzClientService service) : Controller
{
[HttpGet]
public async Task<ActionResult<IEnumerable<WzClientDto>>> GetAll()
{
IEnumerable<WzClientDto> wzClients = await service.GetAll();
return Ok(wzClients);
}
}

View File

@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Services;
namespace FaKrosnoApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class WzHeaderController(IWzHeaderService service, IMaterialTransactionService materialTransactionService) : Controller
{
[HttpGet]
public async Task<ActionResult<IEnumerable<WzHeaderDto>>> GetAll()
{
IEnumerable<WzHeaderDto> wzHeaders = await service.GetAll();
return Ok(wzHeaders);
}
[HttpGet("by-customer-number")]
public async Task<ActionResult<IEnumerable<MaterialTransactionDto>>> GetByCustomerNumber(
[FromQuery] string customerNumber, [FromQuery] int customerSequence)
{
IEnumerable<MaterialTransactionDto> materialTransactions =
await materialTransactionService.GetByCustomerNumber(customerNumber, customerSequence);
return Ok(materialTransactions);
}
}

View File

@@ -65,7 +65,7 @@ builder.Services.AddOpenApiDocument(config =>
In = OpenApiSecurityApiKeyLocation.Header, In = OpenApiSecurityApiKeyLocation.Header,
Description = "Wprowadź token JWT w formacie: Bearer {token}" Description = "Wprowadź token JWT w formacie: Bearer {token}"
}); });
config.OperationProcessors.Add(new OperationSecurityScopeProcessor("Bearer")); config.OperationProcessors.Add(new OperationSecurityScopeProcessor("Bearer"));
}); });
@@ -100,6 +100,9 @@ builder.Services.AddScoped<IRoleService, RoleService>();
builder.Services.AddScoped<IFunctionService, FunctionService>(); builder.Services.AddScoped<IFunctionService, FunctionService>();
builder.Services.AddScoped<IUserRoleService, UserRoleService>(); builder.Services.AddScoped<IUserRoleService, UserRoleService>();
builder.Services.AddScoped<IProductService, ProductService>(); builder.Services.AddScoped<IProductService, ProductService>();
builder.Services.AddScoped<IMaterialTransactionService, MaterialTransactionService>();
builder.Services.AddScoped<IWzClientService, WzClientService>();
builder.Services.AddScoped<IWzHeaderService, WzHeaderService>();
builder.Services.AddHostedService<TimedHostedService>(); builder.Services.AddHostedService<TimedHostedService>();

View File

@@ -2,6 +2,9 @@
@using Syncfusion.Blazor.Cards @using Syncfusion.Blazor.Cards
@using Syncfusion.Blazor.Grids @using Syncfusion.Blazor.Grids
@using SytelineSaAppEfDataModel.Dtos
@inject WarehouseService WarehouseService
<div class="h-100 d-flex justify-content-center align-items-start"> <div class="h-100 d-flex justify-content-center align-items-start">
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;"> <SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
@@ -9,63 +12,34 @@
<h3 class="text-primary">Dokumenty WZ na Magazynie</h3> <h3 class="text-primary">Dokumenty WZ na Magazynie</h3>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<SfGrid @ref="_grid" @* <SfGrid @ref="" *@
AllowFiltering="true" @* AllowFiltering="true" *@
AllowPaging="true" @* AllowPaging="true" *@
AllowSorting="true" @* AllowSorting="true" *@
AllowSelection="true" @* AllowSelection="true" *@
TValue="EdiCustomerOrderDto" @* TValue="" *@
DataSource="@_ediCustomerOrders" @* DataSource="" *@
EnableAdaptiveUI="true"> @* EnableAdaptiveUI="true"> *@
<GridTemplates> @* <GridTemplates> *@
<DetailTemplate> @* <DetailTemplate> *@
@{ @* @{ *@
var order = context as EdiCustomerOrderDto; @* } *@
<SfCard CssClass="mb-4"> @* </DetailTemplate> *@
<CardContent> @* </GridTemplates> *@
<div class="row"> @* <GridColumns> *@
<div class="col"> @* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerOrderNumber) HeaderText="Numer Zamówienia" Width="110"></GridColumn> #1# *@
<u>Numer zamówienia EDI:</u> <b>@order?.CustomerOrderNumber</b><br/> @* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerPoNumber) HeaderText="Zamówienie Klienta" Width="100"></GridColumn> #1# *@
<u>Numer zamówienia Klienta:</u> <b>@order?.CustomerPoNumber</b><br/> @* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerNumber) HeaderText="Numer Klienta" Width="90"></GridColumn> #1# *@
<u>Numer klienta:</u> <b>@order?.CustomerNumber</b><br/> @* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerSequence) HeaderText="Odbiorca" Width="80"></GridColumn> #1# *@
<u>Klient:</u> <b>@order?.CustomerName</b><br/> @* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CreateDate) HeaderText="Data Otrzymania" TextAlign="TextAlign.Center" Width="110"></GridColumn> #1# *@
<u>Numer odbiorcy:</u> <b>@(order?.CustomerSequence?.ToString() ?? "N/A")</b><br/> @* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.SlOrderNumber) HeaderText="Zamówienie SL" Width="100"></GridColumn> #1# *@
<u>Data otrzymania:</u> <b>@(order?.RecivedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/> @* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.SentToSl) HeaderText="Wysłane do SL" TextAlign="TextAlign.Center" Width="80"></GridColumn> #1# *@
<u>Wysłano do Syteline?:</u> <b>@((order?.Posted?.ToString() ?? "0") == "0" ? "NIE" : "TAK")</b><br/> @* </GridColumns> *@
<u>Data wysyłki do Syteline:</u> <b>@(order?.PostedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/> @* <GridFilterSettings Type="FilterType.Excel"/> *@
<u>Data zamówienia:</u> <b>@(order?.OrderDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/> @* <GridPageSettings PageSize="10"/> *@
</div> @* <GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/> *@
<div class="col"> @* $1$ <GridEvents TValue="EdiCustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick" RowSelected="RowSelected"/> #1# *@
<u>Cena:</u> <b>@(order?.Price?.ToString("F2") ?? "N/A")</b><br/> @* </SfGrid> *@
<u>Waga:</u> <b>@(order?.Weight?.ToString("F2") ?? "N/A")</b><br/>
<u>Magazyn:</u> <b>@order?.Warehouse</b><br/>
<u>Gate:</u> <b>@order?.Gate</b><br/>
<u>Kod odbiorcy:</u> <b>@order?.RecipientCode</b><br/>
<u>Kod wysyłającego:</u> <b>@order?.SenderCode</b><br/>
<u>Kod sprzedawcy:</u> <b>@order?.SellerCode</b><br/>
<u>Kod kupującego:</u> <b>@order?.BuyerCode</b><br/>
<u>Typ dokumentu:</u> <b>@order?.DocType</b><br/>
</div>
</div>
</CardContent>
</SfCard>
}
</DetailTemplate>
</GridTemplates>
<GridColumns>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerOrderNumber) HeaderText="Numer Zamówienia" Width="110"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerPoNumber) HeaderText="Zamówienie Klienta" Width="100"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerNumber) HeaderText="Numer Klienta" Width="90"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerSequence) HeaderText="Odbiorca" Width="80"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CreateDate) HeaderText="Data Otrzymania" TextAlign="TextAlign.Center" Width="110"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.SlOrderNumber) HeaderText="Zamówienie SL" Width="100"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.SentToSl) HeaderText="Wysłane do SL" TextAlign="TextAlign.Center" Width="80"></GridColumn>
</GridColumns>
<GridFilterSettings Type="FilterType.Excel"/>
<GridPageSettings PageSize="10"/>
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
<GridEvents TValue="EdiCustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick" RowSelected="RowSelected"/>
</SfGrid>
</CardContent> </CardContent>
<CardFooter> <CardFooter>
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small> <small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
@@ -74,5 +48,11 @@
</div> </div>
@code { @code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
IEnumerable<MaterialTransactionDto> task = await WarehouseService.GetAllClientWzsAsync("K005531", 0);
}
}
} }

View File

@@ -52,6 +52,7 @@ builder.Services.AddScoped<FunctionService>();
builder.Services.AddScoped<UserService>(); builder.Services.AddScoped<UserService>();
builder.Services.AddScoped<ErrorLogService>(); builder.Services.AddScoped<ErrorLogService>();
builder.Services.AddScoped<ProductService>(); builder.Services.AddScoped<ProductService>();
builder.Services.AddScoped<WarehouseService>();
var app = builder.Build(); var app = builder.Build();

View File

@@ -0,0 +1,21 @@
using SytelineSaAppEfDataModel.Dtos;
namespace OrdersManagement.Services;
public class WarehouseService
{
private readonly HttpClient _httpClient;
public WarehouseService(IHttpClientFactory httpClientFactory)
{
_httpClient = httpClientFactory.CreateClient("FaKrosnoApi");
}
public async Task<IEnumerable<MaterialTransactionDto>> GetAllClientWzsAsync(string customerNumber, int customerSequence)
{
var response = await _httpClient.GetAsync(
$"api/WzHeader/by-customer-number?customerNumber={customerNumber}&customerSequence={customerSequence}");
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<IEnumerable<MaterialTransactionDto>>();
}
}

View File

@@ -9,4 +9,5 @@ public interface IMaterialTransactionService
Task<IEnumerable<MaterialTransactionDto>> GetByWzNumbers(ISet<string> wzNumbers); Task<IEnumerable<MaterialTransactionDto>> GetByWzNumbers(ISet<string> wzNumbers);
Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber(string orderNumber); Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber(string orderNumber);
Task<IEnumerable<MaterialTransactionDto>> GetOrderNumbersByWz(ISet<string> wzNumbers); Task<IEnumerable<MaterialTransactionDto>> GetOrderNumbersByWz(ISet<string> wzNumbers);
Task<IEnumerable<MaterialTransactionDto>> GetByCustomerNumber(string customerNumber, int customerSequence);
} }

View File

@@ -66,4 +66,21 @@ public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper
return result.Select(x => mapper.Map<MaterialTransactionDto>(x)); return result.Select(x => mapper.Map<MaterialTransactionDto>(x));
} }
public async Task<IEnumerable<MaterialTransactionDto>> GetByCustomerNumber(string customerNumber, int customerSequence)
{
IList<string> coNumbers = await context.CustomerOrders
.Where(x => x.CustNum == customerNumber && x.CustSeq == customerSequence && (x.Stat == "P" || x.Stat == "O"))
.Select(x => x.CoNum).ToListAsync();
List<MaterialTransactionDto> result = new List<MaterialTransactionDto>();
foreach (string coNumber in coNumbers)
{
IEnumerable<MaterialTransactionDto> materialTransactions = await GetByOrderNumber(coNumber);
result.AddRange(materialTransactions);
}
return result.OrderByDescending(x => x.CreateDate);
}
} }