Warehouses #1
@@ -6,7 +6,7 @@ namespace FaKrosnoApi.Controllers;
|
|||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
public class WzRowMareliController(IWzRowMareliService service, IMaterialTransactionService materialTransactionService) : Controller
|
public class WzRowMarelliController(IWzRowMareliService service, IMaterialTransactionService materialTransactionService) : Controller
|
||||||
{
|
{
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<WzRowMarelliDto>>> GetAll()
|
public async Task<ActionResult<IEnumerable<WzRowMarelliDto>>> GetAll()
|
||||||
@@ -67,22 +67,19 @@
|
|||||||
<GridColumns>
|
<GridColumns>
|
||||||
<GridColumn Field=@nameof(WzRowMarelliDto.ID) IsPrimaryKey="true" Visible="false" AllowEditing="false"
|
<GridColumn Field=@nameof(WzRowMarelliDto.ID) IsPrimaryKey="true" Visible="false" AllowEditing="false"
|
||||||
TextAlign="TextAlign.Center" HeaderText="ID" Width="70"></GridColumn>
|
TextAlign="TextAlign.Center" HeaderText="ID" Width="70"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMarelliDto.OrderNumber) AllowEditing="false"
|
|
||||||
TextAlign="TextAlign.Center" HeaderText="Numer Zamówienia Meyle"
|
|
||||||
Width="70"></GridColumn>
|
|
||||||
<GridColumn Field=@nameof(WzRowMarelliDto.FaIndex) AllowEditing="false" AllowFiltering="true"
|
|
||||||
TextAlign="TextAlign.Center" HeaderText="Numer Indeksu FA" Width="100"></GridColumn>
|
|
||||||
<GridColumn Field=@nameof(WzRowMarelliDto.ItemNumber) AllowEditing="false"
|
|
||||||
TextAlign="TextAlign.Center" HeaderText="Numer Indeksu Meyle" Width="100"></GridColumn>
|
|
||||||
<GridColumn Field=@nameof(WzRowMarelliDto.Quantity) AllowEditing="false" TextAlign="TextAlign.Center"
|
|
||||||
HeaderText="Ilość w Dostawie" Width="80"></GridColumn>
|
|
||||||
<GridColumn Field=@nameof(WzRowMarelliDto.PalletNumber) AllowEditing="true"
|
<GridColumn Field=@nameof(WzRowMarelliDto.PalletNumber) AllowEditing="true"
|
||||||
TextAlign="TextAlign.Center" HeaderText="Nr Palety" Width="100"></GridColumn>
|
TextAlign="TextAlign.Center" HeaderText="Nr Palety" Width="100"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMarelliDto.PartNumberSl) AllowEditing="true"
|
<GridColumn Field=@nameof(WzRowMarelliDto.ItemNumber) AllowEditing="false"
|
||||||
TextAlign="TextAlign.Center"
|
TextAlign="TextAlign.Center" HeaderText="Numer Indeksu Marelli"
|
||||||
HeaderText="Nr Partii SL" Width="80"></GridColumn>
|
Width="70"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMarelliDto.PartNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
<GridColumn Field=@nameof(WzRowMarelliDto.EngineerNumber) AllowEditing="false" AllowFiltering="true"
|
||||||
HeaderText="Nr Partii Meyle" Width="80"></GridColumn>
|
TextAlign="TextAlign.Center" HeaderText="Numer Inżynieryjny" Width="100"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.Quantity) AllowEditing="false" TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Ilość w Dostawie" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.OrderNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Nr Zamówienia" Width="80"></GridColumn>
|
||||||
|
<GridColumn Field=@nameof(WzRowMarelliDto.WzNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
||||||
|
HeaderText="Nr WZ" Width="80"></GridColumn>
|
||||||
</GridColumns>
|
</GridColumns>
|
||||||
<GridEditSettings AllowDeleting="false"
|
<GridEditSettings AllowDeleting="false"
|
||||||
AllowAdding="false"
|
AllowAdding="false"
|
||||||
@@ -183,7 +180,7 @@
|
|||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
WzRowsMarelli = (await WarehouseService.GetWzRowsByWzHeaderId(WzHeader)).ToList();
|
WzRowsMarelli = (await WarehouseService.GetWzRowsMarelliByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
TransactionModelsByPartNumber = await GetTransactionModels();
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
@@ -259,7 +256,7 @@
|
|||||||
if (materialTransactionByPartNumber != null)
|
if (materialTransactionByPartNumber != null)
|
||||||
{
|
{
|
||||||
SelectedRows.Clear();
|
SelectedRows.Clear();
|
||||||
FillFaPartNumberAndPalletNumber(materialTransactionByPartNumber, obj.Value.Trim());
|
FillPalletNumber(materialTransactionByPartNumber, obj.Value.Trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
LastScannedValue = ScannedValue;
|
LastScannedValue = ScannedValue;
|
||||||
@@ -268,7 +265,7 @@
|
|||||||
_scanner.FocusAsync();
|
_scanner.FocusAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task FillFaPartNumberAndPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
private async Task FillPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
||||||
{
|
{
|
||||||
await _grid.ClearSelectionAsync();
|
await _grid.ClearSelectionAsync();
|
||||||
await _grid.Refresh();
|
await _grid.Refresh();
|
||||||
@@ -367,9 +364,9 @@
|
|||||||
|
|
||||||
private async Task UpdateRows(IList<WzRowMarelliDto> changedRecords)
|
private async Task UpdateRows(IList<WzRowMarelliDto> changedRecords)
|
||||||
{
|
{
|
||||||
await WarehouseService.UpdateWzRowsMeyleAsync(changedRecords);
|
await WarehouseService.UpdateWzRowsMarelliAsync(changedRecords);
|
||||||
|
|
||||||
WzRowsMarelli = (await WarehouseService.GetWzRowsByWzHeaderId(WzHeader)).ToList();
|
WzRowsMarelli = (await WarehouseService.GetWzRowsMarelliByWzHeaderId(WzHeader)).ToList();
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
await _grid.Refresh();
|
await _grid.Refresh();
|
||||||
}
|
}
|
||||||
@@ -388,7 +385,7 @@
|
|||||||
{
|
{
|
||||||
if (currentSum == targetSum)
|
if (currentSum == targetSum)
|
||||||
{
|
{
|
||||||
result.Add(new List<WzRowMarelliDto>(currentCombination));
|
result.Add([..currentCombination]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,316 @@
|
|||||||
|
@page "/Warehouse/Marelli/PackList/{WzHeader:guid}/Simple"
|
||||||
|
@using OrdersManagement.Models
|
||||||
|
@using Syncfusion.Blazor.Cards
|
||||||
|
@using SytelineSaAppEfDataModel.Dtos
|
||||||
|
@using Syncfusion.Blazor.Popups
|
||||||
|
@using Syncfusion.Blazor.Inputs
|
||||||
|
@using Syncfusion.Blazor.Buttons
|
||||||
|
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject WarehouseService WarehouseService
|
||||||
|
|
||||||
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardHeader>
|
||||||
|
<h3 class="text-primary">Packing List</h3>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;" Orientation="CardOrientation.Horizontal">
|
||||||
|
<CardContent>
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="ChangeView">Zmień widok</SfButton>
|
||||||
|
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="ExportXls">Generuj XLS i Wyślij</SfButton>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Adresy Email do Wysyłki raportu:</label>
|
||||||
|
<SfTextBox ID="textBox" Placeholder="Wprowadź adresy..." @bind-Value="@EmailAddresses"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Numer WZ:</label>
|
||||||
|
<SfTextBox ID="textBox" @bind-Value=@WzNumber CssClass="e-outline"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Wprowadź numer palety:</label>
|
||||||
|
<SfTextBox ID="palletNumber" Type="InputType.Number" @bind-Value="@PalletNumber"
|
||||||
|
CssClass="e-outline"/>
|
||||||
|
<label for="textBox" class="form-label">Zeskanowana wartość:</label>
|
||||||
|
<SfTextBox ID="scannedValue" ValueChange="ScanValue" @bind-Value="ScannedValue"
|
||||||
|
CssClass="e-outline" @ref="_scanner"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||||
|
<CardContent>
|
||||||
|
<label for="textBox" class="form-label">Numer Indeksu FA:</label>
|
||||||
|
<SfTextBox ID="itemNumber" @bind-Value="@ItemNumber"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
<label for="textBox" class="form-label">Ilość w Dostawie:</label>
|
||||||
|
<SfTextBox ID="qty" Type="InputType.Number" @bind-Value="@Qty"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
<label for="textBox" class="form-label">Numer Palety:</label>
|
||||||
|
<SfTextBox ID="palletNumberOutput" Type="InputType.Number" @bind-Value="@PalletNumberOutput"
|
||||||
|
CssClass="e-outline" Readonly="true"/>
|
||||||
|
</CardContent>
|
||||||
|
</SfCard>
|
||||||
|
</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 if (string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
<p>Błąd: Proszę wprowadzić przynajmniej jeden <b>ADRES EMAIL</b> do wysyłki raportu!</p>
|
||||||
|
}
|
||||||
|
else if (!_isValid)
|
||||||
|
{
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityPalletNumber"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<p>Błąd skanowania! <b>Wybierz NUMER PALETY większy niż 0</b> (Aktualnie '@PalletNumber'):</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>
|
||||||
|
</SfCard>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public Guid WzHeader { get; set; }
|
||||||
|
|
||||||
|
private List<WzRowMarelliDto> WzRowsMarelli { get; set; } = new();
|
||||||
|
private IDictionary<string, List<TransactionModel>> TransactionModelsByPartNumber { get; set; } = new Dictionary<string, List<TransactionModel>>();
|
||||||
|
private List<WzRowMarelliDto> ChangedRecords = new();
|
||||||
|
private WzHeaderDto _wzHeader;
|
||||||
|
private SfTextBox _scanner;
|
||||||
|
|
||||||
|
private string ItemNumber { get; set; } = string.Empty;
|
||||||
|
private string Qty { get; set; } = "0";
|
||||||
|
private string PalletNumberOutput { get; set; } = "0";
|
||||||
|
|
||||||
|
private string WzNumber { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private WzRowMarelliDto? SelectedRow { get; set; }
|
||||||
|
private List<WzRowMarelliDto> SelectedRows { get; set; } = new();
|
||||||
|
|
||||||
|
private bool _isValid;
|
||||||
|
|
||||||
|
public bool Visibility { get; set; }
|
||||||
|
public bool VisibilityPalletNumber { get; set; }
|
||||||
|
|
||||||
|
private string? EmailAddresses { get; set; } = string.Empty;
|
||||||
|
private string PalletNumber { get; set; } = "0";
|
||||||
|
|
||||||
|
private string LastScannedValue { get; set; } = string.Empty;
|
||||||
|
private string ScannedValue { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private void HideModal()
|
||||||
|
{
|
||||||
|
VisibilityPalletNumber = false;
|
||||||
|
Visibility = false;
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
|
WzRowsMarelli = (await WarehouseService.GetWzRowsMarelliByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
|
EmailAddresses = _wzHeader.EmailAddresses;
|
||||||
|
|
||||||
|
WzNumber = _wzHeader.WzNumbers ?? string.Empty;
|
||||||
|
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveChanges()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(EmailAddresses))
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChangedRecords.Any())
|
||||||
|
{
|
||||||
|
await UpdateRows(ChangedRecords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExportXls()
|
||||||
|
{
|
||||||
|
int count = WzRowsMarelli.Count(x => x.PalletNumber == null);
|
||||||
|
|
||||||
|
_isValid = count == 0;
|
||||||
|
_isValid = _isValid && !string.IsNullOrWhiteSpace(EmailAddresses);
|
||||||
|
|
||||||
|
if (_isValid)
|
||||||
|
{
|
||||||
|
await WarehouseService.AddEmailsToWzHeaderAsync(WzHeader, EmailAddresses);
|
||||||
|
await WarehouseService.GenerateXlsForMarelliAsync(WzHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
Visibility = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ScanValue(ChangedEventArgs obj)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
||||||
|
if (int.Parse(PalletNumber) <= 0)
|
||||||
|
{
|
||||||
|
VisibilityPalletNumber = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScannedValue = obj.Value.Trim();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
TransactionModelsByPartNumber.TryGetValue(obj.Value.Trim(), out List<TransactionModel>? materialTransactionsByPartNumber);
|
||||||
|
TransactionModel? materialTransactionByPartNumber = materialTransactionsByPartNumber?.FirstOrDefault();
|
||||||
|
|
||||||
|
if (materialTransactionByPartNumber != null)
|
||||||
|
{
|
||||||
|
FillPalletNumber(materialTransactionByPartNumber, obj.Value.Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
LastScannedValue = ScannedValue;
|
||||||
|
ScannedValue = string.Empty;
|
||||||
|
|
||||||
|
_scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task FillPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
||||||
|
{
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
int palletNumber = int.Parse(PalletNumber);
|
||||||
|
int rowIndex = WzRowsMarelli.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
||||||
|
|
||||||
|
switch (rowIndex)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
{
|
||||||
|
SelectedRows = WzRowsMarelli.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
||||||
|
|
||||||
|
var validCombinations = FindCombinations(SelectedRows, (int?)materialTransactionByPartNumber.Quantity ?? 0);
|
||||||
|
|
||||||
|
foreach (var combination in validCombinations)
|
||||||
|
{
|
||||||
|
foreach (var record in combination)
|
||||||
|
{
|
||||||
|
record.PalletNumber = palletNumber;
|
||||||
|
ChangedRecords.Add(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedRows.Clear();
|
||||||
|
SelectedRows.AddRange(ChangedRecords);
|
||||||
|
|
||||||
|
SelectedRow = SelectedRows.FirstOrDefault();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
SelectedRow = WzRowsMarelli[rowIndex];
|
||||||
|
|
||||||
|
SelectedRow.PalletNumber = palletNumber;
|
||||||
|
|
||||||
|
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
||||||
|
{
|
||||||
|
ChangedRecords.Add(SelectedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await SaveChanges();
|
||||||
|
ChangedRecords.Clear();
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
await _scanner.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IDictionary<string, List<TransactionModel>>> GetTransactionModels()
|
||||||
|
{
|
||||||
|
return await WarehouseService.GetTransactionsModels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateRows(IList<WzRowMarelliDto> changedRecords)
|
||||||
|
{
|
||||||
|
await WarehouseService.UpdateWzRowsMarelliAsync(changedRecords);
|
||||||
|
|
||||||
|
WzRowsMarelli = (await WarehouseService.GetWzRowsMarelliByWzHeaderId(WzHeader)).ToList();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<List<WzRowMarelliDto>> FindCombinations(List<WzRowMarelliDto> records, int targetSum)
|
||||||
|
{
|
||||||
|
var result = new List<List<WzRowMarelliDto>>();
|
||||||
|
var currentCombination = new List<WzRowMarelliDto>();
|
||||||
|
|
||||||
|
void Backtrack(int start, int currentSum)
|
||||||
|
{
|
||||||
|
if (currentSum == targetSum)
|
||||||
|
{
|
||||||
|
result.Add(new List<WzRowMarelliDto>(currentCombination));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < records.Count; i++)
|
||||||
|
{
|
||||||
|
if (currentSum + records[i].Quantity <= targetSum)
|
||||||
|
{
|
||||||
|
currentCombination.Add(records[i]);
|
||||||
|
Backtrack(i + 1, currentSum + records[i].Quantity ?? 0);
|
||||||
|
currentCombination.RemoveAt(currentCombination.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Backtrack(0, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeView()
|
||||||
|
{
|
||||||
|
NavigationManager.NavigateTo($"/Warehouse/Marelli/PackList/{WzHeader}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
WzRowsMeyle = (await WarehouseService.GetWzRowsByWzHeaderId(WzHeader)).ToList();
|
WzRowsMeyle = (await WarehouseService.GetWzRowsMeyleByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
TransactionModelsByPartNumber = await GetTransactionModels();
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@
|
|||||||
{
|
{
|
||||||
await WarehouseService.UpdateWzRowsMeyleAsync(changedRecords);
|
await WarehouseService.UpdateWzRowsMeyleAsync(changedRecords);
|
||||||
|
|
||||||
WzRowsMeyle = (await WarehouseService.GetWzRowsByWzHeaderId(WzHeader)).ToList();
|
WzRowsMeyle = (await WarehouseService.GetWzRowsMeyleByWzHeaderId(WzHeader)).ToList();
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
await _grid.Refresh();
|
await _grid.Refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@
|
|||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
_wzHeader = await WarehouseService.GetWzHeaderByIdAsync(WzHeader);
|
||||||
WzRowsMeyle = (await WarehouseService.GetWzRowsByWzHeaderId(WzHeader)).ToList();
|
WzRowsMeyle = (await WarehouseService.GetWzRowsMeyleByWzHeaderId(WzHeader)).ToList();
|
||||||
|
|
||||||
TransactionModelsByPartNumber = await GetTransactionModels();
|
TransactionModelsByPartNumber = await GetTransactionModels();
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@
|
|||||||
{
|
{
|
||||||
await WarehouseService.UpdateWzRowsMeyleAsync(changedRecords);
|
await WarehouseService.UpdateWzRowsMeyleAsync(changedRecords);
|
||||||
|
|
||||||
WzRowsMeyle = (await WarehouseService.GetWzRowsByWzHeaderId(WzHeader)).ToList();
|
WzRowsMeyle = (await WarehouseService.GetWzRowsMeyleByWzHeaderId(WzHeader)).ToList();
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,6 +419,6 @@
|
|||||||
|
|
||||||
private void ChangeView()
|
private void ChangeView()
|
||||||
{
|
{
|
||||||
NavigationManager.NavigateTo($"/Warehouse/PackList/{WzHeader}");
|
NavigationManager.NavigateTo($"/Warehouse/Meyle/PackList/{WzHeader}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@
|
|||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
_clients = await WarehouseService.GetAllClientsAsync();
|
_clients = await WarehouseService.GetAllClientsAsync();
|
||||||
_clients = _clients.Where(x => x.Name.Equals("MEYLE", StringComparison.OrdinalIgnoreCase));
|
_clients = _clients.Where(x => new[] { "MAGNETI MARELLI", "MEYLE" }.Any(y => y.Equals(x.Name, StringComparison.OrdinalIgnoreCase))).ToList();
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
|
|
||||||
Guid headerId = obj.RowData.ID;
|
Guid headerId = obj.RowData.ID;
|
||||||
|
|
||||||
NavigationManager.NavigateTo($"/Warehouse/{_selectedClient.Name}/PackList/" + headerId);
|
NavigationManager.NavigateTo($"/Warehouse/{_selectedClient.ShortName}/PackList/" + headerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CreatePackingList()
|
private async Task CreatePackingList()
|
||||||
@@ -210,18 +210,18 @@
|
|||||||
|
|
||||||
await WarehouseService.CreateWzHeaderAsync(wzHeader);
|
await WarehouseService.CreateWzHeaderAsync(wzHeader);
|
||||||
|
|
||||||
switch (_selectedClient?.Name.ToUpper())
|
switch (_selectedClient?.ShortName.ToUpper())
|
||||||
{
|
{
|
||||||
case "MEYLE":
|
case "MEYLE":
|
||||||
IList<WzRowMeyleDto> rows = new List<WzRowMeyleDto>();
|
IList<WzRowMeyleDto> meyleRows = new List<WzRowMeyleDto>();
|
||||||
IList<MaterialTransactionDto> materialTransactions = _materialTransactions.Where(x => selectedRecords.Any(y => y.MTGroupNum == x.MTGroupNum)).ToList();
|
IList<MaterialTransactionDto> meyleMaterialTransactions = _materialTransactions.Where(x => selectedRecords.Any(y => y.MTGroupNum == x.MTGroupNum)).ToList();
|
||||||
|
|
||||||
foreach (MaterialTransactionDto materialTransactionDto in materialTransactions)
|
foreach (MaterialTransactionDto materialTransactionDto in meyleMaterialTransactions)
|
||||||
{
|
{
|
||||||
CustomerOrderDto customerOrder = await WarehouseService.GetCustomerOrder(materialTransactionDto.RefNum ?? string.Empty);
|
CustomerOrderDto customerOrder = await WarehouseService.GetCustomerOrder(materialTransactionDto.RefNum ?? string.Empty);
|
||||||
ItemCustDto item = await WarehouseService.GetItem(materialTransactionDto.Item ?? string.Empty, customerOrder.CustNum);
|
ItemCustDto item = await WarehouseService.GetItem(materialTransactionDto.Item ?? string.Empty, customerOrder.CustNum);
|
||||||
|
|
||||||
rows.Add(new WzRowMeyleDto
|
meyleRows.Add(new WzRowMeyleDto
|
||||||
{
|
{
|
||||||
ID = Guid.NewGuid(),
|
ID = Guid.NewGuid(),
|
||||||
Quantity = Math.Abs((int?)materialTransactionDto.Qty ?? 0),
|
Quantity = Math.Abs((int?)materialTransactionDto.Qty ?? 0),
|
||||||
@@ -235,10 +235,39 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await WarehouseService.CreateWzRowsMeyleAsync(rows);
|
await WarehouseService.CreateWzRowsMeyleAsync(meyleRows);
|
||||||
|
|
||||||
NavigationManager.NavigateTo("/Warehouse/Meyle/PackList/" + wzHeader.ID);
|
NavigationManager.NavigateTo("/Warehouse/Meyle/PackList/" + wzHeader.ID);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "MARELLI":
|
||||||
|
IList<WzRowMarelliDto> marelliRows = new List<WzRowMarelliDto>();
|
||||||
|
IList<MaterialTransactionDto> marelliMaterialTransactions = _materialTransactions.Where(x => selectedRecords.Any(y => y.MTGroupNum == x.MTGroupNum)).ToList();
|
||||||
|
|
||||||
|
foreach (MaterialTransactionDto materialTransactionDto in marelliMaterialTransactions)
|
||||||
|
{
|
||||||
|
CustomerOrderDto customerOrder = await WarehouseService.GetCustomerOrder(materialTransactionDto.RefNum ?? string.Empty);
|
||||||
|
ItemCustDto item = await WarehouseService.GetItem(materialTransactionDto.Item ?? string.Empty, customerOrder.CustNum);
|
||||||
|
|
||||||
|
marelliRows.Add(new WzRowMarelliDto
|
||||||
|
{
|
||||||
|
ID = Guid.NewGuid(),
|
||||||
|
Quantity = Math.Abs((int?)materialTransactionDto.Qty ?? 0),
|
||||||
|
ItemNumber = item.CustItem,
|
||||||
|
OrderNumber = customerOrder.CustPo,
|
||||||
|
WzNumber = materialTransactionDto.MTGroupNum ?? string.Empty,
|
||||||
|
FKHeader = wzHeader.ID,
|
||||||
|
TransactionNumber = (int?)materialTransactionDto.TransNum ?? 0,
|
||||||
|
Type = "MIX",
|
||||||
|
FaIndex = item.Item,
|
||||||
|
EngineerNumber = item.Uf_FKR_CustItem2
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await WarehouseService.CreateWzRowsMarelliAsync(marelliRows);
|
||||||
|
|
||||||
|
NavigationManager.NavigateTo("/Warehouse/Marelli/PackList/" + wzHeader.ID);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,20 +63,34 @@ public class WarehouseService(IHttpClientFactory httpClientFactory)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CreateWzRowsMeyleAsync(IEnumerable<WzRowMeyleDto> wzRowMeyles)
|
public async Task CreateWzRowsMeyleAsync(IEnumerable<WzRowMeyleDto> wzRowsMeyle)
|
||||||
{
|
{
|
||||||
if (wzRowMeyles == null || !wzRowMeyles.Any())
|
if (wzRowsMeyle == null || !wzRowsMeyle.Any())
|
||||||
{
|
{
|
||||||
throw new ArgumentException("No rows provided to create.");
|
throw new ArgumentException("No rows provided to create.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = await _httpClient.PostAsJsonAsync("api/WzRowMeyle", wzRowMeyles);
|
var response = await _httpClient.PostAsJsonAsync("api/WzRowMeyle", wzRowsMeyle);
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var errorContent = await response.Content.ReadAsStringAsync();
|
var errorContent = await response.Content.ReadAsStringAsync();
|
||||||
throw new HttpRequestException($"Failed to create WzRowMeyle: {response.StatusCode}, Content: {errorContent}");
|
throw new HttpRequestException($"Failed to create WzRowMeyle: {response.StatusCode}, Content: {errorContent}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateWzRowsMarelliAsync(IEnumerable<WzRowMarelliDto> wzRowsMarelli)
|
||||||
|
{
|
||||||
|
if (wzRowsMarelli == null || !wzRowsMarelli.Any())
|
||||||
|
{
|
||||||
|
throw new ArgumentException("No rows provided to create.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = await _httpClient.PostAsJsonAsync("api/WzRowMarelli", wzRowsMarelli);
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var errorContent = await response.Content.ReadAsStringAsync();
|
||||||
|
throw new HttpRequestException($"Failed to create WzRowMarelli: {response.StatusCode}, Content: {errorContent}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CustomerOrderDto> GetCustomerOrder(string customerOrderNumber)
|
public async Task<CustomerOrderDto> GetCustomerOrder(string customerOrderNumber)
|
||||||
@@ -95,13 +109,20 @@ public class WarehouseService(IHttpClientFactory httpClientFactory)
|
|||||||
return await response.Content.ReadFromJsonAsync<ItemCustDto>();
|
return await response.Content.ReadFromJsonAsync<ItemCustDto>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<WzRowMeyleDto>> GetWzRowsByWzHeaderId(Guid wzHeaderId)
|
public async Task<IEnumerable<WzRowMeyleDto>> GetWzRowsMeyleByWzHeaderId(Guid wzHeaderId)
|
||||||
{
|
{
|
||||||
var response = await _httpClient.GetAsync($"api/WzRowMeyle/by-wz-header-id?wzHeaderId={wzHeaderId}");
|
var response = await _httpClient.GetAsync($"api/WzRowMeyle/by-wz-header-id?wzHeaderId={wzHeaderId}");
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
return await response.Content.ReadFromJsonAsync<IEnumerable<WzRowMeyleDto>>();
|
return await response.Content.ReadFromJsonAsync<IEnumerable<WzRowMeyleDto>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<WzRowMarelliDto>> GetWzRowsMarelliByWzHeaderId(Guid wzHeaderId)
|
||||||
|
{
|
||||||
|
var response = await _httpClient.GetAsync($"api/WzRowMarelli/by-wz-header-id?wzHeaderId={wzHeaderId}");
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
return await response.Content.ReadFromJsonAsync<IEnumerable<WzRowMarelliDto>>();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IDictionary<string, List<TransactionModel>>> GetTransactionsModels()
|
public async Task<IDictionary<string, List<TransactionModel>>> GetTransactionsModels()
|
||||||
{
|
{
|
||||||
var response = await _httpClient.GetAsync($"api/WzRowMeyle/transactions-with-part-number");
|
var response = await _httpClient.GetAsync($"api/WzRowMeyle/transactions-with-part-number");
|
||||||
@@ -124,6 +145,17 @@ public class WarehouseService(IHttpClientFactory httpClientFactory)
|
|||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateWzRowsMarelliAsync(IEnumerable<WzRowMarelliDto?> wzRowsMarelli)
|
||||||
|
{
|
||||||
|
if (wzRowsMarelli == null || !wzRowsMarelli.Any())
|
||||||
|
{
|
||||||
|
throw new ArgumentException("No rows provided to update.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = await _httpClient.PutAsJsonAsync("api/WzRowMarelli", wzRowsMarelli);
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task GenerateXlsForMeyleAsync(Guid wzHeaderId)
|
public async Task GenerateXlsForMeyleAsync(Guid wzHeaderId)
|
||||||
{
|
{
|
||||||
var response = await _httpClient.GetAsync($"api/ExcelGenerator/generate-meyle?packListId={wzHeaderId}");
|
var response = await _httpClient.GetAsync($"api/ExcelGenerator/generate-meyle?packListId={wzHeaderId}");
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ public class WzClientDto
|
|||||||
public int? CustomerSequence { get; set; }
|
public int? CustomerSequence { get; set; }
|
||||||
public DateTime CreatedDate { get; set; }
|
public DateTime CreatedDate { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public string ShortName { get; set; }
|
||||||
}
|
}
|
||||||
@@ -7,4 +7,5 @@ public class WzClient
|
|||||||
public int? CustomerSequence { get; set; }
|
public int? CustomerSequence { get; set; }
|
||||||
public DateTime CreatedDate { get; set; }
|
public DateTime CreatedDate { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public string ShortName { get; set; }
|
||||||
}
|
}
|
||||||
@@ -954,6 +954,11 @@ namespace SytelineSaAppEfDataModel
|
|||||||
.HasColumnName("Name")
|
.HasColumnName("Name")
|
||||||
.HasMaxLength(255)
|
.HasMaxLength(255)
|
||||||
.IsRequired(false);
|
.IsRequired(false);
|
||||||
|
|
||||||
|
entity.Property(e => e.ShortName)
|
||||||
|
.HasColumnName("ShortName")
|
||||||
|
.HasMaxLength(30)
|
||||||
|
.IsRequired(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<WzRowMeyle>(entity =>
|
modelBuilder.Entity<WzRowMeyle>(entity =>
|
||||||
@@ -2559,7 +2564,7 @@ namespace SytelineSaAppEfDataModel
|
|||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.IsRequired(false);
|
.IsRequired(false);
|
||||||
|
|
||||||
entity.Property(e => e.WzNumber)
|
entity.Property(e => e.FaIndex)
|
||||||
.HasColumnName("fa_index")
|
.HasColumnName("fa_index")
|
||||||
.HasMaxLength(30)
|
.HasMaxLength(30)
|
||||||
.IsRequired(false);
|
.IsRequired(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user