Warehouses #1

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

View File

@@ -24,6 +24,16 @@ public class WzHeaderController(IWzHeaderService service, IMaterialTransactionSe
return Ok(materialTransactions);
}
[HttpGet("all-wz-headers")]
public async Task<ActionResult<IEnumerable<MaterialTransactionDto>>> GetHeadersByCustomerNumber(
[FromQuery] string customerNumber, [FromQuery] int customerSequence)
{
IEnumerable<WzHeaderDto> wzHeaders =
await service.GetByCustomerNumber(customerNumber, customerSequence);
return Ok(wzHeaders.OrderByDescending(x => x.CreatedDate));
}
[HttpPost]
public async Task<ActionResult> CreateHeader([FromBody] WzHeaderDto wzHeader)
{

View File

@@ -5,12 +5,9 @@ using Microsoft.EntityFrameworkCore;
namespace FaKrosnoEfDataModel.Services;
public class ProductService : ServiceBase<ProductDto>, IProductService
public class ProductService(FaKrosnoDbContext context, IMapper mapper)
: ServiceBase<ProductDto>(context, mapper), IProductService
{
public ProductService(FaKrosnoDbContext context, IMapper mapper) : base(context, mapper)
{
}
public async Task<IEnumerable<ProductDto?>> GetEntities()
{
IList<ProductDto> products = (await GetAll()).ToList();
@@ -22,9 +19,10 @@ public class ProductService : ServiceBase<ProductDto>, IProductService
{
IList<RecipientDto> recipients =
(await Context.Recipients.ToListAsync()).Select(x => Mapper.Map<RecipientDto>(x)).ToList();
IList<PurchaserDto> purchasers = (await Context.Purchasers.ToListAsync()).Select(x => Mapper.Map<PurchaserDto>(x)).ToList();
IList<ProductDto> products = (await GetAll()).ToList();
IEnumerable<ProductDto> productDtos = products.Where(x => x?.FaIdx == indexName);
IEnumerable<ProductDto> productDtos = products.Where(x => x.FaIdx == indexName).ToList();
foreach (ProductDto productDto in productDtos)
{
@@ -35,6 +33,13 @@ public class ProductService : ServiceBase<ProductDto>, IProductService
productDto.Recipient = recipient;
productDto.RecipientName = recipient.RecipientDesc;
}
PurchaserDto? purchaser = purchasers.FirstOrDefault(x => x.ID == productDto.Recipient.PurchaserID);
if (purchaser != null)
{
productDto.Recipient.Purchaser = purchaser;
}
}
return productDtos;

View File

@@ -1,5 +1,6 @@
@page "/Warehouse"
@using Blazored.LocalStorage
@using Syncfusion.Blazor.Cards
@using Syncfusion.Blazor.Grids
@using SytelineSaAppEfDataModel.Dtos
@@ -10,6 +11,7 @@
@inject WarehouseService WarehouseService
@inject NavigationManager NavigationManager
@inject ILocalStorageService LocalStorage
<div class="h-100 d-flex justify-content-center align-items-start">
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
@@ -18,13 +20,17 @@
</CardHeader>
<CardContent>
<h5 class="text-primary mb-3">Klient</h5>
<SfDropDownList TValue="Guid?" TItem="WzClientDto" DataSource="@_clients" Placeholder="Wybierz Klienta">
<SfDropDownList @ref="_dropdown" TValue="Guid?" TItem="WzClientDto" DataSource="@_clients" Placeholder="Wybierz Klienta">
<DropDownListFieldSettings Value="ID" Text="Name"/>
<DropDownListEvents TValue="Guid?" TItem="WzClientDto" ValueChange="OnValueChange"/>
</SfDropDownList>
@if (_isVisible)
{
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
<CardHeader>
<h5 class="text-primary mb-3">Dokumenty WZ</h5>
</CardHeader>
<CardContent>
<SfGrid @ref="_grid"
AllowFiltering="true"
AllowPaging="true"
@@ -45,9 +51,35 @@
</ToolbarItems>
</SfToolbar>
<GridFilterSettings Type="FilterType.Excel"/>
<GridPageSettings PageSize="10" PageSizes="@(new[] { 10, 20, 50, 100 })"/>
<GridPageSettings PageSize="5"/>
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
</SfGrid>
</CardContent>
</SfCard>
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
<CardHeader>
<h5 class="text-primary mb-3">Packling Listy</h5>
</CardHeader>
<CardContent>
<SfGrid @ref="_wzHeadersGrid"
AllowFiltering="true"
AllowPaging="true"
AllowSorting="true"
AllowSelection="true"
TValue="WzHeaderDto"
DataSource="@_wzHeaders"
EnableAdaptiveUI="true">
<GridColumns>
<GridColumn Field=@nameof(WzHeaderDto.ID) HeaderText="ID" TextAlign="TextAlign.Center" Width="110"></GridColumn>
<GridColumn Field=@nameof(WzHeaderDto.CreatedDate) HeaderText="Data utworzenia" TextAlign="TextAlign.Center" Width="100"></GridColumn>
</GridColumns>
<GridFilterSettings Type="FilterType.Excel"/>
<GridPageSettings PageSize="5"/>
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Single"/>
<GridEvents TValue="WzHeaderDto" OnRecordDoubleClick="OnRowDoubleClick"/>
</SfGrid>
</CardContent>
</SfCard>
}
</CardContent>
<CardFooter>
@@ -58,19 +90,32 @@
@code {
private SfGrid<MaterialTransactionDto> _grid;
private SfGrid<WzHeaderDto> _wzHeadersGrid;
private IEnumerable<WzClientDto> _clients = new List<WzClientDto>();
private IEnumerable<MaterialTransactionDto> _materialTransactions = new List<MaterialTransactionDto>();
private IEnumerable<MaterialTransactionDto> _dataSource = new List<MaterialTransactionDto>();
private IEnumerable<WzHeaderDto> _wzHeaders = new List<WzHeaderDto>();
private WzClientDto? _selectedClient;
bool _isVisible = false;
private WzHeaderDto? _selectedHeader;
private SfDropDownList<Guid?, WzClientDto> _dropdown;
private bool _isVisible;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
_clients = await WarehouseService.GetAllClientsAsync();
_clients = _clients.Where(x => x.Name.Equals("MEYLE", StringComparison.OrdinalIgnoreCase));
var savedClientId = await LocalStorage.GetItemAsync<Guid?>("SelectedClientId");
if (savedClientId != null && _clients.FirstOrDefault(c => c.ID == savedClientId) is {} savedClient)
{
await OnValueChange(new ChangeEventArgs<Guid?, WzClientDto>() { Value = savedClient.ID });
}
StateHasChanged();
}
}
@@ -79,10 +124,18 @@
{
if (args.Value.HasValue)
{
_selectedClient = args.ItemData;
_selectedClient = args.ItemData ?? _clients.FirstOrDefault(x => x.ID == args.Value);
if (_selectedClient == null) { return; }
_isVisible = true;
_materialTransactions = await WarehouseService.GetAllClientWzsAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0);
_dataSource = _materialTransactions.GroupBy(x => x.MTGroupNum).Select(x => x.First()).ToList();
_wzHeaders = await WarehouseService.GetAllClientWzHeadersAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0);
await LocalStorage.SetItemAsync("SelectedClientId", _selectedClient.ID);
_dropdown.Value = _selectedClient.ID;
}
else
{
@@ -93,6 +146,13 @@
StateHasChanged();
}
private void OnRowDoubleClick(RecordDoubleClickEventArgs<WzHeaderDto> obj)
{
Guid headerId = obj.RowData.ID;
NavigationManager.NavigateTo("/Warehouse/PackList/" + headerId);
}
private async Task CreatePackingList()
{
var selectedRecords = await _grid.GetSelectedRecordsAsync();

View File

@@ -3,6 +3,7 @@
@using Syncfusion.Blazor.Grids
@using SytelineSaAppEfDataModel.Dtos
@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Popups
@inject WarehouseService WarehouseService
@@ -59,6 +60,25 @@
<GridEvents OnBatchSave="OnBatchSave" TValue="WzRowMeyleDto"></GridEvents>
</SfGrid>
</CardContent>
<SfDialog Width="500px" Title="Informacja" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
<DialogTemplates>
<Content>
@if (_isValid)
{
<p>Packing List został wygenerowany i wysłany!</p>
}
else
{
<p>Błąd: Nie Wszystkie linie mają wypełniony <b>NUMER PALETY</b>.<br/>Packing List nie zostanie wygenerowany!</p>
}
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
</DialogButtons>
</SfDialog>
<CardFooter>
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
</CardFooter>
@@ -71,6 +91,15 @@
private SfGrid<WzRowMeyleDto> _grid;
private IEnumerable<WzRowMeyleDto> _wzRowsMeyle { get; set; } = new List<WzRowMeyleDto>();
private bool _isValid;
private bool Visibility { get; set; }
private void HideModal()
{
Visibility = false;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
@@ -98,7 +127,16 @@
}
private async Task ExportXls()
{
int count = _wzRowsMeyle.Count(x => x.PalletNumber == null);
_isValid = count == 0;
if (_isValid)
{
await WarehouseService.GenerateXlsForMeyleAsync(WzHeader);
}
Visibility = true;
}
}

View File

@@ -21,6 +21,14 @@ public class WarehouseService(IHttpClientFactory httpClientFactory)
return await response.Content.ReadFromJsonAsync<IEnumerable<MaterialTransactionDto>>();
}
public async Task<IEnumerable<WzHeaderDto>> GetAllClientWzHeadersAsync(string customerNumber, int customerSequence)
{
var response = await _httpClient.GetAsync(
$"api/WzHeader/all-wz-headers?customerNumber={customerNumber}&customerSequence={customerSequence}");
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<IEnumerable<WzHeaderDto>>();
}
public async Task CreateWzHeaderAsync(WzHeaderDto wzHeader)
{
var response = await _httpClient.PostAsJsonAsync("api/WzHeader", wzHeader);

View File

@@ -5,6 +5,7 @@ namespace SytelineSaAppEfDataModel.Services;
public interface IWzHeaderService
{
Task<IEnumerable<WzHeaderDto>> GetAll();
Task<IEnumerable<WzHeaderDto>> GetByCustomerNumber(string customerNumber, int customerSequence);
Task CreateHeader(WzHeaderDto wzHeader);
Task<WzHeaderDto> GetById(Guid id);
}

View File

@@ -12,6 +12,13 @@ public class WzHeaderService(SytelineSaAppDbContext context, IMapper mapper) : I
return await context.WzHeaders.Select(x => mapper.Map<WzHeaderDto>(x)).ToListAsync();
}
public async Task<IEnumerable<WzHeaderDto>> GetByCustomerNumber(string customerNumber, int customerSequence)
{
return await context.WzHeaders.Include(x => x.Client)
.Where(x => x.Client.CustomerNumber == customerNumber && x.Client.CustomerSequence == customerSequence)
.Select(x => mapper.Map<WzHeaderDto>(x)).ToListAsync();
}
public async Task CreateHeader(WzHeaderDto wzHeader)
{
var entity = mapper.Map<WzHeader>(wzHeader);

View File

@@ -899,7 +899,7 @@ namespace SytelineSaAppEfDataModel
entity.Property(e => e.CreatedDate)
.HasColumnName("CreatedDate")
.HasColumnType("timestamp")
.HasColumnType("DateTime")
.IsRowVersion();
// Relationship
@@ -931,7 +931,7 @@ namespace SytelineSaAppEfDataModel
entity.Property(e => e.CreatedDate)
.HasColumnName("CreatedDate")
.HasColumnType("timestamp")
.HasColumnType("DateTime")
.IsRowVersion();
entity.Property(e => e.Name)