Warehouses #1
@@ -24,6 +24,16 @@ public class WzHeaderController(IWzHeaderService service, IMaterialTransactionSe
|
|||||||
return Ok(materialTransactions);
|
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]
|
[HttpPost]
|
||||||
public async Task<ActionResult> CreateHeader([FromBody] WzHeaderDto wzHeader)
|
public async Task<ActionResult> CreateHeader([FromBody] WzHeaderDto wzHeader)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,12 +5,9 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
|
|
||||||
namespace FaKrosnoEfDataModel.Services;
|
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()
|
public async Task<IEnumerable<ProductDto?>> GetEntities()
|
||||||
{
|
{
|
||||||
IList<ProductDto> products = (await GetAll()).ToList();
|
IList<ProductDto> products = (await GetAll()).ToList();
|
||||||
@@ -22,9 +19,10 @@ public class ProductService : ServiceBase<ProductDto>, IProductService
|
|||||||
{
|
{
|
||||||
IList<RecipientDto> recipients =
|
IList<RecipientDto> recipients =
|
||||||
(await Context.Recipients.ToListAsync()).Select(x => Mapper.Map<RecipientDto>(x)).ToList();
|
(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();
|
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)
|
foreach (ProductDto productDto in productDtos)
|
||||||
{
|
{
|
||||||
@@ -35,6 +33,13 @@ public class ProductService : ServiceBase<ProductDto>, IProductService
|
|||||||
productDto.Recipient = recipient;
|
productDto.Recipient = recipient;
|
||||||
productDto.RecipientName = recipient.RecipientDesc;
|
productDto.RecipientName = recipient.RecipientDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PurchaserDto? purchaser = purchasers.FirstOrDefault(x => x.ID == productDto.Recipient.PurchaserID);
|
||||||
|
|
||||||
|
if (purchaser != null)
|
||||||
|
{
|
||||||
|
productDto.Recipient.Purchaser = purchaser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return productDtos;
|
return productDtos;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
@page "/Warehouse"
|
@page "/Warehouse"
|
||||||
|
|
||||||
|
@using Blazored.LocalStorage
|
||||||
@using Syncfusion.Blazor.Cards
|
@using Syncfusion.Blazor.Cards
|
||||||
@using Syncfusion.Blazor.Grids
|
@using Syncfusion.Blazor.Grids
|
||||||
@using SytelineSaAppEfDataModel.Dtos
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
|
|
||||||
@inject WarehouseService WarehouseService
|
@inject WarehouseService WarehouseService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject ILocalStorageService LocalStorage
|
||||||
|
|
||||||
<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;">
|
||||||
@@ -18,13 +20,17 @@
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<h5 class="text-primary mb-3">Klient</h5>
|
<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"/>
|
<DropDownListFieldSettings Value="ID" Text="Name"/>
|
||||||
<DropDownListEvents TValue="Guid?" TItem="WzClientDto" ValueChange="OnValueChange"/>
|
<DropDownListEvents TValue="Guid?" TItem="WzClientDto" ValueChange="OnValueChange"/>
|
||||||
</SfDropDownList>
|
</SfDropDownList>
|
||||||
@if (_isVisible)
|
@if (_isVisible)
|
||||||
{
|
{
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
<h5 class="text-primary mb-3">Dokumenty WZ</h5>
|
<h5 class="text-primary mb-3">Dokumenty WZ</h5>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
<SfGrid @ref="_grid"
|
<SfGrid @ref="_grid"
|
||||||
AllowFiltering="true"
|
AllowFiltering="true"
|
||||||
AllowPaging="true"
|
AllowPaging="true"
|
||||||
@@ -45,9 +51,35 @@
|
|||||||
</ToolbarItems>
|
</ToolbarItems>
|
||||||
</SfToolbar>
|
</SfToolbar>
|
||||||
<GridFilterSettings Type="FilterType.Excel"/>
|
<GridFilterSettings Type="FilterType.Excel"/>
|
||||||
<GridPageSettings PageSize="10" PageSizes="@(new[] { 10, 20, 50, 100 })"/>
|
<GridPageSettings PageSize="5"/>
|
||||||
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
|
||||||
</SfGrid>
|
</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>
|
</CardContent>
|
||||||
<CardFooter>
|
<CardFooter>
|
||||||
@@ -58,19 +90,32 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
private SfGrid<MaterialTransactionDto> _grid;
|
private SfGrid<MaterialTransactionDto> _grid;
|
||||||
|
private SfGrid<WzHeaderDto> _wzHeadersGrid;
|
||||||
private IEnumerable<WzClientDto> _clients = new List<WzClientDto>();
|
private IEnumerable<WzClientDto> _clients = new List<WzClientDto>();
|
||||||
private IEnumerable<MaterialTransactionDto> _materialTransactions = new List<MaterialTransactionDto>();
|
private IEnumerable<MaterialTransactionDto> _materialTransactions = new List<MaterialTransactionDto>();
|
||||||
private IEnumerable<MaterialTransactionDto> _dataSource = new List<MaterialTransactionDto>();
|
private IEnumerable<MaterialTransactionDto> _dataSource = new List<MaterialTransactionDto>();
|
||||||
|
private IEnumerable<WzHeaderDto> _wzHeaders = new List<WzHeaderDto>();
|
||||||
|
|
||||||
private WzClientDto? _selectedClient;
|
private WzClientDto? _selectedClient;
|
||||||
|
|
||||||
bool _isVisible = false;
|
private WzHeaderDto? _selectedHeader;
|
||||||
|
private SfDropDownList<Guid?, WzClientDto> _dropdown;
|
||||||
|
private bool _isVisible;
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
_clients = await WarehouseService.GetAllClientsAsync();
|
_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();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,10 +124,18 @@
|
|||||||
{
|
{
|
||||||
if (args.Value.HasValue)
|
if (args.Value.HasValue)
|
||||||
{
|
{
|
||||||
_selectedClient = args.ItemData;
|
_selectedClient = args.ItemData ?? _clients.FirstOrDefault(x => x.ID == args.Value);
|
||||||
|
|
||||||
|
if (_selectedClient == null) { return; }
|
||||||
|
|
||||||
_isVisible = true;
|
_isVisible = true;
|
||||||
_materialTransactions = await WarehouseService.GetAllClientWzsAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0);
|
_materialTransactions = await WarehouseService.GetAllClientWzsAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0);
|
||||||
_dataSource = _materialTransactions.GroupBy(x => x.MTGroupNum).Select(x => x.First()).ToList();
|
_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
|
else
|
||||||
{
|
{
|
||||||
@@ -93,6 +146,13 @@
|
|||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRowDoubleClick(RecordDoubleClickEventArgs<WzHeaderDto> obj)
|
||||||
|
{
|
||||||
|
Guid headerId = obj.RowData.ID;
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo("/Warehouse/PackList/" + headerId);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task CreatePackingList()
|
private async Task CreatePackingList()
|
||||||
{
|
{
|
||||||
var selectedRecords = await _grid.GetSelectedRecordsAsync();
|
var selectedRecords = await _grid.GetSelectedRecordsAsync();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
@using Syncfusion.Blazor.Grids
|
@using Syncfusion.Blazor.Grids
|
||||||
@using SytelineSaAppEfDataModel.Dtos
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
@using Syncfusion.Blazor.Navigations
|
@using Syncfusion.Blazor.Navigations
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
|
||||||
@inject WarehouseService WarehouseService
|
@inject WarehouseService WarehouseService
|
||||||
|
|
||||||
@@ -59,6 +60,25 @@
|
|||||||
<GridEvents OnBatchSave="OnBatchSave" TValue="WzRowMeyleDto"></GridEvents>
|
<GridEvents OnBatchSave="OnBatchSave" TValue="WzRowMeyleDto"></GridEvents>
|
||||||
</SfGrid>
|
</SfGrid>
|
||||||
</CardContent>
|
</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>
|
<CardFooter>
|
||||||
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
@@ -71,6 +91,15 @@
|
|||||||
private SfGrid<WzRowMeyleDto> _grid;
|
private SfGrid<WzRowMeyleDto> _grid;
|
||||||
private IEnumerable<WzRowMeyleDto> _wzRowsMeyle { get; set; } = new List<WzRowMeyleDto>();
|
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)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
@@ -98,7 +127,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task ExportXls()
|
private async Task ExportXls()
|
||||||
|
{
|
||||||
|
int count = _wzRowsMeyle.Count(x => x.PalletNumber == null);
|
||||||
|
|
||||||
|
_isValid = count == 0;
|
||||||
|
|
||||||
|
if (_isValid)
|
||||||
{
|
{
|
||||||
await WarehouseService.GenerateXlsForMeyleAsync(WzHeader);
|
await WarehouseService.GenerateXlsForMeyleAsync(WzHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Visibility = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,14 @@ public class WarehouseService(IHttpClientFactory httpClientFactory)
|
|||||||
return await response.Content.ReadFromJsonAsync<IEnumerable<MaterialTransactionDto>>();
|
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)
|
public async Task CreateWzHeaderAsync(WzHeaderDto wzHeader)
|
||||||
{
|
{
|
||||||
var response = await _httpClient.PostAsJsonAsync("api/WzHeader", wzHeader);
|
var response = await _httpClient.PostAsJsonAsync("api/WzHeader", wzHeader);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace SytelineSaAppEfDataModel.Services;
|
|||||||
public interface IWzHeaderService
|
public interface IWzHeaderService
|
||||||
{
|
{
|
||||||
Task<IEnumerable<WzHeaderDto>> GetAll();
|
Task<IEnumerable<WzHeaderDto>> GetAll();
|
||||||
|
Task<IEnumerable<WzHeaderDto>> GetByCustomerNumber(string customerNumber, int customerSequence);
|
||||||
Task CreateHeader(WzHeaderDto wzHeader);
|
Task CreateHeader(WzHeaderDto wzHeader);
|
||||||
Task<WzHeaderDto> GetById(Guid id);
|
Task<WzHeaderDto> GetById(Guid id);
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,13 @@ public class WzHeaderService(SytelineSaAppDbContext context, IMapper mapper) : I
|
|||||||
return await context.WzHeaders.Select(x => mapper.Map<WzHeaderDto>(x)).ToListAsync();
|
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)
|
public async Task CreateHeader(WzHeaderDto wzHeader)
|
||||||
{
|
{
|
||||||
var entity = mapper.Map<WzHeader>(wzHeader);
|
var entity = mapper.Map<WzHeader>(wzHeader);
|
||||||
|
|||||||
@@ -899,7 +899,7 @@ namespace SytelineSaAppEfDataModel
|
|||||||
|
|
||||||
entity.Property(e => e.CreatedDate)
|
entity.Property(e => e.CreatedDate)
|
||||||
.HasColumnName("CreatedDate")
|
.HasColumnName("CreatedDate")
|
||||||
.HasColumnType("timestamp")
|
.HasColumnType("DateTime")
|
||||||
.IsRowVersion();
|
.IsRowVersion();
|
||||||
|
|
||||||
// Relationship
|
// Relationship
|
||||||
@@ -931,7 +931,7 @@ namespace SytelineSaAppEfDataModel
|
|||||||
|
|
||||||
entity.Property(e => e.CreatedDate)
|
entity.Property(e => e.CreatedDate)
|
||||||
.HasColumnName("CreatedDate")
|
.HasColumnName("CreatedDate")
|
||||||
.HasColumnType("timestamp")
|
.HasColumnType("DateTime")
|
||||||
.IsRowVersion();
|
.IsRowVersion();
|
||||||
|
|
||||||
entity.Property(e => e.Name)
|
entity.Property(e => e.Name)
|
||||||
|
|||||||
Reference in New Issue
Block a user