diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index 61e1eb4..a91e210 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -1442,7 +1442,7 @@ namespace AppData // salvo in cache rawData = JsonConvert.SerializeObject(answ); - memLayer.ML.setRSV(redKey, rawData, 5 * 60); + memLayer.ML.setRSV(redKey, rawData, 1); } } return answ; diff --git a/NKC_WF/WebUserControls/cmp_batchDetail.ascx b/NKC_WF/WebUserControls/cmp_batchDetail.ascx index fe8c3f1..71151f8 100644 --- a/NKC_WF/WebUserControls/cmp_batchDetail.ascx +++ b/NKC_WF/WebUserControls/cmp_batchDetail.ascx @@ -111,6 +111,7 @@
+
diff --git a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs index bfb559c..2f5ba81 100644 --- a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.cs @@ -19,6 +19,23 @@ namespace NKC_WF.WebUserControls #region Protected Properties + protected int lastValRatio + { + get + { + int answ = 50; + if (!string.IsNullOrEmpty(hfLastRatio.Value)) + { + int.TryParse(hfLastRatio.Value, out answ); + } + return answ; + } + set + { + hfLastRatio.Value = $"{value}"; + } + } + protected bool needSave { get @@ -44,7 +61,7 @@ namespace NKC_WF.WebUserControls } } - protected DS_App.OrderListTreeDataTable TabOrdersFromDb + protected DS_App.OrderListTreeDataTable TabOrders { get { @@ -64,6 +81,10 @@ namespace NKC_WF.WebUserControls } return answ; } + set + { + txtRatio.Text = $"{value}"; + } } #endregion Protected Properties @@ -307,98 +328,92 @@ namespace NKC_WF.WebUserControls /// private void rebalanceOrder() { - // costruisco vettore durata ordini - OrderSetSim FullSet = new OrderSetSim(); - OrderSetSim SetNe01 = new OrderSetSim(); - OrderSetSim SetNe02 = new OrderSetSim(); - - // creo liste x i valori da processare... - Dictionary RawList = new Dictionary(); - Dictionary OrderedList = new Dictionary(); - - var TabOrders = TabOrdersFromDb; - - foreach (var item in TabOrders) - { - RawList.Add(item.OrdID, item.EstProcTime); - } - - // ordino la lista x processing successivo - OrderedList = RawList.OrderBy(x => x.Value).ToDictionary(t => t.Key, t => t.Value); - - // salvo i set - FullSet.OrderSet = OrderedList; - // IndexScore = errore di stima corrente - double IScoreCurr = FullSet.ActualValue; - - // lavoro sull'ottimizzare il MINORE - double ValRatio = (double)valRatio / 100; - if (ValRatio <= 0.5) - { - SetNe01.TargetValue = FullSet.ActualValue * ValRatio; - SetNe01.OrderSet = findLocalMin(OrderedList, SetNe01.TargetValue, IScoreCurr); - // l'altro è la differenza - SetNe02.OrderSet = OrderedList; - foreach (var item in SetNe01.OrderSet) - { - SetNe02.OrderSet.Remove(item.Key); - } - } - else - { - SetNe02.TargetValue = FullSet.ActualValue * (1 - ValRatio); - SetNe02.OrderSet = findLocalMin(OrderedList, SetNe02.TargetValue, IScoreCurr); - // l'altro è la differenza - SetNe01.OrderSet = OrderedList; - foreach (var item in SetNe02.OrderSet) - { - SetNe01.OrderSet.Remove(item.Key); - } - } - + // tecupero ed imposto i batch descendant var TabBatch = TabBatchDesc; - int BatchNe01 = TabBatchDesc[0].BatchID; int BatchNe02 = TabBatchDesc[1].BatchID; - // riorganizzo tabOrders... - List OrdersNe01 = new List(); - List OrdersNe02 = new List(); - foreach (var orderItem in TabOrders) + // solo se variato il ratio... + if (valRatio != lastValRatio) { - if (SetNe01.OrderSet.ContainsKey(orderItem.OrdID)) + lastValRatio = valRatio; + // costruisco vettore durata ordini + OrderSetSim FullSet = new OrderSetSim(); + OrderSetSim SetNe01 = new OrderSetSim(); + OrderSetSim SetNe02 = new OrderSetSim(); + + // creo liste x i valori da processare... + Dictionary RawList = new Dictionary(); + Dictionary OrderedList = new Dictionary(); + + foreach (var item in TabOrders) { -#if false - OrdersNe01.Add(new OrderPrev() { OrderId = orderItem.OrdID, OrderExtCode = orderItem.OrderExtCode, NumBin = orderItem.EstNumBin, NumCart = orderItem.EstNumCart, TotTime = orderItem.EstProcTime, Quota = orderItem.TimeQuota }); -#endif - if (orderItem.BatchID != BatchNe01) + RawList.Add(item.OrdID, item.EstProcTime); + } + + // ordino la lista x processing successivo + OrderedList = RawList.OrderBy(x => x.Value).ToDictionary(t => t.Key, t => t.Value); + + // salvo i set + FullSet.OrderSet = OrderedList; + + // lavoro sull'ottimizzare il MINORE + double ValRatio = (double)valRatio / 100; + if (ValRatio <= 0.5) + { + SetNe01.TargetValue = FullSet.ActualValue * ValRatio; + SetNe01.OrderSet = findLocalMin(OrderedList, SetNe01.TargetValue); + // l'altro è la differenza + SetNe02.OrderSet = OrderedList; + foreach (var item in SetNe01.OrderSet) { - DLMan.taOLT.updateBatch(orderItem.BatchID, orderItem.OrdID, BatchNe01); + SetNe02.OrderSet.Remove(item.Key); } } else { -#if false - OrdersNe02.Add(new OrderPrev() { OrderId = orderItem.OrdID, OrderExtCode = orderItem.OrderExtCode, NumBin = orderItem.EstNumBin, NumCart = orderItem.EstNumCart, TotTime = orderItem.EstProcTime, Quota = orderItem.TimeQuota }); -#endif - if (orderItem.BatchID != BatchNe01) + SetNe02.TargetValue = FullSet.ActualValue * (1 - ValRatio); + SetNe02.OrderSet = findLocalMin(OrderedList, SetNe02.TargetValue); + // l'altro è la differenza + SetNe01.OrderSet = OrderedList; + foreach (var item in SetNe02.OrderSet) { - DLMan.taOLT.updateBatch(orderItem.BatchID, orderItem.OrdID, BatchNe02); + SetNe01.OrderSet.Remove(item.Key); } } + + // riorganizzo tabOrders... + foreach (var orderItem in TabOrders) + { + if (SetNe01.OrderSet.ContainsKey(orderItem.OrdID)) + { + if (orderItem.BatchID != BatchNe01) + { + DLMan.taOLT.updateBatch(orderItem.BatchID, orderItem.OrdID, BatchNe01); + } + } + else + { + if (orderItem.BatchID != BatchNe02) + { + DLMan.taOLT.updateBatch(orderItem.BatchID, orderItem.OrdID, BatchNe02); + } + } + } + // aggiorno valore ratio e ratio last... + double newRatio = (SetNe01.ActualValue * 100 / (SetNe01.ActualValue + SetNe02.ActualValue)); + valRatio = (int)newRatio; + lastValRatio = valRatio; + + // ...aggiorno display + cmp_orderExtListNE01.BatchId = BatchNe01; + cmp_orderExtListNE02.BatchId = BatchNe02; + cmp_orderExtListNE01.doUpdate(); + cmp_orderExtListNE02.doUpdate(); + + // --> richiede salvataggio + needSave = true; } - - // ...e poi mostro - cmp_orderExtListNE01.BatchId = BatchNe01; - cmp_orderExtListNE02.BatchId = BatchNe02; -#if false - // ...e poi mostro - cmp_orderExtListNE01.CurrOrders = OrdersNe01; - cmp_orderExtListNE02.CurrOrders = OrdersNe02; - -#endif - // --> richiede salvataggio - needSave = true; } /// @@ -407,7 +422,7 @@ namespace NKC_WF.WebUserControls private void showBatchDescendant() { // se ho qualcosa aggiorno visualizzazione... - if (TabOrdersFromDb.Count > 0) + if (TabOrders.Count > 0) { // suddivido rebalanceOrder(); @@ -423,9 +438,8 @@ namespace NKC_WF.WebUserControls /// /// Lista ordinata oggetti (INT) + valore /// Valore desiderato (comeSOMMA) - /// Indice score = errore minimo da migliorare /// - protected Dictionary findLocalMin(Dictionary OrderedList, double TargetVal, double CurrIndexScore) + protected Dictionary findLocalMin(Dictionary OrderedList, double TargetVal) { Dictionary answ = new Dictionary(); List Candidates = new List(); @@ -439,12 +453,7 @@ namespace NKC_WF.WebUserControls CurrSimSet = new OrderSetSim(); CurrSimSet.TargetValue = TargetVal; CurrSimSet.OrderSet.Add(currOrder.Key, currOrder.Value); - // se lo score è migliorativo... - if (CurrSimSet.IndexScore < CurrIndexScore) - { - Candidates.Add(CurrSimSet); - CurrIndexScore = CurrSimSet.IndexScore; - } + Candidates.Add(CurrSimSet); } // ora guardo gli elementi restanti.. se ci sono @@ -455,32 +464,23 @@ namespace NKC_WF.WebUserControls CurrSimSet = new OrderSetSim(); CurrSimSet.TargetValue = TargetVal; CurrSimSet.OrderSet.Add(currOrder.Key, currOrder.Value); - // se lo score è migliorativo... - if (CurrSimSet.IndexScore < CurrIndexScore) - { - Candidates.Add(CurrSimSet); - CurrIndexScore = CurrSimSet.IndexScore; - } + Candidates.Add(CurrSimSet); // prendo i restanti tranne il primo OrdInf.Remove(currOrder.Key); // se rimane qualcosa... if (OrdInf != null && OrdInf.Any()) { // calcolo il minimo locale nei 2 casi, da soli - Dictionary TestOrderSet01 = findLocalMin(OrdInf, TargetVal, CurrIndexScore); + Dictionary TestOrderSet01 = findLocalMin(OrdInf, TargetVal); if (TestOrderSet01.Count > 0) { OrderSetSim CurrSet = new OrderSetSim(); CurrSet.TargetValue = TargetVal; CurrSet.OrderSet = TestOrderSet01; - if (CurrSet.IndexScore < CurrIndexScore) - { - Candidates.Add(CurrSimSet); - CurrIndexScore = CurrSimSet.IndexScore; - } + Candidates.Add(CurrSet); } // ...e con il primo valore... - Dictionary TestOrderSet02 = findLocalMin(OrdInf, TargetVal - currOrder.Value, CurrIndexScore); + Dictionary TestOrderSet02 = findLocalMin(OrdInf, TargetVal - currOrder.Value); TestOrderSet02.Add(currOrder.Key, currOrder.Value); // verifico se migliorativo... if (TestOrderSet02.Count > 0) @@ -488,11 +488,7 @@ namespace NKC_WF.WebUserControls OrderSetSim CurrSet = new OrderSetSim(); CurrSet.TargetValue = TargetVal - currOrder.Value; CurrSet.OrderSet = TestOrderSet02; - if (CurrSet.IndexScore < CurrIndexScore) - { - Candidates.Add(CurrSimSet); - CurrIndexScore = CurrSimSet.IndexScore; - } + Candidates.Add(CurrSet); } } } diff --git a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.designer.cs b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.designer.cs index 6f31710..0017d42 100644 --- a/NKC_WF/WebUserControls/cmp_batchDetail.ascx.designer.cs +++ b/NKC_WF/WebUserControls/cmp_batchDetail.ascx.designer.cs @@ -104,6 +104,15 @@ namespace NKC_WF.WebUserControls /// protected global::System.Web.UI.WebControls.HiddenField hfNeedSave; + /// + /// hfLastRatio control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HiddenField hfLastRatio; + /// /// txtRatio control. /// diff --git a/NKC_WF/WebUserControls/cmp_orderExtList.ascx.cs b/NKC_WF/WebUserControls/cmp_orderExtList.ascx.cs index 6a0e878..27e9b5b 100644 --- a/NKC_WF/WebUserControls/cmp_orderExtList.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_orderExtList.ascx.cs @@ -37,5 +37,14 @@ namespace NKC_WF.WebUserControls } #endregion Protected Methods + + #region Public Methods + + public void doUpdate() + { + grView.DataBind(); + } + + #endregion Public Methods } } \ No newline at end of file