diff --git a/gnpapp/properties/delta_RU_XXX_resources.properties b/gnpapp/properties/delta_RU_XXX_resources.properties index 2a960dd3..b6097f58 100644 --- a/gnpapp/properties/delta_RU_XXX_resources.properties +++ b/gnpapp/properties/delta_RU_XXX_resources.properties @@ -12,7 +12,7 @@ DWHE2E_REPOSALDINETTI_BUS_BACKUP_IN=/gnpapp/batch/backup_in/dwhe2e_saldinetti_bu DWHE2E_REPOSALDINETTI_NOME_FILE_CON_OUT =DBCFX_DWHE2E_USCITE_CON_ DWHE2E_REPOSALDINETTI_NOME_FILE_BUS_OUT =DBCFX_DWHE2E_USCITE_BUS_ DWHE2E_REPOSALDINETTI_FILENAME_EXT=.csv -DWHE2E_REPOSALDINETTI_DATA_FILENAME="yyyyMMdd" +DWHE2E_REPOSALDINETTI_DATA_FILENAME=yyyyMMdd #PATH OUT DWHE2E_REPOSALDINETTI PATH_FILE_DWHE2E_REPOSALDINETTI_CON_OUT =/gnpapp/batch/ftpout/dwhe2e_saldinetti_con/ diff --git a/gnpdev/build/hibernate/hibernateOTHER.reveng.xml b/gnpdev/build/hibernate/hibernateOTHER.reveng.xml index c951af54..28642746 100644 --- a/gnpdev/build/hibernate/hibernateOTHER.reveng.xml +++ b/gnpdev/build/hibernate/hibernateOTHER.reveng.xml @@ -1364,7 +1364,7 @@ - SEQ_DWE2EREPORT + SEQ_DWHE2EREPORT
@@ -1372,7 +1372,7 @@ - SEQ_DWE2EREPORT + SEQ_DWHE2EREPORT
diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldiNettiIn.hbm.xml b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldiNettiIn.hbm.xml index bf9253f2..1fe1d4c6 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldiNettiIn.hbm.xml +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldiNettiIn.hbm.xml @@ -7,7 +7,7 @@ - SEQ_DWE2EREPORT + SEQ_DWHE2EREPORT diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldiNettiOut.hbm.xml b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldiNettiOut.hbm.xml index f7caca6e..27b4f83b 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldiNettiOut.hbm.xml +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldiNettiOut.hbm.xml @@ -7,7 +7,7 @@ - SEQ_DWE2EREPORT + SEQ_DWHE2EREPORT diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiInDAO.java b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiInDAO.java index 7cd4620a..bc6c58be 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiInDAO.java +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiInDAO.java @@ -5,7 +5,7 @@ package it.valueteam.gnp.dao.db.hb; import java.util.List; -import it.valueteam.gnpgo.core.object.GnpgoSemaforoSummary; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.LockMode; @@ -203,7 +203,7 @@ public class GnpDwhe2eSaldinettiInDAO extends BaseHibernateDAO{ "saldinettiin.dbcfxDimCodiceOlo, " + "saldinettiin.dbcfxDimTipoUscita, " + "saldinettiin.dbcfxDimDelibera, " + - "count(*) as dbcfxNroUscite" + + "count(saldinettiin.idRichiesta) " + ") " + "from GnpDwhe2eSaldinettiIn saldinettiin " + "where saldinettiin.nomeFile = :nomeFileParam " + @@ -222,6 +222,7 @@ public class GnpDwhe2eSaldinettiInDAO extends BaseHibernateDAO{ "saldinettiin.dbcfxDimDelibera"; try{ + System.out.println(" GnpDwhe2eSaldinettiInDAO.java groupBy = " + query); Query hqlQuery = getSession().createQuery(query) .setParameter("nomeFileParam", nomeFileParam); return hqlQuery.list(); diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiOut.java b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiOut.java index 6d3aa859..bff66f3a 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiOut.java +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiOut.java @@ -50,6 +50,7 @@ public class GnpDwhe2eSaldinettiOut implements java.io.Serializable { //quando effettuo la group dalla IN setto il default flagElaborato ad "N" public GnpDwhe2eSaldinettiOut(String nomeFile, String crm, Date e2eDataCessazione, String e2eServizioAccesso, String e2eDimensione1, String e2eDimensione2, String e2eDimensione3, String e2eDimensione4, String e2eDimensione5, String dbcfxDimCodiceOlo, String dbcfxDimTipoUscita, String dbcfxDimDelibera, Long dbcfxNroUscite) { this.nomeFile = nomeFile; + this.flagElaborato = "N"; this.crm = crm; this.e2eDataCessazione = e2eDataCessazione; this.e2eServizioAccesso = e2eServizioAccesso; @@ -62,7 +63,6 @@ public class GnpDwhe2eSaldinettiOut implements java.io.Serializable { this.dbcfxDimTipoUscita = dbcfxDimTipoUscita; this.dbcfxDimDelibera = dbcfxDimDelibera; this.dbcfxNroUscite = dbcfxNroUscite; - this.flagElaborato = "N"; } public Long getUniqueId() { diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiOutDAO.java b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiOutDAO.java index 97f6f1e5..7fb34ec7 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiOutDAO.java +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/dao/db/hb/GnpDwhe2eSaldinettiOutDAO.java @@ -26,7 +26,7 @@ public class GnpDwhe2eSaldinettiOutDAO extends BaseHibernateDAO{ - private static final String QUERY_UPDATE_FLAG_LAVORATO = "UPDATE GNP_DWHE2E_SALDINETTI_OUT D SET D.FLAG_LAVORATO = :flagLavorato WHERE D.NOME_FILE = :nomeFile "; + private static final String QUERY_UPDATE_FLAG_LAVORATO = "UPDATE GNP_DWHE2E_SALDINETTI_OUT D SET D.FLAG_ELABORATO = :flagElaborato WHERE D.NOME_FILE = :nomeFile "; diff --git a/gnpdev/dbcfx/src/it/valueteam/gnp/internalflow/in/Dwhe2eRepoSaldiNettiIn.java b/gnpdev/dbcfx/src/it/valueteam/gnp/internalflow/in/Dwhe2eRepoSaldiNettiIn.java index d46476ee..ec03ee0e 100644 --- a/gnpdev/dbcfx/src/it/valueteam/gnp/internalflow/in/Dwhe2eRepoSaldiNettiIn.java +++ b/gnpdev/dbcfx/src/it/valueteam/gnp/internalflow/in/Dwhe2eRepoSaldiNettiIn.java @@ -9,12 +9,14 @@ import it.valueteam.gnp.obj.LogInfo; import it.valueteam.gnp.obj.LogProcess; import it.valueteam.gnp.utility.DateUtils; import it.valueteam.gnp.utility.Resources; -import it.valueteam.gnpgo.core.object.GnpgoSemaforoSummary; +import it.valueteam.gnp.utility.UserTransactionUtility; + +import javax.transaction.UserTransaction; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.text.SimpleDateFormat; + import java.util.*; public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Loggable, ProcessIF { @@ -84,15 +86,18 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log //leggo i file da cartella CO List listFileName = getListFileName(Resources.getPATH_FILE_DWHE2E_REPOSALDINETTI_CON_IN()); readFilesAndStore(listFileName); - //per ogni nome file, se .csv allora prendine il nome assoluto DWHE2E_DBCFX_USCITE_CON_aaaammgg + //per ogni nome file for(String fileName : listFileName){ String estensioneFname = fileName.substring(fileName.lastIndexOf("."),fileName.length()); if (estensioneFname.equals(Resources.getDWHE2E_REPOSALDINETTI_FILENAME_EXT())) { - //String fileNameAbsolute = fileName.substring(0,fileName.lastIndexOf(".")); - generaFileOut(generaRecordAndStoreOut(fileName), - Resources.getDWHE2E_REPOSALDINETTI_NOME_FILE_CON_OUT(), + //aggiungo a DBCFX_DWHE2E_USCITE_XXX_ + yyyymmdd.csv al nome file + String nomeFileOut = Resources.getDWHE2E_REPOSALDINETTI_NOME_FILE_CON_OUT(); + nomeFileOut += DateUtils.toString(new Date(), Resources.getDWHE2E_REPOSALDINETTI_DATA_FILENAME()) + Resources.getDWHE2E_REPOSALDINETTI_FILENAME_EXT(); + + generaFileOut(generaRecordAndStoreOut(fileName,nomeFileOut), + nomeFileOut, Resources.getPATH_FILE_DWHE2E_REPOSALDINETTI_CON_OUT(), fileName); } @@ -107,8 +112,11 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log String estensioneFname = fileName.substring(fileName.lastIndexOf("."),fileName.length()); if (estensioneFname.equals(Resources.getDWHE2E_REPOSALDINETTI_FILENAME_EXT())) { - //String fileNameAbsolute = fileName.substring(0,fileName.lastIndexOf(".")); - generaFileOut(generaRecordAndStoreOut(fileName), + //aggiungo a DBCFX_DWHE2E_USCITE_XXX_ + yyyymmdd.csv al nome file + String nomeFileOut = Resources.getDWHE2E_REPOSALDINETTI_NOME_FILE_CON_OUT(); + nomeFileOut += DateUtils.toString(new Date(), Resources.getDWHE2E_REPOSALDINETTI_DATA_FILENAME()) + Resources.getDWHE2E_REPOSALDINETTI_FILENAME_EXT(); + + generaFileOut(generaRecordAndStoreOut(fileName,nomeFileOut), Resources.getDWHE2E_REPOSALDINETTI_NOME_FILE_BUS_OUT(), Resources.getPATH_FILE_DWHE2E_REPOSALDINETTI_BUS_OUT(), fileName); @@ -167,7 +175,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log } - log.write("9999", "End readFiles"); + log.write("9999", "End readFilesAndStore"); } @@ -228,6 +236,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log private void spostaFile(String sDir, File inFile) throws Exception { + log.write("9999", "Start spostaFile"); log.write("9999","Sposto il file : " + inFile.getName()); File out = new File(sDir + inFile.getName() ); FileInputStream fis = new FileInputStream(inFile); @@ -241,6 +250,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log fis.close(); fos.close(); log.write("9999","Cancello file : " + inFile.getName()); + log.write("9999", "End spostaFile"); inFile.delete(); } @@ -255,18 +265,38 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log GnpDwhe2eSaldinettiIn gnpDwhe2eSaldinettiIn = new GnpDwhe2eSaldinettiIn(); gnpDwhe2eSaldinettiIn.setNomeFile(nomeFile); gnpDwhe2eSaldinettiIn.setCrm(piattaforma); - gnpDwhe2eSaldinettiIn.setIdRichiesta(Long.valueOf(parts[0])); - gnpDwhe2eSaldinettiIn.setLinea(parts[1]); - gnpDwhe2eSaldinettiIn.setCor(parts[2]); - gnpDwhe2eSaldinettiIn.setE2eDataCessazione(DateUtils.toDate(parts[3],DATACESSAZIONE_FORMAT)); - gnpDwhe2eSaldinettiIn.setE2eServizioAccesso(parts[4]); - gnpDwhe2eSaldinettiIn.setE2eDimensione1(parts[5]); - gnpDwhe2eSaldinettiIn.setE2eDimensione2(parts[6]); - gnpDwhe2eSaldinettiIn.setE2eDimensione3(parts[7]); - gnpDwhe2eSaldinettiIn.setE2eDimensione4(parts[8]); - gnpDwhe2eSaldinettiIn.setE2eDimensione5(parts[9]); - log.write("9999", "Oggetto creato gnpVerificaCsWhitelist = "+gnpDwhe2eSaldinettiIn.toString()); + if (0 gnpDwhe2eSaldinettiIn){ + private void aggiungiInfoAndSave(List gnpDwhe2eSaldinettiIn) throws Exception { log.write("9999", "Start aggiungiInfoAndSave"); - //instanzia le classi DAO + //istanzia le classi DAO //del.82 GnpRichiesteDonor82DAO daoRichiesteD82 = new GnpRichiesteDonor82DAO(); //del 274 @@ -287,66 +317,120 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log //DAO per storare le richieste IN GnpDwhe2eSaldinettiInDAO dwhe2eSaldinettiInDAO = new GnpDwhe2eSaldinettiInDAO(); - //effettua la ricerca nelle tabelle sfruttando ID_RICHIESTA per poi aggiorna i campi dbcfx - for(GnpDwhe2eSaldinettiIn dwhe2eItem : gnpDwhe2eSaldinettiIn ){ - // del. 82 - GnpRichiesteDonor82 gnpRichiestaDonor82 = daoRichiesteD82.findById(dwhe2eItem.getIdRichiesta()); - if(gnpRichiestaDonor82!=null){ - dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor82.getCowRecipient(),this.DEL_82_TIPOUSCITA, this.DEL_82); - dwhe2eSaldinettiInDAO.save(dwhe2eItem); - continue; - } - // del. 274 - GnpRichiesteDonor gnpRichiestaDonor274 = daoRichiesteDonor.findById(dwhe2eItem.getIdRichiesta()); - if(gnpRichiestaDonor274!=null){ - dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor274.getCowRecipient(),this.DEL_274_TIPOUSCITA, this.DEL_274); - dwhe2eSaldinettiInDAO.save(dwhe2eItem); - continue; - } - // del. 103 uscite Donor nativi olo - GnpRichiesteCsNpg103 gnpRichiesteCsNpg103NativiOlo = daoCsNpg103.findById(dwhe2eItem.getIdRichiesta()); - if(gnpRichiesteCsNpg103NativiOlo!=null){ - dwhe2eItem.popolaAggiuntiviFX(gnpRichiesteCsNpg103NativiOlo.getCodOpRecipient(),this.DEL_103_NATOLO_TIPOUSCITA, this.DEL_103); - dwhe2eSaldinettiInDAO.save(dwhe2eItem); - continue; - } - // del. 103 uscite Donor nativi olo - GnpRichiesteCsNpg103 gnpRichiesteCsNpg103StdVoip = daoCsNpg103.findById(dwhe2eItem.getIdRichiesta()); - if(gnpRichiesteCsNpg103StdVoip!=null){ - dwhe2eItem.popolaAggiuntiviFX(gnpRichiesteCsNpg103StdVoip.getCodOpRecipient(),this.DEL_103_STD_VOIP_TIPOUSCITA, this.DEL_103); - dwhe2eSaldinettiInDAO.save(dwhe2eItem); - } + UserTransaction utx; + try { + utx = UserTransactionUtility.beginUserTransaction(); + } catch (Exception e) { + log.error(e, "aggiungiInfoAndSave: beginUserTransaction"); + throw e; } + + try{ + //effettua la ricerca nelle tabelle sfruttando ID_RICHIESTA per poi aggiorna i campi dbcfx + for(GnpDwhe2eSaldinettiIn dwhe2eItem : gnpDwhe2eSaldinettiIn ){ + // del. 82 + GnpRichiesteDonor82 gnpRichiestaDonor82 = daoRichiesteD82.findById(dwhe2eItem.getIdRichiesta()); + if(gnpRichiestaDonor82!=null){ + dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor82.getCowRecipient(),this.DEL_82_TIPOUSCITA, this.DEL_82); + dwhe2eSaldinettiInDAO.save(dwhe2eItem); + continue; + } + // del. 274 + GnpRichiesteDonor gnpRichiestaDonor274 = daoRichiesteDonor.findById(dwhe2eItem.getIdRichiesta()); + if(gnpRichiestaDonor274!=null){ + dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor274.getCowRecipient(),this.DEL_274_TIPOUSCITA, this.DEL_274); + dwhe2eSaldinettiInDAO.save(dwhe2eItem); + continue; + } + // del. 103 uscite Donor nativi olo + GnpRichiesteCsNpg103 gnpRichiesteCsNpg = daoCsNpg103.findById(dwhe2eItem.getIdRichiesta()); + if(gnpRichiesteCsNpg!=null && gnpRichiesteCsNpg.getProcesso().equalsIgnoreCase("DONOR_NAT_OLO")){ + dwhe2eItem.popolaAggiuntiviFX(gnpRichiesteCsNpg.getCodOpRecipient(),this.DEL_103_NATOLO_TIPOUSCITA, this.DEL_103); + dwhe2eSaldinettiInDAO.save(dwhe2eItem); + continue; + } + // del. 103 uscite Donor nativi olo + if(gnpRichiesteCsNpg!=null && gnpRichiesteCsNpg.getProcesso().equalsIgnoreCase("CSNPg103")){ + dwhe2eItem.popolaAggiuntiviFX(gnpRichiesteCsNpg.getCodOpRecipient(),this.DEL_103_STD_VOIP_TIPOUSCITA, this.DEL_103); + dwhe2eSaldinettiInDAO.save(dwhe2eItem); + } + } + + UserTransactionUtility.endUserTransaction(utx, true); + }catch (Exception ex) { + try { + log.write("9999", "UserTransactionUtility.endUserTransaction rollback"); + // Rollback the transaction + UserTransactionUtility.endUserTransaction(utx, false); + log.error(ex, "aggiungiInfoAndSave try rollback"); + ex.printStackTrace(); + } catch (Exception e) { + log.error(e, "aggiungiInfoAndSave catch rollback"); + e.printStackTrace(); + throw e; + } + throw ex; + } + log.write("9999", "End aggiungiInfoAndSave"); } //TODO - private List generaRecordAndStoreOut(String fileName){ + private List generaRecordAndStoreOut(String fileNameIn, String fileNameOut) throws Exception { + UserTransaction utx; + try { + utx = UserTransactionUtility.beginUserTransaction(); + } catch (Exception e) { + log.error(e, "generaRecordAndStoreOut: beginUserTransaction"); + throw e; + } + + log.write("9999", "Start generaRecordAndStoreOut"); GnpDwhe2eSaldinettiOutDAO saldinettiOutDAO =new GnpDwhe2eSaldinettiOutDAO(); GnpDwhe2eSaldinettiInDAO saldinettiInDAO =new GnpDwhe2eSaldinettiInDAO(); //preleva dalla dwhe2eSaldinettiInDAO tutti i record con quel nome file facendo //group by e torna l'istanza di una list. //Il flag Lavorato ad N è settato nel costruttore quando fa il mapping HB - List listSaldinettiOut = saldinettiInDAO.groupBy(fileName); + List listSaldinettiOut = saldinettiInDAO.groupBy(fileNameIn); - //salva i record nella tabella di out - for(GnpDwhe2eSaldinettiOut itemOut : listSaldinettiOut){ - saldinettiOutDAO.save(itemOut); + try{ + //salva i record nella tabella di out + for(GnpDwhe2eSaldinettiOut itemOut : listSaldinettiOut){ + itemOut.setNomeFile(fileNameOut); + saldinettiOutDAO.save(itemOut); + } + UserTransactionUtility.endUserTransaction(utx, true); + + }catch (Exception ex) { + try { + log.write("9999", "UserTransactionUtility.endUserTransaction rollback"); + // Rollback the transaction + UserTransactionUtility.endUserTransaction(utx, false); + log.error(ex, "generaRecordAndStoreOut try rollback"); + ex.printStackTrace(); + } catch (Exception e) { + log.error(e, "generaRecordAndStoreOut catch rollback"); + e.printStackTrace(); + throw e; + } + throw ex; } + + log.write("9999", "End generaRecordAndStoreOut"); //ritorna la lista return listSaldinettiOut; } //TODO private void generaFileOut(List results, String nomeFileOut, String pathFileDwhe2eOut, String nomeFileIn ){ + log.write("9999", "Start generaFileOut"); // DAO out GnpDwhe2eSaldinettiOutDAO saldinettiOutDAO =new GnpDwhe2eSaldinettiOutDAO(); - //aggiungo yyyymmdd.csv al nome file - nomeFileOut += DateUtils.toString(new Date(), Resources.getDWHE2E_REPOSALDINETTI_DATA_FILENAME()) + Resources.getDWHE2E_REPOSALDINETTI_FILENAME_EXT(); + try { log.write("9999", "TROVATI " + results.size() + " RECORD DA INSERIRE NEL FILE PER DWHE2E SALDI NETTI - FILENAME: " + nomeFileOut); @@ -383,13 +467,14 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log closeFile(true); //aggiorno flag_elaborato a "Y" - saldinettiOutDAO.updateFlagElaborato(nomeFileIn, "Y"); + saldinettiOutDAO.updateFlagElaborato(nomeFileOut, "Y"); } catch (Exception ex) { - log.write("0003", "ERRORE NEL RECUPERO DEI DATI PER MONITORAGGIO E2E " + ex.toString()); + log.write("0003", "ERRORE NEL RECUPERO DEI DATI PER DWHE2E_REPOSALDINETTI E2E " + ex.toString()); // il file è già stato creato con l'header. Per questo elimino deleteFile(pathFileDwhe2eOut + nomeFileOut, true); } + log.write("9999", "End generaFileOut"); }