Skip to content

Commit

Permalink
Scartato il caso di rifiuto da parte di SDI delle fatture passive per…
Browse files Browse the repository at this point in the history
… la notifica esito già pervenuta
  • Loading branch information
gianfranco.gasparro committed Apr 30, 2015
1 parent 8b90f39 commit 92d8bcb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
Expand Up @@ -249,6 +249,7 @@ private void notificaFatturaPassivaScartoEsito(Message message, String userName)
if (headerMessage != null){
String messageID = Arrays.asList(headerMessage).toString();
String messageIDWithUser = userName + " "+messageID;
logger.info("MessageIDWithUser " + messageIDWithUser);
if (!listaMessageIdAlreadyScanned.contains(messageIDWithUser)){
logger.info(messageIDWithUser);
try {
Expand Down Expand Up @@ -277,6 +278,7 @@ private void notificaFatturaPassivaScartoEsito(Message message, String userName)
SendMail.sendErrorMail("Fatture Elettroniche: Passive: Scarto Esito. Allegati non conformi. Mail:"+userName, message.getDescription());
}
listaMessageIdAlreadyScanned.add(messageIDWithUser);
logger.info("Message Added");
} catch (Exception e) {
logger.error("PEC scan error while importing file.", e);
}
Expand Down Expand Up @@ -405,12 +407,14 @@ private void processingMailFromHostPec(Folder folder, String userName) throws Me
if (headerMessage != null){
String messageID = Arrays.asList(headerMessage).toString();
String messageIDWithUser = userName + " "+messageID;
if (!listaMessageIdAlreadyScanned.contains(messageIDWithUser)){
logger.info("MessageIDWithUser " + messageIDWithUser);
if (!listaMessageIdAlreadyScanned.contains(messageIDWithUser)){
logger.info(messageIDWithUser);
String identificativoSdi = message.getSubject().substring(getSubjectTermForFatturaPassivaPec().length() + 1 );
if (identificativoSdi != null){
ricezioneFattureService.notificaFatturaPassivaConsegnaEsitoPec(identificativoSdi.trim(), message.getSentDate());
listaMessageIdAlreadyScanned.add(messageIDWithUser);
logger.info("Message Added");
}
}
}
Expand Down
Expand Up @@ -966,41 +966,47 @@ public void notificaScartoEsito(String nomeFile, DataHandler data) throws Compon
ScartoEsitoCommittenteType scartoEsito = fileScartoEsito.getValue();
Long identificativoSdi = scartoEsito.getIdentificativoSdI().longValue();
LOGGER.info("Fatture Elettroniche: Passive: Pec: Scarto Esito Id SDI: "+identificativoSdi);
List<DocumentoEleTestataBulk> docs = component.recuperoDocumento(userContext, identificativoSdi);
if (docs != null && !docs.isEmpty()){
Boolean docsDaAggiornare = false;
for (DocumentoEleTestataBulk doc : docs) {
if (!StringUtils.isEmpty(doc.getStatoNotificaEsito()) && doc.getStatoNotificaEsito().equals(DocumentoEleTestataBulk.STATO_CONSEGNA_ESITO_SCARTATO_SDI)){
LOGGER.info("Fatture Elettroniche: Passive: Pec: Scarto Esito. Fattura già elaborata ");
} else {
docsDaAggiornare = true;
List<DocumentoEleTrasmissioneBulk> trasms = component.recuperoTrasmissione(userContext, identificativoSdi);
for (DocumentoEleTrasmissioneBulk trasm : trasms) {
saveNotifica(data, nomeFile, trasm.getCmisNodeRef(), CMISDocAmmAspect.SIGLA_FATTURE_ATTACHMENT_SCARTO);
break;
if (scartoEsito.getNote() != null && scartoEsito.getNote().startsWith("EN02: Notifica di esito già pervenuta as Sistema di Interscambio")){
LOGGER.info("Id SDI: "+identificativoSdi + ". "+scartoEsito.getNote());
} else {
List<DocumentoEleTestataBulk> docs = component.recuperoDocumento(userContext, identificativoSdi);
if (docs != null && !docs.isEmpty()){
Boolean docsDaAggiornare = false;
for (DocumentoEleTestataBulk doc : docs) {
if (!StringUtils.isEmpty(doc.getStatoNotificaEsito()) && doc.getStatoNotificaEsito().equals(DocumentoEleTestataBulk.STATO_CONSEGNA_ESITO_SCARTATO_SDI)){
LOGGER.info("Fatture Elettroniche: Passive: Pec: Scarto Esito. Fattura già elaborata ");
} else {
docsDaAggiornare = true;
List<DocumentoEleTrasmissioneBulk> trasms = component.recuperoTrasmissione(userContext, identificativoSdi);
for (DocumentoEleTrasmissioneBulk trasm : trasms) {
saveNotifica(data, nomeFile, trasm.getCmisNodeRef(), CMISDocAmmAspect.SIGLA_FATTURE_ATTACHMENT_SCARTO);
break;
}
}
break;
}
break;
}
if (docsDaAggiornare){
try{
component.aggiornaScartoEsitoPec(userContext, docs);
LOGGER.info("Fatture Elettroniche: Passive: Pec: aggiornamento scarto esito con id SDI "+identificativoSdi);
} catch (Exception ex) {
LOGGER.error("Fatture Elettroniche: Passive: Pec: Errore nell'elaborazione dello scarto esito con id SDI "+identificativoSdi + ". Errore:" +ex.getMessage() == null ? (ex.getCause() == null ? "" : ex.getCause().toString()):ex.getMessage());
java.io.StringWriter sw = new java.io.StringWriter();
ex.printStackTrace(new java.io.PrintWriter(sw));
SendMail.sendErrorMail("Fatture Elettroniche: Passive: Pec: Scarto esito. Id SDI "+identificativoSdi, sw.toString());
if (docsDaAggiornare){
try{
component.aggiornaScartoEsitoPec(userContext, docs);
LOGGER.info("Fatture Elettroniche: Passive: Pec: aggiornamento scarto esito con id SDI "+identificativoSdi);
SendMail.sendErrorMail("Fatture Elettroniche: Passive: E' stato ricevuto uno scarto dell'esito per l'Id SDI."+ identificativoSdi, "Fattura Passiva: Scarto Esito. Id SDI "+identificativoSdi);
} catch (Exception ex) {
LOGGER.error("Fatture Elettroniche: Passive: Pec: Errore nell'elaborazione dello scarto esito con id SDI "+identificativoSdi + ". Errore:" +ex.getMessage() == null ? (ex.getCause() == null ? "" : ex.getCause().toString()):ex.getMessage());
java.io.StringWriter sw = new java.io.StringWriter();
ex.printStackTrace(new java.io.PrintWriter(sw));
SendMail.sendErrorMail("Fatture Elettroniche: Passive: Pec: Scarto esito. Id SDI "+identificativoSdi, sw.toString());
}
}
} else {
LOGGER.warn("Fatture Elettroniche: Passive: Pec: Per l'identificativo SDI indicato nel file dell'e-mail non corrisponde nessun documento." + identificativoSdi);
SendMail.sendErrorMail("Fatture Elettroniche: Passive: Pec: Per l'identificativo SDI del file inviato indicato nel file dell'e-mail non corrisponde nessuna fattura", "Scarto Esito. Id SDI "+identificativoSdi);
}
} else {
LOGGER.warn("Fatture Elettroniche: Passive: Pec: Per l'identificativo SDI indicato nel file dell'e-mail non corrisponde nessun documento." + identificativoSdi);
SendMail.sendErrorMail("Fatture Elettroniche: Passive: Pec: Per l'identificativo SDI del file inviato indicato nel file dell'e-mail non corrisponde nessuna fattura", "Scarto Esito. Id SDI "+identificativoSdi);
}
} catch (Exception e) {
throw new ComponentException(e);
}
}

private UserContext createUserContext() {
UserContext userContext = new WSUserContext("SDI",null,new Integer(java.util.Calendar.getInstance().get(java.util.Calendar.YEAR)),null,null,null);
return userContext;
Expand Down

0 comments on commit 92d8bcb

Please sign in to comment.