gestione note e selezione giri per data
This commit is contained in:
parent
cb9ce2e0ff
commit
1da535c397
@ -36,6 +36,7 @@ namespace ApiSoftway.Controllers
|
||||
private readonly GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext _daCreareDest_context;
|
||||
private readonly GESA_DESTINAZIONI_WEB_DbContext _destinazioni_web_context;
|
||||
private readonly GESA_GIRI_TESTATE_DbContext _giri_testate_context;
|
||||
private readonly GESA_SBR_ORD_TABLE_DbContext _sbrordTable_context;
|
||||
|
||||
private DbSet<Giri>? _giri;
|
||||
private DbSet<GiriConsegna>? _giriCons;
|
||||
@ -48,11 +49,12 @@ namespace ApiSoftway.Controllers
|
||||
private DbSet<GiriConsegnaDaCreare>? _GiriDaCreare;
|
||||
private DbSet<Consegna_m>? _testate;
|
||||
private DbSet<GiriConsegnaDaCreareDest>? _GiriDaCreareDest;
|
||||
private DbSet<Sbr_ordTable>? _sbrordTable;
|
||||
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_PI_GIRI_SERIALI_DbContext giriseriali_context, GESA_GIRICONSEGNEDACREARE_DESTINAZIONI_DbContext daCreareDest_context
|
||||
, GESA_DESTINAZIONI_WEB_DbContext destinazioni_web_context,GESA_GIRI_TESTATE_DbContext giri_testate_context)
|
||||
, GESA_DESTINAZIONI_WEB_DbContext destinazioni_web_context,GESA_GIRI_TESTATE_DbContext giri_testate_context, GESA_SBR_ORD_TABLE_DbContext sbrordTable_context)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
@ -70,6 +72,7 @@ namespace ApiSoftway.Controllers
|
||||
_daCreareDest_context = daCreareDest_context;
|
||||
_destinazioni_web_context = destinazioni_web_context;
|
||||
_giri_testate_context = giri_testate_context;
|
||||
_sbrordTable_context = sbrordTable_context;
|
||||
}
|
||||
|
||||
[HttpGet("listaGiri")]
|
||||
@ -287,6 +290,72 @@ namespace ApiSoftway.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[Route("addBrogliaccio")]
|
||||
public async Task<ActionResult<string>> addBrogliaccio(string token, DateTime? oldData,DateTime? newData)
|
||||
{
|
||||
string msg = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
string usr = getClaimValueByToken(token, "codice");
|
||||
if (!string.IsNullOrEmpty(usr) && usr.Trim().Equals("TEST"))
|
||||
{
|
||||
//step 1 : prendo gli ultimi 1000 record della tabella SBR_ORD
|
||||
_sbrordTable = _sbrordTable_context.Cons;
|
||||
int tot = _sbrordTable.Count();
|
||||
msg = tot.ToString();
|
||||
|
||||
var bro = await _sbrordTable.Where(t => t.Brdatcar == oldData
|
||||
&& !string.IsNullOrEmpty(t.Brautist.Trim())
|
||||
&& (t.Brqtacol != null && t.Brqtacol > 0
|
||||
|| (t.Brqtavol != null && t.Brqtavol > 0)
|
||||
|| (t.Brcolprev != null && t.Brcolprev > 0)
|
||||
|| (t.Brconspr != null && t.Brconspr > 0)
|
||||
|| (t.Bruovapr != null && t.Bruovapr > 0)
|
||||
|| (t.Brcistpr != null && t.Brcistpr > 0)
|
||||
|| (!string.IsNullOrEmpty(t.Brnote))
|
||||
)
|
||||
).ToListAsync();
|
||||
|
||||
int counter = 0;
|
||||
foreach (Sbr_ordTable d in bro)
|
||||
{
|
||||
string newSerial = getCpccchk(10);
|
||||
d.Brserial = newSerial;
|
||||
d.cpccchk = newSerial;
|
||||
d.Brdatcar = newData;
|
||||
d.BRDATINS = newData != null ? newData.Value.AddDays(-1) : DateTime.Now;
|
||||
d.BRDATVAR = newData != null ? newData.Value.AddDays(-1) : DateTime.Now;
|
||||
d.BRDATSCA = newData;
|
||||
d.Brnote = "*****"+newData.ToString() + d.Brnote;
|
||||
|
||||
using (var transactionDest = _sbrordTable_context.Database.BeginTransaction())
|
||||
{
|
||||
await _sbrordTable_context.Cons.AddAsync(d);
|
||||
await _sbrordTable_context.SaveChangesAsync();
|
||||
transactionDest.Commit();
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
msg = "Inseriti " + counter.ToString() + " record";
|
||||
return StatusCode(StatusCodes.Status200OK, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return StatusCode(StatusCodes.Status200OK, "Impossibile procedere al caricamento. Utente non abilitato all'operazione");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
msg = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("closeGiro")]
|
||||
public async Task<ActionResult<GiriConsegna_out>> closeGiro(string? serialeGiro, int? bancaliRecuperati, decimal? importoRecuperato)
|
||||
@ -475,15 +544,33 @@ namespace ApiSoftway.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
//metodo app
|
||||
[HttpGet("listaDestinazioni")]
|
||||
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioni2(string token)
|
||||
public async Task<ActionResult<IEnumerable<Destinazioni_out>>> listaDestinazioni2(string token,DateTime? dataGiro)
|
||||
{
|
||||
//step 1: ricavo la data a partire dal login
|
||||
DateTime? data;
|
||||
string usr = getClaimValueByToken(token, "codice");
|
||||
_giri = _giri_context.Giri;
|
||||
var g = await _giri.Where(t => t.Brautist != null && t.Brautist.Equals(usr)).OrderByDescending(t => t.Brdatcar).Take(1).ToListAsync();
|
||||
DateTime? data = g.First().Brdatcar;
|
||||
bool btnChiudiVisible = true;
|
||||
bool btnNonChiudiVisible = true;
|
||||
if (dataGiro == null)
|
||||
{
|
||||
//step 1: ricavo la data a partire dal login
|
||||
//_giri = _giri_context.Giri;
|
||||
//var g = await _giri.Where(t => t.Brautist != null && t.Brautist.Equals(usr)).OrderByDescending(t => t.Brdatcar).Take(1).ToListAsync();
|
||||
//data = g.First().Brdatcar;
|
||||
|
||||
data = DateTime.Today;
|
||||
}
|
||||
else
|
||||
{
|
||||
data= dataGiro;
|
||||
if(data!=DateTime.Today)
|
||||
{
|
||||
btnChiudiVisible = false;
|
||||
btnNonChiudiVisible = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<Destinazioni_out> lst = new List<Destinazioni_out>();
|
||||
_destinazioni = _destinazioni_context.Destinazioni;
|
||||
@ -551,6 +638,11 @@ namespace ApiSoftway.Controllers
|
||||
o.Seq = d.Seq;
|
||||
o.Prog = d.Prog;
|
||||
|
||||
//2025-03.19 - flag pulsanti visibili: se data passata = data odierna pulsanti visibili altrimenti no
|
||||
o.BtnChiudiVisible= btnChiudiVisible;
|
||||
o.BtnNonChiudiVisible = btnNonChiudiVisible;
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(d.consFattaSerial))
|
||||
{
|
||||
ConsegnaFatta cf=new ConsegnaFatta();
|
||||
@ -1235,7 +1327,7 @@ namespace ApiSoftway.Controllers
|
||||
r.Pimezzo = i.Pimezzo;
|
||||
r.Piimport= i.Piimport;
|
||||
r.Serial=i.Serial;
|
||||
|
||||
r.Pinotcon = i.Pinotcon;
|
||||
|
||||
|
||||
return r;
|
||||
@ -1278,6 +1370,7 @@ namespace ApiSoftway.Controllers
|
||||
r.Pimezzo = i.Pimezzo;
|
||||
r.Piimport = i.Piimport;
|
||||
r.Serial=i.Serial;
|
||||
r.Pinotcon=i.Pinotcon;
|
||||
|
||||
|
||||
|
||||
@ -1320,7 +1413,7 @@ namespace ApiSoftway.Controllers
|
||||
r.Piconseg = i.Piconseg;
|
||||
r.Pimezzo = i.Pimezzo;
|
||||
r.Piimport = i.Piimport;
|
||||
|
||||
r.Pinotcon = i.Pinotcon;
|
||||
|
||||
|
||||
return r;
|
||||
|
||||
@ -33,5 +33,8 @@ namespace ApiSoftway.Models
|
||||
public decimal? Piimport { get; set; }
|
||||
public string? Pinotimp { get; set; }
|
||||
public string? Pinotban { get; set; }
|
||||
|
||||
//nota consegna (nel caso di consegna non possibile)
|
||||
public string? Pinotcon { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,5 +36,8 @@ namespace ApiSoftway.Models
|
||||
public string? Pinotimp { get; set; }
|
||||
public string? Pinotban { get; set; }
|
||||
public string? Serial { get; set; }
|
||||
|
||||
//nota consegna (nel caso di consegna non possibile)
|
||||
public string? Pinotcon { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,9 @@ namespace ApiSoftway.Models
|
||||
public string? Pinotimp { get; set; }
|
||||
public string? Pinotban { get; set; }
|
||||
|
||||
//nota consegna (nel caso di consegna non possibile)
|
||||
public string? Pinotcon { get; set; }
|
||||
|
||||
public string? Serial { get; set; }
|
||||
|
||||
/// <summary>errore titolo</summary>
|
||||
|
||||
@ -40,6 +40,8 @@ namespace ApiSoftway.Models
|
||||
|
||||
//progressivo- chiave tabella pimodgir
|
||||
public string? Prog { get; set; }
|
||||
public bool? BtnChiudiVisible { get; set; }
|
||||
public bool? BtnNonChiudiVisible { get; set; }
|
||||
}
|
||||
public class ConsegnaFatta
|
||||
{
|
||||
|
||||
23
Models/Gesa_DbContext/GESA_SBR_ORD_TABLE_DbContext.cs
Normal file
23
Models/Gesa_DbContext/GESA_SBR_ORD_TABLE_DbContext.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ApiSoftway.Models.Gesa_DbContext
|
||||
{
|
||||
public class GESA_SBR_ORD_TABLE_DbContext : DbContext
|
||||
{
|
||||
public DbSet<Sbr_ordTable>? Cons { get; set; }
|
||||
|
||||
/// <summary></summary>
|
||||
public GESA_SBR_ORD_TABLE_DbContext(DbContextOptions<GESA_SBR_ORD_TABLE_DbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary></summary>
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Sbr_ordTable>().ToTable("GESASBR_ORD");
|
||||
modelBuilder.Entity<Sbr_ordTable>().HasKey(table => new {
|
||||
table.Brserial
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
131
Models/Sbr_ordTable.cs
Normal file
131
Models/Sbr_ordTable.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ApiSoftway.Models
|
||||
{
|
||||
public class Sbr_ordTable
|
||||
{
|
||||
[Key]
|
||||
public string? Brserial { get; set; }
|
||||
public string? Brcodcom { get; set; }
|
||||
public string? Brclifat { get; set; }
|
||||
public int? Brnumseq { get; set; }
|
||||
public string? Brcodsed { get; set; }
|
||||
public DateTime? Brdatcar { get; set; }
|
||||
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? Brqtacol { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? Brqtavol { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? Brcolprev { get; set; }
|
||||
public int? Brconspr { get; set; }
|
||||
public int? Bruovapr { get; set; }
|
||||
public int? Brcistpr { get; set; }
|
||||
public string? Brnote { get; set; }
|
||||
//BRTARTRA,BRAUTIST, CATNOME, CAUDESC
|
||||
public string? Brtartra { get; set; }
|
||||
public string? Brautist { get; set; }
|
||||
|
||||
public string? BRTIPORD { get; set; }
|
||||
public int? BRORACAR { get; set; }
|
||||
public string? BRCARPRI { get; set; }
|
||||
public string? BRTARRIM { get; set; }
|
||||
public int? BRUTEINS { get; set; }
|
||||
public DateTime? BRDATINS { get; set; }
|
||||
public int? BRUTEVAR { get; set; }
|
||||
public DateTime? BRDATVAR { get; set; }
|
||||
public int? BRNUMERO { get; set; }
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? BRQTAPES { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? BRQTAKM { get; set; }
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? BRIMPFOR { get; set; }
|
||||
public string? BRMERCE { get; set; }
|
||||
|
||||
public DateTime? BRDATSCA { get; set; }
|
||||
public int? BRORASCA { get; set; }
|
||||
public string? BRSCAPRI { get; set; }
|
||||
public int? BRPALLET { get; set; }
|
||||
public int? BRNUMBOL { get; set; }
|
||||
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? BRPESEFF { get; set; }
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? BRCOLEFF { get; set; }
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? BRVOLEFF { get; set; }
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? BRKMEFF { get; set; }
|
||||
|
||||
|
||||
|
||||
//,[BRESERCI]
|
||||
|
||||
//,[BRQTAVOL]
|
||||
//,[BRQTACOL]
|
||||
|
||||
//,[BRRIFORD]null
|
||||
|
||||
|
||||
//,[BRDATBOL]null
|
||||
|
||||
//,[BRCODCTR] null
|
||||
//,[BRRIGCTR]null
|
||||
//,[BRCLIFAT]null
|
||||
//,[BRCODESI]null
|
||||
|
||||
public string? BRTIPCLI { get; set; }
|
||||
|
||||
public string? cpccchk { get; set; }
|
||||
public string? BRDESSEDE { get; set; }
|
||||
//,[]
|
||||
|
||||
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(18, 4)")]
|
||||
public decimal? BRPEDEF { get; set; }
|
||||
|
||||
public int? BRCONSEF { get; set; }
|
||||
|
||||
//,[BRSERBOL]null
|
||||
|
||||
|
||||
public int? BRUOVAEF { get; set; }
|
||||
public int? BRCISTEF { get; set; }
|
||||
|
||||
public string? BRTEST { get; set; }
|
||||
|
||||
public string? BRCOSAUT { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(6, 2)")]
|
||||
public decimal? BRPERAUT { get; set; }
|
||||
//,[BRCOSBIL]null
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(6, 2)")]
|
||||
public decimal? BRPERBIL { get; set; }
|
||||
|
||||
public string? BRCOSSTR { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(6, 2)")]
|
||||
public decimal? BRPERSTR { get; set; }
|
||||
|
||||
public string? BRCOSPED { get; set; }
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(6, 2)")]
|
||||
public decimal? BRPERPED { get; set; }
|
||||
//,[BRCHKBIL]
|
||||
public string? BRCHKBIL { get; set; }
|
||||
//,[BRAUTBIL]null
|
||||
|
||||
public int? BRSEQUE { get; set; }
|
||||
//,[PISERGIR]null
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -67,6 +67,9 @@ builder.Services.AddDbContext<GESA_DESTINAZIONI_WEB_DbContext>(options => option
|
||||
builder.Services.AddDbContext<GESA_GIRI_TESTATE_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||
));
|
||||
builder.Services.AddDbContext<GESA_SBR_ORD_TABLE_DbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("GESA")
|
||||
, options => { options.CommandTimeout(commandTimeoutInSeconds); }
|
||||
));
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user