DBCFX_RIL_1044 - Ril. DBCFX_RU_375 - DBCFX - Modifica flussi Cubo Saldi Netti (Consumer e Business) - gestione scarti

This commit is contained in:
manuelstefanile
2025-03-11 09:14:07 +01:00
parent bb1d007ecb
commit 2a7c030943

View File

@@ -42,7 +42,9 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
private static final String DEL_103_NATOLO_TIPOUSCITA = "Uscite 103 Donor Nativo OLO";
private static final String DEL_103_STD_VOIP_TIPOUSCITA = "Uscite 103 Standard o VOIP";
private static final String DATACESSAZIONE_FORMAT = new String("yyyy-MM-dd");
private static final String REGEXP_SALDINETTI_LINE = "^([^;]{1,50});([^;]{0,15});([^;]{0,50});((\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))|);([^;]{0,1000});([^;]{0,1000});([^;]{0,1000});([^;]{0,1000});([^;]{0,1000});([^;]{0,1000})$";
private static final String REGEXP_SALDINETTI_LINE = "^([^;]{0,50});([^;]{0,15});([^;]{0,50});((\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))|);([^;]{0,1000});([^;]{0,1000});([^;]{0,1000});([^;]{0,1000});([^;]{0,1000});([^;]{0,1000})$";
private static final String NONDISPONIBILE = "[n.d]";
private static final String REGEXP_ID_RICHIESTA = "\\d+";
//variabible usata per associare ad ogni nome file il proprio numero di righe e di errori
private HashMap<String, InnerRowFile> associazioneFileReport;
@@ -82,6 +84,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
private class InnerRowFile{
private int rowError= 0;
private int numRowFile= 0;
private int numIsNdOrNonTrovato= 0;
public InnerRowFile(){
}
@@ -105,9 +108,17 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
this.numRowFile++;
}
public int getnumIsNdOrNonTrovato(){
return this.numIsNdOrNonTrovato;
}
public void incrementRowError(){
this.rowError++;
}
public void incrementIsNdOrNonTrovato(){
this.numIsNdOrNonTrovato++;
}
}
public Dwhe2eRepoSaldiNettiIn() throws Exception {
@@ -176,15 +187,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
nomeFileOut,
Resources.getPATH_FILE_DWHE2E_REPOSALDINETTI_CON_OUT());
//recupero gli errori ed il numero di row associati al fileName
InnerRowFile irf = associazioneFileReport.get(fileName);
irf.checkNumRowFile();
log.write("9999", "--------- Report summary CO nomeFile: " + fileName + " ---------");
log.write("9999", "Numero righe totali: " + irf.getNumRowFile());
log.write("9999", "Numero righe elaborate correttamente: " + (irf.getNumRowFile() - irf.getRowError()));
log.write("9999", "Numero righe in errore: " + irf.getRowError());
log.write("9999", "--------- Report summary CO fine ---------");
stampaLogReportSummary(fileName,this.CONSUMER);
}
}
@@ -207,14 +210,7 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
nomeFileOut,
Resources.getPATH_FILE_DWHE2E_REPOSALDINETTI_BUS_OUT());
//recupero gli errori ed il numero di row associati al fileName
InnerRowFile irf = associazioneFileReport.get(fileName);
irf.checkNumRowFile();
log.write("9999", "--------- Report summary BU nomeFile: " + fileName + " ---------");
log.write("9999", "Numero righe totali: " + irf.getNumRowFile());
log.write("9999", "Numero righe elaborate correttamente: " + (irf.getNumRowFile() - irf.getRowError()));
log.write("9999", "Numero righe in errore: " + irf.getRowError());
log.write("9999", "--------- Report summary BU fine ---------");
stampaLogReportSummary(fileName,this.BUSINESS);
}
}
@@ -429,15 +425,17 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
// deve esserci l'ID_RICHIESTA, altrimenti eccezione
if (0<parts.length){
try{
//sono sicuro che sia un ID di una del. <> 82
Long id = Long.parseLong(parts[0]);
gnpDwhe2eSaldinettiIn.setIdRichiesta(parts[0]);
}catch (Exception e){
if(parts[0].isEmpty())
gnpDwhe2eSaldinettiIn.setIdRichiesta(this.NONDISPONIBILE);
// potrebbe essere popolato con un codice_sessione del.82
if(parts[0].startsWith("C")||parts[0].startsWith("B"))
gnpDwhe2eSaldinettiIn.setIdRichiesta(parts[0]);
else
throw e;
gnpDwhe2eSaldinettiIn.setIdRichiesta(parts[0]);
}
}
@@ -510,75 +508,77 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
//effettua la ricerca nelle tabelle sfruttando ID_RICHIESTA, aggiorna i campi dbcfx e SE trova allora salva
for(GnpDwhe2eSaldinettiIn dwhe2eItem : gnpDwhe2eSaldinettiIn ){
Pattern p = Pattern.compile(this.REGEXP_ID_RICHIESTA);
Matcher m = p.matcher(dwhe2eItem.getIdRichiesta());
boolean isIdRichiesta = m.matches();
//per del.82 l'ID_RICHIESTA sarà popolato con il codice sessione alfanumerico che inizia con 'C' o 'B'
boolean isDel82 = dwhe2eItem.getIdRichiesta().startsWith("C")|| dwhe2eItem.getIdRichiesta().startsWith("B");
trovato = false;
boolean isNd = dwhe2eItem.getIdRichiesta().equalsIgnoreCase(this.NONDISPONIBILE);
if(isDel82){
if(!isNd){
if(isDel82){
// del. 82
GnpRichiesteDonor82 gnpRichiestaDonor82 = daoRichiesteD82.findByCodiceSessione(dwhe2eItem.getIdRichiesta());
if(gnpRichiestaDonor82!=null){
dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor82.getCowRecipient(),this.DEL_82_TIPOUSCITA, this.DEL_82);
dwhe2eSaldinettiInDAO.save(dwhe2eItem);
counter++;
trovato = true;
}
}else {
// del. 274
if(!trovato){
GnpRichiesteDonor gnpRichiestaDonor274 = daoRichiesteDonor.findById(Long.parseLong(dwhe2eItem.getIdRichiesta()));
if(gnpRichiestaDonor274!=null){
dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor274.getCowRecipient(),this.DEL_274_TIPOUSCITA, this.DEL_274);
dwhe2eSaldinettiInDAO.save(dwhe2eItem);
counter++;
// del. 82
GnpRichiesteDonor82 gnpRichiestaDonor82 = daoRichiesteD82.findByCodiceSessione(dwhe2eItem.getIdRichiesta());
if(gnpRichiestaDonor82!=null){
dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor82.getCowRecipient(),this.DEL_82_TIPOUSCITA, this.DEL_82);
trovato = true;
}
}
}else if(isIdRichiesta){
// del. 103 uscite Donor nativi olo
GnpRichiesteCsNpg103 gnpRichiesteCsNpg = null;
if(!trovato){
gnpRichiesteCsNpg = daoCsNpg103.findById(Long.parseLong(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. 274
if(!trovato){
GnpRichiesteDonor gnpRichiestaDonor274 = daoRichiesteDonor.findById(Long.parseLong(dwhe2eItem.getIdRichiesta()));
if(gnpRichiestaDonor274!=null){
dwhe2eItem.popolaAggiuntiviFX(gnpRichiestaDonor274.getCowRecipient(),this.DEL_274_TIPOUSCITA, this.DEL_274);
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;
// del. 103 uscite Donor nativi olo
GnpRichiesteCsNpg103 gnpRichiesteCsNpg = null;
if(!trovato){
gnpRichiesteCsNpg = daoCsNpg103.findById(Long.parseLong(dwhe2eItem.getIdRichiesta()));
if(gnpRichiesteCsNpg!=null && gnpRichiesteCsNpg.getProcesso().equalsIgnoreCase("DONOR_NAT_OLO")){
dwhe2eItem.popolaAggiuntiviFX(gnpRichiesteCsNpg.getCodOpRecipient(),this.DEL_103_NATOLO_TIPOUSCITA, this.DEL_103);
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);
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", "GnpDwhe2eSaldinettiIn Processati " + counter + " records.");
}
if(!trovato){
if(isNd || !trovato){
dwhe2eItem.popolaAggiuntiviFX(this.NONDISPONIBILE,this.NONDISPONIBILE, this.NONDISPONIBILE);
if (isDel82)
log.write("9999", "ID_RICHIESTA popolato con CODICE_SESSIONE non trovato a DB: " + dwhe2eItem.getIdRichiesta());
else
//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
InnerRowFile ird = associazioneFileReport.get(dwhe2eItem.getNomeFile());
ird.incrementRowError();
ird.incrementIsNdOrNonTrovato();
}
dwhe2eSaldinettiInDAO.save(dwhe2eItem);
counter++;
//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", "GnpDwhe2eSaldinettiIn Processati " + counter + " records.");
}
}
@@ -728,6 +728,18 @@ public class Dwhe2eRepoSaldiNettiIn extends InternalSenderProcess implements Log
}
private void stampaLogReportSummary(String fileName, String piattaforma){
//recupero gli errori ed il numero di row associati al fileName
InnerRowFile irf = associazioneFileReport.get(fileName);
irf.checkNumRowFile();
log.write("9999", "--------- Report summary " + piattaforma + " nomeFile: " + fileName + " ---------");
log.write("9999", "Numero righe in Input totali: " + irf.getNumRowFile());
log.write("9999", "Numero righe in Input elaborate correttamente: " + (irf.getNumRowFile() - irf.getRowError()));
log.write("9999", "Numero righe in Input in errore per formato tracciato errato: " + irf.getRowError());
log.write("9999", "Nota: sono stati elaborati correttamente " + irf.getnumIsNdOrNonTrovato() + " record (scarti [n.d]) con ID_RICHIESTA null o non presente a DB");
log.write("9999", "--------- Report summary " + piattaforma + " fine ---------");
}
private void add(List<String> list, String value) {
if (value == null) {
list.add("");