modifica componenti VT
This commit is contained in:
commit
6f1ddbd883
@ -52,6 +52,7 @@ using System.Linq;
|
|||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace ApiPolo.Controllers
|
namespace ApiPolo.Controllers
|
||||||
{
|
{
|
||||||
@ -459,6 +460,14 @@ namespace ApiPolo.Controllers
|
|||||||
private readonly VT_ARTICOLI_TABLE_DbContext _VT_articoliTable;
|
private readonly VT_ARTICOLI_TABLE_DbContext _VT_articoliTable;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region VT-MAG_NEW
|
||||||
|
private readonly VT_MAG_NEW_DbContext _VT_MagNew;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region VT-MAGAZZINI
|
||||||
|
private readonly VT_MAGAZZINI_DbContext _VT_Magazzini;
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Commesse desc
|
#region Commesse desc
|
||||||
private readonly SIET_COMMESSE_DESC_DbContext _Siet_commDesc;
|
private readonly SIET_COMMESSE_DESC_DbContext _Siet_commDesc;
|
||||||
private readonly MARRO_COMMESSE_TABLE_DbContext _Marro_commDesc;
|
private readonly MARRO_COMMESSE_TABLE_DbContext _Marro_commDesc;
|
||||||
@ -511,6 +520,8 @@ namespace ApiPolo.Controllers
|
|||||||
private DbSet<Buoni>? _VT_buo;
|
private DbSet<Buoni>? _VT_buo;
|
||||||
private DbSet<Rapp_New_View>? _rapp_new_view;
|
private DbSet<Rapp_New_View>? _rapp_new_view;
|
||||||
private DbSet<Articoli>? _articoliTable;
|
private DbSet<Articoli>? _articoliTable;
|
||||||
|
private DbSet<Vt_Mag_New>? _magNewVT;
|
||||||
|
private DbSet<MagazziniVT>? _magazziniVT;
|
||||||
|
|
||||||
private DbSet<CommessaDesc>? _commDesc;
|
private DbSet<CommessaDesc>? _commDesc;
|
||||||
private DbSet<CommessaDescSiet>? _commDescSiet;
|
private DbSet<CommessaDescSiet>? _commDescSiet;
|
||||||
@ -880,8 +891,12 @@ namespace ApiPolo.Controllers
|
|||||||
VT_Buoni_DbContext VT_Buoni,
|
VT_Buoni_DbContext VT_Buoni,
|
||||||
VT_STO_RAPP_DbContext VT_StoRapp,
|
VT_STO_RAPP_DbContext VT_StoRapp,
|
||||||
VT_TIMBRATURE_DbContext VT_timbr,
|
VT_TIMBRATURE_DbContext VT_timbr,
|
||||||
VT_ARTICOLI_TABLE_DbContext VT_artTable
|
VT_ARTICOLI_TABLE_DbContext VT_artTable,
|
||||||
|
VT_MAG_NEW_DbContext VT_MagNew,
|
||||||
|
VT_MAGAZZINI_DbContext VT_Magazzini
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
@ -1226,6 +1241,8 @@ namespace ApiPolo.Controllers
|
|||||||
_VT_Buoni = VT_Buoni;
|
_VT_Buoni = VT_Buoni;
|
||||||
_VT_StoRapp = VT_StoRapp;
|
_VT_StoRapp = VT_StoRapp;
|
||||||
_VT_articoliTable = VT_artTable;
|
_VT_articoliTable = VT_artTable;
|
||||||
|
_VT_MagNew = VT_MagNew;
|
||||||
|
_VT_Magazzini = VT_Magazzini;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Commesse desc
|
#region Commesse desc
|
||||||
@ -1879,6 +1896,7 @@ namespace ApiPolo.Controllers
|
|||||||
}
|
}
|
||||||
return _sa;
|
return _sa;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DbSet<Compo_Impia> getComponentiByTenant(string tenant)
|
private DbSet<Compo_Impia> getComponentiByTenant(string tenant)
|
||||||
{
|
{
|
||||||
DbSet<Compo_Impia>? _compon;
|
DbSet<Compo_Impia>? _compon;
|
||||||
@ -3040,6 +3058,28 @@ namespace ApiPolo.Controllers
|
|||||||
return mn;
|
return mn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>trasforma un Saldiart in un Vt_Mag_New</summary>
|
||||||
|
private Vt_Mag_New SaldiArtToVtMag_New(Saldiart co, int riga, string newSerial, string tecnico, string azienda)
|
||||||
|
{
|
||||||
|
Vt_Mag_New vtmn = new Vt_Mag_New();
|
||||||
|
vtmn.Azienda = azienda;
|
||||||
|
vtmn.Seriale_Rapportino = newSerial;
|
||||||
|
vtmn.Riga = riga;
|
||||||
|
vtmn.Magazzino = co.slcodmag;
|
||||||
|
vtmn.Articolo = co.slcodice;
|
||||||
|
vtmn.Tipo_Movimento = "A";
|
||||||
|
vtmn.Quantita = co.slqtaper;
|
||||||
|
vtmn.Prezzo = co.liprezzo;
|
||||||
|
vtmn.Codice_Tecnico = tecnico;
|
||||||
|
vtmn.CodLotto = co.locodice;
|
||||||
|
vtmn.Matricola = co.amcodice;
|
||||||
|
vtmn.Desc_Art = co.ardesart;
|
||||||
|
vtmn.Cpccchk = getCpccchk(10);
|
||||||
|
vtmn.Desc_Sup = co.desc_sup;
|
||||||
|
return vtmn;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>trasforma un Compi_Impia in un Mag_New</summary>
|
/// <summary>trasforma un Compi_Impia in un Mag_New</summary>
|
||||||
private Mag_New compo_ImpiaToMag_New(Compo_Impia co, int riga, string newSerial, string tecnico)
|
private Mag_New compo_ImpiaToMag_New(Compo_Impia co, int riga, string newSerial, string tecnico)
|
||||||
{
|
{
|
||||||
@ -3068,6 +3108,35 @@ namespace ApiPolo.Controllers
|
|||||||
return mn;
|
return mn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>trasforma un Compi_Impia in un Vt_Mag_New</summary>
|
||||||
|
private Vt_Mag_New compo_ImpiaToVt_Mag_New(Compo_Impia co, int riga, string newSerial, string tecnico, string azienda)
|
||||||
|
{
|
||||||
|
|
||||||
|
Vt_Mag_New vtmn = new Vt_Mag_New();
|
||||||
|
vtmn.Azienda = azienda;
|
||||||
|
vtmn.Seriale_Rapportino = newSerial;
|
||||||
|
vtmn.Riga = riga;
|
||||||
|
vtmn.Matricola = "001";
|
||||||
|
vtmn.Articolo = co.cocodart;
|
||||||
|
vtmn.Tipo_Movimento = "E";
|
||||||
|
vtmn.Quantita = co.coqtaart;
|
||||||
|
vtmn.Prezzo = 0;
|
||||||
|
vtmn.Codice_Tecnico = tecnico;
|
||||||
|
vtmn.CodLotto = co.lotto;
|
||||||
|
vtmn.Matricola = co.matricola;
|
||||||
|
vtmn.Cprownum = co.cprownum;
|
||||||
|
vtmn.CodImp = co.cocodimp;
|
||||||
|
vtmn.Desc_Art = co.ardesart;
|
||||||
|
vtmn.Cpccchk = getCpccchk(10);
|
||||||
|
vtmn.Desc_Sup = co.desc_sup;
|
||||||
|
|
||||||
|
|
||||||
|
string appoNote = string.Empty;
|
||||||
|
appoNote = (co.co__note != null && co.co__note.Length>254) ? co.co__note.Substring(0, 254) : co.co__note;
|
||||||
|
vtmn.Note = appoNote;
|
||||||
|
return vtmn;
|
||||||
|
}
|
||||||
|
|
||||||
private static Random random = new Random();
|
private static Random random = new Random();
|
||||||
/// <summary>crea un cpccchk</summary>
|
/// <summary>crea un cpccchk</summary>
|
||||||
public static string getCpccchk(int length)
|
public static string getCpccchk(int length)
|
||||||
@ -3799,8 +3868,7 @@ namespace ApiPolo.Controllers
|
|||||||
[HttpGet("magazzini")]
|
[HttpGet("magazzini")]
|
||||||
public async Task<ActionResult<IEnumerable<Magazzini>>> magazzini(string token)
|
public async Task<ActionResult<IEnumerable<Magazzini>>> magazzini(string token)
|
||||||
{
|
{
|
||||||
|
List<Magazzini> lst= new List<Magazzini>();
|
||||||
List < Magazzini > lst= new List<Magazzini>();
|
|
||||||
string ten = getClaimValueByToken(token, "tenant");
|
string ten = getClaimValueByToken(token, "tenant");
|
||||||
string ten2 = getClaimValueByToken(token, "tenant2");
|
string ten2 = getClaimValueByToken(token, "tenant2");
|
||||||
string tenAdhoc = getClaimValueByToken(token, "tenantConfigurazioni");
|
string tenAdhoc = getClaimValueByToken(token, "tenantConfigurazioni");
|
||||||
@ -3812,9 +3880,20 @@ namespace ApiPolo.Controllers
|
|||||||
|
|
||||||
if (ten.Equals(Clienti.VT))
|
if (ten.Equals(Clienti.VT))
|
||||||
{
|
{
|
||||||
|
_magazziniVT = _VT_Magazzini.Magazzini;
|
||||||
|
|
||||||
|
List<MagazziniVT> magaVTList = new List<MagazziniVT>();
|
||||||
|
magaVTList = await _magazziniVT.Where(x => x.Azienda.Equals(ten2)).ToListAsync();
|
||||||
|
|
||||||
|
foreach (var magVT in magaVTList)
|
||||||
|
{
|
||||||
|
Magazzini maga = new Magazzini();
|
||||||
|
maga.mgcodmag = magVT.Mgcodmag.TrimEnd();
|
||||||
|
maga.mgdesmag = magVT.Mgdesmag.TrimEnd();
|
||||||
|
|
||||||
|
lst.Add(maga);
|
||||||
|
}
|
||||||
return lst;
|
return lst;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -6290,7 +6369,6 @@ namespace ApiPolo.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Clienti.VT:
|
case Clienti.VT:
|
||||||
using (var transactionVT = _VT_rapptable.Database.BeginTransaction())
|
using (var transactionVT = _VT_rapptable.Database.BeginTransaction())
|
||||||
{
|
{
|
||||||
@ -6298,6 +6376,40 @@ namespace ApiPolo.Controllers
|
|||||||
await _VT_rapptable.SaveChangesAsync();
|
await _VT_rapptable.SaveChangesAsync();
|
||||||
transactionVT.Commit();
|
transactionVT.Commit();
|
||||||
}
|
}
|
||||||
|
// 27/02/2025 agggiunta gestione Vt_MagNew
|
||||||
|
riga = 0;
|
||||||
|
if (model.compo_add != null && model.compo_add.Count() > 0)
|
||||||
|
{
|
||||||
|
using (var transactionVT2 = _VT_rapptable.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
foreach (Saldiart co in model.compo_add)
|
||||||
|
{
|
||||||
|
Vt_Mag_New vtmn = new Vt_Mag_New();
|
||||||
|
riga = riga + 1;
|
||||||
|
vtmn = SaldiArtToVtMag_New(co, riga, newSerial, tecnico, ten2);
|
||||||
|
|
||||||
|
await _VT_MagNew.MagNewVt.AddAsync(vtmn);
|
||||||
|
await _VT_MagNew.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
transactionVT2.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (model.compo_del != null && model.compo_del.Count() > 0)
|
||||||
|
{
|
||||||
|
using (var transactionVt3 = _VT_rapptable.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
foreach (Compo_Impia co in model.compo_del)
|
||||||
|
{
|
||||||
|
Vt_Mag_New vtmn = new Vt_Mag_New();
|
||||||
|
riga = riga + 1;
|
||||||
|
vtmn = compo_ImpiaToVt_Mag_New(co, riga, newSerial, tecnico, ten2);
|
||||||
|
|
||||||
|
await _VT_MagNew.MagNewVt.AddAsync(vtmn);
|
||||||
|
await _VT_MagNew.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
transactionVt3.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Clienti.LW:
|
case Clienti.LW:
|
||||||
|
|
||||||
@ -8493,24 +8605,14 @@ namespace ApiPolo.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string ten = getClaimValueByToken(token, "tenant");
|
string ten = getClaimValueByToken(token, "tenant");
|
||||||
List<Compo_Impia> lst = new List<Compo_Impia>();
|
|
||||||
if (ten.Equals(Clienti.VT))
|
|
||||||
{
|
|
||||||
Compo_Impia ci = new Compo_Impia();
|
|
||||||
ci.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_compo = getComponentiByTenant(ten);
|
|
||||||
|
|
||||||
var co = await _compo.Where(
|
_compo = getComponentiByTenant(ten);
|
||||||
t => t.cocodimp == codimp
|
|
||||||
).ToListAsync();
|
|
||||||
lst = co;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
var co = await _compo.Where(
|
||||||
|
t => t.cocodimp == codimp
|
||||||
|
).ToListAsync();
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status200OK, lst);
|
return StatusCode(StatusCodes.Status200OK, co);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -8715,70 +8817,129 @@ namespace ApiPolo.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string ten = getClaimValueByToken(token, "tenant");
|
string ten = getClaimValueByToken(token, "tenant");
|
||||||
|
string ten2 = getClaimValueByToken(token, "tenant2");
|
||||||
string tenConf = getClaimValueByToken(token, "tenantConfigurazioni");
|
string tenConf = getClaimValueByToken(token, "tenantConfigurazioni");
|
||||||
|
|
||||||
_saldi = getSaldiartByTenant(ten);
|
//27/02/2025 aggiunta gestione Articoli
|
||||||
Configurazioni conf = await readConf(tenConf);
|
if (tenConf.Equals(Clienti.VT))
|
||||||
int max_record = 0;
|
|
||||||
max_record = conf.max_record!=null? conf.max_record.Value:0;
|
|
||||||
string codlis = string.Empty;
|
|
||||||
_clienti = getClientiByTenant(ten);
|
|
||||||
var a = await _clienti.Where(t => t.ancodice == codcli).ToListAsync();
|
|
||||||
if (a != null && a.Count() == 0)
|
|
||||||
{
|
{
|
||||||
codlis = conf.listino;
|
_articoliTable = _VT_articoliTable.Articoli;
|
||||||
|
|
||||||
|
var listaFiltro = new List<Articoli>();
|
||||||
|
|
||||||
|
listaFiltro = await _articoliTable.Where(x => x.Azienda.Equals(ten2)).ToListAsync();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(art))
|
||||||
|
{
|
||||||
|
listaFiltro = await _articoliTable.Where(x => x.SlCodice.Contains(art)).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(desart))
|
||||||
|
{
|
||||||
|
listaFiltro = await _articoliTable.Where(x => x.ArDesArt.Contains(desart)).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(maga))
|
||||||
|
{
|
||||||
|
listaFiltro = await _articoliTable.Where(x => x.SlCodMag.Contains(maga)).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Saldiart> listaSaldiArt = new List<Saldiart>();
|
||||||
|
|
||||||
|
foreach (Articoli a in listaFiltro)
|
||||||
|
{
|
||||||
|
Saldiart saldo = new Saldiart();
|
||||||
|
|
||||||
|
saldo.slcodice = a.SlCodice.TrimEnd();
|
||||||
|
saldo.ardesart = a.ArDesArt.TrimEnd();
|
||||||
|
saldo.slcodmag = a.SlCodMag.TrimEnd();
|
||||||
|
saldo.slqtaper = a.SlQtAper;
|
||||||
|
saldo.amcodice = a.AmCodice.TrimEnd();
|
||||||
|
saldo.locodice = a.LoCodice.TrimEnd();
|
||||||
|
saldo.licodlis = a.LiCodLis.TrimEnd();
|
||||||
|
saldo.licodart = a.LiCodArt.TrimEnd();
|
||||||
|
saldo.lidatatt = a.LiDatAtt;
|
||||||
|
saldo.liquanti = a.LiQuanti;
|
||||||
|
saldo.liprezzo = a.LiPrezzo;
|
||||||
|
saldo.liscont1 = a.LiScont1;
|
||||||
|
saldo.liscont2 = a.LiScont2;
|
||||||
|
saldo.liscont3 = a.LiScont3;
|
||||||
|
saldo.liscont4 = a.LiScont4;
|
||||||
|
saldo.gest_matr = a.Gest_Matr.TrimEnd();
|
||||||
|
saldo.gest_lotti = a.Gest_Lotti.TrimEnd();
|
||||||
|
saldo.desc_sup = a.Desc_sup.TrimEnd();
|
||||||
|
|
||||||
|
listaSaldiArt.Add(saldo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return StatusCode(StatusCodes.Status200OK, listaFiltro);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
codlis = string.IsNullOrEmpty(a.First().annumlis) ? conf.listino : a.First().annumlis;
|
_saldi = getSaldiartByTenant(ten);
|
||||||
}
|
Configurazioni conf = await readConf(tenConf);
|
||||||
var co = await _saldi.Where(t => t.slcodmag != null && t.slcodmag.Equals(maga) && t.licodlis != null && t.licodlis.Equals(codlis)).ToListAsync();
|
int max_record = 0;
|
||||||
|
max_record = conf.max_record != null ? conf.max_record.Value : 0;
|
||||||
if (!string.IsNullOrEmpty(art))
|
string codlis = string.Empty;
|
||||||
{
|
_clienti = getClientiByTenant(ten);
|
||||||
co = co.Where(t => t.slcodice != null && t.slcodice.ToUpper().Contains(art.ToUpper())).ToList();
|
var a = await _clienti.Where(t => t.ancodice == codcli).ToListAsync();
|
||||||
}
|
if (a != null && a.Count() == 0)
|
||||||
if (!string.IsNullOrEmpty(desart))
|
|
||||||
{
|
|
||||||
co = co.Where(t => t.ardesart != null && t.ardesart.ToUpper().Contains(desart.ToUpper())).ToList();
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(matric))
|
|
||||||
{
|
|
||||||
//List<Saldiart> lista = new List<Saldiart>();
|
|
||||||
//var codart = co.Where(m => m.amcodice != null && m.amcodice.ToUpper().Contains(matric.ToUpper())).ToList();
|
|
||||||
//var query = co.Where(p => codart.Any(kw => p..StartsWith(kw)));
|
|
||||||
//if (codart != null && codart.Count() > 0)
|
|
||||||
//{
|
|
||||||
// foreach(Saldiart sa in codart)
|
|
||||||
// {
|
|
||||||
// string artTrovato = sa.slcodice;
|
|
||||||
// co= co.Where(t => t.slcodice != null && t.slcodice.ToUpper().Contains(artTrovato.ToUpper())
|
|
||||||
// && t.amcodice.ToUpper().Contains(matric.ToUpper())).ToList();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// // devo svuotare l'elenco articoli
|
|
||||||
// co = co.Take(0).ToList();
|
|
||||||
//}
|
|
||||||
co = co.Where(t => t.amcodice != null && t.amcodice.ToUpper().Contains(matric.ToUpper())).ToList();
|
|
||||||
|
|
||||||
}
|
|
||||||
//2024-02-19: se l'articolo è gestito a matricole, la query restituisce tutte le righe splittate,
|
|
||||||
//in questo caso forzo la quantità a 1
|
|
||||||
if (co != null && co.Count() > 0)
|
|
||||||
{
|
|
||||||
foreach (Saldiart s in co)
|
|
||||||
{
|
{
|
||||||
if (s.gest_matr!=null && s.gest_matr.Equals("S"))
|
codlis = conf.listino;
|
||||||
{
|
|
||||||
s.slqtaper = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
codlis = string.IsNullOrEmpty(a.First().annumlis) ? conf.listino : a.First().annumlis;
|
||||||
|
}
|
||||||
|
var co = await _saldi.Where(t => t.slcodmag != null && t.slcodmag.Equals(maga) && t.licodlis != null && t.licodlis.Equals(codlis)).ToListAsync();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(art))
|
||||||
|
{
|
||||||
|
co = co.Where(t => t.slcodice != null && t.slcodice.ToUpper().Contains(art.ToUpper())).ToList();
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(desart))
|
||||||
|
{
|
||||||
|
co = co.Where(t => t.ardesart != null && t.ardesart.ToUpper().Contains(desart.ToUpper())).ToList();
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(matric))
|
||||||
|
{
|
||||||
|
//List<Saldiart> lista = new List<Saldiart>();
|
||||||
|
//var codart = co.Where(m => m.amcodice != null && m.amcodice.ToUpper().Contains(matric.ToUpper())).ToList();
|
||||||
|
//var query = co.Where(p => codart.Any(kw => p..StartsWith(kw)));
|
||||||
|
//if (codart != null && codart.Count() > 0)
|
||||||
|
//{
|
||||||
|
// foreach(Saldiart sa in codart)
|
||||||
|
// {
|
||||||
|
// string artTrovato = sa.slcodice;
|
||||||
|
// co= co.Where(t => t.slcodice != null && t.slcodice.ToUpper().Contains(artTrovato.ToUpper())
|
||||||
|
// && t.amcodice.ToUpper().Contains(matric.ToUpper())).ToList();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// // devo svuotare l'elenco articoli
|
||||||
|
// co = co.Take(0).ToList();
|
||||||
|
//}
|
||||||
|
co = co.Where(t => t.amcodice != null && t.amcodice.ToUpper().Contains(matric.ToUpper())).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
//2024-02-19: se l'articolo è gestito a matricole, la query restituisce tutte le righe splittate,
|
||||||
|
//in questo caso forzo la quantità a 1
|
||||||
|
if (co != null && co.Count() > 0)
|
||||||
|
{
|
||||||
|
foreach (Saldiart s in co)
|
||||||
|
{
|
||||||
|
if (s.gest_matr != null && s.gest_matr.Equals("S"))
|
||||||
|
{
|
||||||
|
s.slqtaper = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
co = co.Take(max_record).ToList();
|
||||||
|
return StatusCode(StatusCodes.Status200OK, co);
|
||||||
}
|
}
|
||||||
co = co.Take(max_record).ToList();
|
|
||||||
return StatusCode(StatusCodes.Status200OK, co);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -15624,6 +15785,135 @@ namespace ApiPolo.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>VIRTUAL TASK: lista mag_new per azienda</summary>
|
||||||
|
[HttpGet("VTMagNewList")]
|
||||||
|
public async Task<ActionResult<IEnumerable<Vt_Mag_New>>> VTMagNewList(string token)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Vt_Mag_New> mnlist = new List<Vt_Mag_New>();
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
string tecnico = getClaimValueByToken(token, "tccodice");
|
||||||
|
_magNewVT = _VT_MagNew.MagNewVt;
|
||||||
|
|
||||||
|
var listaMn = await _magNewVT.Where(x => x.Azienda.Equals(ten)).ToListAsync();
|
||||||
|
foreach (Vt_Mag_New mg in listaMn)
|
||||||
|
{
|
||||||
|
mnlist.Add(mg);
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, mnlist);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string err = "Errore: " + ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, err); ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>VIRTUAL TASK: lista Magazzini per azienda</summary>
|
||||||
|
[HttpGet("magazziniVTList")]
|
||||||
|
public async Task<ActionResult<IEnumerable<MagazziniVT>>> MagazziniVTList(string token)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<MagazziniVT> maglist = new List<MagazziniVT>();
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
string tecnico = getClaimValueByToken(token, "tccodice");
|
||||||
|
_magazziniVT = _VT_Magazzini.Magazzini;
|
||||||
|
|
||||||
|
var magazziniList = await _magazziniVT.Where(x => x.Azienda.Equals(ten)).ToListAsync();
|
||||||
|
foreach (MagazziniVT magaz in magazziniList)
|
||||||
|
{
|
||||||
|
maglist.Add(magaz);
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, maglist);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string err = "Errore: " + ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, err); ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary> VIRTUAL TASK : crea nuovo magazzino return: ActionResult</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("magazziniVT/add")]
|
||||||
|
public async Task<ActionResult<MagazziniVT>> addMagazzinoVT([FromBody] MagazziniVT model, string token)
|
||||||
|
{
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
model.Azienda = ten;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var transaction = _VT_Magazzini.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
await _VT_Magazzini.Magazzini.AddAsync(model);
|
||||||
|
await _VT_Magazzini.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, model);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, errmsg); ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary> VIRTUAL TASK : modifica magazzino return: ActionResult</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("magazziniVT/mod")]
|
||||||
|
public async Task<ActionResult<MagazziniVT>> modMagazzino([FromBody] MagazziniVT model, string token)
|
||||||
|
{
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
model.Azienda = ten;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var transaction = _VT_Magazzini.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
_VT_Magazzini.Entry(model).State = EntityState.Modified;
|
||||||
|
await _VT_Magazzini.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>VIRTUAL TASK: cancella un magazzino return:ActionResult</summary>
|
||||||
|
[HttpPost]
|
||||||
|
[Route("magazziniVT/del")]
|
||||||
|
public async Task<ActionResult<MagazziniVT>> delMagazzino(string magCodice, string token)
|
||||||
|
{
|
||||||
|
string ten = getClaimValueByToken(token, "tenant2");
|
||||||
|
_magazziniVT = _VT_Magazzini.Magazzini;
|
||||||
|
var art = await _magazziniVT.Where(a => a.Mgcodmag.Equals(magCodice) && a.Azienda.Equals(ten)).ToListAsync();
|
||||||
|
|
||||||
|
MagazziniVT model = art.First();
|
||||||
|
model.DataObso = DateTime.Now;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var transaction = _VT_Magazzini.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
_VT_Magazzini.Entry(model).State = EntityState.Modified;
|
||||||
|
await _VT_Magazzini.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
return StatusCode(StatusCodes.Status200OK, model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string errmsg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Logging
|
#region Logging
|
||||||
|
|||||||
29
ApiPolo/Models/MagazziniVT.cs
Normal file
29
ApiPolo/Models/MagazziniVT.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ApiPolo.Models
|
||||||
|
{
|
||||||
|
public class MagazziniVT
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Azienda
|
||||||
|
/// </summary>
|
||||||
|
[Key]
|
||||||
|
public string? Azienda { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// codice magazzino
|
||||||
|
/// </summary>
|
||||||
|
[Key]
|
||||||
|
public string? Mgcodmag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// descrizione
|
||||||
|
/// </summary>
|
||||||
|
public string? Mgdesmag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// descrizione
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? DataObso { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
25
ApiPolo/Models/VT_dbcontext/VT_MAGAZZINI_DbContext.cs
Normal file
25
ApiPolo/Models/VT_dbcontext/VT_MAGAZZINI_DbContext.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiPolo.Models.VT_dbcontext
|
||||||
|
{
|
||||||
|
public class VT_MAGAZZINI_DbContext :DbContext
|
||||||
|
{
|
||||||
|
public DbSet<MagazziniVT> Magazzini { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public VT_MAGAZZINI_DbContext(DbContextOptions<VT_MAGAZZINI_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<MagazziniVT>().ToTable("MAGAZZINI");
|
||||||
|
modelBuilder.Entity<MagazziniVT>().HasKey(Table => new
|
||||||
|
{
|
||||||
|
Table.Azienda,
|
||||||
|
Table.Mgcodmag
|
||||||
|
}); // Definizione della chiave primaria composta
|
||||||
|
//base.OnModelCreating(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
ApiPolo/Models/VT_dbcontext/VT_MAG_NEW_DbContext.cs
Normal file
25
ApiPolo/Models/VT_dbcontext/VT_MAG_NEW_DbContext.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
|
|
||||||
|
namespace ApiPolo.Models.VT_dbcontext
|
||||||
|
{
|
||||||
|
public class VT_MAG_NEW_DbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<Vt_Mag_New> MagNewVt { get; set; }
|
||||||
|
|
||||||
|
public VT_MAG_NEW_DbContext(DbContextOptions<VT_MAG_NEW_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<Vt_Mag_New>().ToTable("MAG_NEW_VT");
|
||||||
|
modelBuilder.Entity<Vt_Mag_New>()
|
||||||
|
.HasKey(Table => new {
|
||||||
|
Table.Azienda,
|
||||||
|
Table.Seriale_Rapportino,
|
||||||
|
Table.Riga
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
ApiPolo/Models/VT_dbcontext/VT_SALDIART_DbContext.cs
Normal file
19
ApiPolo/Models/VT_dbcontext/VT_SALDIART_DbContext.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using ApiPolo.Models.PMS_dbcontext;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ApiPolo.Models.VT_dbcontext
|
||||||
|
{
|
||||||
|
public class VT_SALDIART_DbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<Articoli>? SaldiArt_VT { get; set; }
|
||||||
|
|
||||||
|
public VT_SALDIART_DbContext(DbContextOptions<VT_SALDIART_DbContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<Articoli>().ToView("API_SALDIART_PREZZI");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
ApiPolo/Models/Vt_Mag_New.cs
Normal file
34
ApiPolo/Models/Vt_Mag_New.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ApiPolo.Models
|
||||||
|
{
|
||||||
|
public class Vt_Mag_New
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Required]
|
||||||
|
public string Azienda { get; set; }
|
||||||
|
[Key]
|
||||||
|
[Required]
|
||||||
|
public string Seriale_Rapportino { get; set; }
|
||||||
|
[Key]
|
||||||
|
[Required]
|
||||||
|
public int Riga { get; set; }
|
||||||
|
public string Magazzino { get; set; }
|
||||||
|
public string Articolo { get; set; }
|
||||||
|
public string Tipo_Movimento { get; set; }
|
||||||
|
public decimal? Quantita { get; set; }
|
||||||
|
public decimal? Prezzo { get; set; }
|
||||||
|
public string Codice_Tecnico { get; set; }
|
||||||
|
public string Generato { get; set; }
|
||||||
|
public string Note { get; set; }
|
||||||
|
public string CodLotto { get; set; }
|
||||||
|
public string Matricola { get; set; }
|
||||||
|
public int? Cprownum { get; set; }
|
||||||
|
public string Desc_Art { get; set; }
|
||||||
|
public string CodImp { get; set; }
|
||||||
|
public string Desc_Sup { get; set; }
|
||||||
|
public string? Cpccchk { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -752,6 +752,16 @@ namespace ApiPolo
|
|||||||
services.AddDbContext<VT_ARTICOLI_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
services.AddDbContext<VT_ARTICOLI_TABLE_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
||||||
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
));
|
));
|
||||||
|
services.AddDbContext<VT_MAG_NEW_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
services.AddDbContext<VT_SALDIART_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
services.AddDbContext<VT_MAGAZZINI_DbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("VIRTUAL_TASK")
|
||||||
|
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||||
|
));
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region LIFT_WEB
|
#region LIFT_WEB
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user