Merge branch 'master' into feature/RefactoringGestioneColli
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
# Conflicts: # ems-engine/src/main/java/it/integry/ems/retail/wms/generic/service/WMSArticoloService.java
This commit is contained in:
@@ -155,6 +155,11 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
UtilityDB.createIndex(connection, indexTableDTO);
|
||||
}
|
||||
|
||||
|
||||
protected void cloneTable(String sourceTable, String newTable,boolean fillNewTable, boolean dropOldTable, boolean renameNewTable) throws Exception {
|
||||
UtilityDB.cloneTable(connection, sourceTable, newTable, fillNewTable, dropOldTable, renameNewTable);
|
||||
}
|
||||
|
||||
protected void dropIndex(String tableName, String indexName) throws Exception {
|
||||
UtilityDB.dropIndex(connection, tableName, indexName);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,20 @@ public class Migration_20250929172222 extends BaseMigration implements Migration
|
||||
dropIndex("stb_activity", "ix_stb_activity_alarm");
|
||||
|
||||
executeStatement(
|
||||
"UPDATE stb_activity\n" +
|
||||
"SET\n" +
|
||||
" estimated_time = ISNULL(estimated_time, estimated_date),\n" +
|
||||
" estimated_endtime = ISNULL(estimated_endtime, estimated_enddate),\n" +
|
||||
" effective_time = ISNULL(effective_time, effective_date),\n" +
|
||||
" effective_endtime = ISNULL(effective_endtime, effective_enddate),\n" +
|
||||
" alarm_time = ISNULL(alarm_time, alarm_date)\n" +
|
||||
"WHERE(\n" +
|
||||
" estimated_time IS NULL\n" +
|
||||
" OR estimated_endtime IS NULL\n" +
|
||||
" OR effective_time IS NULL\n" +
|
||||
" OR effective_endtime IS NULL\n" +
|
||||
" OR alarm_time IS NULL\n" +
|
||||
" );\n",
|
||||
"alter table stb_activity drop column data_ins_act ",
|
||||
"alter table stb_activity drop column estimated_date ",
|
||||
"alter table stb_activity drop column alarm_date ",
|
||||
|
||||
@@ -11,6 +11,9 @@ public class Migration_20251002154118 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Carelli_Winact)) {
|
||||
executeStatement(
|
||||
"ALTER TABLE mtb_aart\n" +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251006171357 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -11,7 +11,7 @@ public class Migration_20251006171357 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Biolevante)) return;
|
||||
if (!isCustomerDb(IntegryCustomerDB.Biolevante_Biolevante)) return;
|
||||
createOrUpdateView("mvw_TracciabRintracciabProd", "CREATE view [dbo].[mvw_TracciabRintracciabProd] as\n" +
|
||||
"SELECT produzioni.cod_mart AS idart,\n" +
|
||||
" produzioni.partita_mag AS idlotto,\n" +
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251013091105 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("f_calcScad", "CREATE FUNCTION [dbo].[f_calcScad](@dataIniz DateTime,@codPaga varchar(5), @imponibile numeric(20,5), @imposta numeric(20,5)) \n" +
|
||||
"RETURNS @dateScad TABLE (numRata int, dataScad DateTime, impScad numeric(20,5) ) AS \n" +
|
||||
"\n" +
|
||||
"begin\n" +
|
||||
"\n" +
|
||||
" Declare @ldt_dataInizCalc datetime;\n" +
|
||||
" Declare @li_ggPrimaRata int;\n" +
|
||||
" Declare @li_ggTraRate int;\n" +
|
||||
" Declare @li_numRate int;\n" +
|
||||
" Declare @li_CountRata int; \n" +
|
||||
" Declare @addDay int;\n" +
|
||||
" Declare @lc_impRata numeric(20,5);\n" +
|
||||
" Declare @lc_impPrimaRata numeric(20,5);\n" +
|
||||
" Declare @lc_approssimazione numeric(20,5);\n" +
|
||||
" Declare @ls_ivaPrimaRata varchar(20);\n" +
|
||||
" Declare @ls_dataRif varchar(20);\n" +
|
||||
" \n" +
|
||||
" SELECT @li_CountRata = 2;\n" +
|
||||
" \n" +
|
||||
" SELECT @li_ggPrimaRata = gtb_paga.gg_prima_rata, \n" +
|
||||
" @li_ggTraRate = gtb_paga.gg_tra_rate,\n" +
|
||||
" @ls_ivaPrimaRata = Iva_prima_rata,\n" +
|
||||
" @ls_dataRif = gtb_paga.data_rif, \n" +
|
||||
" @li_numRate = gtb_paga.num_rate\n" +
|
||||
" FROM gtb_paga\n" +
|
||||
" WHERE gtb_paga.cod_paga = @codPaga;\n" +
|
||||
" \n" +
|
||||
" IF @li_numRate > 0 \n" +
|
||||
" begin\n" +
|
||||
" IF @ls_ivaPrimaRata = 'PRIMA RATA SOLO IVA'\n" +
|
||||
" begin\n" +
|
||||
" Select @lc_impRata = round(@imponibile/(@li_numRate - 1),2)\n" +
|
||||
" Select @lc_impPrimaRata = @imposta\n" +
|
||||
" end\n" +
|
||||
" else\n" +
|
||||
" begin\n" +
|
||||
" if @ls_ivaPrimaRata = 'SULLA PRIMA RATA'\n" +
|
||||
" begin\n" +
|
||||
" Select @lc_impRata = round(@imponibile/@li_numRate,2)\n" +
|
||||
" Select @lc_impPrimaRata = @lc_impRata + @imposta\n" +
|
||||
" end\n" +
|
||||
" else\n" +
|
||||
" begin\n" +
|
||||
" Select @lc_impRata = round((@imponibile + @imposta) /@li_numRate,2)\n" +
|
||||
" Select @lc_impPrimaRata = @lc_impRata \n" +
|
||||
" end\n" +
|
||||
" end\n" +
|
||||
" end\n" +
|
||||
" \n" +
|
||||
" SELECT @ldt_dataInizCalc = @dataIniz\n" +
|
||||
" \n" +
|
||||
" IF left(@ls_dataRif, 9) = 'FINE MESE'\n" +
|
||||
" begin\n" +
|
||||
" IF MONTH( @dataIniz ) = 12\n" +
|
||||
" begin\n" +
|
||||
" SELECT @ldt_dataInizCalc = DATEADD(day, -1, \n" +
|
||||
" CONVERT(datetime, \n" +
|
||||
" Convert(varchar(4),Convert(int, year( @dataIniz ) + 1 )) \n" +
|
||||
" + '-' + Convert( varchar(2), 1)\n" +
|
||||
" + '-' + Convert( varchar(2),1), 121))\n" +
|
||||
" end \n" +
|
||||
" ELSE\n" +
|
||||
" begin\n" +
|
||||
" SELECT @ldt_dataInizCalc = DATEADD(day, -1, \n" +
|
||||
" CONVERT(datetime, \n" +
|
||||
" Convert(varchar(4),Convert(int, year( @dataIniz ))) \n" +
|
||||
" + '-' + Convert( varchar(2), (MONTH( @dataIniz ) + 1))\n" +
|
||||
" + '-' + Convert( varchar(2),1), 121))\n" +
|
||||
" end\n" +
|
||||
" end \n" +
|
||||
" \n" +
|
||||
" \n" +
|
||||
" IF @li_ggPrimaRata > 0 \n" +
|
||||
" begin\n" +
|
||||
" select @ldt_dataInizCalc = dbo.f_aggiungiGiorniScad(@ldt_dataInizCalc, @li_ggPrimaRata, @ls_dataRif )\n" +
|
||||
" Insert into @dateScad values (1, @ldt_dataInizCalc, @lc_impPrimaRata)\n" +
|
||||
" end \n" +
|
||||
" ELSE\n" +
|
||||
" begin\n" +
|
||||
" Insert into @dateScad values (1, @ldt_dataInizCalc, @lc_impPrimaRata)\n" +
|
||||
" end\n" +
|
||||
"\n" +
|
||||
" WHILE @li_CountRata <= @li_numRate \n" +
|
||||
" begin\n" +
|
||||
" select @ldt_dataInizCalc = dbo.f_aggiungiGiorniScad(@ldt_dataInizCalc,@li_ggTraRate, @ls_dataRif )\n" +
|
||||
"\n" +
|
||||
" Insert into @dateScad values (@li_CountRata, @ldt_dataInizCalc, @lc_impRata)\n" +
|
||||
" SELECT @li_CountRata = @li_CountRata + 1\n" +
|
||||
" end \n" +
|
||||
" \n" +
|
||||
" /*** Calcolo eventuale residuo di approssimazione da imputare sull'ultima rata ***/\n" +
|
||||
" Select @lc_approssimazione = @lc_impRata * (@li_numRate - 1) + @lc_impPrimaRata - (@imponibile + @imposta)\n" +
|
||||
" IF @lc_approssimazione <> 0 \n" +
|
||||
" begin\n" +
|
||||
" Update @dateScad set impScad = impScad-@lc_approssimazione\n" +
|
||||
" WHERE numRata = @li_numRate\n" +
|
||||
" end\n" +
|
||||
" \n" +
|
||||
" Select @li_CountRata = 1\n" +
|
||||
" Select @addDay = 0\n" +
|
||||
" WHILE @li_CountRata <= @li_numRate \n" +
|
||||
" begin \n" +
|
||||
" IF @ls_dataRif = 'FINE MESE+1GG' \n" +
|
||||
" SELECT @addDay = 1\n" +
|
||||
" IF @ls_dataRif = 'FINE MESE+5GG' \n" +
|
||||
" SELECT @addDay = 5\n" +
|
||||
" IF @ls_dataRif = 'FINE MESE+10GG' \n" +
|
||||
" SELECT @addDay = 10\n" +
|
||||
" \n" +
|
||||
" IF @addDay > 0\n" +
|
||||
" begin \n" +
|
||||
" Update @dateScad set dataScad = DATEADD(day, @addDay , dataScad)\n" +
|
||||
" WHERE numRata = @li_CountRata\n" +
|
||||
" end \n" +
|
||||
" SELECT @li_CountRata = @li_CountRata + 1\n" +
|
||||
" end\n" +
|
||||
"\n" +
|
||||
" return\n" +
|
||||
"end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251013174133 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Carelli)) return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Carelli_Format)) return;
|
||||
|
||||
createOrUpdateView("avw_last_acq_lotto_w"
|
||||
, "CREATE VIEW avw_last_acq_lotto_w WITH SCHEMABINDING AS\n" +
|
||||
" SELECT wdtb_doct.data_reg,\n" +
|
||||
" cod_mart,\n" +
|
||||
" wdtb_docr.partita_mag,\n" +
|
||||
" wdtb_doct.cod_mdep,\n" +
|
||||
" wdtb_doct.data_ins,\n" +
|
||||
" mtb_depo.cod_vlis,\n" +
|
||||
" wdtb_docr.id_riga\n" +
|
||||
" FROM dbo.wdtb_doct\n" +
|
||||
" INNER JOIN dbo.wdtb_docr ON wdtb_doct.cod_anag = wdtb_docr.cod_anag AND\n" +
|
||||
" wdtb_doct.cod_dtip = wdtb_docr.cod_dtip AND\n" +
|
||||
" wdtb_doct.data_doc = wdtb_docr.data_doc AND\n" +
|
||||
" wdtb_doct.ser_doc = wdtb_docr.ser_doc AND\n" +
|
||||
" wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" inner join dbo.mtb_depo on mtb_depo.cod_mdep = wdtb_doct.cod_mdep\n" +
|
||||
" WHERE wdtb_docr.partita_mag IS NOT NULL");
|
||||
|
||||
executeStatement("CREATE UNIQUE CLUSTERED INDEX [IDX_CLUSTERED_avw_last_acq_lotto_w] ON [dbo].avw_last_acq_lotto_w\n" +
|
||||
" (\n" +
|
||||
" data_reg,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" data_ins,\n" +
|
||||
" id_riga\n" +
|
||||
" )",
|
||||
"CREATE NONCLUSTERED INDEX ix_avw_last_acq_lotto_w_2\n" +
|
||||
" ON [dbo].[avw_last_acq_lotto_w] ([cod_mart],[cod_mdep],[data_reg])\n" +
|
||||
" INCLUDE ([data_ins],[cod_vlis])",
|
||||
"CREATE NONCLUSTERED INDEX ix_avw_last_acq_lotto_w_1\n" +
|
||||
" ON [dbo].[avw_last_acq_lotto_w] ([cod_mdep],[data_reg],[cod_vlis])\n" +
|
||||
" INCLUDE ([cod_mart],[data_ins])");
|
||||
|
||||
createOrUpdateView("avw_last_acq_lotto", "CREATE VIEW avw_last_acq_lotto WITH SCHEMABINDING AS\n" +
|
||||
" SELECT dtb_doct.data_reg,\n" +
|
||||
" cod_mart,\n" +
|
||||
" dtb_docr.partita_mag,\n" +
|
||||
" dtb_doct.cod_mdep,\n" +
|
||||
" dtb_doct.data_ins,\n" +
|
||||
" mtb_depo.cod_vlis,\n" +
|
||||
" dtb_docr.id_riga,\n" +
|
||||
" CAST(dtb_doct.cod_anag AS VARCHAR(10))\n" +
|
||||
" + '_' + dtb_doct.cod_dtip\n" +
|
||||
" + '_' + convert(varchar(10), dtb_doct.data_doc, 112)\n" +
|
||||
" + '_' + dtb_doct.ser_doc\n" +
|
||||
" + '_' + CAST(dtb_doct.num_doc AS VARCHAR(10)) AS chiave_doc\n" +
|
||||
" FROM dbo.dtb_doct\n" +
|
||||
" INNER JOIN dbo.dtb_docr\n" +
|
||||
" ON dtb_doct.cod_anag = dtb_docr.cod_anag AND dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND dtb_doct.ser_doc = dtb_docr.ser_doc AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" INNER JOIN dbo.dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dbo.mtb_depo on mtb_depo.cod_mdep = dtb_doct.cod_mdep\n" +
|
||||
" WHERE dtb_tipi.gestione = 'A'\n" +
|
||||
" AND dtb_docr.partita_mag IS NOT NULL\n" +
|
||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" AND dtb_tipi.segno_qta_car = 1\n" +
|
||||
" AND flag_chk_tracciabilita = 1\n" +
|
||||
" and dtb_doct.data_reg >= CONVERT(datetime, '20230101', 112)");
|
||||
|
||||
executeStatement("CREATE UNIQUE CLUSTERED INDEX [IDX_CLUSTERED_avw_last_acq_lotto] ON [dbo].avw_last_acq_lotto\n" +
|
||||
" (\n" +
|
||||
" data_reg,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" data_ins,\n" +
|
||||
" id_riga,\n" +
|
||||
" chiave_doc\n" +
|
||||
" )");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251014154051 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
if (isCustomer(IntegryCustomer.Auricchio) || isCustomer(IntegryCustomer.Florapulia)) return;
|
||||
updateSetupValue("DATI_AZIENDA", "SETUP", "INVIO_EMAIL_NEW", "S");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251015102126 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("W_VMOVIMENTAZIONI_DISP", "DATAWINDOW", "D_VMOVIM_CLIENTE_REP", null,
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("W_VMOVIMENTAZIONI_DISP", "DATAWINDOW", "D_VMOVIM_ARTICOLO_REP", null,
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("W_VMOVIMENTAZIONI_DISP", "DATAWINDOW", "D_VMOVIM_CLIENTE_STATISTICO_REP", null,
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("W_VMOVIMENTAZIONI_DISP", "DATAWINDOW", "D_VMOVIM_ARTICOLO_STATISTICO_REP", null,
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if(isCustomer(IntegryCustomer.Fiume)) {
|
||||
updateSetupValue("W_VMOVIMENTAZIONI_DISP", "DATAWINDOW", "D_VMOVIM_CLIENTE_REP", "D_VMOVIM_CLIENTE_REP_LICOR");
|
||||
updateSetupValue("W_VMOVIMENTAZIONI_DISP", "DATAWINDOW", "D_VMOVIM_ARTICOLO_REP", "D_VMOVIM_ARTICOLO_REP_LICOR");
|
||||
updateSetupValue("W_VMOVIMENTAZIONI_DISP", "DATAWINDOW", "D_VMOVIM_CLIENTE_STATISTICO_REP", "D_VMOVIM_CLIENTE_STATISTICO_REP_LICOR");
|
||||
updateSetupValue("W_VMOVIMENTAZIONI_DISP", "DATAWINDOW", "D_VMOVIM_ARTICOLO_STATISTICO_REP", "D_VMOVIM_ARTICOLO_STATISTICO_REP_LICOR");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,9 @@ public class Migration_20251015125141 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement(";alter table mtb_lisv add flag_primario bit default 0 not null");
|
||||
|
||||
createOrUpdateFunction("getListinoVendita", "CREATE FUNCTION [dbo].[getListinoVendita](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15))\n" +
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251015125257 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE srl_user_table ADD flag_abil varchar(5) NOT NULL DEFAULT 'N'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251017095838 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
createSetup("W_SUPTABLE", "SETUP", "LIMITA_TABELLE", "N",
|
||||
"Limita la visualizzazione delle tabelle per utente ( inserire il dettaglio nella gestione utenti ) ", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
|
||||
if (isCustomer(IntegryCustomer.Carelli))
|
||||
updateSetupValue("W_SUPTABLE", "SETUP", "LIMITA_TABELLE", "S");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
@Master()
|
||||
@PropertyReactive()
|
||||
@Table(value = SrlUserTable.ENTITY)
|
||||
@JsonTypeName(value = SrlUserTable.ENTITY)
|
||||
public class SrlUserTable extends EntityBase {
|
||||
|
||||
public final static String ENTITY = "srl_user_table";
|
||||
|
||||
private final static Long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
public SrlUserTable() {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "table_name", maxLength = 255, nullable = false)
|
||||
private String tableName;
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "user_name", maxLength = 40, nullable = false)
|
||||
@FK(tableName = StbUser.ENTITY, columnName = "user_name")
|
||||
private String userName;
|
||||
|
||||
@SqlField(value = "flag_abil", maxLength = 5, nullable = false, defaultObjectValue = "N")
|
||||
private String flagAbil;
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public SrlUserTable setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public SrlUserTable setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagAbil() {
|
||||
return flagAbil;
|
||||
}
|
||||
|
||||
public SrlUserTable setFlagAbil(String flagAbil) {
|
||||
this.flagAbil = flagAbil;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@ import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import java.util.Date;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -39,7 +40,7 @@ public class StbActivityPublications extends EntityBase {
|
||||
|
||||
@PK
|
||||
@SqlField(value = "data_pub", nullable = false, defaultObjectValue = CommonConstants.TIMESTAMP)
|
||||
private Date dataPub;
|
||||
private LocalDate dataPub;
|
||||
|
||||
@SqlField(value = "custom_activity_description", maxLength = 1024)
|
||||
private String customActivityDescription;
|
||||
@@ -74,11 +75,11 @@ public class StbActivityPublications extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataPub() {
|
||||
public LocalDate getDataPub() {
|
||||
return dataPub;
|
||||
}
|
||||
|
||||
public StbActivityPublications setDataPub(Date dataPub) {
|
||||
public StbActivityPublications setDataPub(LocalDate dataPub) {
|
||||
this.dataPub = dataPub;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static it.integry.ems_model.utility.UtilityString.countSeparator;
|
||||
import static it.integry.ems_model.utility.UtilityString.replaceSubString;
|
||||
@@ -740,4 +741,136 @@ public class UtilityDB {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void cloneTable(Connection conn, String sourceTable, String newTable,boolean fillNewTable, boolean dropOldTable, boolean renameNewTable) throws Exception {
|
||||
//CREAZIONE TABELLA NUOVA
|
||||
executeStatement(conn, String.format("SELECT TOP 0 * INTO %s FROM %s", newTable, sourceTable));
|
||||
|
||||
String fileGroup = executeSimpleQueryOnlyFirstRowFirstColumn(conn,
|
||||
Query.format("SELECT fg.name\n" +
|
||||
"FROM sys.tables AS t \n" +
|
||||
"inner JOIN sys.indexes AS i ON t.object_id = i.object_id \n" +
|
||||
"inner JOIN sys.filegroups AS fg ON i.data_space_id = fg.data_space_id \n" +
|
||||
"WHERE t.name = %s\n" +
|
||||
"and i.type = 1", sourceTable));
|
||||
|
||||
String sql =
|
||||
Query.format("SELECT c.name\n" +
|
||||
"FROM sys.key_constraints kc\n" +
|
||||
" JOIN sys.index_columns ic ON kc.parent_object_id = ic.object_id AND kc.unique_index_id = ic.index_id\n" +
|
||||
" JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id\n" +
|
||||
"\n" +
|
||||
"WHERE kc.parent_object_id = OBJECT_ID(%s)\n" +
|
||||
" AND kc.type = 'PK'\n" +
|
||||
"ORDER BY ic.key_ordinal", sourceTable);
|
||||
|
||||
List<String> listColPK = UtilityDB.executeSimpleQueryOnlyFirstColumn(conn, sql);
|
||||
|
||||
//Creazione PK
|
||||
executeStatement(conn,
|
||||
String.format("ALTER TABLE %s ADD CONSTRAINT [pk_%s] PRIMARY KEY ( %s ) %s",
|
||||
newTable, newTable, StringUtils.join(listColPK, ","),
|
||||
(fileGroup.equalsIgnoreCase("PRIMARY") ? "" : "ON " + fileGroup)));
|
||||
|
||||
//Creazione indici
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT i.name as index_name, i.is_unique, fg.name as file_name\n" +
|
||||
"FROM sys.indexes i inner join sys.tables AS t on i.object_id = t.object_id \n" +
|
||||
"JOIN sys.filegroups AS fg ON i.data_space_id = fg.data_space_id and i.is_primary_key = 1 \n" +
|
||||
"WHERE i.object_id = OBJECT_ID(%s)\n" +
|
||||
" AND i.is_primary_key = 0\n" +
|
||||
" AND i.is_unique_constraint = 0", sourceTable
|
||||
);
|
||||
|
||||
List<HashMap<String, Object>> indexList = UtilityDB.executeSimpleQuery(conn, sql);
|
||||
|
||||
for(HashMap<String, Object> i: indexList) {
|
||||
sql = Query.format(
|
||||
"SELECT c.name\n" +
|
||||
"FROM sys.indexes i\n" +
|
||||
"JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id\n" +
|
||||
"JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id\n" +
|
||||
"WHERE i.object_id = OBJECT_ID(%s)\n" +
|
||||
" AND i.name = %s\n" +
|
||||
"ORDER BY ic.key_ordinal",
|
||||
sourceTable, i.get("index_name")
|
||||
);
|
||||
|
||||
List<String> listColIndex = UtilityDB.executeSimpleQueryOnlyFirstColumn(conn, sql);
|
||||
|
||||
executeStatement(conn, String.format("CREATE %s INDEX %s ON %s ( %s ) %s",
|
||||
(Boolean.TRUE.equals(i.get("is_unique")) ? "UNIQUE" : ""),
|
||||
i.get("index_name"),
|
||||
newTable,
|
||||
StringUtils.join(listColIndex, ","),
|
||||
((String) i.get("file_name")).equalsIgnoreCase("PRIMARY") ? "" : "ON " + (String) i.get("file_name")
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
//creazione default
|
||||
sql = Query.format("SELECT \n" +
|
||||
" dc.name AS DefaultName,\n" +
|
||||
" c.name AS ColumnName,\n" +
|
||||
" dc.definition\n" +
|
||||
"FROM sys.default_constraints dc\n" +
|
||||
"JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id\n" +
|
||||
"WHERE dc.parent_object_id = OBJECT_ID(%s)",
|
||||
sourceTable);
|
||||
|
||||
List<HashMap<String, Object>> listDefatult = UtilityDB.executeSimpleQuery(conn, sql);
|
||||
|
||||
for(HashMap<String, Object> i: listDefatult) {
|
||||
executeStatement(conn, String.format("ALTER TABLE %s ADD CONSTRAINT %s DEFAULT %s FOR %s",
|
||||
newTable,
|
||||
((String) i.get("DefaultName")).toLowerCase().replace(sourceTable.toLowerCase(), newTable.toLowerCase()),
|
||||
i.get("definition"),
|
||||
i.get("ColumnName")
|
||||
));
|
||||
}
|
||||
|
||||
//creazione foreign key
|
||||
sql = Query.format("SELECT fk.name as fk_name, OBJECT_NAME(fk.referenced_object_id) as ref_tab\n" +
|
||||
"FROM sys.foreign_keys fk\n" +
|
||||
"WHERE fk.parent_object_id = OBJECT_ID(%s);",
|
||||
sourceTable);
|
||||
|
||||
List<HashMap<String, Object>> listFk = UtilityDB.executeSimpleQuery(conn, sql);
|
||||
|
||||
for(HashMap<String, Object> fk: listFk) {
|
||||
sql = String.format(
|
||||
"SELECT COL_NAME(fkc.parent_object_id, fkc.parent_column_id) AS column_name, \n" +
|
||||
"COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id) AS column_ref\n" +
|
||||
"FROM sys.foreign_keys fk\n" +
|
||||
"INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id\n" +
|
||||
"WHERE fk.parent_object_id = OBJECT_ID(%s) AND fk.name = %S;",sourceTable, fk.get("fk_name")
|
||||
);
|
||||
|
||||
List<HashMap<String, Object>> listFkColumns = UtilityDB.executeSimpleQuery(conn, sql);
|
||||
|
||||
String colNames = StringUtils.join(listFkColumns.stream().map(x -> (String)x.get("column_name")).collect(Collectors.toList()), ",");
|
||||
String colRef = StringUtils.join(listFkColumns.stream().map(x -> (String)x.get("column_ref")).collect(Collectors.toList()), ",");
|
||||
|
||||
sql = String.format("ALTER TABLE %s ADD CONSTRAINT [ %s_NEW] FOREIGN KEY ([%s]) REFERENCES [%s]([%s]);",
|
||||
newTable,
|
||||
fk.get("fk_name"),
|
||||
colNames,
|
||||
fk.get("ref_tab"),
|
||||
colRef
|
||||
);
|
||||
|
||||
executeStatement(conn, sql);
|
||||
}
|
||||
//RIEMPIMENTO TABELLA NUOVA
|
||||
if (fillNewTable) {
|
||||
executeStatement(conn, String.format("INSERT INTO %s SELECT * FROM %s", newTable, sourceTable));
|
||||
|
||||
if (dropOldTable) {
|
||||
executeStatement(conn, "DROP TABLE " + sourceTable);
|
||||
if (renameNewTable)
|
||||
executeStatement(conn, Query.format("EXEC sp_rename %s, %s;", newTable, sourceTable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,22 @@ public class AuthController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/create-app-token", method = RequestMethod.POST)
|
||||
public ServiceRestResponse createAppToken(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody LoginRequestDTO loginRequestDTO) {
|
||||
try {
|
||||
String profileDb = multiDBTransactionManager.getPrimaryConnection().getProfileName();
|
||||
return ServiceRestResponse.createPositiveResponse(authService.createAppToken(profileDb, loginRequestDTO));
|
||||
} catch (AuthorizationExpriredException ex) {
|
||||
logger.error(request.getRequestURI(), ex);
|
||||
response.setStatus(420);
|
||||
return ServiceRestResponse.createNegativeResponse(ex);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/me", method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse user(@RequestParam(CommonConstants.PROFILE_DB) String profileDb) {
|
||||
|
||||
@@ -60,25 +60,27 @@ public class AuthService {
|
||||
private SettingsModel settingsModel;
|
||||
|
||||
|
||||
|
||||
public JwtResponse createAppToken(String profileDb, LoginRequestDTO loginRequestDTO) throws Exception {
|
||||
return login(profileDb, loginRequestDTO, true);
|
||||
}
|
||||
|
||||
|
||||
public JwtResponse login(String profileDb, LoginRequestDTO loginRequestDTO) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(loginRequestDTO.getUsername())) {
|
||||
return login(profileDb, loginRequestDTO, false);
|
||||
}
|
||||
|
||||
private JwtResponse login(String profileDb, LoginRequestDTO loginRequestDTO, boolean disableExpiration) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(loginRequestDTO.getUsername()))
|
||||
throw new Exception("Username mancante.");
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(loginRequestDTO.getPassword())) {
|
||||
if (UtilityString.isNullOrEmpty(loginRequestDTO.getPassword()))
|
||||
throw new Exception("Password mancante.");
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(loginRequestDTO.getDeviceId())) {
|
||||
if (UtilityString.isNullOrEmpty(loginRequestDTO.getDeviceId()))
|
||||
throw new Exception("Device id mancante.");
|
||||
}
|
||||
|
||||
if (requestDataDTO.getApplication() == null) {
|
||||
if (requestDataDTO.getApplication() == null)
|
||||
throw new Exception("X-App-Token mancante.");
|
||||
}
|
||||
|
||||
String username = loginRequestDTO.getUsername();
|
||||
String password = loginRequestDTO.getPassword();
|
||||
@@ -113,12 +115,14 @@ public class AuthService {
|
||||
stbDevices.getId()
|
||||
);
|
||||
|
||||
String oldAccessToken = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
String primaryProfileDb = multiDBTransactionManager.getPrimaryConnection().getProfileName();
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(oldAccessToken)) {
|
||||
applicationEventPublisher.publishEvent(new TokenExpireEvent(primaryProfileDb, oldAccessToken));
|
||||
if (!disableExpiration) {
|
||||
String oldAccessToken = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(oldAccessToken)) {
|
||||
applicationEventPublisher.publishEvent(new TokenExpireEvent(primaryProfileDb, oldAccessToken));
|
||||
}
|
||||
}
|
||||
|
||||
// Ricreo token di accesso e refresh
|
||||
@@ -127,7 +131,8 @@ public class AuthService {
|
||||
password,
|
||||
foundUser.getKeyGroup(),
|
||||
primaryProfileDb,
|
||||
stbDevices.getId()
|
||||
stbDevices.getId(),
|
||||
disableExpiration
|
||||
);
|
||||
|
||||
applicationEventPublisher.publishEvent(new TokenCreateEvent(primaryProfileDb, stbAuthToken));
|
||||
@@ -139,6 +144,7 @@ public class AuthService {
|
||||
.setExpireIn(ChronoUnit.SECONDS.between(UtilityLocalDate.getNowTime(), stbAuthToken.getExpiryDate()));
|
||||
}
|
||||
|
||||
|
||||
public void logout(String profileDb, LogoutRequestDTO logoutRequestDTO) {
|
||||
|
||||
TokenExpireEvent tokenExpireEvent = new TokenExpireEvent(profileDb, logoutRequestDTO.getToken());
|
||||
|
||||
@@ -99,7 +99,8 @@ public class RefreshTokenService {
|
||||
user.getPassword(),
|
||||
user.getKeyGroup(),
|
||||
profileDb,
|
||||
stbAuthToken.getDeviceId());
|
||||
stbAuthToken.getDeviceId(),
|
||||
false);
|
||||
|
||||
applicationEventPublisher.publishEvent(new TokenCreateEvent(profileDb, newRefreshToken));
|
||||
|
||||
@@ -116,8 +117,10 @@ public class RefreshTokenService {
|
||||
}
|
||||
}
|
||||
|
||||
public StbAuthToken createRefreshTokenIfNotExists(String username, String password, Integer keyGroup, String profileDb, Long deviceId) throws Exception {
|
||||
LocalDateTime expiryDate = LocalDateTime.now().plusDays(settingsModel.getRefreshTokenExpireDays());
|
||||
public StbAuthToken createRefreshTokenIfNotExists(String username, String password, Integer keyGroup, String profileDb, Long deviceId, boolean disableExpiration) throws Exception {
|
||||
LocalDateTime expiryDate = disableExpiration ?
|
||||
LocalDateTime.of(2099, 12, 31, 23, 59) :
|
||||
LocalDateTime.now().plusDays(settingsModel.getRefreshTokenExpireDays());
|
||||
|
||||
if (deviceId == null)
|
||||
throw new Exception("Impossibile creare un refresh token");
|
||||
|
||||
@@ -393,4 +393,13 @@ public class ActivityController {
|
||||
public ServiceRestResponse getAvgResolutionTime(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getAvgResolutionTime());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "activity/insertPublication", method = RequestMethod.POST)
|
||||
public ServiceRestResponse insertPublication(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody(required = false) ActivityPublicationDTO activityPublicationDTO) throws Exception {
|
||||
|
||||
activityService.insertPublication(activityPublicationDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public class ActivityPublicationDTO {private String activityId;
|
||||
private String activityDescription;
|
||||
private String projectDescription;
|
||||
private LocalDate dataPubblicazione;
|
||||
private List<String> commesse;
|
||||
|
||||
public String getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
public ActivityPublicationDTO setActivityId(String activityId) {
|
||||
this.activityId = activityId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActivityDescription() {
|
||||
return activityDescription;
|
||||
}
|
||||
|
||||
public ActivityPublicationDTO setActivityDescription(String activityDescription) {
|
||||
this.activityDescription = activityDescription;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProjectDescription() {
|
||||
return projectDescription;
|
||||
}
|
||||
|
||||
public ActivityPublicationDTO setProjectDescription(String projectDescription) {
|
||||
this.projectDescription = projectDescription;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataPubblicazione() {
|
||||
return dataPubblicazione;
|
||||
}
|
||||
|
||||
public ActivityPublicationDTO setDataPubblicazione(LocalDate dataPubblicazione) {
|
||||
this.dataPubblicazione = dataPubblicazione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getCommesse() {
|
||||
return commesse;
|
||||
}
|
||||
|
||||
public ActivityPublicationDTO setCommesse(List<String> commesse) {
|
||||
this.commesse = commesse;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -764,6 +764,33 @@ public class ActivityService {
|
||||
}
|
||||
}
|
||||
|
||||
public void insertPublication(ActivityPublicationDTO activityPublicationDTO) throws Exception {
|
||||
List<StbActivityPublications> publications = new ArrayList<>();
|
||||
if (UtilityString.isNullOrEmpty(activityPublicationDTO.getActivityDescription()))
|
||||
throw new Exception("La descrizione personalizzata dell'attività non può essere vuota");
|
||||
if (UtilityString.isNullOrEmpty(activityPublicationDTO.getProjectDescription()))
|
||||
throw new Exception("La descrizione personalizzata del progetto non può essere vuota");
|
||||
|
||||
if (activityPublicationDTO.getCommesse() == null || activityPublicationDTO.getCommesse().isEmpty())
|
||||
throw new Exception("Deve essere selezionata almeno una commessa per la pubblicazione");
|
||||
|
||||
if (activityPublicationDTO.getDataPubblicazione() == null)
|
||||
throw new Exception("La data di pubblicazione non può essere vuota");
|
||||
|
||||
for(String codJcom: activityPublicationDTO.getCommesse()){
|
||||
StbActivityPublications publication = new StbActivityPublications()
|
||||
.setActivityId(activityPublicationDTO.getActivityId())
|
||||
.setCodJcom(codJcom)
|
||||
.setDataPub(activityPublicationDTO.getDataPubblicazione())
|
||||
.setCustomActivityDescription(activityPublicationDTO.getActivityDescription())
|
||||
.setCustomProjectDescription(activityPublicationDTO.getProjectDescription());
|
||||
publication.setOperation(OperationType.INSERT);
|
||||
publications.add(publication);
|
||||
}
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityProcessor.processEntityList(publications, true));
|
||||
}
|
||||
|
||||
public ActivityDTO changeCodJcom(String activityId, String codJcom, String parentActivityId) throws Exception {
|
||||
String sql =
|
||||
Query.format("SELECT cod_jcom FROM stb_activity WHERE activity_id = %s", activityId);
|
||||
|
||||
@@ -829,72 +829,95 @@ public class VariazioniPvService {
|
||||
queryAssortimento =
|
||||
"WITH componenti AS (SELECT cod_mart, cod_mart AS cod_comp\n" +
|
||||
" FROM mtb_aart\n" +
|
||||
" WHERE articolo_composto = 'N'\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT mtb_comp.cod_mart, cod_comp\n" +
|
||||
" FROM mtb_comp\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_comp.cod_mart = mtb_aart.cod_mart AND articolo_composto = 'S'),\n" +
|
||||
" doc AS (SELECT wdtb_doct.data_reg,\n" +
|
||||
" FROM mtb_comp),\n" +
|
||||
" doc AS (SELECT avw_last_acq_lotto_w.data_reg,\n" +
|
||||
" componenti.cod_comp AS cod_mart,\n" +
|
||||
" wdtb_docr.partita_mag,\n" +
|
||||
" wdtb_doct.cod_mdep,\n" +
|
||||
" wdtb_doct.data_ins\n" +
|
||||
" FROM wdtb_doct\n" +
|
||||
" INNER JOIN wdtb_docr ON wdtb_doct.cod_anag = wdtb_docr.cod_anag AND\n" +
|
||||
" wdtb_doct.cod_dtip = wdtb_docr.cod_dtip AND\n" +
|
||||
" wdtb_doct.data_doc = wdtb_docr.data_doc AND\n" +
|
||||
" wdtb_doct.ser_doc = wdtb_docr.ser_doc AND\n" +
|
||||
" wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" INNER JOIN componenti ON wdtb_docr.cod_mart = componenti.cod_mart\n" +
|
||||
" avw_last_acq_lotto_w.partita_mag,\n" +
|
||||
" avw_last_acq_lotto_w.cod_mdep,\n" +
|
||||
" avw_last_acq_lotto_w.data_ins,\n" +
|
||||
" avw_last_acq_lotto_w.cod_vlis\n" +
|
||||
" FROM avw_last_acq_lotto_w\n" +
|
||||
" INNER JOIN componenti ON avw_last_acq_lotto_w.cod_mart = componenti.cod_mart\n" +
|
||||
" WHERE avw_last_acq_lotto_w.cod_vlis = '[COD_VLIS]'\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT dtb_doct.data_reg,\n" +
|
||||
" SELECT avw_last_acq_lotto.data_reg,\n" +
|
||||
" componenti.cod_comp AS cod_mart,\n" +
|
||||
" dtb_docr.partita_mag,\n" +
|
||||
" dtb_doct.cod_mdep,\n" +
|
||||
" dtb_doct.data_ins\n" +
|
||||
" FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_docr\n" +
|
||||
" ON dtb_doct.cod_anag = dtb_docr.cod_anag AND dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND dtb_doct.ser_doc = dtb_docr.ser_doc AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_docr.cod_dtip\n" +
|
||||
" INNER JOIN componenti ON dtb_docr.cod_mart = componenti.cod_mart\n" +
|
||||
" WHERE dtb_tipi.gestione = 'A'\n" +
|
||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" AND dtb_tipi.segno_qta_car = 1\n" +
|
||||
" AND flag_chk_tracciabilita = 1),\n" +
|
||||
" last_doc AS (SELECT mtb_depo.cod_vlis,\n" +
|
||||
" kit.cod_comp AS cod_mart,\n" +
|
||||
" doc.partita_mag,\n" +
|
||||
" DENSE_RANK() OVER (PARTITION BY kit.cod_comp ORDER BY doc.data_ins DESC ) AS ord\n" +
|
||||
" FROM doc\n" +
|
||||
" INNER JOIN (SELECT cod_mart, cod_mart AS cod_comp\n" +
|
||||
" FROM mtb_aart\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_mart, cod_comp\n" +
|
||||
" FROM mtb_comp\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_comp, cod_mart\n" +
|
||||
" FROM mtb_comp) kit ON doc.cod_mart = kit.cod_mart\n" +
|
||||
" INNER JOIN mtb_depo ON doc.cod_mdep = mtb_depo.cod_mdep\n" +
|
||||
" WHERE CAST(doc.data_ins AS DATE) BETWEEN DATEADD(DD, -8, '[DATA_VALIDITA]') AND DATEADD(DD, -1, '[DATA_VALIDITA]')\n" +
|
||||
" AND doc.partita_mag IS NOT NULL\n" +
|
||||
" AND mtb_depo.cod_vlis = '[COD_VLIS]'\n" +
|
||||
" avw_last_acq_lotto.partita_mag,\n" +
|
||||
" avw_last_acq_lotto.cod_mdep,\n" +
|
||||
" avw_last_acq_lotto.data_ins,\n" +
|
||||
" avw_last_acq_lotto.cod_vlis\n" +
|
||||
" FROM avw_last_acq_lotto\n" +
|
||||
" INNER JOIN componenti ON avw_last_acq_lotto.cod_mart = componenti.cod_mart\n" +
|
||||
" WHERE avw_last_acq_lotto.cod_vlis = '[COD_VLIS]')\n" +
|
||||
" ,\n" +
|
||||
" max_doc AS (SELECT cod_mart,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" MAX(data_ins) AS last_ins\n" +
|
||||
" FROM doc\n" +
|
||||
" WHERE data_reg <= '2025/10/14'\n" +
|
||||
" GROUP BY cod_mdep, cod_mart),\n" +
|
||||
" last_doc_tot AS (SELECT doc.*\n" +
|
||||
" FROM max_doc\n" +
|
||||
" INNER JOIN doc ON doc.cod_mdep = max_doc.cod_mdep\n" +
|
||||
" AND doc.cod_mart = max_doc.cod_mart\n" +
|
||||
" AND doc.data_ins = max_doc.last_ins)\n" +
|
||||
" ,\n" +
|
||||
" last_doc AS (SELECT *\n" +
|
||||
" FROM last_doc_tot\n" +
|
||||
" WHERE CAST(last_doc_tot.data_ins AS DATE) BETWEEN DATEADD(DD, -8, '[DATA_VALIDITA]') AND DATEADD(DD, -1, '[DATA_VALIDITA]')\n" +
|
||||
" AND NOT EXISTS (SELECT *\n" +
|
||||
" FROM doc d\n" +
|
||||
" WHERE d.data_ins < DATEADD(DD, -1, '[DATA_VALIDITA]')\n" +
|
||||
" AND d.data_reg > doc.data_reg\n" +
|
||||
" AND d.cod_mart = doc.cod_mart\n" +
|
||||
" AND d.cod_mdep = doc.cod_mdep)),\n" +
|
||||
" AND d.data_reg > last_doc_tot.data_reg\n" +
|
||||
" AND d.cod_mart = last_doc_tot.cod_mart\n" +
|
||||
" AND d.cod_mdep = last_doc_tot.cod_mdep)),\n" +
|
||||
" last_doc_kit AS (SELECT last_doc.data_reg,\n" +
|
||||
" last_doc.cod_mart,\n" +
|
||||
" last_doc.partita_mag,\n" +
|
||||
" last_doc.cod_mdep,\n" +
|
||||
" last_doc.data_ins,\n" +
|
||||
" last_doc.cod_vlis\n" +
|
||||
" FROM last_doc\n" +
|
||||
" UNION\n" +
|
||||
" SELECT last_doc.data_reg,\n" +
|
||||
" mtb_comp.cod_comp,\n" +
|
||||
" last_doc.partita_mag,\n" +
|
||||
" last_doc.cod_mdep,\n" +
|
||||
" last_doc.data_ins,\n" +
|
||||
" last_doc.cod_vlis\n" +
|
||||
" FROM last_doc\n" +
|
||||
" INNER JOIN mtb_comp ON last_doc.cod_mart = mtb_comp.cod_mart\n" +
|
||||
" UNION\n" +
|
||||
" SELECT last_doc.data_reg,\n" +
|
||||
" last_doc.cod_mart,\n" +
|
||||
" last_doc.partita_mag,\n" +
|
||||
" last_doc.cod_mdep,\n" +
|
||||
" last_doc.data_ins,\n" +
|
||||
" last_doc.cod_vlis\n" +
|
||||
" FROM last_doc\n" +
|
||||
" UNION\n" +
|
||||
" SELECT last_doc.data_reg,\n" +
|
||||
" mtb_comp.cod_mart,\n" +
|
||||
" STUFF((SELECT DISTINCT '-' + partita_mag\n" +
|
||||
" FROM mtb_comp kit\n" +
|
||||
" INNER JOIN last_doc_tot doc ON kit.cod_comp = doc.cod_mart AND\n" +
|
||||
" doc.cod_mdep = '[COD_VLIS]'\n" +
|
||||
" WHERE kit.cod_mart = mtb_comp.cod_mart\n" +
|
||||
" FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') AS partita_mag,\n" +
|
||||
" last_doc.cod_mdep,\n" +
|
||||
" last_doc.data_ins,\n" +
|
||||
" last_doc.cod_vlis\n" +
|
||||
" FROM mtb_comp\n" +
|
||||
" INNER JOIN last_doc ON mtb_comp.cod_comp = last_doc.cod_mart),\n" +
|
||||
" tmp_assortimento AS (SELECT cod_vlis,\n" +
|
||||
" doc.cod_mart,\n" +
|
||||
" 'A' AS tipo_variazione,\n" +
|
||||
" CONVERT(VARCHAR(15), NULL) AS cod_mart_view,\n" +
|
||||
" 'N' AS 'fine_promo',\n" +
|
||||
" CONVERT(VARCHAR(25), doc.partita_mag) AS lotto\n" +
|
||||
" FROM last_doc doc\n" +
|
||||
" INNER JOIN mtb_aart ON doc.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" WHERE doc.ord = 1)\n";
|
||||
" FROM last_doc_kit doc)\n";
|
||||
|
||||
queryAssortimento =
|
||||
queryAssortimento
|
||||
|
||||
@@ -175,7 +175,7 @@ public class ScontriniZucchettiExportServices {
|
||||
|
||||
|
||||
if ( !dati.isEmpty()) {
|
||||
String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".csv";
|
||||
String fileName = "Forecast_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".csv";
|
||||
File file = new File(fileName);
|
||||
|
||||
CsvMapper<ZucchettiHrDTO> mapper = new CsvMapper<>();
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -97,35 +98,42 @@ public class WMSArticoloService {
|
||||
|
||||
|
||||
public RetrieveArticoloResponseDTO retrieveArts(FilterDTO filter, int page, int pageSize ) throws Exception {
|
||||
|
||||
|
||||
String query = "SELECT mtb_aart.cod_mart AS [mtb_aart.cod_mart], " +
|
||||
" mtb_aart.descrizione AS [mtb_aart.descrizione], " +
|
||||
String query = String.format(
|
||||
"SELECT mtb_aart.cod_mart AS [mtb_aart.cod_mart], " +
|
||||
" mtb_aart.descrizione AS [mtb_aart.descrizione], " +
|
||||
" CONCAT(mtb_aart.cod_mart, ' - ', mtb_aart.descrizione) AS [CONCAT(mtb_aart.cod_mart, ' - ', mtb_aart.descrizione)], " +
|
||||
" mtb_aart.descrizione_estesa AS [mtb_aart.descrizione_estesa], " +
|
||||
" mtb_aart.unt_mis AS [mtb_aart.unt_mis], " +
|
||||
" mtb_aart.cod_mgrp AS [mtb_aart.cod_mgrp], " +
|
||||
" mtb_aart.cod_msgr AS [mtb_aart.cod_msgr], " +
|
||||
" mtb_aart.cod_msfa AS [mtb_aart.cod_msfa], " +
|
||||
" mtb_aart.qta_cnf AS [mtb_aart.qta_cnf], " +
|
||||
" mtb_aart.cod_aliq AS [mtb_aart.cod_aliq], " +
|
||||
" mtb_aart.posizione AS [posizione], " +
|
||||
" bar_code AS [barcode], " +
|
||||
" cod_barre_imb AS [cod_barre_imb], " +
|
||||
" mtb_grup.descrizione AS [mtb_grup.descrizione], " +
|
||||
" mtb_sgrp.descrizione AS [mtb_sgrp.descrizione], " +
|
||||
" mtb_sfam.descrizione AS [mtb_sfam.descrizione] " +
|
||||
"FROM mtb_aart " +
|
||||
" INNER JOIN mtb_grup ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp " +
|
||||
" LEFT OUTER JOIN mtb_sgrp ON mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr " +
|
||||
" LEFT OUTER JOIN mtb_sfam ON mtb_aart.cod_mgrp = mtb_sfam.cod_mgrp AND mtb_aart.cod_msgr = mtb_sfam.cod_msgr AND " +
|
||||
" mtb_aart.cod_msfa = mtb_sfam.cod_msfa ";
|
||||
" mtb_aart.descrizione_estesa AS [mtb_aart.descrizione_estesa], " +
|
||||
" mtb_aart.unt_mis AS [mtb_aart.unt_mis], " +
|
||||
" mtb_aart.cod_mgrp AS [mtb_aart.cod_mgrp], " +
|
||||
" mtb_aart.cod_msgr AS [mtb_aart.cod_msgr], " +
|
||||
" mtb_aart.cod_msfa AS [mtb_aart.cod_msfa], " +
|
||||
" mtb_aart.qta_cnf AS [mtb_aart.qta_cnf], " +
|
||||
" mtb_aart.cod_aliq AS [mtb_aart.cod_aliq], " +
|
||||
" mtb_aart.posizione AS [posizione], " +
|
||||
" bar_code AS [barcode], " +
|
||||
" cod_barre_imb AS [cod_barre_imb], " +
|
||||
" mtb_grup.descrizione AS [mtb_grup.descrizione], " +
|
||||
" mtb_sgrp.descrizione AS [mtb_sgrp.descrizione], " +
|
||||
" mtb_sfam.descrizione AS [mtb_sfam.descrizione] " +
|
||||
"FROM mtb_aart " +
|
||||
" INNER JOIN mtb_grup ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp " +
|
||||
" LEFT OUTER JOIN mtb_sgrp ON mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr " +
|
||||
" LEFT OUTER JOIN mtb_sfam ON mtb_aart.cod_mgrp = mtb_sfam.cod_mgrp AND mtb_aart.cod_msgr = mtb_sfam.cod_msgr AND " +
|
||||
" mtb_aart.cod_msfa = mtb_sfam.cod_msfa " +
|
||||
"WHERE (mtb_grup.tipo_mgrp IS NULL OR mtb_grup.tipo_mgrp NOT IN (%s))",
|
||||
UtilityDB.listValueToString(Arrays.asList(
|
||||
MtbGrup.TipoGruppo.ACCONTI_SCONTI.getValue(),
|
||||
MtbGrup.TipoGruppo.FITTIZIO.getValue(),
|
||||
MtbGrup.TipoGruppo.MATERIALE_ACCESSORI.getValue(),
|
||||
MtbGrup.TipoGruppo.SERVIZI.getValue()
|
||||
))
|
||||
);
|
||||
|
||||
if (filter != null && filter.getFilters().length > 0) {
|
||||
UtilityFilter.convertFilterDtoFieldsToSqlFields(filter, ArticoloDTO.class);
|
||||
|
||||
String filterString = UtilityFilter.processFilters(filter);
|
||||
query += " WHERE " + filterString;
|
||||
query += " AND " + filterString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -332,17 +332,23 @@ public class SystemService {
|
||||
}
|
||||
|
||||
for (String profile : profiles) {
|
||||
UserDTO foundUserTmp = null;
|
||||
|
||||
String dbName = settingsModel.getDbNameFromProfileDb(profile);
|
||||
|
||||
//MD5 utilizzato da Ordikids e Farmmes
|
||||
if (UtilityString.isNullOrEmpty(password) && !UtilityString.isNullOrEmpty(md5User)) {
|
||||
foundUser = userCacheService.retrieveUser(dbName, md5User);
|
||||
foundUserTmp = userCacheService.retrieveUser(dbName, md5User);
|
||||
} else
|
||||
foundUser = userCacheService.retrieveUser(dbName, username, password, requestDataDTO.getApplication());
|
||||
foundUserTmp = userCacheService.retrieveUser(dbName, username, password, requestDataDTO.getApplication());
|
||||
|
||||
if (foundUser == null || !foundUser.isAttivo())
|
||||
if (foundUserTmp == null || !foundUserTmp.isAttivo())
|
||||
continue;
|
||||
|
||||
if (foundUser == null) {
|
||||
foundUser = foundUserTmp;
|
||||
}
|
||||
|
||||
if (!foundUser.getAvailableProfiles().contains(profile)) {
|
||||
foundUser.getAvailableProfiles().add(profile);
|
||||
}
|
||||
@@ -351,7 +357,7 @@ public class SystemService {
|
||||
|
||||
if (foundUser == null) {
|
||||
logger.error(String.format("Credenziali non valide utente: %s ( %s) ",
|
||||
UtilityString.isNull(username,md5User), multiDBTransactionManager.getPrimaryConnection().getCatalog() + " )"));
|
||||
UtilityString.isNull(username,md5User), UtilityString.isNull(profileDB,multiDBTransactionManager.getPrimaryConnection().getCatalog()) + " )"));
|
||||
throw new Exception("Credenziali non valide");
|
||||
} else if (!foundUser.isAttivo()) {
|
||||
throw new Exception("Utente non attivo");
|
||||
|
||||
Reference in New Issue
Block a user