pre passaggio git

This commit is contained in:
Marco Audiffredi 2024-10-31 14:35:11 +01:00
parent b157f50921
commit 11d4700c01
10 changed files with 347 additions and 55 deletions

View File

@ -31,6 +31,9 @@ namespace ApiSoftway.Controllers
private readonly IConfiguration? _configuration;
private readonly GESA_GIRICONSEGNEDACREARE_DbContext _daCreare_context;
private readonly GESA_CONSEGNE_M_DbContext _consegne_m_context;
private readonly GESA_PI_GIRI_SERIALI_DbContext _giriseriali_context;
private readonly GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext _daCreareDest_context;
private readonly GESA_DESTINAZIONI_WEB_DbContext _destinazioni_web_context;
private DbSet<Giri>? _giri;
private DbSet<GiriConsegna>? _giriCons;
@ -42,10 +45,12 @@ namespace ApiSoftway.Controllers
private DbSet<Automezzi>? _automezzi;
private DbSet<GiriConsegnaDaCreare>? _GiriDaCreare;
private DbSet<Consegna_m>? _testate;
private DbSet<GiriConsegnaDaCreareDest>? _GiriDaCreareDest;
public GiriController(ILogger<LoginController> logger, IConfiguration? configuration, GESA_GIRI_DbContext giri_context, GESA_DESTINAZIONI_DbContext destinazioni_context
, GESA_CONSEGNE_DbContext consegne_context, GESA_GIRICONSEGNE_DbContext giricons_context, GESA_GIRICONSEGNEVISTA_DbContext consegnevista_context, GESA_SBR_ORD_DbContext sbrord_context
, GESA_PERSONALE_DbContext personale_context, GESA_AUTOMEZZI_DbContext automezzi_context, GESA_GIRICONSEGNEDACREARE_DbContext daCreare_context
, GESA_CONSEGNE_M_DbContext consegne_m_context)
, GESA_CONSEGNE_M_DbContext consegne_m_context, GESA_PI_GIRI_SERIALI_DbContext giriseriali_context, GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext daCreareDest_context
, GESA_DESTINAZIONI_WEB_DbContext destinazioni_web_context)
{
_logger = logger;
_configuration = configuration;
@ -59,6 +64,9 @@ namespace ApiSoftway.Controllers
_automezzi_context = automezzi_context;
_daCreare_context = daCreare_context;
_consegne_m_context = consegne_m_context;
_giriseriali_context = giriseriali_context;
_daCreareDest_context = daCreareDest_context;
_destinazioni_web_context = destinazioni_web_context;
}
[HttpGet("listaGiri")]
@ -211,13 +219,34 @@ namespace ApiSoftway.Controllers
}
//step 3 aggiorno con il seriale le righe delle destinazioni
_destinazioni = _destinazioni_context.Destinazioni;
var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(model.CodAutista)
&& t.DataCarico != null && t.DataCarico == model.DataGiro
&& t.serialeGiro == null
&& t.CodAutomezzo!=null && t.CodAutomezzo.Equals(model.CodMezzo)).OrderByDescending(t => t.DataCarico).ToListAsync();
//_destinazioni = _destinazioni_context.Destinazioni;
//var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(model.CodAutista)
//&& t.DataCarico != null && t.DataCarico == model.DataGiro
////&& t.serialeGiro == null
//&& t.CodAutomezzo!=null && t.CodAutomezzo.Equals(model.CodMezzo)).OrderByDescending(t => t.DataCarico).ToListAsync();
_destinazioni = _daCreareDest_context.GiriDaCreare;
var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(model.CodAutista)
&& t.DataCarico != null && t.DataCarico == model.DataGiro
//&& t.serialeGiro == null
&& t.CodAutomezzo != null && t.CodAutomezzo.Equals(model.CodMezzo)).OrderByDescending(t => t.DataCarico).ToListAsync();
foreach (Destinazioni d in dest)
{
//20241018: cambiato sistema inserisco in tabella di raccordo GESAPI_GIRI_SERIALI
GiriSeriali g =new GiriSeriali();
g.Brserial = d.Brserial;
g.Pisergir = newSer;
using (var transactionDest = _giriseriali_context.Database.BeginTransaction())
{
await _giriseriali_context.Cons.AddAsync(g);
await _giriseriali_context.SaveChangesAsync();
transactionDest.Commit();
}
/*
Sbr_ord sbr_Ord = new Sbr_ord();
sbr_Ord.Brserial = d.Brserial;
sbr_Ord.Pisergir = newSer;
@ -231,6 +260,7 @@ namespace ApiSoftway.Controllers
await _sbrord_context.SaveChangesAsync();
transactionDest.Commit();
}
*/
}
var giro = await _giriConsView.Where(t => t.SerialeGiro.Equals(newSer)).ToListAsync();
@ -447,6 +477,7 @@ namespace ApiSoftway.Controllers
_destinazioni = _destinazioni_context.Destinazioni;
var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(usr) && t.DataCarico != null && t.DataCarico == data
&& !string.IsNullOrEmpty(t.serialeGiro)
).OrderBy(t => t.serialeGiro).ToListAsync();
@ -613,6 +644,176 @@ namespace ApiSoftway.Controllers
return lst;
}
[HttpGet("listaDestinazioniByAutistaDataMezzoWeb")]
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioniByAutistaDataWeb(string autista, DateTime? dataGiro, string mezzo)
{
List<Destinazioni_out> lst = new List<Destinazioni_out>();
_destinazioni = _destinazioni_web_context.Destinazioni;
var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == dataGiro && t.CodAutomezzo != null && t.CodAutomezzo.Equals(mezzo)).OrderByDescending(t => t.DataCarico).ThenBy(t => t.Seq).ToListAsync();
foreach (Destinazioni d in r)
{
Destinazioni_out o = new Destinazioni_out();
string _aut = !string.IsNullOrEmpty(d.Autista) ? d.Autista.Trim() : string.Empty;
o.Autista = _aut;
string _autCod = !string.IsNullOrEmpty(d.CodAutista) ? d.CodAutista.Trim() : string.Empty;
o.CodAutista = _autCod;
string _automezzo = !string.IsNullOrEmpty(d.DescAutomezzo) ? d.DescAutomezzo.Trim() : string.Empty;
o.DescAutomezzo = _automezzo;
string _automezzoCod = !string.IsNullOrEmpty(d.CodAutomezzo) ? d.CodAutomezzo.Trim() : string.Empty;
o.CodAutomezzo = d.CodAutomezzo;
o.DataCarico = d.DataCarico;
o.Brserial = d.Brserial;
o.Brmerce = d.Brmerce;
o.Brnote = d.Brnote;
o.Cproword = d.Cproword;
o.Cprownum = d.Cprownum;
string _sedeInd = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty;
o.IndirizzoSede = _sedeInd;
string _sede = !string.IsNullOrEmpty(d.Sede) ? d.Sede.Trim() : string.Empty;
o.Sede = _sede;
o.CodCommittente = d.CodCommittente;
string _committente = !string.IsNullOrEmpty(d.Committente) ? d.Committente.Trim() : string.Empty;
o.Committente = _committente;
o.CodSede = d.CodSede;
o.ItemList = formattaDestinazione(d);
o.ImportoDaRitirare = d.ImportoDaRitirare;
o.serialeGiro = d.serialeGiro;
o.Casse = d.Casse;
o.Trasf = d.Trasf;
o.Colli = d.Colli;
o.num_cons = d.num_cons;
o.Uova = d.Uova;
o.Cist = d.Cist;
o.Note = d.Note;
o.Seq = d.Seq;
o.Prog = d.Prog;
if (!string.IsNullOrEmpty(d.consFattaSerial))
{
ConsegnaFatta cf = new ConsegnaFatta();
cf.consFattaSerial = d.consFattaSerial;
cf.consFattaRow = d.consFattaRow;
cf.consFattaAut = d.consFattaAut;
cf.consFattaBanSca = d.consFattaBanSca;
cf.consFattaBanCar = d.consFattaBanCar;
string nota = !string.IsNullOrEmpty(d.consFattaNotBan) ? d.consFattaNotBan.Trim() : string.Empty;
cf.consFattaNotBan = nota;
cf.consFattaImpor = d.consFattaImpor;
cf.consFattaMezzo = d.consFattaMezzo;
string nota2 = !string.IsNullOrEmpty(d.consFattaNotImp) ? d.consFattaNotImp.Trim() : string.Empty;
cf.consFattaNotImp = nota2;
cf.consFattaFlagCons = d.consFattaFlagCons;
cf.consFattaDataOra = d.consFattaDataOra;
o.ConsFatta = cf;
}
lst.Add(o);
}
return lst;
}
[HttpGet("listaDestinazioniByAutistaDataMezzoNonValidate")]
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioniByAutistaDataMezzoNonValidate(string autista, DateTime? dataGiro, string mezzo)
{
List<Destinazioni_out> lst = new List<Destinazioni_out>();
//_destinazioni = _destinazioni_context.Destinazioni;
//var r = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista) && t.DataCarico != null && t.DataCarico == dataGiro && t.CodAutomezzo != null && t.CodAutomezzo.Equals(mezzo)).OrderByDescending(t => t.DataCarico).ThenBy(t => t.Seq).ToListAsync();
_destinazioni = _daCreareDest_context.GiriDaCreare;
var dest = await _destinazioni.Where(t => t.CodAutista != null && t.CodAutista.Equals(autista)
&& t.DataCarico != null && t.DataCarico == dataGiro
//&& t.serialeGiro == null
&& t.CodAutomezzo != null && t.CodAutomezzo.Equals(mezzo)).OrderByDescending(t => t.DataCarico).ToListAsync();
foreach (Destinazioni d in dest)
{
Destinazioni_out o = new Destinazioni_out();
string _aut = !string.IsNullOrEmpty(d.Autista) ? d.Autista.Trim() : string.Empty;
o.Autista = _aut;
string _autCod = !string.IsNullOrEmpty(d.CodAutista) ? d.CodAutista.Trim() : string.Empty;
o.CodAutista = _autCod;
string _automezzo = !string.IsNullOrEmpty(d.DescAutomezzo) ? d.DescAutomezzo.Trim() : string.Empty;
o.DescAutomezzo = _automezzo;
string _automezzoCod = !string.IsNullOrEmpty(d.CodAutomezzo) ? d.CodAutomezzo.Trim() : string.Empty;
o.CodAutomezzo = _automezzoCod;
o.DataCarico = d.DataCarico;
o.Brserial = d.Brserial;
//step 1: leggo da sbr_ord con seriale
o.Brmerce = d.Brmerce;
o.Brnote = d.Brnote;
o.Cproword = d.Cproword;
o.Cprownum = d.Cprownum;
string _sedeInd = !string.IsNullOrEmpty(d.IndirizzoSede) ? d.IndirizzoSede.Trim() : string.Empty;
o.IndirizzoSede = _sedeInd;
string _sede = !string.IsNullOrEmpty(d.Sede) ? d.Sede.Trim() : string.Empty;
o.Sede = _sede;
o.CodCommittente = d.CodCommittente;
string _committente = !string.IsNullOrEmpty(d.Committente) ? d.Committente.Trim() : string.Empty;
o.Committente = _committente;
o.CodSede = d.CodSede;
o.ItemList = formattaDestinazione(d);
o.ImportoDaRitirare = d.ImportoDaRitirare;
o.serialeGiro = d.serialeGiro;
o.Casse = d.Casse;
o.Trasf = d.Trasf;
o.Colli = d.Colli;
o.num_cons = d.num_cons;
o.Uova = d.Uova;
o.Cist = d.Cist;
o.Note = d.Note;
o.Seq = d.Seq;
o.Prog = d.Prog;
if (!string.IsNullOrEmpty(d.consFattaSerial))
{
ConsegnaFatta cf = new ConsegnaFatta();
cf.consFattaSerial = d.consFattaSerial;
cf.consFattaRow = d.consFattaRow;
cf.consFattaAut = d.consFattaAut;
cf.consFattaBanSca = d.consFattaBanSca;
cf.consFattaBanCar = d.consFattaBanCar;
string nota = !string.IsNullOrEmpty(d.consFattaNotBan) ? d.consFattaNotBan.Trim() : string.Empty;
cf.consFattaNotBan = nota;
cf.consFattaImpor = d.consFattaImpor;
cf.consFattaMezzo = d.consFattaMezzo;
string nota2 = !string.IsNullOrEmpty(d.consFattaNotImp) ? d.consFattaNotImp.Trim() : string.Empty;
cf.consFattaNotImp = nota2;
cf.consFattaFlagCons = d.consFattaFlagCons;
cf.consFattaDataOra = d.consFattaDataOra;
o.ConsFatta = cf;
}
lst.Add(o);
}
return lst;
}
[HttpGet("listaDestinazioneBySerial")]
public async Task<ActionResult<Destinazioni_out>> listaDestinazioneBySerial(string seriale)
{
@ -709,32 +910,17 @@ namespace ApiSoftway.Controllers
DateTime dateTime = DateTime.Now;
ConsegnaTable t = fillConsegna(model, token, dateTime);
/*
//Step 1: mi calcolo il nuovo seriale
_consegne = _consegne_context.Cons;
var ser = await _consegne.Take(1).OrderByDescending(t => t.Pisergir).ToListAsync();
string ultSer = "0";
if (ser != null && ser.Count > 0)
{
ultSer = ser.First().Pisergir;
}
string newSer = calcolaNuovoSeriale(ultSer);
t.Pisergir = newSer;
*/
//Step 1: il seriale è quello della PIGIRCON che ho scritto nelle righe di SBR_ORD
// lo leggo da li passando il seriale della destinazione. contemporaneamente mi ricavo anche gli altri valori
//Step 1: il seriale è quello della GESAPI_GIRI_SERIALI che ho scritto in validazione
// lo leggo dalle destinazioni filtrando per il seriale della destinazione. contemporaneamente mi ricavo anche gli altri valori
//che devo scrivere successivamente
_destinazioni = _destinazioni_context.Destinazioni;
var ti = await _destinazioni.Where(t => t.Brserial.Equals(model.Serial)).FirstAsync();
_sbrord = _sbrord_context.Cons;
var ti = await _sbrord.Where(t => t.Brserial.Equals(model.Serial)).FirstAsync();
string _committente = ti.Brcodcom;
string _cliFatturazione = ti.Brclifat;
string _codSede = ti.Brcodsed;
string _pisergir = ti.Pisergir;
int _seque = ti.Brnumseq.Value;
string _committente = ti.CodCommittente;
string _cliFatturazione = ti.CliFatt;
string _codSede = ti.CodSede;
string _pisergir = ti.serialeGiro;
int _seque = ti.Seq.Value;
t.Cca = _committente;
t.Ccda=_cliFatturazione;
t.Cprownum = _seque;
@ -804,29 +990,17 @@ namespace ApiSoftway.Controllers
DateTime dateTime = DateTime.Now;
ConsegnaTable t = fillConsegnaNonEffettuata(model, token);
////Step 1: mi calcolo il nuovo seriale
//_consegne = _consegne_context.Cons;
//var ser = await _consegne.Take(1).OrderByDescending(t => t.Pisergir).ToListAsync();
//string ultSer = "0";
//if (ser != null && ser.Count > 0)
//{
// ultSer = ser.First().Pisergir;
//}
//string newSer = calcolaNuovoSeriale(ultSer);
//t.Pisergir = newSer;
//Step 1: il seriale è quello della PIGIRCON che ho scritto nelle righe di SBR_ORD
// lo leggo da li passando il seriale della destinazione. contemporaneamente mi ricavo anche gli altri valori
//Step 1: il seriale è quello della GESAPI_GIRI_SERIALI che ho scritto in validazione
// lo leggo dalle destinazioni filtrando per il seriale della destinazione. contemporaneamente mi ricavo anche gli altri valori
//che devo scrivere successivamente
_destinazioni = _destinazioni_context.Destinazioni;
var ti = await _destinazioni.Where(t => t.Brserial.Equals(model.Serial)).FirstAsync();
_sbrord = _sbrord_context.Cons;
var ti = await _sbrord.Where(t => t.Brserial.Equals(model.Serial)).FirstAsync();
string _committente = ti.Brcodcom;
string _cliFatturazione = ti.Brclifat;
string _codSede = ti.Brcodsed;
string _pisergir = ti.Pisergir;
int _seque = ti.Brnumseq.Value;
string _committente = ti.CodCommittente;
string _cliFatturazione = ti.CliFatt;
string _codSede = ti.CodSede;
string _pisergir = ti.serialeGiro;
int _seque = ti.Seq.Value;
t.Cca = _committente;
t.Ccda = _cliFatturazione;
t.Cprownum = _seque;

View File

@ -54,5 +54,9 @@ namespace ApiSoftway.Models
//progressivo- chiave tabella pimodgir
public string? Prog { get; set; }
public string? CliFatt { get; set; }
public int? BancaliIniziali { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
namespace ApiSoftway.Models.Gesa_DbContext
{
public class GESA_DESTINAZIONI_WEB_DbContext : DbContext
{
public DbSet<Destinazioni>? Destinazioni { get; set; }
public GESA_DESTINAZIONI_WEB_DbContext(DbContextOptions<GESA_DESTINAZIONI_WEB_DbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Destinazioni>().ToView("API_DESTINAZIONI_WEB");
}
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
namespace ApiSoftway.Models.Gesa_DbContext
{
public class GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext:DbContext
{
public DbSet<Destinazioni>? GiriDaCreare { get; set; }
public GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext(DbContextOptions<GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Destinazioni>().ToView("API_GIRICONSEGNA_DA_CREARE_DESTINAZIONI");
}
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
namespace ApiSoftway.Models.Gesa_DbContext
{
public class GESA_PI_GIRI_SERIALI_DbContext:DbContext
{
public DbSet<GiriSeriali>? Cons { get; set; }
/// <summary></summary>
public GESA_PI_GIRI_SERIALI_DbContext(DbContextOptions<GESA_PI_GIRI_SERIALI_DbContext> options) : base(options)
{
}
/// <summary></summary>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<GiriSeriali>().ToTable("GESAPI_GIRI_SERIALI");
modelBuilder.Entity<GiriSeriali>().HasKey(table => new {
table.Brserial,table.Pisergir
});
}
}
}

View File

@ -10,5 +10,6 @@ namespace ApiSoftway.Models
public string? Autista { get; set; }
public string? Automezzo { get; set; }
public DateTime? DataGiro { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore;
namespace ApiSoftway.Models
{
[Keyless]
public class GiriConsegnaDaCreareDest
{
public string? CodMezzo { get; set; }
public string? CodAutista { get; set; }
public string? Autista { get; set; }
public string? Automezzo { get; set; }
public DateTime? DataGiro { get; set; }
public string? Seriale { get; set; }
}
}

13
Models/GiriSeriali.cs Normal file
View File

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace ApiSoftway.Models
{
public class GiriSeriali
{
[Key]
public string? Brserial { get; set; }
[Key]
public string? Pisergir { get; set; }
}
}

View File

@ -2,6 +2,7 @@ using ApiSoftway.Models.Gesa_DbContext;
using ApiSoftway.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
@ -54,13 +55,40 @@ builder.Services.AddDbContext<GESA_CONSEGNE_M_DbContext>(options => options.UseS
builder.Services.AddDbContext<GESA_SEDECONSEGNA_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_PI_GIRI_SERIALI_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
builder.Services.AddDbContext<GESA_DESTINAZIONI_WEB_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
));
#endregion
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(gen =>
{
gen.ResolveConflictingActions(apiDescription => apiDescription.First());
//gen.SwaggerDoc("v1", new OpenApiInfo { Title = "POLO API WS2016", Version = "v3.3" });
DateTime oggi = DateTime.Now;
string dt = oggi.ToString();
gen.SwaggerDoc("v1", new OpenApiInfo { Title = "GESA API - v.app 1.1", Version = dt });
});
builder.Services.AddLogging(opt =>
{
opt.AddConsole(c =>
{
c.TimestampFormat = "[yyyy-MM-dd HH:mm:ss] ";
});
});
var app = builder.Build();
@ -71,8 +99,8 @@ if (app.Environment.IsDevelopment() || app.Environment.IsProduction())
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
//app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.MapControllers();

View File

@ -9,7 +9,7 @@
"ConnectionStrings": {
"GESA": "Data Source=172.25.30.152;Initial Catalog=AHRGESA_old;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
"GESA": "Data Source=172.25.30.152;Initial Catalog=AHRGESA_20241016;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
//"GESA": "Data Source=windowstest.polo;Initial Catalog=AHRGESA;User Id=sa; Password=p0l01nf.;Integrated Security=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
},
"JWT": {