327915 - Modifica flussi Cubo Saldi Netti (Consumer e Business) - Gestione parallelismo processo CO e BU -
This commit is contained in:
@@ -4,6 +4,8 @@ package it.valueteam.gnp.dao.db.hb;
|
|||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import it.valueteam.gnp.utility.UserTransactionUtility;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.hibernate.*;
|
import org.hibernate.*;
|
||||||
@@ -17,6 +19,7 @@ import static org.hibernate.criterion.Example.create;
|
|||||||
*/
|
*/
|
||||||
import org.hibernate.criterion.Criterion;
|
import org.hibernate.criterion.Criterion;
|
||||||
|
|
||||||
|
import javax.transaction.UserTransaction;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
@@ -188,7 +191,14 @@ public class GnpDwhe2eSaldinettiOutDAO extends BaseHibernateDAO{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateFlagElaborato(String nomeFile, String flagElaborato) {
|
public boolean updateFlagElaborato(String nomeFile, String flagElaborato) throws Exception {
|
||||||
|
UserTransaction utx;
|
||||||
|
try {
|
||||||
|
utx = UserTransactionUtility.beginUserTransaction();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String sqlQuery = this.QUERY_UPDATE_FLAG_LAVORATO;
|
String sqlQuery = this.QUERY_UPDATE_FLAG_LAVORATO;
|
||||||
Query hqlQuery = getSession().createSQLQuery(sqlQuery).addEntity("D", GnpDwhe2eSaldinettiOut.class)
|
Query hqlQuery = getSession().createSQLQuery(sqlQuery).addEntity("D", GnpDwhe2eSaldinettiOut.class)
|
||||||
@@ -198,10 +208,19 @@ public class GnpDwhe2eSaldinettiOutDAO extends BaseHibernateDAO{
|
|||||||
// Esegui l'update
|
// Esegui l'update
|
||||||
int rowsUpdated = hqlQuery.executeUpdate();
|
int rowsUpdated = hqlQuery.executeUpdate();
|
||||||
|
|
||||||
|
UserTransactionUtility.endUserTransaction(utx, true);
|
||||||
|
|
||||||
//almeno 1 update l'ha fatto
|
//almeno 1 update l'ha fatto
|
||||||
return rowsUpdated>0;
|
return rowsUpdated>0;
|
||||||
|
|
||||||
} catch (RuntimeException re) {
|
} catch (RuntimeException re) {
|
||||||
|
try {
|
||||||
|
UserTransactionUtility.endUserTransaction(utx, false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
log.error("getNativiOloOpenAccess query failed", re);
|
log.error("getNativiOloOpenAccess query failed", re);
|
||||||
throw re;
|
throw re;
|
||||||
}finally {
|
}finally {
|
||||||
|
|||||||
@@ -250,6 +250,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
|||||||
log.write("9999", "Start readFileAndGetList");
|
log.write("9999", "Start readFileAndGetList");
|
||||||
|
|
||||||
List<GnpDwhe2eSaldinettiIn> listForFile = new ArrayList<GnpDwhe2eSaldinettiIn>();
|
List<GnpDwhe2eSaldinettiIn> listForFile = new ArrayList<GnpDwhe2eSaldinettiIn>();
|
||||||
|
Scanner reader = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String pathLetturaFile = (piattaforma == this.CONSUMER) ? Resources.getPATH_FILE_DWHE2E_REPOSALDINETTI_CON_IN()
|
String pathLetturaFile = (piattaforma == this.CONSUMER) ? Resources.getPATH_FILE_DWHE2E_REPOSALDINETTI_CON_IN()
|
||||||
@@ -260,7 +261,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
|||||||
log.write("9999", "file da elaborare "+ pathLetturaFile + fileName);
|
log.write("9999", "file da elaborare "+ pathLetturaFile + fileName);
|
||||||
File wlFile = new File(pathLetturaFile+fileName);
|
File wlFile = new File(pathLetturaFile+fileName);
|
||||||
|
|
||||||
Scanner reader = new Scanner(wlFile);
|
reader = new Scanner(wlFile);
|
||||||
|
|
||||||
int row=0;
|
int row=0;
|
||||||
int firstRowHeader= 0;
|
int firstRowHeader= 0;
|
||||||
@@ -309,6 +310,17 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.write("9999", "exception in readFileAndGetList "+e.getMessage());
|
log.write("9999", "exception in readFileAndGetList "+e.getMessage());
|
||||||
throw e;
|
throw e;
|
||||||
|
}finally {
|
||||||
|
if(null != reader) {
|
||||||
|
try {
|
||||||
|
// Closing when previously closed will have no effect;
|
||||||
|
reader.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// no logging possible here, do nothing
|
||||||
|
} finally {
|
||||||
|
reader = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log.write("9999", "End readFileAndGetList");
|
log.write("9999", "End readFileAndGetList");
|
||||||
return listForFile;
|
return listForFile;
|
||||||
@@ -428,7 +440,9 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
try{
|
try{
|
||||||
|
|
||||||
//effettua la ricerca nelle tabelle sfruttando ID_RICHIESTA, aggiorna i campi dbcfx e SE trova allora salva
|
//effettua la ricerca nelle tabelle sfruttando ID_RICHIESTA, aggiorna i campi dbcfx e SE trova allora salva
|
||||||
for(GnpDwhe2eSaldinettiIn dwhe2eItem : gnpDwhe2eSaldinettiIn ){
|
for(GnpDwhe2eSaldinettiIn dwhe2eItem : gnpDwhe2eSaldinettiIn ){
|
||||||
// del. 82
|
// del. 82
|
||||||
@@ -459,6 +473,16 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
// Flush e clear ogni 100 record
|
||||||
|
if (counter % 100 == 0) {
|
||||||
|
|
||||||
|
UserTransactionUtility.endUserTransaction(utx, true);
|
||||||
|
utx = UserTransactionUtility.beginUserTransaction();
|
||||||
|
|
||||||
|
log.write("9999", "Processed " + counter + " records, flushed and cleared session.");
|
||||||
|
}
|
||||||
|
|
||||||
//se soon arrivato qui, allora non c'è corrispondenza nel DB dell'ID_RICHIESTA
|
//se soon arrivato qui, allora non c'è corrispondenza nel DB dell'ID_RICHIESTA
|
||||||
log.write("9999", "ID_RICHIESTA non trovato a DB: " + dwhe2eItem.getIdRichiesta());
|
log.write("9999", "ID_RICHIESTA non trovato a DB: " + dwhe2eItem.getIdRichiesta());
|
||||||
//aggiungo errori legati alla mancata presenza dell'ID_RICHIESTA tra le varie delibere
|
//aggiungo errori legati alla mancata presenza dell'ID_RICHIESTA tra le varie delibere
|
||||||
@@ -493,14 +517,6 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
|||||||
private List<GnpDwhe2eSaldinettiOut> generaRecordAndStoreOut(String fileNameIn, String fileNameOut) throws Exception {
|
private List<GnpDwhe2eSaldinettiOut> generaRecordAndStoreOut(String fileNameIn, String fileNameOut) throws Exception {
|
||||||
log.write("9999", "Start generaRecordAndStoreOut");
|
log.write("9999", "Start generaRecordAndStoreOut");
|
||||||
|
|
||||||
UserTransaction utx;
|
|
||||||
try {
|
|
||||||
utx = UserTransactionUtility.beginUserTransaction();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e, "generaRecordAndStoreOut: beginUserTransaction");
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
GnpDwhe2eSaldinettiOutDAO saldinettiOutDAO =new GnpDwhe2eSaldinettiOutDAO();
|
GnpDwhe2eSaldinettiOutDAO saldinettiOutDAO =new GnpDwhe2eSaldinettiOutDAO();
|
||||||
GnpDwhe2eSaldinettiInDAO saldinettiInDAO =new GnpDwhe2eSaldinettiInDAO();
|
GnpDwhe2eSaldinettiInDAO saldinettiInDAO =new GnpDwhe2eSaldinettiInDAO();
|
||||||
|
|
||||||
@@ -509,12 +525,30 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
|||||||
//Il flag Lavorato ad N è settato nel costruttore quando fa il mapping HB
|
//Il flag Lavorato ad N è settato nel costruttore quando fa il mapping HB
|
||||||
List<GnpDwhe2eSaldinettiOut> listSaldinettiOut = saldinettiInDAO.groupBy(fileNameIn);
|
List<GnpDwhe2eSaldinettiOut> listSaldinettiOut = saldinettiInDAO.groupBy(fileNameIn);
|
||||||
|
|
||||||
|
UserTransaction utx;
|
||||||
|
try {
|
||||||
|
utx = UserTransactionUtility.beginUserTransaction();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e, "generaRecordAndStoreOut: beginUserTransaction");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
int counter = 0;
|
||||||
try{
|
try{
|
||||||
log.write("9999", "Inizio salvataggio in GNP_DWHE2E_SALDINETTI_OUT per i record che POPOLERANNO il file " + fileNameOut);
|
log.write("9999", "Inizio salvataggio in GNP_DWHE2E_SALDINETTI_OUT per i record che POPOLERANNO il file " + fileNameOut);
|
||||||
//salva i record nella tabella di out
|
//salva i record nella tabella di out
|
||||||
for(GnpDwhe2eSaldinettiOut itemOut : listSaldinettiOut){
|
for(GnpDwhe2eSaldinettiOut itemOut : listSaldinettiOut){
|
||||||
itemOut.setNomeFile(fileNameOut);
|
itemOut.setNomeFile(fileNameOut);
|
||||||
saldinettiOutDAO.save(itemOut);
|
saldinettiOutDAO.save(itemOut);
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
if (counter % 100 == 0) {
|
||||||
|
|
||||||
|
UserTransactionUtility.endUserTransaction(utx, true);
|
||||||
|
utx = UserTransactionUtility.beginUserTransaction();
|
||||||
|
|
||||||
|
log.write("9999", "GnpDwhe2eSaldinettiOut Processed " + counter + " records, flushed and cleared session.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
UserTransactionUtility.endUserTransaction(utx, true);
|
UserTransactionUtility.endUserTransaction(utx, true);
|
||||||
log.write("9999", "Fine salvataggio");
|
log.write("9999", "Fine salvataggio");
|
||||||
|
|||||||
Reference in New Issue
Block a user