Migliorato log errore in exchange fornitori

This commit is contained in:
2024-12-16 17:00:27 +01:00
parent c6f85fe920
commit 1b64a2f745
2 changed files with 58 additions and 52 deletions

View File

@@ -333,56 +333,56 @@ public class Migration_20241213163759 extends BaseMigration implements Migration
executeStatement(Query.format( executeStatement(Query.format(
"INSERT INTO mtb_colr (gestione, ser_collo, num_collo, data_collo, riga, cod_mart, cod_col, cod_tagl, partita_mag, gestione_rif, data_collo_rif, ser_collo_rif, num_collo_rif, datetime_row,\n" + "INSERT INTO mtb_colr (gestione, ser_collo, num_collo, data_collo, riga, cod_mart, cod_col, cod_tagl, partita_mag, gestione_rif, data_collo_rif, ser_collo_rif, num_collo_rif, datetime_row,\n" +
" cod_jcom, qta_col, num_cnf, qta_cnf)" + " cod_jcom, qta_col, num_cnf, qta_cnf)" +
" SELECT {} AS gestione,\n" + " SELECT {} AS gestione,\n" +
" {} AS ser_collo,\n" + " {} AS ser_collo,\n" +
" {} AS num_collo,\n" + " {} AS num_collo,\n" +
" CAST({} AS DATE) AS data_collo,\n" + " CAST({} AS DATE) AS data_collo,\n" +
" ROW_NUMBER() OVER (PARTITION BY (SELECT NULL) ORDER BY v.data_collo) AS riga,\n" + " ROW_NUMBER() OVER (PARTITION BY (SELECT NULL) ORDER BY v.data_collo) AS riga,\n" +
" v.cod_mart,\n" + " v.cod_mart,\n" +
" v.cod_col,\n" + " v.cod_col,\n" +
" v.cod_tagl,\n" + " v.cod_tagl,\n" +
" v.partita_mag,\n" + " v.partita_mag,\n" +
" v.gestione AS gestion_rif,\n" + " v.gestione AS gestion_rif,\n" +
" v.data_collo AS data_collo_rif,\n" + " v.data_collo AS data_collo_rif,\n" +
" v.ser_collo AS ser_collo_rif,\n" + " v.ser_collo AS ser_collo_rif,\n" +
" v.num_collo AS num_collo_rif,\n" + " v.num_collo AS num_collo_rif,\n" +
" GETDATE() AS datetime_row,\n" + " GETDATE() AS datetime_row,\n" +
" v.cod_jcom,\n" + " v.cod_jcom,\n" +
" v.qta_col,\n" + " v.qta_col,\n" +
" v.num_cnf,\n" + " v.num_cnf,\n" +
" v.qta_cnf\n" + " v.qta_cnf\n" +
"FROM mvw_sitart_udc_det_inventario v\n" + "FROM mvw_sitart_udc_det_inventario v\n" +
" INNER JOIN (SELECT ser_collo,\n" + " INNER JOIN (SELECT ser_collo,\n" +
" gestione,\n" + " gestione,\n" +
" data_collo,\n" + " data_collo,\n" +
" num_collo,\n" + " num_collo,\n" +
" cod_mdep,\n" + " cod_mdep,\n" +
" posizione,\n" + " posizione,\n" +
" cod_mart,\n" + " cod_mart,\n" +
" partita_mag,\n" + " partita_mag,\n" +
" cod_jcom-- Elenca tutte le colonne coinvolte\n" + " cod_jcom-- Elenca tutte le colonne coinvolte\n" +
" FROM mvw_sitart_udc_det_inventario\n" + " FROM mvw_sitart_udc_det_inventario\n" +
"\n" + "\n" +
" EXCEPT\n" + " EXCEPT\n" +
"\n" + "\n" +
" SELECT ser_collo,\n" + " SELECT ser_collo,\n" +
" gestione,\n" + " gestione,\n" +
" data_collo,\n" + " data_collo,\n" +
" num_collo,\n" + " num_collo,\n" +
" cod_mdep,\n" + " cod_mdep,\n" +
" posizione,\n" + " posizione,\n" +
" cod_mart,\n" + " cod_mart,\n" +
" partita_mag,\n" + " partita_mag,\n" +
" cod_jcom -- Elenca le stesse colonne dalla vista vecchia\n" + " cod_jcom -- Elenca le stesse colonne dalla vista vecchia\n" +
" FROM mvw_sitart_udc_det_inventario_old) t\n" + " FROM mvw_sitart_udc_det_inventario_old) t\n" +
" ON v.num_collo = t.num_collo AND v.data_collo = t.data_collo AND\n" + " ON v.num_collo = t.num_collo AND v.data_collo = t.data_collo AND\n" +
" v.ser_collo = t.ser_collo AND v.gestione = t.gestione AND\n" + " v.ser_collo = t.ser_collo AND v.gestione = t.gestione AND\n" +
" v.cod_mart = t.cod_mart AND v.cod_mdep = t.cod_mdep AND\n" + " v.cod_mart = t.cod_mart AND v.cod_mdep = t.cod_mdep AND\n" +
" ISNULL(v.partita_mag, '') = ISNULL(t.partita_mag, '') AND\n" + " ISNULL(v.partita_mag, '') = ISNULL(t.partita_mag, '') AND\n" +
" ISNULL(v.posizione, '') = ISNULL(t.posizione, '') AND\n" + " ISNULL(v.posizione, '') = ISNULL(t.posizione, '') AND\n" +
" ISNULL(v.cod_jcom, '') = ISNULL(t.cod_jcom, '')", " ISNULL(v.cod_jcom, '') = ISNULL(t.cod_jcom, '')",
mtbColt.getGestione(), mtbColt.getSerCollo(), mtbColt.getNumCollo(), mtbColt.getDataCollo())); mtbColt.getGestione(), mtbColt.getSerCollo(), mtbColt.getNumCollo(), mtbColt.getDataCollo()));

View File

@@ -9,6 +9,7 @@ import it.integry.ems.system.exchange.service.structure.ExchangeImportSchemaMana
import it.integry.ems_model.base.EquatableEntityInterface; import it.integry.ems_model.base.EquatableEntityInterface;
import it.integry.ems_model.entity.AtbForn; import it.integry.ems_model.entity.AtbForn;
import it.integry.ems_model.entity.GtbAnag; import it.integry.ems_model.entity.GtbAnag;
import it.integry.ems_model.exception.EntityException;
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;
@@ -74,10 +75,15 @@ public class ExchangeFornitoriImportService {
internalMultiDb.commitAll(); internalMultiDb.commitAll();
exchangeMultiDb.commitAll(); exchangeMultiDb.commitAll();
} catch (Exception ex) { } catch (Exception ex) {
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = ex;
logger.error("Errore durante l'importazione del fornitore", ex);
internalMultiDb.rollbackAll(); internalMultiDb.rollbackAll();
exchangeMultiDb.commitAll();
GtbAnag gtbAnagError = (GtbAnag) dataToSave;
Exception newException = new EntityException("Errore durante l'importazione del fornitore [" +
"cod_anag: " + gtbAnagError.getCodAnag() + "]", ex);
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = newException;
logger.error(newException);
} }
} }