Finish Release-2
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240708155342 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,6 +11,8 @@ public class Migration_20240708155342 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("MES_GetWorkOrders", "CREATE FUNCTION [dbo].[MES_GetWorkOrders](@codJfas VARCHAR(50), @dateStart DATE, @dateEnd DATE, @flagEvaso VARCHAR(1),\n" +
|
||||
" @codAnag VARCHAR(5))\n" +
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240709165449 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,6 +11,8 @@ public class Migration_20240709165449 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("f_lol_getOperazione", "CREATE FUNCTION [dbo].[f_lol_getOperazione] ( @codDtip varchar(5), @nazione varchar(3), @codMartIniz varchar(15), @partitaMagIniz varchar(20), @codMartFine varchar(15), @partitaMagFine varchar(20), @omaggio bit, @tipoMiscela varchar(1), @isAzienda bit)\n" +
|
||||
"RETURNS varchar(max)\n" +
|
||||
|
||||
@@ -11,6 +11,8 @@ public class Migration_20240710120537 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_SCONTRINI", "INTEGRETAIL", "GG_RECUPERO", null, "giorni di recuper per il servizio pianificato", false, null, false, false, false, false, false, null, false, null);
|
||||
if (isCustomerDb(IntegryCustomerDB.Carelli_Carelli, IntegryCustomerDB.Carelli_GestFood, IntegryCustomerDB.Carelli_Panimal))
|
||||
|
||||
@@ -11,6 +11,9 @@ public class Migration_20240711091525 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateProcedure("MRP_UpdateQtaImpProx", "CREATE Procedure [dbo].[MRP_UpdateQtaImpProx](@elencoArticoli varchar(max) = null)\n" +
|
||||
"AS \n" +
|
||||
"--DECLARE @elencoarticoli VARCHAR(MAX) = NULL\n" +
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240711183409 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "ATTIVO", "S", "Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "COD_ANAG", null, "Codice anagrafico del vettore", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "COD_VVET", null, "Codice vettore", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "ELENCO_TIPI_DOC_DA_ESCLUDERE", null, "Elenco documenti da escludere", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "EMAIL_FOR_LOG", "test@integry.it", "Inserire il file l'indirizzo email per inviare il log dell'importazione", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "FILE_FILTER", null, "Inserire il criterio di filtro dei file o il nome del file specifio (seguire la sintassi di java)", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "GG_CANC_FILE", null, "Giorni per la cancellazione dei file dalla cartella di appoggio", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "IMPORT_REST", "S", "Inserire S/N per attivare/disattivare il salvataggio con i servizi REST", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "LISTENING", "N", "Se LISTENIG = 'N' la procedura di importazione non si potrà mai mettere in ascolto sulla directory perchè nella procedura vengono prese in considerazione più file.", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "PATH_FILE", "\\\\SERVERPB\\DOCUMENTI\\EBC\\", "Directory contente i file da importare.", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "PATH_FILE_IMPORTED", "\\\\SERVERPB\\DOCUMENTI\\EBC\\IMPORTED\\", "Directory dove vengono spostati i file dopo l'importazione.", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "SET_COND_ANNO_DOC", "N", "Se attivato nel ricarcare il documento oltre a cercare per data documento cerca anche il documento nell''anno. Possibili valori S/N", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "SET_COND_GESTIONE", "N", "Se impostato nel ricercare il documento viene impostata la condizione sulla gestione specificata in questa confiturazione (possibile valore V e A)", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "SET_COND_SERIE_DOC", "N", "Se impostato nella ricerca del documento viene impostata la condizione anche sul vettore (Attivare solo se il tracciato provedere la colonna della serie) Possibili valori S/N", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "SET_COND_VETTORE", "N", "Se impostato nel ricercare il documento imposta la condizione anche sul vettore, ma in tal caso si deve essere sicuri che tutti i documenti abbiamo il codice vettore associato altrimenti alcuni documenti del file non verrebbero riconosciuti, Possibili valori S/N", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "SET_ESLUDI_ONERI_ZERO", "S", "Se impostato a S, durante l''importazione le righe con oneri pari a zero nel file vengono escluse", false, null, false, false, false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "TIPO_RIPARTIZIONE_COSTI_PER_PEDANA_A", "PESO", "Se il tipo di calcolo è a PEDANA allora si può decidere se la ripartizione dei costi deve essere fatta a pedana, a colli o a pezzi. E'' stato necessario perchè spesso il numero di pedane del vettore è diverso dal numero di pedane che calcoliamo noi nei documenti", false, null, false, false, false, false, false, null, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240711183516 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
updateSetupValue("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "COD_ANAG", "F2815");
|
||||
updateSetupValue("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "COD_VVET", "233");
|
||||
updateSetupValue("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "ELENCO_TIPI_DOC_DA_ESCLUDERE", "D.D.T");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240711184223 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
updateSetupValue("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "TIPO_CALC", "PESO");
|
||||
updateSetupValue("IMPORT_DOCUMENTI_TRASPORTO", "EBC", "TIPO_RIPARTIZIONE_COSTI_PER_PEDANA_A", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240712133359 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,6 +11,9 @@ public class Migration_20240712133359 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
executeStatement("alter table mtb_aart_link add constraint fk_mtb_aart_link_stb_files_attached foreign key (id_attach) references stb_files_attached (id_attach)");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240715105345 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -9,6 +10,8 @@ public class Migration_20240715105345 extends BaseMigration implements Migration
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
executeStatement("ALTER TABLE ntb_docr\n" +
|
||||
" ADD causale_reso VARCHAR(5);");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240716090151 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,6 +11,8 @@ public class Migration_20240716090151 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateView("vvw_banc_riba", "CREATE VIEW [dbo].[vvw_banc_riba] AS SELECT \n" +
|
||||
" DISTINCT vtb_riba.tipo_anag, \n" +
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240717122430 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -9,6 +10,10 @@ public class Migration_20240717122430 extends BaseMigration implements Migration
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE mtb_grup\n" +
|
||||
" ADD flag_attivo bit default 1",
|
||||
"UPDATE mtb_grup SET flag_attivo = 1",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240718093241 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,6 +11,9 @@ public class Migration_20240718093241 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE [dbo].[mtb_aart] WITH NOCHECK ADD CONSTRAINT [CHK_mtb_aart_rap_conv2] CHECK (([unt_mis2] is not null and [rap_conv2]<>(0))or [unt_mis2] is null )" ,
|
||||
"ALTER TABLE [dbo].[mtb_aart] CHECK CONSTRAINT [CHK_mtb_aart_rap_conv2]",
|
||||
"ALTER TABLE [dbo].[mtb_aart] WITH NOCHECK ADD CONSTRAINT [CHK_mtb_aart_rap_conv3] CHECK (([unt_mis3] is not null and [rap_conv3]<>(0)or [unt_mis3] is null))",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240718125945 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,6 +11,8 @@ public class Migration_20240718125945 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateTrigger("t_UpdProgMagaInsT", "CREATE TRIGGER [dbo].[t_UpdProgMagaInsT]\n" +
|
||||
" ON [dbo].[dtb_ordt]\n" +
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240719163828 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -10,6 +11,9 @@ public class Migration_20240719163828 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("CountAllegatiCommessa", "CREATE FUNCTION [dbo].[CountAllegatiCommessa](@codJcom VARCHAR(10), @userName VARCHAR(40))\n" +
|
||||
" RETURNS INTEGER\n" +
|
||||
"AS\n" +
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240722092015 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateProcedure("MRP_UpdateQtaImpProx", "CREATE Procedure [dbo].[MRP_UpdateQtaImpProx](@elencoArticoli varchar(max) = null)\n" +
|
||||
"AS \n" +
|
||||
"--DECLARE @elencoarticoli VARCHAR(MAX) = 'CEBIO75DMB'\n" +
|
||||
"--DROP TABLE #tmp\n" +
|
||||
"\n" +
|
||||
"SET NOCOUNT ON;\n" +
|
||||
"DECLARE @tableart TABLE\n" +
|
||||
" (\n" +
|
||||
" cod_mart VARCHAR(15)\n" +
|
||||
" );\n" +
|
||||
"\n" +
|
||||
"IF @elencoarticoli IS NOT NULL AND @elencoarticoli <> ''\n" +
|
||||
" BEGIN\n" +
|
||||
" INSERT INTO @tableart\n" +
|
||||
" SELECT *\n" +
|
||||
" FROM dbo.parsestringintoarray(@elencoarticoli, '|')\n" +
|
||||
" END\n" +
|
||||
"ELSE\n" +
|
||||
" BEGIN\n" +
|
||||
" INSERT INTO @tableart\n" +
|
||||
" SELECT mtb_aart.cod_mart\n" +
|
||||
" FROM mtb_aart\n" +
|
||||
" INNER JOIN jtb_cicl ON mtb_aart.cod_mart = jtb_cicl.cod_mart\n" +
|
||||
" WHERE mtb_aart.flag_stato = 'A'\n" +
|
||||
" END;\n" +
|
||||
"\n" +
|
||||
"WITH imp_ordini AS (SELECT mtb_part.cod_mart,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN SUM(mtb_part.qta_imp_cli) > SUM(mtb_part.qta_esistente + mtb_part.qta_ord_for) THEN\n" +
|
||||
" SUM(mtb_part.qta_imp_cli - (mtb_part.qta_esistente + mtb_part.qta_ord_for))\n" +
|
||||
" ELSE 0 END AS qtadaprodurre,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN SUM(mtb_part.qta_imp_cli) > SUM(mtb_part.qta_esistente + mtb_part.qta_ord_for) THEN\n" +
|
||||
" SUM(mtb_part.qta_imp_cli - (mtb_part.qta_esistente + mtb_part.qta_ord_for)) /\n" +
|
||||
" mtb_aart.qta_cnf\n" +
|
||||
" ELSE 0 END AS numdaprodurre,\n" +
|
||||
" SUM((mtb_part.qta_esistente + mtb_part.qta_ord_for) - mtb_part.qta_imp_cli) AS qta_disp\n" +
|
||||
" \n" +
|
||||
" FROM mtb_part\n" +
|
||||
" INNER JOIN jtb_cicl ON mtb_part.cod_mart = jtb_cicl.cod_prod\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_part.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN @tableart a ON mtb_aart.cod_mart = a.cod_mart\n" +
|
||||
" WHERE mtb_aart.flag_stato = 'A'\n" +
|
||||
" GROUP BY mtb_part.cod_mart, mtb_aart.unt_mis, mtb_aart.qta_cnf\n" +
|
||||
" HAVING SUM(mtb_part.qta_esistente + mtb_part.qta_ord_for) <> SUM(mtb_part.qta_imp_cli) \n" +
|
||||
" \n" +
|
||||
" \n" +
|
||||
" )\n" +
|
||||
" , imp_contratti AS ( SELECT c.cod_mart,\n" +
|
||||
" ISNULL(SUM((qta_vend_contratto - qta_ord - qta_doc) /\n" +
|
||||
" CASE WHEN c.rap_conv = 0 THEN 1 ELSE c.rap_conv END), 0) AS qtacontratto\n" +
|
||||
" FROM vvw_contratti_vendita c\n" +
|
||||
" INNER JOIN @tableart a ON c.cod_mart = a.cod_mart\n" +
|
||||
" WHERE c.data_fine >= CAST(GETDATE() AS DATE)\n" +
|
||||
" GROUP BY c.cod_mart\n" +
|
||||
" HAVING ISNULL(SUM(qta_residua), 0) > 0)\n" +
|
||||
" , imp_budget AS (SELECT b.cod_mart,\n" +
|
||||
" SUM(qta_saldo) AS qta_bdg\n" +
|
||||
" FROM ovw_budget_ordv b\n" +
|
||||
" INNER JOIN @tableart a ON b.cod_mart = a.cod_mart\n" +
|
||||
" WHERE CAST(GETDATE() AS DATE) BETWEEN b.data_iniz AND b.data_fine\n" +
|
||||
" AND qta_saldo <> 0\n" +
|
||||
" GROUP BY b.cod_mart)\n" +
|
||||
" , tmp_impegni\n" +
|
||||
" AS (SELECT ISNULL(ISNULL(imp_ordini.cod_mart, imp_contratti.cod_mart), imp_budget.cod_mart) AS cod_mart,\n" +
|
||||
" SUM(ISNULL(imp_ordini.qtadaprodurre, 0)) AS qtadaprodurre,\n" +
|
||||
" SUM(ISNULL(imp_ordini.numdaprodurre, 0)) AS numdaprodurre,\n" +
|
||||
" SUM(ISNULL(imp_contratti.qtacontratto -\n" +
|
||||
" ISNULL(CASE WHEN imp_ordini.qta_disp > 0 THEN imp_ordini.qta_disp ELSE 0 END, 0),\n" +
|
||||
" 0)) AS qtacontratto,\n" +
|
||||
" SUM(ISNULL(imp_budget.qta_bdg, 0)) AS qtabudget\n" +
|
||||
" \n" +
|
||||
" FROM imp_ordini\n" +
|
||||
" FULL OUTER JOIN imp_contratti ON imp_ordini.cod_mart = imp_contratti.cod_mart\n" +
|
||||
" FULL OUTER JOIN imp_budget ON imp_ordini.cod_mart = imp_budget.cod_mart\n" +
|
||||
" \n" +
|
||||
" GROUP BY ISNULL(ISNULL(imp_ordini.cod_mart, imp_contratti.cod_mart), imp_budget.cod_mart)\n" +
|
||||
" HAVING SUM(ISNULL(imp_ordini.qtadaprodurre, 0)) <> 0\n" +
|
||||
" OR SUM(ISNULL(imp_contratti.qtacontratto -\n" +
|
||||
" ISNULL(CASE WHEN imp_ordini.qta_disp > 0 THEN imp_ordini.qta_disp ELSE 0 END, 0), 0)) <> 0\n" +
|
||||
" OR SUM(ISNULL(imp_budget.qta_bdg, 0)) <> 0)\n" +
|
||||
"\n" +
|
||||
"SELECT materiali.cod_mart,\n" +
|
||||
" materiali.cod_prod,\n" +
|
||||
" jtb_fasi.cod_mdep_lav AS cod_mdep,\n" +
|
||||
" SUM(qtadaprodurre * ((materiali.qta_prod * materiali.rap_conv) /\n" +
|
||||
" (jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod))) AS impegnatoprox,\n" +
|
||||
" SUM(qtacontratto * ((materiali.qta_prod * materiali.rap_conv) /\n" +
|
||||
" (jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod))) AS impproxcontratto,\n" +
|
||||
" SUM(qtabudget * ((materiali.qta_prod * materiali.rap_conv) /\n" +
|
||||
" (jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod))) AS impproxbudget,\n" +
|
||||
" /*\n" +
|
||||
" max(case when ord.gestione = 'L' THEN max_data_cons else null end ) as data_imp_prox,\n" +
|
||||
" max(case when ord.gestione = 'A' THEN max_data_cons else null end ) as data_imp_prox_contr\n" +
|
||||
" */\n" +
|
||||
" IsNull(max(ORD.data_imp_prox), convert(date,GetDate())) as data_imp_prox,\n" +
|
||||
" IsNull(max(ORD.data_imp_prox_contr), convert(date,GetDate())) as data_imp_prox_contr\n" +
|
||||
"INTO #tmp\n" +
|
||||
"FROM tmp_impegni\n" +
|
||||
" INNER JOIN\n" +
|
||||
" (\n" +
|
||||
" SELECT cod_mart, descrizione_estesa, unt_mis_prod AS unt_doc, rap_conv_prod AS rap_conv, qta_prod, cod_prod\n" +
|
||||
" FROM [dbo].getmaterialidistinta(NULL)\n" +
|
||||
" WHERE cod_parent IS NOT NULL) materiali ON materiali.cod_prod = tmp_impegni.cod_mart\n" +
|
||||
" INNER JOIN jtb_cicl ON materiali.cod_prod = jtb_cicl.cod_prod\n" +
|
||||
" INNER JOIN jtb_fasi ON jtb_cicl.cod_jfas = jtb_fasi.cod_jfas \n" +
|
||||
" LEFT OUTER JOIN (\n" +
|
||||
" /* Modifcata da Massimo 10/07/24 la vecchia query creva quantità doppie in presenza di ordini L e A\n" +
|
||||
" select cod_mart, dtb_ordt.gestione, MAX(dtb_ordr.data_cons) as max_data_cons\n" +
|
||||
" from dtb_ordt inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||
" and dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||
" and dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" where dtb_ordt.gestione <> 'V' AND\n" +
|
||||
" dtb_ordt.flag_annulla = 'N' and\n" +
|
||||
" dtb_ordt.flag_budget = 0 and\n" +
|
||||
" dtb_ordt.flag_sospeso = 'N' and\n" +
|
||||
" dtb_ordt.flag_evaso_forzato = 'N' and \n" +
|
||||
" dtb_ordr.flag_evaso = 'I' \n" +
|
||||
" group by cod_mart, dtb_ordt.gestione\n" +
|
||||
" */\n" +
|
||||
" Select isNull(ODL.cod_mart,ODA.cod_mart) as cod_mart, ODL.data_imp_prox, ODA.data_imp_prox_contr\n" +
|
||||
" from \n" +
|
||||
" (select cod_mart, dtb_ordt.gestione, MAX(dtb_ordr.data_cons) as data_imp_prox\n" +
|
||||
" from dtb_ordt inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||
" and dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||
" and dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" where dtb_ordt.gestione = 'L' AND\n" +
|
||||
" dtb_ordt.flag_annulla = 'N' and\n" +
|
||||
" dtb_ordt.flag_budget = 0 and\n" +
|
||||
" dtb_ordt.flag_sospeso = 'N' and\n" +
|
||||
" dtb_ordt.flag_evaso_forzato = 'N' and \n" +
|
||||
" dtb_ordr.flag_evaso = 'I' \n" +
|
||||
" group by cod_mart, dtb_ordt.gestione\n" +
|
||||
" )ODL full outer join\n" +
|
||||
" (\n" +
|
||||
" select cod_mart, dtb_ordt.gestione, MAX(dtb_ordr.data_cons) as data_imp_prox_contr\n" +
|
||||
" from dtb_ordt inner join dtb_ordr on dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||
" and dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||
" and dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" where dtb_ordt.gestione = 'A' AND\n" +
|
||||
" dtb_ordt.flag_annulla = 'N' and\n" +
|
||||
" dtb_ordt.flag_budget = 0 and\n" +
|
||||
" dtb_ordt.flag_sospeso = 'N' and\n" +
|
||||
" dtb_ordt.flag_evaso_forzato = 'N' and \n" +
|
||||
" dtb_ordr.flag_evaso = 'I' \n" +
|
||||
" \n" +
|
||||
" group by cod_mart, dtb_ordt.gestione)\n" +
|
||||
" ODA on ODA.cod_mart = ODL.cod_mart\n" +
|
||||
" ) ORD ON materiali.cod_mart = ORD.cod_mart\n" +
|
||||
"GROUP BY materiali.cod_prod,\n" +
|
||||
" materiali.cod_mart,\n" +
|
||||
" jtb_fasi.cod_mdep_lav\n" +
|
||||
" \n" +
|
||||
"SELECT cod_mart,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" SUM(impegnatoprox) AS impegnatoprox,\n" +
|
||||
" SUM(impproxcontratto) AS impproxcontratto,\n" +
|
||||
" SUM(impproxbudget) AS impproxbudget,\n" +
|
||||
" data_imp_prox,\n" +
|
||||
" case when data_imp_prox_contr < data_imp_prox then data_imp_prox else data_imp_prox_contr end as data_imp_prox_contr\n" +
|
||||
" --case when data_imp_prox_contr is null then isNull(data_imp_prox,convert(date,GetDate())) else data_imp_prox_contr end as data_imp_prox_contr\n" +
|
||||
" --IIF( data_imp_prox is null or data_imp_prox < Cast(getdate() as date), Cast(getdate() as date), data_imp_prox) as data_imp_prox,\n" +
|
||||
" --IIF( data_imp_prox_contr is null or isNull(data_imp_prox_contr,data_imp_prox) < Cast(getdate() as date), Cast(getdate() as date), data_imp_prox_contr) as data_imp_prox_contr \n" +
|
||||
"INTO #tmpsum\n" +
|
||||
"FROM #tmp\n" +
|
||||
"WHERE cod_mdep IS NOT NULL\n" +
|
||||
"GROUP BY cod_mart, cod_mdep,\n" +
|
||||
" data_imp_prox,\n" +
|
||||
" data_imp_prox_contr\n" +
|
||||
"\n" +
|
||||
"INSERT INTO mtb_part (cod_mart, cod_mdep, scorta_min, qta_esistente, qta_imp_cli, qta_imp_lav, qta_ord_for)\n" +
|
||||
"SELECT cod_mart, cod_mdep, 0, 0, 0, 0, 0\n" +
|
||||
"FROM #tmpsum t\n" +
|
||||
"WHERE NOT EXISTS(SELECT * FROM mtb_part WHERE mtb_part.cod_mart = t.cod_mart AND mtb_part.cod_mdep = t.cod_mdep)\n" +
|
||||
"\n" +
|
||||
"IF @elencoarticoli IS NULL OR @elencoarticoli = ''\n" +
|
||||
" UPDATE mtb_part SET qta_imp_prox = 0, qta_imp_prox_contr = 0, qta_imp_prox_bdg = 0, data_imp_prox = null, data_imp_prox_contr = null\n" +
|
||||
"ELSE\n" +
|
||||
" UPDATE mtb_part\n" +
|
||||
" SET qta_imp_prox = 0,\n" +
|
||||
" qta_imp_prox_contr = 0,\n" +
|
||||
" qta_imp_prox_bdg = 0,\n" +
|
||||
" data_imp_prox = null, \n" +
|
||||
" data_imp_prox_contr = null \n" +
|
||||
" WHERE cod_mart IN (SELECT cod_mart FROM #tmpsum)\n" +
|
||||
"\n" +
|
||||
"UPDATE mtb_part\n" +
|
||||
"SET qta_imp_prox = q.impegnatoprox,\n" +
|
||||
" qta_imp_prox_contr = q.impproxcontratto,\n" +
|
||||
" qta_imp_prox_bdg = q.impproxbudget,\n" +
|
||||
" data_imp_prox = DateAdd(day, 1, q.data_imp_prox), \n" +
|
||||
" data_imp_prox_contr = DateAdd(day, 1, q.data_imp_prox_contr )\n" +
|
||||
"FROM mtb_part\n" +
|
||||
" INNER JOIN #tmpsum q ON mtb_part.cod_mdep = q.cod_mdep AND mtb_part.cod_mart = q.cod_mart\n" +
|
||||
"\n" +
|
||||
"IF EXISTS(SELECT *\n" +
|
||||
" FROM #tmp\n" +
|
||||
" WHERE cod_mdep IS NULL)\n" +
|
||||
" BEGIN\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" DECLARE @message VARCHAR(MAX), @email VARCHAR(MAX)\n" +
|
||||
"\n" +
|
||||
" SELECT @email = e_mail FROM stb_email WHERE flag_default = 'S';\n" +
|
||||
"\n" +
|
||||
" SET @message = 'Verificare i seguenti articoli: la fase non ha il deposito agganciato.' + CHAR(10) + CHAR(13)\n" +
|
||||
" SELECT @message = @message +\n" +
|
||||
" STUFF((SELECT ',' + cod_prod\n" +
|
||||
" FROM #tmp\n" +
|
||||
" WHERE cod_mdep IS NULL\n" +
|
||||
" FOR XML PATH('')), 1, 1, '')\n" +
|
||||
"\n" +
|
||||
" EXECUTE [dbo].[sp_sendEmail] @email, 'helpdesk@integry.it', 'Errore Impegni Prossimi', @message\n" +
|
||||
"\n" +
|
||||
" END");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240722095833 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE mtb_tipi\n" +
|
||||
" ADD flag_attivo bit default 1",
|
||||
"UPDATE mtb_tipi SET flag_attivo = 1",
|
||||
"ALTER TABLE mtb_tipi ALTER COLUMN flag_attivo bit NOT NULL;");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public class Migration_20240722120944 extends BaseMigration implements Migration
|
||||
if (!isCustomerDb(IntegryCustomerDB.Carelli_Winact))
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("steup_getGrigliaVendita", "CREATE FUNCTION [dbo].[steup_getGrigliaVendita](\n" +
|
||||
" @codMdep VARCHAR(5), @codJfas VARCHAR(5)\n" +
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240722133058 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("COD_ALIS", "COD_ALIS", "SELECT cod_alis FROM atb_list where flag_attivo = 'S'");
|
||||
createSetup("DATI_AZIENDA", "GIACENZA_DA_INV", "LISTINI_ACQUISTO", null, null, false, "COD_ALIS", false, false, false, false, false, null, true, "SELECT cod_alis FROM atb_list where flag_attivo = 'S'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240723185410 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!existsSetup("PVM", "MONITORAGGIO_LINEE_V2", "MOSTRA_QUARANTENA"))
|
||||
createSetup(
|
||||
"PVM", "MONITORAGGIO_LINEE_V2", "MOSTRA_QUARANTENA",
|
||||
null, "Flag per mostrare o meno per linea la scelta se mettere il collo in quarantena o no.", false, "SI_NO",
|
||||
false, false, false, false, false, "jtb_fasi", false
|
||||
);
|
||||
|
||||
String codDtipProvv = null;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Gramm_Gramm)) {
|
||||
codDtipProvv = "Q35";
|
||||
}
|
||||
|
||||
if (!existsSetup("MES", "SETUP", "COD_DTIP_PROVV"))
|
||||
createSetup(
|
||||
"MES", "SETUP", "COD_DTIP_PROVV",
|
||||
codDtipProvv, "Cod. dtip provv usato per indicare i colli in quarantena.", null
|
||||
);
|
||||
}
|
||||
|
||||
@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.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240725113812 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE mtb_grup\n" +
|
||||
" ADD flag_tracciabilita bit default 0",
|
||||
"UPDATE mtb_grup SET flag_tracciabilita = 0",
|
||||
"ALTER TABLE mtb_grup ALTER COLUMN flag_tracciabilita bit NOT NULL;");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,528 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240725150448 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Agricoper_Agricoper)) {
|
||||
return;
|
||||
}
|
||||
|
||||
createOrUpdateView("CRP_OF_FabbisognoOre_JSON", "CREATE VIEW [dbo].[CRP_OF_FabbisognoOre_JSON] AS\n" +
|
||||
" --Prende tutte le righe degli ordini di vendita da confezionare in sede ed produce una riga di raccolta per ogni varietà inclusa nel confezionamento\n" +
|
||||
"/*SELECT CASE\n" +
|
||||
" WHEN jtb_cicl.cod_jfas = 'COMA' AND jtb_dist_clav_dir.cod_jfas = 'CONF' THEN 'SEDE'\n" +
|
||||
" ELSE 'CAMPAGNA' END AS luogo_lavoro,\n" +
|
||||
" --ISNULL(dtb_ordt.cod_jcom, CONVERT(VARCHAR(8), (YEAR(dtb_ordt.data_ord) - 2000) * 100000 + dtb_ordt.num_ord)) AS cod_jcom,\n" +
|
||||
" (SELECT DISTINCT ISNULL(ordV.cod_jcom,\n" +
|
||||
" CONVERT(VARCHAR(8), (YEAR(ordV.data_ord) - 2000) * 100000 + ordV.num_ord)) AS cod_jcom,\n" +
|
||||
" jc.descrizione AS desc_comm,\n" +
|
||||
" (SELECT MAX(kg_ord)\n" +
|
||||
" FROM (VALUES (ROUND((qta_ord - qta_evasa) * rap_conv * ma.peso_kg * distPF.perc_mp * 1.1, 0)),\n" +
|
||||
" (0)) AS t(kg_ord)) AS kg_ord\n" +
|
||||
" FROM dtb_ordt ordV\n" +
|
||||
" INNER JOIN dtb_ordr OrdVr ON OrdV.gestione = OrdVr.gestione AND\n" +
|
||||
" ordV.data_ord = OrdVr.data_ord AND\n" +
|
||||
" ordV.num_ord = OrdVr.num_ord AND\n" +
|
||||
" ordV.cod_anag = dtb_ordt.cod_anag AND\n" +
|
||||
" ordVr.cod_mart = dtb_ordr.cod_mart AND\n" +
|
||||
" ordVr.data_cons = dtb_ordr.data_cons\n" +
|
||||
" INNER JOIN mtb_aart ma ON OrdVr.cod_mart = ma.cod_mart\n" +
|
||||
" INNER JOIN jtb_comt jc ON ISNULL(ordV.cod_jcom,\n" +
|
||||
" CONVERT(VARCHAR(8), (YEAR(ordV.data_ord) - 2000) * 100000 + ordV.num_ord)) =\n" +
|
||||
" jc.cod_jcom\n" +
|
||||
" FOR JSON PATH) AS cod_jcom,\n" +
|
||||
" dtb_ordr.data_cons,\n" +
|
||||
" dtb_ordt.cod_anag,\n" +
|
||||
" gtb_anag.rag_soc,\n" +
|
||||
" dtb_ordt.cod_anag + ' - ' + gtb_anag.rag_soc AS cliente,\n" +
|
||||
" --ISNULL(vtb_dest.citta, gtb_anag.citta) AS citta,\n" +
|
||||
" '' AS citta,\n" +
|
||||
" dtb_ordr.cod_mart,\n" +
|
||||
" dtb_ordr.descrizione_estesa AS descrizione,\n" +
|
||||
" dtb_ordr.cod_mart + ' - ' + dtb_ordr.descrizione_estesa AS prodotto,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN SUM(qta_ord - qta_evasa) < 0 THEN 0\n" +
|
||||
" ELSE SUM((qta_ord - qta_evasa) * rap_conv) END *\n" +
|
||||
" distPf.perc_mp *\n" +
|
||||
" 1.1 AS qta_ord,\n" +
|
||||
" ROUND(CASE\n" +
|
||||
" WHEN SUM(qta_ord - qta_evasa) < 0 THEN 0\n" +
|
||||
" ELSE SUM((qta_ord - qta_evasa) * rap_conv * mtb_aart.peso_kg) END * distPf.perc_mp * 1.1, 0) AS kg_ord,\n" +
|
||||
" CEILING(CASE\n" +
|
||||
" WHEN SUM(num_cnf - num_cnf_evasa) < 0 THEN 0\n" +
|
||||
" ELSE SUM(dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa) END *\n" +
|
||||
" distPf.perc_mp *\n" +
|
||||
" 1.1) AS colli_ord,\n" +
|
||||
" dtb_ordr.qta_cnf,\n" +
|
||||
" CEILING(CASE\n" +
|
||||
" WHEN SUM(num_cnf - num_cnf_evasa) < 0 THEN 0\n" +
|
||||
" ELSE SUM((dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa) / dtb_ordr.colli_pedana) END *\n" +
|
||||
" distPf.perc_mp *\n" +
|
||||
" 1.1) AS pedane_ord,\n" +
|
||||
" jtb_dist_clav_dir.cod_jfas,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN jtb_cicl.cod_jfas = 'COMA' AND jtb_dist_clav_dir.cod_jfas = 'CONF' THEN 'COMA'\n" +
|
||||
" ELSE 'CONF' END AS luogo,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN SUM(qta_ord - qta_evasa) < 0 THEN 0\n" +
|
||||
" ELSE ROUND(SUM(qta_ord * rap_conv * jtb_dist_clav_dir.hr_time /\n" +
|
||||
" (jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod)) / 3600,\n" +
|
||||
" 2) END *\n" +
|
||||
" distPf.perc_mp AS ore_uomo_necessarie,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN jtb_dist_clav_dir.hr_time = 0 THEN 80\n" +
|
||||
" ELSE ISNULL(ROUND(jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod /\n" +
|
||||
" (jtb_dist_clav_dir.hr_time / 3600), 0),\n" +
|
||||
" 80) END AS produttivita,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" dtb_ordt.flag_sospeso,\n" +
|
||||
" (SELECT PF.cod_mart,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" (SELECT jtb_cicl.cod_jfas AS cod_jfas_sl,\n" +
|
||||
" jtb_cicl.cod_prod AS cod_sl,\n" +
|
||||
" jtb_cicl.descrizione_prod AS descr_sl,\n" +
|
||||
" sl.qta_cnf,\n" +
|
||||
" sl.colli_pedana,\n" +
|
||||
" jtb_dist_mate.perc_sfrido,\n" +
|
||||
" CONVERT(VARCHAR(20), CONVERT(INTEGER, ISNULL(mtb_part.qta_esistente, 0))) + ' ' +\n" +
|
||||
" mtb_aart.unt_mis AS giacenza\n" +
|
||||
" FROM jtb_cicl\n" +
|
||||
" INNER JOIN jtb_dist_mate ON jtb_cicl.cod_prod = jtb_dist_mate.cod_prod\n" +
|
||||
" INNER JOIN mtb_aart sl ON jtb_dist_mate.cod_prod = sl.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON jtb_dist_mate.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_grup\n" +
|
||||
" ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp AND\n" +
|
||||
" mtb_grup.tipo_mgrp = 'MP'\n" +
|
||||
" AND mtb_aart.cod_mart = PF.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_part\n" +
|
||||
" ON jtb_cicl.cod_mart = mtb_part.cod_mart AND mtb_part.cod_mdep =\n" +
|
||||
" (SELECT DBO.getGestSetup('CRUSCOTTO_PRODUZIONE', 'SETUP', 'COD_MDEP_SCAR'))\n" +
|
||||
" WHERE jtb_cicl.cod_jfas = 'RACC'\n" +
|
||||
" AND sl.flag_stato = 'A'\n" +
|
||||
" FOR JSON PATH) AS semilavorato\n" +
|
||||
" FROM jtb_dist_mate PF\n" +
|
||||
" INNER JOIN mtb_aart ON PF.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_grup ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp AND mtb_grup.tipo_mgrp = 'MP'\n" +
|
||||
" WHERE PF.cod_prod = distPF.cod_prod\n" +
|
||||
" AND PF.cod_mart = distPF.cod_mart\n" +
|
||||
" FOR JSON PATH) AS varieta,\n" +
|
||||
" dtb_ordr.cod_tcol_UL\n" +
|
||||
"FROM dtb_ordt\n" +
|
||||
" INNER JOIN dtb_ordr ON dtb_ordt.gestione = dtb_ordr.gestione AND dtb_ordt.data_ord = dtb_ordr.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" INNER JOIN jtb_cicl ON jtb_cicl.cod_prod = dtb_ordr.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN jtb_dist_clav_dir\n" +
|
||||
" ON jtb_dist_clav_dir.cod_prod = dtb_ordr.cod_mart AND jtb_dist_clav_dir.cod_jfas = 'RACC'\n" +
|
||||
" INNER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" LEFT OUTER JOIN vtb_dest ON dtb_ordt.cod_anag = vtb_dest.cod_anag AND dtb_ordt.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
" INNER JOIN\n" +
|
||||
" (SELECT jtb_cicl.cod_prod, jtb_dist_mate.cod_mart, jtb_dist_mate.qta_std / jtb_cicl.qta_prod AS perc_mp\n" +
|
||||
" FROM jtb_cicl\n" +
|
||||
" INNER JOIN jtb_dist_mate ON jtb_cicl.cod_prod = jtb_dist_mate.cod_prod\n" +
|
||||
" INNER JOIN mtb_aart ON jtb_dist_mate.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_grup ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp AND mtb_grup.tipo_mgrp = 'MP') distPF\n" +
|
||||
" ON dtb_ordr.cod_mart = distPF.cod_prod\n" +
|
||||
"\n" +
|
||||
"WHERE dtb_ordt.gestione = 'V'\n" +
|
||||
" AND dtb_ordr.data_cons >= DATEADD(DAY, -1, GETDATE())\n" +
|
||||
" AND flag_evaso = 'I'\n" +
|
||||
" AND flag_annulla = 'N'\n" +
|
||||
"--AND dtb_ordr.cod_mart = '150122-122' and data_cons = '2022/10/01'\n" +
|
||||
"\n" +
|
||||
"GROUP BY jtb_cicl.cod_jfas,\n" +
|
||||
" dtb_ordr.data_cons, gtb_anag.rag_soc, gtb_anag.citta, --vtb_dest.citta,\n" +
|
||||
" dtb_ordr.cod_mart,\n" +
|
||||
" dtb_ordr.descrizione_estesa, jtb_dist_clav_dir.cod_jfas, jtb_dist_clav_dir.hr_time, flag_sospeso,\n" +
|
||||
" dtb_ordt.cod_anag,\n" +
|
||||
" mtb_aart.unt_mis, distPf.perc_mp, distPF.cod_mart,\n" +
|
||||
" distPF.cod_mart, distPF.cod_prod,\n" +
|
||||
" jtb_cicl.qta_prod,\n" +
|
||||
" jtb_cicl.rap_conv_prod, dtb_ordr.cod_tcol_UL, dtb_ordr.qta_cnf*/\n" +
|
||||
"\n" +
|
||||
"WITH prodotti AS (SELECT PF.cod_mart,\n" +
|
||||
" PF.cod_prod,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" (SELECT jtb_cicl.cod_jfas AS cod_jfas_sl,\n" +
|
||||
" jtb_cicl.cod_prod AS cod_sl,\n" +
|
||||
" jtb_cicl.descrizione_prod AS descr_sl,\n" +
|
||||
" sl.qta_cnf,\n" +
|
||||
" sl.colli_pedana,\n" +
|
||||
" jtb_dist_mate.perc_sfrido,\n" +
|
||||
" CONVERT(VARCHAR(20), CONVERT(INTEGER, ISNULL(mtb_part.qta_esistente, 0))) + ' ' +\n" +
|
||||
" mtb_aart.unt_mis AS giacenza\n" +
|
||||
" FROM jtb_cicl\n" +
|
||||
" INNER JOIN jtb_dist_mate ON jtb_cicl.cod_prod = jtb_dist_mate.cod_prod\n" +
|
||||
" INNER JOIN mtb_aart sl ON jtb_dist_mate.cod_prod = sl.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON jtb_dist_mate.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_grup\n" +
|
||||
" ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp AND\n" +
|
||||
" mtb_grup.tipo_mgrp = 'MP'\n" +
|
||||
" AND mtb_aart.cod_mart = PF.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_part\n" +
|
||||
" ON jtb_cicl.cod_mart = mtb_part.cod_mart AND mtb_part.cod_mdep =\n" +
|
||||
" (SELECT DBO.getGestSetup('CRUSCOTTO_PRODUZIONE', 'SETUP', 'COD_MDEP_SCAR'))\n" +
|
||||
" WHERE jtb_cicl.cod_jfas = 'RACC'\n" +
|
||||
" AND sl.flag_stato = 'A'\n" +
|
||||
" FOR JSON PATH) AS semilavorato\n" +
|
||||
" FROM jtb_dist_mate PF\n" +
|
||||
" INNER JOIN mtb_aart ON PF.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_grup\n" +
|
||||
" ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp AND mtb_grup.tipo_mgrp = 'MP'),\n" +
|
||||
" varieta AS (SELECT prodotti.cod_mart,\n" +
|
||||
" prodotti.cod_prod,\n" +
|
||||
" prodotti.descrizione,\n" +
|
||||
" (SELECT cod_mart, descrizione, semilavorato\n" +
|
||||
" FROM prodotti varieta2\n" +
|
||||
" WHERE varieta2.cod_prod = prodotti.cod_prod\n" +
|
||||
" AND varieta2.cod_mart = prodotti.cod_mart\n" +
|
||||
" FOR JSON PATH) AS json_varieta\n" +
|
||||
" FROM prodotti),\n" +
|
||||
" colliL AS (SELECT mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.data_collo,\n" +
|
||||
" SUM(mtb_colr.num_cnf) AS num_cnf,\n" +
|
||||
" SUM(ma.qta_cnf * mtb_colr.num_cnf) AS qta_col_teo,\n" +
|
||||
" SUM(mtb_colr.qta_col) AS qta_col_eff\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" INNER JOIN mtb_aart ma ON mtb_colr.cod_mart = ma.cod_mart\n" +
|
||||
" INNER JOIN mtb_colt ON mtb_colr.gestione = mtb_colt.gestione AND\n" +
|
||||
" mtb_colr.data_collo = mtb_colt.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND\n" +
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||
" WHERE mtb_colr.gestione = 'L'\n" +
|
||||
" AND mtb_colt.segno = 1\n" +
|
||||
" GROUP BY mtb_colr.cod_mart, mtb_colr.data_collo),\n" +
|
||||
" colliV AS (SELECT mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_jcom,\n" +
|
||||
" mtb_colr.gestione,\n" +
|
||||
" mtb_colr.data_ord,\n" +
|
||||
" mtb_colr.num_ord,\n" +
|
||||
" SUM(mtb_colr.num_cnf) AS num_cnf,\n" +
|
||||
" SUM(ma.qta_cnf * mtb_colr.num_cnf) AS qta_col_teo,\n" +
|
||||
" SUM(mtb_colr.qta_col) AS qta_col_eff\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" INNER JOIN mtb_aart ma ON mtb_colr.cod_mart = ma.cod_mart\n" +
|
||||
" INNER JOIN mtb_colt ON mtb_colr.gestione = mtb_colt.gestione AND\n" +
|
||||
" mtb_colr.data_collo = mtb_colt.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND\n" +
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||
" WHERE mtb_colr.gestione = 'V'\n" +
|
||||
" AND mtb_colt.segno = -1\n" +
|
||||
" AND mtb_colt.data_doc IS NULL\n" +
|
||||
" GROUP BY mtb_colr.cod_mart, mtb_colr.cod_jcom, mtb_colr.gestione, mtb_colr.data_ord, mtb_colr.num_ord),\n" +
|
||||
" qtaPianConf AS (SELECT cod_prod,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" MAX(flag_evaso_prod) AS flag_evaso_prod,\n" +
|
||||
" SUM(qta_pian) AS qta_pian,\n" +
|
||||
" SUM(colli_pian) AS colli_pian\n" +
|
||||
" FROM (SELECT DISTINCT luogo_lavoro,\n" +
|
||||
" dopp.cod_jfas,\n" +
|
||||
" dopp.cod_anag,\n" +
|
||||
" dopp.cod_prod,\n" +
|
||||
" cod_sl,\n" +
|
||||
" dopp.cod_jcom,\n" +
|
||||
" dopp.cod_mart,\n" +
|
||||
" magaz,\n" +
|
||||
" CASE WHEN do.flag_evaso_prod = 'E' THEN 1 ELSE 0 END AS flag_evaso_prod,\n" +
|
||||
" CEILING(SUM(CASE WHEN do.flag_evaso_prod = 'E' THEN 0 ELSE qta_ord END)\n" +
|
||||
" OVER (PARTITION BY dopp.cod_jfas, do.num_ord, dopp.cod_prod, dopp.cod_jcom))\n" +
|
||||
" AS qta_pian,\n" +
|
||||
" CEILING(SUM(CASE WHEN do.flag_evaso_prod = 'E' THEN 0 ELSE qta_ord END /\n" +
|
||||
" ma.qta_cnf)\n" +
|
||||
" OVER (PARTITION BY dopp.cod_jfas, do.num_ord, dopp.cod_prod, dopp.cod_jcom))\n" +
|
||||
" AS colli_pian,\n" +
|
||||
" dopp.data_ord\n" +
|
||||
" FROM dtb_ordr_pian_prod dopp\n" +
|
||||
" LEFT OUTER JOIN dtb_ordt do\n" +
|
||||
" ON dopp.gestione = do.gestione\n" +
|
||||
" AND dopp.data_ord = do.data_ord\n" +
|
||||
" AND do.num_ord = dopp.num_ord\n" +
|
||||
" LEFT OUTER JOIN mtb_aart ma ON dopp.cod_prod = ma.cod_mart\n" +
|
||||
" WHERE magaz = 0\n" +
|
||||
" AND dopp.cod_jcom IS NOT NULL\n" +
|
||||
" AND (data_piano >= CAST(GETDATE() AS DATE) OR do.num_ord IS NOT NULL)) t\n" +
|
||||
" GROUP BY cod_prod, cod_jcom),\n" +
|
||||
" qtaPianiRacc AS (SELECT cod_mart,\n" +
|
||||
" data_piano,\n" +
|
||||
" MAX(flag_evaso_prod) AS flag_evaso_prod,\n" +
|
||||
" SUM(qta_pian) AS qta_pian\n" +
|
||||
" FROM (SELECT DISTINCT dopp.cod_mart,\n" +
|
||||
" CASE WHEN do.flag_evaso_prod = 'E' THEN 1 ELSE 0 END AS flag_evaso_prod,\n" +
|
||||
" CEILING(SUM(CASE WHEN do.flag_evaso_prod = 'E' THEN 0 ELSE qta_ord END)\n" +
|
||||
" OVER (PARTITION BY dopp.data_piano, dopp.cod_mart))\n" +
|
||||
" AS qta_pian,\n" +
|
||||
" dopp.data_piano\n" +
|
||||
" FROM dtb_ordr_pian_prod dopp\n" +
|
||||
" LEFT OUTER JOIN dtb_ordt do\n" +
|
||||
" ON dopp.gestione = do.gestione\n" +
|
||||
" AND dopp.data_ord = do.data_ord\n" +
|
||||
" AND do.num_ord = dopp.num_ord\n" +
|
||||
" WHERE dopp.cod_jfas = 'RACC'\n" +
|
||||
" AND data_piano >= CAST(GETDATE() AS DATE)) t\n" +
|
||||
" GROUP BY cod_mart, data_piano),\n" +
|
||||
" ordiniResiduiConf AS (SELECT CASE\n" +
|
||||
" WHEN jtb_cicl.cod_jfas = 'COMA' AND jtb_dist_clav_dir.cod_jfas = 'CONF'\n" +
|
||||
" THEN 'SEDE'\n" +
|
||||
" ELSE 'CAMPAGNA' END AS luogo_lavoro,\n" +
|
||||
" ISNULL(dtb_ordt.cod_jcom,\n" +
|
||||
" CONVERT(VARCHAR(8), (YEAR(dtb_ordt.data_ord) - 2000) * 100000 + dtb_ordt.num_ord)) AS cod_jcom,\n" +
|
||||
" dtb_ordr.data_cons,\n" +
|
||||
" dtb_ordt.cod_anag,\n" +
|
||||
" gtb_anag.rag_soc,\n" +
|
||||
" dtb_ordt.cod_anag + ' - ' + gtb_anag.rag_soc AS cliente,\n" +
|
||||
" dtb_ordr.cod_mart,\n" +
|
||||
" dtb_ordr.descrizione,\n" +
|
||||
" dtb_ordr.cod_mart + ' - ' + dtb_ordr.descrizione AS prodotto,\n" +
|
||||
" --MAX(qtaPian.flag_evaso_prod) AS flag_evaso_prod,\n" +
|
||||
" (dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa) * mtb_aart.qta_cnf *\n" +
|
||||
" mtb_aart.peso_kg AS kg_ord,\n" +
|
||||
" qtaPianConf.qta_pian,\n" +
|
||||
" calc.kg_residui AS kg_residui,\n" +
|
||||
" qtaPianConf.colli_pian,\n" +
|
||||
" calc.colli_residui AS colli_residui,\n" +
|
||||
" mtb_aart.qta_cnf,\n" +
|
||||
" dtb_ordr.colli_pedana,\n" +
|
||||
" CEILING(qtaPianConf.colli_pian / dtb_ordr.colli_pedana) AS pedane_pian,\n" +
|
||||
" CEILING(calc.colli_residui / dtb_ordr.colli_pedana) AS pedane_residue,\n" +
|
||||
" jtb_dist_clav_dir.cod_jfas,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN jtb_cicl.cod_jfas = 'COMA' AND jtb_dist_clav_dir.cod_jfas = 'CONF'\n" +
|
||||
" THEN 'COMA'\n" +
|
||||
" ELSE 'CONF' END AS luogo,\n" +
|
||||
" ROUND(calc.kg_residui * jtb_dist_clav_dir.hr_time /\n" +
|
||||
" (jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod) / 3600,\n" +
|
||||
" 2) AS ore_uomo_necessarie,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN jtb_dist_clav_dir.hr_time = 0 THEN 80\n" +
|
||||
" ELSE ISNULL(ROUND(jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod /\n" +
|
||||
" (jtb_dist_clav_dir.hr_time / 3600), 0),\n" +
|
||||
" 80) END AS produttivita,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" dtb_ordt.flag_sospeso,\n" +
|
||||
" dtb_ordr.cod_tcol_UL,\n" +
|
||||
" (SELECT MP.cod_mart, MP.descrizione, MP.perc_sfrido\n" +
|
||||
" FROM (SELECT jtb_cicl.cod_jfas AS cod_jfas_sl,\n" +
|
||||
" jtb_dist_mate.cod_mart,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" jtb_cicl.cod_prod AS cod_sl,\n" +
|
||||
" jtb_cicl.descrizione_prod AS descr_sl,\n" +
|
||||
" jtb_dist_mate.perc_sfrido\n" +
|
||||
" FROM jtb_cicl\n" +
|
||||
" INNER JOIN jtb_dist_mate ON jtb_cicl.cod_prod = jtb_dist_mate.cod_prod\n" +
|
||||
" INNER JOIN mtb_aart ON jtb_dist_mate.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_grup\n" +
|
||||
" ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp AND mtb_grup.tipo_mgrp = 'MP'\n" +
|
||||
" WHERE jtb_cicl.cod_prod = dtb_ordr.cod_mart) MP\n" +
|
||||
" FOR JSON AUTO) varieta\n" +
|
||||
" FROM dtb_ordt\n" +
|
||||
" INNER JOIN dtb_ordr ON dtb_ordt.gestione = dtb_ordr.gestione AND\n" +
|
||||
" dtb_ordt.data_ord = dtb_ordr.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" INNER JOIN jtb_cicl ON jtb_cicl.cod_prod = dtb_ordr.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN jtb_dist_clav_dir\n" +
|
||||
" ON jtb_dist_clav_dir.cod_prod = dtb_ordr.cod_mart AND\n" +
|
||||
" jtb_dist_clav_dir.cod_jfas <> 'RACC'\n" +
|
||||
" INNER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" LEFT OUTER JOIN vtb_dest ON dtb_ordt.cod_anag = vtb_dest.cod_anag AND\n" +
|
||||
" dtb_ordt.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
" LEFT OUTER JOIN colliV ON colliV.cod_mart = dtb_ordr.cod_mart AND\n" +
|
||||
" colliV.cod_jcom = dtb_ordt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN qtaPianConf ON dtb_ordr.cod_mart = qtaPianConf.cod_prod AND\n" +
|
||||
" dtb_ordt.cod_jcom = qtaPianConf.cod_jcom\n" +
|
||||
" CROSS APPLY(SELECT ROUND(CEILING(dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa -\n" +
|
||||
" ISNULL(colliV.num_cnf, 0) -\n" +
|
||||
" (ISNULL(qtaPianConf.colli_pian, 0))) *\n" +
|
||||
" mtb_aart.qta_cnf *\n" +
|
||||
" mtb_aart.peso_kg, 0) AS kg_residui,\n" +
|
||||
" CEILING(dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa -\n" +
|
||||
" ISNULL(colliV.num_cnf, 0) -\n" +
|
||||
" (ISNULL(qtaPianConf.colli_pian, 0))) AS colli_residui) calc\n" +
|
||||
" WHERE dtb_ordt.gestione = 'V'\n" +
|
||||
" AND dtb_ordr.data_cons >= DATEADD(DAY, -1, GETDATE())\n" +
|
||||
" AND flag_evaso = 'I'\n" +
|
||||
" AND flag_annulla = 'N'),\n" +
|
||||
" ordiniResidui AS (SELECT 'CAMPAGNA' AS luogo_lavoro,\n" +
|
||||
" NULL AS cod_jcom,\n" +
|
||||
" data_cons,\n" +
|
||||
" NULL AS cod_anag,\n" +
|
||||
" NULL AS rag_soc,\n" +
|
||||
" NULL AS cliente,\n" +
|
||||
" distPF.cod_mart,\n" +
|
||||
" varieta.descrizione AS descrizione,\n" +
|
||||
" distPF.cod_mart + ' - ' + varieta.descrizione AS prodotto,\n" +
|
||||
" -- 0 AS flag_evaso_prod,\n" +
|
||||
" qtaPianiRacc.qta_pian AS qta_pian,\n" +
|
||||
" ROUND(IIF(SUM(ordiniResiduiConf.kg_ord *\n" +
|
||||
" distPF.perc_mp * 1.1) - ISNULL(qtaPianiRacc.qta_pian, 0) > 0,\n" +
|
||||
" SUM(ordiniResiduiConf.kg_ord *\n" +
|
||||
" distPF.perc_mp * 1.1) - ISNULL(qtaPianiRacc.qta_pian, 0),\n" +
|
||||
" 0),\n" +
|
||||
" 0) AS kg_residui,\n" +
|
||||
" 0 AS colli_pian,\n" +
|
||||
" 0 AS colli_residui,\n" +
|
||||
" semilavorato.qta_cnf,\n" +
|
||||
" semilavorato.colli_pedana,\n" +
|
||||
" 0 AS pedane_pian,\n" +
|
||||
" 0 AS pedane_residue,\n" +
|
||||
" 'RACC' AS cod_jfas,\n" +
|
||||
" 'CONF' AS luogo,\n" +
|
||||
" ROUND(IIF(ROUND(SUM((ordiniResiduiConf.kg_ord *\n" +
|
||||
" distPF.perc_mp * 1.1)), 0) - ISNULL(qtaPianiRacc.qta_pian, 0) > 0,\n" +
|
||||
" ROUND(SUM((ordiniResiduiConf.kg_ord *\n" +
|
||||
" distPF.perc_mp * 1.1)), 0) - ISNULL(qtaPianiRacc.qta_pian, 0),\n" +
|
||||
" 0) / 100\n" +
|
||||
" , 2) AS ore_uomo_necessarie,\n" +
|
||||
" 100 AS produttivita, -- Da perfezionare nel servizio dal calcolo: ROUND(jtb_cicl.qta_prod * jtb_cicl.rap_conv_prod / (jtb_dist_clav_dir.hr_time / 3600), 0)\n" +
|
||||
" 'KG' AS unt_mis,\n" +
|
||||
" 'N' AS flag_sospeso,\n" +
|
||||
" NULL AS cod_tcol_UL,\n" +
|
||||
" varieta.json_varieta AS varieta\n" +
|
||||
" FROM ordiniResiduiConf\n" +
|
||||
" INNER JOIN (SELECT jtb_cicl.cod_prod,\n" +
|
||||
" jtb_dist_mate.cod_mart,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" mtb_aart.peso_kg,\n" +
|
||||
" jtb_dist_mate.qta_std / jtb_cicl.qta_prod AS perc_mp\n" +
|
||||
" FROM jtb_cicl\n" +
|
||||
" INNER JOIN jtb_dist_mate ON jtb_cicl.cod_prod = jtb_dist_mate.cod_prod\n" +
|
||||
" INNER JOIN mtb_aart ON jtb_dist_mate.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_grup\n" +
|
||||
" ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp AND mtb_grup.tipo_mgrp = 'MP') distPF\n" +
|
||||
" ON ordiniResiduiConf.cod_mart = distPF.cod_prod\n" +
|
||||
" INNER JOIN jtb_cicl ON jtb_cicl.cod_prod = ordiniResiduiConf.cod_mart\n" +
|
||||
" INNER JOIN jtb_dist_clav_dir\n" +
|
||||
" ON jtb_dist_clav_dir.cod_prod = ordiniResiduiConf.cod_mart AND\n" +
|
||||
" jtb_dist_clav_dir.cod_jfas = 'RACC'\n" +
|
||||
" INNER JOIN varieta ON varieta.cod_prod = distPF.cod_prod AND\n" +
|
||||
" varieta.cod_mart = distPF.cod_mart\n" +
|
||||
" CROSS APPLY OPENJSON(varieta.json_varieta, N'$') WITH (\n" +
|
||||
" cod_mart VARCHAR(200),\n" +
|
||||
" semilavorato NVARCHAR(MAX) AS JSON\n" +
|
||||
" ) AS varieta2\n" +
|
||||
" OUTER APPLY OPENJSON(varieta2.semilavorato, '$[0]')\n" +
|
||||
" WITH (\n" +
|
||||
" qta_cnf NUMERIC(15, 5),\n" +
|
||||
" colli_pedana NUMERIC(15, 5)\n" +
|
||||
" ) AS semilavorato\n" +
|
||||
" LEFT OUTER JOIN colliL ON colliL.data_collo = ordiniResiduiConf.data_cons AND\n" +
|
||||
" colliL.cod_mart = ordiniResiduiConf.cod_mart\n" +
|
||||
" LEFT OUTER JOIN qtaPianiRacc ON distPF.cod_mart = qtaPianiRacc.cod_mart AND\n" +
|
||||
" ordiniResiduiConf.data_cons = qtaPianiRacc.data_piano\n" +
|
||||
" WHERE flag_sospeso = 'N'\n" +
|
||||
" GROUP BY ordiniResiduiConf.data_cons,\n" +
|
||||
" distPF.cod_mart,\n" +
|
||||
" varieta.descrizione,\n" +
|
||||
" varieta.json_varieta,\n" +
|
||||
" semilavorato.qta_cnf,\n" +
|
||||
" semilavorato.colli_pedana,\n" +
|
||||
" qtaPianiRacc.qta_pian\n" +
|
||||
"\n" +
|
||||
" UNION ALL\n" +
|
||||
"\n" +
|
||||
"-- Prende tutte le righe degli ordini di vendita con i dati della distinta di confezionamento di sede o di campagna\n" +
|
||||
" SELECT luogo_lavoro,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" data_cons,\n" +
|
||||
" cod_anag,\n" +
|
||||
" rag_soc,\n" +
|
||||
" cliente,\n" +
|
||||
" cod_mart,\n" +
|
||||
" descrizione,\n" +
|
||||
" prodotto,\n" +
|
||||
" qta_pian,\n" +
|
||||
" kg_residui,\n" +
|
||||
" colli_pian,\n" +
|
||||
" colli_residui,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" colli_pedana,\n" +
|
||||
" pedane_pian,\n" +
|
||||
" pedane_residue,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" luogo,\n" +
|
||||
" ore_uomo_necessarie,\n" +
|
||||
" produttivita,\n" +
|
||||
" unt_mis,\n" +
|
||||
" flag_sospeso,\n" +
|
||||
" cod_tcol_UL,\n" +
|
||||
" varieta\n" +
|
||||
" FROM ordiniResiduiConf)\n" +
|
||||
"SELECT luogo_lavoro,\n" +
|
||||
" (SELECT jc.cod_jcom,\n" +
|
||||
" jc.descrizione AS desc_comm,\n" +
|
||||
" kg_residui AS kg_ord,\n" +
|
||||
" colli_residui AS colli_ord,\n" +
|
||||
" pedane_residue AS pedane_ord\n" +
|
||||
" FROM ordiniResidui orJson\n" +
|
||||
" INNER JOIN jtb_comt jc ON orJson.cod_jcom = jc.cod_jcom\n" +
|
||||
" WHERE orJson.cod_anag = ordiniResidui.cod_anag\n" +
|
||||
" AND orJson.cod_mart = ordiniResidui.cod_mart\n" +
|
||||
" AND orJson.data_cons = ordiniResidui.data_cons\n" +
|
||||
" AND orJson.cod_tcol_UL = ordiniResidui.cod_tcol_UL\n" +
|
||||
" AND orJson.colli_pedana = ordiniResidui.colli_pedana\n" +
|
||||
" FOR JSON AUTO) AS cod_jcom,\n" +
|
||||
" data_cons,\n" +
|
||||
" cod_anag,\n" +
|
||||
" rag_soc,\n" +
|
||||
" cliente,\n" +
|
||||
" ordiniResidui.cod_mart,\n" +
|
||||
" ordiniResidui.descrizione,\n" +
|
||||
" prodotto,\n" +
|
||||
" SUM(qta_pian) AS qta_pian,\n" +
|
||||
" SUM(kg_residui) AS kg_ord,\n" +
|
||||
" SUM(colli_pian) AS colli_pian,\n" +
|
||||
" SUM(colli_residui) AS colli_ord,\n" +
|
||||
" ordiniResidui.qta_cnf,\n" +
|
||||
" ordiniResidui.colli_pedana,\n" +
|
||||
" SUM(pedane_pian) AS pedane_pian,\n" +
|
||||
" SUM(pedane_residue) AS pedane_ord,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" luogo,\n" +
|
||||
" SUM(ore_uomo_necessarie) AS ore_uomo_necessarie,\n" +
|
||||
" produttivita,\n" +
|
||||
" ordiniResidui.unt_mis,\n" +
|
||||
" flag_sospeso,\n" +
|
||||
" ordiniResidui.cod_tcol_UL,\n" +
|
||||
" mt.descrizione AS desc_pedana,\n" +
|
||||
" varieta,\n" +
|
||||
" ma.qta_cnf AS qta_cnf_prod,\n" +
|
||||
" ma.colli_pedana AS colli_pedana_prod\n" +
|
||||
"FROM ordiniResidui\n" +
|
||||
" INNER JOIN mtb_aart ma ON ordiniResidui.cod_mart = ma.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_tcol mt ON ordiniResidui.cod_tcol_UL = mt.cod_tcol\n" +
|
||||
"GROUP BY luogo_lavoro,\n" +
|
||||
" data_cons,\n" +
|
||||
" cod_anag,\n" +
|
||||
" rag_soc,\n" +
|
||||
" cliente,\n" +
|
||||
" ordiniResidui.cod_mart,\n" +
|
||||
" ordiniResidui.descrizione,\n" +
|
||||
" prodotto,\n" +
|
||||
" ordiniResidui.qta_cnf,\n" +
|
||||
" ordiniResidui.colli_pedana,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" luogo,\n" +
|
||||
" produttivita,\n" +
|
||||
" ordiniResidui.unt_mis,\n" +
|
||||
" flag_sospeso,\n" +
|
||||
" ordiniResidui.cod_tcol_UL,\n" +
|
||||
" mt.descrizione,\n" +
|
||||
" varieta,\n" +
|
||||
" ma.qta_cnf,\n" +
|
||||
" ma.colli_pedana");
|
||||
}
|
||||
|
||||
@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.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240725153539 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Auricchio_Auricchio)){
|
||||
updateSetupValue("W_GANAG_RC", "SETUP", "ABILITA_NUM_DICH_PLAFOND_IVA", "S");
|
||||
|
||||
} else {
|
||||
updateSetupValue("W_GANAG_RC", "SETUP", "ABILITA_NUM_DICH_PLAFOND_IVA", "N");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -431,6 +431,60 @@ public class AccountingRules extends QueryRules {
|
||||
|
||||
}
|
||||
|
||||
public static List<CrlScadParr> completeCrlParrScadScad(Connection conn, CtbScad ctbScad) throws Exception {
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM crl_scad_parr\n" +
|
||||
"where tipo_anag = %s \n" +
|
||||
" and cod_anag = %s\n" +
|
||||
" and anno_part = %s\n" +
|
||||
" and ser_doc = %s\n" +
|
||||
" and num_doc = %s\n" +
|
||||
" and id_riga_scad = %s\n" +
|
||||
" and num_cmov = %s\n" +
|
||||
" and id_riga_mov = %s ",
|
||||
ctbScad.getTipoAnag(),
|
||||
ctbScad.getCodAnag(),
|
||||
ctbScad.getAnnoPart(),
|
||||
ctbScad.getSerDoc(),
|
||||
ctbScad.getNumDoc(),
|
||||
ctbScad.getIdRiga(),
|
||||
ctbScad.getNumCmov(),
|
||||
ctbScad.getIdRigaMov());
|
||||
List<CrlScadParr> crlScadParrs = UtilityDB.executeSimpleQueryDTO(conn, sql, CrlScadParr.class);
|
||||
|
||||
crlScadParrs.stream().forEach(x->x.setOperation(OperationType.DELETE));
|
||||
|
||||
if (crlScadParrs != null && crlScadParrs.size() > 0 ){
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM ctb_parr\n" +
|
||||
"where tipo_anag = %s \n" +
|
||||
" and cod_anag = %s\n" +
|
||||
" and anno_part = %s\n" +
|
||||
" and ser_doc = %s\n" +
|
||||
" and num_doc = %s\n" +
|
||||
" and num_cmov = %s\n" +
|
||||
" and id_riga = %s ",
|
||||
ctbScad.getTipoAnag(),
|
||||
ctbScad.getCodAnag(),
|
||||
ctbScad.getAnnoPart(),
|
||||
ctbScad.getSerDoc(),
|
||||
ctbScad.getNumDoc(),
|
||||
ctbScad.getNumCmov(),
|
||||
ctbScad.getIdRigaMov());
|
||||
List<CtbParr> ctbParr = UtilityDB.executeSimpleQueryDTO(conn, sql, CtbParr.class);
|
||||
ctbParr.stream().forEach(x->x.setOperation(OperationType.DELETE));
|
||||
ctbScad.setCtbParr(ctbParr);
|
||||
}
|
||||
|
||||
|
||||
return crlScadParrs;
|
||||
|
||||
}
|
||||
|
||||
public static List<CtbParr> InsertCtbParr(Connection conn, CtbMovr ctbMovr) throws Exception {
|
||||
String desAgg;
|
||||
|
||||
@@ -538,7 +592,18 @@ public class AccountingRules extends QueryRules {
|
||||
.setIdRigaScad(ctbScad.getIdRiga())
|
||||
.setIdRigaMov(ctbMovr.getIdRiga())
|
||||
.setNumCmov(ctbMovr.getNumCmov());
|
||||
crlScadParr.setOperation(OperationType.INSERT);
|
||||
|
||||
String where = crlScadParr.getEntityHolder().getWhereCondFields(crlScadParr);
|
||||
String sql = "SELECT id FROM " + crlScadParr.getTableName();
|
||||
sql = UtilityDB.addwhereCond(sql, where, true);
|
||||
|
||||
Long id = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
if (id == null )
|
||||
crlScadParr.setOperation(OperationType.INSERT);
|
||||
else {
|
||||
crlScadParr.setId(id);
|
||||
crlScadParr.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
ctbScad
|
||||
.setIdRigaMov(ctbMovr.getIdRiga())
|
||||
.setCrlScadParr(new ArrayList<>()).getCrlScadParr().add(crlScadParr);
|
||||
|
||||
@@ -4,13 +4,11 @@ import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.rules.businessLogic.enums.TipoEmissione;
|
||||
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity.common.DtbBaseDocT;
|
||||
import it.integry.ems_model.entity.common.DtbDocOrdT;
|
||||
import it.integry.ems_model.rules.util.DroolsUtil;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
@@ -826,7 +824,7 @@ public class DocumentRules extends QueryRules {
|
||||
public static String completePartitaMag(Connection conn, DtbDocr dtbDocr) throws Exception {
|
||||
String partitaMag = null;
|
||||
if (!dtbDocr.getGestione().equalsIgnoreCase("V") &&
|
||||
setupGest.getSetupBoolean("DTB_DOCT", "TRACCIABILITA", "ASS_AUTOMATICA_PARTITA_" + dtbDocr.getGestione())) {
|
||||
setupGest.getSetupBoolean(conn, "DTB_DOCT", "TRACCIABILITA", "ASS_AUTOMATICA_PARTITA_" + dtbDocr.getGestione())) {
|
||||
|
||||
DatiPartitaMagDTO datiPartita =
|
||||
new DatiPartitaMagDTO()
|
||||
|
||||
@@ -852,19 +852,19 @@ public class SalesRules extends QueryRules {
|
||||
Boolean ret = false;
|
||||
String query =
|
||||
Query.format(
|
||||
"SELECT TOP 1 cod_promo, " +
|
||||
"data_iniz, " +
|
||||
"data_fine, " +
|
||||
"versione " +
|
||||
" FROM dbo.getPromozioneVendita( %s, %s, %s , null, %s) " +
|
||||
" WHERE tipo_variazione <> 'D' AND" +
|
||||
" versione <> %s",
|
||||
"SELECT TOP 1 cod_promo, " +
|
||||
"data_iniz, " +
|
||||
"data_fine, " +
|
||||
"versione " +
|
||||
" FROM dbo.getPromozioneVendita( %s, %s, %s , null, %s) " +
|
||||
" WHERE tipo_variazione <> 'D' AND" +
|
||||
" versione <> %s",
|
||||
entity.getDataIniz(),
|
||||
entity.getDataFine(),
|
||||
entity.getCodVlis(),
|
||||
entity.getCodMart(),
|
||||
entity.getVersione()==null?0:entity.getVersione()
|
||||
);
|
||||
entity.getVersione() == null ? 0 : entity.getVersione()
|
||||
);
|
||||
|
||||
HashMap<String, Object> datiPromo = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, query);
|
||||
if (UtilityHashMap.isPresent(datiPromo)) {
|
||||
@@ -1175,11 +1175,29 @@ public class SalesRules extends QueryRules {
|
||||
return;
|
||||
}
|
||||
|
||||
int indexOfLastPosizione = viaggiGiorno.indexOf(viaggiGiorno.stream()
|
||||
.filter(viaggio -> !viaggio.getIdViaggio().equalsIgnoreCase(vtbViaggi.getIdViaggio()) && Objects.equals(viaggio.getPosizione(), vtbViaggi.getPosizione())).findFirst().orElse(null));
|
||||
VtbViaggi lastDataViaggio = viaggiGiorno.stream()
|
||||
.filter(viaggio -> viaggio.getIdViaggio().equalsIgnoreCase(vtbViaggi.getIdViaggio()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
if (indexOfLastPosizione != -1) {
|
||||
viaggiGiorno.add(indexOfLastPosizione, vtbViaggi);
|
||||
if (lastDataViaggio != null) {
|
||||
viaggiGiorno.remove(lastDataViaggio);
|
||||
}
|
||||
|
||||
int indexOfViaggioConNuovaPos = viaggiGiorno.indexOf(viaggiGiorno.stream()
|
||||
.filter(viaggio -> viaggio.getPosizione().equals(vtbViaggi.getPosizione())).findFirst().orElse(null));
|
||||
|
||||
if (indexOfViaggioConNuovaPos != -1) {
|
||||
if (lastDataViaggio != null && vtbViaggi.getPosizione() > lastDataViaggio.getPosizione()) {
|
||||
indexOfViaggioConNuovaPos += 1;
|
||||
}
|
||||
|
||||
viaggiGiorno.add(indexOfViaggioConNuovaPos, vtbViaggi);
|
||||
} else {
|
||||
viaggiGiorno.add(vtbViaggi);
|
||||
|
||||
viaggiGiorno = Stream.of(viaggiGiorno)
|
||||
.sortBy(VtbViaggi::getPosizione)
|
||||
.toList();
|
||||
}
|
||||
|
||||
Stream.of(viaggiGiorno)
|
||||
|
||||
@@ -1448,7 +1448,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
final Object value = fieldsWithoutIdentityAndNotNull.get(i - 1).getSecond();
|
||||
insertBulkPs.setObject(i, value);
|
||||
|
||||
// traceSql = traceSql.replaceFirst("\\?", UtilityDB.valueToString(value).replaceAll("\\$", "\\\\\\$"));
|
||||
traceSql = traceSql.replace("?", UtilityDB.valueToString(value));
|
||||
}
|
||||
|
||||
logger.trace("Query tracing: {}", traceSql);
|
||||
|
||||
@@ -294,6 +294,7 @@ public class EmsRestConstants {
|
||||
public static final String PATH_GET_ACTIVITY_HISTORY = PATH + "activity/getActivityHistory";
|
||||
public static final String PATH_SET_ACTIVITY_SOLVED = PATH + "activity/activitySolved";
|
||||
public static final String PATH_GET_OLD_UPDATE = PATH + "activity/oldUpdate";
|
||||
public static final String PATH_SEARCH_ACTIVITY = PATH + "activity/searchActivity";
|
||||
public static final String PATH_SUGGEST_ACTIVITY_DESCRIPTION = PATH + "activity/suggestActivityDescription";
|
||||
//SteUP
|
||||
public static final String PATH_LOGIN_STEUP = PATH + "login";
|
||||
|
||||
@@ -15,10 +15,10 @@ public class CrlScadParr extends EntityBase {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String ENTITY = "crl_scad_parr";
|
||||
|
||||
@Unique
|
||||
@SqlField(value = "anno_part")
|
||||
private Integer annoPart;
|
||||
|
||||
@Unique
|
||||
@SqlField(value = "cod_anag")
|
||||
private String codAnag;
|
||||
|
||||
@@ -27,22 +27,28 @@ public class CrlScadParr extends EntityBase {
|
||||
@SqlField(value = "id")
|
||||
private Long id;
|
||||
|
||||
@Unique
|
||||
@SqlField(value = "id_riga_mov")
|
||||
private Integer idRigaMov;
|
||||
|
||||
@Unique
|
||||
@ImportFromParent(value = "idRiga")
|
||||
@SqlField(value = "id_riga_scad")
|
||||
private Integer idRigaScad;
|
||||
|
||||
@Unique
|
||||
@SqlField(value = "num_cmov")
|
||||
private Integer numCmov;
|
||||
|
||||
@Unique
|
||||
@SqlField(value = "num_doc")
|
||||
private Integer numDoc;
|
||||
|
||||
@Unique
|
||||
@SqlField(value = "ser_doc")
|
||||
private String serDoc;
|
||||
|
||||
@Unique
|
||||
@SqlField(value = "tipo_anag")
|
||||
private String tipoAnag;
|
||||
|
||||
|
||||
@@ -111,9 +111,14 @@ public class CtbScad extends EntityBase {
|
||||
@JsonProperty(value = "is_insoluto")
|
||||
private Boolean isInsoluto;
|
||||
|
||||
private Boolean riaperta;
|
||||
|
||||
@EntityChild
|
||||
private List<CrlScadParr> crlScadParr;
|
||||
|
||||
@Priority(value = 101, copyPk = false)
|
||||
private List<CtbParr> ctbParr;
|
||||
|
||||
public CtbScad() {
|
||||
super();
|
||||
}
|
||||
@@ -361,6 +366,15 @@ public class CtbScad extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getRiaperta() {
|
||||
return riaperta;
|
||||
}
|
||||
|
||||
public CtbScad setRiaperta(Boolean riaperta) {
|
||||
this.riaperta = riaperta;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<CrlScadParr> getCrlScadParr() {
|
||||
return crlScadParr;
|
||||
}
|
||||
@@ -370,14 +384,21 @@ public class CtbScad extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<CtbParr> getCtbParr() {
|
||||
return ctbParr;
|
||||
}
|
||||
|
||||
public CtbScad setCtbParr(List<CtbParr> ctbParr) {
|
||||
this.ctbParr = ctbParr;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void insertChilds() throws Exception {
|
||||
if (getCrlScadParr() != null) {
|
||||
for (CrlScadParr crlScadParr : getCrlScadParr()) {
|
||||
if (crlScadParr.getIdRigaScad() == null)
|
||||
crlScadParr.setIdRigaScad(getIdRiga());
|
||||
if (crlScadParr.getIdRigaMov() == null)
|
||||
crlScadParr.setIdRigaMov(getIdRigaMov());
|
||||
if (crlScadParr.getIdRigaScad() == null) crlScadParr.setIdRigaScad(getIdRiga());
|
||||
if (crlScadParr.getIdRigaMov() == null) crlScadParr.setIdRigaMov(getIdRigaMov());
|
||||
crlScadParr.manageWithParentConnection(connection, crlScadParr.getOperation(), dataCompleting, entityHolder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,14 @@ package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@@ -1297,6 +1301,28 @@ public class MtbAart extends EntityBase implements EquatableEntityInterface<MtbA
|
||||
|
||||
@Override
|
||||
protected void deleteChilds() throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
"WHERE NOT EXISTS (SELECT * FROM dtb_docr WHERE mtb_aart.cod_mart = dtb_docr.cod_mart)\n" +
|
||||
" AND NOT EXISTS(SELECT * FROM dtb_ordr WHERE mtb_aart.cod_mart = dtb_ordr.cod_mart)\n" +
|
||||
" AND NOT EXISTS(SELECT * FROM mtb_movi WHERE mtb_aart.cod_mart = mtb_movi.cod_mart)\n" +
|
||||
" AND mtb_aart.cod_mart = %s",
|
||||
this.codMart
|
||||
);
|
||||
boolean isPresent = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
if (isPresent){
|
||||
MtbPartDt mtbPartDt = new MtbPartDt();
|
||||
mtbPartDt.deleteAllEntities(connection, this);
|
||||
MtbSartDt mtbSartDt = new MtbSartDt();
|
||||
mtbSartDt.deleteAllEntities(connection, this);
|
||||
MtbPart mtbPart = new MtbPart();
|
||||
mtbPart.deleteAllEntities(connection, this);
|
||||
MtbSart mtbSart = new MtbSart();
|
||||
mtbSart.deleteAllEntities(connection, this);
|
||||
}
|
||||
|
||||
MtbSpes mtbSpes = new MtbSpes();
|
||||
mtbSpes.deleteAllEntities(connection, this);
|
||||
MtbComp mtbComp = new MtbComp();
|
||||
|
||||
@@ -41,6 +41,9 @@ public class MtbGrup extends EntityBase implements EquatableEntityInterface<MtbG
|
||||
@SqlField(value = "flag_attivo", nullable = false, defaultObjectValue = "1")
|
||||
private Boolean flagAttivo;
|
||||
|
||||
@SqlField(value = "flag_tracciabilita", nullable = false, defaultObjectValue = "0")
|
||||
private Boolean flagTracciabilita;
|
||||
|
||||
@EntityChild
|
||||
private List<MtbSgrp> mtbSgrp;
|
||||
|
||||
@@ -131,6 +134,14 @@ public class MtbGrup extends EntityBase implements EquatableEntityInterface<MtbG
|
||||
this.flagAttivo = flagAttivo;
|
||||
}
|
||||
|
||||
public Boolean getFlagTracciabilita() {
|
||||
return flagTracciabilita;
|
||||
}
|
||||
|
||||
public void setFlagTracciabilita(Boolean flagTracciabilita) {
|
||||
this.flagTracciabilita = flagTracciabilita;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteChilds() throws Exception {
|
||||
MtbSfam mtbSfam = new MtbSfam();
|
||||
|
||||
@@ -26,6 +26,9 @@ public class MtbTipi extends EntityBase implements EquatableEntityInterface<MtbT
|
||||
@SqlField(value = "descrizione", maxLength = 40, nullable = false)
|
||||
private String descrizione;
|
||||
|
||||
@SqlField(value = "flag_attivo", nullable = false, defaultObjectValue = "1")
|
||||
private Boolean flagAttivo;
|
||||
|
||||
@EntityChild
|
||||
private List<MtbStip> mtbStip;
|
||||
|
||||
@@ -68,6 +71,10 @@ public class MtbTipi extends EntityBase implements EquatableEntityInterface<MtbT
|
||||
this.mtbTipiCarat = mtbTipiCarat;
|
||||
}
|
||||
|
||||
public Boolean getFlagAttivo() { return flagAttivo;}
|
||||
|
||||
public void setFlagAttivo(Boolean flagAttivo) { this.flagAttivo = flagAttivo; }
|
||||
|
||||
@Override
|
||||
protected void deleteChilds() throws Exception {
|
||||
MtbTipiCarat mtbTipiCarat = new MtbTipiCarat();
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package it.integry.ems_model.exception;
|
||||
|
||||
public class GestSetupNotFoundException extends Exception {
|
||||
|
||||
public GestSetupNotFoundException(String gestName, String section, String keySection) {
|
||||
super(String.format(
|
||||
"Setup non configurata. Configurarla in %s->%s->%s",
|
||||
gestName,
|
||||
section,
|
||||
keySection
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package it.integry.ems_model.rulescompleting;
|
||||
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.event.rule.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -29,9 +27,7 @@ public class AgendaList extends DefaultAgendaEventListener {
|
||||
public void beforeMatchFired(BeforeMatchFiredEvent event) {
|
||||
if (mapTotalTimeGroupRule.get(event.getMatch().getRule().getName()) == null)
|
||||
mapTotalTimeGroupRule.put(event.getMatch().getRule().getName(), System.nanoTime());
|
||||
String message = new Date() + " RULE " + event.getMatch().getRule().getName() + " before apply...";
|
||||
if (UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer())
|
||||
System.out.println(message);
|
||||
String message = event.getMatch().getRule().getName() + " before apply...";
|
||||
logger.trace(message);
|
||||
}
|
||||
|
||||
@@ -40,9 +36,7 @@ public class AgendaList extends DefaultAgendaEventListener {
|
||||
Long lastVal = mapTotalTimeGroupRule.get(event.getMatch().getRule().getName());
|
||||
mapTotalTimeGroupRule.put(event.getMatch().getRule().getName(), System.nanoTime() - lastVal);
|
||||
|
||||
String errorText = new Date() + " RULE " + event.getMatch().getRule().getName() + " applyed";
|
||||
if (UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer())
|
||||
System.out.println(errorText);
|
||||
String errorText = event.getMatch().getRule().getName() + " applyed";
|
||||
logger.trace(errorText);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -390,6 +390,19 @@ then
|
||||
modify ( $entity ) { setDataDoc(dataDoc) }
|
||||
end
|
||||
|
||||
|
||||
|
||||
rule "completeCrlParrScad"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$entity: CtbScad(riaperta != null && riaperta && numCmov !=null)
|
||||
then
|
||||
List<CrlScadParr> crlScadParrs = AccountingRules.completeCrlParrScadScad(conn, $entity);
|
||||
modify ( $entity ) { setCrlScadParr(crlScadParrs) }
|
||||
end
|
||||
|
||||
|
||||
rule "completeCodPagaMov"
|
||||
no-loop
|
||||
when
|
||||
|
||||
@@ -343,4 +343,13 @@ public class ActivityController {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.suggestActivityDescription(activityType));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = EmsRestConstants.PATH_SEARCH_ACTIVITY, method = RequestMethod.POST)
|
||||
public ServiceRestResponse searchActivity(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody SearchActivityDTO searchActivityDTO) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.searchActivity(searchActivityDTO));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import it.integry.ems.activity.dto.SteUPEntryDTO;
|
||||
import it.integry.ems.activity.dto.SteUpScoreDTO;
|
||||
import it.integry.ems.activity.exception.IspezioneCompletataException;
|
||||
import it.integry.ems.activity.service.SteUPService;
|
||||
import it.integry.ems.document.fatture.xml.postacert.Data;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.response.StatusResponse;
|
||||
@@ -17,13 +18,16 @@ import it.integry.ems_model.utility.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bouncycastle.jcajce.provider.asymmetric.ec.KeyFactorySpi;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -343,10 +347,11 @@ public class SteUPController {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "allieamentoStruttudaDb", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse allieamentoStruttudaDb(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB ) {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB) {
|
||||
try {
|
||||
steUPService.allineamentoStrutturaDb(profileDB);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
@@ -354,6 +359,16 @@ public class SteUPController {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "deleteInspections", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse deleteInspections(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date dataInizio,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date dataFine) throws Exception {
|
||||
|
||||
steUPService.deleteInspections(dataInizio, dataFine);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
public class SearchActivityDTO {
|
||||
|
||||
private String activityId;
|
||||
private String codJcom;
|
||||
private String activityDescription;
|
||||
|
||||
public String getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
public SearchActivityDTO setActivityId(String activityId) {
|
||||
this.activityId = activityId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodJcom() {
|
||||
return codJcom;
|
||||
}
|
||||
|
||||
public SearchActivityDTO setCodJcom(String codJcom) {
|
||||
this.codJcom = codJcom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActivityDescription() {
|
||||
return activityDescription;
|
||||
}
|
||||
|
||||
public SearchActivityDTO setActivityDescription(String activityDescription) {
|
||||
this.activityDescription = activityDescription;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1273,6 +1273,17 @@ public class ActivityService {
|
||||
}
|
||||
}
|
||||
|
||||
String sql = Query.format(
|
||||
"SELECT cod_jfas\n" +
|
||||
"FROM stb_activity_type\n" +
|
||||
"WHERE activity_type_id = %s\n" +
|
||||
" AND flag_tipologia = %s",
|
||||
activity.getTipoAttivita(),
|
||||
activity.getFlagTipologia()
|
||||
);
|
||||
|
||||
String codJfas = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
StbActivity stbActivity = new StbActivity();
|
||||
stbActivity.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
@@ -1291,12 +1302,23 @@ public class ActivityService {
|
||||
.setPriorita(activity.getPriorita())
|
||||
.setCodMart(activity.getCodMart())
|
||||
.setFlagTipologia(activity.getFlagTipologia())
|
||||
.setParentActivityId(activity.getParentActivityId());
|
||||
.setParentActivityId(activity.getParentActivityId())
|
||||
.setCodJfas(codJfas);
|
||||
|
||||
entityProcessor.processEntity(stbActivity, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
public void updateActivityTask(ActivityTaskDTO activity) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT cod_jfas\n" +
|
||||
"FROM stb_activity_type\n" +
|
||||
"WHERE activity_type_id = %s\n" +
|
||||
" AND flag_tipologia = 'A'",
|
||||
activity.getActivityTypeId()
|
||||
);
|
||||
|
||||
String codJfas = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
StbActivity stbActivity = new StbActivity();
|
||||
stbActivity.setOperation(OperationType.UPDATE);
|
||||
|
||||
@@ -1580,4 +1602,176 @@ public class ActivityService {
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbActivityTyper.class);
|
||||
}
|
||||
|
||||
public List<ActivityDTO> searchActivity(SearchActivityDTO searchActivityDTO) throws Exception {
|
||||
List<String> whereCondList = new ArrayList<>();
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getActivityDescription())){
|
||||
whereCondList.add(
|
||||
"stb_activity.activity_description LIKE " +
|
||||
UtilityDB.valueToString("%" + searchActivityDTO.getActivityDescription().replaceAll("[*]", "%") + "%") +
|
||||
" \n"
|
||||
);
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getActivityId())){
|
||||
whereCondList.add("stb_activity.activity_id LIKE "+
|
||||
UtilityDB.valueToString("%" + searchActivityDTO.getActivityId().replaceAll("[*]", "%") + "%") +
|
||||
" \n"
|
||||
);
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getCodJcom())){
|
||||
whereCondList.add("stb_activity.cod_jcom LIKE "+
|
||||
UtilityDB.valueToString("%" + searchActivityDTO.getCodJcom().replaceAll("[*]", "%") + "%") +
|
||||
" \n"
|
||||
);
|
||||
}
|
||||
|
||||
StringBuilder sql = new StringBuilder("WITH escludi_commesse AS (SELECT value_string cod_jcom\n" +
|
||||
" FROM dbo.parsestringintoarray((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'STB_ACTIVITY'\n" +
|
||||
" AND section = 'SETUP'\n" +
|
||||
" AND key_section = 'ESCLUDI_COMMESSE'), '|') s),\n" +
|
||||
" sottoattivita AS (SELECT stb_activity.parent_activity_id,\n" +
|
||||
" MAX(IIF(effective_date <= CAST(GETDATE() AS DATE), effective_date, NULL)) AS last_activity_date,\n" +
|
||||
" MIN(IIF(estimated_date >= CAST(GETDATE() AS DATE), estimated_date, NULL)) AS next_activity_date,\n" +
|
||||
" MAX(IIF(\n" +
|
||||
" ((estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
|
||||
" estimated_date IS NULL) AND effective_date IS NULL),\n" +
|
||||
" stb_activity.activity_description,\n" +
|
||||
" NULL)) AS activity_description,\n" +
|
||||
" MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS planned_this_week,\n" +
|
||||
" MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, -1, GETDATE())) AND dbo.f_getLastDayOfWeek(DATEADD(WEEK, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS planned_previous_week,\n" +
|
||||
" MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, 1, GETDATE())) AND dbo.f_getLastDayOfWeek(DATEADD(WEEK, 1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS planned_next_week,\n" +
|
||||
" MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(GETDATE()) AND EOMONTH(GETDATE()),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS done_this_month,\n" +
|
||||
" MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(DATEADD(MONTH, -1, GETDATE())) AND EOMONTH(DATEADD(MONTH, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS done_previous_month,\n" +
|
||||
" MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" DATEPART(QUARTER, effective_date) = DATEPART(QUARTER, GETDATE()), 1,\n" +
|
||||
" 0)) AS done_this_quarter,\n" +
|
||||
" MAX(IIF(effective_date IS NOT NULL AND DATEPART(QUARTER, effective_date) =\n" +
|
||||
" DATEPART(QUARTER, DATEADD(MONTH, -3, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS done_previous_quarter,\n" +
|
||||
" SUM(jtb_rlavr.ore) AS ore\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" GROUP BY stb_activity.parent_activity_id)\n" +
|
||||
"SELECT stb_activity.cod_jcom AS 'Commessa',\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name AS 'Responsabile',\n" +
|
||||
" stb_activity.cod_mart,\n" +
|
||||
" IIF(stb_activity.cod_mart IS NULL, 'NESSUN PRODOTTO',\n" +
|
||||
" ISNULL(mtb_aart.descr_cassa, mtb_aart.descrizione)) AS descr_prodotto,\n" +
|
||||
" ISNULL(parent.project_description, '') AS 'project_description',\n" +
|
||||
" ISNULL(parent.activity_description, 'Altre Attività') AS 'parent_activity_description',\n" +
|
||||
" parent.activity_type_id AS 'parent_activity_type',\n" +
|
||||
" stb_activity.activity_type_id AS 'tipo_attivita',\n" +
|
||||
" ISNULL(stb_activity.ora_ins_act, stb_activity.data_ins_act) AS 'data_inserimento',\n" +
|
||||
" stb_activity.ora_mod_act AS 'ultima_modifica',\n" +
|
||||
" stb_activity.activity_id AS 'Id_Attivita',\n" +
|
||||
" stb_activity.activity_description AS 'Descrizione',\n" +
|
||||
" stb_activity.effective_time AS 'Data_Inizio_Effettiva',\n" +
|
||||
" stb_activity.effective_endtime AS 'Data_Fine_Effettiva',\n" +
|
||||
" stb_activity.activity_result_id AS 'Esito',\n" +
|
||||
" stb_activity.priorita,\n" +
|
||||
" CAST(CASE WHEN stb_activity.effective_endtime IS NULL THEN 0 ELSE 1 END AS BIT) AS 'attivita_chiusa',\n" +
|
||||
" stb_activity.estimated_time AS 'Data_Inizio_prev',\n" +
|
||||
" stb_activity.estimated_endtime AS 'data_fine_prev',\n" +
|
||||
" stb_activity.result_description AS 'descr_esito',\n" +
|
||||
" DENSE_RANK() OVER (ORDER BY parent.project_description, parent.activity_description) AS 'id_processo',\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.persona_rif AS 'richiedente',\n" +
|
||||
" parent.responabile_progetto,\n" +
|
||||
" CAST(ISNULL(sottoattivita.done_this_month, 0) AS BIT) AS done_this_month,\n" +
|
||||
" CAST(ISNULL(sottoattivita.done_previous_month, 0) AS BIT) AS done_previous_month,\n" +
|
||||
" CAST(ISNULL(sottoattivita.done_this_quarter, 0) AS BIT) AS done_this_quarter,\n" +
|
||||
" CAST(ISNULL(sottoattivita.done_previous_quarter, 0) AS BIT) AS done_previous_quarter,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita IS NULL THEN 0 --backlog\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 0 THEN 1 --programmato\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 1 THEN 2 --in corso\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 2 AND\n" +
|
||||
" stb_activity_result.flag_activity_result = -1 THEN 3 --sospesa\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 2 AND\n" +
|
||||
" stb_activity_result.flag_activity_result = 1 THEN 4 --test\n" +
|
||||
" ELSE 5 /*completata*/ END AS stato_attivita,\n" +
|
||||
" CAST(IIF(estimated_enddate < CAST(GETDATE() AS DATE), 1, 0) AS BIT) AS scaduta,\n" +
|
||||
" stb_activity.user_creator,\n" +
|
||||
" creator.full_name AS 'creata_da',\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" stb_activity.flag_risolto,\n" +
|
||||
" task.daPagare AS da_pagare,\n" +
|
||||
" task.aCanone AS a_canone\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" INNER JOIN (SELECT * FROM jtb_comt) jtb_comt ON stb_activity.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN sottoattivita ON stb_activity.activity_id = sottoattivita.parent_activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" INNER JOIN stb_user creator ON stb_activity.user_creator = creator.user_name\n" +
|
||||
" LEFT OUTER JOIN mtb_aart ON stb_activity.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN (SELECT parent.activity_description AS 'project_description',\n" +
|
||||
" stb_activity.activity_description AS 'activity_description',\n" +
|
||||
" stb_activity.activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.persona_rif AS 'responabile_progetto'\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN stb_activity parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" WHERE stb_activity.flag_tipologia = 'P') parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" LEFT OUTER JOIN stb_activity_result\n" +
|
||||
" ON stb_activity.activity_result_id = stb_activity_result.activity_result_id\n" +
|
||||
" OUTER APPLY (SELECT CAST(MAX(CASE WHEN task.cod_jfas <> 'C01' THEN 0 ELSE 1 END) AS BIT) AS daPagare,\n" +
|
||||
" CAST(MAX(CASE WHEN task.cod_jfas = 'C01' THEN 0 ELSE 1 END) AS BIT) AS aCanone\n" +
|
||||
" FROM stb_activity task\n" +
|
||||
" WHERE stb_activity.activity_id = task.parent_activity_id) task\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'P'\n" +
|
||||
" AND NOT EXISTS(SELECT *\n" +
|
||||
" FROM escludi_commesse\n" +
|
||||
" WHERE stb_activity.cod_jcom = escludi_commesse.cod_jcom)\n" +
|
||||
" AND stb_activity.activity_type_id IN (SELECT activity_type_id\n" +
|
||||
" FROM srl_activity_type\n" +
|
||||
" WHERE activity_type_id IN\n" +
|
||||
" (SELECT srl_activity_type.activity_type_id\n" +
|
||||
" FROM srl_activity_type,\n" +
|
||||
" stb_activity_type\n" +
|
||||
" WHERE srl_activity_type.flag_tipologia = 'P'\n" +
|
||||
" AND srl_activity_type.activity_type_id_next =\n" +
|
||||
" stb_activity_type.activity_type_id\n" +
|
||||
" AND srl_activity_type.flag_tipologia_next =\n" +
|
||||
" stb_activity_type.flag_tipologia\n" +
|
||||
" AND stb_activity_type.flag_attiva = 'S'\n" +
|
||||
" GROUP BY srl_activity_type.activity_type_id\n" +
|
||||
" HAVING COUNT(DISTINCT flag_tipologia_next) = 1)\n" +
|
||||
" AND flag_tipologia_next = 'A')\n");
|
||||
|
||||
if (whereCondList.size() == 1){
|
||||
sql.append(" AND ").append(whereCondList.get(0));
|
||||
} else {
|
||||
for (String whereCond : whereCondList){
|
||||
sql.append(" AND ").append(whereCond);
|
||||
}
|
||||
}
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql.toString(), ActivityDTO.class);
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
@@ -198,10 +199,10 @@ public class SteUPService {
|
||||
// VERIFICO: CHE SONO DIVERSI FRA LORO, E CHE ESISTONO NELLE OPZIONI SELEZIONABILI
|
||||
if (activityTypeIdRottura != null && activityTypeIdVerifica != null && !activityTypeIdRottura.equalsIgnoreCase(activityTypeIdVerifica)) {
|
||||
|
||||
if (!reas.contains(activityTypeIdVerifica)){
|
||||
if (!reas.contains(activityTypeIdVerifica)) {
|
||||
activityTypeIdVerifica = null;
|
||||
}
|
||||
if (!reas.contains(activityTypeIdRottura)){
|
||||
if (!reas.contains(activityTypeIdRottura)) {
|
||||
activityTypeIdRottura = null;
|
||||
}
|
||||
} else {
|
||||
@@ -459,7 +460,6 @@ public class SteUPService {
|
||||
Date dataCreation = UtilityDate.StringToDate(entry.getDataCreation(), CommonConstants.DATETIME_FORMAT_YMD);
|
||||
|
||||
|
||||
|
||||
if (UtilityString.isNullOrEmpty(activityTypeId))
|
||||
throw new Exception("Motivazione attività non presente");
|
||||
|
||||
@@ -691,10 +691,10 @@ public class SteUPService {
|
||||
UtilityString.equalsIgnoreCase(tipoAttivitaVerificaPromo, activityTypeId)) {
|
||||
boolean verificaVolantino = UtilityString.equalsIgnoreCase(tipoAttivitaVerificaVolantino, activityTypeId);
|
||||
barcodes = chkVolantino(codJfas, codMdep, barcodes, verificaVolantino, dataCreation);
|
||||
}else if(activityTypeId.equalsIgnoreCase(tipoAttivitaRotturaStock)){
|
||||
} else if (activityTypeId.equalsIgnoreCase(tipoAttivitaRotturaStock)) {
|
||||
|
||||
List<HashMap<String, Object>> pluRepo = getGrigliaPluRepo(codMdep,codJfas,activityTypeId,null, dataCreation);
|
||||
if(repartiFreschi != null && repartiFreschi.contains(codJfas)){
|
||||
List<HashMap<String, Object>> pluRepo = getGrigliaPluRepo(codMdep, codJfas, activityTypeId, null, dataCreation);
|
||||
if (repartiFreschi != null && repartiFreschi.contains(codJfas)) {
|
||||
List<String> finalBarcodes = barcodes;
|
||||
barcodes = new ArrayList<>();
|
||||
|
||||
@@ -705,14 +705,14 @@ public class SteUPService {
|
||||
String codMart = entry.getKey();
|
||||
List<HashMap<String, Object>> hashMapList = entry.getValue();
|
||||
|
||||
boolean containBarcode = hashMapList.stream().anyMatch(x->finalBarcodes.contains(((String) x.get("barcode"))));
|
||||
boolean containBarcode = hashMapList.stream().anyMatch(x -> finalBarcodes.contains(((String) x.get("barcode"))));
|
||||
|
||||
if (!containBarcode)
|
||||
barcodes.add(hashMapList.stream().findFirst().map(x->x.get("barcode").toString()).get());
|
||||
barcodes.add(hashMapList.stream().findFirst().map(x -> x.get("barcode").toString()).get());
|
||||
}
|
||||
// barcodes = pluRepo.stream().filter(a-> !finalBarcodes.contains(((String) a.get("barcode")))).map(a->(String) a.get("barcode")).collect(Collectors.toList());
|
||||
}else{
|
||||
barcodes = barcodes.stream().filter( a-> pluRepo.stream().map(x->x.get("barcode")).collect(Collectors.toList()).contains(a)).collect(Collectors.toList());
|
||||
} else {
|
||||
barcodes = barcodes.stream().filter(a -> pluRepo.stream().map(x -> x.get("barcode")).collect(Collectors.toList()).contains(a)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,7 +824,7 @@ public class SteUPService {
|
||||
String tipoAttivitaVerificaVolantino = setup.get("TIPO_ATTIVITA_VERIFICA_VOLANTINO");
|
||||
String tipoAttivitaVerificaPromo = setup.get("TIPO_ATTIVITA_VERIFICA_ALTRE_PROMO");
|
||||
String tipoAttivitaRotturaStock = setup.get("TIPO_ATTIVITA_ROTTURA_STOCK");
|
||||
List<String> repartiFreschi = Arrays.asList(StringUtils.split(UtilityString.isNull(setup.get("REPARTI_FRESCHI"),""), "|"));
|
||||
List<String> repartiFreschi = Arrays.asList(StringUtils.split(UtilityString.isNull(setup.get("REPARTI_FRESCHI"), ""), "|"));
|
||||
|
||||
if (UtilityString.isNullOrEmpty(activityTypeId)) {
|
||||
//se non aggiornano l'app il tipo attività non viene inviato e quindi diamo per scontato che si tratti di verifica volantino
|
||||
@@ -851,10 +851,10 @@ public class SteUPService {
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, false);
|
||||
} else if (activityTypeId.equalsIgnoreCase(tipoAttivitaRotturaStock)) {
|
||||
if (repartiFreschi.contains(codJfas)) {
|
||||
sql = "Select cod_mart,descrizione,bar_code as barcode,cod_msgr from steup_getGrigliaVendita("+ UtilityDB.valueToString(codMdep)+","+ UtilityDB.valueToString(codJfas)+")";
|
||||
sql = "Select cod_mart,descrizione,bar_code as barcode,cod_msgr from steup_getGrigliaVendita(" + UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codJfas) + ")";
|
||||
} else {
|
||||
sql = "SELECT cod_mart,descrizione,bar_code as barcode,cod_msgr\n" +
|
||||
"FROM steup_getAssortimento("+ UtilityDB.valueToString(codMdep)+","+ UtilityDB.valueToString(codJfas)+")\n" +
|
||||
"FROM steup_getAssortimento(" + UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codJfas) + ")\n" +
|
||||
"WHERE cod_mart NOT IN (SELECT cod_mart\n" +
|
||||
" FROM (SELECT cod_mart,\n" +
|
||||
" cod_mdep,\n" +
|
||||
@@ -872,12 +872,12 @@ public class SteUPService {
|
||||
" OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_validita, tipo_variazione ) AS tipo_variazione_succ\n" +
|
||||
" FROM carelli.dbo.atb_griglie_art\n" +
|
||||
" WHERE atb_griglie_art.data_validita <= CAST(GETDATE() AS DATE)\n" +
|
||||
" AND atb_griglie_art.cod_mdep = "+ UtilityDB.valueToString(codMdep)+") g\n" +
|
||||
" AND atb_griglie_art.cod_mdep = " + UtilityDB.valueToString(codMdep) + ") g\n" +
|
||||
" WHERE g.tipo_variazione_succ IS NULL\n" +
|
||||
" AND DATEDIFF(DAY, data_validita, CAST(GETDATE() AS DATE)) < 7\n" +
|
||||
" AND g.tipo_variazione = 'I'\n" +
|
||||
" UNION " +
|
||||
" SELECT cod_mart FROM dbo.steup_getInevasi("+ UtilityDB.valueToString(codMdep)+", " + UtilityDB.valueToString(codJfas)+", " + UtilityDB.valueToString(dataCreation) + "))";
|
||||
" SELECT cod_mart FROM dbo.steup_getInevasi(" + UtilityDB.valueToString(codMdep) + ", " + UtilityDB.valueToString(codJfas) + ", " + UtilityDB.valueToString(dataCreation) + "))";
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@@ -1362,4 +1362,85 @@ public class SteUPService {
|
||||
UtilityFile.writeStringToFile(StringUtils.join(queries, CommonConstants.A_CAPO), file);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteInspections(Date dataInizio, Date dataFine) throws Exception {
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
String sql = Query.format(
|
||||
"SELECT activity_id,\n" +
|
||||
" UPPER(user_name) AS user_name,\n" +
|
||||
" user_creator,\n" +
|
||||
" CONVERT(DATETIME, CONVERT(DATE, effective_time)) AS data_ispezione,\n" +
|
||||
" effective_time,\n" +
|
||||
" effective_endtime,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" descr_deposito\n" +
|
||||
"FROM dbo.steup_getRilevazioni()\n" +
|
||||
"WHERE CAST(effective_time AS DATE) BETWEEN %s AND %s",
|
||||
dataInizio,
|
||||
dataFine
|
||||
);
|
||||
|
||||
List<HashMap<String, Object>> rilevazioni = UtilityDB.executeSimpleQuery(conn, sql);
|
||||
|
||||
for (HashMap<String, Object> row : rilevazioni) {
|
||||
List<StbActivity> entityList = new ArrayList<>();
|
||||
|
||||
//First level
|
||||
StbActivity activity = new StbActivity();
|
||||
activity
|
||||
.setActivityId(row.get("activity_id").toString())
|
||||
.setOperation(OperationType.DELETE);
|
||||
entityList.add(activity);
|
||||
|
||||
//Second level
|
||||
sql = Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM stb_activity\n" +
|
||||
"WHERE parent_activity_id = %s\n" +
|
||||
" AND CAST(effective_time AS DATE) BETWEEN %s AND %s",
|
||||
row.get("activity_id").toString(),
|
||||
dataInizio,
|
||||
dataFine
|
||||
);
|
||||
List<StbActivity> activityList = UtilityDB.executeSimpleQueryDTO(conn, sql, StbActivity.class);
|
||||
if (activityList != null) {
|
||||
entityList.addAll(
|
||||
activityList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.peek(x -> x.setOperation(OperationType.DELETE))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
//Third level
|
||||
entityList.addAll(
|
||||
activityList.stream()
|
||||
.map(x -> {
|
||||
String query = Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM stb_activity\n" +
|
||||
"WHERE parent_activity_id = %s\n" +
|
||||
" AND CAST(effective_time AS DATE) BETWEEN %s AND %s",
|
||||
x.getActivityId(),
|
||||
dataInizio,
|
||||
dataFine
|
||||
);
|
||||
|
||||
try {
|
||||
return UtilityDB.executeSimpleQueryDTO(conn, query, StbActivity.class);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(x -> x.stream().peek(y -> y.setOperation(OperationType.DELETE)))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
Collections.reverse(entityList);
|
||||
|
||||
entityProcessor.processEntityList(entityList, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class DocCostiTrasportoController {
|
||||
|
||||
List<ReturnDocCostiTrasportoDTO> docTrasp = new ArrayList<>();
|
||||
try {
|
||||
docTrasp = documentService.importDocumentiTrasportoPapagni(requestDataDTO);
|
||||
docTrasp = documentService.importDocumentiTrasportoPapagni(requestDataDTO, "DOCUMENIT TRASPORTO", "PAPAGNI");
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(docTrasp);
|
||||
|
||||
@@ -55,9 +55,10 @@ public class DocCostiTrasportoController {
|
||||
docTrasp = documentService.importDocumentiTrasportoMirarchi(requestDataDTO, type, format);
|
||||
break;
|
||||
case "STEF":
|
||||
docTrasp = documentService.importDocumentiTrasportoStef(requestDataDTO);
|
||||
docTrasp = documentService.importDocumentiTrasportoStef(requestDataDTO, type, format);
|
||||
break;
|
||||
case "EBC":
|
||||
docTrasp = documentService.importDocumentiTrasportoEBC(requestDataDTO, type, format);
|
||||
break;
|
||||
case "ROTUNNO":
|
||||
docTrasp = documentService.importDocumentiTrasportoROTUNNO(requestDataDTO, type, format);
|
||||
@@ -65,9 +66,6 @@ public class DocCostiTrasportoController {
|
||||
case "DIPA":
|
||||
docTrasp = documentService.importDocumentiTrasportoDIPA(requestDataDTO, type, format);
|
||||
break;
|
||||
case "PAPAGNI":
|
||||
docTrasp = documentService.importDocumentiTrasportoPapagni(requestDataDTO);
|
||||
break;
|
||||
}
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(docTrasp);
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package it.integry.ems.document.CostiTrasporto.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class DocTraspEBCDTO {
|
||||
@JsonProperty("SUPPLEMENTO P/ASS")
|
||||
private BigDecimal supplementoPASS;
|
||||
@JsonProperty("PREAVVISO TELEFONICO")
|
||||
private BigDecimal preavvisoTelefonico;
|
||||
@JsonProperty("SUPPLEMENTO CARBURANTE")
|
||||
private BigDecimal supplementoTelefonico;
|
||||
@JsonProperty("GESTIONE EPAL")
|
||||
private BigDecimal gestioneEPAL;
|
||||
@JsonProperty("SERVIZIO NON STOP")
|
||||
private BigDecimal servizioNonStop;
|
||||
@JsonProperty("ASSICURAZIONE")
|
||||
private BigDecimal assicurazione;
|
||||
@JsonProperty("SOSTA ALLO SCARICO")
|
||||
private BigDecimal sostaAlloScarico;
|
||||
@JsonProperty("DIRITTO FISSO")
|
||||
private BigDecimal dirittoFisso;
|
||||
@JsonProperty("RIPREZZAMENTO FUORI SAGOMA")
|
||||
private BigDecimal riprezzamentoFuoriSagoma;
|
||||
@JsonProperty("RIPREZZAMENTO FUORI PESO")
|
||||
private BigDecimal ripressamentoFuoriPeso;
|
||||
@JsonProperty("ADDEBITO PRENOTAZIONE SU TESI")
|
||||
private BigDecimal AddebitoPrenotazioneSuTesi;
|
||||
@JsonProperty("ADD PREN SU MERCAREON/SMARTBAY")
|
||||
private BigDecimal AddPrenSuMercareonSmartbay;
|
||||
@JsonProperty("IMPORTO DOCUMENTO")
|
||||
private BigDecimal importoDocumento;
|
||||
@JsonProperty("SCARICO COOPERATIVE GDO")
|
||||
private BigDecimal scaricoCooperativaGDO;
|
||||
@JsonProperty("ZONA DISAGIATA")
|
||||
private BigDecimal zonsDisagiata;
|
||||
@JsonProperty("CODICE CLIENTE")
|
||||
private String codiceCliente;
|
||||
@JsonProperty("RAGIONE SOCIALE MITTENTE")
|
||||
private String ragioneSocialeMittente;
|
||||
@JsonProperty("LOCALITA")
|
||||
private String localita;
|
||||
@JsonProperty("N.DOCUMENTO")
|
||||
private Integer numDocumento;
|
||||
@JsonProperty("DATA DOCUMENTO")
|
||||
private Date dataDocumento;
|
||||
@JsonProperty("DATA SPEDIZIONE")
|
||||
private Date dataSpedizione;
|
||||
@JsonProperty("CONTR.")
|
||||
private BigDecimal contr;
|
||||
@JsonProperty("RIF.MITTENTE")
|
||||
private String rifMittente;
|
||||
@JsonProperty("TP")
|
||||
private String tp;
|
||||
@JsonProperty("NS.RIFERIMENTO")
|
||||
private String nsRiferimento;
|
||||
@JsonProperty("TR")
|
||||
private String tr;
|
||||
@JsonProperty("RIFERIMENTO OP LOGISTICA")
|
||||
private String riferimentoOpLogistica;
|
||||
@JsonProperty("DESTINATARIO/MITTENTE")
|
||||
private String destinarioMittente;
|
||||
@JsonProperty("LOCALITA DEST.")
|
||||
private String localitaDest;
|
||||
@JsonProperty("PART")
|
||||
private String part;
|
||||
@JsonProperty("ARR.")
|
||||
private String arrotonamento;
|
||||
@JsonProperty("N.BANCALI")
|
||||
private Integer numBancali;
|
||||
@JsonProperty("N.COLLI")
|
||||
private Integer numColli;
|
||||
@JsonProperty("PESO")
|
||||
private BigDecimal peso;
|
||||
@JsonProperty("VOLUME")
|
||||
private BigDecimal volume;
|
||||
@JsonProperty("NOLO")
|
||||
private BigDecimal nolo;
|
||||
@JsonProperty("COMMISSIONE CONTRASSEGNO")
|
||||
private BigDecimal commissioneContrassegno;
|
||||
@JsonProperty("SUPPLEMENTO ADR")
|
||||
private BigDecimal supplementoADR;
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package it.integry.ems.document.CostiTrasporto.service;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.document.CostiTrasporto.dto.DocTraspEBCDTO;
|
||||
import it.integry.ems.document.CostiTrasporto.dto.DocTraspImportDTO;
|
||||
import it.integry.ems.document.CostiTrasporto.dto.DocTraspStefDTO;
|
||||
import it.integry.ems.document.CostiTrasporto.dto.ReturnDocCostiTrasportoDTO;
|
||||
@@ -66,8 +67,6 @@ public class DocCostiTrasporto {
|
||||
|
||||
private String sql;
|
||||
|
||||
private String STEF = "STEF", PAPAGNI = "PAPAGNI";
|
||||
|
||||
private Logger logger = LogManager.getLogger();
|
||||
|
||||
@NotNull
|
||||
@@ -220,7 +219,7 @@ public class DocCostiTrasporto {
|
||||
/*Se si tratta di STEF è necessario verificare se il cliente è tra quelli gestiti a PALLET ed in tal caso il tipo calcolo andrà cambiato,
|
||||
purtroppo STEF non fornisce nel file per ogni cliente che tipo di costo è stato associato.
|
||||
Siamo costretti a fare il controllo qui perchè nel file non abbiamo il codice cliente e solo in questo punto viene identificato*/
|
||||
if (format.equalsIgnoreCase(STEF)){
|
||||
if (format.equalsIgnoreCase("STEF")){
|
||||
if (codAnag != null && elencoClientiTipoCalcPallet != null && elencoClientiTipoCalcPallet.contains(codAnag)){
|
||||
tipoCalc = "PEDANE";
|
||||
untMis = getUntMisFromTipoCalc(tipoCalc);
|
||||
@@ -249,15 +248,15 @@ public class DocCostiTrasporto {
|
||||
return docCostiTrasp;
|
||||
}
|
||||
|
||||
public List<ReturnDocCostiTrasportoDTO> importDocumentiTrasportoPapagni(ImportRequestDTO requestDataDTO) throws Exception {
|
||||
public List<ReturnDocCostiTrasportoDTO> importDocumentiTrasportoPapagni(ImportRequestDTO requestDataDTO, String type, String format) throws Exception {
|
||||
Integer index = 0, numDoc = null;
|
||||
String serDoc, codAnag, ragSocDB, codDtip, cittaDB, tipoCalc, format = PAPAGNI, type = "DOCUMENTI_TRASPORTO";
|
||||
String serDoc, codAnag, ragSocDB, codDtip, cittaDB, tipoCalc;
|
||||
List<ReturnDocCostiTrasportoDTO> docCostiTrasp = new ArrayList<>();
|
||||
DataFormatter dataFormatter = new DataFormatter();
|
||||
Date dataDoc;
|
||||
Connection connect = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
String codVvet = UtilityString.emptyStr2Null(setupGest.getImportSetup(connect, type, format, "COD_VVET"));
|
||||
String codVvet = UtilityString.emptyStr2Null(setupGest.getImportSetup(connect, "DOCUMENTI_TRASPORTO", "PAPAGNI", "COD_VVET"));
|
||||
if (codVvet == null){
|
||||
throw new Exception("CODICE VETTORE NON CONFIGURATO");
|
||||
}
|
||||
@@ -458,9 +457,8 @@ public class DocCostiTrasporto {
|
||||
return returns;
|
||||
}
|
||||
|
||||
public List<ReturnDocCostiTrasportoDTO> importDocumentiTrasportoStef(ImportRequestDTO requestDataDTO) throws Exception {
|
||||
public List<ReturnDocCostiTrasportoDTO> importDocumentiTrasportoStef(ImportRequestDTO requestDataDTO, String type, String format) throws Exception {
|
||||
Integer idRiga = 0;
|
||||
String format = STEF, type = "DOCUMENTI_TRASPORTO";
|
||||
List<ReturnDocCostiTrasportoDTO> docCostiTrasp = new ArrayList<>();
|
||||
List<DocTraspImportDTO> listDocTrasp = new ArrayList<>();
|
||||
HashMap<String, String> returns = new HashMap<>();
|
||||
@@ -793,6 +791,84 @@ public class DocCostiTrasporto {
|
||||
|
||||
docCostiTrasp = checkAndImportDoc(listDocTrasp, format);
|
||||
|
||||
String pathFileImported = UtilityString.replaceSubString(requestDataDTO.getPathFile(), format, format + "\\imported");
|
||||
UtilityFile.fileDelete(pathFileImported);
|
||||
FileUtils.moveFile(new File(requestDataDTO.getPathFile()), new File(pathFileImported));
|
||||
|
||||
return docCostiTrasp;
|
||||
}
|
||||
|
||||
public List<ReturnDocCostiTrasportoDTO> importDocumentiTrasportoEBC(ImportRequestDTO requestDataDTO, String type, String format) throws Exception {
|
||||
Integer idRiga = 0;
|
||||
List<ReturnDocCostiTrasportoDTO> docCostiTrasp = new ArrayList<>();
|
||||
List<DocTraspImportDTO> listDocTrasp = new ArrayList<>();
|
||||
HashMap<String, String> returns = new HashMap<>();
|
||||
BigDecimal tassato = BigDecimal.ZERO;
|
||||
Connection connect = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
String tipoCalc = UtilityString.emptyStr2Null(setupGest.getImportSetup(connect, type, format, "TIPO_CALC"));
|
||||
if (tipoCalc == null){throw new Exception("E' NECESSARIO DEFINIRE LA TIPOLOGIA DI CALCOLO SE A PESO O A COLLI");}
|
||||
String untMis = getUntMisFromTipoCalc(tipoCalc);
|
||||
|
||||
File tempFile = new File(requestDataDTO.getPathFile());
|
||||
String csvEBC = FileUtils.readFileToString(tempFile);
|
||||
CsvMapper<DocTraspEBCDTO> mapper = new CsvMapper<DocTraspEBCDTO>();
|
||||
List<DocTraspEBCDTO> EBCList = mapper.deserialize(csvEBC, DocTraspEBCDTO.class, ";");
|
||||
|
||||
for (DocTraspEBCDTO doc : EBCList) {
|
||||
/*String rifDoc = doc.gertNSRiferimento
|
||||
BigDecimal totaleNolo = doc.getNolo().divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
|
||||
BigDecimal tassatoCollo = doc.getNumColli().divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
|
||||
BigDecimal tassatoPeso = doc.getPeso().divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
|
||||
BigDecimal tassatoPallet = doc.getNumeroPallet();
|
||||
idRiga ++;
|
||||
|
||||
returns = getSerNumDoc(rifDoc);
|
||||
String numDocFile = returns.get("numDoc");
|
||||
String serDoc = returns.get("serDoc");
|
||||
|
||||
Integer numDoc = null;
|
||||
if (numDocFile != null && UtilityString.isNumber(numDocFile)){
|
||||
numDoc = Integer.valueOf(numDocFile);
|
||||
}
|
||||
Date dataDoc = null;
|
||||
try {
|
||||
dataDoc = new SimpleDateFormat("yyyyMMdd").parse(doc.getDataDocumento());
|
||||
} catch (Exception e){
|
||||
logger.warn("Data documento non presente o non valida");
|
||||
}
|
||||
if (tipoCalc.compareTo("PESO") == 0){
|
||||
tassato = tassatoPeso;
|
||||
} else {
|
||||
tassato = tassatoCollo;
|
||||
}
|
||||
String checkSerieDoc = "N";
|
||||
if (doc.getCategoriaTariffa().compareTo("EM") == 0){
|
||||
checkSerieDoc = "S";
|
||||
}
|
||||
|
||||
DocTraspImportDTO docTrasp = new DocTraspImportDTO();
|
||||
docTrasp.setDataDoc(dataDoc);
|
||||
docTrasp.setNumDoc(numDoc);
|
||||
docTrasp.setSerDoc(serDoc);
|
||||
docTrasp.setRagSoc(doc.getRagSc());
|
||||
docTrasp.setCitta(doc.getCitta());
|
||||
docTrasp.setNolo(totaleNolo);
|
||||
docTrasp.setTassato(tassato);
|
||||
docTrasp.setTipoCalc(tipoCalc);
|
||||
docTrasp.setUntMis(untMis);
|
||||
docTrasp.setDataSped(dataDoc);
|
||||
docTrasp.setRifDoc(rifDoc);
|
||||
docTrasp.setIdRiga(idRiga);
|
||||
docTrasp.setCheckSerDoc(checkSerieDoc);
|
||||
docTrasp.setColli(tassatoCollo);
|
||||
docTrasp.setPeso(tassatoPeso);
|
||||
docTrasp.setPallet(tassatoPallet);
|
||||
listDocTrasp.add(docTrasp);*/
|
||||
}
|
||||
docCostiTrasp = checkAndImportDoc(listDocTrasp, format);
|
||||
|
||||
|
||||
String pathFileImported = UtilityString.replaceSubString(requestDataDTO.getPathFile(), format, format + "\\imported");
|
||||
UtilityFile.fileDelete(pathFileImported);
|
||||
FileUtils.moveFile(new File(requestDataDTO.getPathFile()), new File(pathFileImported));
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
package it.integry.ems.document.controller;public class DocumentiDifferitiController {
|
||||
}
|
||||
@@ -60,19 +60,19 @@ public class DataSheetServices {
|
||||
Optional<StbFilesAttached> document = Optional.empty();
|
||||
|
||||
String sql = "SELECT stb_files_attached.*\n" +
|
||||
"FROM mtb_aart_link\n" +
|
||||
" INNER JOIN stb_files_attached ON stb_files_attached.id_attach = mtb_aart_link.id_attach\n" +
|
||||
"WHERE type_attach = 'ST'\n" +
|
||||
" AND mtb_aart_link.cod_mart = " + UtilityDB.valueToString(codMart) + "\n" +
|
||||
" AND mime_type NOT LIKE '%image%'";
|
||||
"FROM mtb_aart_link\n" +
|
||||
" INNER JOIN stb_files_attached ON stb_files_attached.id_attach = mtb_aart_link.id_attach\n" +
|
||||
"WHERE type_attach = 'ST'\n" +
|
||||
" AND mtb_aart_link.cod_mart = " + UtilityDB.valueToString(codMart) + "\n" +
|
||||
" AND mime_type NOT LIKE '%image%'";
|
||||
|
||||
List<StbFilesAttached> stbFilesAttacheds = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbFilesAttached.class);
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(stbFilesAttacheds)){
|
||||
if (!UtilityList.isNullOrEmpty(stbFilesAttacheds)) {
|
||||
document = stbFilesAttacheds.stream().findFirst();
|
||||
}
|
||||
|
||||
if (UtilityList.isNullOrEmpty(stbFilesAttacheds) || !document.isPresent()){
|
||||
if (UtilityList.isNullOrEmpty(stbFilesAttacheds) || !document.isPresent()) {
|
||||
throw new Exception("Scheda prodotto non trovata");
|
||||
}
|
||||
|
||||
@@ -103,21 +103,22 @@ public class DataSheetServices {
|
||||
.map(x -> x.substring(x.indexOf("_") + 1))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
sql = String.format(
|
||||
"SELECT 'descrizione_' + cod_lingua as cod_var, IsNull(descrizione_estesa, descrizione) as descrizione from mtb_aart_desc WHERE cod_mart = %s and cod_lingua in (%s)",
|
||||
UtilityDB.valueToString(codMart),
|
||||
UtilityDB.listValueToString( codLingua )
|
||||
);
|
||||
if (!codLingua.isEmpty()) {
|
||||
sql = String.format(
|
||||
"SELECT 'descrizione_' + cod_lingua as cod_var, IsNull(descrizione_estesa, descrizione) as descrizione from mtb_aart_desc WHERE cod_mart = %s and cod_lingua in (%s)",
|
||||
UtilityDB.valueToString(codMart),
|
||||
UtilityDB.listValueToString(codLingua)
|
||||
);
|
||||
List<HashMap<String, Object>> descrizioni = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
List<HashMap<String, Object>> descrizioni = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (!descrizioni.isEmpty())
|
||||
hashMaps.addAll(descrizioni);
|
||||
if (!descrizioni.isEmpty())
|
||||
hashMaps.addAll(descrizioni);
|
||||
}
|
||||
|
||||
HashMap<String, String> resultMap = new HashMap<>();
|
||||
|
||||
allVariables.forEach(variable -> {
|
||||
if (mtb_aart.containsKey(variable)){
|
||||
if (mtb_aart.containsKey(variable)) {
|
||||
resultMap.put(variable, (String) mtb_aart.get(variable));
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ public class DataSheetServices {
|
||||
});
|
||||
});
|
||||
|
||||
return resultMap;
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private HashMap<String, UtilityDocx.ImageData> getImage(String codMart, List<UtilityDocx.ImageData> allImgVariables) throws Exception {
|
||||
|
||||
@@ -432,7 +432,7 @@ public class SicilianiDMSExportService {
|
||||
|
||||
conAlyante.commit();
|
||||
} catch (Exception e) {
|
||||
conAlyante.rollback();
|
||||
//conAlyante.rollback();
|
||||
if (sql != null){logger.error(sql);}
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
package it.integry.ems.document.service;public class DocumentiDifferitiService {
|
||||
}
|
||||
@@ -306,6 +306,11 @@ public class OrdiniAcquistoExportServices {
|
||||
}
|
||||
|
||||
int pos = intercode.indexOf("|");
|
||||
|
||||
if (pos < 0){
|
||||
throw new Exception("L'intercode presente sul deposito associato all'ordine non è formato correttamente (intercode: "+intercode+").");
|
||||
}
|
||||
|
||||
String codiceTerminale = intercode.substring(0, pos);
|
||||
if (codiceTerminale.substring(0, 1).compareTo("C") == 0) {
|
||||
codiceTerminale = codiceTerminale.substring(1);
|
||||
|
||||
@@ -101,12 +101,21 @@ public class OrdiniEDIimportService {
|
||||
clienti.add(codAnag);
|
||||
}
|
||||
|
||||
if (clienti == null || clienti.size() == 0 )
|
||||
throw new Exception(String.format("Nessun cliente trovato con il %s (%s) %s",
|
||||
(identificativo.equalsIgnoreCase("ZZ")?"partita iva":"ean cliente"),
|
||||
identificativo,
|
||||
partIvaClie));
|
||||
if (clienti == null || clienti.size() == 0 ) {
|
||||
String message = null;
|
||||
|
||||
if (UtilityString.streNull(partIvaClie).isEmpty()){
|
||||
message = String.format("Nessun cliente trovato verificare che nel file esista codice EAN o PARTITA IVA nella sezione BGM in posizione 4");
|
||||
} else {
|
||||
message = String.format("Nessun cliente trovato con il %s (%s) %s",
|
||||
(identificativo.equalsIgnoreCase("ZZ") ? "partita iva" : "ean cliente"),
|
||||
identificativo,
|
||||
partIvaClie);
|
||||
}
|
||||
|
||||
|
||||
throw new Exception(message);
|
||||
}
|
||||
dtbOrdt =
|
||||
new DtbOrdt()
|
||||
.setGestione(gestione)
|
||||
|
||||
@@ -26,8 +26,9 @@ public class ArticoliImporter extends BaseEntityImporter<List<EntityBase>> imple
|
||||
ProductServices importDistinteMorganteService = ContextLoader.getCurrentWebApplicationContext().getBean(ProductServices.class);
|
||||
return importDistinteMorganteService.importDistinteMorgante((String) requestDto.getRawContent(), type, format);
|
||||
case REPO_IMAGES:
|
||||
case FOTO:
|
||||
ProductServices importArticoliRepoImagesServices = ContextLoader.getCurrentWebApplicationContext().getBean(ProductServices.class);
|
||||
return importArticoliRepoImagesServices.importAarticoliFromREPOIMAGES(type, format, requestDto.getPathFile());
|
||||
return importArticoliRepoImagesServices.importFotoArticoli(type, format, requestDto);
|
||||
case APULIA:
|
||||
return ContextLoader.getCurrentWebApplicationContext().getBean(ProductServices.class).importArticoliApulia(type, format, requestDto.getRawContent());
|
||||
default:
|
||||
@@ -45,7 +46,8 @@ public class ArticoliImporter extends BaseEntityImporter<List<EntityBase>> imple
|
||||
MORGANTE("MORGANTE"),
|
||||
MORGANTE_DISTINTE("MORGANTE_DISTINTE"),
|
||||
REPO_IMAGES("REPO_IMAGES"),
|
||||
APULIA("APULIA");
|
||||
APULIA("APULIA"),
|
||||
FOTO("FOTO");
|
||||
|
||||
private String text;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.annimon.stream.Stream;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.product.importaz.dto.ArticoliMorganteDTO;
|
||||
import it.integry.ems.product.importaz.dto.ContrattiVenditaDTO;
|
||||
@@ -62,22 +63,22 @@ public class ProductServices {
|
||||
|
||||
private Logger logger = LogManager.getLogger();
|
||||
|
||||
public List<EntityBase> saveArtDialogo (MtbAart mtbAart) throws Exception {
|
||||
public List<EntityBase> saveArtDialogo(MtbAart mtbAart) throws Exception {
|
||||
List<EntityBase> entityList = new ArrayList<>();
|
||||
mtbAart.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityList.add(mtbAart);
|
||||
|
||||
for (MtbAartBarCode b: mtbAart.getMtbAartBarCode()) {
|
||||
for (MtbAartBarCode b : mtbAart.getMtbAartBarCode()) {
|
||||
b.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
if (mtbAart.getMtbLisa() != null )
|
||||
for (MtbLisa l: mtbAart.getMtbLisa()) {
|
||||
if (mtbAart.getMtbLisa() != null)
|
||||
for (MtbLisa l : mtbAart.getMtbLisa()) {
|
||||
l.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityList.add(l);
|
||||
}
|
||||
|
||||
List<EntityBase> entitites = importAnagListiniService.importAnagListinoAcq(entityList, "V" , null, null);
|
||||
List<EntityBase> entitites = importAnagListiniService.importAnagListinoAcq(entityList, "V", null, null);
|
||||
|
||||
return entitites;
|
||||
}
|
||||
@@ -1014,47 +1015,82 @@ public class ProductServices {
|
||||
}
|
||||
|
||||
|
||||
public List<EntityBase> importAarticoliFromREPOIMAGES(String typeImport, String formatImport, String filePath) throws Exception {
|
||||
List<EntityBase> entitiesReturn = new ArrayList<EntityBase>();
|
||||
public List<EntityBase> importFotoArticoli(String type, String format, ImportRequestDTO requestDto) throws Exception {
|
||||
List<MtbAart> mtbAartList = new ArrayList<>();
|
||||
|
||||
Connection conn = multiDBTransactionManager.getPrimaryDatasource().getConnection();
|
||||
Map<String, String> setup = setupGest.getImportSetupSection(multiDBTransactionManager.getPrimaryConnection(), type, format);
|
||||
String filePath = UtilityString.isNullOrEmpty(requestDto.getPathFile()) ? setup.get("FILE_FILTER") : requestDto.getPathFile();
|
||||
|
||||
if (filePath == null) {
|
||||
mtbAartList.add(
|
||||
prepareEntityForImportFoto(requestDto.getFileName())
|
||||
);
|
||||
} else {
|
||||
File directory = new File(filePath);
|
||||
|
||||
if (directory.exists() && directory.isDirectory()) {
|
||||
File[] files = directory.listFiles();
|
||||
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
mtbAartList.add(
|
||||
prepareEntityForImportFoto(file.getName())
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Cartella vuota");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mtbAartList.isEmpty()) {
|
||||
throw new Exception("Nessuna immagine salvata");
|
||||
}
|
||||
|
||||
return entityProcessor.processEntityList(mtbAartList, multiDBTransactionManager, true);
|
||||
}
|
||||
|
||||
private MtbAart prepareEntityForImportFoto(String fileName) throws Exception {
|
||||
List<String> validExtensions = Arrays.asList(".jpg", ".jpeg", ".png", ".gif");
|
||||
int extensionIndex = fileName.lastIndexOf(".");
|
||||
String codMart;
|
||||
|
||||
if (extensionIndex >= 0 && validExtensions.contains(fileName.substring(extensionIndex))) {
|
||||
codMart = fileName.substring(0, extensionIndex);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
String fileName = filePath.substring(filePath.lastIndexOf("\\") + 1);
|
||||
String codMart = fileName.substring(0, fileName.lastIndexOf(".jpg"));
|
||||
String[] arg = codMart.split("-");
|
||||
if (arg != null && arg.length > 0) codMart = arg[0];
|
||||
if (arg.length > 0) codMart = arg[0];
|
||||
|
||||
MtbAartLink searchArtLink = new MtbAartLink();
|
||||
searchArtLink.setCodMart(codMart);
|
||||
searchArtLink.setPathLink(fileName);
|
||||
searchArtLink.setOperation(OperationType.SELECT);
|
||||
searchArtLink.setNativeSql("select * from mtb_aart_link where cod_mart = " + UtilityDB.valueToString(codMart) + "and path_link = " + UtilityDB.valueToString(fileName));
|
||||
|
||||
List<EntityBase> artLinkResult = entityProcessor.processEntity(searchArtLink, multiDBTransactionManager);
|
||||
|
||||
MtbAartLink mtbAartLink = new MtbAartLink();
|
||||
mtbAartLink.setCodMart(codMart);
|
||||
mtbAartLink.setPathLink(fileName);
|
||||
mtbAartLink.setDescrizioneLink("Immagine prodotto " + codMart);
|
||||
|
||||
if (artLinkResult == null || artLinkResult.isEmpty()) {
|
||||
MtbAartLink mtbAartLink = new MtbAartLink();
|
||||
mtbAartLink.setCodMart(codMart);
|
||||
mtbAartLink.setPathLink(fileName);
|
||||
mtbAartLink.setDescrizioneLink("Immagine prodotto " + codMart);
|
||||
mtbAartLink.setOperation(OperationType.INSERT);
|
||||
|
||||
MtbAart mtbAart = new MtbAart();
|
||||
mtbAart.setCodMart(codMart);
|
||||
mtbAart.setOperation(OperationType.NO_OP);
|
||||
mtbAart.getMtbAartLink().add(mtbAartLink);
|
||||
|
||||
entityProcessor.processEntity(mtbAart, true, multiDBTransactionManager);
|
||||
entitiesReturn.add(mtbAart);
|
||||
} else {
|
||||
mtbAartLink.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
|
||||
/* if ( mtbAart != null){
|
||||
MtbAartLink mtbAartLink= Stream.of(mtbAart.getMtbAartLink()).filter(x-> x.getCodMart().equalsIgnoreCase(codMart) && x.getPathLink().equalsIgnoreCase(fileName)).single();
|
||||
MtbAart mtbAart = new MtbAart();
|
||||
mtbAart.setCodMart(codMart);
|
||||
mtbAart.setOperation(OperationType.NO_OP);
|
||||
mtbAart.getMtbAartLink().add(mtbAartLink);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
return entitiesReturn;
|
||||
return mtbAart;
|
||||
}
|
||||
|
||||
public List<EntityBase> saveSalesAgreement(ContrattiVenditaDTO contrattiVenditaDTO) throws Exception {
|
||||
@@ -1194,23 +1230,23 @@ public class ProductServices {
|
||||
|
||||
String sql =
|
||||
(
|
||||
"WITH lisa as (\n" +
|
||||
"select atb_forn.cod_alis\n" +
|
||||
"from atb_forn inner join atb_list on atb_forn.cod_alis = atb_list.cod_alis\n" +
|
||||
"where atb_forn.cod_anag = '[cod_anag]'\n" +
|
||||
"and atb_list.part_iva_forn is null\n" +
|
||||
"union\n" +
|
||||
"select vtb_dest.cod_alis\n" +
|
||||
"from vtb_dest inner join atb_list on vtb_dest.cod_alis = atb_list.cod_alis\n" +
|
||||
"where vtb_dest.cod_anag = '[cod_anag]'\n" +
|
||||
"and atb_list.part_iva_forn is null ),\n" +
|
||||
"barcode as (\n" +
|
||||
"select l.cod_mart\n" +
|
||||
"from dbo.getListinoAcquisto(null, null, '[cod_art_for]', null, 'N', null) l\n" +
|
||||
"inner join lisa on lisa.cod_alis = l.cod_alis\n" +
|
||||
"where l.tipo_variazione <> 'D' and l.cod_mart is not null )\n" +
|
||||
"select cod_mart from barcode")
|
||||
.replace("[cod_anag]",codAnag )
|
||||
"WITH lisa as (\n" +
|
||||
"select atb_forn.cod_alis\n" +
|
||||
"from atb_forn inner join atb_list on atb_forn.cod_alis = atb_list.cod_alis\n" +
|
||||
"where atb_forn.cod_anag = '[cod_anag]'\n" +
|
||||
"and atb_list.part_iva_forn is null\n" +
|
||||
"union\n" +
|
||||
"select vtb_dest.cod_alis\n" +
|
||||
"from vtb_dest inner join atb_list on vtb_dest.cod_alis = atb_list.cod_alis\n" +
|
||||
"where vtb_dest.cod_anag = '[cod_anag]'\n" +
|
||||
"and atb_list.part_iva_forn is null ),\n" +
|
||||
"barcode as (\n" +
|
||||
"select l.cod_mart\n" +
|
||||
"from dbo.getListinoAcquisto(null, null, '[cod_art_for]', null, 'N', null) l\n" +
|
||||
"inner join lisa on lisa.cod_alis = l.cod_alis\n" +
|
||||
"where l.tipo_variazione <> 'D' and l.cod_mart is not null )\n" +
|
||||
"select cod_mart from barcode")
|
||||
.replace("[cod_anag]", codAnag)
|
||||
.replace("[cod_art_for]", codArtFor);
|
||||
|
||||
String codMart = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
@@ -1218,28 +1254,28 @@ public class ProductServices {
|
||||
if (!UtilityString.isNullOrEmpty(codMart)) {
|
||||
sql =
|
||||
"WITH barcode_new as (SELECT DISTINCT cod_barre \n" +
|
||||
"FROM (\n" +
|
||||
"VALUES ('" + StringUtils.join(barcode, "'),('") + "')\n" +
|
||||
") AS a(cod_barre)),\n" +
|
||||
"barcode as (\n" +
|
||||
"SELECT mvw_barcode.cod_mart, mvw_barcode.cod_barre\n" +
|
||||
"FROM mvw_barcode \n" +
|
||||
"WHERE mvw_barcode.cod_mart = " + UtilityDB.valueToString(codMart) + " \n" +
|
||||
"union all\n" +
|
||||
"SELECT mtb_comp.cod_mart, mvw_barcode.cod_barre\n" +
|
||||
"FROM mvw_barcode inner join mtb_comp on mvw_barcode.cod_mart = mtb_comp.cod_mart\n" +
|
||||
"WHERE mtb_comp.cod_comp = " + UtilityDB.valueToString(codMart) + "\n) " +
|
||||
"SELECT DISTINCT CASE WHEN LEFT(barcode_new.cod_barre, 5) = '00000' THEN substring(barcode_new.cod_barre, 6, 8) ELSE barcode_new.cod_barre END as cod_barre\n" +
|
||||
"FROM barcode_new \n" +
|
||||
"WHERE not EXISTS(SELECT * FROM barcode WHERE barcode.cod_barre = CASE WHEN LEFT(barcode_new.cod_barre, 5) = '00000' THEN substring(barcode_new.cod_barre, 6, 8) ELSE barcode_new.cod_barre END )";
|
||||
"FROM (\n" +
|
||||
"VALUES ('" + StringUtils.join(barcode, "'),('") + "')\n" +
|
||||
") AS a(cod_barre)),\n" +
|
||||
"barcode as (\n" +
|
||||
"SELECT mvw_barcode.cod_mart, mvw_barcode.cod_barre\n" +
|
||||
"FROM mvw_barcode \n" +
|
||||
"WHERE mvw_barcode.cod_mart = " + UtilityDB.valueToString(codMart) + " \n" +
|
||||
"union all\n" +
|
||||
"SELECT mtb_comp.cod_mart, mvw_barcode.cod_barre\n" +
|
||||
"FROM mvw_barcode inner join mtb_comp on mvw_barcode.cod_mart = mtb_comp.cod_mart\n" +
|
||||
"WHERE mtb_comp.cod_comp = " + UtilityDB.valueToString(codMart) + "\n) " +
|
||||
"SELECT DISTINCT CASE WHEN LEFT(barcode_new.cod_barre, 5) = '00000' THEN substring(barcode_new.cod_barre, 6, 8) ELSE barcode_new.cod_barre END as cod_barre\n" +
|
||||
"FROM barcode_new \n" +
|
||||
"WHERE not EXISTS(SELECT * FROM barcode WHERE barcode.cod_barre = CASE WHEN LEFT(barcode_new.cod_barre, 5) = '00000' THEN substring(barcode_new.cod_barre, 6, 8) ELSE barcode_new.cod_barre END )";
|
||||
|
||||
List<MtbAartBarCode> mtbAartBarCodes = new ResultSetMapper().mapQuerySetToList(multiDBTransactionManager.getPrimaryConnection(), sql, MtbAartBarCode.class, OperationType.INSERT);
|
||||
|
||||
if (mtbAartBarCodes != null && mtbAartBarCodes.size() > 0 ) {
|
||||
if (mtbAartBarCodes != null && mtbAartBarCodes.size() > 0) {
|
||||
MtbAart mtbAart =
|
||||
new MtbAart()
|
||||
.setCodMart(codMart)
|
||||
.setMtbAartBarCode(mtbAartBarCodes);
|
||||
.setCodMart(codMart)
|
||||
.setMtbAartBarCode(mtbAartBarCodes);
|
||||
|
||||
entityList.add(mtbAart);
|
||||
}
|
||||
@@ -1248,7 +1284,7 @@ public class ProductServices {
|
||||
}
|
||||
}
|
||||
|
||||
if ( entityList != null && entityList.size() > 0 ) {
|
||||
if (entityList != null && entityList.size() > 0) {
|
||||
List<EntityBase> entityBases = entityProcessor.processEntityList(entityList, true);
|
||||
UtilityEntity.throwEntitiesException(entityBases);
|
||||
return entityBases;
|
||||
@@ -1256,10 +1292,10 @@ public class ProductServices {
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<String> getElencoBarcode(String elencoBarcode){
|
||||
private List<String> getElencoBarcode(String elencoBarcode) {
|
||||
String[] splitString = elencoBarcode.split("(?<=\\G.{13})");
|
||||
List<String> barcode = Stream.of(splitString)
|
||||
.filterNot(s->s.equalsIgnoreCase("0000000000000"))
|
||||
.filterNot(s -> s.equalsIgnoreCase("0000000000000"))
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
|
||||
@@ -302,6 +302,27 @@ public class ProductionPlanService {
|
||||
}
|
||||
|
||||
ordLavDTO.setPartite(saveProductionPlanDTO.getPartite());
|
||||
|
||||
sql = Query.format(
|
||||
"SELECT num_ord, qta_prod\n" +
|
||||
"FROM dtb_ordt\n" +
|
||||
"WHERE cod_jcom = %s\n" +
|
||||
" AND cod_prod = %s",
|
||||
saveProductionPlanDTO.getCodJcom(),
|
||||
saveProductionPlanDTO.getCodProd()
|
||||
);
|
||||
|
||||
if (numOrdL == null || numOrdL == 0) {
|
||||
HashMap<String, Object> ordData = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (ordData != null) {
|
||||
numOrdL = UtilityHashMap.getValueIfExists(ordData, "num_ord");
|
||||
|
||||
qtaProd = (qtaProd != null ? qtaProd : BigDecimal.ZERO)
|
||||
.add(UtilityHashMap.getValueIfExists(ordData, "qta_prod"));
|
||||
}
|
||||
}
|
||||
|
||||
if (numOrdL == null || numOrdL == 0) {
|
||||
operation = OperationType.INSERT;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ public class CaricoProdottoFinitoDTO {
|
||||
private boolean assegnaPosizione;
|
||||
private boolean aggiornaDettagliOrdine;
|
||||
private boolean accodaAdEsistenti = true;
|
||||
private boolean segnaQuarantena = false;
|
||||
|
||||
|
||||
public String getCodMart() {
|
||||
@@ -206,4 +207,13 @@ public class CaricoProdottoFinitoDTO {
|
||||
this.dataCollo = dataCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSegnaQuarantena() {
|
||||
return segnaQuarantena;
|
||||
}
|
||||
|
||||
public CaricoProdottoFinitoDTO setSegnaQuarantena(boolean segnaQuarantena) {
|
||||
this.segnaQuarantena = segnaQuarantena;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.exception.GestSetupNotFoundException;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
@@ -980,9 +981,20 @@ public class MesProductionServiceV2 {
|
||||
.setCodVdes(ordineLav.getCodVdes())
|
||||
.setPreparatoDa(dto.getPreparatoDa())
|
||||
.setNumOrd(dto.getNumOrd());
|
||||
if (dto.getDataCollo()!= null){
|
||||
if (dto.getDataCollo() != null) {
|
||||
mtbColtToInsert.setDataCollo(UtilityLocalDate.localDateFromDate(dto.getDataCollo()));
|
||||
}
|
||||
|
||||
if (dto.isSegnaQuarantena()) {
|
||||
String codDtipProvv = setupGest.getSetup("MES", "SETUP", "COD_DTIP_PROVV");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codDtipProvv)) {
|
||||
throw new GestSetupNotFoundException("MES", "SETUP", "COD_DTIP_PROVV");
|
||||
}
|
||||
|
||||
mtbColtToInsert.setCodDtipProvv(codDtipProvv);
|
||||
}
|
||||
|
||||
mtbColtToInsert.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,7 @@ import it.integry.ems.production.dto.MRP.*;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.CtbScad;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.UtilityBigDecimal;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -188,10 +185,16 @@ public class MrpDailyMaterialReqService {
|
||||
.toList();
|
||||
|
||||
for (Map.Entry<HashMap<String, Object>, List<MrpDailyMaterialReqDetDTO>> gg : listGG) {
|
||||
MrpDailyMaterialReqDTO.DatiGg mrpGiorno =
|
||||
new MrpDailyMaterialReqDTO.DatiGg()
|
||||
.setDataMrp((Date) gg.getKey().get("data"));
|
||||
// .setCodMdep((String) gg.getKey().get("codMdep"))
|
||||
MrpDailyMaterialReqDTO.DatiGg mrpGiorno;
|
||||
java.util.Optional<MrpDailyMaterialReqDTO.DatiGg> data = datiGg.stream().filter(x ->x. getDataMrp().compareTo(UtilityHashMap.getValueIfExists(gg.getKey(), "data"))==0).findFirst();
|
||||
if (data.isPresent()) {
|
||||
mrpGiorno = data.get();
|
||||
datiGg.remove(mrpGiorno);
|
||||
} else {
|
||||
mrpGiorno =
|
||||
new MrpDailyMaterialReqDTO.DatiGg()
|
||||
.setDataMrp((Date) gg.getKey().get("data"));
|
||||
}
|
||||
|
||||
for (MrpDailyMaterialReqDetDTO x : gg.getValue()) {
|
||||
giacenza = giacenza.add(x.getGiacenza());
|
||||
|
||||
@@ -451,9 +451,8 @@ public class OrtoFruttaProductionService {
|
||||
.setActivityId(activityId)
|
||||
.setCodDtip(codDtip)
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(dto.getDataDocProvv()))
|
||||
.setNumDoc(dto.getNumDocProvv())
|
||||
.setCodAnag(dto.getCodAnag())
|
||||
.setSerDoc(UtilityString.isNull(dto.getSerDocProvv(), serDoc))
|
||||
.setSerDoc(serDoc)
|
||||
.setDataOrd(dataOrd)
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setCodProd(dto.getCodMart())
|
||||
|
||||
@@ -22,6 +22,9 @@ public class GiacenzaDTO {
|
||||
@SqlField("cod_mdep")
|
||||
private String codMdep;
|
||||
|
||||
@SqlField("incoming_stock")
|
||||
private BigDecimal incomingStock;
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
@@ -66,4 +69,13 @@ public class GiacenzaDTO {
|
||||
this.codMdep = codMdep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getIncomingStock() {
|
||||
return incomingStock;
|
||||
}
|
||||
|
||||
public GiacenzaDTO setIncomingStock(BigDecimal incomingStock) {
|
||||
this.incomingStock = incomingStock;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3180,32 +3180,38 @@ public class PvmService {
|
||||
entityProcessor.processEntity(dtbDoct, multiDBTransactionManager);
|
||||
result.add(dtbDoct);
|
||||
|
||||
String exportType = "";
|
||||
String exportType = "", whereCondAnag = "";
|
||||
gestione = dtbDoct.getGestione();
|
||||
|
||||
if ("V".equals(gestione)) {
|
||||
exportType = "DOCUMENTI VENDITA";
|
||||
whereCondAnag = " wtb_clie.cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag());
|
||||
} else if ("L".equals(gestione)) {
|
||||
exportType = "DOCUMENTI LAVORAZIONE";
|
||||
whereCondAnag = " wtb_forn.cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag());
|
||||
} else if ("A".equals(gestione)) {
|
||||
exportType = "DOCUMENTI ACQUISTO";
|
||||
whereCondAnag = " wtb_forn.cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag());
|
||||
}
|
||||
|
||||
query =
|
||||
"SELECT wtb_users.user_name, wtb_users.password, wtb_users_info.format_file, COUNT(wtb_users_info.format_file) over (partition by wtb_users_info.user_name) " +
|
||||
" FROM wtb_users, wtb_users_info, wtb_clie " +
|
||||
" WHERE wtb_users.User_name = wtb_users_info.user_name and " +
|
||||
" wtb_users_info.User_name = wtb_clie.user_name and " +
|
||||
" wtb_clie.cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag()) + " AND " +
|
||||
" wtb_users_info.flag_state = 'S' and " +
|
||||
" wtb_users_info.export_type = " + UtilityDB.valueToString(exportType);
|
||||
|
||||
PreparedStatement psExport = multiDBTransactionManager.prepareStatement(query);
|
||||
ResultSet rsExport = psExport.executeQuery();
|
||||
if (rsExport.next()) {
|
||||
String userNameExport = rsExport.getString(1);
|
||||
String passwordExport = rsExport.getString(2);
|
||||
String formatExport = rsExport.getString(3);
|
||||
Integer countExport = rsExport.getInt(4);
|
||||
query =
|
||||
"SELECT wtb_users.user_name, wtb_users.password, wtb_users_info.format_file, COUNT(wtb_users_info.format_file) over (partition by wtb_users_info.user_name) as count_export" +
|
||||
" FROM wtb_users " +
|
||||
"INNER JOIN wtb_users_info ON wtb_users.User_name = wtb_users_info.user_name " +
|
||||
"LEFT OUTER JOIN wtb_clie ON wtb_users.User_name = wtb_clie.user_name AND wtb_users_info.export_type = 'DOCUMENTI VENDITA' " +
|
||||
"LEFT OUTER JOIN wtb_forn ON wtb_users.User_name = wtb_forn.user_name AND wtb_users_info.export_type <> 'DOCUMENTI VENDITA'" +
|
||||
" WHERE wtb_users_info.flag_state = 'S' and " +
|
||||
" wtb_users_info.export_type = " + UtilityDB.valueToString(exportType);
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCondAnag, true);
|
||||
HashMap<String, Object> datiExport = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
if (UtilityHashMap.isPresent(datiExport)) {
|
||||
String userNameExport = UtilityHashMap.getValueIfExists(datiExport, "user_name");
|
||||
String passwordExport = UtilityHashMap.getValueIfExists(datiExport, "password");
|
||||
String formatExport = UtilityHashMap.getValueIfExists(datiExport, "format_file");
|
||||
Integer countExport = UtilityHashMap.getValueIfExists(datiExport, "count_export");
|
||||
|
||||
if (countExport == 1) {
|
||||
requestDataDTO.setUsername(userNameExport);
|
||||
@@ -3225,8 +3231,6 @@ public class PvmService {
|
||||
}
|
||||
|
||||
}
|
||||
rsExport.close();
|
||||
psExport.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
|
||||
@@ -41,30 +41,32 @@ public class GiacenzaService {
|
||||
EntityProcessor entityProcessor;
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public void popolaGiancezaDaInventario(String codMdepParm) throws Exception {
|
||||
Date startDate = new Date();
|
||||
|
||||
final String queryArt =
|
||||
"SELECT mtb_aart.cod_mart AS cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.articolo_composto = 'S' AND mtb_comp.cod_comp IS NOT NULL THEN mtb_comp.cod_comp\n" +
|
||||
" ELSE mtb_aart.cod_mart END AS cod_mart_mov,\n" +
|
||||
" ISNULL(mtb_comp.qta_std, 1) AS qta_std\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
" LEFT OUTER JOIN mtb_comp ON mtb_aart.cod_mart = mtb_comp.cod_mart and mtb_aart.articolo_composto = 'S'";
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.articolo_composto = 'S' AND mtb_comp.cod_comp IS NOT NULL THEN mtb_comp.cod_comp\n" +
|
||||
" ELSE mtb_aart.cod_mart END AS cod_mart_mov,\n" +
|
||||
" ISNULL(mtb_comp.qta_std, 1) AS qta_std\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
" LEFT OUTER JOIN mtb_comp ON mtb_aart.cod_mart = mtb_comp.cod_mart and mtb_aart.articolo_composto = 'S'";
|
||||
|
||||
String sql =
|
||||
"SELECT cod_mdep\n" +
|
||||
"FROM stb_gest_setup_depo\n" +
|
||||
"WHERE gest_name = 'DATI_AZIENDA'\n" +
|
||||
" AND section = 'GIACENZA_DA_INV'\n" +
|
||||
" AND key_section = 'ATTIVO'\n" +
|
||||
" AND value = 'S'";
|
||||
"FROM stb_gest_setup_depo\n" +
|
||||
"WHERE gest_name = 'DATI_AZIENDA'\n" +
|
||||
" AND section = 'GIACENZA_DA_INV'\n" +
|
||||
" AND key_section = 'ATTIVO'\n" +
|
||||
" AND value = 'S'";
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(codMdepParm)) sql +=" AND stb_gest_setup_depo.cod_mdep = " + UtilityDB.valueToString(codMdepParm);
|
||||
if (!UtilityString.isNullOrEmpty(codMdepParm))
|
||||
sql += " AND stb_gest_setup_depo.cod_mdep = " + UtilityDB.valueToString(codMdepParm);
|
||||
List<String> depositi = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
List<RunnableThrowable> calls = new ArrayList<>();
|
||||
for (String codMdep: depositi) {
|
||||
for (String codMdep : depositi) {
|
||||
calls.add(() -> {
|
||||
try {
|
||||
popolamentoDatiDeposito(codMdep, queryArt, startDate);
|
||||
@@ -85,7 +87,7 @@ public class GiacenzaService {
|
||||
logger.debug(String.format(GiacenzaService.class.getSimpleName() + " - Deposito %s - Cancellazione kit: Timing " + ((new Date().getTime() - startDate.getTime()) / 1000) + " secs", codMdep));
|
||||
|
||||
String dataParm = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "DATI_AZIENDA", "GIACENZA_DA_INV", "DATA_INIZ", codMdep);
|
||||
Date dataIniz ;
|
||||
Date dataIniz;
|
||||
if (!UtilityString.isNullOrEmpty(dataParm))
|
||||
dataIniz = UtilityString.parseDate(dataParm);
|
||||
else
|
||||
@@ -132,7 +134,7 @@ public class GiacenzaService {
|
||||
}
|
||||
|
||||
|
||||
private void cancellazioneKit(String codMdep ) throws Exception {
|
||||
private void cancellazioneKit(String codMdep) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT g.cod_mdep, g.cod_mart\n" +
|
||||
"FROM carelli_giacenza_prog g INNER JOIN mtb_aart ON g.cod_mart =mtb_aart.cod_mart \n" +
|
||||
@@ -151,58 +153,58 @@ public class GiacenzaService {
|
||||
private void popolaQtaMovimenti(String codMdep, String queryArt, List<String> articoliSalvati) throws Exception {
|
||||
String sql;
|
||||
sql =
|
||||
(
|
||||
"WITH art AS (" + queryArt + "),\n" +
|
||||
" movimenti AS (SELECT mtb_movi.cod_mdep,\n" +
|
||||
" mtb_movi.cod_mart,\n" +
|
||||
" mtb_movi.data_reg,\n" +
|
||||
" mtb_movi.qta_car AS qta_car,\n" +
|
||||
" mtb_movi.qta_scar AS qta_scar,\n" +
|
||||
" dtb_doct.data_ins,\n" +
|
||||
" case when mtb_movi.qta_car > 0 THEN 'D' ELSE null END as tipo_car\n" +
|
||||
" FROM mtb_movi\n" +
|
||||
" INNER JOIN dtb_doct ON dtb_doct.cod_anag = mtb_movi.cod_anag AND\n" +
|
||||
" dtb_doct.cod_dtip = mtb_movi.cod_dtip AND\n" +
|
||||
" dtb_doct.data_doc = mtb_movi.data_doc AND\n" +
|
||||
" dtb_doct.ser_doc = mtb_movi.ser_doc AND\n" +
|
||||
" dtb_doct.num_doc = mtb_movi.num_doc\n" +
|
||||
" WHERE mtb_movi.cod_mdep = '[COD_MDEP]'\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT ntb_doct.cod_mdep,\n" +
|
||||
" ntb_docr.cod_mart,\n" +
|
||||
" ntb_doct.date_only_doc as data_reg,\n" +
|
||||
" 0,\n" +
|
||||
" ntb_docr.qta_doc * ntb_docr.qta_cnf,\n" +
|
||||
" ntb_doct.data_import,\n" +
|
||||
" null as tipo_car\n" +
|
||||
" FROM ntb_doct\n" +
|
||||
" INNER JOIN ntb_docr ON ntb_doct.cod_mdep = ntb_docr.cod_mdep AND\n" +
|
||||
" ntb_doct.cod_cassa = ntb_docr.cod_cassa AND\n" +
|
||||
" ntb_doct.data_doc = ntb_docr.data_doc\n" +
|
||||
" LEFT OUTER JOIN dtb_tipi ON ntb_doct.cod_dtip_val = dtb_tipi.cod_dtip\n" +
|
||||
" WHERE ntb_doct.cod_mdep = '[COD_MDEP]'\n" +
|
||||
" AND ntb_doct.causale = 'V'\n" +
|
||||
" AND (ntb_doct.data_doc_val IS NULL OR dtb_tipi.segno_qta_scar = 0))\n" +
|
||||
"\n" +
|
||||
"SELECT movimenti.cod_mdep,\n" +
|
||||
" art.cod_mart_mov as cod_mart,\n" +
|
||||
" IsNull(giac.qta_iniz, 0) as qta_iniz,\n" +
|
||||
" isNull(SUM(movimenti.qta_car * art.qta_std) , 0) + IsNull(giac.qta_iniz, 0) as qta_car,\n" +
|
||||
" isNull(SUM(movimenti.qta_scar * art.qta_std), 0) as qta_scar,\n" +
|
||||
" getdate() as data_ins\n" +
|
||||
"FROM movimenti\n" +
|
||||
" INNER JOIN art ON movimenti.cod_mart = art.cod_mart\n" +
|
||||
" LEFT OUTER JOIN carelli_giacenza_prog giac ON giac.cod_mdep = movimenti.cod_mdep AND giac.cod_mart = art.cod_mart_mov\n" +
|
||||
"WHERE movimenti.data_reg >= CAST(ISNULL(giac.data_reg, GETDATE()) AS DATE) AND \n" +
|
||||
" (giac.tipo_car is null OR giac.tipo_car <> 'R' OR (giac.tipo_car = 'R' AND movimenti.data_ins >= giac.data_reg)) \n" +
|
||||
"GROUP BY movimenti.cod_mdep,\n " +
|
||||
" art.cod_mart_mov,\n"+
|
||||
" giac.qta_iniz\n").replace("[COD_MDEP]", codMdep);
|
||||
(
|
||||
"WITH art AS (" + queryArt + "),\n" +
|
||||
" movimenti AS (SELECT mtb_movi.cod_mdep,\n" +
|
||||
" mtb_movi.cod_mart,\n" +
|
||||
" mtb_movi.data_reg,\n" +
|
||||
" mtb_movi.qta_car AS qta_car,\n" +
|
||||
" mtb_movi.qta_scar AS qta_scar,\n" +
|
||||
" dtb_doct.data_ins,\n" +
|
||||
" case when mtb_movi.qta_car > 0 THEN 'D' ELSE null END as tipo_car\n" +
|
||||
" FROM mtb_movi\n" +
|
||||
" INNER JOIN dtb_doct ON dtb_doct.cod_anag = mtb_movi.cod_anag AND\n" +
|
||||
" dtb_doct.cod_dtip = mtb_movi.cod_dtip AND\n" +
|
||||
" dtb_doct.data_doc = mtb_movi.data_doc AND\n" +
|
||||
" dtb_doct.ser_doc = mtb_movi.ser_doc AND\n" +
|
||||
" dtb_doct.num_doc = mtb_movi.num_doc\n" +
|
||||
" WHERE mtb_movi.cod_mdep = '[COD_MDEP]'\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT ntb_doct.cod_mdep,\n" +
|
||||
" ntb_docr.cod_mart,\n" +
|
||||
" ntb_doct.date_only_doc as data_reg,\n" +
|
||||
" 0,\n" +
|
||||
" ntb_docr.qta_doc * ntb_docr.qta_cnf,\n" +
|
||||
" ntb_doct.data_import,\n" +
|
||||
" null as tipo_car\n" +
|
||||
" FROM ntb_doct\n" +
|
||||
" INNER JOIN ntb_docr ON ntb_doct.cod_mdep = ntb_docr.cod_mdep AND\n" +
|
||||
" ntb_doct.cod_cassa = ntb_docr.cod_cassa AND\n" +
|
||||
" ntb_doct.data_doc = ntb_docr.data_doc\n" +
|
||||
" LEFT OUTER JOIN dtb_tipi ON ntb_doct.cod_dtip_val = dtb_tipi.cod_dtip\n" +
|
||||
" WHERE ntb_doct.cod_mdep = '[COD_MDEP]'\n" +
|
||||
" AND ntb_doct.causale = 'V'\n" +
|
||||
" AND (ntb_doct.data_doc_val IS NULL OR dtb_tipi.segno_qta_scar = 0))\n" +
|
||||
"\n" +
|
||||
"SELECT movimenti.cod_mdep,\n" +
|
||||
" art.cod_mart_mov as cod_mart,\n" +
|
||||
" IsNull(giac.qta_iniz, 0) as qta_iniz,\n" +
|
||||
" isNull(SUM(movimenti.qta_car * art.qta_std) , 0) + IsNull(giac.qta_iniz, 0) as qta_car,\n" +
|
||||
" isNull(SUM(movimenti.qta_scar * art.qta_std), 0) as qta_scar,\n" +
|
||||
" getdate() as data_ins\n" +
|
||||
"FROM movimenti\n" +
|
||||
" INNER JOIN art ON movimenti.cod_mart = art.cod_mart\n" +
|
||||
" LEFT OUTER JOIN carelli_giacenza_prog giac ON giac.cod_mdep = movimenti.cod_mdep AND giac.cod_mart = art.cod_mart_mov\n" +
|
||||
"WHERE movimenti.data_reg >= CAST(ISNULL(giac.data_reg, GETDATE()) AS DATE) AND \n" +
|
||||
" (giac.tipo_car is null OR giac.tipo_car <> 'R' OR (giac.tipo_car = 'R' AND movimenti.data_ins >= giac.data_reg)) \n" +
|
||||
"GROUP BY movimenti.cod_mdep,\n " +
|
||||
" art.cod_mart_mov,\n" +
|
||||
" giac.qta_iniz\n").replace("[COD_MDEP]", codMdep);
|
||||
|
||||
List<CarelliGiacenzaProg> carelliGiacenzaProgs = new ResultSetMapper().mapQuerySetToList(multiDBTransactionManager.getPrimaryConnection(), sql, CarelliGiacenzaProg.class);
|
||||
|
||||
Stream.of(carelliGiacenzaProgs)
|
||||
.forEach(x-> {
|
||||
.forEach(x -> {
|
||||
if (articoliSalvati.contains(x.getCodMart()))
|
||||
x.setOperation(OperationType.UPDATE);
|
||||
else {
|
||||
@@ -219,7 +221,7 @@ public class GiacenzaService {
|
||||
|
||||
private void popolaQtaCarInventario(String codMdep, Date dataIniz, String queryArt, List<String> articoliSalvati, String codDtipRett) throws Exception {
|
||||
String sql =
|
||||
Query.format("SELECT min(id_inventario) from carelli_giacenza_prog WHERE cod_mdep = %s and id_inventario is not null", codMdep);
|
||||
Query.format("SELECT max(id_inventario) from carelli_giacenza_prog WHERE cod_mdep = %s and id_inventario is not null", codMdep);
|
||||
|
||||
Integer maxIdInv = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
@@ -232,7 +234,7 @@ public class GiacenzaService {
|
||||
"FROM mtb_invent\n " +
|
||||
"WHERE cod_mdep = %s AND \n" +
|
||||
"data_inventario >= %s AND\n " +
|
||||
(maxIdInv!=null?"id_inventario>"+maxIdInv + " AND \n":"") +
|
||||
(maxIdInv != null ? "id_inventario>" + maxIdInv + " AND \n" : "") +
|
||||
"flag_stato <> 2 \n " +
|
||||
"AND EXISTS(SELECT * FROM mtb_invenr WHERE mtb_invent.id_inventario = mtb_invenr.id_inventario and mtb_invent.cod_mdep = mtb_invenr.cod_mdep ) " +
|
||||
"AND NOT EXISTS(SELECT * FROM carelli_giacenza_prog WHERE mtb_invent.id_inventario = carelli_giacenza_prog.id_inventario AND mtb_invent.cod_mdep = carelli_giacenza_prog.cod_mdep )",
|
||||
@@ -258,11 +260,11 @@ public class GiacenzaService {
|
||||
idInventario, codMdep);
|
||||
|
||||
List<MtbInvenr> mtbInvenrs = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbInvenr.class);
|
||||
if (mtbInvenrs == null || mtbInvenrs.size() == 0 )
|
||||
if (mtbInvenrs == null || mtbInvenrs.size() == 0)
|
||||
continue;
|
||||
|
||||
List<CarelliGiacenzaProg> giacDaInv = new ArrayList<>();
|
||||
for (MtbInvenr x: mtbInvenrs) {
|
||||
List<CarelliGiacenzaProg> giacDaInv = new ArrayList<>();
|
||||
for (MtbInvenr x : mtbInvenrs) {
|
||||
CarelliGiacenzaProg carelliGiacenzaProg = new CarelliGiacenzaProg()
|
||||
.setCodMdep(codMdep)
|
||||
.setCodMart(x.getCodMart())
|
||||
@@ -298,18 +300,18 @@ public class GiacenzaService {
|
||||
}
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT art.cod_mart_mov as cod_mart " +
|
||||
" FROM mtb_aart " +
|
||||
" INNER JOIN (" + queryArt + ") art on mtb_aart.cod_mart = art.cod_mart\n" +
|
||||
"WHERE exists(select * from mtb_sart where mtb_aart.cod_marT = mtb_sart.cod_mart and mtb_sart.cod_mdep = %s and \n" +
|
||||
"(qta_iniz <> 0 or qta_car <> 0 or qta_scar <> 0 ))", codMdep);
|
||||
Query.format(
|
||||
"SELECT DISTINCT art.cod_mart_mov as cod_mart " +
|
||||
" FROM mtb_aart " +
|
||||
" INNER JOIN (" + queryArt + ") art on mtb_aart.cod_mart = art.cod_mart\n" +
|
||||
"WHERE exists(select * from mtb_sart where art.cod_mart_mov = mtb_sart.cod_mart and mtb_sart.cod_mdep = %s and \n" +
|
||||
"(qta_iniz <> 0 or qta_car <> 0 or qta_scar <> 0 ))", codMdep);
|
||||
sql = UtilityDB.addwhereCond(sql, whereCondFiltro, true);
|
||||
List<String> datiArt = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
datiArt = Stream.of(datiArt).filterNot(x -> elencoArt.contains(x)).toList();
|
||||
|
||||
giacDaInv = new ArrayList<>();
|
||||
for(String codMart: datiArt) {
|
||||
for (String codMart : datiArt) {
|
||||
CarelliGiacenzaProg carelliGiacenzaProg = new CarelliGiacenzaProg()
|
||||
.setCodMdep(codMdep)
|
||||
.setCodMart(codMart)
|
||||
@@ -367,7 +369,7 @@ public class GiacenzaService {
|
||||
.setQtaScar(BigDecimal.ZERO)
|
||||
.setDataReg(dataCollo)
|
||||
.setTipoCar("R")
|
||||
.setDataIns(new Date());
|
||||
.setDataIns(dataCollo);
|
||||
|
||||
if (articoliSalvati.contains(codMart))
|
||||
c.setOperation(OperationType.UPDATE);
|
||||
@@ -391,12 +393,12 @@ public class GiacenzaService {
|
||||
dataIniz, codMdep, codDtipRett);
|
||||
|
||||
List<MtbColt> mtbColts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
if (mtbColts != null){
|
||||
if (mtbColts != null) {
|
||||
for (MtbColt collo : mtbColts) {
|
||||
collo
|
||||
.setCodDtip(codDtipRett)
|
||||
.setCodDtip(codDtipRett)
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(collo.getDataCollo()))
|
||||
.setDataDistribuzione(new Date());
|
||||
.setDataDistribuzione(new Date());
|
||||
collo.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(collo, false, false, "", multiDBTransactionManager, new RequestDataDTO(),false, false);
|
||||
UtilityEntity.throwEntityException(collo);
|
||||
@@ -406,7 +408,7 @@ public class GiacenzaService {
|
||||
}
|
||||
|
||||
private void saveEntity(List<? extends EntityBase> entityBases) throws SQLException, IOException {
|
||||
if ( entityBases.isEmpty()) return;
|
||||
if (entityBases.isEmpty()) return;
|
||||
|
||||
try {
|
||||
AtomicInteger counter = new AtomicInteger();
|
||||
@@ -482,14 +484,10 @@ public class GiacenzaService {
|
||||
|
||||
public List<GiacenzaDTO> retrieveGiacenza(String codMdep) throws Exception {
|
||||
String sql = "WITH art\n" +
|
||||
" AS (SELECT mtb_aart.cod_mart AS cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.articolo_composto = 'S'\n" +
|
||||
" AND mtb_comp.cod_comp IS NOT NULL\n" +
|
||||
" THEN mtb_comp.cod_comp\n" +
|
||||
" ELSE mtb_aart.cod_mart\n" +
|
||||
" END AS cod_mart_mov,\n" +
|
||||
" ISNULL(mtb_comp.qta_std, 1) AS qta_std\n" +
|
||||
" AS (SELECT mtb_aart.cod_mart AS cod_mart,\n" +
|
||||
" IIF(mtb_aart.articolo_composto = 'S'\n" +
|
||||
" AND mtb_comp.cod_comp IS NOT NULL, mtb_comp.cod_comp, mtb_aart.cod_mart) AS cod_mart_mov,\n" +
|
||||
" ISNULL(mtb_comp.qta_std, 1) AS qta_std\n" +
|
||||
" FROM mtb_aart\n" +
|
||||
" LEFT OUTER JOIN mtb_comp\n" +
|
||||
" ON mtb_aart.cod_mart = mtb_comp.cod_mart\n" +
|
||||
@@ -509,8 +507,7 @@ public class GiacenzaService {
|
||||
" AND dtb_doct.data_doc = mtb_movi.data_doc\n" +
|
||||
" AND dtb_doct.ser_doc = mtb_movi.ser_doc\n" +
|
||||
" AND dtb_doct.num_doc = mtb_movi.num_doc\n" +
|
||||
" WHERE mtb_movi.cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" AND dtb_doct.data_ins >= DATEADD(DAY, - 7, CAST(GETDATE() AS DATE))\n" +
|
||||
" WHERE mtb_movi.cod_mdep = " + UtilityDB.valueToString(codMdep) + "\n" +
|
||||
"\n" +
|
||||
" UNION ALL\n" +
|
||||
"\n" +
|
||||
@@ -529,9 +526,7 @@ public class GiacenzaService {
|
||||
" AND wdtb_doct.ser_doc = wdtb_docr.ser_doc\n" +
|
||||
" AND wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" WHERE wdtb_doct.flag_elaborato = 'N'\n" +
|
||||
" AND wdtb_doct.cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" AND wdtb_doct.data_ins >= DATEADD(DAY, - 7, CAST(GETDATE() AS DATE))\n" +
|
||||
"\n" +
|
||||
" AND wdtb_doct.cod_mdep = " + UtilityDB.valueToString(codMdep) + "\n" +
|
||||
" UNION ALL\n" +
|
||||
"\n" +
|
||||
" SELECT ntb_doct.cod_mdep,\n" +
|
||||
@@ -548,147 +543,238 @@ public class GiacenzaService {
|
||||
" AND ntb_doct.data_doc = ntb_docr.data_doc\n" +
|
||||
" LEFT OUTER JOIN dtb_tipi\n" +
|
||||
" ON ntb_doct.cod_dtip_val = dtb_tipi.cod_dtip\n" +
|
||||
" WHERE ntb_doct.cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" WHERE ntb_doct.cod_mdep = " + UtilityDB.valueToString(codMdep) + "\n" +
|
||||
" AND ntb_doct.causale = 'V'\n" +
|
||||
" AND (\n" +
|
||||
" ntb_doct.data_doc_val IS NULL\n" +
|
||||
" OR dtb_tipi.segno_qta_scar = 0\n" +
|
||||
" )\n" +
|
||||
" AND ntb_doct.date_only_doc >= DATEADD(DAY, - 7, CAST(GETDATE() AS DATE))),\n" +
|
||||
" AND NOT EXISTS (SELECT *\n" +
|
||||
" FROM dtb_doct\n" +
|
||||
" INNER JOIN mtb_depo ON dtb_doct.cod_mdep = mtb_depo.cod_mdep AND\n" +
|
||||
" dtb_doct.cod_dtip = mtb_depo.cod_dtip\n" +
|
||||
" WHERE date_only_doc = dtb_doct.data_doc\n" +
|
||||
" AND ntb_doct.cod_mdep = dtb_doct.cod_mdep)),\n" +
|
||||
" inventario_provvisorio\n" +
|
||||
" AS (SELECT mtb_colt.cod_mdep,\n" +
|
||||
" art.cod_mart_mov AS cod_mart,\n" +
|
||||
" SUM(qta_col * art.qta_std) AS qta_col,\n" +
|
||||
" art.cod_mart_mov AS cod_mart,\n" +
|
||||
" SUM(qta_col * art.qta_std) AS qta_col,\n" +
|
||||
" data_ins,\n" +
|
||||
" MAX(data_ins) OVER (\n" +
|
||||
" PARTITION BY mtb_colt.cod_mdep,art.cod_mart_mov\n" +
|
||||
" ) max_data_ins\n" +
|
||||
" MAX(data_ins) OVER ( PARTITION BY mtb_colt.cod_mdep,art.cod_mart_mov) AS max_data_ins\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr\n" +
|
||||
" ON mtb_colt.gestione = mtb_colr.gestione\n" +
|
||||
" AND mtb_colt.data_collo = mtb_colr.data_collo\n" +
|
||||
" AND mtb_colt.ser_collo = mtb_colr.ser_collo\n" +
|
||||
" AND mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" INNER JOIN (SELECT mtb_aart.cod_mart AS cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.articolo_composto = 'S'\n" +
|
||||
" AND mtb_comp.cod_comp IS NOT NULL\n" +
|
||||
" THEN mtb_comp.cod_comp\n" +
|
||||
" ELSE mtb_aart.cod_mart\n" +
|
||||
" END AS cod_mart_mov,\n" +
|
||||
" ISNULL(mtb_comp.qta_std, 1) AS qta_std\n" +
|
||||
" INNER JOIN (SELECT mtb_aart.cod_mart AS cod_mart,\n" +
|
||||
" IIF(mtb_aart.articolo_composto = 'S'\n" +
|
||||
" AND mtb_comp.cod_comp IS NOT NULL,\n" +
|
||||
" mtb_comp.cod_comp, mtb_aart.cod_mart) AS cod_mart_mov,\n" +
|
||||
" ISNULL(mtb_comp.qta_std, 1) AS qta_std\n" +
|
||||
" FROM mtb_aart\n" +
|
||||
" LEFT OUTER JOIN mtb_comp\n" +
|
||||
" ON mtb_aart.cod_mart = mtb_comp.cod_mart) art\n" +
|
||||
" ON mtb_colr.cod_mart = art.cod_mart\n" +
|
||||
" WHERE mtb_colt.cod_dtip_provv = 'RGIAC'\n" +
|
||||
" AND mtb_colt.data_ins >= DATEADD(DAY, - 7, CAST(GETDATE() AS DATE))\n" +
|
||||
" AND mtb_colt.cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" AND mtb_colt.data_distribuzione IS NULL\n" +
|
||||
" AND mtb_colt.cod_mdep = " + UtilityDB.valueToString(codMdep) + "\n" +
|
||||
" GROUP BY art.cod_mart_mov, mtb_colt.data_collo, data_ins, mtb_colt.cod_mdep),\n" +
|
||||
" selezione_giacenza\n" +
|
||||
" AS (SELECT ISNULL(ip.cod_mdep, gp.cod_mdep) cod_mdep,\n" +
|
||||
" ISNULL(ip.cod_mart, gp.cod_mart) cod_mart,\n" +
|
||||
" ISNULL(ip.qta_col, gp.qta_car) AS qta_car,\n" +
|
||||
" ISNULL(CASE\n" +
|
||||
" WHEN gp.data_ins < ip.data_ins\n" +
|
||||
" THEN 0\n" +
|
||||
" ELSE gp.qta_scar\n" +
|
||||
" END, 0) AS qta_scar,\n" +
|
||||
" ISNULL(ip.data_ins, gp.data_ins) AS data_ins,\n" +
|
||||
" ISNULL(CAST(ip.data_ins AS DATE), gp.data_reg) AS data_reg,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ip.data_ins IS NULL\n" +
|
||||
" THEN 0\n" +
|
||||
" ELSE 1\n" +
|
||||
" END AS is_invent,\n" +
|
||||
" ip.data_ins last_rgiac\n" +
|
||||
" AS (SELECT ISNULL(ip.cod_mdep, gp.cod_mdep) AS cod_mdep,\n" +
|
||||
" ISNULL(ip.cod_mart, gp.cod_mart) AS cod_mart,\n" +
|
||||
" ISNULL(ip.qta_col, gp.qta_car) AS qta_car,\n" +
|
||||
" ISNULL(IIF(gp.data_ins < ip.data_ins, 0, gp.qta_scar), 0) AS qta_scar,\n" +
|
||||
" ISNULL(ip.data_ins, gp.data_ins) AS data_ins,\n" +
|
||||
" ISNULL(CAST(ip.data_ins AS DATE), gp.data_reg) AS data_reg,\n" +
|
||||
" IIF(ip.data_ins IS NULL, 0, 1) AS is_invent,\n" +
|
||||
" ip.data_ins AS last_rgiac\n" +
|
||||
" FROM carelli_giacenza_prog gp\n" +
|
||||
" LEFT JOIN inventario_provvisorio ip\n" +
|
||||
" ON ip.cod_mart = gp.cod_mart\n" +
|
||||
" AND ip.cod_mdep = gp.cod_mdep\n" +
|
||||
" AND max_data_ins = ip.data_ins\n" +
|
||||
" AND (gp.data_ins < ip.data_ins)\n" +
|
||||
" WHERE gp.cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")),\n" +
|
||||
" mov\n" +
|
||||
" AS (SELECT movimenti.cod_mdep,\n" +
|
||||
" WHERE gp.cod_mdep = " + UtilityDB.valueToString(codMdep) + "),\n" +
|
||||
" mov AS (SELECT movimenti.cod_mdep,\n" +
|
||||
" art.cod_mart_mov AS cod_mart,\n" +
|
||||
" SUM(movimenti.qta_car * qta_std) + ISNULL(giac.qta_car, 0) AS qta_car,\n" +
|
||||
" SUM(movimenti.qta_scar * qta_std) + ISNULL(giac.qta_scar, 0) AS qta_scar,\n" +
|
||||
" GETDATE() AS data_ins\n" +
|
||||
"\n" +
|
||||
" FROM movimenti\n" +
|
||||
" INNER JOIN art\n" +
|
||||
" ON movimenti.cod_mart = art.cod_mart\n" +
|
||||
" INNER JOIN art ON movimenti.cod_mart = art.cod_mart\n" +
|
||||
" LEFT OUTER JOIN selezione_giacenza giac\n" +
|
||||
" ON giac.cod_mdep = movimenti.cod_mdep\n" +
|
||||
" AND giac.cod_mart = art.cod_mart_mov\n" +
|
||||
" ON giac.cod_mdep = movimenti.cod_mdep AND giac.cod_mart = art.cod_mart_mov\n" +
|
||||
" WHERE (\n" +
|
||||
" (movimenti.data_reg >= ISNULL(giac.data_reg, CAST(GETDATE() AS DATE)) AND\n" +
|
||||
" (giac.data_ins IS NULL OR (movimenti.data_ins >= giac.data_ins))) OR\n" +
|
||||
" (\n" +
|
||||
" movimenti.data_reg >= ISNULL(giac.data_reg, CAST(GETDATE() AS DATE))\n" +
|
||||
" AND (\n" +
|
||||
" giac.data_ins IS NULL\n" +
|
||||
" OR (movimenti.data_ins >= giac.data_ins)\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" OR (\n" +
|
||||
" (movimenti.tipo_car = 'W')\n" +
|
||||
" AND (\n" +
|
||||
" (\n" +
|
||||
" giac.data_ins IS NULL\n" +
|
||||
" OR (movimenti.data_ins >= giac.data_ins)\n" +
|
||||
" )\n" +
|
||||
" OR (\n" +
|
||||
" is_invent = 0\n" +
|
||||
" AND (\n" +
|
||||
" movimenti.data_ins >= last_rgiac\n" +
|
||||
" OR last_rgiac IS NULL\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" (movimenti.tipo_car = 'W') AND (\n" +
|
||||
" (giac.data_ins IS NULL OR (movimenti.data_ins >= giac.data_ins)) OR\n" +
|
||||
" (is_invent = 1 AND (movimenti.data_ins >= last_rgiac)) OR\n" +
|
||||
" (is_invent = 0 AND movimenti.data_ins >= ISNULL(giac.data_reg, CAST(GETDATE() AS DATE)))\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" AND movimenti.cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" AND movimenti.cod_mdep = " + UtilityDB.valueToString(codMdep) + "\n" +
|
||||
" GROUP BY movimenti.cod_mdep, art.cod_mart_mov, giac.qta_car, giac.qta_scar),\n" +
|
||||
" inv\n" +
|
||||
" AS (SELECT ISNULL(r.cod_mart, k.cod_mart) AS cod_mart,\n" +
|
||||
" ISNULL(mtb_aart.descrizione, '') descrizione,\n" +
|
||||
" ISNULL(r.qta_car, ISNULL(k.qta_car, 0)) - ISNULL(r.qta_scar, ISNULL(k.qta_scar, 0)) qta_inv,\n" +
|
||||
" ISNULL(k.data_ins, CAST(GETDATE() AS DATE)) data_inventario,\n" +
|
||||
" ISNULL(r.cod_mdep, k.cod_mdep) AS cod_mdep\n" +
|
||||
" AS (SELECT ISNULL(r.cod_mart, k.cod_mart) AS cod_mart,\n" +
|
||||
" ISNULL(r.qta_car, ISNULL(k.qta_car, 0)) - ISNULL(r.qta_scar, ISNULL(k.qta_scar, 0)) AS qta_inv,\n" +
|
||||
" ISNULL(k.data_ins, CAST(GETDATE() AS DATE)) AS data_inventario,\n" +
|
||||
" ISNULL(r.cod_mdep, k.cod_mdep) AS cod_mdep\n" +
|
||||
" FROM mov r\n" +
|
||||
" INNER JOIN mtb_aart\n" +
|
||||
" ON r.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" FULL OUTER JOIN selezione_giacenza k\n" +
|
||||
" ON k.cod_mart = r.cod_mart\n" +
|
||||
" AND k.cod_mdep = r.cod_mdep\n" +
|
||||
" AND k.cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")),\n" +
|
||||
" final\n" +
|
||||
" AS (SELECT cod_mart, descrizione, qta_inv, data_inventario, cod_mdep\n" +
|
||||
" FROM inv\n" +
|
||||
" WHERE cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" AND qta_inv != 0\n" +
|
||||
" AND k.cod_mdep = " + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" ,\n" +
|
||||
" final AS (SELECT cod_mart, qta_inv, data_inventario, cod_mdep\n" +
|
||||
" FROM inv\n" +
|
||||
" WHERE cod_mdep = " + UtilityDB.valueToString(codMdep) + "\n" +
|
||||
" AND qta_inv != 0\n" +
|
||||
" UNION\n" +
|
||||
" SELECT mtb_comp.cod_mart,\n" +
|
||||
" ROUND(SUM(ISNULL(qta_inv, 0)) / SUM(qta_std), 2),\n" +
|
||||
" MAX(data_inventario),\n" +
|
||||
" MAX(cod_mdep)\n" +
|
||||
" FROM mtb_aart\n" +
|
||||
" INNER JOIN mtb_comp ON mtb_aart.cod_mart = mtb_comp.cod_mart\n" +
|
||||
" LEFT OUTER JOIN tmpGiac inv ON mtb_comp.cod_comp = inv.cod_mart\n" +
|
||||
" WHERE mtb_aart.articolo_composto = 'S'\n" +
|
||||
" AND mtb_aart.flag_stato = 'A'\n" +
|
||||
" GROUP BY mtb_comp.cod_mart)\n" +
|
||||
"\n" +
|
||||
" UNION\n" +
|
||||
"\n" +
|
||||
" SELECT mtb_comp.cod_mart, descrizione, ROUND(qta_inv / qta_std, 2), data_inventario, cod_mdep\n" +
|
||||
" FROM inv\n" +
|
||||
" JOIN mtb_comp\n" +
|
||||
" ON inv.cod_mart = mtb_comp.cod_comp\n" +
|
||||
" WHERE cod_mdep IN (" + UtilityDB.valueToString(codMdep) + ")),\n" +
|
||||
" find_duplicates AS (SELECT cod_mart,\n" +
|
||||
" descrizione,\n" +
|
||||
" qta_inv,\n" +
|
||||
" data_inventario,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY cod_mart, cod_mdep ORDER BY data_inventario DESC, qta_inv DESC) AS rownum\n" +
|
||||
" FROM final)\n" +
|
||||
"SELECT cod_mart,\n" +
|
||||
"SELECT final.cod_mart,\n" +
|
||||
" descrizione,\n" +
|
||||
" qta_inv,\n" +
|
||||
" data_inventario,\n" +
|
||||
" cod_mdep\n" +
|
||||
"FROM find_duplicates\n" +
|
||||
"WHERE rownum = 1";
|
||||
"FROM final\n" +
|
||||
" INNER JOIN mtb_aart ON final.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"WHERE cod_mdep IS NOT NULL";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, GiacenzaDTO.class);
|
||||
List<GiacenzaDTO> listGiacenza = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, GiacenzaDTO.class);
|
||||
|
||||
String listiniAcquisto = setupGest.getSetup("DATI_AZIENDA", "GIACENZA_DA_INV", "LISTINI_ACQUISTO");
|
||||
List<String> listini = Arrays.asList(listiniAcquisto.split("\\|"));
|
||||
|
||||
sql = "WITH incoming_stock_documenti AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione dei documenti (bolle web) di merce consegnata\n" +
|
||||
"*/\n" +
|
||||
"\n" +
|
||||
" SELECT wdtb_doct.cod_mdep,\n" +
|
||||
" wdtb_docr.cod_mart,\n" +
|
||||
" wdtb_docr.data_ord,\n" +
|
||||
" wdtb_docr.num_ord,\n" +
|
||||
" riga_ord,\n" +
|
||||
" wdtb_doct.cod_anag,\n" +
|
||||
" wdtb_docr.qta_doc * wdtb_docr.rap_conv AS qta_doc,\n" +
|
||||
" wdtb_doct.flag_elaborato\n" +
|
||||
" FROM wdtb_doct\n" +
|
||||
" INNER JOIN wdtb_docr\n" +
|
||||
" ON wdtb_doct.cod_anag = wdtb_docr.cod_anag AND wdtb_doct.cod_dtip = wdtb_docr.cod_dtip AND\n" +
|
||||
" wdtb_doct.data_doc = wdtb_docr.data_doc AND wdtb_doct.ser_doc = wdtb_docr.ser_doc AND\n" +
|
||||
" wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" WHERE wdtb_doct.data_ins >= dateadd(DAY, - 21, CAST(getdate() AS DATE))\n" +
|
||||
" AND wdtb_doct.cod_mdep = " + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" , incoming_stock_ordini AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione degli ordini d'acquisto in consegna\n" +
|
||||
"*/\n" +
|
||||
" SELECT r.cod_mdep,\n" +
|
||||
" r.cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN r.data_cons = r.data_ord\n" +
|
||||
" THEN CAST(getdate() AS DATE)\n" +
|
||||
" ELSE r.data_cons\n" +
|
||||
" END AS data_cons,\n" +
|
||||
" r.qta_ord,\n" +
|
||||
" r.data_ord,\n" +
|
||||
" r.riga_ord,\n" +
|
||||
" r.num_ord,\n" +
|
||||
" cod_anag\n" +
|
||||
" FROM dtb_ordt t\n" +
|
||||
" INNER JOIN dtb_ordr r\n" +
|
||||
" ON t.gestione = r.gestione\n" +
|
||||
" AND t.data_ord = r.data_ord\n" +
|
||||
" AND t.num_ord = r.num_ord\n" +
|
||||
" WHERE\n" +
|
||||
" -- ordini acquisto\n" +
|
||||
" t.gestione = 'A'\n" +
|
||||
" -- ordini non annullati\n" +
|
||||
" AND t.flag_annulla = 'N'\n" +
|
||||
" -- ordii non sospesi\n" +
|
||||
" AND t.flag_sospeso = 'N'\n" +
|
||||
" AND (\n" +
|
||||
" -- ordini futuri\n" +
|
||||
" (r.data_cons >= CAST(getdate() AS DATE))\n" +
|
||||
" OR\n" +
|
||||
" -- ordini fuori piano logistico (r.data_cons = r.data_ord), inevasi e fatti negli ultimi 3 giorni\n" +
|
||||
" (\n" +
|
||||
" r.data_cons = r.data_ord\n" +
|
||||
" AND flag_evaso = 'I'\n" +
|
||||
" AND r.data_ord >= dateadd(DAY, - 3, CAST(getdate() AS DATE))\n" +
|
||||
" )\n" +
|
||||
" )\n" +
|
||||
" -- prendiamo i soli ordini del SECCO, sarà da modificare quando inizieranno ad ordinare anche altri (es. APULD)\n" +
|
||||
" AND t.listino IN (" + UtilityDB.listValueToString(listini) + ")\n" +
|
||||
" -- ordine non ancora evaso\n" +
|
||||
" AND flag_evaso <> 'E'\n" +
|
||||
" -- filtro solamente un Pdv\n" +
|
||||
" AND r.cod_mdep = " + UtilityDB.valueToString(codMdep) + ")\n" +
|
||||
" , incoming_stock_doc_consegnati AS (\n" +
|
||||
"/*\n" +
|
||||
"Estrazione dei documenti consegnati\n" +
|
||||
"*/\n" +
|
||||
" SELECT DISTINCT wdtb_docr.num_ord, wdtb_docr.data_ord, wdtb_doct.cod_anag\n" +
|
||||
" FROM wdtb_doct\n" +
|
||||
" INNER JOIN wdtb_docr\n" +
|
||||
" ON wdtb_doct.cod_anag = wdtb_docr.cod_anag AND wdtb_doct.cod_dtip = wdtb_docr.cod_dtip AND\n" +
|
||||
" wdtb_doct.data_doc = wdtb_docr.data_doc AND wdtb_doct.ser_doc = wdtb_docr.ser_doc AND\n" +
|
||||
" wdtb_doct.num_doc = wdtb_docr.num_doc\n" +
|
||||
" WHERE wdtb_doct.data_ins >= dateadd(DAY, - 7, CAST(getdate() AS DATE))\n" +
|
||||
" AND wdtb_doct.flag_elaborato = 'N')\n" +
|
||||
"\n" +
|
||||
"-- Step 4) Unione delle estrazioni precedenti [MySQL]\n" +
|
||||
"\n" +
|
||||
"SELECT ISNULL(d.cod_mdep, o.cod_mdep) AS store_code,\n" +
|
||||
" ISNULL(d.cod_mart, o.cod_mart) AS art_code,\n" +
|
||||
" data_cons,\n" +
|
||||
" SUM(ISNULL(qta_doc, qta_ord)) AS incoming_stock\n" +
|
||||
"FROM incoming_stock_ordini o\n" +
|
||||
" FULL OUTER JOIN incoming_stock_documenti d\n" +
|
||||
" ON o.cod_mdep = d.cod_mdep AND o.cod_mart = d.cod_mart AND o.data_ord = d.data_ord AND\n" +
|
||||
" o.num_ord = d.num_ord AND o.cod_anag = d.cod_anag AND o.riga_ord = d.riga_ord\n" +
|
||||
" LEFT JOIN incoming_stock_doc_consegnati k\n" +
|
||||
" ON o.num_ord = k.num_ord AND o.cod_anag = k.cod_anag AND o.data_ord = k.data_ord\n" +
|
||||
"WHERE (flag_elaborato = 'I' OR flag_elaborato IS NULL)\n" +
|
||||
" AND ((d.cod_mart IS NOT NULL) OR (d.cod_mart IS NULL AND k.num_ord IS NULL))\n" +
|
||||
"GROUP BY ISNULL(d.cod_mdep, o.cod_mdep), ISNULL(d.cod_mart, o.cod_mart), data_cons, k.num_ord\n";
|
||||
|
||||
List<HashMap<String, Object>> merceInArrivo = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (listGiacenza != null) {
|
||||
|
||||
merceInArrivo
|
||||
.forEach(merce -> {
|
||||
String storeCode = (String) merce.get("store_code");
|
||||
String artCode = (String) merce.get("art_code");
|
||||
BigDecimal incomingStock = (BigDecimal) merce.get("incoming_stock");
|
||||
|
||||
listGiacenza.stream()
|
||||
.filter(x -> x.getCodMart().equals(artCode) && x.getCodMdep().equals(storeCode))
|
||||
.findFirst()
|
||||
.ifPresent(x -> {
|
||||
x.setIncomingStock(incomingStock);
|
||||
});
|
||||
});
|
||||
|
||||
return listGiacenza;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1420,6 +1420,7 @@ public class WMSGenericService {
|
||||
|
||||
}
|
||||
|
||||
Date datetimeRow = new Date();
|
||||
|
||||
for (ScaricoMateriaPrimaDTO scaricoMateriaPrimaDTO : scaricoMateriaPrimaDTOList) {
|
||||
List<MtbColt> mtbColtsToInsert = new ArrayList<>();
|
||||
@@ -1546,7 +1547,8 @@ public class WMSGenericService {
|
||||
.setNumColloRif(giacInPosizioneItem.getNumCollo())
|
||||
.setDataColloRif(UtilityLocalDate.localDateToDate(giacInPosizioneItem.getDataCollo()))
|
||||
.setSerColloRif(giacInPosizioneItem.getSerCollo())
|
||||
.setGestioneRif(giacInPosizioneItem.getGestione());
|
||||
.setGestioneRif(giacInPosizioneItem.getGestione())
|
||||
.setDatetimeRow(datetimeRow);
|
||||
mtbColr.setOperation(OperationType.INSERT);
|
||||
mtbColtToInsert.getMtbColr().add(mtbColr);
|
||||
|
||||
@@ -1571,6 +1573,7 @@ public class WMSGenericService {
|
||||
private List<AnomalieDTO> scaricoMateriaPrimadaOrdine(String codMdep, String codJfas, boolean useRapportoMatPrima, List<ScaricoMateriaPrimaDaOrdineDTO> listScarichiOrdine) throws Exception {
|
||||
final List<AnomalieDTO> anomalieList = new ArrayList<>();
|
||||
List<MtbColt> mtbColtsToInsert = new ArrayList<>();
|
||||
Date datetimeRow = new Date();
|
||||
|
||||
for (ScaricoMateriaPrimaDaOrdineDTO scaricoDaOrdine : listScarichiOrdine) {
|
||||
String codJfasScarico = codJfas != null ? codJfas : scaricoDaOrdine.getCodJfas();
|
||||
@@ -1632,7 +1635,6 @@ public class WMSGenericService {
|
||||
|
||||
|
||||
for (MvwSitArtUdcDetInventarioDTO giacenza : giacenzeArticolo) {
|
||||
|
||||
if (UtilityBigDecimal.equalsOrLowerThan(qtaRimanente, BigDecimal.ZERO)) {
|
||||
break;
|
||||
}
|
||||
@@ -1698,7 +1700,8 @@ public class WMSGenericService {
|
||||
.setNumColloRif(giacenza.getNumCollo())
|
||||
.setDataColloRif(UtilityLocalDate.localDateToDate(giacenza.getDataCollo()))
|
||||
.setSerColloRif(giacenza.getSerCollo())
|
||||
.setGestioneRif(giacenza.getGestione());
|
||||
.setGestioneRif(giacenza.getGestione())
|
||||
.setDatetimeRow(datetimeRow);
|
||||
mtbColr.setOperation(OperationType.INSERT);
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ public class CertificatiSinfoOneDTO {
|
||||
private String codAnag;
|
||||
@SqlField("ragSoc")
|
||||
private String ragSoc;
|
||||
@SqlField("produttore")
|
||||
private String produttore;
|
||||
@SqlField("op")
|
||||
private String op;
|
||||
@SqlField("codVdes")
|
||||
private String codVdes;
|
||||
@SqlField("dataCert")
|
||||
@@ -74,6 +78,24 @@ public class CertificatiSinfoOneDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProduttore() {
|
||||
return produttore;
|
||||
}
|
||||
|
||||
public CertificatiSinfoOneDTO setProduttore(String produttore) {
|
||||
this.produttore = produttore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
public CertificatiSinfoOneDTO setOp(String op) {
|
||||
this.op = op;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVdes() {
|
||||
return codVdes;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.integry.ems.system.exchange.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -132,7 +133,11 @@ public class ExchangeColliImportService {
|
||||
} catch (Exception ex) {
|
||||
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = ex;
|
||||
|
||||
logger.error("Errore durante l'importazione del collo", ex);
|
||||
MtbColt collo = (MtbColt) dataToSave;
|
||||
logger.error("Errore durante l'importazione del collo [num: " + collo.getNumCollo() + ", " +
|
||||
"data: " + UtilityLocalDate.formatDate(collo.getDataCollo(), CommonConstants.DATE_FORMAT_DMY) + ", " +
|
||||
"serie: " + collo.getSerCollo() + ", " +
|
||||
"gestione: " + collo.getGestione() + "]", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +217,8 @@ public class ExchangeColliImportService {
|
||||
" data_cert AS dataCert,\n" +
|
||||
" CONVERT(NUMERIC(10, 0), num_cert) AS numCert,\n" +
|
||||
" data_bolla AS dataBolla,\n" +
|
||||
" produttore AS produttore,\n" +
|
||||
" OP AS op,\n" +
|
||||
" TRIM(num_bolla) AS numBolla,\n" +
|
||||
" TRIM(PMB_TIPO_POMODORO) AS codMart,\n" +
|
||||
" TRIM(PMB_SEME) AS varieta,\n" +
|
||||
|
||||
@@ -146,7 +146,13 @@ public class ExchangeDocumentImportService {
|
||||
} catch (Exception ex) {
|
||||
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = ex;
|
||||
|
||||
logger.error("Errore durante l'importazione del documento", ex);
|
||||
DtbDoct document = (DtbDoct) dataToSave;
|
||||
logger.error("Errore durante l'importazione del documento [" +
|
||||
"num: " + document.getNumDoc() + ", " +
|
||||
"serie: " + document.getSerDoc() + ", " +
|
||||
"data: " + document.getDataDoc() + ", " +
|
||||
"cod anag: " + document.getCodAnag() + ", " +
|
||||
"cod dtip: " + document.getCodDtip() + "]", ex);
|
||||
//multiDBTransactionManager.rollbackAll();
|
||||
//throw ex;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,11 @@ public class ExchangeOrdiniImportService {
|
||||
} catch (Exception ex) {
|
||||
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = ex;
|
||||
|
||||
logger.error("Errore durante l'importazione dell'ordine", ex);
|
||||
DtbOrdt order = (DtbOrdt) dataToSave;
|
||||
|
||||
logger.error("Errore durante l'importazione dell'ordine [num: " + order.getNumOrd() + "," +
|
||||
"data: " + order.getDataOrd() + "," +
|
||||
"gestione: " + order.getGestione() + "]", ex);
|
||||
internalMultiDb.rollbackAll();
|
||||
//throw ex;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Service
|
||||
@@ -65,6 +66,9 @@ public class ExchangePartiteMagazzinoImportService {
|
||||
|
||||
allData.forEach(x -> x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation()));
|
||||
|
||||
allData = allData.stream().filter(x -> x.getOperation() != OperationType.DELETE)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final Exception[] firstExceptionToThrow = {null};
|
||||
|
||||
AtomicInteger importedCounter = new AtomicInteger();
|
||||
|
||||
@@ -98,24 +98,24 @@
|
||||
|
||||
<Loggers>
|
||||
|
||||
<AsyncLogger name="it.integry" level="ALL" additivity="false">
|
||||
<AppenderRef ref="console" level="DEBUG"/>
|
||||
<AsyncLogger name="it.integry" level="ALL" additivity="false">
|
||||
<AppenderRef ref="console" level="ALL"/>
|
||||
<AppenderRef ref="primaryFileLogger" level="ALL"/>
|
||||
<AppenderRef ref="errorFileLogger" level="ERROR"/>
|
||||
<AppenderRef ref="infoFileLogger" level="INFO"/>
|
||||
<AppenderRef ref="debugFileLogger" level="DEBUG"/>
|
||||
<AppenderRef ref="traceFileLogger" level="TRACE"/>
|
||||
<AppenderRef ref="SqLiteDatabase"/>
|
||||
</AsyncLogger >
|
||||
<AsyncLogger name="org.springframework" level="ALL" additivity="false">
|
||||
<AppenderRef ref="console" level="DEBUG"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="org.springframework" level="ALL" additivity="false">
|
||||
<AppenderRef ref="console" level="ALL"/>
|
||||
<AppenderRef ref="primaryFileLogger" level="ALL"/>
|
||||
<AppenderRef ref="errorFileLogger" level="ERROR"/>
|
||||
<AppenderRef ref="infoFileLogger" level="INFO"/>
|
||||
<AppenderRef ref="debugFileLogger" level="DEBUG"/>
|
||||
<AppenderRef ref="traceFileLogger" level="TRACE"/>
|
||||
<AppenderRef ref="SqLiteDatabase"/>
|
||||
</AsyncLogger >
|
||||
</AsyncLogger>
|
||||
|
||||
<!-- <Logger name="org.springframework.beans.factory" level="ALL">-->
|
||||
<!-- <appender-ref ref="console" level="DEBUG"/>-->
|
||||
|
||||
Reference in New Issue
Block a user