Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package it.integry.ems.migration._base;
|
package it.integry.ems.migration._base;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public enum IntegryCustomer {
|
public enum IntegryCustomer {
|
||||||
|
|
||||||
Agricoper(IntegryCustomerDB.Agricoper_Agricoper,
|
Agricoper(IntegryCustomerDB.Agricoper_Agricoper,
|
||||||
@@ -137,4 +139,13 @@ public enum IntegryCustomer {
|
|||||||
public IntegryCustomerDB[] getValues() {
|
public IntegryCustomerDB[] getValues() {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IntegryCustomer getFromDB(IntegryCustomerDB customerDB) {
|
||||||
|
if(customerDB == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return Arrays.stream(values()).filter(x -> Arrays.stream(x.getValues()).anyMatch(y -> y == customerDB))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package it.integry.ems.migration._base;
|
package it.integry.ems.migration._base;
|
||||||
|
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public enum IntegryCustomerDB {
|
public enum IntegryCustomerDB {
|
||||||
Agricoper_Agricoper("agricoper"),
|
Agricoper_Agricoper("agricoper"),
|
||||||
Agricoper_IlVisone("ilvisone"),
|
Agricoper_IlVisone("ilvisone"),
|
||||||
@@ -211,4 +215,13 @@ public enum IntegryCustomerDB {
|
|||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IntegryCustomerDB parse(String value) {
|
||||||
|
if(UtilityString.isNullOrEmpty(value))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return Arrays.stream(values()).filter(x -> x.getValue().equalsIgnoreCase(value))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,198 @@
|
|||||||
|
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_20250318093455 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||||
|
return;
|
||||||
|
|
||||||
|
dropDefault("mrl_depo_art_esclusi_wms", "flag_escludi_vend");
|
||||||
|
|
||||||
|
executeStatement(
|
||||||
|
"ALTER TABLE mrl_depo_art_esclusi_wms\n" +
|
||||||
|
" DROP COLUMN flag_escludi_vend;\n" +
|
||||||
|
"ALTER TABLE mrl_depo_art_esclusi_wms\n" +
|
||||||
|
" ADD flag_escludi_ven BIT DEFAULT 1 NOT NULL;"
|
||||||
|
);
|
||||||
|
|
||||||
|
createOrUpdateView("mvw_articoli_esclusi_wms", "CREATE VIEW dbo.mvw_articoli_esclusi_wms AS\n" +
|
||||||
|
"SELECT DISTINCT mrl_depo_art_esclusi_wms.cod_mdep,\n" +
|
||||||
|
" ma.cod_mart,\n" +
|
||||||
|
" ma.cod_mgrp,\n" +
|
||||||
|
" ma.cod_msgr,\n" +
|
||||||
|
" ma.cod_msfa,\n" +
|
||||||
|
" ma.cod_mtip,\n" +
|
||||||
|
" ma.cod_mstp,\n" +
|
||||||
|
" mrl_depo_art_esclusi_wms.flag_escludi_lav,\n" +
|
||||||
|
" mrl_depo_art_esclusi_wms.flag_escludi_acq,\n" +
|
||||||
|
" mrl_depo_art_esclusi_wms.flag_escludi_ven\n" +
|
||||||
|
"FROM mrl_depo_art_esclusi_wms\n" +
|
||||||
|
" INNER JOIN mtb_aart ma\n" +
|
||||||
|
" ON (ISNULL(mrl_depo_art_esclusi_wms.cod_mgrp, ma.cod_mgrp) = ma.cod_mgrp AND\n" +
|
||||||
|
" ISNULL(mrl_depo_art_esclusi_wms.cod_msgr, ma.cod_msgr) = ma.cod_msgr AND\n" +
|
||||||
|
" ISNULL(ISNULL(mrl_depo_art_esclusi_wms.cod_msfa, ma.cod_msfa), '') = ISNULL(ma.cod_msfa, '') AND\n" +
|
||||||
|
" ISNULL(ISNULL(mrl_depo_art_esclusi_wms.cod_mtip, ma.cod_mtip), '') = ISNULL(ma.cod_mtip, '') AND\n" +
|
||||||
|
" ISNULL(ISNULL(mrl_depo_art_esclusi_wms.cod_mstp, ma.cod_mstp), '') = ISNULL(ma.cod_mstp, '') AND\n" +
|
||||||
|
" ISNULL(mrl_depo_art_esclusi_wms.cod_mart, ma.cod_mart) = ma.cod_mart)"
|
||||||
|
);
|
||||||
|
|
||||||
|
createOrUpdateView("ovw_situazione_qta_ordini_wms_vend", "CREATE VIEW [dbo].[ovw_situazione_qta_ordini_wms_vend] AS\n" +
|
||||||
|
" /*Vista usata dal WMS per individuare gli ordini da evadere e le righe gia' caricate su un viaggio*/\n" +
|
||||||
|
"WITH custom_mtb_colr AS (SELECT mtb_colr.gestione,\n" +
|
||||||
|
" mtb_colr.data_ord,\n" +
|
||||||
|
" mtb_colr.num_ord,\n" +
|
||||||
|
" mtb_colr.riga_ord,\n" +
|
||||||
|
" SUM(qta_col) AS qta_col,\n" +
|
||||||
|
" SUM(num_cnf) AS num_cnf,\n" +
|
||||||
|
" SUM(qta_col / qta_cnf) AS cnf_col\n" +
|
||||||
|
" FROM mtb_colt,\n" +
|
||||||
|
" mtb_colr\n" +
|
||||||
|
" WHERE mtb_colr.gestione = mtb_colt.gestione\n" +
|
||||||
|
" AND mtb_colr.data_collo = mtb_colt.data_collo\n" +
|
||||||
|
" AND mtb_colr.ser_collo = mtb_colt.ser_collo\n" +
|
||||||
|
" AND mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||||
|
" AND mtb_colt.cod_dtip IS NULL\n" +
|
||||||
|
" GROUP BY mtb_colr.gestione, mtb_colr.data_ord, mtb_colr.num_ord, mtb_colr.riga_ord),\n" +
|
||||||
|
" sit_ord_wms AS (SELECT mum.unt_mis,\n" +
|
||||||
|
" mum.cifre_dec,\n" +
|
||||||
|
" dtb_ordr.gestione,\n" +
|
||||||
|
" dtb_ordr.data_ord,\n" +
|
||||||
|
" dtb_ordr.num_ord,\n" +
|
||||||
|
" dtb_ordt.rif_ord,\n" +
|
||||||
|
" dtb_ordr.partita_mag,\n" +
|
||||||
|
" CASE dtb_ordr.gestione WHEN 'A' THEN '1' WHEN 'L' THEN '2' WHEN 'V' THEN '3' END +\n" +
|
||||||
|
" REPLACE(CONVERT(VARCHAR(10), dtb_ordr.data_ord, 105), '-', '') +\n" +
|
||||||
|
" REPLICATE('0', 5 - LEN(dtb_ordr.num_ord)) +\n" +
|
||||||
|
" CONVERT(VARCHAR(6), dtb_ordr.num_ord) AS chiave_ordine,\n" +
|
||||||
|
" dtb_ordr.unt_ord,\n" +
|
||||||
|
" dtb_ordr.cod_alis,\n" +
|
||||||
|
" dtb_ordr.cod_art_for,\n" +
|
||||||
|
" dtb_ordr.riga_ord,\n" +
|
||||||
|
" dtb_ordr.qta_ord,\n" +
|
||||||
|
" dtb_ordr.qta_cnf * dtb_ordr.rap_conv AS qta_cnf,\n" +
|
||||||
|
" dtb_ordr.descrizione,\n" +
|
||||||
|
" dtb_ordr.descrizione_estesa,\n" +
|
||||||
|
" ISNULL(SUM(mtb_colr.qta_col), 0) AS qta_col,\n" +
|
||||||
|
" CONVERT(DECIMAL(20, 5), ROUND(ISNULL(SUM(mtb_colr.cnf_col), 0), 2)) AS cnf_col,\n" +
|
||||||
|
" dtb_ordr.qta_evasa,\n" +
|
||||||
|
" SUM(dtb_ordr.qta_ord * dtb_ordr.val_unt * (1 - sconto1 / 100) * (1 - sconto2 / 100) *\n" +
|
||||||
|
" (1 - sconto3 / 100) * (1 - sconto4 / 100) * (1 - sconto5 / 100) * (1 - sconto6 / 100) *\n" +
|
||||||
|
" (1 - sconto7 / 100) * (1 - sconto8 / 100)) AS importorigaord,\n" +
|
||||||
|
" SUM(CASE\n" +
|
||||||
|
" WHEN (dtb_ordr.qta_ord > dtb_ordr.qta_evasa) AND dtb_ordr.flag_evaso = 'I' THEN\n" +
|
||||||
|
" (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) * dtb_ordr.val_unt *\n" +
|
||||||
|
" (1 - sconto1 / 100) * (1 - sconto2 / 100) * (1 - sconto3 / 100) *\n" +
|
||||||
|
" (1 - sconto4 / 100) * (1 - sconto5 / 100) * (1 - sconto6 / 100) *\n" +
|
||||||
|
" (1 - sconto7 / 100) * (1 - sconto8 / 100)\n" +
|
||||||
|
" ELSE 0 END) AS importoinevaso,\n" +
|
||||||
|
" SUM(CASE\n" +
|
||||||
|
" WHEN (dtb_ordr.qta_ord > dtb_ordr.qta_evasa) AND dtb_ordr.flag_evaso = 'I' THEN\n" +
|
||||||
|
" (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) * dtb_ordr.val_unt *\n" +
|
||||||
|
" (1 + gtb_aliq.perc_aliq / 100) * (1 - sconto1 / 100) * (1 - sconto2 / 100) *\n" +
|
||||||
|
" (1 - sconto3 / 100) * (1 - sconto4 / 100) * (1 - sconto5 / 100) *\n" +
|
||||||
|
" (1 - sconto6 / 100) * (1 - sconto7 / 100) * (1 - sconto8 / 100)\n" +
|
||||||
|
" ELSE 0 END) AS importoinevasoivato,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN ((dtb_ordr.qta_ord * rap_conv) - ISNULL(SUM(mtb_colr.qta_col), 0) -\n" +
|
||||||
|
" dtb_ordr.qta_evasa * rap_conv) > 0 THEN (dtb_ordr.qta_ord * rap_conv -\n" +
|
||||||
|
" ISNULL(SUM(mtb_colr.qta_col), 0) -\n" +
|
||||||
|
" dtb_ordr.qta_evasa * rap_conv)\n" +
|
||||||
|
" ELSE 0 END AS qta_da_evadere,\n" +
|
||||||
|
" dtb_ordr.num_cnf,\n" +
|
||||||
|
" dtb_ordr.num_cnf_evasa AS num_cnf_evase,\n" +
|
||||||
|
" ISNULL(SUM(mtb_colr.num_cnf), 0) AS num_cnf_col,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa - ISNULL(SUM(mtb_colr.num_cnf), 0) > 0\n" +
|
||||||
|
" THEN dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa - ISNULL(SUM(mtb_colr.num_cnf), 0)\n" +
|
||||||
|
" ELSE 0 END AS num_cnf_da_evadere,\n" +
|
||||||
|
" SUM(mvw_art_depo_disp.qta_disp_xpick) AS qta_disp,\n" +
|
||||||
|
" SUM(mvw_art_depo_disp.num_disp_xpick) AS cnf_disp,\n" +
|
||||||
|
" dtb_ordr.cod_jcom,\n" +
|
||||||
|
" dtb_ordr.cod_mart,\n" +
|
||||||
|
" dtb_ordr.cod_col,\n" +
|
||||||
|
" dtb_ordr.cod_tagl,\n" +
|
||||||
|
" ISNULL(vtb_viaggi.data_ora_iniz_trasp, dtb_ordr.data_cons) AS data_cons,\n" +
|
||||||
|
" dtb_ordr.flag_evaso,\n" +
|
||||||
|
" dtb_ordr.id_viaggio,\n" +
|
||||||
|
" SUM(CASE\n" +
|
||||||
|
" WHEN sconto5 = 100 OR sconto6 = 100 OR sconto7 = 100 OR sconto8 = 100 THEN qta_ord\n" +
|
||||||
|
" ELSE 0 END) AS qta_omg\n" +
|
||||||
|
" FROM dtb_ordt,\n" +
|
||||||
|
" dtb_ordr\n" +
|
||||||
|
" LEFT OUTER JOIN custom_mtb_colr mtb_colr ON dtb_ordr.gestione = mtb_colr.gestione AND\n" +
|
||||||
|
" dtb_ordr.data_ord = mtb_colr.data_ord AND\n" +
|
||||||
|
" dtb_ordr.num_ord = mtb_colr.num_ord AND\n" +
|
||||||
|
" dtb_ordr.riga_ord = mtb_colr.riga_ord\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_viaggi ON dtb_ordr.id_viaggio = vtb_viaggi.id_viaggio\n" +
|
||||||
|
" LEFT OUTER JOIN mvw_art_depo_disp ON dtb_ordr.cod_mdep = mvw_art_depo_disp.cod_mdep AND\n" +
|
||||||
|
" dtb_ordr.cod_mart = mvw_art_depo_disp.cod_mart\n" +
|
||||||
|
" LEFT OUTER JOIN gtb_aliq ON dtb_ordr.cod_aliq = gtb_aliq.cod_aliq\n" +
|
||||||
|
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" INNER JOIN mtb_unt_mis mum ON mtb_aart.unt_mis = mum.unt_mis\n" +
|
||||||
|
" LEFT OUTER JOIN mvw_articoli_esclusi_wms\n" +
|
||||||
|
" ON dtb_ordr.cod_mart = mvw_articoli_esclusi_wms.cod_mart AND\n" +
|
||||||
|
" dtb_ordr.cod_mdep = mvw_articoli_esclusi_wms.cod_mdep AND\n" +
|
||||||
|
" mvw_articoli_esclusi_wms.flag_escludi_ven = 1\n" +
|
||||||
|
" WHERE 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" +
|
||||||
|
" AND dtb_ordt.flag_annulla = 'N'\n" +
|
||||||
|
" AND mvw_articoli_esclusi_wms.cod_mart IS NULL\n" +
|
||||||
|
" GROUP BY dtb_ordr.gestione, dtb_ordr.data_ord, dtb_ordr.num_ord, dtb_ordt.rif_ord,\n" +
|
||||||
|
" dtb_ordr.riga_ord, dtb_ordr.unt_ord, dtb_ordr.cod_alis, dtb_ordr.cod_art_for,\n" +
|
||||||
|
" dtb_ordr.riga_ord, dtb_ordr.qta_ord, dtb_ordr.partita_mag, dtb_ordr.descrizione,\n" +
|
||||||
|
" dtb_ordr.descrizione_estesa, dtb_ordr.qta_ord, dtb_ordr.qta_evasa, dtb_ordr.rap_conv,\n" +
|
||||||
|
" dtb_ordr.num_cnf, dtb_ordr.qta_cnf, dtb_ordr.cod_jcom, dtb_ordr.cod_mart,\n" +
|
||||||
|
" dtb_ordr.cod_col, dtb_ordr.cod_tagl, dtb_ordr.data_cons, dtb_ordr.flag_evaso,\n" +
|
||||||
|
" dtb_ordr.num_cnf_evasa, vtb_viaggi.data_ora_iniz_trasp, mtb_colr.gestione,\n" +
|
||||||
|
" dtb_ordr.id_viaggio, mum.unt_mis, mum.cifre_dec)\n" +
|
||||||
|
"SELECT gestione,\n" +
|
||||||
|
" data_ord,\n" +
|
||||||
|
" num_ord,\n" +
|
||||||
|
" rif_ord,\n" +
|
||||||
|
" partita_mag,\n" +
|
||||||
|
" chiave_ordine,\n" +
|
||||||
|
" unt_ord,\n" +
|
||||||
|
" cod_alis,\n" +
|
||||||
|
" cod_art_for,\n" +
|
||||||
|
" riga_ord,\n" +
|
||||||
|
" ROUND(qta_ord, cifre_dec) AS qta_ord,\n" +
|
||||||
|
" qta_cnf,\n" +
|
||||||
|
" descrizione,\n" +
|
||||||
|
" descrizione_estesa,\n" +
|
||||||
|
" qta_col,\n" +
|
||||||
|
" cnf_col,\n" +
|
||||||
|
" qta_evasa,\n" +
|
||||||
|
" importorigaord,\n" +
|
||||||
|
" importoinevaso,\n" +
|
||||||
|
" importoinevasoivato,\n" +
|
||||||
|
" qta_da_evadere,\n" +
|
||||||
|
" num_cnf,\n" +
|
||||||
|
" num_cnf_evase,\n" +
|
||||||
|
" num_cnf_col,\n" +
|
||||||
|
" num_cnf_da_evadere,\n" +
|
||||||
|
" qta_disp,\n" +
|
||||||
|
" cnf_disp,\n" +
|
||||||
|
" cod_jcom,\n" +
|
||||||
|
" cod_mart,\n" +
|
||||||
|
" cod_col,\n" +
|
||||||
|
" cod_tagl,\n" +
|
||||||
|
" data_cons,\n" +
|
||||||
|
" flag_evaso,\n" +
|
||||||
|
" id_viaggio,\n" +
|
||||||
|
" qta_omg\n" +
|
||||||
|
"FROM sit_ord_wms");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20250318135249 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||||
|
createSetup("DTB_DOCT", "FATTURA_PEDANE", "ATTIVA", "N",
|
||||||
|
"attivare la procedura", false, "SI_NO", false, false,
|
||||||
|
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||||
|
|
||||||
|
if (isCustomer(IntegryCustomer.RossoGargano)){
|
||||||
|
updateSetupValue("DTB_DOCT", "FATTURA_PEDANE", "ATTIVA", "S");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
package it.integry.ems.migration.service;
|
package it.integry.ems.migration.service;
|
||||||
|
|
||||||
import it.integry.ems.javabeans.RequestDataDTO;
|
|
||||||
import it.integry.ems.migration.MigrationComponent;
|
import it.integry.ems.migration.MigrationComponent;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
import it.integry.ems.migration.dto.MigrationStatusDTO;
|
import it.integry.ems.migration.dto.MigrationStatusDTO;
|
||||||
import it.integry.ems.migration.dto.MigrationStatusEnum;
|
import it.integry.ems.migration.dto.MigrationStatusEnum;
|
||||||
import it.integry.ems.service.EntityProcessor;
|
import it.integry.ems.service.EntityProcessor;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
@@ -21,7 +23,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Scope("request")
|
@Scope("request")
|
||||||
@@ -39,7 +40,7 @@ public class MigrationSetupService {
|
|||||||
private EntityProcessor entityProcessor;
|
private EntityProcessor entityProcessor;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RequestDataDTO requestDataDTO;
|
private SettingsController settingsController;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MultiDBTransactionManager multiDBTransactionManager;
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
@@ -49,16 +50,15 @@ public class MigrationSetupService {
|
|||||||
|
|
||||||
final List<MigrationStatusDTO> migrationStatuses = new ArrayList<>();
|
final List<MigrationStatusDTO> migrationStatuses = new ArrayList<>();
|
||||||
|
|
||||||
final List<AvailableConnectionsModel> databases = settingsModel.getAvailableConnections().stream()
|
String historyProfileDb = settingsController.getHistoryProfileDb();
|
||||||
.filter(AvailableConnectionsModel::getInternalDb)
|
final List<AvailableConnectionsModel> databases = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true, historyProfileDb);
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
for (AvailableConnectionsModel availableConnectionsModel : databases) {
|
for (AvailableConnectionsModel availableConnectionsModel : databases) {
|
||||||
if (availableConnectionsModel.getDbName().equalsIgnoreCase("studioml") && UtilityDebug.isDebugExecution())
|
if (IntegryCustomer.getFromDB(IntegryCustomerDB.parse(availableConnectionsModel.getDbName())) == IntegryCustomer.Integry &&
|
||||||
|
UtilityDebug.isDebugExecution())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(availableConnectionsModel)) {
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(availableConnectionsModel)) {
|
||||||
|
|
||||||
List<StbMigrationStatus> stbMigrationStatuses = retrieveStatuses(multiDBTransactionManager);
|
List<StbMigrationStatus> stbMigrationStatuses = retrieveStatuses(multiDBTransactionManager);
|
||||||
|
|
||||||
if (stbMigrationStatuses == null) {
|
if (stbMigrationStatuses == null) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
@Component
|
@Component
|
||||||
public class BasicConnectionPool {
|
public class BasicConnectionPool {
|
||||||
private static final Logger logger = LogManager.getLogger(BasicConnectionPool.class);
|
private static final Logger logger = LogManager.getLogger(BasicConnectionPool.class);
|
||||||
|
private final String ExtraConnectionNamePrefix = "EMS Extra Connection #";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SettingsModel settingsModel;
|
private SettingsModel settingsModel;
|
||||||
@@ -186,7 +187,7 @@ public class BasicConnectionPool {
|
|||||||
int baseCount = connectionPool.get(dbName).size() + usedConnections.get(dbName).size();
|
int baseCount = connectionPool.get(dbName).size() + usedConnections.get(dbName).size();
|
||||||
int extraCount = extraConnectionCounters.get(dbName).incrementAndGet();
|
int extraCount = extraConnectionCounters.get(dbName).incrementAndGet();
|
||||||
|
|
||||||
String connectionName = "EMS Extra Connection #" + (baseCount + extraCount);
|
String connectionName = ExtraConnectionNamePrefix + (baseCount + extraCount);
|
||||||
|
|
||||||
// Verifica se la connessione esiste già
|
// Verifica se la connessione esiste già
|
||||||
if (activeConnectionNames.get(dbName).contains(connectionName)) {
|
if (activeConnectionNames.get(dbName).contains(connectionName)) {
|
||||||
@@ -227,9 +228,10 @@ public class BasicConnectionPool {
|
|||||||
String connectionName = ds.getApplicationName();
|
String connectionName = ds.getApplicationName();
|
||||||
String dbName = ds.getDbName();
|
String dbName = ds.getDbName();
|
||||||
|
|
||||||
if (connectionName.startsWith("EMS Extra Connection #")) {
|
if (connectionName.startsWith(ExtraConnectionNamePrefix)) {
|
||||||
activeConnectionNames.get(dbName).remove(connectionName);
|
activeConnectionNames.get(dbName).remove(connectionName);
|
||||||
ds.forceClose();
|
ds.forceClose();
|
||||||
|
tryResetExtraConnectionsCounter(ds);
|
||||||
logger.trace("Closed extra connection: {} for database: {}", connectionName, dbName);
|
logger.trace("Closed extra connection: {} for database: {}", connectionName, dbName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -239,4 +241,12 @@ public class BasicConnectionPool {
|
|||||||
logger.trace("Released connection: {} for database: {}", connectionName, dbName);
|
logger.trace("Released connection: {} for database: {}", connectionName, dbName);
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tryResetExtraConnectionsCounter(DataSource ds) {
|
||||||
|
String dbName = ds.getDbName();
|
||||||
|
boolean otherExtraConnectionsOpened = activeConnectionNames.get(dbName).stream().anyMatch(x -> x.startsWith(ExtraConnectionNamePrefix));
|
||||||
|
|
||||||
|
if(!otherExtraConnectionsOpened)
|
||||||
|
extraConnectionCounters.get(dbName).set(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -85,6 +85,8 @@ public class UserService {
|
|||||||
entityProcessor.processEntity(stbUser, multiDBTransactionManager);
|
entityProcessor.processEntity(stbUser, multiDBTransactionManager);
|
||||||
|
|
||||||
UtilityEntity.throwEntityException(stbUser);
|
UtilityEntity.throwEntityException(stbUser);
|
||||||
|
|
||||||
|
userCacheService.invalidateCache();
|
||||||
return stbUser;
|
return stbUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -749,7 +749,7 @@ public class ContabilService {
|
|||||||
.setDataDist(datiMov.getDataDist())
|
.setDataDist(datiMov.getDataDist())
|
||||||
.setRifDist(datiMov.getRifDist())
|
.setRifDist(datiMov.getRifDist())
|
||||||
.setNumCmov(ctbMovt.getNumCmov());
|
.setNumCmov(ctbMovt.getNumCmov());
|
||||||
distinta.setOperation(OperationType.UPDATE);
|
vtbDist.setOperation(OperationType.UPDATE);
|
||||||
entityProcessor.processEntity(vtbDist, multiDBTransactionManager);
|
entityProcessor.processEntity(vtbDist, multiDBTransactionManager);
|
||||||
}
|
}
|
||||||
return ctbMovt;
|
return ctbMovt;
|
||||||
|
|||||||
@@ -57,9 +57,11 @@ public class DocumentiDirettiService {
|
|||||||
if (!UtilityHashMap.isPresent(datiTipoDoc))
|
if (!UtilityHashMap.isPresent(datiTipoDoc))
|
||||||
throw new Exception(String.format("Tipo Documento %s inesistente", dtbDoct.getCodDtip()));
|
throw new Exception(String.format("Tipo Documento %s inesistente", dtbDoct.getCodDtip()));
|
||||||
|
|
||||||
|
boolean salvaImballiAttiva = setupGest.getSetupBoolean("DTB_DOCT", "FATTURA_PEDANE", "ATTIVA");
|
||||||
|
|
||||||
if (UtilityHashMap.<String>getValueIfExists(datiTipoDoc, "gestione").equalsIgnoreCase("V") &&
|
if (UtilityHashMap.<String>getValueIfExists(datiTipoDoc, "gestione").equalsIgnoreCase("V") &&
|
||||||
TipoEmissione.valueOf(UtilityHashMap.getValueIfExists(datiTipoDoc, "tipo_emissione")) == TipoEmissione.DIRETTA &&
|
TipoEmissione.valueOf(UtilityHashMap.getValueIfExists(datiTipoDoc, "tipo_emissione")) == TipoEmissione.DIRETTA &&
|
||||||
!dtbDoct.getDtbDocImb().isEmpty()) {
|
!dtbDoct.getDtbDocImb().isEmpty() && salvaImballiAttiva) {
|
||||||
saveDocImballi(dtbDoct, entityList, isInsert);
|
saveDocImballi(dtbDoct, entityList, isInsert);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,17 @@ import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchem
|
|||||||
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTable;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTable;
|
||||||
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTableView;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTableView;
|
||||||
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseView;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseView;
|
||||||
import it.integry.ems.expansion.RunnableThrowable;
|
|
||||||
import it.integry.ems.export.base.EntityExporterUtility;
|
import it.integry.ems.export.base.EntityExporterUtility;
|
||||||
import it.integry.ems.export.enums.EntityExportType;
|
import it.integry.ems.export.enums.EntityExportType;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.system.Import.AnagraficaImporter;
|
import it.integry.ems.system.Import.AnagraficaImporter;
|
||||||
import it.integry.ems.system.export.AnagraficaExporter;
|
import it.integry.ems.system.export.AnagraficaExporter;
|
||||||
import it.integry.ems.system.export.RisorseUmaneExporter;
|
import it.integry.ems.system.export.RisorseUmaneExporter;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems.task.TaskExecutorService;
|
||||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
import it.integry.ems_model.utility.UtilityThread;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -27,7 +26,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -37,9 +36,15 @@ public class EmsSystemContext {
|
|||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SettingsController settingsController;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SettingsModel settingsModel;
|
private SettingsModel settingsModel;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TaskExecutorService taskExecutorService;
|
||||||
|
|
||||||
@PostContextConstruct
|
@PostContextConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
logger.debug("Init");
|
logger.debug("Init");
|
||||||
@@ -49,11 +54,10 @@ public class EmsSystemContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 0 * * *", zone = "Europe/Rome")
|
@Scheduled(cron = "0 0 0 * * *", zone = "Europe/Rome")
|
||||||
private void cleanTempTablesAndViews() {
|
private void cleanTempTablesAndViews() throws Exception {
|
||||||
|
|
||||||
final List<AvailableConnectionsModel> availableDatabases = settingsModel.getAvailableConnections().stream()
|
String historyProfile = settingsController.getHistoryProfileDb();
|
||||||
.filter(AvailableConnectionsModel::getInternalDb)
|
final List<AvailableConnectionsModel> availableDatabases = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true, historyProfile);
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
|
|
||||||
Pattern pattern1 = Pattern.compile("(t[0-9])\\w+", Pattern.CASE_INSENSITIVE);
|
Pattern pattern1 = Pattern.compile("(t[0-9])\\w+", Pattern.CASE_INSENSITIVE);
|
||||||
@@ -64,10 +68,10 @@ public class EmsSystemContext {
|
|||||||
pattern2.matcher(x.getTableName()).matches() ||
|
pattern2.matcher(x.getTableName()).matches() ||
|
||||||
pattern3.matcher(x.getTableName()).matches();
|
pattern3.matcher(x.getTableName()).matches();
|
||||||
|
|
||||||
List<RunnableThrowable> calls = new ArrayList<>();
|
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
||||||
|
|
||||||
for (AvailableConnectionsModel availableDatabase : availableDatabases) {
|
for (final AvailableConnectionsModel availableDatabase : availableDatabases) {
|
||||||
calls.add(() -> {
|
futureTasks.add(() -> {
|
||||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(availableDatabase)) {
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(availableDatabase)) {
|
||||||
|
|
||||||
logger.info(String.format("[%s] Running clean temp tables and views", availableDatabase.getProfileName()));
|
logger.info(String.format("[%s] Running clean temp tables and views", availableDatabase.getProfileName()));
|
||||||
@@ -77,18 +81,12 @@ public class EmsSystemContext {
|
|||||||
cleanTables(schemaManager, deletionPredicate);
|
cleanTables(schemaManager, deletionPredicate);
|
||||||
cleanViews(schemaManager, deletionPredicate);
|
cleanViews(schemaManager, deletionPredicate);
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
taskExecutorService.executeTasks(futureTasks);
|
||||||
UtilityThread.executeParallel(calls);
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanTables(SQLServerDBSchemaManager schemaManager, Predicate<DatabaseTableView> deletePredicate) throws Exception {
|
private void cleanTables(SQLServerDBSchemaManager schemaManager, Predicate<DatabaseTableView> deletePredicate) throws Exception {
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ public class SystemController {
|
|||||||
stbActivitiesToUpdate.forEach
|
stbActivitiesToUpdate.forEach
|
||||||
(x -> {
|
(x -> {
|
||||||
x.setActivityResultId(activityResultId);
|
x.setActivityResultId(activityResultId);
|
||||||
|
x.setActivityDescription(null);
|
||||||
x.setOperation(OperationType.UPDATE);
|
x.setOperation(OperationType.UPDATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user