327915 - Modifica flussi Cubo Saldi Netti (Consumer e Business) - Inserimento log e buffer per commit -
This commit is contained in:
@@ -20,4 +20,7 @@ PATH_FILE_DWHE2E_REPOSALDINETTI_BUS_OUT =/gnpapp/batch/ftpout/dwhe2e_saldinetti_
|
||||
|
||||
DWHE2E_REPOSALDINETTI_OUT_HEADER=E2E_DATA_CESSAZIONE;E2E_SERVIZIO_ACCESSO;E2E_DIMENSIONE_1;E2E_DIMENSIONE_2;E2E_DIMENSIONE_3;E2E_DIMENSIONE_4;E2E_DIMENSIONE_5;DBCFX_DIM_CODICE_OLO;DBCFX_DIM_TIPO_USCITA;DBCFX_DIM_DELIBERA;DBCFX_NRO_USCITE
|
||||
|
||||
#BUFFER PER LE COMMIT DI SCRITTURA AL DB PER I FLUSSI IN e OUT
|
||||
DWHE2E_REPOSALDINETTI_BUFFER_COMMIT = 500
|
||||
|
||||
########################### FINE DWHE2E_REPOSALDINETTI ###########################
|
||||
@@ -23,7 +23,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Loggable, ProcessIF {
|
||||
private ProcessLogger log;
|
||||
private InnerLog log;
|
||||
|
||||
private final static String codiceProcesso = "ER";
|
||||
private final static String versione = "1.0.0";
|
||||
@@ -48,6 +48,37 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
||||
private int rowError= 0;
|
||||
private int numRowFile= 0;
|
||||
|
||||
private class InnerLog {
|
||||
private ProcessLogger logInside;
|
||||
private String piattaforma;
|
||||
|
||||
public InnerLog (Dwhe2eRepoSaldiNettiIn istanza) throws Exception {
|
||||
LogProcess logProcess = new LogProcess();
|
||||
logProcess.setCodice(codiceProcesso);
|
||||
logProcess.setProcess(istanza);
|
||||
logInside = new ProcessLogger(logProcess);
|
||||
}
|
||||
|
||||
public String getPiattaforma() {
|
||||
return piattaforma;
|
||||
}
|
||||
|
||||
public void setPiattaforma(String piattaforma) {
|
||||
this.piattaforma = piattaforma;
|
||||
}
|
||||
|
||||
public void write(String codiceLog, String msgVariabile){
|
||||
msgVariabile = piattaforma==null ? "?" : piattaforma + "_" + msgVariabile;
|
||||
logInside.write(codiceLog,msgVariabile);
|
||||
}
|
||||
|
||||
public void error(Exception ex, String messaggio){
|
||||
messaggio = piattaforma==null ? "?" : piattaforma + "_" + messaggio;
|
||||
logInside.error(ex,messaggio);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Dwhe2eRepoSaldiNettiIn() throws Exception {
|
||||
try {
|
||||
initLog();
|
||||
@@ -58,10 +89,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
||||
}
|
||||
|
||||
private void initLog() throws Exception {
|
||||
LogProcess logProcess = new LogProcess();
|
||||
logProcess.setCodice(codiceProcesso);
|
||||
logProcess.setProcess(this);
|
||||
log = new ProcessLogger(logProcess);
|
||||
log = new InnerLog(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,11 +98,16 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
||||
* @param args String[]
|
||||
*/
|
||||
public void execute(String[] args) throws Exception {
|
||||
log.write("9999", "Start EXECUTE Dwhe2eRepoSaldiNettiIn ");
|
||||
|
||||
try {
|
||||
if(args[0].equalsIgnoreCase(this.CONSUMER)|| args[0].equalsIgnoreCase(this.BUSINESS))
|
||||
if(args.length!=0 && (args[0].equalsIgnoreCase(this.CONSUMER)|| args[0].equalsIgnoreCase(this.BUSINESS))){
|
||||
|
||||
//utilizzato per la stampa dei log in concorrenza per CO e BU
|
||||
log.setPiattaforma(args[0]);
|
||||
log.write("9999", "Start EXECUTE Dwhe2eRepoSaldiNettiIn ");
|
||||
readFile(args[0]);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
//0003 C - PROCESSO TERMINATO CON ECCEZIONI
|
||||
log.write("0003", "" + ex.toString());
|
||||
@@ -441,52 +474,71 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
boolean trovato = false;
|
||||
int buffer = (Integer.parseInt(Resources.getDWHE2E_REPOSALDINETTI_BUFFER_COMMIT()));
|
||||
try{
|
||||
|
||||
//effettua la ricerca nelle tabelle sfruttando ID_RICHIESTA, aggiorna i campi dbcfx e SE trova allora salva
|
||||
for(GnpDwhe2eSaldinettiIn dwhe2eItem : gnpDwhe2eSaldinettiIn ){
|
||||
|
||||
trovato = false;
|
||||
|
||||
// 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;
|
||||
counter++;
|
||||
trovato = true;
|
||||
}
|
||||
|
||||
// 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);
|
||||
continue;
|
||||
if(!trovato){
|
||||
GnpRichiesteDonor gnpRichiestaDonor274 = daoRichiesteDonor.findById(dwhe2eItem.getIdRichiesta());
|
||||
if(gnpRichiestaDonor274!=null){
|
||||
dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor274.getCowRecipient(),this.DEL_274_TIPOUSCITA, this.DEL_274);
|
||||
dwhe2eSaldinettiInDAO.save(dwhe2eItem);
|
||||
counter++;
|
||||
trovato = true;
|
||||
}
|
||||
}
|
||||
|
||||
counter++;
|
||||
// Flush e clear ogni 100 record
|
||||
if (counter % 100 == 0) {
|
||||
// del. 103 uscite Donor nativi olo
|
||||
GnpRichiesteCsNpg103 gnpRichiesteCsNpg = null;
|
||||
if(!trovato){
|
||||
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);
|
||||
counter++;
|
||||
trovato = true;
|
||||
}
|
||||
}
|
||||
|
||||
// del. 103 uscite Donor nativi olo
|
||||
if(!trovato){
|
||||
if(gnpRichiesteCsNpg!=null && gnpRichiesteCsNpg.getProcesso().equalsIgnoreCase("CSNPg103")){
|
||||
dwhe2eItem.popolaAggiuntiviFX(gnpRichiesteCsNpg.getCodOpRecipient(),this.DEL_103_STD_VOIP_TIPOUSCITA, this.DEL_103);
|
||||
dwhe2eSaldinettiInDAO.save(dwhe2eItem);
|
||||
counter++;
|
||||
trovato = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Commit e chiusura transazione ogni tot record definiti nella properties DWHE2E_REPOSALDINETTI_BUFFER_COMMIT
|
||||
if (counter % buffer == 0) {
|
||||
UserTransactionUtility.endUserTransaction(utx, true);
|
||||
utx = UserTransactionUtility.beginUserTransaction();
|
||||
|
||||
log.write("9999", "Processed " + counter + " records, flushed and cleared session.");
|
||||
log.write("9999", "GnpDwhe2eSaldinettiIn Processati " + counter + " records.");
|
||||
}
|
||||
|
||||
if(!trovato){
|
||||
//se soon arrivato qui, allora non c'è corrispondenza nel DB dell'ID_RICHIESTA
|
||||
log.write("9999", "ID_RICHIESTA non trovato a DB: " + dwhe2eItem.getIdRichiesta());
|
||||
//aggiungo errori legati alla mancata presenza dell'ID_RICHIESTA tra le varie delibere
|
||||
rowError++;
|
||||
}
|
||||
|
||||
//se soon arrivato qui, allora non c'è corrispondenza nel DB dell'ID_RICHIESTA
|
||||
log.write("9999", "ID_RICHIESTA non trovato a DB: " + dwhe2eItem.getIdRichiesta());
|
||||
//aggiungo errori legati alla mancata presenza dell'ID_RICHIESTA tra le varie delibere
|
||||
rowError++;
|
||||
}
|
||||
|
||||
UserTransactionUtility.endUserTransaction(utx, true);
|
||||
@@ -533,6 +585,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
||||
throw e;
|
||||
}
|
||||
int counter = 0;
|
||||
int buffer = (Integer.parseInt(Resources.getDWHE2E_REPOSALDINETTI_BUFFER_COMMIT()));
|
||||
try{
|
||||
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
|
||||
@@ -541,12 +594,13 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
|
||||
saldinettiOutDAO.save(itemOut);
|
||||
|
||||
counter++;
|
||||
if (counter % 100 == 0) {
|
||||
//Commit e chiusura transazione ogni tot record definiti nella properties DWHE2E_REPOSALDINETTI_BUFFER_COMMIT
|
||||
if (counter % buffer == 0) {
|
||||
|
||||
UserTransactionUtility.endUserTransaction(utx, true);
|
||||
utx = UserTransactionUtility.beginUserTransaction();
|
||||
|
||||
log.write("9999", "GnpDwhe2eSaldinettiOut Processed " + counter + " records, flushed and cleared session.");
|
||||
log.write("9999", "GnpDwhe2eSaldinettiOut Processati " + counter + " records.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3347,4 +3347,10 @@ public class Resources {
|
||||
return Trim(props.getProperty("DWHE2E_REPOSALDINETTI_OUT_HEADER"));
|
||||
}
|
||||
|
||||
public static String getDWHE2E_REPOSALDINETTI_BUFFER_COMMIT() {
|
||||
if (props == null)
|
||||
init();
|
||||
return Trim(props.getProperty("DWHE2E_REPOSALDINETTI_BUFFER_COMMIT"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user