update x salvataggio ritorno BOM in stima ODL
This commit is contained in:
@@ -3844,6 +3844,90 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
return numItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco PODL non assegnati con struttura DTO appiattita
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal async Task<List<OdlAssignDto>?> ProdOdlAssignGetAsync()
|
||||
{
|
||||
List<OdlAssignDto>? dbResults = null;
|
||||
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
|
||||
using (DataLayerContext dbCtx = new DataLayerContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResults = await dbCtx.DbSetProdODL
|
||||
.Where(x => !x.DateAssign.HasValue)
|
||||
.Select(odl => new OdlAssignDto
|
||||
{
|
||||
Envir = odl.ProdBatchNav.Envir,
|
||||
ProdODLID = odl.ProdODLID,
|
||||
Description = odl.Description,
|
||||
EstimTime = odl.EstimTime,
|
||||
Index = odl.Index,
|
||||
OdlTag = odl.OdlTag,
|
||||
PhaseID = odl.PhaseID,
|
||||
ProdBatchID = odl.ProdBatchID,
|
||||
ProdPlantCod = odl.ProdPlantCod,
|
||||
Qty = odl.Qty,
|
||||
ResourceID = odl.ResourceID,
|
||||
ItemList = odl.Item2OdlNav.Select(i => new ItemAssignDto
|
||||
{
|
||||
ProdItemID = i.ProdItemID,
|
||||
OrderID = i.ProductionItemNav.OrderRowNav.OrderNav.OrderID,
|
||||
OrderRowID = i.ProductionItemNav.OrderRowNav.OrderRowID,
|
||||
OrderTag = i.ProductionItemNav.OrderRowNav.OrderNav.OrderCode,
|
||||
OrderRowTag = i.ProductionItemNav.OrderRowNav.OrderRowCode,
|
||||
ProdItemTag = i.ProductionItemNav.ProdItemTag ?? "***"
|
||||
}).ToList()
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante ProductionOdlUnassignAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResults;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna record ProdOdl (se trovato) con BOM (raw) ricevuta
|
||||
/// </summary>
|
||||
/// <param name="uID"></param>
|
||||
/// <param name="bomRaw"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task<bool> ProdOdlUpdateBomAsync(string uID, string bomRaw)
|
||||
{
|
||||
bool answ = false;
|
||||
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
|
||||
using (DataLayerContext dbCtx = new DataLayerContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = dbCtx
|
||||
.DbSetProdODL
|
||||
.Where(x => x.OdlTag == uID)
|
||||
.FirstOrDefault();
|
||||
// se trovato --> salvo BOM e calcolo costi
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.RawBoM = bomRaw;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
|
||||
// salvo...
|
||||
var result = dbCtx.SaveChanges();
|
||||
answ = result > 0;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante ProdOdlUpdateBomAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
internal async Task<List<ProductionPlantModel>> ProdPlantGetAllAsync()
|
||||
{
|
||||
List<ProductionPlantModel> dbResult = new List<ProductionPlantModel>();
|
||||
@@ -3976,53 +4060,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
return dbRestults;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco PODL non assegnati con struttura DTO appiattita
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal async Task<List<OdlAssignDto>?> ProdOdlAssignGetAsync()
|
||||
{
|
||||
List<OdlAssignDto>? dbResults = null;
|
||||
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
|
||||
using (DataLayerContext dbCtx = new DataLayerContext())
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResults = await dbCtx.DbSetProdODL
|
||||
.Where(x => !x.DateAssign.HasValue)
|
||||
.Select(odl => new OdlAssignDto
|
||||
{
|
||||
Envir = odl.ProdBatchNav.Envir,
|
||||
ProdODLID = odl.ProdODLID,
|
||||
Description = odl.Description,
|
||||
EstimTime = odl.EstimTime,
|
||||
Index = odl.Index,
|
||||
OdlTag = odl.OdlTag,
|
||||
PhaseID = odl.PhaseID,
|
||||
ProdBatchID = odl.ProdBatchID,
|
||||
ProdPlantCod = odl.ProdPlantCod,
|
||||
Qty = odl.Qty,
|
||||
ResourceID = odl.ResourceID,
|
||||
ItemList = odl.Item2OdlNav.Select(i => new ItemAssignDto
|
||||
{
|
||||
ProdItemID = i.ProdItemID,
|
||||
OrderID = i.ProductionItemNav.OrderRowNav.OrderNav.OrderID,
|
||||
OrderRowID = i.ProductionItemNav.OrderRowNav.OrderRowID,
|
||||
OrderTag = i.ProductionItemNav.OrderRowNav.OrderNav.OrderCode,
|
||||
OrderRowTag = i.ProductionItemNav.OrderRowNav.OrderRowCode,
|
||||
ProdItemTag = i.ProductionItemNav.ProdItemTag ?? "***"
|
||||
}).ToList()
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante ProductionOdlUnassignAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return dbResults;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Eliminazione record
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Cost;
|
||||
using EgwCoreLib.Lux.Core.RestPayload;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Cost;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Task;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@@ -99,6 +101,28 @@ namespace EgwCoreLib.Lux.Data.DbModel.Production
|
||||
/// </summary>
|
||||
public decimal WorkTime { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// BOM serializzata per la produzione dell'intero ODL
|
||||
/// </summary>
|
||||
public string RawBoM { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// BOM in versione deserializzata
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public List<BomItemDTO> ListBoM
|
||||
{
|
||||
get
|
||||
{
|
||||
List<BomItemDTO> bomList = new List<BomItemDTO>();
|
||||
if (!string.IsNullOrEmpty(RawBoM) && RawBoM.Length > 2)
|
||||
{
|
||||
bomList = JsonConvert.DeserializeObject<List<BomItemDTO>>(RawBoM) ?? new List<BomItemDTO>();
|
||||
}
|
||||
return bomList;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione sui Batch
|
||||
/// </summary>
|
||||
@@ -122,6 +146,6 @@ namespace EgwCoreLib.Lux.Data.DbModel.Production
|
||||
/// <summary>
|
||||
/// Navigazione verso tabella Item2Odl
|
||||
/// </summary>
|
||||
public ICollection<ProductionItem2ODLModel> Item2OdlNav { get; set; } = new List<ProductionItem2ODLModel>();
|
||||
public ICollection<ProductionItem2ODLModel> Item2OdlNav { get; set; } = new List<ProductionItem2ODLModel>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2309,10 +2309,11 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
/// Esegue salvataggio BOM sul DB
|
||||
/// </summary>
|
||||
/// <param name="uID">UID dell'item offerta di cui si è ricevuto la BOM</param>
|
||||
/// <param name="qMode">Mode della chiamata (x decidere cosa/dove salvare)</param>
|
||||
/// <param name="execEnvironment">Environment dell'item</param>
|
||||
/// <param name="bomContent">BOM serializzata</param>
|
||||
/// <returns></returns>
|
||||
public async Task SaveBomAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string bomContent)
|
||||
public async Task SaveBomAsync(string uID, Egw.Window.Data.Enums.QuestionModes qMode, Constants.EXECENVIRONMENTS execEnvironment, string bomContent)
|
||||
{
|
||||
// salvo sul DB il risultato della BOM
|
||||
if (!string.IsNullOrEmpty(bomContent))
|
||||
@@ -2328,8 +2329,34 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
{
|
||||
// verifico 1:1 gli item ricevuti dalla BOM sul DB con eventuale insert in anagrafica dei nuovi
|
||||
dbController.ItemUpsertFromBom(bomList);
|
||||
// salvo la BOM nel record del DB relativo all'oggetto richiesto
|
||||
dbController.OfferUpsertFromBom(uID, bomList);
|
||||
// se mode = 2 è offerta, se 5 = ODL...
|
||||
switch (qMode)
|
||||
{
|
||||
case Egw.Window.Data.Enums.QuestionModes.NULL:
|
||||
break;
|
||||
case Egw.Window.Data.Enums.QuestionModes.PREVIEW:
|
||||
break;
|
||||
|
||||
// BOM in offerta
|
||||
case Egw.Window.Data.Enums.QuestionModes.BOM:
|
||||
// salvo la BOM nel record Offer del DB relativo all'oggetto richiesto
|
||||
dbController.OfferUpsertFromBom(uID, bomList);
|
||||
break;
|
||||
|
||||
case Egw.Window.Data.Enums.QuestionModes.HARDWARE:
|
||||
break;
|
||||
case Egw.Window.Data.Enums.QuestionModes.CONFIG:
|
||||
break;
|
||||
|
||||
// BOM in ODL
|
||||
case Egw.Window.Data.Enums.QuestionModes.ORDER:
|
||||
// salvo la BOM nel record Offer del DB relativo all'oggetto richiesto
|
||||
await dbController.ProdOdlUpdateBomAsync(uID, bomContent);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
await Task.Delay(1);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>1.1.2601.2316</Version>
|
||||
<Version>1.1.2601.2317</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -105,6 +105,16 @@ namespace Lux.API.Services
|
||||
* ----------------------------------------*/
|
||||
string UID = retData.Args["UID"];
|
||||
string RUID = "";
|
||||
string sMode = retData.Args["Mode"];
|
||||
Egw.Window.Data.Enums.QuestionModes cMode = QuestionModes.NULL;
|
||||
if (int.TryParse(sMode, out int iMode))
|
||||
{
|
||||
bool modeValido = Enum.IsDefined(typeof(QuestionModes), iMode);
|
||||
if (modeValido)
|
||||
{
|
||||
cMode = (QuestionModes)iMode;
|
||||
}
|
||||
}
|
||||
|
||||
// gestione RUID
|
||||
if (retData.Args.ContainsKey("RUID"))
|
||||
@@ -145,7 +155,7 @@ namespace Lux.API.Services
|
||||
// salvo BOM ricevuta RAW in redis (cache)
|
||||
await cacheService.SaveBomAsync(UID, retData.ExecEnvironment, newBom);
|
||||
// salvo la BOM completa con i dati recuperati dal DB
|
||||
await dbService.SaveBomAsync(UID, retData.ExecEnvironment, newBom);
|
||||
await dbService.SaveBomAsync(UID, cMode, retData.ExecEnvironment, newBom);
|
||||
// reset cache redis...
|
||||
await cacheService.ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*");
|
||||
await cacheService.ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>LUX - Web Windows MES</i>
|
||||
<h4>Versione: 1.1.2601.2316</h4>
|
||||
<h4>Versione: 1.1.2601.2317</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.1.2601.2316
|
||||
1.1.2601.2317
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.1.2601.2316</version>
|
||||
<version>1.1.2601.2317</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