This commit is contained in:
zaccaria.majid
2023-10-27 10:22:32 +02:00
7 changed files with 204 additions and 84 deletions
+6 -2
View File
@@ -14,9 +14,13 @@
</div>
<div class="d-flex justify-content-between flex-wrap">
<div class="col-12 p-1">
<TechSheet_ST_ObjCheck CodArticolo="@CodArticolo"></TechSheet_ST_ObjCheck>
<TechSheet_ST_ObjCheck CodArticolo="@CodArticolo" IdxOdl="@IdxOdl" E_Updated="ForceRefresh"></TechSheet_ST_ObjCheck>
</div>
@if (ListGruppi.Count == 0)
@if (isProcessing)
{
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
}
else if (ListGruppi.Count == 0)
{
<div class="alert alert-warning fs-3">ST: Nessun Gruppo Trovato</div>
}
@@ -39,6 +39,14 @@ namespace MP_TAB_SERV.Components
checkReset();
}
protected async Task ForceRefresh()
{
isProcessing = true;
await InvokeAsync(StateHasChanged);
await ReloadData();
isProcessing = false;
}
protected override async Task OnParametersSetAsync()
{
if (RecMSE != null)
@@ -59,6 +67,8 @@ namespace MP_TAB_SERV.Components
private bool inAttr = false;
private bool isProcessing = false;
#endregion Private Fields
#region Private Properties
@@ -1,5 +1,16 @@
<div class="input-group input-group-lg">
<span class="input-group-text" id="inputGroup-sizing-default">Verifica</span>
<input type="text" class="form-control" @bind="ScanValue">
<button class="btn btn-warning text-uppercase"><i class="fa-solid fa-barcode"></i> read</button>
</div>
@if (showChecks)
{
<div class="input-group input-group-lg">
<span class="input-group-text" id="inputGroup-sizing-default">Verifica</span>
<input type="text" class="form-control" @bind="ScanValue">
<button class="btn btn-warning text-uppercase"><i class="fa-solid fa-barcode"></i> read</button>
</div>
@if (!string.IsNullOrEmpty(MessageText))
{
<div class="row">
<div class="col-12 text-center @MessageCss">
@MessageText
</div>
</div>
}
}
@@ -1,131 +1,184 @@
using global::System;
using global::System.Collections.Generic;
using global::System.Linq;
using global::System.Threading.Tasks;
using global::Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using MP_TAB_SERV;
using MP_TAB_SERV.Shared;
using MP_TAB_SERV.Components;
using MP.Data;
using MP.Data.DatabaseModels;
using MP.Data.DTO;
using MP.Data.Objects;
using MP.Data.Services;
using Newtonsoft.Json;
using NLog;
using Amazon.Runtime.Internal.Util;
namespace MP_TAB_SERV.Components
{
public partial class TechSheet_ST_ObjCheck
{
#region Public Properties
[Parameter]
public string CodArticolo { get; set; } = "";
[Parameter]
public int idxOdl { get; set; } = 0;
public EventCallback<bool> E_Updated { get; set; }
[Parameter]
public int IdxOdl { get; set; } = 0;
#endregion Public Properties
#region Public Methods
public void checkInputData()
{
if (IdxOdl > 0)
{
var rawData = TabDServ.STAR_pendByOdl(IdxOdl);
showChecks = rawData.Count > 0;
}
else
{
showChecks = false;
}
}
#endregion Public Methods
#region Protected Properties
[Inject]
protected MessageService MServ { get; set; } = null!;
protected string ScanValue
{
get => "";
set
{
lastScan = value;
// processo
processInput();
lastBCodeVal = value;
// processo input in async....
var pUpd = Task.Run(async () =>
{
await processInput();
//await InvokeAsync(() => StateHasChanged());
});
pUpd.Wait();
}
}
[Inject]
protected SharedMemService SMServ { get; set; } = null!;
[Inject]
protected TabDataService TabDServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override void OnParametersSet()
{
checkInputData();
}
#endregion Protected Methods
#region Private Fields
private string lastBCodeVal = "";
private string MessageCss = "";
private string MessageText = "";
private bool showChecks = false;
#endregion Private Fields
#region Private Properties
private string CognomeNome
{
get => MServ.CognomeNome;
}
#endregion Private Properties
#region Private Methods
/// <summary>
/// procedura pricipale decodifica Barcode
/// </summary>
private void processInput()
private async Task processInput()
{
bool found = false;
bool batchOk = false;
List<ST_ActRow> tabRichieste = TabDServ.STAR_pendByOdl(idxOdl);
List<ST_ActRow> tabRichieste = TabDServ.STAR_pendByOdl(IdxOdl);
List<AnagLottiArca> tabGiacenzeLotto = new List<AnagLottiArca>();
ST_ActRow datiBatchCheck;
AnagLottiArca datiLotto;
ST_ActRow? datiBatchCheck;
AnagLottiArca? datiLotto;
// per prima cosa recupero i valori "Pending" da leggere come candidati...
#if false
if (tabRichieste != null && tabRichieste.Count > 0)
{
// cerco per EQ come primo step...
var trovatoEq = tabRichieste.Where(x => x.CheckType == "EQ" && x.Value == BCodeVal);
var trovatoEq = tabRichieste.Where(x => x.CheckType == "EQ" && x.Value == lastBCodeVal);
if (trovatoEq != null && trovatoEq.Count() > 0)
{
// recupero record..
var datiEqCheck = trovatoEq.FirstOrDefault();
// registro trovato
found = true;
lblMessage.Text = $"Parametro acquisito: {BCodeVal}";
lblMessage.CssClass = "text-success";
// upsert controllo
DataLayerObj.taSTChk.upsertQuery(idxOdl, datiEqCheck.IdxST, datiEqCheck.Oggetto, datiEqCheck.Num, BCodeVal, BCodeVal, true, user_std.UtSn.utente, false);
if (datiEqCheck != null)
{
// registro trovato
found = true;
MessageText = $"Parametro acquisito: {lastBCodeVal}";
MessageCss = "text-success";
// upsert controllo
await TabDServ.ST_CheckUpsert(IdxOdl, datiEqCheck.IdxST, datiEqCheck.Oggetto, datiEqCheck.Num, lastBCodeVal, lastBCodeVal, true, CognomeNome, false);
}
}
// se non trovato
if (!found)
{
// recupero record.. cercando in giacenza il LOTTO...
tabGiacenzeLotto = DataLayerObj.taArcaGiac.getBySearch(null, "", BCodeVal, "", false);
// controllo condizione tipo BATCH (speciale) - prima solo che CI SIA una richiesta di questo tipo
tabGiacenzeLotto = await TabDServ.LottoEsterno("", lastBCodeVal, "");
// controllo condizione tipo BATCH (speciale) - prima solo che CI SIA una
// richiesta di questo tipo
var trovatoBatch = tabRichieste.Where(x => x.CheckType == "BATCH");
if (trovatoBatch != null && trovatoBatch.Count() > 0)
{
datiBatchCheck = trovatoBatch.FirstOrDefault();
if (tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0)
if (datiBatchCheck != null && tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0)
{
datiLotto = tabGiacenzeLotto.FirstOrDefault();
// registro trovato
found = true;
// upsert controllo
DataLayerObj.taSTChk.upsertQuery(idxOdl, datiBatchCheck.IdxST, datiBatchCheck.Oggetto, datiBatchCheck.Num, BCodeVal, datiLotto.Cd_AR, true, user_std.UtSn.utente, false);
// conto quanti check ci sono dopo, se calati --> ok altrimenti errore
var tabRichiestePost = DataLayerObj.taSTAR.getPendingByOdl(idxOdl);
if (tabRichiestePost.Count < tabRichieste.Count)
if (datiLotto != null)
{
lblMessage.Text = $"Lotto riconosciuto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo acquisito";
lblMessage.CssClass = "text-success";
batchOk = true;
}
else
{
lblMessage.Text = $"Lotto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto";
lblMessage.CssClass = "text-danger";
// registro trovato
found = true;
// upsert controllo
await TabDServ.ST_CheckUpsert(IdxOdl, datiBatchCheck.IdxST, datiBatchCheck.Oggetto, datiBatchCheck.Num, lastBCodeVal, datiLotto.Cd_AR, true, CognomeNome, false);
// conto quanti check ci sono dopo, se calati --> ok altrimenti errore
var tabRichiestePost = TabDServ.STAR_pendByOdl(IdxOdl);
if (tabRichiestePost.Count < tabRichieste.Count)
{
MessageText = $"Lotto riconosciuto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo acquisito";
MessageCss = "text-success";
batchOk = true;
}
else
{
MessageText = $"Lotto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto";
MessageCss = "text-danger";
}
}
}
}
if (!batchOk)
{
var currDeroga = DataLayerObj.getDerogaSt(tabRichieste[0].IdxST);
var currDeroga = TabDServ.ST_DerogaGet(CognomeNome, tabRichieste[0].IdxST);
// ciclo tra TUTTE le richeiste attive
foreach (var item in tabRichieste)
{
// verifico EVENTUALI deroghe
// se è deroga x gruppo/tipo/num corretto...
// verifico EVENTUALI deroghe se è deroga x gruppo/tipo/num corretto...
if (currDeroga.CanForce && item.CodGruppo == currDeroga.CodGruppo && item.CodTipo == currDeroga.CodTipo && item.Num == currDeroga.Num && item.Oggetto == currDeroga.Oggetto)
{
// ... forzo accettazione deroga
DataLayerObj.taSTChk.upsertQuery(idxOdl, item.IdxST, item.Oggetto, item.Num, BCodeVal, item.Value, true, user_std.UtSn.utente, true);
lblMessage.Text = $"Lotto/articolo non valido: {BCodeVal} --> Forzato a valido per articolo {item.Value}";
lblMessage.CssClass = "text-warning";
DataLayerObj.setDerogaSt(new MapoSDK.StCheckOverride() { IdxST = item.IdxST, CanForce = false });
await TabDServ.ST_CheckUpsert(IdxOdl, item.IdxST, item.Oggetto, item.Num, lastBCodeVal, item.Value, true, CognomeNome, true);
MessageText = $"Lotto/articolo non valido: {lastBCodeVal} --> Forzato a valido per articolo {item.Value}";
MessageCss = "text-warning";
TabDServ.ST_DerogaSet(new StCheckOverride() { IdxST = item.IdxST, CanForce = false });
batchOk = true;
}
}
@@ -138,30 +191,32 @@ namespace MP_TAB_SERV.Components
if (tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0)
{
datiLotto = tabGiacenzeLotto.FirstOrDefault();
lblMessage.Text = $"Lotto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto";
lblMessage.CssClass = "text-danger";
if (datiLotto != null)
{
MessageText = $"Lotto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto";
MessageCss = "text-danger";
}
}
else
{
lblMessage.Text = $"Parametro non riconosciuto: {BCodeVal}";
lblMessage.CssClass = "text-secondary";
MessageText = $"Parametro non riconosciuto: {lastBCodeVal}";
MessageCss = "text-secondary";
}
}
}
else
{
lblMessage.Text = $"Parametro non valido: {BCodeVal}";
lblMessage.CssClass = "text-secondary";
MessageText = $"Parametro non valido: {lastBCodeVal}";
MessageCss = "text-secondary";
}
// sistemo visualizzaizone componente
BCodeVal = "";
lastBCodeVal = "";
checkInputData();
// sollevo evento
reportUpdate();
#endif
await E_Updated.InvokeAsync(true);
}
private string lastScan = "";
#endregion Private Methods
}
}
@@ -80,7 +80,7 @@ namespace MP_TAB_SERV.Components
CodTipo = CurrRec.CodTipo,
CodGruppo = CurrRec.CodGruppo,
IdxST = CurrRec.IdxST,
Utente = $"{MatrOpr}"
Utente = CognomeNome
};
// salvo
TabDServ.ST_DerogaSet(newDeroga);
@@ -100,7 +100,7 @@ namespace MP_TAB_SERV.Components
if (CurrRec != null)
{
hasDeroga = false;
var currDeroga = TabDServ.ST_DerogaGet($"{MatrOpr}", CurrRec.IdxST);
var currDeroga = TabDServ.ST_DerogaGet(CognomeNome, CurrRec.IdxST);
if (currDeroga != null)
{
hasDeroga = (currDeroga.IdxST == CurrRec.IdxST && currDeroga.CanForce && currDeroga.Num == CurrRec.Num && currDeroga.CodGruppo == CurrRec.CodGruppo && currDeroga.CodTipo == CurrRec.CodTipo && currDeroga.Oggetto == CurrRec.Oggetto);
@@ -156,9 +156,9 @@ namespace MP_TAB_SERV.Components
}
}
private int MatrOpr
private string CognomeNome
{
get => MServ.MatrOpr;
get => MServ.CognomeNome;
}
#endregion Private Properties
+22
View File
@@ -1053,6 +1053,28 @@ namespace MP.Data.Controllers
}
return fatto;
}
public bool ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced)
{
bool fatto = false;
using (var dbCtx = new MoonProContext(_configuration))
{
var IdxOdl = new SqlParameter("@IdxOdl", idxOdl);
var IdxST = new SqlParameter("@IdxST", idxST);
var Oggetto = new SqlParameter("@Oggetto", oggetto);
var Num = new SqlParameter("@Num", num);
var ValueRead = new SqlParameter("@ValueRead", valueRead);
var ExtCode = new SqlParameter("@ExtCode", extCode);
var CheckOk = new SqlParameter("@CheckOk", checkOk);
var UserMod = new SqlParameter("@UserMod", userMod);
var Forced = new SqlParameter("@Forced", forced);
var result = dbCtx
.Database
.ExecuteSqlRaw("EXEC stp_ST_CHK_upsert @IdxOdl, @IdxST, @Oggetto, @Num, @ValueRead, @ExtCode, @CheckOk, @UserMod, @Forced", IdxOdl, IdxST, Oggetto, Num, ValueRead, ExtCode, CheckOk, UserMod, Forced);
fatto = result != 0;
}
return fatto;
}
/// <summary>
/// Recupero Righe pending da ODL
+19 -1
View File
@@ -1405,6 +1405,24 @@ namespace MP.Data.Services
return answ;
}
public async Task<bool> ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced)
{
bool answ = false;
try
{
// inserisco evento
answ = dbTabController.ST_CheckUpsert(idxOdl, idxST, oggetto, num, valueRead, extCode, checkOk, userMod, forced);
await FlushCache("ST");
}
catch (Exception exc)
{
string logMsg = $"Eccezione in ST_CheckUpsert | idxOdl: {idxOdl}{Environment.NewLine}{exc}";
Log.Error(logMsg);
}
return answ;
}
/// <summary>
/// Dati deroga SchedaTecnica serializzati in REDIS
/// </summary>
@@ -1469,7 +1487,7 @@ namespace MP.Data.Services
result = dbTabController.STAR_pendByOdl(idxODL);
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, LongCache);
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(5));
}
if (result == null)
{