ancora update gestione prodAssign
This commit is contained in:
@@ -21,49 +21,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
{
|
||||
// manca costruttore parametrico contoller...
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue assegnazione bulk dei ProdItem ad un unico ProdAssign parent
|
||||
/// </summary>
|
||||
/// <param name="ProdAssignId"></param>
|
||||
/// <param name="itemsToAssign"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> ProdItemBulkAssignItems(int ProdAssignId, Dictionary<string, double> itemsToAssign)
|
||||
{
|
||||
int totalUpdated = 0;
|
||||
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
|
||||
using (DataLayerContext dbCtx = new DataLayerContext())
|
||||
{
|
||||
using var transaction = await dbCtx.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
foreach (var entry in itemsToAssign)
|
||||
{
|
||||
// Esegue un UPDATE diretto: UPDATE production_item SET ProdAssignID = x, EstimTime = y WHERE ProdLabel = z
|
||||
int rowsAffected = await dbCtx.DbSetProdItem
|
||||
.Where(p => p.ProdLabel == entry.Key)
|
||||
.ExecuteUpdateAsync(setters => setters
|
||||
.SetProperty(p => p.ProdAssignID, ProdAssignId)
|
||||
.SetProperty(p => p.EstimTime, entry.Value)
|
||||
);
|
||||
|
||||
totalUpdated += rowsAffected;
|
||||
}
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
await transaction.RollbackAsync();
|
||||
Log.Error($"Eccezione durante ProdItemBulkAssignItems{Environment.NewLine}{exc}");
|
||||
//throw;
|
||||
}
|
||||
}
|
||||
return totalUpdated;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal async Task<List<EnvirParamModel>> ConfEnvirParamGetAllAsync()
|
||||
@@ -3339,6 +3296,46 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
return removed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue assegnazione bulk dei ProdItem ad un unico ProdAssign parent
|
||||
/// </summary>
|
||||
/// <param name="OrderRowId"></param>
|
||||
/// <param name="ProdAssignId"></param>
|
||||
/// <param name="itemsToAssign"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task<int> ProdItemBulkAssignItems(int OrderRowId, int ProdAssignId, Dictionary<string, double> itemsToAssign)
|
||||
{
|
||||
int totalUpdated = 0;
|
||||
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
|
||||
using (DataLayerContext dbCtx = new DataLayerContext())
|
||||
{
|
||||
using var transaction = await dbCtx.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
foreach (var entry in itemsToAssign)
|
||||
{
|
||||
// Esegue un UPDATE diretto: UPDATE production_item SET ProdAssignID = x, EstimTime = y WHERE ProdLabel = z
|
||||
int rowsAffected = await dbCtx.DbSetProdItem
|
||||
.Where(p => p.OrderRowID == OrderRowId && p.ProdLabel == entry.Key)
|
||||
.ExecuteUpdateAsync(setters => setters
|
||||
.SetProperty(p => p.ProdAssignID, ProdAssignId)
|
||||
.SetProperty(p => p.EstimTime, entry.Value)
|
||||
);
|
||||
|
||||
totalUpdated += rowsAffected;
|
||||
}
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
await transaction.RollbackAsync();
|
||||
Log.Error($"Eccezione durante ProdItemBulkAssignItems{Environment.NewLine}{exc}");
|
||||
//throw;
|
||||
}
|
||||
}
|
||||
return totalUpdated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ProdItem dato OrderRow
|
||||
/// </summary>
|
||||
|
||||
@@ -1637,6 +1637,21 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<int> ProdItemBulkAssignItems(int OrderRowId, int ProdAssignId, Dictionary<string, double> itemsToAssign)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// calcolo
|
||||
int fatto = await dbController.ProdItemBulkAssignItems(OrderRowId, ProdAssignId, itemsToAssign);
|
||||
// svuoto cache...
|
||||
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdItems:*");
|
||||
sw.Stop();
|
||||
Log.Debug($"ProdItemBulkAssignItems in {sw.Elapsed.TotalMilliseconds} ms");
|
||||
return fatto;
|
||||
}
|
||||
|
||||
|
||||
/// Esegue Delete del record ricevuto
|
||||
/// </summary>
|
||||
/// <param name="upsRec"></param>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>0.9.2512.2411</Version>
|
||||
<Version>0.9.2512.2412</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="col-9">Non producibili: <span class="fw-bold px-1">@DetailRecord.NumKo</span></div>
|
||||
<div class="col-3">
|
||||
<button class="btn btn-sm btn-danger w-100">Send EXT <i class="fa-solid fa-triangle-exclamation"></i></button>
|
||||
<button class="btn btn-sm btn-danger w-100" @onclick="SendUnworkExt">Send EXT <i class="fa-solid fa-triangle-exclamation"></i></button>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using EgwCoreLib.Lux.Core.Generic;
|
||||
using EgwCoreLib.Lux.Core.RestPayload;
|
||||
using EgwCoreLib.Lux.Data.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NLog.Targets.Wrappers;
|
||||
|
||||
@@ -9,6 +10,9 @@ namespace Lux.UI.Components.Compo.WorkLoad
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int OrderRowId { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public WorkLoadDetailDTO DetailRecord { get; set; } = null!;
|
||||
|
||||
@@ -24,6 +28,8 @@ namespace Lux.UI.Components.Compo.WorkLoad
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Fields
|
||||
[Inject]
|
||||
protected DataLayerServices DLService { get; set; } = null!;
|
||||
|
||||
protected BalanceReqDto cBalanceReq = new BalanceReqDto();
|
||||
|
||||
@@ -104,7 +110,30 @@ namespace Lux.UI.Components.Compo.WorkLoad
|
||||
/// <returns></returns>
|
||||
protected async Task SendUnworkExt()
|
||||
{
|
||||
//
|
||||
// recupero ProdAssignId x EXT... da elenco record mostrati...
|
||||
int ProdAssignId = 0;
|
||||
if (OrderRowId > 0 && ProdAssignId > 0)
|
||||
{
|
||||
// recupero elenco e converto in Dict
|
||||
var dictUnwokr = DetailRecord
|
||||
.ListUnWorkable
|
||||
.ToDictionary(x => x, x => 0.0);
|
||||
|
||||
// chiamo update!
|
||||
await DLService.ProdItemBulkAssignItems(OrderRowId, ProdAssignId, dictUnwokr);
|
||||
|
||||
}
|
||||
// rileggo!
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rilettura dati da DB associazioni
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
|
||||
<Version>0.9.2512.2318</Version>
|
||||
<Version>0.9.2512.2412</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>LUX - Web Windows MES</i>
|
||||
<h4>Versione: 0.9.2512.2411</h4>
|
||||
<h4>Versione: 0.9.2512.2412</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
0.9.2512.2411
|
||||
0.9.2512.2412
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>0.9.2512.2411</version>
|
||||
<version>0.9.2512.2412</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user