300 lines
9.5 KiB
C#
300 lines
9.5 KiB
C#
using AppData;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace NKC_WF.WebUserControls
|
|
{
|
|
public partial class cmp_BP_sheetList : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Bunk corrente...
|
|
/// </summary>
|
|
public int BunkId
|
|
{
|
|
set
|
|
{
|
|
hfStackID.Value = value.ToString();
|
|
// aggiorno dati mongo...
|
|
updateMongoData(BatchId, value);
|
|
// disegno datagrid...
|
|
grView.DataBind();
|
|
}
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfStackID.Value, out answ);
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Num totale Sheets
|
|
/// </summary>
|
|
public int numSheets
|
|
{
|
|
get
|
|
{
|
|
return grView.Rows.Count;
|
|
}
|
|
}
|
|
|
|
// <summary>
|
|
/// Indice selezionato
|
|
/// </summary>
|
|
public int selIndex
|
|
{
|
|
get
|
|
{
|
|
return grView.SelectedIndex;
|
|
}
|
|
set
|
|
{
|
|
grView.SelectedIndex = value;
|
|
grView.DataBind();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// SheetId selezionato
|
|
/// </summary>
|
|
public int SheetIdSel
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
try
|
|
{
|
|
if (grView != null)
|
|
{
|
|
if (grView.SelectedValue != null)
|
|
{
|
|
int.TryParse(grView.SelectedValue.ToString(), out answ);
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Formatta in min/sec il tempo in sec decimale
|
|
/// </summary>
|
|
/// <param name="_timeSec"></param>
|
|
/// <returns></returns>
|
|
public string formatMinSec(object _timeSec)
|
|
{
|
|
int totSec = 0;
|
|
string answ = "";
|
|
int.TryParse(_timeSec.ToString().Replace(".", ""), out totSec);
|
|
int numMin = totSec / 60;
|
|
int numSec = totSec - (60 * numMin);
|
|
answ = $"{numMin:00}:{numSec:00}";
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera valore YELD dato SheetID
|
|
/// </summary>
|
|
/// <param name="sId"></param>
|
|
/// <returns></returns>
|
|
public string GetSheetPartQty(object sId)
|
|
{
|
|
int answ = 0;
|
|
int sheetId = 0;
|
|
if (int.TryParse($"{sId}", out sheetId))
|
|
{
|
|
if (SheetPartQty.ContainsKey(sheetId))
|
|
{
|
|
answ = SheetPartQty[sheetId];
|
|
}
|
|
}
|
|
return $"{answ:N0}";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupera valore YELD dato SheetID
|
|
/// </summary>
|
|
/// <param name="sId"></param>
|
|
/// <returns></returns>
|
|
public string GetSheetYeld(object sId)
|
|
{
|
|
double answ = 0;
|
|
int sheetId = 0;
|
|
if (int.TryParse($"{sId}", out sheetId))
|
|
{
|
|
if (SheetYeld.ContainsKey(sheetId))
|
|
{
|
|
answ = SheetYeld[sheetId];
|
|
}
|
|
}
|
|
return $"{answ:P1}";
|
|
}
|
|
|
|
public void resetSelezione()
|
|
{
|
|
//lblStack.Text = "";
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
raiseEvent();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
/// <summary>
|
|
/// Tabella dei dati di quante part siano presenti x foglio recuperato dai dati nesting da mongoDB
|
|
/// </summary>
|
|
protected Dictionary<int, int> SheetPartQty = new Dictionary<int, int>();
|
|
|
|
/// <summary>
|
|
/// Tabella dei dati di resa (Yeald) x foglio recuperato dai dati nesting da mongoDB
|
|
/// </summary>
|
|
protected Dictionary<int, double> SheetYeld = new Dictionary<int, double>();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Batch corrente...
|
|
/// </summary>
|
|
protected int BatchId
|
|
{
|
|
get
|
|
{
|
|
int answ = memLayer.ML.QSI("BatchId");
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
raiseEvent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// comando reset
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Aggiorna i dati di stima recuperando da Mongo le risposte complete dal supervisor
|
|
/// </summary>
|
|
/// <param name="BatchId">ID del Batch di cui recuperare le info</param>
|
|
/// <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"))
|
|
{
|
|
var bunkList = dlMan.taSTL.getByBatch(BatchId);
|
|
var bunkRow = bunkList.Where(x => x.StackID == BunkId).FirstOrDefault();
|
|
|
|
// da eliminare quando testato altro metodo...
|
|
#if false
|
|
// 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)
|
|
{
|
|
double num = 0;
|
|
double den = 1;
|
|
double currRatio = 0;
|
|
try
|
|
{
|
|
if (nestAnsw.BunkList != null)
|
|
{
|
|
foreach (var bunk in nestAnsw.BunkList)
|
|
{
|
|
if (bunkRow.StackIndex == bunk.BunkIndex)
|
|
{
|
|
// procedo SOLO per il bunk corrente...
|
|
foreach (var sheet in bunk.SheetList)
|
|
{
|
|
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
|
|
{ }
|
|
}
|
|
#endif
|
|
// 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);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
protected void grView_PageIndexChanged(object sender, EventArgs e)
|
|
{
|
|
updateMongoData(BatchId, BunkId);
|
|
}
|
|
}
|
|
} |