Recupero statistiche foglio da obj REDIS OK...
This commit is contained in:
@@ -38,14 +38,6 @@ namespace NKC_WF.WebUserControls
|
||||
{
|
||||
MatStatList = statData.ListByMaterial;
|
||||
}
|
||||
#if false
|
||||
Random rnd = new Random();
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
var randDbl = rnd.NextDouble();
|
||||
MatStatList.Add(new NKC_WF.DTO.MaterialStats() { MatCode = $"{i * 100:00000}", MatDescript = $"Descrizione {i:00}", TotSheets = rnd.Next(10), TotParts = 50 * rnd.Next(1, 5), YeldAvg = randDbl, YeldMin = randDbl / 2, YeldMax = 1 - (1 - randDbl) / 2 });
|
||||
}
|
||||
#endif
|
||||
return MatStatList;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,6 +207,8 @@ namespace NKC_WF.WebUserControls
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private bool readDirect = false;
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna i dati di stima recuperando da Mongo le risposte complete dal supervisor
|
||||
/// </summary>
|
||||
@@ -214,62 +216,80 @@ namespace NKC_WF.WebUserControls
|
||||
/// <param name="BunkId">ID del BUNK da considerare</param>
|
||||
private void updateMongoData(int BatchId, int BunkId)
|
||||
{
|
||||
SheetYeld = new Dictionary<int, double>();
|
||||
SheetPartQty = new Dictionary<int, int>();
|
||||
DataLayer dlMan = new DataLayer();
|
||||
if (memLayer.ML.CRB("enableMongo"))
|
||||
{
|
||||
SheetYeld = new Dictionary<int, double>();
|
||||
SheetPartQty = new Dictionary<int, int>();
|
||||
// cerco da lista salvataggi Nest...
|
||||
var nestAnsw = ComLib.man.getNestAnsw(BatchId);
|
||||
// recupero bunk da DB
|
||||
DataLayer dlMan = new DataLayer();
|
||||
var bunkList = dlMan.taSTL.getByBatch(BatchId);
|
||||
var bunkRow = bunkList.Where(x => x.StackID == BunkId).FirstOrDefault();
|
||||
// elenchi x ricerca duplicati
|
||||
List<int> partListNest = new List<int>();
|
||||
List<int> partListNestDupl = new List<int>();
|
||||
|
||||
if (nestAnsw != null && bunkRow!=null)
|
||||
if (readDirect)
|
||||
{
|
||||
double num = 0;
|
||||
double den = 1;
|
||||
double currRatio = 0;
|
||||
try
|
||||
// cerco da lista salvataggi Nest...
|
||||
var nestAnsw = ComLib.man.getNestAnsw(BatchId);
|
||||
// recupero bunk da DB
|
||||
// elenchi x ricerca duplicati
|
||||
List<int> partListNest = new List<int>();
|
||||
List<int> partListNestDupl = new List<int>();
|
||||
|
||||
if (nestAnsw != null && bunkRow != null)
|
||||
{
|
||||
if (nestAnsw.BunkList != null)
|
||||
double num = 0;
|
||||
double den = 1;
|
||||
double currRatio = 0;
|
||||
try
|
||||
{
|
||||
foreach (var bunk in nestAnsw.BunkList)
|
||||
if (nestAnsw.BunkList != null)
|
||||
{
|
||||
if (bunkRow.StackIndex == bunk.BunkIndex)
|
||||
foreach (var bunk in nestAnsw.BunkList)
|
||||
{
|
||||
// procedo SOLO per il bunk corrente...
|
||||
foreach (var sheet in bunk.SheetList)
|
||||
if (bunkRow.StackIndex == bunk.BunkIndex)
|
||||
{
|
||||
num = sheet.SurfaceWork > 0 ? sheet.SurfaceWork : 0;
|
||||
den = sheet.SurfaceTotal > 0 ? sheet.SurfaceTotal : 1;
|
||||
currRatio = ComLib.ratioProt(num, den);
|
||||
if (SheetYeld.ContainsKey(sheet.SheetIndex))
|
||||
// procedo SOLO per il bunk corrente...
|
||||
foreach (var sheet in bunk.SheetList)
|
||||
{
|
||||
SheetYeld[sheet.SheetIndex] = currRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
SheetYeld.Add(sheet.SheetIndex, currRatio);
|
||||
}
|
||||
if (SheetPartQty.ContainsKey(sheet.SheetIndex))
|
||||
{
|
||||
SheetPartQty[sheet.SheetIndex] = sheet.PartList.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
SheetPartQty.Add(sheet.SheetIndex, sheet.PartList.Count);
|
||||
num = sheet.SurfaceWork > 0 ? sheet.SurfaceWork : 0;
|
||||
den = sheet.SurfaceTotal > 0 ? sheet.SurfaceTotal : 1;
|
||||
currRatio = ComLib.ratioProt(num, den);
|
||||
if (SheetYeld.ContainsKey(sheet.SheetIndex))
|
||||
{
|
||||
SheetYeld[sheet.SheetIndex] = currRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
SheetYeld.Add(sheet.SheetIndex, currRatio);
|
||||
}
|
||||
if (SheetPartQty.ContainsKey(sheet.SheetIndex))
|
||||
{
|
||||
SheetPartQty[sheet.SheetIndex] = sheet.PartList.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
SheetPartQty.Add(sheet.SheetIndex, sheet.PartList.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// leggo da obj di DlMan
|
||||
var statData = DLMan.GetYeldStatsFromMongoData(BatchId);
|
||||
if (statData != null)
|
||||
{
|
||||
List<AppData.DTO.SheetYeldStatDTO> sList = statData
|
||||
.ListBySheet
|
||||
.Where(x => x.BunkIdx == bunkRow.StackIndex)
|
||||
.ToList();
|
||||
// converto...
|
||||
SheetYeld = sList.ToDictionary(r => r.SheetIdx, r => r.Yeld);
|
||||
SheetPartQty = sList.ToDictionary(r => r.SheetIdx, r => r.NumParts);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user