* Added new Controllers to API
* Added methods to get WZs for specific client
This commit is contained in:
17
FaKrosnoApi/Controllers/WzClientController.cs
Normal file
17
FaKrosnoApi/Controllers/WzClientController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
26
FaKrosnoApi/Controllers/WzHeaderController.cs
Normal file
26
FaKrosnoApi/Controllers/WzHeaderController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,9 @@ builder.Services.AddScoped<IRoleService, RoleService>();
|
||||
builder.Services.AddScoped<IFunctionService, FunctionService>();
|
||||
builder.Services.AddScoped<IUserRoleService, UserRoleService>();
|
||||
builder.Services.AddScoped<IProductService, ProductService>();
|
||||
builder.Services.AddScoped<IMaterialTransactionService, MaterialTransactionService>();
|
||||
builder.Services.AddScoped<IWzClientService, WzClientService>();
|
||||
builder.Services.AddScoped<IWzHeaderService, WzHeaderService>();
|
||||
|
||||
builder.Services.AddHostedService<TimedHostedService>();
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
@using Syncfusion.Blazor.Cards
|
||||
@using Syncfusion.Blazor.Grids
|
||||
@using SytelineSaAppEfDataModel.Dtos
|
||||
|
||||
@inject WarehouseService WarehouseService
|
||||
|
||||
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||
@@ -9,63 +12,34 @@
|
||||
<h3 class="text-primary">Dokumenty WZ na Magazynie</h3>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<SfGrid @ref="_grid"
|
||||
AllowFiltering="true"
|
||||
AllowPaging="true"
|
||||
AllowSorting="true"
|
||||
AllowSelection="true"
|
||||
TValue="EdiCustomerOrderDto"
|
||||
DataSource="@_ediCustomerOrders"
|
||||
EnableAdaptiveUI="true">
|
||||
<GridTemplates>
|
||||
<DetailTemplate>
|
||||
@{
|
||||
var order = context as EdiCustomerOrderDto;
|
||||
<SfCard CssClass="mb-4">
|
||||
<CardContent>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<u>Numer zamówienia EDI:</u> <b>@order?.CustomerOrderNumber</b><br/>
|
||||
<u>Numer zamówienia Klienta:</u> <b>@order?.CustomerPoNumber</b><br/>
|
||||
<u>Numer klienta:</u> <b>@order?.CustomerNumber</b><br/>
|
||||
<u>Klient:</u> <b>@order?.CustomerName</b><br/>
|
||||
<u>Numer odbiorcy:</u> <b>@(order?.CustomerSequence?.ToString() ?? "N/A")</b><br/>
|
||||
<u>Data otrzymania:</u> <b>@(order?.RecivedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||
<u>Wysłano do Syteline?:</u> <b>@((order?.Posted?.ToString() ?? "0") == "0" ? "NIE" : "TAK")</b><br/>
|
||||
<u>Data wysyłki do Syteline:</u> <b>@(order?.PostedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||
<u>Data zamówienia:</u> <b>@(order?.OrderDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<u>Cena:</u> <b>@(order?.Price?.ToString("F2") ?? "N/A")</b><br/>
|
||||
<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>
|
||||
@* <SfGrid @ref="" *@
|
||||
@* AllowFiltering="true" *@
|
||||
@* AllowPaging="true" *@
|
||||
@* AllowSorting="true" *@
|
||||
@* AllowSelection="true" *@
|
||||
@* TValue="" *@
|
||||
@* DataSource="" *@
|
||||
@* EnableAdaptiveUI="true"> *@
|
||||
@* <GridTemplates> *@
|
||||
@* <DetailTemplate> *@
|
||||
@* @{ *@
|
||||
@* } *@
|
||||
@* </DetailTemplate> *@
|
||||
@* </GridTemplates> *@
|
||||
@* <GridColumns> *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerOrderNumber) HeaderText="Numer Zamówienia" Width="110"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerPoNumber) HeaderText="Zamówienie Klienta" Width="100"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerNumber) HeaderText="Numer Klienta" Width="90"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerSequence) HeaderText="Odbiorca" Width="80"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.CreateDate) HeaderText="Data Otrzymania" TextAlign="TextAlign.Center" Width="110"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.SlOrderNumber) HeaderText="Zamówienie SL" Width="100"></GridColumn> #1# *@
|
||||
@* $1$ <GridColumn Field=@nameof(EdiCustomerOrderDto.SentToSl) HeaderText="Wysłane do SL" TextAlign="TextAlign.Center" Width="80"></GridColumn> #1# *@
|
||||
@* </GridColumns> *@
|
||||
@* <GridFilterSettings Type="FilterType.Excel"/> *@
|
||||
@* <GridPageSettings PageSize="10"/> *@
|
||||
@* <GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/> *@
|
||||
@* $1$ <GridEvents TValue="EdiCustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick" RowSelected="RowSelected"/> #1# *@
|
||||
@* </SfGrid> *@
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||
@@ -74,5 +48,11 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
IEnumerable<MaterialTransactionDto> task = await WarehouseService.GetAllClientWzsAsync("K005531", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ builder.Services.AddScoped<FunctionService>();
|
||||
builder.Services.AddScoped<UserService>();
|
||||
builder.Services.AddScoped<ErrorLogService>();
|
||||
builder.Services.AddScoped<ProductService>();
|
||||
builder.Services.AddScoped<WarehouseService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
21
OrdersManagement/Services/WarehouseService.cs
Normal file
21
OrdersManagement/Services/WarehouseService.cs
Normal 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>>();
|
||||
}
|
||||
}
|
||||
@@ -9,4 +9,5 @@ public interface IMaterialTransactionService
|
||||
Task<IEnumerable<MaterialTransactionDto>> GetByWzNumbers(ISet<string> wzNumbers);
|
||||
Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber(string orderNumber);
|
||||
Task<IEnumerable<MaterialTransactionDto>> GetOrderNumbersByWz(ISet<string> wzNumbers);
|
||||
Task<IEnumerable<MaterialTransactionDto>> GetByCustomerNumber(string customerNumber, int customerSequence);
|
||||
}
|
||||
@@ -66,4 +66,21 @@ public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user