diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
index 59fa95d0..d91a7b29 100644
--- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
+++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
@@ -515,6 +515,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
return answ;
}
+#if true
///
/// Assegnazione in blocco degli item agli ODL corrispondenti
///
@@ -708,35 +709,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
return answ;
}
-
- ///
- /// Elenco PODL non assegnati
- ///
- ///
- internal async Task?> ProductionOdlUnassignAsync()
- {
- List? dbRestults = null;
- //using (DataLayerContext dbCtx = new DataLayerContext(_config))
- using (DataLayerContext dbCtx = new DataLayerContext())
- {
- try
- {
- dbRestults = await dbCtx
- .DbSetProdODL
- .Where(x => !x.DateAssign.HasValue)
- .Include(x => x.Item2OdlNav)
- //.ThenInclude(i => i.ProductionItemNav)
- //.ThenInclude(o => o.OrderRowNav)
- //.ThenInclude(o => o.OrderNav)
- .ToListAsync();
- }
- catch (Exception exc)
- {
- Log.Error($"Eccezione durante ProductionOdlUnassignAsync{Environment.NewLine}{exc}");
- }
- }
- return dbRestults;
- }
+#endif
///
/// Esegue merge dei dati nella tab profili del DB con le info accessorie...
diff --git a/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj b/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj
index de103521..fed9128f 100644
--- a/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj
+++ b/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj
@@ -48,7 +48,6 @@
-
diff --git a/EgwCoreLib.Lux.Data/Repository/Production/IProductionOdlRepository.cs b/EgwCoreLib.Lux.Data/Repository/Production/IProductionOdlRepository.cs
index ba18e3c6..3e075f09 100644
--- a/EgwCoreLib.Lux.Data/Repository/Production/IProductionOdlRepository.cs
+++ b/EgwCoreLib.Lux.Data/Repository/Production/IProductionOdlRepository.cs
@@ -7,6 +7,13 @@ namespace EgwCoreLib.Lux.Data.Repository.Production
{
#region Public Methods
+ ///
+ /// Metodo aggiunta record
+ ///
+ ///
+ ///
+ Task AddAsync(ProductionODLModel entity);
+
///
/// Insert sul DB di un elenco ODL con calcolo della relativa KEY a cui poter, successivamente, collegare i record child (items)
///
@@ -22,11 +29,24 @@ namespace EgwCoreLib.Lux.Data.Repository.Production
///
Task GetByUidAsync(string uID);
+ ///
+ /// Elenco PODL non assegnati
+ ///
+ ///
+ Task> GetUnassignAsync();
+
///
/// Elenco PODL non assegnati con struttura DTO appiattita
///
///
- Task> GetUnassignAsync();
+ Task> GetUnassignOdlDtoAsync();
+
+ ///
+ /// Update generico record
+ ///
+ ///
+ ///
+ Task UpdateAsync(ProductionODLModel entity);
#endregion Public Methods
}
diff --git a/EgwCoreLib.Lux.Data/Repository/Production/ProductionOdlRepository.cs b/EgwCoreLib.Lux.Data/Repository/Production/ProductionOdlRepository.cs
index 56ebd5d9..4b4ffe76 100644
--- a/EgwCoreLib.Lux.Data/Repository/Production/ProductionOdlRepository.cs
+++ b/EgwCoreLib.Lux.Data/Repository/Production/ProductionOdlRepository.cs
@@ -17,6 +17,12 @@ namespace EgwCoreLib.Lux.Data.Repository.Production
#region Public Methods
+ public async Task AddAsync(ProductionODLModel entity)
+ {
+ await using var dbCtx = await CreateContextAsync();
+ await dbCtx.DbSetProdODL.AddAsync(entity);
+ return await dbCtx.SaveChangesAsync() > 0;
+ }
///
/// Insert sul DB di un elenco ODL con calcolo della relativa KEY a cui poter, successivamente, collegare i record child (items)
@@ -75,13 +81,26 @@ namespace EgwCoreLib.Lux.Data.Repository.Production
.FirstOrDefaultAsync(x => x.OdlTag == uID);
}
+ ///
+ /// Elenco PODL non assegnati
+ ///
+ ///
+ public async Task> GetUnassignAsync()
+ {
+ await using var dbCtx = await CreateContextAsync();
+ return await dbCtx.DbSetProdODL
+ .Where(x => !x.DateAssign.HasValue)
+ .AsNoTracking()
+ .Include(x => x.Item2OdlNav)
+ .ToListAsync();
+ }
+
///
/// Elenco PODL non assegnati con struttura DTO appiattita
///
///
- public async Task> GetUnassignAsync()
+ public async Task> GetUnassignOdlDtoAsync()
{
-
await using var dbCtx = await CreateContextAsync();
return await dbCtx.DbSetProdODL
.Where(x => !x.DateAssign.HasValue)
@@ -112,6 +131,27 @@ namespace EgwCoreLib.Lux.Data.Repository.Production
.ToListAsync();
}
+ ///
+ /// Update generico record
+ ///
+ ///
+ ///
+ public async Task UpdateAsync(ProductionODLModel entity)
+ {
+ await using var dbCtx = await CreateContextAsync();
+ var trackedEntity = dbCtx.DbSetProdODL.Local.FirstOrDefault(x => x.ProdODLID == entity.ProdODLID);
+
+ if (trackedEntity != null)
+ {
+ dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity);
+ }
+ else
+ {
+ dbCtx.DbSetProdODL.Update(entity);
+ }
+ return await dbCtx.SaveChangesAsync() > 0;
+ }
+
#endregion Public Methods
}
-}
+}
\ No newline at end of file
diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
index ae2e1de4..7783bf56 100644
--- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
+++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
@@ -250,6 +250,7 @@ namespace EgwCoreLib.Lux.Data.Services
return result;
}
+#if true
///
/// Assegnazione in blocco degli item agli ODL corrispondenti
///
@@ -289,6 +290,7 @@ namespace EgwCoreLib.Lux.Data.Services
LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
+#endif
///
/// Esegue salvataggio BOM sul DB
diff --git a/EgwCoreLib.Lux.Data/Services/Production/IProductionOdlService.cs b/EgwCoreLib.Lux.Data/Services/Production/IProductionOdlService.cs
index cfaa11f7..1cfeed55 100644
--- a/EgwCoreLib.Lux.Data/Services/Production/IProductionOdlService.cs
+++ b/EgwCoreLib.Lux.Data/Services/Production/IProductionOdlService.cs
@@ -26,7 +26,38 @@ namespace EgwCoreLib.Lux.Data.Services.Production
/// Elenco PODL non assegnati con struttura DTO appiattita
///
///
- Task> GetUnassignAsync();
+ Task> GetUnassignOdlDtoAsync();
+
+ ///
+ /// Aggiorna record ProdOdl (se trovato) con BOM (raw) ricevuta
+ ///
+ ///
+ ///
+ ///
+ Task UpdateBomAsync(string uID, string bomRaw);
+
+ ///
+ /// Aggiorna record ProdOdl (se trovato) con ItemListRaw (raw) inviata x calcolo PROD
+ ///
+ ///
+ ///
+ ///
+ Task UpdateItemRawAsync(string uID, string itemListRaw);
+
+ ///
+ /// Aggiorna record ProdOdl (se trovato) con RawMaterialList (raw) ricevuta da calcolo PROD
+ ///
+ ///
+ ///
+ ///
+ Task UpdateRawMaterialAsync(string uID, string materialListRaw);
+
+ ///
+ /// Upsert intero record
+ ///
+ ///
+ ///
+ Task UpsertAsync(ProductionODLModel upsRec);
#endregion Public Methods
}
diff --git a/EgwCoreLib.Lux.Data/Services/Production/ProductionOdlService.cs b/EgwCoreLib.Lux.Data/Services/Production/ProductionOdlService.cs
index 78498b09..111a4ae1 100644
--- a/EgwCoreLib.Lux.Data/Services/Production/ProductionOdlService.cs
+++ b/EgwCoreLib.Lux.Data/Services/Production/ProductionOdlService.cs
@@ -62,18 +62,137 @@ namespace EgwCoreLib.Lux.Data.Services.Production
/// Elenco PODL non assegnati con struttura DTO appiattita
///
///
- public async Task> GetUnassignAsync()
+ public async Task> GetUnassignOdlDtoAsync()
{
return await TraceAsync($"{_className}.GetUnassign", async (activity) =>
{
return await GetOrSetCacheAsync(
$"{_redisBaseKey}:{_className}:unassign",
- async () => await _repo.GetUnassignAsync(),
+ async () => await _repo.GetUnassignOdlDtoAsync(),
UltraFastCache
);
});
}
+ ///
+ /// Aggiorna record ProdOdl (se trovato) con BOM (raw) ricevuta
+ ///
+ ///
+ ///
+ ///
+ public async Task UpdateBomAsync(string uID, string bomRaw)
+ {
+ return await TraceAsync($"{_className}.UpdateBom", async (activity) =>
+ {
+ var currRec = await _repo.GetByUidAsync(uID);
+
+ if (currRec == null)
+ return false;
+
+ currRec.RawBoM = bomRaw;
+ activity?.SetTag("db.operation", "UpdateBom");
+ bool success = await _repo.UpdateAsync(currRec);
+
+ if (success)
+ {
+ await ClearCacheAsync($"{_redisBaseKey}:{_className}:*");
+ }
+
+ return success;
+ });
+ }
+
+ ///
+ /// Aggiorna record ProdOdl (se trovato) con ItemListRaw (raw) inviata x calcolo PROD
+ ///
+ ///
+ ///
+ ///
+ public async Task UpdateItemRawAsync(string uID, string itemListRaw)
+ {
+ return await TraceAsync($"{_className}.UpdateItemRaw", async (activity) =>
+ {
+ var currRec = await _repo.GetByUidAsync(uID);
+
+ if (currRec == null)
+ return false;
+
+ currRec.RawItemRawList = itemListRaw;
+ activity?.SetTag("db.operation", "UpdateItemRaw");
+ bool success = await _repo.UpdateAsync(currRec);
+
+ if (success)
+ {
+ await ClearCacheAsync($"{_redisBaseKey}:{_className}:*");
+ }
+
+ return success;
+ });
+ }
+
+ ///
+ /// Aggiorna record ProdOdl (se trovato) con RawMaterialList (raw) ricevuta da calcolo PROD
+ ///
+ ///
+ ///
+ ///
+ public async Task UpdateRawMaterialAsync(string uID, string materialListRaw)
+ {
+ return await TraceAsync($"{_className}.UpdateRawMaterial", async (activity) =>
+ {
+ var currRec = await _repo.GetByUidAsync(uID);
+
+ if (currRec == null)
+ return false;
+
+ currRec.RawMaterials = materialListRaw;
+ activity?.SetTag("db.operation", "UpdateRawMaterial");
+ bool success = await _repo.UpdateAsync(currRec);
+
+ if (success)
+ {
+ await ClearCacheAsync($"{_redisBaseKey}:{_className}:*");
+ }
+
+ return success;
+ });
+ }
+
+ ///
+ /// Aggiorna record ProdOdl (se trovato) con BOM (raw) ricevuta
+ ///
+ ///
+ ///
+ ///
+ public async Task UpsertAsync(ProductionODLModel upsRec)
+ {
+ return await TraceAsync($"{_className}.Upsert", async (activity) =>
+ {
+ var currRec = await _repo.GetByUidAsync(upsRec.OdlTag);
+
+ string operation = "UPDATE";
+ bool success = false;
+ if (currRec != null)
+ {
+ success = await _repo.UpdateAsync(upsRec);
+ }
+ else
+ {
+ operation = "INSERT";
+ success = await _repo.AddAsync(upsRec);
+ }
+
+ activity?.SetTag("db.operation", operation);
+
+ if (success)
+ {
+ await ClearCacheAsync($"{_redisBaseKey}:{_className}");
+ }
+
+ return success;
+ });
+ }
+
#endregion Public Methods
#region Private Fields