package it.valueteam.gnp.manager; import com.tibco.schemas.dbssgoacawirelineceasecheck82.shared.schemas.external.dbcfx.wirelineceasecheck82.WirelineCeaseCheck82ResponseType; import dbcfx.soa.checkretailplatform.x20160704.CheckRetailPlatformRequest; import it.telecomitalia.soa.customerlocationquery.x20150511.Parameter; import it.telecomitalia.soa.customerlocationquery.x20150511.RetrieveByLineNumberRequestMessage; import it.telecomitalia.soa.customerlocationquery.x20150511.RetrieveByLineNumberResponseMessage; import it.telecomitalia.soa.customerlocationquerycustomtypes.x20150511.*; import it.valueteam.gnp.dao.db.UtilityDao; import it.valueteam.gnp.dao.db.hb.*; import it.valueteam.gnp.dao.db.hb.crm.GnpCrmNotifyDonorOut; import it.valueteam.gnp.dao.db.hb.crm.GnpCrmNotifyDonorOutDAO; import it.valueteam.gnp.exception.StateTransitionNotPossibleException; import it.valueteam.gnp.log.ProcessLogger; import it.valueteam.gnp.obj.ApplicationCostants; import it.valueteam.gnp.obj.ProcessMapper; import it.valueteam.gnp.obj.StatoRichiestaDon; import it.valueteam.gnp.systemcontroller.ControllerFactory; import it.valueteam.gnp.systemcontroller.SystemControllerIF; import it.valueteam.gnp.systemcontroller.crm.SistemaCrmIF; import it.valueteam.gnp.systemcontroller.formatcontroller.dbss.DBSSController; import it.valueteam.gnp.systemcontroller.formatcontroller.now.NowController; import it.valueteam.gnp.systemcontroller.olo.OLOControllerDonor; import it.valueteam.gnp.utility.DateUtils; import it.valueteam.gnp.utility.Func; import it.valueteam.gnp.utility.Resources; import it.valueteam.gnp.utility.StateManagerDonor; import it.valueteam.gnp.ws.dbss.client.CustomerLocationQueryClient; import java.util.Date; import java.util.List; public class RequestManagerDonor82 { private static NowController instance; private final static String operationName = "OperationCode"; private final static String lineValue = "1"; private final static String serviceNumber = "ServiceNumber"; public static final int RET_CODE_OK_FROM_WS = 0; public static final int RET_CODE_UTENZA_NON_PRESENTE_FROM_WS = 1; public static final int RET_CODE_ERRORE_GENERICO_WS = 2; public static final int RET_CODE_SERV_CRMB_NON_DISPONIBILE = 4; public static final int RET_CODE_SERV_CRMR_NON_DISPONIBILE = 5; //C06 public static final String ANOMALIA_LINEA_NON_PRESENTE_CCC="LINEA_NON_PRESENTE"; public static final String ANOMALIA_LINEA_NON_PRESENTE_CCC_DESCRIZIONE="Linea non presente sull'operation retrieveByLineNumber di customerLocationQuery"; public static final String ANOMALIA_ERRORE_CODICE_SERVIZIO_CCC="CODICE_ERRORE_SERVIZIO_CCC"; public static final String ANOMALIA_ERRORE_CODICE_SERVIZIO_CCC_DESCRIZIONE="L'operation retrieveByLineNumber di customerLocationQuery ha restituito un errore : "; public static final String ANOMALIA_ERRORE_CODICE_SERVIZIO_NON_PREVISTO_CCC="CODICE_NON_PREVISTO_ERRORE_SERVIZIO_CCC"; public static final String ANOMALIA_ERRORE_CODICE_SERVIZIO_NON_PREVISTO_CCC_DESCRIZIONE="L'operation retrieveByLineNumber di customerLocationQuery ha restituito un errore non previsto : "; public static final String VERIFICA_CS_ERRATA_DBSS="VERIFICA_CODICE_SEGRETO_ERRORE_DBSS"; public static final String VERIFICA_CS_ERRATA_DBSS_DESCRIZIONE="VERIFICA CODICE SEGRETO ERRORE INASPETTATO DBSS"; public static final String VERIFICA_CS_DBSS_NUMERAZIONE_NON_GESTITA="VERIFICA_CODICE_SEGRETO_NUMERAZIONE_NON_GESTITA"; public static final String VERIFICA_CS_DBSS_NUMERAZIONE_NON_GESTITA_DESCRIZIONE="VERIFICA CODICE SEGRETO NUMERAZIONE NON GESTITA DBSS"; public static final String VERIFICA_CS_DBSS_ESITO_NON_GESTITO="VERIFICA_CODICE_SEGRETO_ESITO_NON_GESTITO"; public static final String VERIFICA_CS_DBSS_ESITO_NON_GESTITO_DESCRIZIONE="VERIFICA CODICE SEGRETO ESITO NON GESTITO DBSS"; private RequestManagerDonor82() { } /** * Avanzamento stato in ACQUISITA * * @param oloRichiesteDonorIn * @param log * @return * @throws Exception */ public static Long avanzaStatoInAcquisita(GnpOloRichiesteDonorIn oloRichiesteDonorIn, ProcessLogger log) throws Exception { GnpRichiesteDonor82 richiestaDonor = creaRichiestaMigrazione(oloRichiesteDonorIn); GnpRichiesteDonor82DAO richiesteDonorDAO = new GnpRichiesteDonor82DAO(); richiesteDonorDAO.save(richiestaDonor); logStoricoPassaggioStato(richiestaDonor.getIdRichiesta(), -1, StatoRichiestaDon.ACQUISITA, log); return richiestaDonor.getIdRichiesta(); } /** * Inserisce nello storico della richiesta il passaggio di stato * da -1 a 1 * * @throws Exception */ public static void logStoricoPassaggioStato(Long idRichiesta, int statoDa, int statoA, ProcessLogger log) throws Exception { GnpStoricoRichiesteDonor storicoRich = new GnpStoricoRichiesteDonor(); storicoRich.setIdRichiesta(idRichiesta); storicoRich.setStatoDa((long) statoDa); storicoRich.setStatoA((long) statoA); GnpStoricoRichiesteDonorDAO storicoDonorDAO = new GnpStoricoRichiesteDonorDAO(); storicoDonorDAO.save(storicoRich); log.write("9999", "ID RICHIESTA DONOR " + idRichiesta.toString() + " PASSA DALLO STATO " + (statoDa != -1 ? StatoRichiestaDon.getStatoDescr(statoDa) : "INIZIALE") + " ALLO STATO " + StatoRichiestaDon.getStatoDescr(statoA)); } public static GnpRichiesteDonor82 creaRichiestaMigrazione(GnpOloRichiesteDonorIn oloRichiesteDonorIn) throws Exception { GnpRichiesteDonor82 richiesteDonor = new GnpRichiesteDonor82(); //Codice Olo Donating richiesteDonor.setCowDonating(oloRichiesteDonorIn.getCodiceOperatoreDonating()); //Codice Olo Recipient richiesteDonor.setCowRecipient(oloRichiesteDonorIn.getCodiceOperatoreRecipient()); //Directory Number ovvero il Cor ovvero il codice Risorsa richiesteDonor.setDn(oloRichiesteDonorIn.getDn1()); richiesteDonor.setCognomeCliente(oloRichiesteDonorIn.getCognomeClienteRagioneSocial()); richiesteDonor.setCodiceOrdineRecipient(oloRichiesteDonorIn.getCodiceOrdineRecipient()); richiesteDonor.setStato((long) StatoRichiestaDon.ACQUISITA); richiesteDonor.setDataRicezione(oloRichiesteDonorIn.getDataRicezione()); //Data Fine Wait - Calcolata con DataRicezione + 24H lavorative richiesteDonor.setDfw(DateUtils.aggiungi24OreLavorative(oloRichiesteDonorIn.getDataRicezione())); //Calcolata con DataRicezione + 17 giorni lavorativi richiesteDonor.setDataScadenza(DateUtils.aggiungiGiorniLavorativiTodateImpostaOra (oloRichiesteDonorIn.getDataRicezione(), ApplicationCostants.GIORNI_CALCOLO_DATA_SCADENZA, ApplicationCostants.ORA_CALCOLO_DATA_SCADENZA, ApplicationCostants.MINUTI_CALCOLO_DATA_SCADENZA, ApplicationCostants.SECONDI_CALCOLO_DATA_SCADENZA) ); richiesteDonor.setCor(oloRichiesteDonorIn.getCor()); richiesteDonor.setCos(oloRichiesteDonorIn.getCos()); richiesteDonor.setDn2(oloRichiesteDonorIn.getDn2()); richiesteDonor.setDn3(oloRichiesteDonorIn.getDn3()); richiesteDonor.setDn4(oloRichiesteDonorIn.getDn4()); richiesteDonor.setDn5(oloRichiesteDonorIn.getDn5()); richiesteDonor.setDn6(oloRichiesteDonorIn.getDn6()); richiesteDonor.setDn7(oloRichiesteDonorIn.getDn7()); richiesteDonor.setDn8(oloRichiesteDonorIn.getDn8()); richiesteDonor.setDn9(oloRichiesteDonorIn.getDn9()); richiesteDonor.setDn10(oloRichiesteDonorIn.getDn10()); //I campi codice Sessione, CRMCompetenza, KoNonInviato, PresaInCarico, CodValidazione //vengono inseriti successivamente nel processo return richiesteDonor; } /** * Avanzamento stato in ACCETTATA * * @param richiesta * @param log * @throws Exception */ public static void avanzaStatoInAccettata(GnpRichiesteDonor82 richiesta, ProcessLogger log) throws Exception { GnpRichiesteDonor82DAO ricDonorDAO = new GnpRichiesteDonor82DAO(); int statoDa = richiesta.getStato().intValue(); int check = StateManagerDonor.checkTransition(richiesta.getIdRichiesta(), StatoRichiestaDon.ACCETTATA); if (check != StateManagerDonor.TRANSIZIONE_NON_POSSIBILE) { // CALCOLA DATA SCADENZA ALLA MEZZANOTTE DEL 16� GIORNO log.write("9999", "avanzaStatoInAccettata richiestaD82:" + richiesta.getIdRichiesta()); Date dataScadenza = DateUtils.aggiungiGiorniLavorativiTodateImpostaOra(new Date(), 16, 0, 0, 0); richiesta.setStato((long) StatoRichiestaDon.ACCETTATA); richiesta.setDataScadenza(dataScadenza); ricDonorDAO.merge(richiesta); logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.ACCETTATA, log); // Ricerca eventuali altre richieste stesso DN, stesso COW RECIPIENT // DBCFX SM_525 Anomalia da pezzulla. Modifica da effettuare cambiare la SYSDATE della query in to_date(sysdate, 'DD-MON-YY'), // formattandola quindi in giorno mese e anno e non considerando l'orario. List altreRichieste = ricDonorDAO.getAltreRichiesteStessoCowDN(richiesta.getDn(), richiesta.getCowRecipient()); if (altreRichieste != null && altreRichieste.size() > 0) { for (Object anAltreRichieste : altreRichieste) { //ogni altra richiesta viene posta in scaduta GnpRichiesteDonor82 altraR = (GnpRichiesteDonor82) anAltreRichieste; statoDa = altraR.getStato().intValue(); altraR.setStato((long) StatoRichiestaDon.SCADUTA); altraR.setDataScadenza(dataScadenza); ricDonorDAO.merge(altraR); logStoricoPassaggioStato(altraR.getIdRichiesta(), statoDa, StatoRichiestaDon.SCADUTA, log); } } } else { throw new StateTransitionNotPossibleException("StateTransitionNotPossibleException"); } } public static void avanzaStatoInRifiutata(GnpRichiesteDonor82 richiesta, String descrizioneRifiuto, int codMotivoRifiuto, boolean cowNonTI, ProcessLogger log) throws Exception { GnpRichiesteDonor82DAO dao = new GnpRichiesteDonor82DAO(); int check = StateManagerDonor.checkTransition(richiesta.getIdRichiesta(), StatoRichiestaDon.RIFIUTATA); int statoDa = richiesta.getStato().intValue(); if (check != StateManagerDonor.TRANSIZIONE_NON_POSSIBILE) { log.write("9999", "Passaggio di stato in RIFIUTATA ID RICHIESTA " + richiesta.getIdRichiesta()); richiesta.setStato((long) StatoRichiestaDon.RIFIUTATA); richiesta.setCodValidazione((long) ApplicationCostants.COD_VALIDAZIONE_KO); // Notifica a OLO OLOControllerDonor.getInstance().accodaKORichiestaOloDonorOut(richiesta, descrizioneRifiuto, codMotivoRifiuto, ApplicationCostants.PROCESSO_DONOR.OLO_OUT.CAUSALE_RIFIUTO_GESTIONALE, ApplicationCostants.OLO_TIPO_COMUNICAZIONE_VER_GESTIONALI); logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.RIFIUTATA, log); dao.merge(richiesta); } else if (statoDa == StatoRichiestaDon.ACCETTATA) { log.write("9999", "Passaggio di stato in RIFIUTATA non effettuato perche richiesta gia in ACCETTATA: ID RICHIESTA " + richiesta.getIdRichiesta()); richiesta.setKoNonInviato(ApplicationCostants.PROCESSO_DONOR.KO_NON_INVIATO); } else { throw new StateTransitionNotPossibleException("StateTransitionNotPossibleException"); } } public static String createSessionID82(String idProgressivo) throws Exception { String sessionID; StringBuffer bf = new StringBuffer(); Date dataCreazione = new Date(); bf.append(DateUtils.toStringFileName(dataCreazione)); bf.append(idProgressivo); sessionID = bf.toString(); return sessionID; } public static String generaCodiceSessione82(GnpRichiesteDonor82 richiesta, ProcessLogger log) throws Exception { GnpRichiesteDonor82DAO dao = new GnpRichiesteDonor82DAO(); GnpDbssDonorOutDAO dbssDonorOutRecDAO = new GnpDbssDonorOutDAO(); // Ricerco nell'anagrafica il cow Donating ricevuto GnpAnagCowLineaTelecom anagCowLineaTelecom = null; GnpAnagCowLineaTelecomDAO cowLineaDao; GnpAnagCowTelecomDAO anagCowDAO = new GnpAnagCowTelecomDAO(); GnpAnagCowTelecom anagCowTelecom = anagCowDAO.findById(richiesta.getCowDonating()); //C09 2019 WA RICHIESTO ESCLUSIVAMENTE PER LA VERIFICA CS if (Resources.getFLAG_CHECK_ANAG_COW_LINEA()) { log.write("9999", "CONTROLLO SU TABELLA GNP_ANAG_COW_LINEA_TELECOM(FLAG WA ABILITATO) : " + richiesta.getIdRichiesta() + " COW: " + richiesta.getCowDonating() + " DN:" + richiesta.getDn()); cowLineaDao = new GnpAnagCowLineaTelecomDAO(); anagCowLineaTelecom = cowLineaDao.findByDnAndCowOld(richiesta.getDn(), richiesta.getCowDonating()); } //C09 2019 WA RICHIESTO ESCLUSIVAMENTE PER LA VERIFICA CS SE E' UGUALE A NULL IL PROCESSO RESTA INVARIATO if (anagCowLineaTelecom != null) { log.write("9999", "TROVATA LINEA SU TABELLA GNP_ANAG_COW_LINEA_TELECOM(FLAG WA ABILITATO) : " + richiesta.getIdRichiesta() + " COW VECCHIO: " + richiesta.getCowDonating() + " COW NUOVO:" + anagCowLineaTelecom.getCowNew() + " DN:" + richiesta.getDn()); anagCowTelecom = new GnpAnagCowTelecom(); anagCowTelecom.setCow(anagCowLineaTelecom.getCowNew()); richiesta.setCowDonating(anagCowLineaTelecom.getCowNew()); } // Se non trovo il cow nell'anagrafica: // 1)Aggiorno la tabella GNP_RICHIESTE_DONOR con cod_validazione = 1 // 2)Inserisco un record nella tabella GNP_OLO_RICHIESTE_DONOR_OUT if (anagCowTelecom == null) { richiesta.setCodValidazione(1L); String sessionId = Func.findNextD82SessionId(); String dateSessionId = createSessionID82(sessionId); return "X" + dateSessionId; } else { // DETERMINO LA PIATTAFORMA CRM DI COMPETENZA /* C06 RE: GATEWAY DBCFX :Studio per il tracciamento di eventi non correttamente gestiti dal sistema * cambio implementazione del recupero della piattaforma di competenza, non si basa più sull'anagrafica (anagCowTelecom) * ma tramite il localizzatore. Per maggiori dettagli vedi mail */ if (!callCheckRetailPlatform(richiesta, log)) { log.write("9999", "callCheckRetailPlatform false : " + richiesta.getIdRichiesta() + " COW DONATING: " + richiesta.getCowDonating() + "CRM recuperato: " + richiesta.getCrmCompetenza()); } //USO IL CRM DI COMPETENZA RECUPERATO DAL SERVIZIO CUSTOMER LOCATION QUERY String crmCompetenza = richiesta.getCrmCompetenza(); String sessionId = Func.findNextD82SessionId(); String dateSessionId = createSessionID82(sessionId); if ("B".equalsIgnoreCase(crmCompetenza)) { return crmCompetenza + dateSessionId; } else if ("D".equalsIgnoreCase(crmCompetenza)) { return "C" + dateSessionId; } else { return "X" + dateSessionId; } } } /** * Passaggio di stato in PRESAINCARICO. *

* Ritorna false se il COW Donating non � mappato su uno di quelli Telecom * * @param richiesta * @param log * @return * @throws Exception */ public static boolean avanzaStatoInPresaInCarico(GnpRichiesteDonor82 richiesta, ProcessLogger log) throws Exception { GnpRichiesteDonor82DAO dao = new GnpRichiesteDonor82DAO(); GnpRichiesteCsNpg103DAO npg103DAO = new GnpRichiesteCsNpg103DAO(); GnpCrmNotifyDonorOutDAO dbssDonorOutRecDAO = new GnpCrmNotifyDonorOutDAO(); boolean ret = true; List richiesteDN = dao.getAltreRichiesteStessoCowDN(richiesta.getDn(), richiesta.getCowDonating()); GnpRichiesteCsNpg103 richiesteCsNpg103s = npg103DAO.findByDn(richiesta.getDn()); //check su 103 è fattibile? TODO query List richieste274 = dao.getAltreRichiesteStessoCowDN(richiesta.getDn(), richiesta.getCowDonating()); Boolean daRifiutare = false; if (richieste274 != null && richieste274.size() > 0) { for (GnpRichiesteDonor ric : richieste274) { if (ric.getIdRichiesta() != richiesta.getIdRichiesta() && ric.getDataScadenza().after(richiesta.getDataRicezione())) { daRifiutare = true; } } if (daRifiutare) { avanzaStatoInRifiutata(richiesta, "Altro ordine in corso per tale utenza", ApplicationCostants.PROCESSO_DONOR.OLO_OUT.CAUSALE_RIFIUTO_GESTIONALE, false, log); return true; } } if (richiesteCsNpg103s != null && (richiesteCsNpg103s.getStato() == 1 || richiesteCsNpg103s.getStato() == 2 || (richiesteCsNpg103s.getStato() == 3 && richiesteCsNpg103s.getProcesso().equalsIgnoreCase(ProcessMapper.proc_CS_NPg103)) )) { avanzaStatoInRifiutata(richiesta, "Altro ordine in corso per tale utenza", ApplicationCostants.PROCESSO_DONOR.OLO_OUT.CAUSALE_RIFIUTO_GESTIONALE, false, log); return true; } if (richiesteDN != null && richiesteDN.size() > 0) { for (GnpRichiesteDonor82 ric : richiesteDN) { if (ric.getIdRichiesta() != richiesta.getIdRichiesta() && ric.getDataScadenza().after(richiesta.getDataRicezione())) { daRifiutare = true; } } if (daRifiutare) { avanzaStatoInRifiutata(richiesta, "Altro ordine in corso per tale utenza", ApplicationCostants.PROCESSO_DONOR.OLO_OUT.CAUSALE_RIFIUTO_GESTIONALE, false, log); return true; } } int check = StateManagerDonor.checkTransition(richiesta.getIdRichiesta(), StatoRichiestaDon.PRESA_IN_CARICO); if (check != StateManagerDonor.TRANSIZIONE_NON_POSSIBILE) { int statoDa = richiesta.getStato().intValue(); richiesta.setStato((long) StatoRichiestaDon.PRESA_IN_CARICO); richiesta.setDataPresaincarico(new Date()); log.write("9999", "PRESA IN CARICO del DN :"+richiesta.getDn()+" IdRichiesta: "+richiesta.getIdRichiesta()+richiesta.getDataPresaincarico()); Boolean verificaWhiteList = new WhiteListManager().verificaCsWhiteListDonorDel274(richiesta.getDn(), richiesta.getCowDonating()); if (verificaWhiteList != null && verificaWhiteList) { log.write("9999", "Risultato Verifica in WhiteList [TRUE]. Passaggio in ACCETTATA DN: "+richiesta.getDn()); avanzaStatoInAccettata(richiesta, log); } else if (verificaWhiteList != null && !verificaWhiteList) { log.write("9999", "Verifica cs whitelist false"+" IDRichiesta: "+richiesta.getIdRichiesta()); avanzaStatoInRifiutata(richiesta, "Codice Segreto Errato", ApplicationCostants.PROCESSO_DONOR.OLO_OUT.COD_MOTIVO_11, false, log); } //verificaWhiteList == null else { if (richiesta.getCodValidazione() != null && richiesta.getCodValidazione() == 1) { ret = false; } else { String crmCompetenza = richiesta.getCrmCompetenza(); boolean utenzaDbss = false; // X06 2016 - Integrazione con DBSS (nuovo sistema Retail) if (Resources.getDBSS_DONOR_ACTIVE()) { if(isUtenzaDBSS(crmCompetenza)){ log.write("9999", "isUtenzaDBSS: "+crmCompetenza+" DN:"+richiesta.getDn()+" Id-Richiesta: "+richiesta.getIdRichiesta()); callVerificaFase2DBSS(log,richiesta,dbssDonorOutRecDAO); utenzaDbss=true; } } UtilityDao utilityDao = new UtilityDao(); //PP X5.2010 - aggiunto controllo se multilinea if (utilityDao.isDnMultilinea(richiesta.getDn()) && crmCompetenza.equalsIgnoreCase("B") && !utenzaDbss) { log.write("9999", "DN BUSINESS MULTILINEA: DBCFX SIMULA LA NOTIFICA OK DA CRM"); //-- PASSAGGIO FORZATO IN PRESA IN CARICO ------------------- dao.merge(richiesta); logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.PRESA_IN_CARICO, log); //----------------------------------------------------------- //-- PASSAGGIO FORZATO IN ATTESA VERIFICA ------------------- RequestManagerDonor82.avanzaStatoInAttesaVerifica(richiesta.getCodiceSessione(), log); //----------------------------------------------------------- //-- PASSAGGIO FORZATO IN ACCETTATA ------------------------- RequestManagerDonor82.avanzaStatoInAccettata(richiesta, log); //----------------------------------------------------------- } else if (!utenzaDbss) { log.write("9999", "DN NON MULTILINEA"); //-- PASSAGGIO IN PRESA IN CARICO e INVIO NOTIFICA A CRM --- SistemaCrmIF crmController = ControllerFactory.getSistemaCRMDonor(crmCompetenza); crmController.notificaCRMDonor(richiesta.getIdRichiesta()); dao.merge(richiesta); logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.PRESA_IN_CARICO, log); //----------------------------------------------------------- } } } return ret; } else throw new StateTransitionNotPossibleException("StateTransitionNotPossibleException"); } protected static boolean callCheckRetailPlatform(GnpRichiesteDonor82 richiestaDonor,ProcessLogger log) throws Exception { log.write("9999", " START callCheckRetailPlatform : " +richiestaDonor.getIdRichiesta() + "DN: "+ richiestaDonor.getDn()); String methSig = "[RequestManagerDonor82].[callCheckRetailPlatform] "; boolean res=false; CheckRetailPlatformRequest body = new CheckRetailPlatformRequest(); body.setDN(richiestaDonor.getDn()); RetrieveByLineNumberResponseMessage resp = checkDN(body,log); res=gestisciResponseCheckRetail(methSig,resp,log,richiestaDonor); log.write("9999", " END callCheckRetailPlatform : " +richiestaDonor.getIdRichiesta() + "DN: "+ richiestaDonor.getDn()+ "con esito: "+res); return res; } private static boolean gestisciResponseCheckRetail(String methSig,RetrieveByLineNumberResponseMessage resp,ProcessLogger log,GnpRichiesteDonor82 richiestaDon) throws Exception { //return code puo' essere a una cifra o due (es. 01 o 1) int retCode = new Integer(resp.getProcessData().getReturnCode()); log.write("9999", " return code ricevuto da ws: " + retCode); boolean foundByWs = false; String crmComp = ""; switch (retCode) { //0 case (RET_CODE_OK_FROM_WS): //itera sui (tre) parameter, se ne trova uno con valore == 'Y' ne restituisce il name, altrimentii restituisce codice di errore Parameter[] params = resp.getProcessData().getParameters().getParameter(); for (Parameter p : params) { if (!("Y").equalsIgnoreCase(p.getValue())) { continue; //se diverso da Y passa al successivo } log.write("9999", methSig + " - trovato el. con val. = Y e name " + p.getName()); if (SystemControllerIF.SystemProvider_CRMB_DESC.equals(p.getName())) { crmComp = "B"; foundByWs = true; } else if (SystemControllerIF.SystemProvider_CRMR_DESC.equals(p.getName())) { // DISMISSIONE CRMR: nel caso la richiesta risulti proveniente da CRMR viene settato a D invece di R crmComp = "D"; foundByWs = true; } else if (SystemControllerIF.SystemProvider_DBSS_DESC.equals(p.getName())) { crmComp = "D"; foundByWs = true; } else { log.write("9999", methSig + " valore non previsto"); log.write("0002", methSig + " ws response return code: " + retCode); log.write("9999", methSig +" non avanza stato in rifiutato : " + retCode); log.write("9999", methSig +" PER RICHIESTA DI INGLISA VIENE SETTATO IL CRM DI COMPETENZA A B"); //MODIFICA INGLISA NEL CASO IN CUI NON TROVO IL CRM CONTATTO B //RequestManagerDonor.avanzaStatoInRifiutata(richiestaDon, "COW COR Errato", ApplicationCostants.PROCESSO_DONOR.OLO_OUT.COD_MOTIVO_COW_COR_ERRATO,true, log); crmComp = "B"; foundByWs = true; } } break; case (RET_CODE_UTENZA_NON_PRESENTE_FROM_WS): log.write("9999", methSig + " ws response return code [" + retCode + "] corrispondente a LINEA NON PRESENTE SU WS"+ "ANCHE SE DBSS RESTITUISCE UTENZA NON PRESENTE,PER RICHIESTA DI INGLISA VIENE SETTATO IL CRM DI COMPETENZA A B"); crmComp = "B"; foundByWs = true; //RequestManagerDonor.avanzaStatoInRifiutata(richiestaDon, "COW COR Errato", ApplicationCostants.PROCESSO_DONOR.OLO_OUT.COD_MOTIVO_COW_COR_ERRATO,true, log); break; case (RET_CODE_SERV_CRMB_NON_DISPONIBILE): case (RET_CODE_SERV_CRMR_NON_DISPONIBILE): case (RET_CODE_ERRORE_GENERICO_WS): log.write("0002", methSig + " ws response return code: " + retCode+ "corrispondente a un errore interno di CCC scrivo solo nella SCARTI CS"); buildScartiVerificaCs(richiestaDon,ANOMALIA_ERRORE_CODICE_SERVIZIO_CCC,ANOMALIA_ERRORE_CODICE_SERVIZIO_CCC_DESCRIZIONE+retCode,log); break; default: log.write("9999", methSig + " ws response return code [" + retCode + "] non previsto da interfaccia"); log.write("0002", methSig + " ws response return code: " + retCode+ "corrispondente a un errore interno di CCC"); buildScartiVerificaCs(richiestaDon,ANOMALIA_ERRORE_CODICE_SERVIZIO_NON_PREVISTO_CCC,ANOMALIA_ERRORE_CODICE_SERVIZIO_NON_PREVISTO_CCC_DESCRIZIONE+retCode,log); } if (foundByWs) { log.write("9999", methSig + " crm recuperato da DBSS e settato nella richiesta : " + crmComp); richiestaDon.setCrmCompetenza(crmComp); } return foundByWs; } private static void buildScartiVerificaCs(GnpRichiesteDonor82 richiestaDon,String tipoAnomalia,String descrizioneAnomalia,ProcessLogger log) { log.write("9999","START buildScartiVerificaCs DN: " + richiestaDon.getDn()+"Idrichiesta: "+richiestaDon.getIdRichiesta()); GnpScartiVerificaCsDAO scartiVerificaCsDao=new GnpScartiVerificaCsDAO(); GnpScartiVerificaCs scartiVerificaCs=new GnpScartiVerificaCs(); scartiVerificaCs.setIdRichiesta(richiestaDon.getIdRichiesta()); scartiVerificaCs.setDn(richiestaDon.getDn()); scartiVerificaCs.setTipoAnomalia(tipoAnomalia); scartiVerificaCs.setDescrizioneAnomalia(descrizioneAnomalia); scartiVerificaCs.setCodiceSegreto(richiestaDon.getCowDonating()); scartiVerificaCs.setDataInserimento(new Date()); scartiVerificaCsDao.merge(scartiVerificaCs); log.write("9999","END buildScartiVerificaCs DN: " + richiestaDon.getDn()+"Idrichiesta: "+richiestaDon.getIdRichiesta()); } /** * @version 4.1 20180417 migliorati i log */ public static RetrieveByLineNumberResponseMessage checkDN(CheckRetailPlatformRequest body,ProcessLogger log) throws Exception { String requestDn = body.getDN(); log.write("9999", "NowController RetrieveByLineNumberResponseMessage - Ricevuta richiesta DN ["+requestDn+"]"); CustomerLocationQueryClient client = new CustomerLocationQueryClient(); RetrieveByLineNumberRequestMessage requestMessage = new RetrieveByLineNumberRequestMessage(); Request_LineNumber request = new Request_LineNumber(); CharacteristicValueRequest_LineNumber characteristicValueRequest = new CharacteristicValueRequest_LineNumber(); characteristicValueRequest.setValue(lineValue); CharacteristicSpecificationRequest_LineNumber characteristicSpecification = new CharacteristicSpecificationRequest_LineNumber(); characteristicSpecification.setName(operationName); characteristicValueRequest.setCharacteristicSpecification(characteristicSpecification); CharacteristicValueRequest_LineNumber[] characteristicValueArray = {characteristicValueRequest}; request.setCharacteristicValue(characteristicValueArray); BusinessInteractionRelationship_LineNumber businessInteractionRelationship = new BusinessInteractionRelationship_LineNumber(); ProductOrderRequest_LineNumber productOrder = new ProductOrderRequest_LineNumber(); CustomerOrderItemRequest_LineNumber customerOrder = new CustomerOrderItemRequest_LineNumber(); ProductBundleRequest_LineNumber productBundle = new ProductBundleRequest_LineNumber(); ProductCharacteristicValueRequest_LineNumber productCharacteristic = new ProductCharacteristicValueRequest_LineNumber(); productCharacteristic.setValue(requestDn); ProductSpecCharacteristicRequest_LineNumber productSpecCharachteristic = new ProductSpecCharacteristicRequest_LineNumber(); productSpecCharachteristic.setName(serviceNumber); productCharacteristic.setProductSpecCharacteristic(productSpecCharachteristic); ProductCharacteristicValueRequest_LineNumber[] productCharacteristicValue = {productCharacteristic}; productBundle.setProductCharacteristicValue(productCharacteristicValue); customerOrder.setProductBundle(productBundle); CustomerOrderItemRequest_LineNumber[] customerOrderItem = {customerOrder}; productOrder.setCustomerOrderItem(customerOrderItem); businessInteractionRelationship.setProductOrder(productOrder); request.setBusinessInteractionRelationship(businessInteractionRelationship); requestMessage.setRequest(request); RetrieveByLineNumberResponseMessage retrieveByLineNumberResponseMessage = client.retrieveByLineNumber(requestMessage); String retCode = retrieveByLineNumberResponseMessage != null && retrieveByLineNumberResponseMessage.getProcessData() != null ? retrieveByLineNumberResponseMessage.getProcessData().getReturnCode() : null; log.write("9999", "NowController RetrieveByLineNumberResponseMessage Ottenuta risposta DN ["+requestDn+"] codice ["+retCode+"]"); String descr = retrieveByLineNumberResponseMessage != null && retrieveByLineNumberResponseMessage.getProcessData() != null ? retrieveByLineNumberResponseMessage.getProcessData().getReturnDescription() : null; log.write("9999", "NowController RetrieveByLineNumberResponseMessage Ottenuta risposta DN ["+requestDn+"] descrizione ["+descr+"]"); return retrieveByLineNumberResponseMessage; } /** * Passaggio di stato in PRESAINCARICO. *

* Ritorna false se il COW Donating non � mappato su uno di quelli Telecom * * @param richiesta * @param log * @return * @throws Exception */ public static boolean avanzaStatoInPresaInCaricoTool(GnpRichiesteDonor82 richiesta,String piattaformaCompetenza, ProcessLogger log) throws Exception { GnpRichiesteDonor82DAO dao = new GnpRichiesteDonor82DAO(); GnpCrmNotifyDonorOutDAO dbssDonorOutRecDAO = new GnpCrmNotifyDonorOutDAO(); boolean ret = true; //richiesta.setStato(new Long(StatoRichiestaDon.ACQUISITA)); //int check = StateManagerDonor.checkTransition(richiesta.getIdRichiesta(), StatoRichiestaDon.PRESA_IN_CARICO); int check=1; if (check != StateManagerDonor.TRANSIZIONE_NON_POSSIBILE) { int statoDa = richiesta.getStato().intValue(); richiesta.setStato((long) StatoRichiestaDon.PRESA_IN_CARICO); /* * * Penso che la presa in carico sia più corretta considerare la prima data e non questa * quindi non sovrascrivere la precedente */ //richiesta.setDataPresaincarico(new java.util.Date()); log.write("9999", "Verifica cs whitelist null"); // Ricerco nell'anagrafica il cow Donating ricevuto GnpAnagCowLineaTelecom anagCowLineaTelecom=null; GnpAnagCowLineaTelecomDAO cowLineaDao; GnpAnagCowTelecomDAO anagCowDAO = new GnpAnagCowTelecomDAO(); GnpAnagCowTelecom anagCowTelecom = anagCowDAO.findById(richiesta.getCowDonating()); //C09 2019 WA RICHIESTO ESCLUSIVAMENTE PER LA VERIFICA CS if(Resources.getFLAG_CHECK_ANAG_COW_LINEA()) { log.write("9999", "CONTROLLO SU TABELLA GNP_ANAG_COW_LINEA_TELECOM(FLAG WA ABILITATO) : "+richiesta.getIdRichiesta()+" COW: "+richiesta.getCowDonating()+" DN:"+richiesta.getDn()); cowLineaDao = new GnpAnagCowLineaTelecomDAO(); anagCowLineaTelecom = cowLineaDao.findByDnAndCowOld(richiesta.getDn(),richiesta.getCowDonating()); } //C09 2019 WA RICHIESTO ESCLUSIVAMENTE PER LA VERIFICA CS SE E' UGUALE A NULL IL PROCESSO RESTA INVARIATO if(anagCowLineaTelecom!=null) { log.write("9999", "TROVATA LINEA SU TABELLA GNP_ANAG_COW_LINEA_TELECOM(FLAG WA ABILITATO) : "+richiesta.getIdRichiesta()+" COW VECCHIO: "+richiesta.getCowDonating()+ " COW NUOVO:"+anagCowLineaTelecom.getCowNew()+" DN:"+richiesta.getDn()); anagCowTelecom=new GnpAnagCowTelecom(); anagCowTelecom.setCow(anagCowLineaTelecom.getCowNew()); richiesta.setCowDonating(anagCowLineaTelecom.getCowNew()); // salvo la richiesta con stato acquisita dao.save(richiesta); } // Se non trovo il cow nell'anagrafica: // 1)Aggiorno la tabella GNP_RICHIESTE_DONOR con cod_validazione = 1 // 2)Inserisco un record nella tabella GNP_OLO_RICHIESTE_DONOR_OUT if (anagCowTelecom == null) { ret = false; } else { log.write("9999", "Piattaforma notificata da BO : "+piattaformaCompetenza+" DN:"+richiesta.getDn()+" Id-Richiesta: "+richiesta.getIdRichiesta()); //Setto la piattaforma di competenza con quello del campo settato dal BO String crmCompetenza=piattaformaCompetenza; richiesta.setCrmCompetenza(crmCompetenza); boolean utenzaDbss = false; if(isUtenzaDBSS(piattaformaCompetenza)){ log.write("9999", "isUtenzaDBSS: "+piattaformaCompetenza+" DN:"+richiesta.getDn()+" Id-Richiesta: "+richiesta.getIdRichiesta()); if (Resources.getDBSS_DONOR_ACTIVE()) { callVerificaFase2DBSS(log,richiesta,dbssDonorOutRecDAO); utenzaDbss=true; } } // X06 2016 - Integrazione con DBSS (nuovo sistema Retail) UtilityDao utilityDao = new UtilityDao(); //PP X5.2010 - aggiunto controllo se multilinea if (utilityDao.isDnMultilinea(richiesta.getDn()) && crmCompetenza.equalsIgnoreCase("B") && !utenzaDbss) { log.write("9999", "DN BUSINESS MULTILINEA: DBCFX SIMULA LA NOTIFICA OK DA CRM"); //-- PASSAGGIO FORZATO IN PRESA IN CARICO ------------------- dao.merge(richiesta); logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.PRESA_IN_CARICO, log); //----------------------------------------------------------- //-- PASSAGGIO FORZATO IN ATTESA VERIFICA ------------------- RequestManagerDonor82.avanzaStatoInAttesaVerifica(richiesta.getCodiceSessione(), log); //----------------------------------------------------------- //-- PASSAGGIO FORZATO IN ACCETTATA ------------------------- RequestManagerDonor82.avanzaStatoInAccettata(richiesta, log); //----------------------------------------------------------- } else if (!utenzaDbss) { log.write("9999", "DN NON MULTILINEA"); //-- PASSAGGIO IN PRESA IN CARICO e INVIO NOTIFICA A CRM --- SistemaCrmIF crmController = ControllerFactory.getSistemaCRMDonor(crmCompetenza); crmController.notificaCRMDonor(richiesta.getIdRichiesta()); dao.merge(richiesta); logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.PRESA_IN_CARICO, log); //----------------------------------------------------------- } } return ret; } else throw new StateTransitionNotPossibleException("StateTransitionNotPossibleException"); } private static void callVerificaFase2DBSS(ProcessLogger log, GnpRichiesteDonor82 richiesta, GnpCrmNotifyDonorOutDAO dbssDonorOutRecDAO) throws Exception { log.write("9999", "START Chiamata al WS WirelineLineCodeQuery DBSS DN:["+richiesta.getDn()+"]"); // chiamata al WS WirelineLineCodeQuery DBSSController dbssController = DBSSController.getInstance(); GnpCrmNotifyDonorOut dbssDonorOut = dbssController.creaRichiestaVerificaFase2(richiesta); WirelineCeaseCheck82ResponseType dbssResponse = dbssController.callNotificaDbssD82(dbssDonorOut); String esito = null; if (dbssResponse != null) { esito = dbssResponse.getProcessData().getReturnDescription(); dbssDonorOutRecDAO.save(dbssDonorOut); log.write("9999", "Esito sincrono chiamata: " + esito); }else { log.write("9999", "Risposta vuota non gestita: "+richiesta.getCrmCompetenza()+" DN:"+richiesta.getDn()+" Id-Richiesta: "+richiesta.getIdRichiesta()); buildScartiVerificaCs(richiesta,VERIFICA_CS_DBSS_ESITO_NON_GESTITO,VERIFICA_CS_DBSS_ESITO_NON_GESTITO_DESCRIZIONE,log); } log.write("9999", "END Chiamata al WS WirelineLineCodeQuery DBSS DN:["+richiesta.getDn()+"]"); } public static void callNotificaFase3DBSS(ProcessLogger log, GnpRichiesteDonor82 richiesta, GnpCrmNotifyDonorOutDAO dbssDonorOutRecDAO, GnpNowD82RichiesteOut nowDonorOut) throws Exception { log.write("9999", "START Chiamata al WS WirelineLineCodeQuery DBSS DN:["+richiesta.getDn()+"]"); // chiamata al WS WirelineLineCodeQuery DBSSController dbssController = DBSSController.getInstance(); GnpCrmNotifyDonorOut dbssDonorOut = dbssController.creaNotificaEsitoN9(richiesta, nowDonorOut); WirelineCeaseCheck82ResponseType dbssResponse = dbssController.callNotificaDbssD82(dbssDonorOut); String esito = null; if (dbssResponse != null) { esito = dbssResponse.getProcessData().getReturnDescription(); dbssDonorOutRecDAO.save(dbssDonorOut); log.write("9999", "Esito sincrono chiamata: " + esito); }else { log.write("9999", "Risposta vuota non gestita: "+richiesta.getCrmCompetenza()+" DN:"+richiesta.getDn()+" Id-Richiesta: "+richiesta.getIdRichiesta()); //buildScartiVerificaCs(richiesta,VERIFICA_CS_DBSS_ESITO_NON_GESTITO,VERIFICA_CS_DBSS_ESITO_NON_GESTITO_DESCRIZIONE,log); } log.write("9999", "END Chiamata al WS WirelineLineCodeQuery DBSS DN:["+richiesta.getDn()+"]"); } private static boolean isUtenzaDBSS(String piattaforma) { return "D".equalsIgnoreCase(piattaforma); } public static void avanzaStatoInPresaInCaricoKO(GnpRichiesteDonor82 richiesta, ProcessLogger log) throws Exception { GnpRichiesteDonor82DAO dao = new GnpRichiesteDonor82DAO(); int check = StateManagerDonor.checkTransition(richiesta.getIdRichiesta(), StatoRichiestaDon.PRESA_IN_CARICO_KO); if (check != StateManagerDonor.TRANSIZIONE_NON_POSSIBILE) { int statoDa = richiesta.getStato().intValue(); richiesta.setStato(new Long(StatoRichiestaDon.PRESA_IN_CARICO_KO)); dao.merge(richiesta); logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.PRESA_IN_CARICO_KO, log); } else throw new StateTransitionNotPossibleException("StateTransitionNotPossibleException"); } public static void passaggioStatoScaduta(GnpRichiesteDonor82 richiesta, ProcessLogger log) throws Exception { GnpRichiesteDonor82DAO ricDonorDAO = new GnpRichiesteDonor82DAO(); // IMPOSTA LO STATO IN SCADUTA int statoDa = richiesta.getStato().intValue(); richiesta.setStato(new Long(StatoRichiestaDon.SCADUTA)); ricDonorDAO.merge(richiesta); RequestManagerDonor82.logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.SCADUTA, log); } public static void avanzaStatoInAttesaVerifica(String codiceSessione, ProcessLogger log) throws Exception { GnpRichiesteDonor82DAO dao = new GnpRichiesteDonor82DAO(); GnpRichiesteDonor82 richiesta = dao.findByCodiceSessione(codiceSessione); if (richiesta == null) throw new Exception("Richiesta con codice sessione " + codiceSessione + " non trovata"); int statoDa = StateManagerDonor.checkTransition(richiesta.getIdRichiesta(), StatoRichiestaDon.ATTESA_VERIFICA); if (statoDa != StateManagerDonor.TRANSIZIONE_NON_POSSIBILE) { richiesta.setStato(new Long(StatoRichiestaDon.ATTESA_VERIFICA)); dao.merge(richiesta); logStoricoPassaggioStato(richiesta.getIdRichiesta(), statoDa, StatoRichiestaDon.ATTESA_VERIFICA, log); } else throw new StateTransitionNotPossibleException("StateTransitionNotPossibleException"); } }