First Commit - Source Code from Reply
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
@@ -0,0 +1,8 @@
|
||||
#Thu Feb 19 09:31:27 CET 2009
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
fullBuildGoals=process-test-resources
|
||||
includeModules=false
|
||||
resolveWorkspaceProjects=true
|
||||
resourceFilterGoals=process-resources resources\:testResources
|
||||
version=1
|
||||
64
dbcmnpsrc/FE/mnpdev/dbcgo/dbcgoBusiness/pom.xml
Normal file
64
dbcmnpsrc/FE/mnpdev/dbcgo/dbcgoBusiness/pom.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>dbcgoBusiness</groupId>
|
||||
<artifactId>dbcgoBusiness</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>dbcgoBusiness</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.jexcelapi</groupId>
|
||||
<artifactId>jxl</artifactId>
|
||||
<version>2.6.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dbcgoModel</groupId>
|
||||
<artifactId>dbcgoModel</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dbcgom</groupId>
|
||||
<artifactId>dbcgom</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ojdbc</groupId>
|
||||
<artifactId>ojdbc</artifactId>
|
||||
<version>14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,55 @@
|
||||
package it.valueteam.dbcgo.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DonorQuadraturaBean {
|
||||
|
||||
private String idOperatore;
|
||||
private String idOperatoreVirtuale;
|
||||
private String dataDal;
|
||||
private String dataAl;
|
||||
private List listaDati;
|
||||
|
||||
|
||||
public List getListaDati() {
|
||||
return listaDati;
|
||||
}
|
||||
|
||||
public void setListaDati(List listaDati) {
|
||||
this.listaDati = listaDati;
|
||||
}
|
||||
|
||||
public DonorQuadraturaBean(){}
|
||||
|
||||
public String getIdOperatore() {
|
||||
return idOperatore;
|
||||
}
|
||||
|
||||
public void setIdOperatore(String idOperatore) {
|
||||
this.idOperatore = idOperatore;
|
||||
}
|
||||
|
||||
public String getIdOperatoreVirtuale() {
|
||||
return idOperatoreVirtuale;
|
||||
}
|
||||
|
||||
public void setIdOperatoreVirtuale(String idOperatoreVirtuale) {
|
||||
this.idOperatoreVirtuale = idOperatoreVirtuale;
|
||||
}
|
||||
|
||||
public String getDataDal() {
|
||||
return dataDal;
|
||||
}
|
||||
|
||||
public void setDataDal(String dataDal) {
|
||||
this.dataDal = dataDal;
|
||||
}
|
||||
|
||||
public String getDataAl() {
|
||||
return dataAl;
|
||||
}
|
||||
|
||||
public void setDataAl(String dataAl) {
|
||||
this.dataAl = dataAl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package it.valueteam.dbcgo.bean;
|
||||
|
||||
public class FunzioneWebBean {
|
||||
|
||||
private int id;
|
||||
private int idPadre;
|
||||
private String nome;
|
||||
private String comando;
|
||||
private String descrizione;
|
||||
private int ordine;
|
||||
|
||||
public FunzioneWebBean(){}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public int getIdPadre() {
|
||||
return idPadre;
|
||||
}
|
||||
public void setIdPadre(int idPadre) {
|
||||
this.idPadre = idPadre;
|
||||
}
|
||||
public String getNome() {
|
||||
return nome;
|
||||
}
|
||||
public void setNome(String nome) {
|
||||
this.nome = nome;
|
||||
}
|
||||
public String getComando() {
|
||||
return comando;
|
||||
}
|
||||
public void setComando(String comando) {
|
||||
this.comando = comando;
|
||||
}
|
||||
public String getDescrizione() {
|
||||
return descrizione;
|
||||
}
|
||||
public void setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
}
|
||||
public int getOrdine() {
|
||||
return ordine;
|
||||
}
|
||||
public void setOrdine(int ordine) {
|
||||
this.ordine = ordine;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.valueteam.dbcgo.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemMenuBean {
|
||||
FunzioneWebBean itemPrincipale;
|
||||
List itemSecondari;
|
||||
|
||||
public ItemMenuBean(){}
|
||||
|
||||
public FunzioneWebBean getItemPrincipale() {
|
||||
return itemPrincipale;
|
||||
}
|
||||
|
||||
public void setItemPrincipale(FunzioneWebBean itemPrincipale) {
|
||||
this.itemPrincipale = itemPrincipale;
|
||||
}
|
||||
|
||||
public List getItemSecondari() {
|
||||
return itemSecondari;
|
||||
}
|
||||
|
||||
public void setItemSecondari(List itemSecondari) {
|
||||
this.itemSecondari = itemSecondari;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package it.valueteam.dbcgo.bean;
|
||||
|
||||
public class RecipientQuadraturaBean {
|
||||
|
||||
private String idOperatore;
|
||||
private String idOperatoreVirtuale;
|
||||
private String dataDal;
|
||||
private String dataAl;
|
||||
private String idTipoCliente;
|
||||
private String idTipoContratto;
|
||||
|
||||
public RecipientQuadraturaBean(){}
|
||||
|
||||
public String getIdOperatore() {
|
||||
return idOperatore;
|
||||
}
|
||||
|
||||
public void setIdOperatore(String idOperatore) {
|
||||
this.idOperatore = idOperatore;
|
||||
}
|
||||
|
||||
public String getIdOperatoreVirtuale() {
|
||||
return idOperatoreVirtuale;
|
||||
}
|
||||
|
||||
public void setIdOperatoreVirtuale(String idOperatoreVirtuale) {
|
||||
this.idOperatoreVirtuale = idOperatoreVirtuale;
|
||||
}
|
||||
|
||||
public String getDataDal() {
|
||||
return dataDal;
|
||||
}
|
||||
|
||||
public void setDataDal(String dataDal) {
|
||||
this.dataDal = dataDal;
|
||||
}
|
||||
|
||||
public String getDataAl() {
|
||||
return dataAl;
|
||||
}
|
||||
|
||||
public void setDataAl(String dataAl) {
|
||||
this.dataAl = dataAl;
|
||||
}
|
||||
|
||||
|
||||
public String getIdTipoCliente() {
|
||||
return idTipoCliente;
|
||||
}
|
||||
|
||||
public void setIdTipoCliente(String idTipoCliente) {
|
||||
this.idTipoCliente = idTipoCliente;
|
||||
}
|
||||
|
||||
public String getIdTipoContratto() {
|
||||
return idTipoContratto;
|
||||
}
|
||||
|
||||
public void setIdTipoContratto(String idTipoContratto) {
|
||||
this.idTipoContratto = idTipoContratto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package it.valueteam.dbcgo.bean.excel;
|
||||
|
||||
import jxl.CellType;
|
||||
|
||||
public class CellaExcel {
|
||||
boolean isIntestazione = false;
|
||||
CellType tipo = null;
|
||||
String contents = null;
|
||||
|
||||
public CellType getTipo() {
|
||||
return tipo;
|
||||
}
|
||||
|
||||
public void setTipo(CellType tipo) {
|
||||
this.tipo = tipo;
|
||||
}
|
||||
|
||||
public String getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public void setContents(String contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public boolean isIntestazione() {
|
||||
return isIntestazione;
|
||||
}
|
||||
|
||||
public void setIntestazione(boolean intestazione) {
|
||||
isIntestazione = intestazione;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package it.valueteam.dbcgo.bean.excel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RigaExcel {
|
||||
boolean isIntestazione = false;
|
||||
List colonne = null;
|
||||
|
||||
public boolean isIntestazione() {
|
||||
return isIntestazione;
|
||||
}
|
||||
|
||||
public void setIntestazione(boolean intestazione) {
|
||||
isIntestazione = intestazione;
|
||||
}
|
||||
|
||||
public List getColonne() {
|
||||
return colonne;
|
||||
}
|
||||
|
||||
public void setColonne(List colonne) {
|
||||
this.colonne = colonne;
|
||||
}
|
||||
|
||||
public void addCella(CellaExcel cella) {
|
||||
if (this.colonne == null) {
|
||||
colonne = new ArrayList();
|
||||
}
|
||||
colonne.add(cella);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package it.valueteam.dbcgo.bean.excel;
|
||||
|
||||
public class RigaExcelReportSintesi {
|
||||
boolean isRecipient = true;
|
||||
String operatore;
|
||||
String trimestre;
|
||||
// Utilizzato solamente nella sintesi mensile
|
||||
String meseRiferimento;
|
||||
String anno;
|
||||
String tipoSla;
|
||||
String sla;
|
||||
|
||||
// Attributi presi calcolati da step1
|
||||
Double caricato = new Double(0);
|
||||
// Attributi presi calcolati da step2
|
||||
Double nonFattDisservizi = new Double(0);
|
||||
Double nonFattFranchigia = new Double(0);
|
||||
Double nonFattAltreCausali = new Double(0);
|
||||
|
||||
// Attributi presi calcolati da step4
|
||||
Double contestato = new Double(0);
|
||||
Double contestatoAccettata = new Double(0);
|
||||
Double contestatoRespinta = new Double(0);
|
||||
|
||||
// Attributo valido solo per ambito DONOR
|
||||
Double fatturato = new Double(0);
|
||||
|
||||
String stato;
|
||||
|
||||
public boolean isRecipient() {
|
||||
return isRecipient;
|
||||
}
|
||||
|
||||
public void setRecipient(boolean recipient) {
|
||||
isRecipient = recipient;
|
||||
}
|
||||
|
||||
public String getOperatore() {
|
||||
return operatore;
|
||||
}
|
||||
|
||||
public void setOperatore(String operatore) {
|
||||
this.operatore = operatore;
|
||||
}
|
||||
|
||||
public String getTrimestre() {
|
||||
return trimestre;
|
||||
}
|
||||
|
||||
public void setTrimestre(String trimestre) {
|
||||
this.trimestre = trimestre;
|
||||
}
|
||||
|
||||
public String getAnno() {
|
||||
return anno;
|
||||
}
|
||||
|
||||
public void setAnno(String anno) {
|
||||
this.anno = anno;
|
||||
}
|
||||
|
||||
public String getTipoSla() {
|
||||
return tipoSla;
|
||||
}
|
||||
|
||||
public void setTipoSla(String tipoSla) {
|
||||
this.tipoSla = tipoSla;
|
||||
}
|
||||
|
||||
public Double getCaricato() {
|
||||
return caricato;
|
||||
}
|
||||
|
||||
public void setCaricato(Double caricato) {
|
||||
this.caricato = caricato;
|
||||
}
|
||||
|
||||
public Double getNonFattDisservizi() {
|
||||
return nonFattDisservizi;
|
||||
}
|
||||
|
||||
public void setNonFattDisservizi(Double nonFattDisservizi) {
|
||||
this.nonFattDisservizi = nonFattDisservizi;
|
||||
}
|
||||
|
||||
public Double getNonFattFranchigia() {
|
||||
return nonFattFranchigia;
|
||||
}
|
||||
|
||||
public void setNonFattFranchigia(Double nonFattFranchigia) {
|
||||
this.nonFattFranchigia = nonFattFranchigia;
|
||||
}
|
||||
|
||||
public Double getNonFattAltreCausali() {
|
||||
return nonFattAltreCausali;
|
||||
}
|
||||
|
||||
public void setNonFattAltreCausali(Double nonFattAltreCausali) {
|
||||
this.nonFattAltreCausali = nonFattAltreCausali;
|
||||
}
|
||||
|
||||
public Double getContestato() {
|
||||
return contestato;
|
||||
}
|
||||
|
||||
public void setContestato(Double contestato) {
|
||||
this.contestato = contestato;
|
||||
}
|
||||
|
||||
public Double getContestatoAccettata() {
|
||||
return contestatoAccettata;
|
||||
}
|
||||
|
||||
public void setContestatoAccettata(Double contestatoAccettata) {
|
||||
this.contestatoAccettata = contestatoAccettata;
|
||||
}
|
||||
|
||||
public Double getContestatoRespinta() {
|
||||
return contestatoRespinta;
|
||||
}
|
||||
|
||||
public void setContestatoRespinta(Double contestatoRespinta) {
|
||||
this.contestatoRespinta = contestatoRespinta;
|
||||
}
|
||||
|
||||
public Double getFatturato() {
|
||||
return fatturato;
|
||||
}
|
||||
|
||||
public void setFatturato(Double fatturato) {
|
||||
this.fatturato = fatturato;
|
||||
}
|
||||
|
||||
public String getSla() {
|
||||
return sla;
|
||||
}
|
||||
|
||||
public void setSla(String sla) {
|
||||
this.sla = sla;
|
||||
}
|
||||
|
||||
public String getMeseRiferimento() {
|
||||
return meseRiferimento;
|
||||
}
|
||||
|
||||
public void setMeseRiferimento(String meseRiferimento) {
|
||||
this.meseRiferimento = meseRiferimento;
|
||||
}
|
||||
|
||||
public String getStato() {
|
||||
return stato;
|
||||
}
|
||||
|
||||
public void setStato(String stato) {
|
||||
this.stato = stato;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package it.valueteam.dbcgo.bean.excel;
|
||||
|
||||
public class RigaExcelStep3Sintesi {
|
||||
boolean isPenaleAltroAom = false;
|
||||
Double importoPrimoMese = new Double(0);
|
||||
Double importoPrimoMesePenaleTrue = new Double(0);
|
||||
Double importoPrimoMesePenaleFalse = new Double(0);
|
||||
Double importoSecondoMese = new Double(0);
|
||||
Double importoSecondoMesePenaleTrue = new Double(0);
|
||||
Double importoSecondoMesePenaleFalse = new Double(0);
|
||||
Double importoTerzoMese = new Double(0);
|
||||
Double importoTerzoMesePenaleTrue = new Double(0);
|
||||
Double importoTerzoMesePenaleFalse = new Double(0);
|
||||
Double importoDisservizi = new Double(0);
|
||||
Double importoDisserviziPenaleTrue = new Double(0);
|
||||
Double importoDisserviziPenaleFalse = new Double(0);
|
||||
Double importoFranchigie = new Double(0);
|
||||
Double importoFranchigiePenaleTrue = new Double(0);
|
||||
Double importoFranchigiePenaleFalse = new Double(0);
|
||||
|
||||
public boolean isPenaleAltroAom() {
|
||||
return isPenaleAltroAom;
|
||||
}
|
||||
|
||||
public void setPenaleAltroAom(boolean penaleAltroAom) {
|
||||
isPenaleAltroAom = penaleAltroAom;
|
||||
}
|
||||
|
||||
public Double getImportoPrimoMese() {
|
||||
return importoPrimoMese;
|
||||
}
|
||||
|
||||
public void setImportoPrimoMese(Double importoPrimoMese) {
|
||||
this.importoPrimoMese = importoPrimoMese;
|
||||
}
|
||||
|
||||
public Double getImportoPrimoMesePenaleTrue() {
|
||||
return importoPrimoMesePenaleTrue;
|
||||
}
|
||||
|
||||
public void setImportoPrimoMesePenaleTrue(Double importoPrimoMesePenaleTrue) {
|
||||
this.importoPrimoMesePenaleTrue = importoPrimoMesePenaleTrue;
|
||||
}
|
||||
|
||||
public Double getImportoPrimoMesePenaleFalse() {
|
||||
return importoPrimoMesePenaleFalse;
|
||||
}
|
||||
|
||||
public void setImportoPrimoMesePenaleFalse(Double importoPrimoMesePenaleFalse) {
|
||||
this.importoPrimoMesePenaleFalse = importoPrimoMesePenaleFalse;
|
||||
}
|
||||
|
||||
public Double getImportoSecondoMese() {
|
||||
return importoSecondoMese;
|
||||
}
|
||||
|
||||
public void setImportoSecondoMese(Double importoSecondoMese) {
|
||||
this.importoSecondoMese = importoSecondoMese;
|
||||
}
|
||||
|
||||
public Double getImportoSecondoMesePenaleTrue() {
|
||||
return importoSecondoMesePenaleTrue;
|
||||
}
|
||||
|
||||
public void setImportoSecondoMesePenaleTrue(Double importoSecondoMesePenaleTrue) {
|
||||
this.importoSecondoMesePenaleTrue = importoSecondoMesePenaleTrue;
|
||||
}
|
||||
|
||||
public Double getImportoSecondoMesePenaleFalse() {
|
||||
return importoSecondoMesePenaleFalse;
|
||||
}
|
||||
|
||||
public void setImportoSecondoMesePenaleFalse(Double importoSecondoMesePenaleFalse) {
|
||||
this.importoSecondoMesePenaleFalse = importoSecondoMesePenaleFalse;
|
||||
}
|
||||
|
||||
public Double getImportoTerzoMese() {
|
||||
return importoTerzoMese;
|
||||
}
|
||||
|
||||
public void setImportoTerzoMese(Double importoTerzoMese) {
|
||||
this.importoTerzoMese = importoTerzoMese;
|
||||
}
|
||||
|
||||
public Double getImportoTerzoMesePenaleTrue() {
|
||||
return importoTerzoMesePenaleTrue;
|
||||
}
|
||||
|
||||
public void setImportoTerzoMesePenaleTrue(Double importoTerzoMesePenaleTrue) {
|
||||
this.importoTerzoMesePenaleTrue = importoTerzoMesePenaleTrue;
|
||||
}
|
||||
|
||||
public Double getImportoTerzoMesePenaleFalse() {
|
||||
return importoTerzoMesePenaleFalse;
|
||||
}
|
||||
|
||||
public void setImportoTerzoMesePenaleFalse(Double importoTerzoMesePenaleFalse) {
|
||||
this.importoTerzoMesePenaleFalse = importoTerzoMesePenaleFalse;
|
||||
}
|
||||
|
||||
public Double getImportoDisservizi() {
|
||||
return importoDisservizi;
|
||||
}
|
||||
|
||||
public void setImportoDisservizi(Double importoDisservizi) {
|
||||
this.importoDisservizi = importoDisservizi;
|
||||
}
|
||||
|
||||
public Double getImportoDisserviziPenaleTrue() {
|
||||
return importoDisserviziPenaleTrue;
|
||||
}
|
||||
|
||||
public void setImportoDisserviziPenaleTrue(Double importoDisserviziPenaleTrue) {
|
||||
this.importoDisserviziPenaleTrue = importoDisserviziPenaleTrue;
|
||||
}
|
||||
|
||||
public Double getImportoDisserviziPenaleFalse() {
|
||||
return importoDisserviziPenaleFalse;
|
||||
}
|
||||
|
||||
public void setImportoDisserviziPenaleFalse(Double importoDisserviziPenaleFalse) {
|
||||
this.importoDisserviziPenaleFalse = importoDisserviziPenaleFalse;
|
||||
}
|
||||
|
||||
public Double getImportoFranchigie() {
|
||||
return importoFranchigie;
|
||||
}
|
||||
|
||||
public void setImportoFranchigie(Double importoFranchigie) {
|
||||
this.importoFranchigie = importoFranchigie;
|
||||
}
|
||||
|
||||
public Double getImportoFranchigiePenaleTrue() {
|
||||
return importoFranchigiePenaleTrue;
|
||||
}
|
||||
|
||||
public void setImportoFranchigiePenaleTrue(Double importoFranchigiePenaleTrue) {
|
||||
this.importoFranchigiePenaleTrue = importoFranchigiePenaleTrue;
|
||||
}
|
||||
|
||||
public Double getImportoFranchigiePenaleFalse() {
|
||||
return importoFranchigiePenaleFalse;
|
||||
}
|
||||
|
||||
public void setImportoFranchigiePenaleFalse(Double importoFranchigiePenaleFalse) {
|
||||
this.importoFranchigiePenaleFalse = importoFranchigiePenaleFalse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
package it.valueteam.dbcgo.bean.excel;
|
||||
|
||||
public class RigaExcelStep4Donor {
|
||||
private String checkFatturazione;
|
||||
private String causaleStorno;
|
||||
private String giorniDaCorrispondere;
|
||||
private String importoDaCorrispondereAOM;
|
||||
private String importoDaCorrispondereTIM;
|
||||
private String soggettoAFranchigia;
|
||||
private String donatingOspitato;
|
||||
private String recipientOspitato;
|
||||
private String donatingRete;
|
||||
private String recipientRete;
|
||||
private String MSISDN;
|
||||
private String codiceRichiestaRecipient;
|
||||
private String dataInvioRicezioneFileEventoIniziale;
|
||||
private String nomeFileEventoIniziale;
|
||||
private String ackEventoIniziale;
|
||||
private String dataInvioRicezioneFileEventoFinale;
|
||||
private String nomeFileEventoFinale;
|
||||
private String ackEventoFinale;
|
||||
private String dataAttesaEventoFinale;
|
||||
private String giorniRitardoSolari;
|
||||
private String importo;
|
||||
private String meseCompetenzaEventoFinale;
|
||||
private String tipoSla;
|
||||
private String flagPenaleAltroOperatore;
|
||||
|
||||
public String getCheckFatturazione() {
|
||||
return checkFatturazione;
|
||||
}
|
||||
|
||||
public void setCheckFatturazione(String checkFatturazione) {
|
||||
this.checkFatturazione = checkFatturazione;
|
||||
}
|
||||
|
||||
public String getCausaleStorno() {
|
||||
return causaleStorno;
|
||||
}
|
||||
|
||||
public void setCausaleStorno(String causaleStorno) {
|
||||
this.causaleStorno = causaleStorno;
|
||||
}
|
||||
|
||||
public String getGiorniDaCorrispondere() {
|
||||
return giorniDaCorrispondere;
|
||||
}
|
||||
|
||||
public void setGiorniDaCorrispondere(String giorniDaCorrispondere) {
|
||||
this.giorniDaCorrispondere = giorniDaCorrispondere;
|
||||
}
|
||||
|
||||
public String getImportoDaCorrispondereAOM() {
|
||||
return importoDaCorrispondereAOM;
|
||||
}
|
||||
|
||||
public void setImportoDaCorrispondereAOM(String importoDaCorrispondereAOM) {
|
||||
this.importoDaCorrispondereAOM = importoDaCorrispondereAOM;
|
||||
}
|
||||
|
||||
public String getImportoDaCorrispondereTIM() {
|
||||
return importoDaCorrispondereTIM;
|
||||
}
|
||||
|
||||
public void setImportoDaCorrispondereTIM(String importoDaCorrispondereTIM) {
|
||||
this.importoDaCorrispondereTIM = importoDaCorrispondereTIM;
|
||||
}
|
||||
|
||||
public String getSoggettoAFranchigia() {
|
||||
return soggettoAFranchigia;
|
||||
}
|
||||
|
||||
public void setSoggettoAFranchigia(String soggettoAFranchigia) {
|
||||
this.soggettoAFranchigia = soggettoAFranchigia;
|
||||
}
|
||||
|
||||
public String getDonatingOspitato() {
|
||||
return donatingOspitato;
|
||||
}
|
||||
|
||||
public void setDonatingOspitato(String donatingOspitato) {
|
||||
this.donatingOspitato = donatingOspitato;
|
||||
}
|
||||
|
||||
public String getRecipientOspitato() {
|
||||
return recipientOspitato;
|
||||
}
|
||||
|
||||
public void setRecipientOspitato(String recipientOspitato) {
|
||||
this.recipientOspitato = recipientOspitato;
|
||||
}
|
||||
|
||||
public String getDonatingRete() {
|
||||
return donatingRete;
|
||||
}
|
||||
|
||||
public void setDonatingRete(String donatingRete) {
|
||||
this.donatingRete = donatingRete;
|
||||
}
|
||||
|
||||
public String getRecipientRete() {
|
||||
return recipientRete;
|
||||
}
|
||||
|
||||
public void setRecipientRete(String recipientRete) {
|
||||
this.recipientRete = recipientRete;
|
||||
}
|
||||
|
||||
public String getMSISDN() {
|
||||
return MSISDN;
|
||||
}
|
||||
|
||||
public void setMSISDN(String MSISDN) {
|
||||
this.MSISDN = MSISDN;
|
||||
}
|
||||
|
||||
public String getCodiceRichiestaRecipient() {
|
||||
return codiceRichiestaRecipient;
|
||||
}
|
||||
|
||||
public void setCodiceRichiestaRecipient(String codiceRichiestaRecipient) {
|
||||
this.codiceRichiestaRecipient = codiceRichiestaRecipient;
|
||||
}
|
||||
|
||||
public String getDataInvioRicezioneFileEventoIniziale() {
|
||||
return dataInvioRicezioneFileEventoIniziale;
|
||||
}
|
||||
|
||||
public void setDataInvioRicezioneFileEventoIniziale(String dataInvioRicezioneFileEventoIniziale) {
|
||||
this.dataInvioRicezioneFileEventoIniziale = dataInvioRicezioneFileEventoIniziale;
|
||||
}
|
||||
|
||||
public String getNomeFileEventoIniziale() {
|
||||
return nomeFileEventoIniziale;
|
||||
}
|
||||
|
||||
public void setNomeFileEventoIniziale(String nomeFileEventoIniziale) {
|
||||
this.nomeFileEventoIniziale = nomeFileEventoIniziale;
|
||||
}
|
||||
|
||||
public String getAckEventoIniziale() {
|
||||
return ackEventoIniziale;
|
||||
}
|
||||
|
||||
public void setAckEventoIniziale(String ackEventoIniziale) {
|
||||
this.ackEventoIniziale = ackEventoIniziale;
|
||||
}
|
||||
|
||||
public String getDataInvioRicezioneFileEventoFinale() {
|
||||
return dataInvioRicezioneFileEventoFinale;
|
||||
}
|
||||
|
||||
public void setDataInvioRicezioneFileEventoFinale(String dataInvioRicezioneFileEventoFinale) {
|
||||
this.dataInvioRicezioneFileEventoFinale = dataInvioRicezioneFileEventoFinale;
|
||||
}
|
||||
|
||||
public String getNomeFileEventoFinale() {
|
||||
return nomeFileEventoFinale;
|
||||
}
|
||||
|
||||
public void setNomeFileEventoFinale(String nomeFileEventoFinale) {
|
||||
this.nomeFileEventoFinale = nomeFileEventoFinale;
|
||||
}
|
||||
|
||||
public String getAckEventoFinale() {
|
||||
return ackEventoFinale;
|
||||
}
|
||||
|
||||
public void setAckEventoFinale(String ackEventoFinale) {
|
||||
this.ackEventoFinale = ackEventoFinale;
|
||||
}
|
||||
|
||||
public String getDataAttesaEventoFinale() {
|
||||
return dataAttesaEventoFinale;
|
||||
}
|
||||
|
||||
public void setDataAttesaEventoFinale(String dataAttesaEventoFinale) {
|
||||
this.dataAttesaEventoFinale = dataAttesaEventoFinale;
|
||||
}
|
||||
|
||||
public String getGiorniRitardoSolari() {
|
||||
return giorniRitardoSolari;
|
||||
}
|
||||
|
||||
public void setGiorniRitardoSolari(String giorniRitardoSolari) {
|
||||
this.giorniRitardoSolari = giorniRitardoSolari;
|
||||
}
|
||||
|
||||
public String getImporto() {
|
||||
return importo;
|
||||
}
|
||||
|
||||
public void setImporto(String importo) {
|
||||
this.importo = importo;
|
||||
}
|
||||
|
||||
public String getMeseCompetenzaEventoFinale() {
|
||||
return meseCompetenzaEventoFinale;
|
||||
}
|
||||
|
||||
public void setMeseCompetenzaEventoFinale(String meseCompetenzaEventoFinale) {
|
||||
this.meseCompetenzaEventoFinale = meseCompetenzaEventoFinale;
|
||||
}
|
||||
|
||||
public String getTipoSla() {
|
||||
return tipoSla;
|
||||
}
|
||||
|
||||
public void setTipoSla(String tipoSla) {
|
||||
this.tipoSla = tipoSla;
|
||||
}
|
||||
|
||||
public String getFlagPenaleAltroOperatore() {
|
||||
return flagPenaleAltroOperatore;
|
||||
}
|
||||
|
||||
public void setFlagPenaleAltroOperatore(String flagPenaleAltroOperatore) {
|
||||
this.flagPenaleAltroOperatore = flagPenaleAltroOperatore;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package it.valueteam.dbcgo.bean.reportritardi;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class MonitoraggioRifiutiCsvRow implements java.io.Serializable {
|
||||
|
||||
private String msisdn;
|
||||
private Date dataPic;
|
||||
private Date dataEspletamento;
|
||||
private int numeroRifiutiTotali = 0;
|
||||
private String causaliRifiuto;
|
||||
private String operatoreEffettivo;
|
||||
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
|
||||
// Contiene il numero di rifiuti suddivisi per ogni causale (la chiave e' il codice causale)
|
||||
private Map numeroRifiutiCausali;
|
||||
|
||||
public String getMsisdn() {
|
||||
return msisdn;
|
||||
}
|
||||
|
||||
public void setMsisdn(String msisdn) {
|
||||
this.msisdn = msisdn;
|
||||
}
|
||||
|
||||
public Date getDataPic() {
|
||||
return dataPic;
|
||||
}
|
||||
|
||||
public void setDataPic(Date dataPic) {
|
||||
this.dataPic = dataPic;
|
||||
}
|
||||
|
||||
public Date getDataEspletamento() {
|
||||
return dataEspletamento;
|
||||
}
|
||||
|
||||
public void setDataEspletamento(Date dataEspletamento) {
|
||||
this.dataEspletamento = dataEspletamento;
|
||||
}
|
||||
|
||||
public int getNumeroRifiutiTotali() {
|
||||
return numeroRifiutiTotali;
|
||||
}
|
||||
|
||||
public void setNumeroRifiutiTotali(int numeroRifiutiTotali) {
|
||||
this.numeroRifiutiTotali = numeroRifiutiTotali;
|
||||
}
|
||||
|
||||
public String getCausaliRifiuto() {
|
||||
return causaliRifiuto;
|
||||
}
|
||||
|
||||
public void setCausaliRifiuto(String causaliRifiuto) {
|
||||
this.causaliRifiuto = causaliRifiuto;
|
||||
}
|
||||
|
||||
public Map getNumeroRifiutiCausali() {
|
||||
return numeroRifiutiCausali;
|
||||
}
|
||||
|
||||
public void setNumeroRifiutiCausali(Map numeroRifiutiCausali) {
|
||||
this.numeroRifiutiCausali = numeroRifiutiCausali;
|
||||
}
|
||||
|
||||
public String getOperatoreEffettivo() {
|
||||
return operatoreEffettivo;
|
||||
}
|
||||
|
||||
public void setOperatoreEffettivo(String operatoreEffettivo) {
|
||||
this.operatoreEffettivo = operatoreEffettivo;
|
||||
}
|
||||
|
||||
public String toCsv() {
|
||||
StringBuffer sb = new StringBuffer() ;
|
||||
sb.append(msisdn).append(",");
|
||||
if (dataPic != null) {
|
||||
sb.append(dateFormat.format(dataPic));
|
||||
}
|
||||
sb.append(",");
|
||||
|
||||
if (dataEspletamento != null) {
|
||||
sb.append(dateFormat.format(dataEspletamento));
|
||||
}
|
||||
sb.append(",");
|
||||
|
||||
sb.append(numeroRifiutiTotali).append(",");
|
||||
sb.append(causaliRifiuto).append(",");
|
||||
|
||||
// stampo i rifiuti per causale in maniera ordinata
|
||||
Vector v = new Vector(numeroRifiutiCausali.keySet());
|
||||
Collections.sort(v);
|
||||
for (Enumeration e = v.elements(); e.hasMoreElements();) {
|
||||
String key = (String)e.nextElement();
|
||||
Integer val = (Integer)numeroRifiutiCausali.get(key);
|
||||
sb.append(val.intValue()).append(",");
|
||||
}
|
||||
sb.append(operatoreEffettivo);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package it.valueteam.dbcgo.bean.reportritardi;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class RicorrenzaLineeMnpCsvRow implements java.io.Serializable {
|
||||
|
||||
private String msisdn;
|
||||
private Date dataEspletamento;
|
||||
private int numeroGiorniRitardo = 0;
|
||||
private int ppNum = 0;
|
||||
private String operatoreEffettivo;
|
||||
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
|
||||
public String getMsisdn() {
|
||||
return msisdn;
|
||||
}
|
||||
|
||||
public void setMsisdn(String msisdn) {
|
||||
this.msisdn = msisdn;
|
||||
}
|
||||
|
||||
public Date getDataEspletamento() {
|
||||
return dataEspletamento;
|
||||
}
|
||||
|
||||
public void setDataEspletamento(Date dataEspletamento) {
|
||||
this.dataEspletamento = dataEspletamento;
|
||||
}
|
||||
|
||||
public int getNumeroGiorniRitardo() {
|
||||
return numeroGiorniRitardo;
|
||||
}
|
||||
|
||||
public void setNumeroGiorniRitardo(int numeroGiorniRitardo) {
|
||||
this.numeroGiorniRitardo = numeroGiorniRitardo;
|
||||
}
|
||||
|
||||
public int getPpNum() {
|
||||
return ppNum;
|
||||
}
|
||||
|
||||
public void setPpNum(int ppNum) {
|
||||
this.ppNum = ppNum;
|
||||
}
|
||||
|
||||
public String getOperatoreEffettivo() {
|
||||
return operatoreEffettivo;
|
||||
}
|
||||
|
||||
public void setOperatoreEffettivo(String operatoreEffettivo) {
|
||||
this.operatoreEffettivo = operatoreEffettivo;
|
||||
}
|
||||
|
||||
public String toCsv() {
|
||||
StringBuffer sb = new StringBuffer() ;
|
||||
sb.append(msisdn).append(",");
|
||||
|
||||
if (dataEspletamento != null) {
|
||||
sb.append(dateFormat.format(dataEspletamento));
|
||||
}
|
||||
sb.append(",");
|
||||
|
||||
sb.append(numeroGiorniRitardo).append(",");
|
||||
sb.append(ppNum).append(",");
|
||||
sb.append(operatoreEffettivo);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoAnagraficaOperatoriDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoAnagraficaOperatori;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoAnagraficaOperatoriId;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: SeiditaNi
|
||||
* Date: 01/06/12
|
||||
* Time: 16.19
|
||||
*/
|
||||
public class AnagraficaOperatoriBusiness {
|
||||
static Logger log = Logger.getLogger(AnagraficaOperatoriBusiness.class.getName());
|
||||
|
||||
public AnagraficaOperatoriBusiness() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resituisce tutti gli operatori virtuali di un operatore di rete (compreso se stesso)
|
||||
* @param operatore
|
||||
* @return
|
||||
*/
|
||||
public List getVirtFor(String operatore) {
|
||||
log.info("getting operator for:"+operatore);
|
||||
List listaOperatori = new ArrayList();
|
||||
DbcgoAnagraficaOperatoriDAO aDao = new DbcgoAnagraficaOperatoriDAO();
|
||||
List criterias = new ArrayList();
|
||||
criterias.add(Restrictions.eq("id.gestoreAom",operatore));
|
||||
List results = aDao.findByCriteria(criterias);
|
||||
Iterator it = results.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
try {
|
||||
DbcgoAnagraficaOperatori anagraficaOperatori = (DbcgoAnagraficaOperatori)it.next();
|
||||
DbcgoAnagraficaOperatoriId iddc = anagraficaOperatori.getId();
|
||||
listaOperatori.add(iddc.getIdOperatore());
|
||||
} catch (NullPointerException npe){
|
||||
log.info("Trovato operatore di rete.");
|
||||
listaOperatori.add(operatore);
|
||||
}
|
||||
}
|
||||
return listaOperatori;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoAnagDisserviziDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoAnagDisservizi;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoAnagDisserviziId;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.Generic;
|
||||
import it.valueteam.dbcgo.utility.JavaUtilsClass;
|
||||
import it.valueteam.dbcgo.utility.RestrictionBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Leoniw
|
||||
* Date: 14/06/12
|
||||
* Time: 15.57
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class CalcoloDisserviziAomBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(CalcoloDisserviziAomBusiness.class.getName());
|
||||
public DbcgoAnagDisserviziDAO viewDAO;
|
||||
|
||||
String col_sla = "id.sla";
|
||||
String col_operatore = "id.operatore";
|
||||
String col_dataInizio = "id.dataInizio";
|
||||
String col_dataFine = "id.dataFine";
|
||||
String col_causaleStorno = "causaleStorno";
|
||||
String col_dataCausale = "dataCausaleStorno";
|
||||
String coltipoProcesso = "tipoProcesso";
|
||||
|
||||
public CalcoloDisserviziAomBusiness () {
|
||||
viewDAO = new DbcgoAnagDisserviziDAO();
|
||||
}
|
||||
|
||||
/* public void instanceCriteria(Map _map){
|
||||
DynaWorkForm dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
public List eseguiRicerca (String sla, String operatore, String dataInizio, String dataFine, String causaleStorno, String dataCausale, String tipoProcesso) {
|
||||
|
||||
Date myDataInizio = new JavaUtilsClass().StringToDate(dataInizio,"dd/MM/yyyy");
|
||||
Date myDataFine = new JavaUtilsClass().StringToDate(dataFine,"dd/MM/yyyy");
|
||||
Date myDataCausale = new JavaUtilsClass().StringToDate(dataCausale,"dd/MM/yyyy");
|
||||
|
||||
List criterions = getCriteria(sla,operatore,myDataInizio,myDataFine,causaleStorno,myDataCausale,tipoProcesso);
|
||||
return eseguiRicerca(criterions);
|
||||
}
|
||||
|
||||
public List eseguiRicerca (List criterions) {
|
||||
return viewDAO.findByCriteria(criterions);
|
||||
}
|
||||
|
||||
private List getCriteria(String sla, String operatore, Date dataInizio, Date dataFine, String causaleStorno, Date dataCausale, String tipoProcesso) {
|
||||
|
||||
causaleStorno = causaleStorno.trim().toUpperCase();
|
||||
|
||||
List criteri = new ArrayList();
|
||||
if (sla != null && !sla.equals("")) {
|
||||
criteri.add(Restrictions.eq(col_sla, sla));
|
||||
}
|
||||
if (operatore != null && !operatore.equals("")) {
|
||||
criteri.add(Restrictions.eq(col_operatore, operatore));
|
||||
}
|
||||
if (dataInizio != null && !dataInizio.equals("")) {
|
||||
criteri.add(Restrictions.ge(col_dataInizio, dataInizio));
|
||||
}
|
||||
if (dataFine != null && !dataFine.equals("")) {
|
||||
criteri.add(Restrictions.le(col_dataFine, dataFine));
|
||||
}
|
||||
if (causaleStorno != null && !causaleStorno.equals("")) {
|
||||
criteri.add(Restrictions.eq(col_causaleStorno, causaleStorno));
|
||||
}
|
||||
if (dataCausale != null && !dataCausale.equals("")) {
|
||||
criteri.add(Restrictions.eq(col_dataCausale, dataCausale));
|
||||
}
|
||||
criteri.add(Restrictions.eq(coltipoProcesso, tipoProcesso));
|
||||
|
||||
return criteri;
|
||||
}
|
||||
|
||||
public void inserisci(String tipologiaPenale, String[] slas, String[] operatores, String dataComunicazione,
|
||||
String dataInizio, String dataFine, String causaleStorno, String dataCausale, String disabilitaDisservizio, String note,
|
||||
String matricolaUser, String tipoProcesso) {
|
||||
|
||||
Character mycharDisDis = new Character(disabilitaDisservizio.toCharArray()[0]);
|
||||
Character mycharTipPro = new Character(tipoProcesso.toCharArray()[0]);
|
||||
Date myDataInizio = new JavaUtilsClass().StringToDate(dataInizio,"dd/MM/yyyy");
|
||||
Date mydataFine = new JavaUtilsClass().StringToDate(dataFine,"dd/MM/yyyy");
|
||||
Date mydataComunicazione = new JavaUtilsClass().StringToDate(dataComunicazione,"dd/MM/yyyy");
|
||||
Date mydataCausale = new JavaUtilsClass().StringToDate(dataCausale,"dd/MM/yyyy");
|
||||
causaleStorno = causaleStorno.toUpperCase();
|
||||
|
||||
for (String sla : slas) {
|
||||
for (String operatore : operatores) {
|
||||
DbcgoAnagDisservizi dbcgoAnagDisservizi = new DbcgoAnagDisservizi();
|
||||
dbcgoAnagDisservizi.setCausaleStorno(causaleStorno);
|
||||
dbcgoAnagDisservizi.setDisabilitaDisservizio(mycharDisDis);
|
||||
dbcgoAnagDisservizi.setNote(note);
|
||||
dbcgoAnagDisservizi.setMatricolaUser(matricolaUser);
|
||||
dbcgoAnagDisservizi.setTipoProcesso(mycharTipPro);
|
||||
dbcgoAnagDisservizi.setDataComunicazione(mydataComunicazione);
|
||||
dbcgoAnagDisservizi.setDataCausaleStorno(mydataCausale);
|
||||
|
||||
DbcgoAnagDisserviziId dbcgoAnagDisserviziId = new DbcgoAnagDisserviziId();
|
||||
if (sla.equalsIgnoreCase("SLA0") || sla.equalsIgnoreCase("SLA1") ||
|
||||
sla.equalsIgnoreCase("SLA2") || sla.equalsIgnoreCase("SLA3") ) {
|
||||
dbcgoAnagDisserviziId.setTipologiaPenale("MNP");
|
||||
} else {
|
||||
dbcgoAnagDisserviziId.setTipologiaPenale("TCR");
|
||||
}
|
||||
|
||||
dbcgoAnagDisserviziId.setSla(sla);
|
||||
dbcgoAnagDisserviziId.setOperatore(operatore);
|
||||
dbcgoAnagDisserviziId.setDataInizio(myDataInizio);
|
||||
dbcgoAnagDisserviziId.setDataFine(mydataFine);
|
||||
dbcgoAnagDisservizi.setId(dbcgoAnagDisserviziId);
|
||||
viewDAO.save(dbcgoAnagDisservizi);
|
||||
viewDAO.flush();
|
||||
log.info("Inserito disservizio per SLA ["+sla+"] Operatore ["+operatore+"]");
|
||||
}
|
||||
}
|
||||
log.info("inserisci, fine");
|
||||
return ;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,886 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.dao.DbcgoSequenceDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoFilePenaliDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoProcessoPenaliDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoVoMesiRiferimentoDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: SeiditaNi
|
||||
* Date: 28/05/12
|
||||
* Time: 16.37
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class CalcoloPenaliBusiness {
|
||||
|
||||
/**
|
||||
* Questa classe espone i metodi di business necessari alla gestione del processo
|
||||
* di calcolo delle penali
|
||||
*/
|
||||
String col_idProcesso = "idProcesso";
|
||||
String col_meseRiferimento = "id.meseRiferimento";
|
||||
String col_operatore = "id.operatore";
|
||||
String col_tipoProcesso = "id.processo";
|
||||
String col_tipoSla = "id.tipoSla";
|
||||
String col_anno = "id.anno";
|
||||
final String PROCESSO_DONOR = "D";
|
||||
final String PROCESSO_RECIPIENT ="R";
|
||||
static Logger log = Logger.getLogger(CalcoloPenaliBusiness.class.getName());
|
||||
DbcgoProcessoPenaliDAO processoPenaliDAO;
|
||||
DbcgoFilePenaliDAO filePenaliDAO;
|
||||
DbcgoSequenceDAO seqDao;
|
||||
DbcgoVoMesiRiferimentoDAO mesiDAO;
|
||||
String SEQ_DBCGO_PENALI = "s_dbcgo_processo_penali";
|
||||
final String YES = "Y";
|
||||
final String NO = "N";
|
||||
final int STATO_OK = 0;
|
||||
final int STATO_IN_LAVORAZIONE=1;
|
||||
final int STATO_EVASO=2;
|
||||
final int STATO_CONFLITTO=3;
|
||||
final int STEP_1 = 1;
|
||||
final int STEP_2 = 2;
|
||||
final int STEP_3 = 3;
|
||||
final int STEP_4 = 4;
|
||||
final int STEP_5 = 5;
|
||||
final String XLS = "xls";
|
||||
final String CSV = "csv";
|
||||
GestioneStepPenaliBusiness gestioneStepPenaliBusiness;
|
||||
|
||||
public CalcoloPenaliBusiness() {
|
||||
processoPenaliDAO = new DbcgoProcessoPenaliDAO();
|
||||
filePenaliDAO = new DbcgoFilePenaliDAO();
|
||||
seqDao = new DbcgoSequenceDAO();
|
||||
mesiDAO = new DbcgoVoMesiRiferimentoDAO();
|
||||
gestioneStepPenaliBusiness = new GestioneStepPenaliBusiness(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Questo metodo viene richiamato internamente alla classe
|
||||
* consente di inserire il lock su un processo
|
||||
* @param user
|
||||
* @param idProcesso
|
||||
*/
|
||||
public void addLock(String user, String idProcesso) throws Exception{
|
||||
log.info("addLock for user:"+user+ " idProcesso:"+idProcesso);
|
||||
List listaprocesso = processoPenaliDAO.findByProperty(col_idProcesso, new Long(idProcesso));
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = null;
|
||||
if (listaprocesso!=null && listaprocesso.size()>0){
|
||||
dbcgoProcessoPenali = (DbcgoProcessoPenali)listaprocesso.get(0);
|
||||
} else {
|
||||
throw new Exception("nessun risultato trovato");
|
||||
}
|
||||
dbcgoProcessoPenali.setIsLockByUser("Y");
|
||||
dbcgoProcessoPenali.setUsername(user);
|
||||
processoPenaliDAO.merge(dbcgoProcessoPenali);
|
||||
processoPenaliDAO.flush();
|
||||
log.info("exit addLock");
|
||||
}
|
||||
|
||||
/**
|
||||
* Questo metodo consente di rimuovere il lock su un processo
|
||||
* @param idProcesso
|
||||
*/
|
||||
public void removeLock (String idProcesso) throws Exception{
|
||||
log.info("removeLock for idProcesso:"+idProcesso);
|
||||
List listaprocesso = processoPenaliDAO.findByProperty(col_idProcesso, new Long(idProcesso));
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = null;
|
||||
if (listaprocesso!=null && listaprocesso.size()>0){
|
||||
dbcgoProcessoPenali = (DbcgoProcessoPenali)listaprocesso.get(0);
|
||||
} else {
|
||||
throw new Exception("nessun risultato trovato");
|
||||
}
|
||||
dbcgoProcessoPenali.setUsername(null);
|
||||
dbcgoProcessoPenali.setIsLockByUser("N");
|
||||
processoPenaliDAO.merge(dbcgoProcessoPenali);
|
||||
processoPenaliDAO.flush();
|
||||
log.info("exit removeLock");
|
||||
}
|
||||
|
||||
/**
|
||||
* Controllo l'esistenza di altri file per il processo
|
||||
* @param mese
|
||||
* @param processo
|
||||
* @param operatore
|
||||
* @param anno
|
||||
* @param user
|
||||
* @param tipoSla
|
||||
* @return
|
||||
*/
|
||||
public HashMap executeInit (String mese, String processo , String operatore , String anno, String user, String tipoSla) {
|
||||
byte[] fileGenerato = null;
|
||||
boolean generatenextstep = false;
|
||||
try {
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = getProcesso(anno,mese,operatore,processo,tipoSla,STEP_1);
|
||||
if (dbcgoProcessoPenali!=null) {
|
||||
if (dbcgoProcessoPenali.getStato().equals(new Long(0))) {
|
||||
//se lo stato è zero vuol dire che devo reinizializare lo step.
|
||||
//vanno invalidati anche gli step successivi.
|
||||
// invalido via HQL
|
||||
updateStatoViaHQL(mese,operatore,processo,tipoSla,anno,STEP_1,"N","N");
|
||||
//genero il nuovo file via business.
|
||||
GestioneXlsBusiness gestioneXlsBusiness = new GestioneXlsBusiness();
|
||||
if (processo.equals(PROCESSO_DONOR)) {
|
||||
fileGenerato = gestioneXlsBusiness.generaStep1_Donor(operatore,mese,anno,tipoSla);
|
||||
} else {
|
||||
fileGenerato = gestioneXlsBusiness.generaStep1_Recipient(operatore,mese,anno,tipoSla);
|
||||
}
|
||||
//recupero il file esistente
|
||||
List files = getFilePenali(dbcgoProcessoPenali.getIdProcesso(),"xls",new Long(0));
|
||||
DbcgoFilePenali dbcgoFilePenali = new DbcgoFilePenali();
|
||||
if (files.get(0)!=null) {
|
||||
dbcgoFilePenali = (DbcgoFilePenali)files.get(0);
|
||||
} else {
|
||||
throw new Exception("nessun file trovato!!!:"+dbcgoProcessoPenali.getIdProcesso());
|
||||
}
|
||||
|
||||
//procedo con l'update della riga
|
||||
updateFilePenali(dbcgoFilePenali.getId().getVersione().toString(),
|
||||
dbcgoFilePenali.getId().getIdProcesso().toString(),dbcgoFilePenali.getId().getTipoFile(),"1");
|
||||
|
||||
//inserisco in tabella il nuovo record
|
||||
saveFilePenali(fileGenerato,"N","xls",dbcgoProcessoPenali.getIdProcesso(),new Long(0));
|
||||
} else {
|
||||
//se lo stato non è zero, sovrascrivo l'attuale filepenale.
|
||||
fileGenerato = initRecord(mese,processo,operatore,anno,tipoSla,null);
|
||||
}
|
||||
} else {
|
||||
//il processo non esiste per cui lo creo.
|
||||
fileGenerato = initRecord(mese,processo,operatore,anno,tipoSla,null);
|
||||
generatenextstep = true;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
HashMap results = new HashMap();
|
||||
|
||||
|
||||
results.put("bytes",fileGenerato);
|
||||
results.put("action",new Boolean(generatenextstep));
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Questo metodo consente di creare un nuovo record sulla tabella di processo.
|
||||
* Crea il file chiamando il metodo di business e lo salva su db in DBCGO_FILE_PENALI
|
||||
* @param mese
|
||||
* @param processo
|
||||
* @param operatore
|
||||
* @param anno
|
||||
* @param tipoSla
|
||||
* @return file generato passo1
|
||||
*/
|
||||
private byte[] initRecord (String mese, String processo , String operatore , String anno,
|
||||
String tipoSla, DbcgoProcessoPenali dbcgoProcessoPenali) throws Exception{
|
||||
log.info("initRecord for mese:"+mese +" processo:"+processo+" anno:"+anno+" operatore:"+operatore +" tipoSla:"+tipoSla);
|
||||
|
||||
byte[] fileGenerato = null;
|
||||
//chiedo alla business dei file xls che venga generato l'xls
|
||||
GestioneXlsBusiness gestioneXlsBusiness = new GestioneXlsBusiness();
|
||||
if (processo.equals(PROCESSO_DONOR)) {
|
||||
fileGenerato = gestioneXlsBusiness.generaStep1_Donor(operatore,""+mese,""+anno,tipoSla);
|
||||
} else if (processo.equals(PROCESSO_RECIPIENT)) {
|
||||
fileGenerato = gestioneXlsBusiness.generaStep1_Recipient(operatore,""+mese,""+anno,tipoSla);
|
||||
} else {
|
||||
throw new Exception("Il processo non esiste");
|
||||
}
|
||||
//controllo l'esistenza di un record in tabella.
|
||||
|
||||
DbcgoProcessoPenaliId dbcgoProcessoPenaliId = new DbcgoProcessoPenaliId();
|
||||
DbcgoFilePenali dbcgoFilePenali = new DbcgoFilePenali();
|
||||
|
||||
|
||||
log.info("fileGenerato size:"+fileGenerato.length);
|
||||
if(dbcgoProcessoPenali!=null && dbcgoProcessoPenali.getId()!=null){
|
||||
log.info("Preparo la sovrascrittura del file");
|
||||
//se esiste gia' un record procedo con la sovrascrittura del file.
|
||||
dbcgoProcessoPenali.setIsLockByUser(NO);
|
||||
dbcgoProcessoPenali.setIsValid(YES);
|
||||
|
||||
dbcgoProcessoPenali.setStato(new Long(STATO_OK));
|
||||
processoPenaliDAO.merge(dbcgoProcessoPenali);
|
||||
processoPenaliDAO.flush();
|
||||
processoPenaliDAO.closeSession();
|
||||
//salvo il nuovo file sulla tabella file penali
|
||||
|
||||
DbcgoFilePenaliId dbcgoFilePenaliId = new DbcgoFilePenaliId();
|
||||
|
||||
dbcgoFilePenaliId.setVersione(new Long(0));
|
||||
dbcgoFilePenaliId.setIdProcesso(dbcgoProcessoPenali.getIdProcesso());
|
||||
dbcgoFilePenaliId.setTipoFile(XLS);
|
||||
dbcgoFilePenali = filePenaliDAO.findById(dbcgoFilePenaliId);
|
||||
if (dbcgoFilePenali!=null) {
|
||||
//esiste un filePenali
|
||||
dbcgoFilePenali.setFileBlob(Hibernate.createBlob(fileGenerato));
|
||||
dbcgoFilePenali.setIsConsolidato(YES);
|
||||
filePenaliDAO.merge(dbcgoFilePenali);
|
||||
} else {
|
||||
//non esiste un file penali
|
||||
dbcgoFilePenali = new DbcgoFilePenali();
|
||||
dbcgoFilePenali.setFileBlob(Hibernate.createBlob(fileGenerato));
|
||||
dbcgoFilePenali.setIsConsolidato(YES);
|
||||
dbcgoFilePenaliId = new DbcgoFilePenaliId();
|
||||
dbcgoFilePenaliId.setIdProcesso(dbcgoProcessoPenali.getIdProcesso());
|
||||
dbcgoFilePenaliId.setVersione(new Long(0));
|
||||
dbcgoFilePenaliId.setTipoFile(XLS);
|
||||
dbcgoFilePenali.setId(dbcgoFilePenaliId);
|
||||
filePenaliDAO.save(dbcgoFilePenali);
|
||||
}
|
||||
filePenaliDAO.flush();
|
||||
filePenaliDAO.closeSession();
|
||||
} else {
|
||||
//creo record se non esiste
|
||||
dbcgoProcessoPenali = new DbcgoProcessoPenali();
|
||||
dbcgoProcessoPenali.setIsLockByUser(NO);
|
||||
dbcgoProcessoPenali.setIsValid(YES);
|
||||
dbcgoProcessoPenali.setStato(new Long(STATO_OK));
|
||||
dbcgoProcessoPenaliId.setStep(new Long(STEP_1));
|
||||
dbcgoProcessoPenaliId.setAnno(new Long(anno));
|
||||
dbcgoProcessoPenaliId.setMeseRiferimento(new Long(mese));
|
||||
dbcgoProcessoPenaliId.setOperatore(operatore);
|
||||
dbcgoProcessoPenaliId.setProcesso(processo);
|
||||
dbcgoProcessoPenaliId.setTipoSla(tipoSla);
|
||||
dbcgoProcessoPenali.setId(dbcgoProcessoPenaliId);
|
||||
//recover idProcesso
|
||||
Long idProcesso = seqDao.getNextValue(SEQ_DBCGO_PENALI);
|
||||
dbcgoProcessoPenali.setIdProcesso(idProcesso);
|
||||
//salvo l'istanza
|
||||
processoPenaliDAO.save(dbcgoProcessoPenali);
|
||||
processoPenaliDAO.flush();
|
||||
processoPenaliDAO.closeSession();
|
||||
|
||||
//salvo il file generato
|
||||
dbcgoFilePenali.setFileBlob(Hibernate.createBlob(fileGenerato));
|
||||
dbcgoFilePenali.setIsConsolidato(YES);
|
||||
DbcgoFilePenaliId dbcgoFilePenaliId = new DbcgoFilePenaliId();
|
||||
dbcgoFilePenaliId.setIdProcesso(idProcesso);
|
||||
dbcgoFilePenaliId.setVersione(new Long(0));
|
||||
dbcgoFilePenaliId.setTipoFile(XLS);
|
||||
dbcgoFilePenali.setId(dbcgoFilePenaliId);
|
||||
filePenaliDAO.save(dbcgoFilePenali);
|
||||
filePenaliDAO.flush();
|
||||
filePenaliDAO.closeSession();
|
||||
}
|
||||
|
||||
log.info("exit initRecord");
|
||||
return fileGenerato;
|
||||
}
|
||||
|
||||
/**
|
||||
* Questo metodo restituisce a partire dal mese i record del trimestre di riferimento.
|
||||
* @param tipoProcesso
|
||||
* @param operatore
|
||||
* @param meseanno
|
||||
* @param tipoSla
|
||||
* @return
|
||||
*/
|
||||
public List getRecordPerMese(String tipoProcesso, String operatore, String meseanno ,String tipoSla) throws Exception{
|
||||
log.info("getRecordPerMese for: tipoProcesso:"+tipoProcesso+" operatore:"+operatore+" mese:"+meseanno +" tipoSla:"+tipoSla);
|
||||
List risultatiRicerca = new ArrayList();
|
||||
String[] dates = meseanno.split("/");
|
||||
|
||||
Long[] trimestre = (Long[])getTrimestrePerMese(meseanno,false,true);
|
||||
|
||||
List criterions = getCriteria(tipoProcesso,operatore,trimestre,tipoSla,dates[1]);
|
||||
risultatiRicerca = processoPenaliDAO.findByCriteria(criterions);
|
||||
|
||||
if (risultatiRicerca==null){
|
||||
throw new Exception("nessun risultato trovato");
|
||||
}
|
||||
if (risultatiRicerca!=null && risultatiRicerca.size()==0) {
|
||||
log.info("Nessun record trovato...aggiungo");
|
||||
}
|
||||
log.info("exit getRecordPerMese");
|
||||
return risultatiRicerca;
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruisce la lista di criteri per la query HB
|
||||
* @param tipoProcesso
|
||||
* @param operatore
|
||||
* @param trimestre
|
||||
* @param tipoSla
|
||||
* @param anno
|
||||
* @return
|
||||
*/
|
||||
private List getCriteria(String tipoProcesso, String operatore, Long trimestre[] ,String tipoSla,String anno) {
|
||||
log.info("getCriteria for: tipoProcesso:"+tipoProcesso+" operatore:"+operatore+" trimestre:"+trimestre.length +" tipoSla:"+tipoSla+" anno:"+anno);
|
||||
List criteri = new ArrayList();
|
||||
criteri.add(Restrictions.in(col_meseRiferimento,trimestre));
|
||||
criteri.add(Restrictions.eq(col_tipoProcesso,tipoProcesso));
|
||||
criteri.add(Restrictions.eq(col_operatore,operatore));
|
||||
criteri.add(Restrictions.eq(col_tipoSla,tipoSla));
|
||||
criteri.add(Restrictions.eq(col_anno,new Long(anno)));
|
||||
return criteri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il trimestre per il mese indicato
|
||||
* @param meseanno
|
||||
* @param withYear
|
||||
* @return
|
||||
*/
|
||||
public Object[] getTrimestrePerMese (String meseanno, boolean withYear, boolean withTrimestre) {
|
||||
//recupero i mesi del trimestre di riferimento
|
||||
log.info(" getTrimestrePerMese meseanno:"+meseanno);
|
||||
String[] dates = meseanno.split("/");
|
||||
List cr = new ArrayList();
|
||||
DbcgoVoMesiRiferimentoDAO mesiRiferimentoDAO = new DbcgoVoMesiRiferimentoDAO();
|
||||
String trimestreRif = mesiRiferimentoDAO.findById(new Long(dates[0])).getTrimestreRif();
|
||||
if(trimestreRif!=null) {
|
||||
cr.add(Restrictions.eq("trimestreRif",trimestreRif));
|
||||
}
|
||||
cr.add(Restrictions.lt("id", new Long(13)));
|
||||
List mesi = mesiRiferimentoDAO.findByCriteria(cr);
|
||||
if(!withYear){
|
||||
if(withTrimestre){
|
||||
Long toadd = null;
|
||||
if (new Long(dates[0]).intValue()<13) {
|
||||
toadd = ((DbcgoVoMesiRiferimento)mesiRiferimentoDAO.findByProperty("label",trimestreRif).get(0)).getId();
|
||||
} else {
|
||||
toadd = new Long(dates[0]);
|
||||
}
|
||||
Long[] trimestre ={((DbcgoVoMesiRiferimento)mesi.get(0)).getId(),
|
||||
((DbcgoVoMesiRiferimento)mesi.get(1)).getId(),
|
||||
((DbcgoVoMesiRiferimento)mesi.get(2)).getId(),
|
||||
toadd};
|
||||
return trimestre;
|
||||
} else {
|
||||
Long[] trimestre ={((DbcgoVoMesiRiferimento)mesi.get(0)).getId(),
|
||||
((DbcgoVoMesiRiferimento)mesi.get(1)).getId(),
|
||||
((DbcgoVoMesiRiferimento)mesi.get(2)).getId()};
|
||||
return trimestre;
|
||||
}
|
||||
|
||||
} else {
|
||||
DbcgoVoMesiRiferimento[] trimestre ={((DbcgoVoMesiRiferimento)mesi.get(0)),
|
||||
((DbcgoVoMesiRiferimento)mesi.get(1)),
|
||||
((DbcgoVoMesiRiferimento)mesi.get(2))};
|
||||
return trimestre;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il file richiesto in byte[]
|
||||
* @param type
|
||||
* @param version
|
||||
* @param idProcess
|
||||
* @return
|
||||
*/
|
||||
public byte[] getRequestedFile(String type, Long version, Long idProcess) throws IOException {
|
||||
log.info("getRequestedFile");
|
||||
|
||||
List results = getFilePenali(idProcess,type,version);
|
||||
DbcgoFilePenali dbcgoFilePenali = (DbcgoFilePenali)results.get(0);
|
||||
if (dbcgoFilePenali==null) {
|
||||
throw new IOException();
|
||||
}
|
||||
byte[] bytes = null;
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
InputStream in = dbcgoFilePenali.getFileBlob().getBinaryStream();
|
||||
int n = 0;
|
||||
while ((n = in.read(buf)) >= 0) {
|
||||
baos.write(buf, 0, n);
|
||||
}
|
||||
in.close();
|
||||
bytes = baos.toByteArray();
|
||||
} catch (SQLException sqle) {
|
||||
log.error(sqle.getMessage());
|
||||
sqle.printStackTrace();
|
||||
} catch (IOException ioe) {
|
||||
log.error(ioe.getMessage());
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
log.info("getRequestedFile - exit");
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserisce un nuovo record sulla tabella di processo penali.
|
||||
* @param isLockByUser
|
||||
* @param isValid
|
||||
* @param tipoSla
|
||||
* @param stato
|
||||
* @param step
|
||||
* @param anno
|
||||
* @param operatore
|
||||
* @param mese
|
||||
* @param processo
|
||||
*/
|
||||
public Long saveProcess(String isLockByUser, String isValid,String tipoSla,
|
||||
Long stato, Long step, Long anno, String operatore, Long mese, String processo) {
|
||||
log.info("saveProcess");
|
||||
Long idProcesso = seqDao.getNextValue(SEQ_DBCGO_PENALI);
|
||||
log.info("generato idProcesso:"+idProcesso.toString());
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = new DbcgoProcessoPenali();
|
||||
dbcgoProcessoPenali.setIdProcesso(idProcesso);
|
||||
dbcgoProcessoPenali.setIsLockByUser(isLockByUser);
|
||||
dbcgoProcessoPenali.setIsValid(isValid);
|
||||
dbcgoProcessoPenali.setStato(stato);
|
||||
DbcgoProcessoPenaliId dbcgoProcessoPenaliId = new DbcgoProcessoPenaliId();
|
||||
dbcgoProcessoPenaliId.setAnno(anno);
|
||||
dbcgoProcessoPenaliId.setProcesso(processo);
|
||||
dbcgoProcessoPenaliId.setMeseRiferimento(mese);
|
||||
dbcgoProcessoPenaliId.setOperatore(operatore);
|
||||
dbcgoProcessoPenaliId.setTipoSla(tipoSla);
|
||||
dbcgoProcessoPenaliId.setStep(step);
|
||||
dbcgoProcessoPenali.setId(dbcgoProcessoPenaliId);
|
||||
processoPenaliDAO.save(dbcgoProcessoPenali);
|
||||
processoPenaliDAO.flush();
|
||||
log.info("saveProcess - exit");
|
||||
return idProcesso;
|
||||
}
|
||||
|
||||
/**
|
||||
* Salva il file fisico sul db. String idProcesso_,String versione
|
||||
* @param myFile
|
||||
* @param isConsolidato
|
||||
* @param tipoFile
|
||||
* @param idProcesso_
|
||||
* @param versione
|
||||
*/
|
||||
public void saveFilePenali(byte[] myFile, String isConsolidato, String tipoFile, String idProcesso_,String versione) {
|
||||
log.info("saveFilePenali");
|
||||
DbcgoFilePenali dbcgoFilePenali = new DbcgoFilePenali();
|
||||
dbcgoFilePenali.setFileBlob(Hibernate.createBlob(myFile));
|
||||
dbcgoFilePenali.setIsConsolidato(isConsolidato);
|
||||
DbcgoFilePenaliId dbcgoFilePenaliId = new DbcgoFilePenaliId();
|
||||
Long idProcesso = new Long(idProcesso_);
|
||||
dbcgoFilePenaliId.setIdProcesso(idProcesso);
|
||||
dbcgoFilePenaliId.setTipoFile(tipoFile);
|
||||
dbcgoFilePenaliId.setVersione(new Long(versione));
|
||||
dbcgoFilePenali.setId(dbcgoFilePenaliId);
|
||||
filePenaliDAO.save(dbcgoFilePenali);
|
||||
filePenaliDAO.flush();
|
||||
log.info("saveFilePenali - exit");
|
||||
}
|
||||
/**
|
||||
* Salva il file fisico sul db. Long idProcesso_,Long versione
|
||||
* @param myFile
|
||||
* @param isConsolidato
|
||||
* @param tipoFile
|
||||
* @param idProcesso_
|
||||
* @param versione
|
||||
*/
|
||||
public void saveFilePenali(byte[] myFile, String isConsolidato, String tipoFile, Long idProcesso_,Long versione) {
|
||||
log.info("saveFilePenali");
|
||||
DbcgoFilePenali dbcgoFilePenali = new DbcgoFilePenali();
|
||||
dbcgoFilePenali.setFileBlob(Hibernate.createBlob(myFile));
|
||||
dbcgoFilePenali.setIsConsolidato(isConsolidato);
|
||||
DbcgoFilePenaliId dbcgoFilePenaliId = new DbcgoFilePenaliId();
|
||||
Long idProcesso = idProcesso_;
|
||||
dbcgoFilePenaliId.setIdProcesso(idProcesso);
|
||||
dbcgoFilePenaliId.setTipoFile(tipoFile);
|
||||
dbcgoFilePenaliId.setVersione(versione);
|
||||
dbcgoFilePenali.setId(dbcgoFilePenaliId);
|
||||
filePenaliDAO.save(dbcgoFilePenali);
|
||||
filePenaliDAO.flush();
|
||||
log.info("saveFilePenali - exit");
|
||||
}
|
||||
|
||||
/**
|
||||
* Torna i file penali corrispondenti alla ricerca
|
||||
* @param idProcess
|
||||
* @param type
|
||||
* @param version
|
||||
* @return List<DbcgoFilePenali>
|
||||
*/
|
||||
public List getFilePenali (Long idProcess, String type, Long version) {
|
||||
DbcgoFilePenaliId id = new DbcgoFilePenaliId();
|
||||
List criteria = new ArrayList();
|
||||
if (idProcess != null) {
|
||||
criteria.add(Restrictions.eq("id.idProcesso",idProcess));
|
||||
}
|
||||
if (type != null) {
|
||||
criteria.add(Restrictions.eq("id.tipoFile",type));
|
||||
}
|
||||
if (version != null) {
|
||||
criteria.add(Restrictions.eq("id.versione",version));
|
||||
}
|
||||
|
||||
return filePenaliDAO.findByCriteria(criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il processo indicato.
|
||||
* @param anno
|
||||
* @param mese
|
||||
* @param operatore
|
||||
* @param processo
|
||||
* @param tipoSla
|
||||
* @param step
|
||||
* @return
|
||||
*/
|
||||
public DbcgoProcessoPenali getProcesso (String anno,String mese, String operatore,
|
||||
String processo, String tipoSla, int step) {
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = null;
|
||||
DbcgoProcessoPenaliId dbcgoProcessoPenaliId = new DbcgoProcessoPenaliId();
|
||||
dbcgoProcessoPenaliId.setAnno(new Long(anno));
|
||||
dbcgoProcessoPenaliId.setMeseRiferimento(new Long(mese));
|
||||
dbcgoProcessoPenaliId.setOperatore(operatore);
|
||||
dbcgoProcessoPenaliId.setProcesso(processo);
|
||||
dbcgoProcessoPenaliId.setTipoSla(tipoSla) ;
|
||||
dbcgoProcessoPenaliId.setStep(new Long(step));
|
||||
dbcgoProcessoPenali = processoPenaliDAO.findById(dbcgoProcessoPenaliId);
|
||||
return dbcgoProcessoPenali;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il processo indicato.
|
||||
* @param idProcesso
|
||||
* @return
|
||||
*/
|
||||
public DbcgoProcessoPenali getProcesso (String idProcesso) {
|
||||
return (DbcgoProcessoPenali)(processoPenaliDAO.findByProperty ("idProcesso",new Long(idProcesso)).get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Porta lo stato a ok
|
||||
* elimina i file vecchi
|
||||
* @param idProcesso
|
||||
*/
|
||||
public void consolidaProcesso (String idProcesso, String trimestre,String idStepSuccessivo) {
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = getProcesso(idProcesso);
|
||||
dbcgoProcessoPenali.setStato(new Long(0));
|
||||
dbcgoProcessoPenali.setIsValid(YES);
|
||||
processoPenaliDAO.merge(dbcgoProcessoPenali);
|
||||
processoPenaliDAO.flush();
|
||||
// se lo step e' 1 o 2 allora eliminiamo solo xls vecchio e consolidiamo il nuovo.
|
||||
// se invece e' 3 o 4 o 5 anche csv
|
||||
switch (dbcgoProcessoPenali.getId().getStep().intValue()) {
|
||||
case 1:
|
||||
case 2:
|
||||
deleteFilePenali(dbcgoProcessoPenali.getIdProcesso(),"xls",new Long(1));
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
deleteFilePenali(dbcgoProcessoPenali.getIdProcesso(),null,new Long(1));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Aggiorno il record del file per impostare il flag IS_CONSOLIDATO
|
||||
List files = getFilePenali(dbcgoProcessoPenali.getIdProcesso(), "xls", new Long(0));
|
||||
DbcgoFilePenali dbcgoFilePenali;
|
||||
if (files != null && files.size()>0 && files.get(0) != null) {
|
||||
dbcgoFilePenali = (DbcgoFilePenali) files.get(0);
|
||||
updateFilePenaliConsolidato(dbcgoFilePenali.getId().getVersione().toString(), dbcgoFilePenali.getId().getIdProcesso().toString(), dbcgoFilePenali.getId().getTipoFile());
|
||||
}
|
||||
|
||||
if (dbcgoProcessoPenali.getId().getStep().intValue() == 3) {
|
||||
// if (dbcgoProcessoPenali.getId().getProcesso().equalsIgnoreCase("R")) { // Se Recipient aggiorno anche il csv
|
||||
// Aggiorno il record del file per impostare il flag IS_CONSOLIDATO
|
||||
List filesCsv = getFilePenali(dbcgoProcessoPenali.getIdProcesso(), "csv", new Long(0));
|
||||
DbcgoFilePenali dbcgoFilePenaliCSV;
|
||||
if (filesCsv != null && filesCsv.size()>0 && filesCsv.get(0) != null) {
|
||||
dbcgoFilePenaliCSV = (DbcgoFilePenali) filesCsv.get(0);
|
||||
updateFilePenaliConsolidato(dbcgoFilePenaliCSV.getId().getVersione().toString(), dbcgoFilePenaliCSV.getId().getIdProcesso().toString(), dbcgoFilePenaliCSV.getId().getTipoFile());
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// avvia step successivi.
|
||||
switch (dbcgoProcessoPenali.getId().getStep().intValue()) {
|
||||
case 1:
|
||||
//avvia lo step 2
|
||||
gestioneStepPenaliBusiness.rielaboraPasso2(idProcesso,dbcgoProcessoPenali.getId().getAnno().toString(),
|
||||
dbcgoProcessoPenali.getId().getMeseRiferimento().toString(),dbcgoProcessoPenali.getId().getOperatore(),
|
||||
dbcgoProcessoPenali.getId().getProcesso(),dbcgoProcessoPenali.getId().getTipoSla());
|
||||
break;
|
||||
case 2:
|
||||
//esegue i controlli ed avvia lo step 3
|
||||
gestioneStepPenaliBusiness.passaAlloStep3(dbcgoProcessoPenali,trimestre,idStepSuccessivo);
|
||||
break;
|
||||
case 3:
|
||||
//avvia lo step 4
|
||||
gestioneStepPenaliBusiness.passaAlloStep4(dbcgoProcessoPenali,trimestre,idStepSuccessivo);
|
||||
break;
|
||||
case 4:
|
||||
//processo terminato
|
||||
if (dbcgoProcessoPenali.getId().getProcesso().equals(PROCESSO_RECIPIENT)) {
|
||||
log.info("PROCESSO TERMINATO RECIPIENT:"+idProcesso);
|
||||
dbcgoProcessoPenali.setStato(new Long(2));
|
||||
processoPenaliDAO.merge(dbcgoProcessoPenali);
|
||||
processoPenaliDAO.flush();
|
||||
} else {
|
||||
//avvia lo step 5 (solo per donor)
|
||||
gestioneStepPenaliBusiness.passaAlloStep5(dbcgoProcessoPenali,idStepSuccessivo);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
log.info("PROCESSO TERMINATO DONOR:"+idProcesso);
|
||||
dbcgoProcessoPenali.setStato(new Long(2));
|
||||
processoPenaliDAO.merge(dbcgoProcessoPenali);
|
||||
processoPenaliDAO.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoca il metodo generaStep2 (donor o recipient)
|
||||
* e salva l'output su DBCGO_FILE_PENALI
|
||||
* @param idProcesso
|
||||
* @param file
|
||||
* @param tipoFile
|
||||
* @param tipoProcesso
|
||||
* @param tipoSla
|
||||
*/
|
||||
public void elaboraPasso2(Long idProcesso,byte[] file,String tipoFile, String tipoProcesso, String tipoSla) {
|
||||
GestioneXlsBusiness gb= new GestioneXlsBusiness();
|
||||
byte[] ris = null;
|
||||
if("D".equalsIgnoreCase(tipoProcesso)) {
|
||||
ris = gb.generaStep2_Donor(file, tipoSla, idProcesso);
|
||||
} else {
|
||||
ris = gb.generaStep2_Recipient(file, tipoSla, idProcesso);
|
||||
}
|
||||
saveFilePenali(ris, "N",tipoFile, String.valueOf(idProcesso),"0");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tramite questo metodo è possibile invalidare tutti i processi successivi al mese invalidato.
|
||||
* @param mese
|
||||
* @param operatore
|
||||
* @param processo
|
||||
* @param tipoSla
|
||||
* @param anno
|
||||
* @param step
|
||||
* @param isValid
|
||||
* @param isLockByUser
|
||||
*/
|
||||
void updateStatoViaHQL (String mese, String operatore, String processo, String tipoSla ,
|
||||
String anno,int step, String isValid, String isLockByUser) {
|
||||
Query query = processoPenaliDAO.getSession().createSQLQuery("update Dbcgo_Processo_Penali set stato = :stato, is_valid = :isValid, is_lock_by_user = :isLockByUser " +
|
||||
" where (mese_riferimento = :mese or mese_riferimento > :trimestre) and " +
|
||||
"operatore = :operatore and processo = :processo and tipo_sla = :tipoSla and anno= :anno and step>=:step");
|
||||
query.setParameter("stato", new Long(1));
|
||||
query.setParameter("mese", new Long(mese));
|
||||
query.setParameter("operatore", operatore);
|
||||
query.setParameter("processo", processo);
|
||||
query.setParameter("tipoSla",tipoSla);
|
||||
query.setParameter("step",new Long(step));
|
||||
query.setParameter("anno", new Long(anno));
|
||||
query.setParameter("trimestre", new Long(12));
|
||||
query.setParameter("isValid", isValid);
|
||||
query.setParameter("isLockByUser", isLockByUser);
|
||||
int result = query.executeUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Per un problema di hibernate l'update sulla tabella delle penali perde il valore del
|
||||
* campo BLOB. Per aggirare il problema invochiamo una SQL standard.
|
||||
* @param versione_old
|
||||
* @param id_processo
|
||||
* @param tipo_file
|
||||
* @param versione_new
|
||||
*/
|
||||
void updateFilePenali (String versione_old , String id_processo, String tipo_file, String versione_new) {
|
||||
Query query = filePenaliDAO.getSession().createSQLQuery("update Dbcgo_file_Penali set versione = :versione_new" +
|
||||
" where id_processo = :id_processo and tipo_file = :tipo_file and versione = :versione_old");
|
||||
|
||||
query.setParameter("id_processo", id_processo);
|
||||
query.setParameter("tipo_file", tipo_file);
|
||||
query.setParameter("versione_old", versione_old);
|
||||
query.setParameter("versione_new", versione_new);
|
||||
query.executeUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue la cancellazione del file delle penali
|
||||
* @param id_processo
|
||||
* @param tipo_file
|
||||
* @param versione
|
||||
*/
|
||||
void deleteFilePenali (Long id_processo, String tipo_file, Long versione) {
|
||||
StringBuffer stringa = new StringBuffer ();
|
||||
stringa.append("delete from Dbcgo_file_Penali" +
|
||||
" where id_processo = :id_processo and versione = :versione ");
|
||||
if (tipo_file!=null) {
|
||||
stringa.append(" and tipo_file = :tipo_file");
|
||||
}
|
||||
Query query = filePenaliDAO.getSession().createSQLQuery(stringa.toString());
|
||||
query.setParameter("id_processo", id_processo);
|
||||
if (tipo_file!=null) {
|
||||
query.setParameter("tipo_file", tipo_file);
|
||||
}
|
||||
query.setParameter("versione", versione);
|
||||
query.executeUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gestisce l'upload del file.
|
||||
* nel caso in cui il processo sia in stato 0 = ok vuol dire che devo reinizializzare lo step.
|
||||
* Per cui procedo con invalidare tutti gli step
|
||||
* porto il vecchio file in versione 1
|
||||
* salvo il nuovo.
|
||||
* Nel caso non esiste lo creo, se esiste ed il processo è in stato 1 sovrscrivo.
|
||||
* @param step
|
||||
* @param myFile
|
||||
* @param idProcesso
|
||||
* @param operatore
|
||||
* @param processo
|
||||
* @param tipoSla
|
||||
* @throws Exception
|
||||
*/
|
||||
public void handleUpload(int step, byte[] myFile, String idProcesso, String operatore,
|
||||
String processo, String tipoSla) throws Exception{
|
||||
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = getProcesso(idProcesso);
|
||||
if (dbcgoProcessoPenali != null) {
|
||||
if (dbcgoProcessoPenali.getStato().equals(new Long(0)) || dbcgoProcessoPenali.getStato().equals(new Long(2))) {
|
||||
|
||||
//se lo stato è zero vuol dire che devo reinizializare lo step.
|
||||
//vanno invalidati anche gli step successivi.
|
||||
// invalido via HQL
|
||||
updateStatoViaHQL(dbcgoProcessoPenali.getId().getMeseRiferimento().toString(),operatore,processo,tipoSla,
|
||||
dbcgoProcessoPenali.getId().getAnno().toString(),step,"N","N");
|
||||
|
||||
//recupero il file esistente
|
||||
List files = getFilePenali(dbcgoProcessoPenali.getIdProcesso(),"xls",new Long(0));
|
||||
DbcgoFilePenali dbcgoFilePenali = new DbcgoFilePenali();
|
||||
if (files.get(0)!=null) {
|
||||
dbcgoFilePenali = (DbcgoFilePenali)files.get(0);
|
||||
} else {
|
||||
throw new Exception("nessun file trovato!!!:"+dbcgoProcessoPenali.getIdProcesso());
|
||||
}
|
||||
|
||||
//procedo con l'update della riga
|
||||
updateFilePenali(dbcgoFilePenali.getId().getVersione().toString(),
|
||||
dbcgoFilePenali.getId().getIdProcesso().toString(),dbcgoFilePenali.getId().getTipoFile(),"1");
|
||||
|
||||
//inserisco in tabella il nuovo record
|
||||
saveFilePenali(myFile,"N","xls",new Long(idProcesso),new Long(0));
|
||||
} else {
|
||||
//se lo stato non è zero, sovrascrivo l'attuale filepenale.
|
||||
deleteFilePenali(new Long(idProcesso),"xls",new Long(0));
|
||||
saveFilePenali(myFile, "N", "xls", idProcesso, "0");
|
||||
}
|
||||
} else {
|
||||
//il file non esiste per cui lo creo.
|
||||
saveFilePenali(myFile, "N", "xls", idProcesso, "0");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gestisce l'upload del file.
|
||||
* nel caso in cui il processo sia in stato 0 = ok vuol dire che devo reinizializzare lo step.
|
||||
* Per cui procedo con invalidare tutti gli step
|
||||
* porto il vecchio file in versione 1
|
||||
* salvo il nuovo.
|
||||
* Nel caso non esiste lo creo, se esiste ed il processo è in stato 1 sovrscrivo.
|
||||
* @param step
|
||||
* @param myFile
|
||||
* @param idProcesso
|
||||
* @param operatore
|
||||
* @param processo
|
||||
* @param tipoSla
|
||||
* @throws Exception
|
||||
*/
|
||||
public void handleUploadCsvDonor(int step, byte[] myFile, String idProcesso, String operatore,
|
||||
String processo, String tipoSla) throws Exception{
|
||||
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = getProcesso(idProcesso);
|
||||
if (dbcgoProcessoPenali != null) {
|
||||
if (dbcgoProcessoPenali.getStato().equals(new Long(0))) {
|
||||
|
||||
//se lo stato è zero vuol dire che devo reinizializare lo step.
|
||||
//vanno invalidati anche gli step successivi.
|
||||
// invalido via HQL
|
||||
updateStatoViaHQL(dbcgoProcessoPenali.getId().getMeseRiferimento().toString(),operatore,processo,tipoSla,
|
||||
dbcgoProcessoPenali.getId().getAnno().toString(),step,"N","N");
|
||||
|
||||
//recupero il file esistente
|
||||
List files = getFilePenali(dbcgoProcessoPenali.getIdProcesso(),"csv",new Long(0));
|
||||
DbcgoFilePenali dbcgoFilePenali = new DbcgoFilePenali();
|
||||
if (files.get(0)!=null) {
|
||||
dbcgoFilePenali = (DbcgoFilePenali)files.get(0);
|
||||
} else {
|
||||
throw new Exception("nessun file trovato!!!:"+dbcgoProcessoPenali.getIdProcesso());
|
||||
}
|
||||
|
||||
//procedo con l'update della riga
|
||||
updateFilePenali(dbcgoFilePenali.getId().getVersione().toString(),
|
||||
dbcgoFilePenali.getId().getIdProcesso().toString(),dbcgoFilePenali.getId().getTipoFile(),"1");
|
||||
|
||||
//inserisco in tabella il nuovo record
|
||||
saveFilePenali(myFile,"N","csv",new Long(idProcesso),new Long(0));
|
||||
} else {
|
||||
//se lo stato non è zero, sovrascrivo l'attuale filepenale.
|
||||
deleteFilePenali(new Long(idProcesso),"csv",new Long(0));
|
||||
saveFilePenali(myFile, "N", "csv", idProcesso, "0");
|
||||
}
|
||||
} else {
|
||||
//il file non esiste per cui lo creo.
|
||||
saveFilePenali(myFile, "N", "csv", idProcesso, "0");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Viene generato il report Sintesi per il trimestre ed anno in input
|
||||
|
||||
* @param trimestre
|
||||
* @param anno
|
||||
* @return
|
||||
*/
|
||||
public byte[] generaReportSintesi(String trimestre, String anno) {
|
||||
GestioneXlsBusiness business = new GestioneXlsBusiness();
|
||||
return business.generaReportSintesi(trimestre, anno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Viene generato il report Sintesi Mensile per il trimestre ed anno in input
|
||||
|
||||
* @param trimestre
|
||||
* @param anno
|
||||
* @return
|
||||
*/
|
||||
public byte[] generaReportSintesiMensile(String trimestre, String anno) {
|
||||
GestioneXlsBusiness business = new GestioneXlsBusiness();
|
||||
return business.generaReportSintesiMensile(trimestre, anno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Il metodo imposta il flag IS_CONSOLIDATO a Y per il record individuato dai parametri
|
||||
* in input.
|
||||
*
|
||||
* Per un problema di hibernate l'update sulla tabella delle penali perde il valore del
|
||||
* campo BLOB. Per aggirare il problema invochiamo una SQL standard.
|
||||
* @param versione
|
||||
* @param id_processo
|
||||
* @param tipo_file
|
||||
*/
|
||||
void updateFilePenaliConsolidato (String versione , String id_processo, String tipo_file) {
|
||||
Query query = filePenaliDAO.getSession().createSQLQuery("update Dbcgo_file_Penali set is_consolidato = 'Y'" +
|
||||
" where id_processo = :id_processo and tipo_file = :tipo_file and versione = :versione");
|
||||
|
||||
query.setParameter("id_processo", id_processo);
|
||||
query.setParameter("tipo_file", tipo_file);
|
||||
query.setParameter("versione", versione);
|
||||
query.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,628 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.bean.DonorQuadraturaBean;
|
||||
import it.valueteam.dbcgo.car.DonorQuadraturaCar;
|
||||
import it.valueteam.dbcgo.dao.impl.AnagOperatoriDao;
|
||||
import it.valueteam.dbcgo.dao.impl.DonorQuadraturaDaoImpl;
|
||||
import it.valueteam.dbcgo.dao.impl.AnagOperatoriDao.InfoOperatore;
|
||||
import it.valueteam.dbcgo.dao.intf.DonorQuadraturaDao;
|
||||
import it.valueteam.dbcgo.dto.DonorQuadraturaAnalisiDto;
|
||||
import it.valueteam.dbcgo.dto.DonorQuadraturaSintesiDto;
|
||||
import it.valueteam.dbcgo.service.ServiceLocatorException;
|
||||
import it.valueteam.dbcgo.utility.Generic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
public class DonorQuadraturaBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(DonorQuadraturaBusiness.class.getName());
|
||||
private static final int STATO_TRASFERITO = 1;
|
||||
|
||||
|
||||
public DonorQuadraturaBusiness(){}
|
||||
|
||||
public static List getListaDatiSintesiDonor(DonorQuadraturaBean aDonorQuadraturaBean) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
List listaDatiSintesi = new ArrayList();
|
||||
try {
|
||||
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
|
||||
// recupero il DAO ed eseguo la query
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
listaDatiSintesi = theDonorQuadraturaDao.getListaDatiSintesi(aDonorQuadraturaCar);
|
||||
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return listaDatiSintesi;
|
||||
}
|
||||
|
||||
public static List getListaDatiAnalisiDonor(DonorQuadraturaBean aDonorQuadraturaBean) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
|
||||
// recupero il DAO ed eseguo la query
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theDonorQuadraturaDao.getListaDatiAnalisi(aDonorQuadraturaCar);
|
||||
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return listaDatiAnalisi;
|
||||
}
|
||||
|
||||
public static Map getInfoListaDatiAnalisiDonor(DonorQuadraturaBean aDonorQuadraturaBean) throws Exception{
|
||||
log.info("Start");
|
||||
Map mappa = new HashMap();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
// recupero il DAO ed eseguo la query
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
mappa = theDonorQuadraturaDao.getInfoListaDatiAnalisi(aDonorQuadraturaCar);
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return mappa;
|
||||
}
|
||||
|
||||
public static Map getInfoListaDatiDettaglioExtraDonor(DonorQuadraturaBean aDonorQuadraturaBean) throws Exception{
|
||||
log.info("Start");
|
||||
Map mappa = new HashMap();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
// recupero il DAO ed eseguo la query
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
mappa = theDonorQuadraturaDao.getInfoListaDatiDettaglioExtra(aDonorQuadraturaCar);
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return mappa;
|
||||
}
|
||||
|
||||
public static List getListaDatiAnalisiDonorInRange(DonorQuadraturaBean aDonorQuadraturaBean,long start, long range) throws Exception{
|
||||
log.info("Start");
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
// recupero il DAO ed eseguo la query
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theDonorQuadraturaDao.getListaDatiAnalisiInRange(aDonorQuadraturaCar, start, range);
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return listaDatiAnalisi;
|
||||
}
|
||||
|
||||
public static List getListaDatiDettaglioExtraDonorInRange(DonorQuadraturaBean aDonorQuadraturaBean,long start, long range) throws Exception{
|
||||
log.info("Start");
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
// recupero il DAO ed eseguo la query
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theDonorQuadraturaDao.getListaDatiDettaglioExtraInRange(aDonorQuadraturaCar, start, range);
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return listaDatiAnalisi;
|
||||
}
|
||||
|
||||
public static byte[] getTXTReportSintesi(DonorQuadraturaBean aDonorQuadraturaBean) throws Exception {
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
List listaDatiSintesi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
|
||||
// recupero il DAO ed eseguo la query
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
listaDatiSintesi = theDonorQuadraturaDao.getListaDatiSintesi(aDonorQuadraturaCar);
|
||||
// inizio la costruzione del file
|
||||
byteTxtReport = writeTXTReportSintesi(aDonorQuadraturaBean, listaDatiSintesi);
|
||||
|
||||
} catch(Exception e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] getTXTReportAnalisi(DonorQuadraturaBean aDonorQuadraturaBean) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theDonorQuadraturaDao.getListaDatiAnalisi(aDonorQuadraturaCar);
|
||||
|
||||
// inizio la costruzione del file
|
||||
byteTxtReport = writeTXTReportAnalisi(aDonorQuadraturaBean, listaDatiAnalisi);
|
||||
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
public static byte[] getTXTReportDettaglioExtra(DonorQuadraturaBean aDonorQuadraturaBean) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = BeanToCar(aDonorQuadraturaBean);
|
||||
|
||||
DonorQuadraturaDao theDonorQuadraturaDao = new DonorQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theDonorQuadraturaDao.getListaDatiDettaglioExtra(aDonorQuadraturaCar);
|
||||
|
||||
// inizio la costruzione del file
|
||||
byteTxtReport = writeTXTReportDettaglioExtra(aDonorQuadraturaBean, listaDatiAnalisi);
|
||||
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
|
||||
// metodo accessorio per la costruzione del file di sintesi
|
||||
private static byte[] writeTXTReportSintesi(DonorQuadraturaBean aDonorQuadraturaBean, List listaDatiSintesi) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
try{
|
||||
AnagOperatoriDao anagOperatoriDao = new AnagOperatoriDao();
|
||||
String dataDal = aDonorQuadraturaBean.getDataDal();
|
||||
String meseRiferimento = dataDal.substring(6)+""+dataDal.substring(3,5);
|
||||
InfoOperatore infoOperatore = anagOperatoriDao.getInfoOperatore(aDonorQuadraturaBean.getIdOperatore());
|
||||
// creazione record di testa
|
||||
StringBuffer stringBufferHeader = new StringBuffer(90);
|
||||
|
||||
StringBuffer stringBufferHeader_ = new StringBuffer();
|
||||
stringBufferHeader_.append(Generic.fillWith(1,' ')); // filler(1)
|
||||
stringBufferHeader_.append("RS"); // tipo record(2)
|
||||
if(aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
} else {
|
||||
//inserisco il corretto operatore
|
||||
stringBufferHeader_.append(infoOperatore.getGestore_aom()); // codice operatore recipient di rete(4)
|
||||
}
|
||||
stringBufferHeader_.append("TIMG"); // codice operatore donating(4)
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferHeader_.append(infoOperatore.getId_operatore()); // codice operatore virtuale recipient(4)
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
if("TIM".equalsIgnoreCase(aDonorQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' ')); // codice operatore virtuale donating(4)
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFillwhite(4,aDonorQuadraturaBean.getIdOperatoreVirtuale())); // codice operatore virtuale donating(4)
|
||||
}
|
||||
stringBufferHeader_.append(meseRiferimento); // mese di riferimento(6)
|
||||
stringBufferHeader_.append("SIN_" + meseRiferimento); // nome file(10)
|
||||
stringBufferHeader.append(Generic.plainRow(stringBufferHeader_.toString()));
|
||||
stringBufferHeader.append("\r\n");
|
||||
|
||||
// creazione dei record centrali
|
||||
int numeroDisposizioni = 0;
|
||||
double totaleImporti = 0;
|
||||
int contatore = 0;
|
||||
StringBuffer stringBufferBody = new StringBuffer();
|
||||
|
||||
Iterator iterator = listaDatiSintesi.iterator();
|
||||
while(iterator.hasNext()){
|
||||
contatore++;
|
||||
DonorQuadraturaSintesiDto aDonorQuadraturaSinteticaDto = (DonorQuadraturaSintesiDto)iterator.next();
|
||||
numeroDisposizioni = numeroDisposizioni + aDonorQuadraturaSinteticaDto.getNumeroPosizioniTrasferite();
|
||||
totaleImporti = totaleImporti + aDonorQuadraturaSinteticaDto.getTotaleImportiTrasferiti();
|
||||
StringBuffer stringBufferBody_ = new StringBuffer();
|
||||
stringBufferBody_.append(Generic.fillWith(1,' '));
|
||||
stringBufferBody_.append("20");
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000",""+contatore));
|
||||
String dataNC = Generic.DateToString(aDonorQuadraturaSinteticaDto.getDataNotificaCredito(), "dd-MM-yyyy");
|
||||
//porto in formato yyyyMMdd
|
||||
dataNC = dataNC.substring(6)+""+dataNC.substring(3,5)+""+dataNC.substring(0,2);
|
||||
stringBufferBody_.append(dataNC);
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(aDonorQuadraturaSinteticaDto.getTotaleImportiTrasferiti())));
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000",""+aDonorQuadraturaSinteticaDto.getNumeroPosizioniTrasferite()));
|
||||
//stringBufferBody_.append(aDonorQuadraturaSinteticaDto.getOperatoreRecipient());
|
||||
stringBufferBody.append(Generic.plainRow(stringBufferBody_.toString()));
|
||||
stringBufferBody.append("\r\n");
|
||||
}
|
||||
|
||||
// creazione record di coda
|
||||
StringBuffer stringBufferFooter = new StringBuffer(90);
|
||||
StringBuffer stringBufferFooter_ = new StringBuffer();
|
||||
stringBufferFooter_.append(Generic.fillWith(1,' ')); // filler(1)
|
||||
stringBufferFooter_.append("RF"); // tipo record
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferFooter_.append(infoOperatore.getGestore_aom()); // codice operatore recipient reale(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL")); // codice operatore recipient ALL(4)
|
||||
}
|
||||
stringBufferFooter_.append("TIMG"); // codice operatore donating(4)
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferFooter_.append(infoOperatore.getId_operatore()); // codice operatore virtuale recipient(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
if("TIM".equalsIgnoreCase(aDonorQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFillwhite(4,aDonorQuadraturaBean.getIdOperatoreVirtuale())); // codice operatore virtuale donating(4)
|
||||
}
|
||||
stringBufferFooter_.append(meseRiferimento); // mese di riferimento(6)
|
||||
stringBufferFooter_.append("SIN_" + meseRiferimento); // nome file(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+numeroDisposizioni)); // numero disposizioni(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(totaleImporti))); //totale importi trasferiti(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000",""+(listaDatiSintesi.size()+2))); // numero record(10)
|
||||
stringBufferFooter.append(Generic.plainRow(stringBufferFooter_.toString()));
|
||||
stringBufferFooter.append("\r\n");
|
||||
|
||||
String txtReport = stringBufferHeader.toString()+stringBufferBody.toString()+stringBufferFooter.toString();
|
||||
byteTxtReport = txtReport.getBytes();
|
||||
log.info("End");
|
||||
} catch (Exception e){
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
|
||||
// metodo accessorio per la costruzione del file di analisi
|
||||
private static byte[] writeTXTReportAnalisi(DonorQuadraturaBean aDonorQuadraturaBean, List listaDatiAnalisi) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
try{
|
||||
AnagOperatoriDao anagOperatoriDao = new AnagOperatoriDao();
|
||||
String dataDal = aDonorQuadraturaBean.getDataDal();
|
||||
String dataRiferimento = dataDal.substring(6)+""+dataDal.substring(3,5)+""+dataDal.substring(0,2);
|
||||
InfoOperatore infoOperatore = anagOperatoriDao.getInfoOperatore(aDonorQuadraturaBean.getIdOperatore());
|
||||
log.info("----------------RECORD TESTA-----------------------");
|
||||
// creazione record di testa
|
||||
StringBuffer stringBufferHeader = new StringBuffer(90);
|
||||
StringBuffer stringBufferHeader_ = new StringBuffer(90);
|
||||
stringBufferHeader_.append(Generic.fillWith(1,' '));
|
||||
stringBufferHeader_.append("PC");
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferHeader_.append(infoOperatore.getGestore_aom());
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferHeader_.append("TIMG");
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferHeader_.append(infoOperatore.getId_operatore()); // codice operatore virtuale recipient(4)
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
if("TIM".equalsIgnoreCase(aDonorQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFillwhite(4,aDonorQuadraturaBean.getIdOperatoreVirtuale()));
|
||||
}
|
||||
stringBufferHeader_.append(dataRiferimento);
|
||||
stringBufferHeader_.append("D_"+dataRiferimento);
|
||||
stringBufferHeader.append(Generic.plainRow(stringBufferHeader_.toString()));
|
||||
stringBufferHeader.append("\r\n");
|
||||
// creazione dei record centrali
|
||||
double totaleImporti = 0;
|
||||
int contatore = 0;
|
||||
StringBuffer stringBufferBody = new StringBuffer();
|
||||
|
||||
Iterator iterator = listaDatiAnalisi.iterator();
|
||||
log.info("----------------RECORD CENTRALI-----------------------");
|
||||
while(iterator.hasNext()){
|
||||
StringBuffer stringBufferBody_ = new StringBuffer();
|
||||
contatore++;
|
||||
DonorQuadraturaAnalisiDto aDonorQuadraturaAnalisiDto = (DonorQuadraturaAnalisiDto)iterator.next();
|
||||
log.info("----------------DTO-----------------------");
|
||||
log.info(aDonorQuadraturaAnalisiDto.getCodiceRichiestaRecipient());
|
||||
log.info(aDonorQuadraturaAnalisiDto.getAmbito());
|
||||
log.info(aDonorQuadraturaAnalisiDto.getMsisdn());
|
||||
log.info(aDonorQuadraturaAnalisiDto.getUtenza());
|
||||
log.info(aDonorQuadraturaAnalisiDto.getOperatoreDonor());
|
||||
log.info(aDonorQuadraturaAnalisiDto.getOperatoreRecipient());
|
||||
log.info("------------------------------------------");
|
||||
|
||||
totaleImporti = totaleImporti + aDonorQuadraturaAnalisiDto.getImportoTrasferito();
|
||||
|
||||
stringBufferBody_.append(Generic.fillWith(1,' '));
|
||||
stringBufferBody_.append("10");
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000",""+contatore));
|
||||
String realCodiceRichiestaRecipient = aDonorQuadraturaAnalisiDto.getCodiceRichiestaRecipient().substring(5, aDonorQuadraturaAnalisiDto.getCodiceRichiestaRecipient().length());
|
||||
String contenitore18Blank = " ";
|
||||
stringBufferBody_.append(Generic.strRightFill(contenitore18Blank, realCodiceRichiestaRecipient));
|
||||
// SM_1922: tolti questi ulteriori spazi non previsti dalle specifiche
|
||||
// stringBufferBody_.append(Generic.fillWith(18-realCodiceRichiestaRecipient.length(),' '));
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(aDonorQuadraturaAnalisiDto.getImportoTrasferito())));
|
||||
//stringBufferBody_.append(aDonorQuadraturaAnalisiDto.getOperatoreRecipient());
|
||||
stringBufferBody.append(Generic.plainRow(stringBufferBody_.toString()));
|
||||
stringBufferBody.append("\r\n");
|
||||
}
|
||||
log.info("----------------RECORD CODA-----------------------");
|
||||
// creazione record di coda
|
||||
StringBuffer stringBufferFooter = new StringBuffer(90);
|
||||
StringBuffer stringBufferFooter_ = new StringBuffer(90);
|
||||
stringBufferFooter_.append(Generic.fillWith(1,' '));
|
||||
stringBufferFooter_.append("EF");
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferFooter_.append(infoOperatore.getGestore_aom()); // codice operatore recipient(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferFooter_.append("TIMG");
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferFooter_.append(infoOperatore.getId_operatore()); // codice operatore virtuale recipient(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
|
||||
if("TIM".equalsIgnoreCase(aDonorQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFillwhite(4,aDonorQuadraturaBean.getIdOperatoreVirtuale()));
|
||||
}
|
||||
stringBufferFooter_.append(dataRiferimento);
|
||||
stringBufferFooter_.append("D_"+dataRiferimento);
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+listaDatiAnalisi.size()));
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(totaleImporti)));
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+(listaDatiAnalisi.size()+2)));
|
||||
stringBufferFooter.append(Generic.plainRow(stringBufferFooter_.toString()));
|
||||
stringBufferFooter.append("\r\n");
|
||||
|
||||
String txtReport = stringBufferHeader.toString()+stringBufferBody.toString()+stringBufferFooter.toString();
|
||||
byteTxtReport = txtReport.getBytes();
|
||||
log.info("End");
|
||||
} catch (Exception e){
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
// metodo accessorio per la costruzione del file di analisi
|
||||
private static byte[] writeTXTReportDettaglioExtra(DonorQuadraturaBean aDonorQuadraturaBean, List listaDatiAnalisi) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
try{
|
||||
AnagOperatoriDao anagOperatoriDao = new AnagOperatoriDao();
|
||||
String dataDal = aDonorQuadraturaBean.getDataDal();
|
||||
String dataRiferimento = dataDal.substring(6)+""+dataDal.substring(3,5)+""+dataDal.substring(0,2);
|
||||
InfoOperatore infoOperatore = anagOperatoriDao.getInfoOperatore(aDonorQuadraturaBean.getIdOperatore());
|
||||
// creazione record di testa
|
||||
StringBuffer stringBufferHeader = new StringBuffer(90);
|
||||
StringBuffer stringBufferHeader_ = new StringBuffer();
|
||||
stringBufferHeader_.append(Generic.fillWith(1,' '));
|
||||
stringBufferHeader_.append("TE");
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferHeader_.append(infoOperatore.getGestore_aom());
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferHeader_.append("TIMG");
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferHeader_.append(infoOperatore.getId_operatore()); // codice operatore virtuale recipient(4)
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
|
||||
if("TIM".equalsIgnoreCase(aDonorQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFillwhite(4,aDonorQuadraturaBean.getIdOperatoreVirtuale()));
|
||||
}
|
||||
stringBufferHeader_.append(dataRiferimento);
|
||||
stringBufferHeader_.append("D_"+dataRiferimento);
|
||||
stringBufferHeader.append(Generic.plainRow(stringBufferHeader_.toString()));
|
||||
stringBufferHeader.append("\r\n");
|
||||
|
||||
// creazione dei record centrali
|
||||
double totaleImporti = 0;
|
||||
int contatore = 0;
|
||||
StringBuffer stringBufferBody = new StringBuffer();
|
||||
|
||||
Iterator iterator = listaDatiAnalisi.iterator();
|
||||
while(iterator.hasNext()){
|
||||
StringBuffer stringBufferBody_ = new StringBuffer();
|
||||
contatore++;
|
||||
DonorQuadraturaAnalisiDto aDonorQuadraturaAnalisiDto = (DonorQuadraturaAnalisiDto)iterator.next();
|
||||
totaleImporti = totaleImporti + aDonorQuadraturaAnalisiDto.getImportoTrasferito();
|
||||
|
||||
|
||||
stringBufferBody_.append(Generic.fillWith(1,' '));
|
||||
stringBufferBody_.append("30");
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000",""+contatore));
|
||||
|
||||
String realCodiceRichiestaRecipient = aDonorQuadraturaAnalisiDto.getCodiceRichiestaRecipient().substring(5, aDonorQuadraturaAnalisiDto.getCodiceRichiestaRecipient().length());
|
||||
String contenitore18Blank = " ";
|
||||
|
||||
stringBufferBody_.append(Generic.strRightFill(contenitore18Blank, realCodiceRichiestaRecipient));
|
||||
|
||||
// SM_1922: tolti questi ulteriori spazi non previsti dalle specifiche
|
||||
//stringBufferBody_.append(Generic.fillWith(18-realCodiceRichiestaRecipient.length(),' '));
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(aDonorQuadraturaAnalisiDto.getImportoTrasferito())));
|
||||
stringBufferBody_.append(aDonorQuadraturaAnalisiDto.getOperatoreRecipient());
|
||||
stringBufferBody_.append(Generic.strLeftFill("000000000000000",aDonorQuadraturaAnalisiDto.getMsisdn()));
|
||||
if(aDonorQuadraturaAnalisiDto.getUtenza().equals("PRP")){
|
||||
stringBufferBody_.append("PP ");
|
||||
} else {
|
||||
stringBufferBody_.append(aDonorQuadraturaAnalisiDto.getUtenza());
|
||||
}
|
||||
stringBufferBody_.append(aDonorQuadraturaAnalisiDto.getAmbito());
|
||||
stringBufferBody.append(Generic.plainRow(stringBufferBody_.toString()));
|
||||
|
||||
stringBufferBody.append("\r\n");
|
||||
}
|
||||
|
||||
// creazione record di coda
|
||||
StringBuffer stringBufferFooter = new StringBuffer(90);
|
||||
|
||||
StringBuffer stringBufferFooter_ = new StringBuffer();
|
||||
stringBufferFooter_.append(Generic.fillWith(1,' '));
|
||||
stringBufferFooter_.append("CO");
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferFooter_.append(infoOperatore.getGestore_aom()); // codice operatore recipient(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferFooter_.append("TIMG");
|
||||
if(!aDonorQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferFooter_.append(infoOperatore.getId_operatore()); // codice operatore virtuale recipient(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
|
||||
|
||||
if("TIM".equalsIgnoreCase(aDonorQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFillwhite(4,aDonorQuadraturaBean.getIdOperatoreVirtuale()));
|
||||
}
|
||||
stringBufferFooter_.append(dataRiferimento);
|
||||
stringBufferFooter_.append("D_"+dataRiferimento);
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+listaDatiAnalisi.size()));
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(totaleImporti)));
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+(listaDatiAnalisi.size()+2)));
|
||||
stringBufferFooter.append(Generic.plainRow(stringBufferFooter_.toString()));
|
||||
stringBufferFooter.append("\r\n");
|
||||
|
||||
String txtReport = stringBufferHeader.toString()+stringBufferBody.toString()+stringBufferFooter.toString();
|
||||
byteTxtReport = txtReport.getBytes();
|
||||
log.info("End");
|
||||
} catch (Exception e){
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
private static DonorQuadraturaCar BeanToCar(DonorQuadraturaBean aDonorQuadraturaBean){
|
||||
|
||||
DonorQuadraturaCar aDonorQuadraturaCar = new DonorQuadraturaCar();
|
||||
aDonorQuadraturaCar.setIdOperatore(aDonorQuadraturaBean.getIdOperatore());
|
||||
|
||||
// eseguo controlli su idOperatore Virtuale
|
||||
String idOperatoreVirtuale = aDonorQuadraturaBean.getIdOperatoreVirtuale();
|
||||
if("TIM".equalsIgnoreCase(idOperatoreVirtuale)){
|
||||
idOperatoreVirtuale = idOperatoreVirtuale+"%";
|
||||
} else if("ALL".equalsIgnoreCase(idOperatoreVirtuale)){
|
||||
idOperatoreVirtuale = "%%";
|
||||
}
|
||||
aDonorQuadraturaCar.setIdOperatoreVirtuale(idOperatoreVirtuale);
|
||||
|
||||
aDonorQuadraturaCar.setDataDal(aDonorQuadraturaBean.getDataDal());
|
||||
aDonorQuadraturaCar.setDataAl(aDonorQuadraturaBean.getDataAl());
|
||||
aDonorQuadraturaCar.setIdStato(STATO_TRASFERITO);
|
||||
|
||||
return aDonorQuadraturaCar;
|
||||
}
|
||||
|
||||
private static boolean isVirt(InfoOperatore info){
|
||||
if ("VIRT".equals(info.getTipo_operatore().trim()))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoGestRicDonVirtViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoVoPrevalidazioneDbcDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoGestRicDonVirtView;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoVoPrevalidazioneDbc;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.RestrictionBuilder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
public class DonorVirtMvnoBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(DonorVirtMvnoBusiness.class.getName());
|
||||
private List criterion;
|
||||
private DbcgoGestRicDonVirtViewDAO dbcgoGestRicDonVirtViewDAO;
|
||||
private DynaWorkForm dwm;
|
||||
|
||||
public DonorVirtMvnoBusiness () {
|
||||
dbcgoGestRicDonVirtViewDAO = new DbcgoGestRicDonVirtViewDAO();
|
||||
}
|
||||
|
||||
public void instanceCriteria(Map _map){
|
||||
dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
}
|
||||
|
||||
public List eseguiRicerca (int start, int range) {
|
||||
List opcol_lista_dati = new ArrayList();
|
||||
List opcol_lista_dati_uscita = new ArrayList();
|
||||
opcol_lista_dati = (List)dbcgoGestRicDonVirtViewDAO.findByCriteriaRange(getCriterion(),start,range);
|
||||
log.info("opcol_lista_dati.size():" + opcol_lista_dati.size());
|
||||
Iterator it = opcol_lista_dati.iterator();
|
||||
while (it.hasNext()) {
|
||||
DbcgoVoPrevalidazioneDbcDAO dbcgoVoPrevalidazioneDbcDAO = new DbcgoVoPrevalidazioneDbcDAO();
|
||||
DbcgoGestRicDonVirtView dbcgoGestRicDonVirtView = (DbcgoGestRicDonVirtView)it.next();
|
||||
String rifiutoValidazione = dbcgoGestRicDonVirtView.getCodicerifiutovalidazione();
|
||||
if(rifiutoValidazione!=null && !("").equals(rifiutoValidazione.trim())){
|
||||
String[] codiciA = rifiutoValidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ", <br>";;
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicDonVirtView.setCodicerifiutovalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String prevalidazione = dbcgoGestRicDonVirtView.getPrevalidazione();
|
||||
if(prevalidazione!=null && !("").equals(prevalidazione.trim())){
|
||||
String[] codiciA = prevalidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel() +", <br>";
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicDonVirtView.setPrevalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
opcol_lista_dati_uscita.add(dbcgoGestRicDonVirtView);
|
||||
}
|
||||
|
||||
log.info("Record trovati: " + opcol_lista_dati.size());
|
||||
log.info("Record trovati dopo decode: " + opcol_lista_dati_uscita.size());
|
||||
return opcol_lista_dati;
|
||||
}
|
||||
|
||||
public List eseguiRicerca () {
|
||||
List opcol_lista_dati = new ArrayList();
|
||||
List opcol_lista_dati_uscita = new ArrayList();
|
||||
opcol_lista_dati = (List)dbcgoGestRicDonVirtViewDAO.findByCriteria(getCriterion());
|
||||
Iterator it = opcol_lista_dati.iterator();
|
||||
while (it.hasNext()) {
|
||||
DbcgoVoPrevalidazioneDbcDAO dbcgoVoPrevalidazioneDbcDAO = new DbcgoVoPrevalidazioneDbcDAO();
|
||||
DbcgoGestRicDonVirtView dbcgoGestRicDonVirtView = (DbcgoGestRicDonVirtView)it.next();
|
||||
String rifiutoValidazione = dbcgoGestRicDonVirtView.getCodicerifiutovalidazione();
|
||||
if(rifiutoValidazione!=null && !("").equals(rifiutoValidazione.trim())){
|
||||
String[] codiciA = rifiutoValidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ", <br>";;
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicDonVirtView.setCodicerifiutovalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String prevalidazione = dbcgoGestRicDonVirtView.getPrevalidazione();
|
||||
if(prevalidazione!=null && !("").equals(prevalidazione.trim())){
|
||||
String[] codiciA = prevalidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel() +", <br>";
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicDonVirtView.setPrevalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
opcol_lista_dati_uscita.add(dbcgoGestRicDonVirtView);
|
||||
}
|
||||
|
||||
log.info("Record trovati: " + opcol_lista_dati.size());
|
||||
log.info("Record trovati dopo decode: " + opcol_lista_dati_uscita.size());
|
||||
return opcol_lista_dati;
|
||||
}
|
||||
|
||||
public int count () {
|
||||
return dbcgoGestRicDonVirtViewDAO.findByCriteriaCount(getCriterion());
|
||||
}
|
||||
|
||||
public List getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
public void setCriterion(List criterion) {
|
||||
this.criterion = criterion;
|
||||
}
|
||||
|
||||
public DynaWorkForm getDwm() {
|
||||
return dwm;
|
||||
}
|
||||
|
||||
public void setDwm(DynaWorkForm dwm) {
|
||||
this.dwm = dwm;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.MnpDwXmlInOutViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.MnpDwXmlInOutDto;
|
||||
import it.valueteam.dbcgo.hb.dto.MnpDwXmlInOutView;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm.OggettoDyna;
|
||||
import it.valueteam.dbcgo.utility.JavaUtilsClass;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class FilesXmlBusiness {
|
||||
static Logger log = Logger.getLogger(FilesXmlBusiness.class.getName());
|
||||
|
||||
public List criterion;
|
||||
public MnpDwXmlInOutViewDAO mnpDwXmlInOutViewDAO;
|
||||
private Vector vlist = new Vector();
|
||||
private JavaUtilsClass juc = new JavaUtilsClass();
|
||||
|
||||
public FilesXmlBusiness() {
|
||||
mnpDwXmlInOutViewDAO = new MnpDwXmlInOutViewDAO();
|
||||
}
|
||||
|
||||
public void instanceCriteria(Map _map) {
|
||||
DynaWorkForm dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
//criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
vlist = dwm.getVlist();
|
||||
criterion = this.getCriterion();
|
||||
}
|
||||
|
||||
public List eseguiRicerca() {
|
||||
return (List) mnpDwXmlInOutViewDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
public List eseguiRicercaRange(int start, int range) {
|
||||
return (List) mnpDwXmlInOutViewDAO.findByCriteriaRange(getCriterion(), start, range);
|
||||
}
|
||||
|
||||
public List eseguiRicercaDistinct(Map params) {
|
||||
return (List) mnpDwXmlInOutViewDAO.findByCriteriaDistinct(params);
|
||||
}
|
||||
|
||||
public List eseguiRicercaDistinctRange(Map params, int start, int range) {
|
||||
List lori = (List) mnpDwXmlInOutViewDAO.findByCriteriaDistinctRange(params, start, range);
|
||||
|
||||
Iterator iter = lori.iterator();
|
||||
if (!iter.hasNext()) {
|
||||
return lori;
|
||||
}
|
||||
List lnew = new ArrayList();
|
||||
while (iter.hasNext()) {
|
||||
MnpDwXmlInOutDto obj = (MnpDwXmlInOutDto) iter.next();
|
||||
List crit = new ArrayList();
|
||||
crit.add(Restrictions.eq("id.nomeFile", obj.getNomeFile()));
|
||||
List childsView = mnpDwXmlInOutViewDAO.findByCriteria(crit);
|
||||
List childsDto = new ArrayList(childsView.size());
|
||||
for(Iterator childIter = childsView.iterator(); childIter.hasNext();) {
|
||||
MnpDwXmlInOutView childView = (MnpDwXmlInOutView) childIter.next();
|
||||
MnpDwXmlInOutDto dto = new MnpDwXmlInOutDto();
|
||||
dto.setIdRichiesta(childView.getId().getIdRichiesta());
|
||||
dto.setMsisdn(childView.getMsisdn());
|
||||
childsDto.add(dto);
|
||||
}
|
||||
obj.setChild(childsDto);
|
||||
lnew.add(obj);
|
||||
}
|
||||
return lnew;
|
||||
}
|
||||
|
||||
public void setCriterion(List criterion) {
|
||||
this.criterion = criterion;
|
||||
}
|
||||
|
||||
public int count() {
|
||||
return mnpDwXmlInOutViewDAO.findByCriteriaCount(getCriterion());
|
||||
}
|
||||
|
||||
public int distictCount() {
|
||||
return mnpDwXmlInOutViewDAO.findByCriteriaDistinctCount(getCriterion());
|
||||
}
|
||||
|
||||
public List getCriterion() {
|
||||
ArrayList criterion = new ArrayList();
|
||||
for (int i = 0; i < vlist.size(); i++) {
|
||||
OggettoDyna oDyna = (OggettoDyna) vlist.get(i);
|
||||
String prop = oDyna.getChiave();
|
||||
log.debug("chiave: " + prop + " valore: " + oDyna.getValore());
|
||||
if (prop.equals("nomeFileXml")) {
|
||||
Object valore = "";
|
||||
if (oDyna.getValore() != null) {
|
||||
valore = (String) oDyna.getValore();
|
||||
}
|
||||
Criterion _firstCrit = Restrictions.eq("id.nomeFileAck", valore);
|
||||
Criterion _SecondCrit = Restrictions.eq("id.nomeFileXml", valore);
|
||||
LogicalExpression orExp = Restrictions.or(_firstCrit, _SecondCrit);
|
||||
criterion.add(orExp);
|
||||
} else if (prop.equals("idRichiesta")) {
|
||||
Object valore = "";
|
||||
if (oDyna.getValore() != null) {
|
||||
valore = (String) oDyna.getValore();
|
||||
}
|
||||
criterion.add(Restrictions.eq("id.idRichiesta", valore));
|
||||
} else if (prop.equals("dataFrom")) {
|
||||
String dataa = null;
|
||||
String valore = oDyna.getValore();
|
||||
Date dDate = juc.StringToDate(valore, "dd/MM/yyyy");
|
||||
criterion.add(Restrictions.ge("data", dDate));
|
||||
} else if (prop.equals("dataTo")) {
|
||||
String dataa = null;
|
||||
String valore = oDyna.getValore();
|
||||
Date dDate = juc.StringToDate(valore, "dd/MM/yyyy");
|
||||
//aggiungo un giorno
|
||||
Date plusDay = new Date(dDate.getTime() + 86400000);
|
||||
criterion.add(Restrictions.le("data", plusDay));
|
||||
} else {
|
||||
String valore = oDyna.getValore();
|
||||
criterion.add(Restrictions.eq(prop, valore));
|
||||
}
|
||||
}
|
||||
return criterion;
|
||||
}
|
||||
|
||||
/* public static void main(String[] args) {
|
||||
FilesXmlBusiness test = new FilesXmlBusiness();
|
||||
test.prova();
|
||||
|
||||
}
|
||||
|
||||
private void prova() {
|
||||
//To change body of created methods use File | Settings | File Templates.
|
||||
HashMap params = new HashMap();
|
||||
params.put("nomeFileXml", "H3GI20110404143700TIMG22222");
|
||||
List results = eseguiRicercaDistinctRange(params, 0, 5);
|
||||
} */
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.exception.CsvFormatException;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoAnagFranchigieDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoAnagFranchigie;
|
||||
import it.valueteam.dbcgo.utility.JavaUtilsClass;
|
||||
import it.valueteam.dbcgo.utility.penali.ExcelUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: SeiditaNi
|
||||
* Date: 20/06/12
|
||||
* Time: 17.08
|
||||
*/
|
||||
public class FranchigieBusiness {
|
||||
static Logger log = Logger.getLogger(FranchigieBusiness.class.getName());
|
||||
static final String PATTERN = "dd/MM/yyyy";
|
||||
|
||||
/**
|
||||
* Legge il file importato e salva il contenuto sul db.
|
||||
*
|
||||
* @param myfile
|
||||
*/
|
||||
public void readCSV(byte[] myfile) throws CsvFormatException {
|
||||
try {
|
||||
//create BufferedReader to read csv file
|
||||
String csv = new String(myfile);
|
||||
BufferedReader br = new BufferedReader(new StringReader(csv));
|
||||
String strLine = "";
|
||||
StringTokenizer st = null;
|
||||
int lineNumber = 0, tokenNumber = 0, i = 0;
|
||||
//read comma separated file line by line
|
||||
List dati = new ArrayList();
|
||||
boolean isDonating = false;
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
String[] columns = strLine.split(";");
|
||||
if (columns.length != 9 && columns.length != 11) {
|
||||
log.info("******** TROVATA RIGA CON " +columns.length+" COLONNE");
|
||||
throw new CsvFormatException("Formato file non corretto");
|
||||
}
|
||||
|
||||
//break comma separated line using ","
|
||||
st = new StringTokenizer(strLine, ";");
|
||||
DbcgoAnagFranchigie dbcgoAnagFranchigie = new DbcgoAnagFranchigie();
|
||||
while (st.hasMoreTokens()) {
|
||||
String token = st.nextToken();
|
||||
//display csv values
|
||||
if (i == 2) {
|
||||
isDonating = isDonating(token);
|
||||
if (isDonating) {
|
||||
log.info("UPLOAD FRANCHIGIE DI TIPO DONOR");
|
||||
} else {
|
||||
log.info("UPLOAD FRANCHIGIE DI TIPO RECIPIENT");
|
||||
}
|
||||
// Ulteriore controllo sul formato
|
||||
if (isDonating && columns.length != 11) { // file donating deve avere 11 colonne
|
||||
throw new CsvFormatException("Formato file non corretto");
|
||||
} else if (!isDonating && columns.length != 9) { // file recipient ha 9 colonne
|
||||
throw new CsvFormatException("Formato file non corretto");
|
||||
}
|
||||
}
|
||||
i++;
|
||||
if (lineNumber > 0) {
|
||||
if (isDonating) {
|
||||
dbcgoAnagFranchigie = popolaDonating(dbcgoAnagFranchigie, token, tokenNumber);
|
||||
} else {
|
||||
dbcgoAnagFranchigie = popolaRecipient(dbcgoAnagFranchigie, token, tokenNumber);
|
||||
}
|
||||
}
|
||||
tokenNumber++;
|
||||
}
|
||||
//set tipo processo
|
||||
if (isDonating) {
|
||||
dbcgoAnagFranchigie.setTipoProcesso("D");
|
||||
} else {
|
||||
dbcgoAnagFranchigie.setTipoProcesso("R");
|
||||
}
|
||||
//add dbcgoAnagFranchigie to list for saving action
|
||||
if (lineNumber > 0) {
|
||||
dati.add(dbcgoAnagFranchigie);
|
||||
}
|
||||
//reset token number
|
||||
tokenNumber = 0;
|
||||
//nextline
|
||||
lineNumber++;
|
||||
|
||||
}
|
||||
//write list on db.
|
||||
save(dati);
|
||||
} catch (Exception e) {
|
||||
log.warn(e);
|
||||
if (e instanceof CsvFormatException) {
|
||||
CsvFormatException cfe = (CsvFormatException) e;
|
||||
throw cfe;
|
||||
}
|
||||
log.error("Exception while reading csv file: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Popola l'oggetto in modalita' recipient
|
||||
*
|
||||
* @param dbcgoAnagFranchigie
|
||||
* @param token
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private DbcgoAnagFranchigie popolaRecipient(DbcgoAnagFranchigie dbcgoAnagFranchigie, String token, int id) throws CsvFormatException {
|
||||
switch (id) {
|
||||
case 0:
|
||||
dbcgoAnagFranchigie.setDonatingOspitato(token);
|
||||
break;
|
||||
case 1:
|
||||
dbcgoAnagFranchigie.setDonatingRete(token);
|
||||
break;
|
||||
case 2:
|
||||
dbcgoAnagFranchigie.setDataEvento(new JavaUtilsClass().StringToDate(token, PATTERN));
|
||||
break;
|
||||
case 3:
|
||||
if (!isTipoEventoMNP(token)) {
|
||||
throw new CsvFormatException(CsvFormatException.SLA_NON_PERMESSO);
|
||||
}
|
||||
dbcgoAnagFranchigie.setTipoEvento(token);
|
||||
break;
|
||||
case 4:
|
||||
dbcgoAnagFranchigie.setEventiAttesi(new Long(token));
|
||||
break;
|
||||
case 5:
|
||||
dbcgoAnagFranchigie.setEventiSla(new Long(token));
|
||||
break;
|
||||
case 6:
|
||||
dbcgoAnagFranchigie.setEventiFuoriSla(new Long(token));
|
||||
break;
|
||||
case 7:
|
||||
dbcgoAnagFranchigie.setPercentualeFranchigia(new Long(token));
|
||||
break;
|
||||
case 8:
|
||||
dbcgoAnagFranchigie.setSuperamentoSoglia(token);
|
||||
break;
|
||||
}
|
||||
return dbcgoAnagFranchigie;
|
||||
}
|
||||
|
||||
/**
|
||||
* popola l'oggetto in modalita' donating
|
||||
*
|
||||
* @param dbcgoAnagFranchigie
|
||||
* @param token
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private DbcgoAnagFranchigie popolaDonating(DbcgoAnagFranchigie dbcgoAnagFranchigie, String token, int id) throws CsvFormatException {
|
||||
//Donating Ospitato;Donating di Rete ;Recipient Ospitato;Recipient di Rete ;Data Evento;
|
||||
// Tipo Evento;Eventi Attesi;Eventi in SLA;Eventi Fuori SLA;Percentuale Franchigia;Superamento Soglia
|
||||
switch (id) {
|
||||
case 0:
|
||||
dbcgoAnagFranchigie.setDonatingOspitato(token);
|
||||
break;
|
||||
case 1:
|
||||
dbcgoAnagFranchigie.setDonatingRete(token);
|
||||
break;
|
||||
case 2:
|
||||
dbcgoAnagFranchigie.setRecipientOspitato(token);
|
||||
break;
|
||||
case 3:
|
||||
dbcgoAnagFranchigie.setRecipientRete(token);
|
||||
break;
|
||||
case 4:
|
||||
dbcgoAnagFranchigie.setDataEvento(new JavaUtilsClass().StringToDate(token, PATTERN));
|
||||
break;
|
||||
case 5:
|
||||
if (!isTipoEventoMNP(token)) {
|
||||
throw new CsvFormatException(CsvFormatException.SLA_NON_PERMESSO);
|
||||
}
|
||||
dbcgoAnagFranchigie.setTipoEvento(token);
|
||||
break;
|
||||
case 6:
|
||||
dbcgoAnagFranchigie.setEventiAttesi(new Long(token));
|
||||
break;
|
||||
case 7:
|
||||
dbcgoAnagFranchigie.setEventiSla(new Long(token));
|
||||
break;
|
||||
case 8:
|
||||
dbcgoAnagFranchigie.setEventiFuoriSla(new Long(token));
|
||||
break;
|
||||
case 9:
|
||||
dbcgoAnagFranchigie.setPercentualeFranchigia(new Long(token));
|
||||
break;
|
||||
case 10:
|
||||
dbcgoAnagFranchigie.setSuperamentoSoglia(token);
|
||||
break;
|
||||
}
|
||||
return dbcgoAnagFranchigie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Effettua il salvataggio della lista.
|
||||
*
|
||||
* @param mylist
|
||||
*/
|
||||
private void save(List mylist) {
|
||||
Iterator it = mylist.iterator();
|
||||
DbcgoAnagFranchigieDAO dbcgoAnagFranchigieDAO = new DbcgoAnagFranchigieDAO();
|
||||
while (it.hasNext()) {
|
||||
DbcgoAnagFranchigie dbcgoAnagFranchigie = (DbcgoAnagFranchigie) it.next();
|
||||
try {
|
||||
dbcgoAnagFranchigieDAO.save(dbcgoAnagFranchigie);
|
||||
} catch (Exception ex) {
|
||||
//log.error("Exception in save: " + ex);
|
||||
}
|
||||
}
|
||||
dbcgoAnagFranchigieDAO.closeSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* Controlla se il processo e' recipient.
|
||||
*
|
||||
* @param process
|
||||
* @return
|
||||
*/
|
||||
private boolean isDonating(String process) {
|
||||
if (process.trim().equals("Recipient Ospitato") || process.indexOf("Recipient") > 0) {
|
||||
log.info("PROCESSO DONOR");
|
||||
return true;
|
||||
}
|
||||
log.info("PROCESSO RECIPIENT");
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isTipoEventoMNP(String token) {
|
||||
if (!token.equalsIgnoreCase(ExcelUtils.TIPO_SLA0)) {
|
||||
if (!token.equalsIgnoreCase(ExcelUtils.TIPO_SLA1)) {
|
||||
if (!token.equalsIgnoreCase(ExcelUtils.TIPO_SLA2)) {
|
||||
if (!token.equalsIgnoreCase(ExcelUtils.TIPO_SLA3)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
|
||||
|
||||
import it.valueteam.dbcgo.dao.impl.GenericComboDaoImpl;
|
||||
import it.valueteam.dbcgo.service.ServiceLocatorException;
|
||||
import it.valueteam.dbcgo.dto.GenericComboDto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class GenericComboBusiness {
|
||||
static Logger log = Logger.getLogger(GenericComboBusiness.class.getName());
|
||||
public GenericComboBusiness(){}
|
||||
|
||||
public static void genericComboInit(){
|
||||
|
||||
}
|
||||
public static Vector getElencoCombo(){
|
||||
try {
|
||||
if (log.isDebugEnabled()) log.debug("getElencoCombo() - I");
|
||||
GenericComboDaoImpl gComboDao = new GenericComboDaoImpl();
|
||||
return gComboDao.getElencoCombo();
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Vector(0);
|
||||
}
|
||||
|
||||
public static List getComboParametrica(String nome_tabella){
|
||||
try {
|
||||
if (log.isDebugEnabled()) log.debug("getComboParametrica() - I");
|
||||
GenericComboDaoImpl gComboDao = new GenericComboDaoImpl();
|
||||
return gComboDao.getComboParametrica(nome_tabella);
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Vector(0);
|
||||
}
|
||||
|
||||
public static List getComboLov(String aggregazione){
|
||||
try {
|
||||
if (log.isDebugEnabled()) log.debug("getComboLov() - I");
|
||||
GenericComboDaoImpl gComboDao = new GenericComboDaoImpl();
|
||||
return gComboDao.getComboLov(aggregazione);
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Vector(0);
|
||||
}
|
||||
|
||||
public static List getComboLovOrdByName(String aggregazione){
|
||||
try {
|
||||
if (log.isDebugEnabled()) log.debug("getComboLovOrdByName() - I");
|
||||
GenericComboDaoImpl gComboDao = new GenericComboDaoImpl();
|
||||
return gComboDao.getComboLovOrderByName(aggregazione);
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Vector(0);
|
||||
}
|
||||
|
||||
public static HashMap getHashMapFromList (List listaCombo) {
|
||||
HashMap hash = new HashMap();
|
||||
Iterator it = listaCombo.iterator();
|
||||
while (it.hasNext()) {
|
||||
GenericComboDto gen = (GenericComboDto)it.next();
|
||||
hash.put(gen.getValue(), gen.getLabel());
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static List getComboAnagOperatori() {
|
||||
try {
|
||||
if (log.isDebugEnabled()) log.debug("getComboAnagOperatori() - I");
|
||||
GenericComboDaoImpl gComboDao = new GenericComboDaoImpl();
|
||||
return gComboDao.getComboAnagOperatori();
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Vector(0);
|
||||
}
|
||||
|
||||
public static List getComboAnagOperatoriRete() {
|
||||
try {
|
||||
if (log.isDebugEnabled()) log.debug("getComboAnagOperatoriRete() - I");
|
||||
GenericComboDaoImpl gComboDao = new GenericComboDaoImpl();
|
||||
return gComboDao.getComboAnagOperatoriRete();
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Vector(0);
|
||||
}
|
||||
|
||||
public static List getComboParametricaNotOrdered(int mese, int annoiniziopenali){
|
||||
try {
|
||||
if (log.isDebugEnabled()) log.debug("getComboParametricaNotOrdered() - I");
|
||||
GenericComboDaoImpl gComboDao = new GenericComboDaoImpl();
|
||||
return gComboDao.getComboParametricaOrderedById( annoiniziopenali, mese);
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Vector(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.dao.DbcgoSequenceDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoFilePenaliDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoProcessoPenaliDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoVoMesiRiferimentoDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoFilePenali;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoProcessoPenali;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoVoMesiRiferimento;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: SeiditaNi
|
||||
* Date: 19/06/12
|
||||
* Time: 14.08
|
||||
*/
|
||||
public class GestioneStepPenaliBusiness {
|
||||
static Logger log = Logger.getLogger(GestioneStepPenaliBusiness.class.getName());
|
||||
DbcgoProcessoPenaliDAO processoPenaliDAO;
|
||||
DbcgoFilePenaliDAO filePenaliDAO;
|
||||
DbcgoSequenceDAO seqDao;
|
||||
DbcgoVoMesiRiferimentoDAO mesiDAO;
|
||||
CalcoloPenaliBusiness calcoloPenaliBusiness;
|
||||
final String PROCESSO_DONOR = "D";
|
||||
final String PROCESSO_RECIPIENT = "R";
|
||||
final int STEP_1 = 1;
|
||||
final int STEP_2 = 2;
|
||||
final int STEP_3 = 3;
|
||||
final int STEP_4 = 4;
|
||||
final int STEP_5 = 5;
|
||||
|
||||
public GestioneStepPenaliBusiness(CalcoloPenaliBusiness calcoloPenaliBusiness) {
|
||||
processoPenaliDAO = new DbcgoProcessoPenaliDAO();
|
||||
filePenaliDAO = new DbcgoFilePenaliDAO();
|
||||
seqDao = new DbcgoSequenceDAO();
|
||||
mesiDAO = new DbcgoVoMesiRiferimentoDAO();
|
||||
this.calcoloPenaliBusiness = calcoloPenaliBusiness;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Riproduce l'elaborazione del passo2.
|
||||
* Se il file del passo 2 e' in stato consolidato allora
|
||||
* porto il file in non consolidato e versione = 1
|
||||
* creo un file nuovo con versione 0
|
||||
*/
|
||||
void rielaboraPasso2(String idProcessoPasso1, String anno, String mese, String operatore,
|
||||
String processo, String tipoSla) {
|
||||
DbcgoProcessoPenali dbcgoProcessoPenali = calcoloPenaliBusiness.getProcesso(anno, mese, operatore, processo, tipoSla, STEP_2);
|
||||
dbcgoProcessoPenali.getIdProcesso();
|
||||
List dbcgoFilePenalis = calcoloPenaliBusiness.getFilePenali(dbcgoProcessoPenali.getIdProcesso(), null, null);
|
||||
//in base al numero di file ottenuti
|
||||
//size = 1 se file consolidato e versione 0 allora backup, altrimenti sovrascrivo
|
||||
//size = 2 sovrascrivo il file new
|
||||
if (dbcgoFilePenalis != null) {
|
||||
//recupero il file byte[]
|
||||
byte[] myFile = null;
|
||||
try {
|
||||
myFile = calcoloPenaliBusiness.getRequestedFile("xls", new Long(0), new Long(idProcessoPasso1));
|
||||
} catch (IOException ioe) {
|
||||
System.out.println(ioe.getMessage());
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
|
||||
//generate new file.
|
||||
GestioneXlsBusiness gb = new GestioneXlsBusiness();
|
||||
byte[] ris = null;
|
||||
if ("D".equalsIgnoreCase(processo)) {
|
||||
ris = gb.generaStep2_Donor(myFile, tipoSla, new Long(idProcessoPasso1));
|
||||
} else {
|
||||
ris = gb.generaStep2_Recipient(myFile, tipoSla, new Long(idProcessoPasso1));
|
||||
}
|
||||
|
||||
switch (dbcgoFilePenalis.size()) {
|
||||
case 1:
|
||||
DbcgoFilePenali dbcgoFilePenali = (DbcgoFilePenali) dbcgoFilePenalis.get(0);
|
||||
if (dbcgoFilePenali.getIsConsolidato().equals("Y")) {
|
||||
//backup
|
||||
calcoloPenaliBusiness.updateFilePenali(dbcgoFilePenali.getId().getVersione().toString(), dbcgoProcessoPenali.getIdProcesso().toString(),
|
||||
dbcgoFilePenali.getId().getTipoFile(), "1");
|
||||
} else {
|
||||
//delete file
|
||||
calcoloPenaliBusiness.deleteFilePenali(dbcgoProcessoPenali.getIdProcesso(), "xls", new Long(0));
|
||||
}
|
||||
//insert new file.
|
||||
calcoloPenaliBusiness.saveFilePenali(ris, "N", "xls", dbcgoProcessoPenali.getIdProcesso(), new Long(0));
|
||||
break;
|
||||
case 2:
|
||||
// in this case the NEW file is deleted.
|
||||
//delete file
|
||||
calcoloPenaliBusiness.deleteFilePenali(dbcgoProcessoPenali.getIdProcesso(), "xls", new Long(0));
|
||||
//insert new file.
|
||||
calcoloPenaliBusiness.saveFilePenali(ris, "N", "xls", dbcgoProcessoPenali.getIdProcesso(), new Long(0));
|
||||
break;
|
||||
default:
|
||||
log.error("NESSUN FILE TROVATO!");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce i processi in stato ok.
|
||||
*
|
||||
* @param operatore
|
||||
* @param tipoSla
|
||||
* @param processo
|
||||
* @param anno
|
||||
* @param mesi
|
||||
* @return
|
||||
*/
|
||||
List controllaStep3(String operatore, String tipoSla, String processo, String anno, Long[] mesi) {
|
||||
//controllo che i passi del trimestre siano tutti in stato 0
|
||||
|
||||
Criteria criteria = processoPenaliDAO.getSession().createCriteria(it.valueteam.dbcgo.hb.dto.DbcgoProcessoPenali.class);
|
||||
criteria.add(Restrictions.eq("stato", new Long(0)));
|
||||
criteria.add(Restrictions.eq("id.operatore", operatore));
|
||||
criteria.add(Restrictions.eq("id.tipoSla", tipoSla));
|
||||
criteria.add(Restrictions.eq("id.processo", processo));
|
||||
criteria.add(Restrictions.in("id.meseRiferimento", mesi));
|
||||
criteria.add(Restrictions.eq("id.anno", new Long(anno)));
|
||||
criteria.addOrder(Order.asc("id.step"));
|
||||
criteria.addOrder(Order.asc("id.meseRiferimento"));
|
||||
|
||||
return criteria.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo utilizzato per gestire il passaggio dallo step 2 al 3
|
||||
*
|
||||
* @param dbcgoProcessoPenali
|
||||
* @param trimestre
|
||||
* @param idStepSuccessivo
|
||||
*/
|
||||
void passaAlloStep3(DbcgoProcessoPenali dbcgoProcessoPenali, String trimestre, String idStepSuccessivo) {
|
||||
//controlla che sia avviabile lo step 3
|
||||
Long[] mesi = (Long[]) calcoloPenaliBusiness.getTrimestrePerMese(dbcgoProcessoPenali.getId().getMeseRiferimento().toString() + "/" + dbcgoProcessoPenali.getId().getAnno().toString(), false, false);
|
||||
List rows = controllaStep3(dbcgoProcessoPenali.getId().getOperatore(), dbcgoProcessoPenali.getId().getTipoSla(),
|
||||
dbcgoProcessoPenali.getId().getProcesso(), dbcgoProcessoPenali.getId().getAnno().toString(), mesi);
|
||||
Map mappa = new HashMap();
|
||||
DbcgoProcessoPenali mese1 = null;
|
||||
DbcgoProcessoPenali mese2 = null;
|
||||
DbcgoProcessoPenali mese3 = null;
|
||||
if (dbcgoProcessoPenali.getId().getProcesso().equalsIgnoreCase(PROCESSO_RECIPIENT)) {
|
||||
if (rows.size() > 5) {
|
||||
log.info("ATTIVO LO STEP 3!");
|
||||
mese1 = (DbcgoProcessoPenali) rows.get(3); //mese1?
|
||||
log.info("idProcesso:" + mese1.getIdProcesso());
|
||||
log.info("meseRiferimento:" + mese1.getId().getMeseRiferimento());
|
||||
mese2 = (DbcgoProcessoPenali) rows.get(4); //mese2?
|
||||
log.info("idProcesso:" + mese2.getIdProcesso());
|
||||
log.info("meseRiferimento:" + mese2.getId().getMeseRiferimento());
|
||||
mese3 = (DbcgoProcessoPenali) rows.get(5); //mese3?
|
||||
log.info("idProcesso:" + mese3.getIdProcesso());
|
||||
log.info("meseRiferimento:" + mese3.getId().getMeseRiferimento());
|
||||
try {
|
||||
mappa = new GestioneXlsBusiness().generaStep3_Recipient(calcoloPenaliBusiness.getRequestedFile(null, null, mese1.getIdProcesso()),
|
||||
calcoloPenaliBusiness.getRequestedFile(null, null, mese2.getIdProcesso()),
|
||||
calcoloPenaliBusiness.getRequestedFile(null, null, mese3.getIdProcesso()), mese1.getId().getOperatore(),
|
||||
trimestre, dbcgoProcessoPenali.getId().getAnno().toString(), dbcgoProcessoPenali.getId().getTipoSla());
|
||||
} catch (IOException ioe) {
|
||||
log.error(ioe.getMessage());
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dbcgoProcessoPenali.getId().getProcesso().equalsIgnoreCase(PROCESSO_RECIPIENT)) {
|
||||
//RECIPIENT
|
||||
switch (rows.size()) {
|
||||
case 6:
|
||||
if (idStepSuccessivo != null && !idStepSuccessivo.equals("0") && !idStepSuccessivo.trim().equals("")) {
|
||||
//lo step successivo e' stato inizializzato
|
||||
log.info("STEP ESISTENTE");
|
||||
//recupero il processo
|
||||
DbcgoProcessoPenali dbcgoPPenali = calcoloPenaliBusiness.getProcesso(idStepSuccessivo);
|
||||
//se lo stato e' zero rigenero i file e li pongo come nuovi mentre
|
||||
// gli esistenti vanno come vecchi.
|
||||
if (dbcgoPPenali.getStato().equals(new Long(0))) {
|
||||
//backup dei file
|
||||
calcoloPenaliBusiness.updateFilePenali("0", idStepSuccessivo, "csv", "1");
|
||||
calcoloPenaliBusiness.updateFilePenali("0", idStepSuccessivo, "xls", "1");
|
||||
//salvo nuovi file
|
||||
} else {
|
||||
//elimino gli esistenti
|
||||
calcoloPenaliBusiness.deleteFilePenali(dbcgoPPenali.getIdProcesso(), "csv", new Long(0));
|
||||
calcoloPenaliBusiness.deleteFilePenali(dbcgoPPenali.getIdProcesso(), "xls", new Long(0));
|
||||
}
|
||||
//salvo i nuovi
|
||||
calcoloPenaliBusiness.saveFilePenali((byte[]) mappa.get(GestioneXlsBusiness.CSV), "N", "csv", dbcgoPPenali.getIdProcesso(), new Long(0));
|
||||
//salvo xls
|
||||
calcoloPenaliBusiness.saveFilePenali((byte[]) mappa.get(GestioneXlsBusiness.XLS), "N", "xls", dbcgoPPenali.getIdProcesso(), new Long(0));
|
||||
} else {
|
||||
//lo step successivo non e' stato inizializzato
|
||||
log.info("CREO LO STEP");
|
||||
//recupero l'id del trimestre
|
||||
Long myTrimestre = ((DbcgoVoMesiRiferimento) (mesiDAO.findByProperty("label", trimestre)).get(0)).getId();
|
||||
//creo il record di processo
|
||||
Long newProcessId = calcoloPenaliBusiness.saveProcess("N", "N", dbcgoProcessoPenali.getId().getTipoSla(), new Long(1), new Long(STEP_3), dbcgoProcessoPenali.getId().getAnno(),
|
||||
dbcgoProcessoPenali.getId().getOperatore(), myTrimestre, PROCESSO_RECIPIENT);
|
||||
//salvo csv
|
||||
calcoloPenaliBusiness.saveFilePenali((byte[]) mappa.get(GestioneXlsBusiness.CSV), "N", "csv", newProcessId, new Long(0));
|
||||
//salvo xls
|
||||
calcoloPenaliBusiness.saveFilePenali((byte[]) mappa.get(GestioneXlsBusiness.XLS), "N", "xls", newProcessId, new Long(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//DONOR
|
||||
switch (rows.size()) {
|
||||
case 6:
|
||||
//lo step 3 consente solamente il caricamento.
|
||||
// per cui inizializzo solamente lo step senza creare file
|
||||
if (idStepSuccessivo!=null && idStepSuccessivo!="0" && !idStepSuccessivo.trim().equals("")) {
|
||||
//lo step 3 gia' esiste non ce' bisogno di generarlo.
|
||||
//Non eseguo alcuna azione :)
|
||||
|
||||
log.info("STEP 3 esistente bypasso");
|
||||
} else {
|
||||
Long myTrimestre = ((DbcgoVoMesiRiferimento) (mesiDAO.findByProperty("label", trimestre)).get(0)).getId();
|
||||
calcoloPenaliBusiness.saveProcess("N", "N", dbcgoProcessoPenali.getId().getTipoSla(), new Long(1), new Long(STEP_3),
|
||||
dbcgoProcessoPenali.getId().getAnno(), dbcgoProcessoPenali.getId().getOperatore(), myTrimestre, PROCESSO_DONOR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gestisce il passaggio da step 3 a 4
|
||||
*
|
||||
* @param dbcgoProcessoPenali
|
||||
* @param idStepSuccessivo
|
||||
*/
|
||||
public void passaAlloStep4(DbcgoProcessoPenali dbcgoProcessoPenali, String trimestre, String idStepSuccessivo) {
|
||||
Long[] mesi = (Long[]) calcoloPenaliBusiness.getTrimestrePerMese(dbcgoProcessoPenali.getId().getMeseRiferimento().toString() + "/" + dbcgoProcessoPenali.getId().getAnno().toString(), false, true);
|
||||
List rows = controllaStep3(dbcgoProcessoPenali.getId().getOperatore(), dbcgoProcessoPenali.getId().getTipoSla(),
|
||||
dbcgoProcessoPenali.getId().getProcesso(), dbcgoProcessoPenali.getId().getAnno().toString(), mesi);
|
||||
DbcgoProcessoPenali mese1 = null;
|
||||
DbcgoProcessoPenali mese2 = null;
|
||||
DbcgoProcessoPenali mese3 = null;
|
||||
DbcgoProcessoPenali trimestreDonorStep3 = null;
|
||||
byte[] mybyte = null;
|
||||
if (dbcgoProcessoPenali.getId().getProcesso().equalsIgnoreCase(PROCESSO_RECIPIENT)) {
|
||||
if (rows.size() > 5) {
|
||||
log.info("ATTIVO LO STEP 4!");
|
||||
mese1 = (DbcgoProcessoPenali) rows.get(3); //mese1?
|
||||
log.info("idProcesso:" + mese1.getIdProcesso());
|
||||
log.info("meseRiferimento:" + mese1.getId().getMeseRiferimento());
|
||||
mese2 = (DbcgoProcessoPenali) rows.get(4); //mese2?
|
||||
log.info("idProcesso:" + mese2.getIdProcesso());
|
||||
log.info("meseRiferimento:" + mese2.getId().getMeseRiferimento());
|
||||
mese3 = (DbcgoProcessoPenali) rows.get(5); //mese3?
|
||||
log.info("idProcesso:" + mese3.getIdProcesso());
|
||||
log.info("meseRiferimento:" + mese3.getId().getMeseRiferimento());
|
||||
try {
|
||||
mybyte = new GestioneXlsBusiness().generaStep4_Recipient(
|
||||
calcoloPenaliBusiness.getRequestedFile(null, null, mese1.getIdProcesso()),
|
||||
calcoloPenaliBusiness.getRequestedFile(null, null, mese2.getIdProcesso()),
|
||||
calcoloPenaliBusiness.getRequestedFile(null, null, mese3.getIdProcesso()),
|
||||
dbcgoProcessoPenali.getId().getTipoSla());
|
||||
log.info("mybyte.length:" + mybyte.length);
|
||||
} catch (IOException ioe) {
|
||||
log.error(ioe.getMessage());
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// PROCESSO DONOR, lo step3 e' l'upload dell'excel da parte dell'utente. Lo step 4
|
||||
if (rows.size() > 6) {
|
||||
log.info("ATTIVO LO STEP 4 DONOR!");
|
||||
trimestreDonorStep3 = (DbcgoProcessoPenali) rows.get(6); // step3 donor
|
||||
log.info("idProcesso:" + trimestreDonorStep3.getIdProcesso());
|
||||
log.info("meseRiferimento:" + trimestreDonorStep3.getId().getMeseRiferimento());
|
||||
String operatore = trimestreDonorStep3.getId().getOperatore();
|
||||
try {
|
||||
mybyte = new GestioneXlsBusiness().generaStep4_Donor(calcoloPenaliBusiness.getRequestedFile(null, null, trimestreDonorStep3.getIdProcesso()),
|
||||
operatore, trimestre, trimestreDonorStep3.getId().getAnno().toString(), trimestreDonorStep3.getId().getTipoSla() );
|
||||
log.info("mybyte.length:" + mybyte.length);
|
||||
} catch (IOException ioe) {
|
||||
log.error(ioe.getMessage());
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dbcgoProcessoPenali.getId().getProcesso().equalsIgnoreCase(PROCESSO_RECIPIENT)) {
|
||||
if (idStepSuccessivo != null && !idStepSuccessivo.equals("0") && !idStepSuccessivo.trim().equals("")) {
|
||||
//lo step successivo e' stato inizializzato
|
||||
log.info("STEP ESISTENTE");
|
||||
//recupero il processo
|
||||
DbcgoProcessoPenali dbcgoPPenali = calcoloPenaliBusiness.getProcesso(idStepSuccessivo);
|
||||
//se lo stato e' zero rigenero i file e li pongo come nuovi mentre
|
||||
// gli esistenti vanno come vecchi.
|
||||
if (dbcgoPPenali.getStato().equals(new Long(0))) {
|
||||
//backup dei file
|
||||
calcoloPenaliBusiness.updateFilePenali("0", idStepSuccessivo, "xls", "1");
|
||||
//salvo nuovi file
|
||||
} else {
|
||||
//elimino gli esistenti
|
||||
calcoloPenaliBusiness.deleteFilePenali(dbcgoPPenali.getIdProcesso(), "xls", new Long(0));
|
||||
}
|
||||
//salvo xls
|
||||
calcoloPenaliBusiness.saveFilePenali(mybyte, "N", "xls", dbcgoPPenali.getIdProcesso(), new Long(0));
|
||||
} else {
|
||||
//lo step successivo non e' stato inizializzato
|
||||
log.info("CREO LO STEP");
|
||||
//creo il record di processo
|
||||
Long newProcessId = calcoloPenaliBusiness.saveProcess("N", "N", dbcgoProcessoPenali.getId().getTipoSla(), new Long(1), new Long(STEP_4), dbcgoProcessoPenali.getId().getAnno(),
|
||||
dbcgoProcessoPenali.getId().getOperatore(), dbcgoProcessoPenali.getId().getMeseRiferimento(), PROCESSO_RECIPIENT);
|
||||
//salvo xls
|
||||
calcoloPenaliBusiness.saveFilePenali(mybyte, "N", "xls", newProcessId, new Long(0));
|
||||
}
|
||||
} else {
|
||||
// GENERAZIONE STEP4 PROCESSO DONOR
|
||||
if (idStepSuccessivo != null && !idStepSuccessivo.equals("0") && !idStepSuccessivo.trim().equals("")) {
|
||||
//lo step successivo e' stato inizializzato
|
||||
log.info("STEP4 DONOR ESISTENTE");
|
||||
//recupero il processo
|
||||
DbcgoProcessoPenali dbcgoPPenali = calcoloPenaliBusiness.getProcesso(idStepSuccessivo);
|
||||
//se lo stato e' zero rigenero i file e li pongo come nuovi mentre
|
||||
// gli esistenti vanno come vecchi.
|
||||
if (dbcgoPPenali.getStato().equals(new Long(0))) {
|
||||
//backup dei file
|
||||
calcoloPenaliBusiness.updateFilePenali("0", idStepSuccessivo, "xls", "1");
|
||||
//salvo nuovi file
|
||||
} else {
|
||||
//elimino gli esistenti
|
||||
calcoloPenaliBusiness.deleteFilePenali(dbcgoPPenali.getIdProcesso(), "xls", new Long(0));
|
||||
}
|
||||
//salvo xls
|
||||
calcoloPenaliBusiness.saveFilePenali(mybyte, "N", "xls", dbcgoPPenali.getIdProcesso(), new Long(0));
|
||||
} else {
|
||||
//lo step successivo non e' stato inizializzato
|
||||
log.info("CREO LO STEP4 DONOR");
|
||||
//creo il record di processo
|
||||
Long newProcessId = calcoloPenaliBusiness.saveProcess("N", "N", dbcgoProcessoPenali.getId().getTipoSla(), new Long(1), new Long(STEP_4), dbcgoProcessoPenali.getId().getAnno(),
|
||||
dbcgoProcessoPenali.getId().getOperatore(), dbcgoProcessoPenali.getId().getMeseRiferimento(), PROCESSO_DONOR);
|
||||
//salvo xls
|
||||
calcoloPenaliBusiness.saveFilePenali(mybyte, "N", "xls", newProcessId, new Long(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gestisce il passaggio da step 4 a 5
|
||||
*
|
||||
* @param dbcgoProcessoPenali
|
||||
* @param idStepSuccessivo
|
||||
*/
|
||||
public void passaAlloStep5(DbcgoProcessoPenali dbcgoProcessoPenali, String idStepSuccessivo) {
|
||||
Long[] mesi = (Long[]) calcoloPenaliBusiness.getTrimestrePerMese(dbcgoProcessoPenali.getId().getMeseRiferimento().toString() + "/" + dbcgoProcessoPenali.getId().getAnno().toString(), false, true);
|
||||
List rows = controllaStep3(dbcgoProcessoPenali.getId().getOperatore(), dbcgoProcessoPenali.getId().getTipoSla(),
|
||||
dbcgoProcessoPenali.getId().getProcesso(), dbcgoProcessoPenali.getId().getAnno().toString(), mesi);
|
||||
DbcgoProcessoPenali trimestreDonorStep4 = null;
|
||||
byte[] mybyte = null;
|
||||
if (rows.size() > 7) {
|
||||
log.info("ATTIVO LO STEP 5 DONOR!");
|
||||
trimestreDonorStep4 = (DbcgoProcessoPenali) rows.get(7); // step4 donor
|
||||
log.info("idProcesso:" + trimestreDonorStep4.getIdProcesso());
|
||||
log.info("meseRiferimento:" + trimestreDonorStep4.getId().getMeseRiferimento());
|
||||
try {
|
||||
mybyte = new GestioneXlsBusiness().generaStep5_Donor(calcoloPenaliBusiness.getRequestedFile(null, null, trimestreDonorStep4.getIdProcesso()), dbcgoProcessoPenali.getId().getTipoSla());
|
||||
log.info("mybyte.length:" + mybyte.length);
|
||||
} catch (IOException ioe) {
|
||||
log.error(ioe.getMessage());
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// GENERAZIONE STEP5 PROCESSO DONOR
|
||||
if (idStepSuccessivo != null && !idStepSuccessivo.equals("0") && !idStepSuccessivo.trim().equals("")) {
|
||||
//lo step successivo e' stato inizializzato
|
||||
log.info("STEP5 DONOR ESISTENTE");
|
||||
//recupero il processo
|
||||
DbcgoProcessoPenali dbcgoPPenali = calcoloPenaliBusiness.getProcesso(idStepSuccessivo);
|
||||
//se lo stato e' zero rigenero i file e li pongo come nuovi mentre
|
||||
// gli esistenti vanno come vecchi.
|
||||
if (dbcgoPPenali.getStato().equals(new Long(0))) {
|
||||
//backup dei file
|
||||
calcoloPenaliBusiness.updateFilePenali("0", idStepSuccessivo, "xls", "1");
|
||||
//salvo nuovi file
|
||||
} else {
|
||||
//elimino gli esistenti
|
||||
calcoloPenaliBusiness.deleteFilePenali(dbcgoPPenali.getIdProcesso(), "xls", new Long(0));
|
||||
}
|
||||
//salvo xls
|
||||
calcoloPenaliBusiness.saveFilePenali(mybyte, "N", "xls", dbcgoPPenali.getIdProcesso(), new Long(0));
|
||||
} else {
|
||||
//lo step successivo non e' stato inizializzato
|
||||
log.info("CREO LO STEP5 DONOR");
|
||||
//creo il record di processo
|
||||
Long newProcessId = calcoloPenaliBusiness.saveProcess("N", "N", dbcgoProcessoPenali.getId().getTipoSla(), new Long(1), new Long(STEP_5), dbcgoProcessoPenali.getId().getAnno(),
|
||||
dbcgoProcessoPenali.getId().getOperatore(), dbcgoProcessoPenali.getId().getMeseRiferimento(), PROCESSO_DONOR);
|
||||
//salvo xls
|
||||
calcoloPenaliBusiness.saveFilePenali(mybyte, "N", "xls", newProcessId, new Long(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,532 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.bean.excel.RigaExcelStep4Donor;
|
||||
import it.valueteam.dbcgo.exception.CalcoloPenaliException;
|
||||
import it.valueteam.dbcgo.exception.CsvFormatException;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoProcessoPenali;
|
||||
import it.valueteam.dbcgo.utility.penali.*;
|
||||
import jxl.*;
|
||||
import jxl.write.DateTime;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Questa classe gestisce tutte le logiche di generazione file xls e di business
|
||||
* del calcolo penali a partire dai dati caricati.
|
||||
*/
|
||||
public class GestioneXlsBusiness extends ExcelUtils {
|
||||
public static final Logger logger = Logger.getLogger(GestioneXlsBusiness.class.getName());
|
||||
|
||||
public static final String CSV = "CSV";
|
||||
public static final String XLS = "XLS";
|
||||
public static final String TIPO_SLA_MNP = "MNP";
|
||||
public static final String TIPO_SLA_TCR = "TCR";
|
||||
public static final String OPERATORE_EFFETTIVO_TIMG = "TIMG";
|
||||
|
||||
public byte[] generaStep1_Recipient(String operatore, String meseRiferimento, String annoRiferimento, String tipoSla)
|
||||
throws CalcoloPenaliException {
|
||||
HashMap parametri = new HashMap(3);
|
||||
parametri.put("recipientEffettivo", OPERATORE_EFFETTIVO_TIMG);
|
||||
parametri.put("dataMessaggio", (meseRiferimento + "/" + annoRiferimento));
|
||||
parametri.put("donorEffettivo", operatore);
|
||||
return generaStep1(parametri, tipoSla, false);
|
||||
}
|
||||
|
||||
public byte[] generaStep1_Donor(String operatore, String meseRiferimento, String annoRiferimento, String tipoSla)
|
||||
throws CalcoloPenaliException {
|
||||
HashMap parametri = new HashMap(3);
|
||||
parametri.put("recipientEffettivo", operatore);
|
||||
parametri.put("dataMessaggio", (meseRiferimento + "/" + annoRiferimento));
|
||||
parametri.put("donorEffettivo", OPERATORE_EFFETTIVO_TIMG);
|
||||
return generaStep1(parametri, tipoSla, true);
|
||||
}
|
||||
|
||||
private byte[] generaStep1(HashMap parametri, String tipoSla, boolean isDonating) throws CalcoloPenaliException {
|
||||
ReportPenaliBusiness reportPenaliBusiness = new ReportPenaliBusiness();
|
||||
reportPenaliBusiness.instanceCriteria(parametri);
|
||||
List l = null;
|
||||
if (tipoSla.equalsIgnoreCase(TIPO_SLA_MNP)) {
|
||||
l = reportPenaliBusiness.eseguiRicercaSLA3GG();
|
||||
} else if (tipoSla.equalsIgnoreCase(TIPO_SLA_TCR)) {
|
||||
l = reportPenaliBusiness.eseguiRicerca();
|
||||
}
|
||||
|
||||
//if (l == null || l.size()==0 ) {
|
||||
// throw new CalcoloPenaliException(CalcoloPenaliException.RICERCA_VUOTA);
|
||||
//}
|
||||
|
||||
// Genera excel
|
||||
CalcoloPenaliStep1ExcelUtils xlsUtil = new CalcoloPenaliStep1ExcelUtils();
|
||||
byte[] excel = xlsUtil.generaExcelStep1(l, isDonating, tipoSla);
|
||||
|
||||
return excel;
|
||||
}
|
||||
|
||||
private byte[] generaStep2(byte[] excelStep1, boolean isDonating, boolean isMNP, Long idProcesso) {
|
||||
// Genera excel
|
||||
CalcoloPenaliStep2ExcelUtils xlsUtil = new CalcoloPenaliStep2ExcelUtils();
|
||||
return xlsUtil.generaExcelStep2(excelStep1, isDonating, isMNP, idProcesso);
|
||||
}
|
||||
|
||||
public byte[] generaStep2_Donor(byte[] excelStep1, String tipoSla, Long idProcesso) {
|
||||
// Genera excel step 2
|
||||
boolean isMNP = false;
|
||||
if (tipoSla.equalsIgnoreCase(TIPO_SLA_MNP)) {
|
||||
isMNP = true;
|
||||
} else if (tipoSla.equalsIgnoreCase(TIPO_SLA_TCR)) {
|
||||
isMNP = false;
|
||||
}
|
||||
return generaStep2(excelStep1, true, isMNP, idProcesso);
|
||||
}
|
||||
|
||||
public byte[] generaStep2_Recipient(byte[] excelStep1, String tipoSla, Long idProcesso) {
|
||||
// Genera excel step 2
|
||||
boolean isMNP = false;
|
||||
if (tipoSla.equalsIgnoreCase(TIPO_SLA_MNP)) {
|
||||
isMNP = true;
|
||||
} else if (tipoSla.equalsIgnoreCase(TIPO_SLA_TCR)) {
|
||||
isMNP = false;
|
||||
}
|
||||
return generaStep2(excelStep1, false, isMNP, idProcesso);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trasforma l'excel in input nel formato CSV.
|
||||
* I record sono separati da ";"
|
||||
*
|
||||
* @param excel excel in input
|
||||
* @return byte[] contenente il CSV di output
|
||||
*/
|
||||
/* public byte[] trasformaInCSV(byte[] excel) {
|
||||
byte[] output = null;
|
||||
CalcoloPenaliStep3ExcelUtils xlsUtil = new CalcoloPenaliStep3ExcelUtils();
|
||||
return xlsUtil.trasformaInCSV(excel);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Genera lo STEP3 per il processo recipient. Occorrono tre byte[] che rappresentano gli excel
|
||||
* dei mesi del trimestre corrispondenti allo STEP2.
|
||||
* Restituisce una mappa contenente:
|
||||
* - il CSV degli eventi in penale fatturabili (key = <code>GestioneXlsBusiness.CSV</code>)
|
||||
* - l'Excel di resoconto trimestrale (key = <code>GestioneXlsBusiness.XLS</code>)
|
||||
* @param excelFirstMonth
|
||||
* @param excelSecondMonth
|
||||
* @param excelThirdMonth
|
||||
* @return
|
||||
*/
|
||||
public Map generaStep3_Recipient(byte[] excelFirstMonth, byte[] excelSecondMonth, byte[] excelThirdMonth,
|
||||
String operatore, String trimestre, String anno, String tipoSla) {
|
||||
// Genera excel step 3
|
||||
Map output = new HashMap(2);
|
||||
boolean isMNP = false;
|
||||
if (tipoSla.equalsIgnoreCase(TIPO_SLA_MNP)) {
|
||||
isMNP = true;
|
||||
} else if (tipoSla.equalsIgnoreCase(TIPO_SLA_TCR)) {
|
||||
isMNP = false;
|
||||
}
|
||||
// Genera CSV - Somma degli excel setp 2 del primo, secondo e terzo mese con Check Fatturazione != NO
|
||||
CalcoloPenaliStep3ExcelUtils xlsUtil = new CalcoloPenaliStep3ExcelUtils();
|
||||
byte[] csvStep3 = xlsUtil.generaCSV_Step3(excelFirstMonth, excelSecondMonth, excelThirdMonth, isMNP);
|
||||
|
||||
// Generazione excel. Raggruppamento dei mesi
|
||||
byte[] excelStep3 = xlsUtil.generaXLS_Step3(excelFirstMonth, excelSecondMonth, excelThirdMonth, operatore, trimestre, anno, isMNP);
|
||||
|
||||
output.put(GestioneXlsBusiness.CSV, csvStep3);
|
||||
output.put(GestioneXlsBusiness.XLS, excelStep3);
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il file delle differenze fra i record in penale forniti da AltroAOM
|
||||
* e quelli attesi da TIMG
|
||||
*
|
||||
* @param csvUploaded
|
||||
* @return
|
||||
*/
|
||||
public byte[] generaStep4_Donor(byte[] csvUploaded, String operatore, String trimestre, String anno, String tipoSla) {
|
||||
// Deve ritornare un excel contenente le differenze fra il file uploaded (.csv) e quello generato
|
||||
// come lo step 3 del recipient
|
||||
// (simulazione dello step_3 per la parte DONOR).
|
||||
CalcoloPenaliStep4ExcelUtils step4Utils = new CalcoloPenaliStep4ExcelUtils();
|
||||
byte[] excelOutput = null;
|
||||
try {
|
||||
//create BufferedReader to read csv file
|
||||
String csv = new String(csvUploaded);
|
||||
BufferedReader br = new BufferedReader(new StringReader(csv));
|
||||
String strLine = "";
|
||||
int lineNumber = 0;
|
||||
//read comma separated file line by line
|
||||
List datiDifferenti = new ArrayList(); // contiene gli elementi diversi rispetto all'importo (di tipo RigaExcelStep4Donor)
|
||||
strLine = br.readLine(); // metto da parte la prima riga (l'intestazione)
|
||||
String[] columns = strLine.split(";", -1); // con il -1 gestisco anche l'ultimo token a NULL
|
||||
datiDifferenti.add(convertiInObj(columns)); // Aggiungo l'intestazione
|
||||
if (columns.length < 23) {
|
||||
logger.info("CSV non corretto. Trovate "+columns.length+" colonne invece di 23.");
|
||||
throw new CsvFormatException("CSV non corretto. Trovate "+columns.length+" colonne invece di 23." );
|
||||
}
|
||||
|
||||
HashMap eventiPenaleInterni = generaMappaDaEventiExcel(operatore, trimestre, anno, tipoSla); // chiave codiceRichiesta-tipoSla Recuperare dal db tutte le richieste
|
||||
|
||||
logger.info(" +++++++++++++ Trovati ["+eventiPenaleInterni.size()+"] eventi in penale negli excel");
|
||||
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
columns = strLine.split(";", -1); // con il -1 gestisco anche l'ultimo token a NULL
|
||||
if (columns.length < 23) {
|
||||
logger.info("CSV non corretto");
|
||||
throw new CsvFormatException("CSV non corretto. Trovate "+columns.length+" colonne invece di 23." );
|
||||
}
|
||||
String importoDaCorrispondere = columns[3]; // QUARTA COLONNA DEL CSV
|
||||
String codiceRichiesta = columns[10]; // UNDICESIMA COLONNA DEL CSV
|
||||
String sla = columns[21]; // VENTIDUESIMA COLONNA DEL CSV
|
||||
String flagPenaleAltroAom = columns[22]; // VENTITREESIMA COLONNA DEL CSV
|
||||
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info(" CSV importoDaCorrispondere ["+importoDaCorrispondere+"]");
|
||||
logger.info(" CSV codiceRichiesta ["+codiceRichiesta+"]");
|
||||
logger.info(" CSV sla ["+sla+"]");
|
||||
}
|
||||
if (flagPenaleAltroAom != null && flagPenaleAltroAom.equalsIgnoreCase("Y")) {
|
||||
if (eventiPenaleInterni.get( (codiceRichiesta+"-"+sla) ) != null) {
|
||||
RigaExcelStep4Donor interno = (RigaExcelStep4Donor)eventiPenaleInterni.get( (codiceRichiesta+"-"+sla) );
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Trovato evento corrispondente in excel");
|
||||
logger.info(" Excel importoDaCorrispondereTIM ["+interno.getImportoDaCorrispondereTIM()+"]");
|
||||
logger.info(" Excel codiceRichiesta ["+interno.getCodiceRichiestaRecipient()+"]");
|
||||
logger.info(" Excel sla ["+interno.getTipoSla()+"]");
|
||||
}
|
||||
if (interno.getCodiceRichiestaRecipient().equalsIgnoreCase(codiceRichiesta)) { // Stesso id_richiesta
|
||||
if (interno.getTipoSla().equalsIgnoreCase(sla)) { // Stesso tipo_sla
|
||||
if (!interno.getImportoDaCorrispondereTIM().equalsIgnoreCase(importoDaCorrispondere)) {
|
||||
interno.setImportoDaCorrispondereAOM(importoDaCorrispondere);
|
||||
datiDifferenti.add(interno);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // se non esiste aggiungo l'interno record preso dal file CSV
|
||||
datiDifferenti.add(convertiInObj(columns));
|
||||
}
|
||||
} else {
|
||||
// Prendo tutti i record caricati in step 3 con FlagPenaleAltroAOM nullo o pari a N
|
||||
datiDifferenti.add(convertiInObj(columns));
|
||||
}
|
||||
lineNumber++;
|
||||
}
|
||||
|
||||
excelOutput = step4Utils.generaExcelStep4_Donor(datiDifferenti, eventiPenaleInterni);
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception while reading csv file: " + e, e);
|
||||
}
|
||||
return excelOutput;
|
||||
}
|
||||
|
||||
// Viene generata una mappa avente chiave IDRICHIESTA_SLA di elementi RigaExcelStep4Donor
|
||||
private HashMap generaMappaDaEventiExcel(String operatore, String trimestre, String anno, String tipoSla) {
|
||||
HashMap output = new HashMap();
|
||||
// Query per excel
|
||||
try {
|
||||
CalcoloPenaliBusiness businessService = new CalcoloPenaliBusiness();
|
||||
String meseanno = null;
|
||||
if (trimestre.equalsIgnoreCase("1Q")) {
|
||||
meseanno = 13+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("2Q")) {
|
||||
meseanno = 14+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("3Q")) {
|
||||
meseanno = 15+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("4Q")) {
|
||||
meseanno = 16+"/"+anno;
|
||||
}
|
||||
List dbcgoProcessi = businessService.getRecordPerMese("D", operatore, meseanno, tipoSla);
|
||||
|
||||
for (Iterator iter = dbcgoProcessi.iterator(); iter.hasNext();) {
|
||||
DbcgoProcessoPenali singleProcess = (DbcgoProcessoPenali) iter.next();
|
||||
if (singleProcess.getId().getStep().equals(new Long(2))) {
|
||||
aggiungiRecordEventiExcel(businessService.getRequestedFile("xls", new Long(0), singleProcess.getIdProcesso()), output, tipoSla);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//
|
||||
}
|
||||
// Sommo gli excel dello step2 in un unico CSV
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private void aggiungiRecordEventiExcel(byte[] excel, HashMap output, String tipoSla) {
|
||||
// Apro l'excel e trasformo le righe in RigaExcelStep4Donor
|
||||
try {
|
||||
Workbook tempWb = Workbook.getWorkbook(new ByteArrayInputStream(excel));
|
||||
Sheet sheet = tempWb.getSheet(0);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT_PATTERN);
|
||||
|
||||
// ciclo sulle righe escludendo l'header (parto quindi da 1)
|
||||
for (int i = 1; i < sheet.getRows(); i++) {
|
||||
Cell[] row = sheet.getRow(i);
|
||||
RigaExcelStep4Donor riga = new RigaExcelStep4Donor();
|
||||
riga.setCheckFatturazione(row[0].getContents());
|
||||
riga.setCausaleStorno(row[1].getContents());
|
||||
riga.setGiorniDaCorrispondere(row[2].getContents());
|
||||
riga.setImportoDaCorrispondereAOM("0");
|
||||
riga.setImportoDaCorrispondereTIM(row[3].getContents());
|
||||
|
||||
if (tipoSla.equalsIgnoreCase(GestioneXlsBusiness.TIPO_SLA_MNP)) {
|
||||
riga.setSoggettoAFranchigia(row[4].getContents());
|
||||
riga.setDonatingOspitato(row[5].getContents());
|
||||
riga.setRecipientOspitato(row[6].getContents());
|
||||
riga.setDonatingRete(row[7].getContents());
|
||||
riga.setRecipientRete(row[8].getContents());
|
||||
riga.setMSISDN(row[9].getContents());
|
||||
riga.setCodiceRichiestaRecipient(row[10].getContents());
|
||||
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
riga.setDataInvioRicezioneFileEventoIniziale(row[11].getContents().replace('.',':'));
|
||||
|
||||
riga.setNomeFileEventoIniziale(row[12].getContents());
|
||||
riga.setAckEventoIniziale(row[13].getContents());
|
||||
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
riga.setDataInvioRicezioneFileEventoFinale(row[14].getContents().replace('.',':'));
|
||||
|
||||
riga.setNomeFileEventoFinale(row[15].getContents());
|
||||
riga.setAckEventoFinale(row[16].getContents());
|
||||
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
riga.setDataAttesaEventoFinale(row[17].getContents().replace('.',':'));
|
||||
riga.setGiorniRitardoSolari(row[18].getContents());
|
||||
riga.setImporto(row[19].getContents());
|
||||
riga.setMeseCompetenzaEventoFinale(row[20].getContents());
|
||||
riga.setTipoSla(row[21].getContents());
|
||||
riga.setFlagPenaleAltroOperatore(row[22].getContents());
|
||||
} else {
|
||||
riga.setSoggettoAFranchigia("NO");
|
||||
riga.setDonatingOspitato(row[4].getContents());
|
||||
riga.setRecipientOspitato(row[5].getContents());
|
||||
riga.setDonatingRete(row[6].getContents());
|
||||
riga.setRecipientRete(row[7].getContents());
|
||||
riga.setMSISDN(row[8].getContents());
|
||||
riga.setCodiceRichiestaRecipient(row[9].getContents());
|
||||
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
riga.setDataInvioRicezioneFileEventoIniziale(row[10].getContents().replace('.',':'));
|
||||
|
||||
riga.setNomeFileEventoIniziale(row[11].getContents());
|
||||
riga.setAckEventoIniziale(row[12].getContents());
|
||||
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
riga.setDataInvioRicezioneFileEventoFinale(row[13].getContents().replace('.',':'));
|
||||
|
||||
riga.setNomeFileEventoFinale(row[14].getContents());
|
||||
riga.setAckEventoFinale(row[15].getContents());
|
||||
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
riga.setDataAttesaEventoFinale(row[16].getContents().replace('.',':'));
|
||||
riga.setGiorniRitardoSolari(row[17].getContents());
|
||||
riga.setImporto(row[18].getContents());
|
||||
riga.setMeseCompetenzaEventoFinale(row[19].getContents());
|
||||
riga.setTipoSla(row[20].getContents());
|
||||
riga.setFlagPenaleAltroOperatore(row[21].getContents());
|
||||
}
|
||||
output.put( (riga.getCodiceRichiestaRecipient()+"-"+riga.getTipoSla()) , riga);
|
||||
}
|
||||
tempWb.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] generaStep4_Recipient(byte[] excelFirstMonth, byte[] excelSecondMonth, byte[] excelThirdMonth, String tipoSla) {
|
||||
// Genera excel step 4
|
||||
boolean isMNP = false;
|
||||
if (tipoSla.equalsIgnoreCase(TIPO_SLA_MNP)) {
|
||||
isMNP = true;
|
||||
}
|
||||
CalcoloPenaliStep4ExcelUtils xlsUtil = new CalcoloPenaliStep4ExcelUtils();
|
||||
return xlsUtil.generaExcelStep4(excelFirstMonth, excelSecondMonth, excelThirdMonth, false, isMNP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge le colonne per la gestione della contestazione degli eventi in penale
|
||||
*
|
||||
* @param excelStep4
|
||||
* @return
|
||||
*/
|
||||
public byte[] generaStep5_Donor(byte[] excelStep4, String tipoSla) {
|
||||
// Il comportamento e' il medesimo dello step4 Recipient
|
||||
boolean isMNP = false;
|
||||
if (tipoSla.equalsIgnoreCase(TIPO_SLA_MNP)) {
|
||||
isMNP = true;
|
||||
}
|
||||
CalcoloPenaliStep4ExcelUtils xlsUtil = new CalcoloPenaliStep4ExcelUtils();
|
||||
return xlsUtil.generaExcelStep4(excelStep4, null, null, true, isMNP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Il metodo genera il primo foglio del report sintesi
|
||||
*
|
||||
* @param trimestre
|
||||
* @param anno
|
||||
* @return
|
||||
*/
|
||||
public byte[] generaReportSintesi(String trimestre, String anno) {
|
||||
CalcoloPenaliReportSintesiExcelUtils xlsUtils = new CalcoloPenaliReportSintesiExcelUtils();
|
||||
return xlsUtils.generaReportSintesi(trimestre, anno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Il metodo genera il report sintesi mensile
|
||||
*
|
||||
* @param trimestre
|
||||
* @param anno
|
||||
* @return
|
||||
*/
|
||||
public byte[] generaReportSintesiMensile(String trimestre, String anno) {
|
||||
CalcoloPenaliReportSintesiMensileExcelUtils xlsUtils = new CalcoloPenaliReportSintesiMensileExcelUtils();
|
||||
return xlsUtils.generaReportSintesiMensile(trimestre, anno);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String strFilePath01Step1 = "C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoTISC_12_2011_1.xls";
|
||||
String strFilePath01Step2 = "C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoTISC_12_2011_2.xls";
|
||||
|
||||
String strFilePath02Step1 = "C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoWIND_02_2010_1.xls";
|
||||
String strFilePath02Step2 = "C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoWIND_02_2010_2.xls";
|
||||
|
||||
String strFilePath03Step1 = "C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoWIND_03_2010_1.xls";
|
||||
String strFilePath03Step2 = "C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoWIND_03_2010_2.xls";
|
||||
|
||||
GestioneXlsBusiness business = new GestioneXlsBusiness();
|
||||
try {
|
||||
/* BasicConfigurator.configure();
|
||||
CalcoloDisserviziAomBusiness disservizi = new CalcoloDisserviziAomBusiness();
|
||||
|
||||
List criteri = new ArrayList();
|
||||
criteri.add(Restrictions.eq("id.tipologiaPenale", TIPO_SLA_MNP));
|
||||
criteri.add(Restrictions.le("id.dataInizio", Utils.toDate("31/05/2012","dd/MM/yyyy")));
|
||||
criteri.add(Restrictions.ge("id.dataFine", Utils.toDate("01/05/2012","dd/MM/yyyy")));
|
||||
|
||||
List risultati = disservizi.eseguiRicerca(criteri);
|
||||
|
||||
System.out.println(); */
|
||||
FileOutputStream fos = null;
|
||||
FileOutputStream fos2 = null;
|
||||
// ********** PRIMO MESE ***************
|
||||
byte[] excel01Step1 = business.generaStep1_Donor("TISC", "12", "2011", TIPO_SLA_TCR);
|
||||
fos = new FileOutputStream(strFilePath01Step1);
|
||||
fos.write(excel01Step1);
|
||||
fos.close();
|
||||
|
||||
System.out.println(" ********* TERMINE PRIMO MESE STEP1 "+business.isNotEmptyExcel(excel01Step1));
|
||||
|
||||
/* byte[] excel01Step2 = business.generaStep2_Donor(excel01Step1, TIPO_SLA_TCR);
|
||||
fos2 = new FileOutputStream(strFilePath01Step2);
|
||||
fos2.write(excel01Step2);
|
||||
fos2.close();
|
||||
System.out.println(" ********* TERMINE PRIMO MESE STEP2 "+business.isNotEmptyExcel(excel01Step2));*/
|
||||
|
||||
/* // ********** SECONDO MESE ***************
|
||||
byte[] excel02Step1 = business.generaStep1_Recipient("WIND", "02", "2010", TIPO_SLA_MNP);
|
||||
fos = new FileOutputStream(strFilePath02Step1);
|
||||
fos.write(excel02Step1);
|
||||
fos.close();
|
||||
|
||||
System.out.println(" ********* TERMINE SECONDO MESE STEP1 "+business.isNotEmptyExcel(excel02Step1));
|
||||
|
||||
byte[] excel02Step2 = business.generaStep2_Recipient(excel02Step1, TIPO_SLA_MNP);
|
||||
fos2 = new FileOutputStream(strFilePath02Step2);
|
||||
fos2.write(excel02Step2);
|
||||
fos2.close();
|
||||
System.out.println(" ********* TERMINE SECONDO MESE STEP2 "+business.isNotEmptyExcel(excel02Step2));
|
||||
|
||||
// ********** TERZO MESE ***************
|
||||
byte[] excel03Step1 = business.generaStep1_Recipient("WIND", "03", "2010", TIPO_SLA_MNP);
|
||||
fos = new FileOutputStream(strFilePath03Step1);
|
||||
fos.write(excel03Step1);
|
||||
fos.close();
|
||||
|
||||
System.out.println(" ********* TERMINE TERZO MESE STEP1 "+business.isNotEmptyExcel(excel03Step1));
|
||||
|
||||
byte[] excel03Step2 = business.generaStep2_Recipient(excel03Step1, TIPO_SLA_MNP);
|
||||
fos2 = new FileOutputStream(strFilePath03Step2);
|
||||
fos2.write(excel03Step2);
|
||||
fos2.close();
|
||||
System.out.println(" ********* TERMINE TERZO MESE STEP2 "+business.isNotEmptyExcel(excel03Step2));
|
||||
|
||||
Map risultati = business.generaStep3_Recipient(excel01Step2, excel02Step2, excel03Step2, "WIND", "1Q", "2010", "MNP");
|
||||
fos2 = new FileOutputStream("C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoSTEP3_CSV.txt");
|
||||
fos2.write((byte[])risultati.get(GestioneXlsBusiness.CSV));
|
||||
fos2.close();
|
||||
|
||||
fos2 = new FileOutputStream("C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoSTEP3_XLS.xls");
|
||||
fos2.write((byte[])risultati.get(GestioneXlsBusiness.XLS));
|
||||
fos2.close();
|
||||
System.out.println(" ********* TERMINE STEP3 ");
|
||||
|
||||
fos2 = new FileOutputStream("C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoSTEP4_XLS.xls");
|
||||
fos2.write(business.generaStep4_Recipient(excel01Step2, excel02Step2, excel03Step2));
|
||||
fos2.flush();
|
||||
fos2.close();
|
||||
System.out.println(" ********* TERMINE STEP4 "); */
|
||||
|
||||
// ***************** REPORT SINTESI ******************
|
||||
/*CalcoloPenaliReportSintesiExcelUtils xlsUtils = new CalcoloPenaliReportSintesiExcelUtils();
|
||||
FileOutputStream fos2 = new FileOutputStream("C://Users//giustinianide//Desktop//DemoCalcoloPenali//demoReportSintesi.xls");
|
||||
fos2.write(business.generaReportSintesi("1Q", "2010"));
|
||||
fos2.flush();
|
||||
fos2.close();
|
||||
System.out.println(" ********* TERMINE SINTESI ");*/
|
||||
} /*catch (CalcoloPenaliException cpex) {
|
||||
System.out.println("CalcoloPenaliException : " + cpex);
|
||||
}*/ catch (FileNotFoundException ex) {
|
||||
System.out.println("FileNotFoundException : " + ex);
|
||||
} catch (IOException ioe) {
|
||||
System.out.println("IOException : " + ioe);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna <code>true</code> se l'excel in input possiede almeno due righe
|
||||
* (una riga oltre l'intestazione). <code>false</code> quando non ci sono eventi in penale
|
||||
*
|
||||
* @param excel l'excel in input
|
||||
* @return true se ho almeno un record
|
||||
*/
|
||||
public boolean isNotEmptyExcel(byte[] excel) {
|
||||
CalcoloPenaliStep1ExcelUtils xlsUtil = new CalcoloPenaliStep1ExcelUtils();
|
||||
return xlsUtil.isEmptyExcel(excel);
|
||||
}
|
||||
|
||||
// Converte le righe del CSV uploaded da AOM in un oggetto interno
|
||||
private RigaExcelStep4Donor convertiInObj(String[] csvColumns) {
|
||||
RigaExcelStep4Donor output = new RigaExcelStep4Donor();
|
||||
output.setCheckFatturazione(csvColumns[0]);
|
||||
output.setCausaleStorno(csvColumns[1]);
|
||||
output.setGiorniDaCorrispondere(csvColumns[2]);
|
||||
output.setImportoDaCorrispondereAOM(csvColumns[3]);
|
||||
output.setImportoDaCorrispondereTIM("0");
|
||||
output.setSoggettoAFranchigia(csvColumns[4]);
|
||||
output.setDonatingOspitato(csvColumns[5]);
|
||||
output.setRecipientOspitato(csvColumns[6]);
|
||||
output.setDonatingRete(csvColumns[7]);
|
||||
output.setRecipientRete(csvColumns[8]);
|
||||
output.setMSISDN(csvColumns[9]);
|
||||
output.setCodiceRichiestaRecipient(csvColumns[10]);
|
||||
output.setDataInvioRicezioneFileEventoIniziale(csvColumns[11]);
|
||||
output.setNomeFileEventoIniziale(csvColumns[12]);
|
||||
output.setAckEventoIniziale(csvColumns[13]);
|
||||
output.setDataInvioRicezioneFileEventoFinale(csvColumns[14]);
|
||||
output.setNomeFileEventoFinale(csvColumns[15]);
|
||||
output.setAckEventoFinale(csvColumns[16]);
|
||||
output.setDataAttesaEventoFinale(csvColumns[17]);
|
||||
output.setGiorniRitardoSolari(csvColumns[18]);
|
||||
output.setImporto(csvColumns[19]);
|
||||
output.setMeseCompetenzaEventoFinale(csvColumns[20]);
|
||||
output.setTipoSla(csvColumns[21]);
|
||||
output.setFlagPenaleAltroOperatore(csvColumns[22]);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.bean.FunzioneWebBean;
|
||||
import it.valueteam.dbcgo.bean.ItemMenuBean;
|
||||
import it.valueteam.dbcgo.dao.impl.ProfiloDaoImpl;
|
||||
import it.valueteam.dbcgo.dao.intf.ProfiloDao;
|
||||
import it.valueteam.dbcgo.dto.FunzioneWebDto;
|
||||
import it.valueteam.dbcgo.service.ServiceLocatorException;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class MenuProfiloBusiness {
|
||||
static Logger log = Logger.getLogger(MenuProfiloBusiness.class.getName());
|
||||
public MenuProfiloBusiness(){}
|
||||
|
||||
public static List creaMenu(String profilo){
|
||||
log.info("Creazione Menu con profilo ["+profilo+"]");
|
||||
List listaItemMenu = new ArrayList();
|
||||
|
||||
try {
|
||||
ProfiloDao theProfiloDao = new ProfiloDaoImpl();
|
||||
|
||||
log.info("creazione menu principali");
|
||||
//carico gli item principali e li inserisco nella lista item menu
|
||||
List listaItemPrincipali = theProfiloDao.selectItemMenuPrincipale(profilo);
|
||||
Iterator itItemPrincipali = listaItemPrincipali.iterator();
|
||||
while (itItemPrincipali.hasNext()){
|
||||
FunzioneWebDto aFunzioneWebDto = (FunzioneWebDto) itItemPrincipali.next();
|
||||
FunzioneWebBean aFunzioneWebBean = new FunzioneWebBean();
|
||||
try {
|
||||
BeanUtils.copyProperties(aFunzioneWebBean,aFunzioneWebDto);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ItemMenuBean aItemMenuBean = new ItemMenuBean();
|
||||
aItemMenuBean.setItemPrincipale(aFunzioneWebBean);
|
||||
listaItemMenu.add(aItemMenuBean);
|
||||
}
|
||||
|
||||
//per ogni item principale carico gli item secondari e rimetto nella lista item menu
|
||||
log.info("creazione menu secondari");
|
||||
Iterator itListaMenu = listaItemMenu.iterator();
|
||||
while (itListaMenu.hasNext()){
|
||||
List listaItemSecondariBean = new ArrayList();
|
||||
ItemMenuBean aItemMenuBean = (ItemMenuBean) itListaMenu.next();
|
||||
int idPadre = aItemMenuBean.getItemPrincipale().getId();
|
||||
List listaItemSecondari = theProfiloDao.selectItemMenuSecondari(idPadre,profilo);
|
||||
Iterator itListaItemSecondari = listaItemSecondari.iterator();
|
||||
while (itListaItemSecondari.hasNext()){
|
||||
FunzioneWebDto aFunzioneWebDto = (FunzioneWebDto) itListaItemSecondari.next();
|
||||
FunzioneWebBean aFunzioneWebBean = new FunzioneWebBean();
|
||||
try {
|
||||
BeanUtils.copyProperties(aFunzioneWebBean,aFunzioneWebDto);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
listaItemSecondariBean.add(aFunzioneWebBean);
|
||||
}
|
||||
aItemMenuBean.setItemSecondari(listaItemSecondariBean);
|
||||
}
|
||||
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error("Eccezione in creaMenu");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return listaItemMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Carica le funzioni abilitate (check nelle pagine jsp) al profilo
|
||||
* @param profilo
|
||||
* @return List of FunzioneWebBean
|
||||
*/
|
||||
public static List caricaFunzioni(String profilo) {
|
||||
log.info("Creazione Lista Funzioni profilate con profilo [" + profilo + "]");
|
||||
List listaItemMenu = new ArrayList();
|
||||
|
||||
try {
|
||||
ProfiloDao theProfiloDao = new ProfiloDaoImpl();
|
||||
|
||||
log.info("creazione lista funzioni");
|
||||
//carico gli item principali e li inserisco nella lista item menu
|
||||
List listaItemPrincipali = theProfiloDao.selectFunzioniProfilate(profilo);
|
||||
Iterator itItemPrincipali = listaItemPrincipali.iterator();
|
||||
while (itItemPrincipali.hasNext()) {
|
||||
FunzioneWebDto aFunzioneWebDto = (FunzioneWebDto) itItemPrincipali.next();
|
||||
FunzioneWebBean aFunzioneWebBean = new FunzioneWebBean();
|
||||
try {
|
||||
BeanUtils.copyProperties(aFunzioneWebBean, aFunzioneWebDto);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
listaItemMenu.add(aFunzioneWebBean);
|
||||
}
|
||||
} catch (ServiceLocatorException e) {
|
||||
log.error("Eccezione in creaMenu");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return listaItemMenu;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import java.util.*;
|
||||
|
||||
public class MonitorPenaliBusiness {
|
||||
static Logger log = Logger.getLogger(MonitorPenaliBusiness.class.getName());
|
||||
|
||||
private MnpDwSlaInMatGiorViewDAO mnpdwSlaInMatGiorViewDAO;
|
||||
private MnpDwSlaMatGiorViewDAO mnpdwSlaMatGiorViewDAO;
|
||||
private MnpDwSlaInMatGioTcVwDAO mnpDwSlaInMatGioTcVwDAO;
|
||||
private MnpDwSlaMatGioTcVwDAO mnpDwSlaMatGioTcVwDAO;
|
||||
|
||||
private ArrayList criterion;
|
||||
private static final String RECIPIENT = "R";
|
||||
private static final String DONOR = "D";
|
||||
private static final String C_DONOR_EFFETTIVO="donorEffettivo";
|
||||
private static final String C_RECIPIENT_EFFETTIVO="recipientEffettivo";
|
||||
private static final String C_TIPO_SLA = "tipoMessaggio";
|
||||
private static final String C_TIPO_PROCESSO = "tipoProcesso";
|
||||
private static final String C_DATA_MESSAGGIO_SHOW = "dataMessaggioShow";
|
||||
private static final String C_DATA_FINALE = "dataFinale";
|
||||
private static final String MATURATI = "0";
|
||||
private static final String IN_MATURAZIONE = "1";
|
||||
private static final String SLA_X = "SLA X";
|
||||
private static final String SLA_Y = "SLA Y";
|
||||
private static final String SLA_Z = "SLA Z";
|
||||
private static final String SLA_0 = "SLA0";
|
||||
private static final String SLA_1 = "SLA1";
|
||||
private static final String SLA_2 = "SLA2";
|
||||
private static final String SLA_3 = "SLA3";
|
||||
private static final String ALL_TCR= "ALL_TCR";
|
||||
private static final String ALL_MNP= "ALL_MNP";
|
||||
|
||||
private static Set SLA = new HashSet();
|
||||
static {
|
||||
SLA.add(SLA_0);
|
||||
SLA.add(SLA_1);
|
||||
SLA.add(SLA_2) ;
|
||||
SLA.add(SLA_3) ;
|
||||
SLA.add(ALL_MNP);
|
||||
}
|
||||
|
||||
//PROVA
|
||||
|
||||
private static Set SLA_TC = new HashSet();
|
||||
static {
|
||||
SLA_TC.add(SLA_X);
|
||||
SLA_TC.add(SLA_Y);
|
||||
SLA_TC.add(SLA_Z);
|
||||
SLA_TC.add(ALL_TCR);
|
||||
}
|
||||
|
||||
public MonitorPenaliBusiness() {
|
||||
mnpdwSlaInMatGiorViewDAO = new MnpDwSlaInMatGiorViewDAO();
|
||||
mnpdwSlaMatGiorViewDAO = new MnpDwSlaMatGiorViewDAO();
|
||||
mnpDwSlaInMatGioTcVwDAO = new MnpDwSlaInMatGioTcVwDAO();
|
||||
mnpDwSlaMatGioTcVwDAO = new MnpDwSlaMatGioTcVwDAO();
|
||||
criterion = new ArrayList();
|
||||
}
|
||||
|
||||
|
||||
public void createCriteria(String tipoProcesso, String operatore, String tipoMessaggio,
|
||||
String tipoPenale, Date dataDal, Date dataAl) {
|
||||
log.info("Operatore:" + operatore);
|
||||
log.info("SLA:" + tipoMessaggio);
|
||||
log.info("TipoProcesso:" + tipoProcesso);
|
||||
log.info("TipoPenale:" + tipoPenale);
|
||||
log.info("DataDal:" + dataDal);
|
||||
log.info("DataAl:" + dataAl);
|
||||
/*
|
||||
Se TipoProcesso = R allora Operatore = Recipient Effettivo
|
||||
Se TipoProcesso = D allora Operatore = Donor Effettivo
|
||||
*/
|
||||
String[] processi = new String[2];
|
||||
if (operatore!=null && !operatore.trim().equals("")) {
|
||||
if (tipoProcesso.equals(DONOR)){
|
||||
criterion.add(Restrictions.eq(C_DONOR_EFFETTIVO,operatore));
|
||||
} else if (tipoProcesso.equals(RECIPIENT)) {
|
||||
criterion.add(Restrictions.eq(C_RECIPIENT_EFFETTIVO,operatore));
|
||||
}
|
||||
}// else {
|
||||
processi[0]= tipoProcesso;
|
||||
processi[1]= "V";
|
||||
criterion.add(Restrictions.in(C_TIPO_PROCESSO, processi));
|
||||
|
||||
//}
|
||||
|
||||
// Date giornoLavorativoPrecedente = null;
|
||||
// try {
|
||||
// giornoLavorativoPrecedente = recuperaGiornoLavPrecedente();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// //
|
||||
// }
|
||||
|
||||
if(tipoPenale != null && tipoPenale.equals(IN_MATURAZIONE)){
|
||||
criterion.add(Restrictions.eq(C_DATA_MESSAGGIO_SHOW, dataDal));
|
||||
}
|
||||
else if(tipoPenale != null && tipoPenale.equals(MATURATI)){
|
||||
criterion.add(Restrictions.ge(C_DATA_FINALE, dataDal));
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(dataAl);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||||
criterion.add(Restrictions.lt(C_DATA_FINALE, calendar.getTime()));
|
||||
}
|
||||
//criterion.add(Restrictions.sqlRestriction(" TRUNC({alias}.DATA_MESSAGGIO_SHOW) = TRUNC( DWH.FUN_GIORNI_MENO@dwh(sysdate, 1) ) "));
|
||||
/*
|
||||
Se TipoMessaggio = ALL_TCR Allora non filtro
|
||||
Se TipoMessaggio = ALL_MNP Allora non filtro
|
||||
*/
|
||||
if(tipoMessaggio!=null && !tipoMessaggio.startsWith("ALL")) {
|
||||
criterion.add(Restrictions.eq(C_TIPO_SLA,tipoMessaggio));
|
||||
}
|
||||
}
|
||||
|
||||
private List getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
|
||||
private List performSearchTCMAT(){
|
||||
return mnpDwSlaMatGioTcVwDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
private List performSearchMAT(){
|
||||
return mnpdwSlaMatGiorViewDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
private List performSearchTCINMAT(){
|
||||
return mnpDwSlaInMatGioTcVwDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
private List performSearchINMAT(){
|
||||
return mnpdwSlaInMatGiorViewDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
public List performSearch(String tipoMessaggio,String tipopenale) {
|
||||
List list = new ArrayList();
|
||||
if (SLA_TC.contains(tipoMessaggio)) {
|
||||
//TC
|
||||
list = searchTC(tipopenale) ;
|
||||
} else if (SLA.contains(tipoMessaggio)) {
|
||||
//MNP
|
||||
list = search(tipopenale);
|
||||
} else {
|
||||
//ALL
|
||||
list.addAll(search(tipopenale));
|
||||
list.addAll(searchTC(tipopenale));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List searchTC(String tipopenale){
|
||||
List list = new ArrayList();
|
||||
// SE CONTIENE SLA_TC ALLORA LA QUERY è SOLO QU QUESTO RAMO
|
||||
if ("0".equals(tipopenale) || "".equals(tipopenale)){
|
||||
//SLA TC MAT
|
||||
list.addAll(performSearchTCMAT());
|
||||
}
|
||||
if ("1".equals(tipopenale) || "".equals(tipopenale)){
|
||||
//SLA TC IN MAT
|
||||
list.addAll(performSearchTCINMAT());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List search(String tipopenale){
|
||||
List list = new ArrayList();
|
||||
if ("0".equals(tipopenale) || "".equals(tipopenale)){
|
||||
//SLA MNP MAT
|
||||
list.addAll(performSearchMAT());
|
||||
}
|
||||
if ("1".equals(tipopenale) || "".equals(tipopenale)){
|
||||
//SLA MNP IN MAT
|
||||
list.addAll(performSearchINMAT());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Date recuperaGiornoLavPrecedente() {
|
||||
Date output = new Date(System.currentTimeMillis());
|
||||
try {
|
||||
String query = "select TRUNC (dwh.fun_giorni_meno@dwh (SYSDATE, 1)) from dual";
|
||||
Query stmt = mnpdwSlaInMatGiorViewDAO.getSession().createSQLQuery(query);
|
||||
output = (Date)stmt.uniqueResult();
|
||||
} catch (RuntimeException re) {
|
||||
log.error(re);
|
||||
throw re;
|
||||
} finally {
|
||||
mnpdwSlaInMatGiorViewDAO.closeSession();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoGestRicRvM2mViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoVoPrevalidazioneDbcDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoGestRicRvM2mView;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoVoPrevalidazioneDbc;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.RestrictionBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
public class Mvno2MvnoBusiness {
|
||||
static Logger log = Logger.getLogger(Mvno2MvnoBusiness.class.getName());
|
||||
|
||||
public List criterion;
|
||||
public DbcgoGestRicRvM2mViewDAO dbcgoGestRicRvM2mViewDAO;
|
||||
|
||||
public Mvno2MvnoBusiness () {
|
||||
dbcgoGestRicRvM2mViewDAO = new DbcgoGestRicRvM2mViewDAO();
|
||||
}
|
||||
|
||||
public void instanceCriteria(Map _map){
|
||||
DynaWorkForm dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
}
|
||||
|
||||
public List eseguiRicerca (int start, int range) {
|
||||
List opcol_lista_dati = new ArrayList();
|
||||
List opcol_lista_dati_uscita = new ArrayList();
|
||||
opcol_lista_dati = (List)dbcgoGestRicRvM2mViewDAO.findByCriteriaRange(getCriterion(),start,range);
|
||||
Iterator it = opcol_lista_dati.iterator();
|
||||
while (it.hasNext()) {
|
||||
DbcgoVoPrevalidazioneDbcDAO dbcgoVoPrevalidazioneDbcDAO = new DbcgoVoPrevalidazioneDbcDAO();
|
||||
DbcgoGestRicRvM2mView dbcgoGestRicRvM2mView = (DbcgoGestRicRvM2mView)it.next();
|
||||
String rifiutoValidazione = dbcgoGestRicRvM2mView.getCodicerifiutovalidazione();
|
||||
if(rifiutoValidazione!=null && !("").equals(rifiutoValidazione.trim())){
|
||||
String[] codiciA = rifiutoValidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ", <br>";;
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicRvM2mView.setCodicerifiutovalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String prevalidazione = dbcgoGestRicRvM2mView.getPrevalidazione();
|
||||
if(prevalidazione!=null && !("").equals(prevalidazione.trim())){
|
||||
String[] codiciA = prevalidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel() +", <br>";
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicRvM2mView.setPrevalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
opcol_lista_dati_uscita.add(dbcgoGestRicRvM2mView);
|
||||
}
|
||||
|
||||
log.info("Record trovati" + opcol_lista_dati.size());
|
||||
log.info("Record trovati dopo decode" + opcol_lista_dati_uscita.size());
|
||||
return opcol_lista_dati;
|
||||
}
|
||||
|
||||
public List eseguiRicerca () {
|
||||
List opcol_lista_dati = new ArrayList();
|
||||
List opcol_lista_dati_uscita = new ArrayList();
|
||||
opcol_lista_dati = (List)dbcgoGestRicRvM2mViewDAO.findByCriteria(getCriterion());
|
||||
Iterator it = opcol_lista_dati.iterator();
|
||||
while (it.hasNext()) {
|
||||
DbcgoVoPrevalidazioneDbcDAO dbcgoVoPrevalidazioneDbcDAO = new DbcgoVoPrevalidazioneDbcDAO();
|
||||
DbcgoGestRicRvM2mView dbcgoGestRicRvM2mView = (DbcgoGestRicRvM2mView)it.next();
|
||||
String rifiutoValidazione = dbcgoGestRicRvM2mView.getCodicerifiutovalidazione();
|
||||
if(rifiutoValidazione!=null && !("").equals(rifiutoValidazione.trim())){
|
||||
String[] codiciA = rifiutoValidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ", <br>";;
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicRvM2mView.setCodicerifiutovalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String prevalidazione = dbcgoGestRicRvM2mView.getPrevalidazione();
|
||||
if(prevalidazione!=null && !("").equals(prevalidazione.trim())){
|
||||
String[] codiciA = prevalidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel() +", <br>";
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicRvM2mView.setPrevalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
opcol_lista_dati_uscita.add(dbcgoGestRicRvM2mView);
|
||||
}
|
||||
|
||||
log.info("Record trovati" + opcol_lista_dati.size());
|
||||
log.info("Record trovati dopo decode" + opcol_lista_dati_uscita.size());
|
||||
return opcol_lista_dati;
|
||||
}
|
||||
|
||||
public int count () {
|
||||
return dbcgoGestRicRvM2mViewDAO.findByCriteriaCount(getCriterion());
|
||||
}
|
||||
|
||||
public List getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
public void setCriterion(List criterion) {
|
||||
this.criterion = criterion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,600 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.bean.RecipientQuadraturaBean;
|
||||
import it.valueteam.dbcgo.car.RecipientQuadraturaCar;
|
||||
import it.valueteam.dbcgo.dao.impl.AnagOperatoriDao;
|
||||
import it.valueteam.dbcgo.dao.impl.RecipientQuadraturaDaoImpl;
|
||||
import it.valueteam.dbcgo.dao.impl.AnagOperatoriDao.InfoOperatore;
|
||||
import it.valueteam.dbcgo.dao.intf.RecipientQuadraturaDao;
|
||||
import it.valueteam.dbcgo.dto.RecipientQuadraturaAnalisiDto;
|
||||
import it.valueteam.dbcgo.dto.RecipientQuadraturaSintesiDto;
|
||||
import it.valueteam.dbcgo.service.ServiceLocatorException;
|
||||
import it.valueteam.dbcgo.utility.Generic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
public class RecipientQuadraturaBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(RecipientQuadraturaBusiness.class.getName());
|
||||
private static final int STATO_TRASFERITO = 1;
|
||||
|
||||
public RecipientQuadraturaBusiness(){}
|
||||
|
||||
|
||||
public static List getListaDatiSintesiRecipient(RecipientQuadraturaBean aRecipientQuadraturaBean) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
List listaDatiSintesi = new ArrayList();
|
||||
try {
|
||||
|
||||
// copio i dati dal BEAN al CAR
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = BeanToCar(aRecipientQuadraturaBean);
|
||||
|
||||
// recupero il DAO ed eseguo la query
|
||||
RecipientQuadraturaDao theRecipientQuadraturaDao = new RecipientQuadraturaDaoImpl();
|
||||
listaDatiSintesi = theRecipientQuadraturaDao.getListaDatiSintesi(aRecipientQuadraturaCar);
|
||||
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return listaDatiSintesi;
|
||||
}
|
||||
|
||||
public static List getListaDatiAnalisiRecipient(RecipientQuadraturaBean aRecipientQuadraturaBean) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
|
||||
// copio i dati dal BEAN al CAR
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = BeanToCar(aRecipientQuadraturaBean);
|
||||
|
||||
// recupero il DAO ed eseguo la query
|
||||
RecipientQuadraturaDao theRecipientQuadraturaDao = new RecipientQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theRecipientQuadraturaDao.getListaDatiAnalisi(aRecipientQuadraturaCar);
|
||||
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return listaDatiAnalisi;
|
||||
}
|
||||
|
||||
public static List getListaDatiAnalisiRecipientInRange(RecipientQuadraturaBean aRecipientQuadraturaBean,long start, long range) throws Exception{
|
||||
log.info("Start");
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = BeanToCar(aRecipientQuadraturaBean);
|
||||
// recupero il DAO ed eseguo la query
|
||||
RecipientQuadraturaDao theRecipientQuadraturaDao = new RecipientQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theRecipientQuadraturaDao.getListaDatiAnalisiInRange(aRecipientQuadraturaCar, start, range);
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return listaDatiAnalisi;
|
||||
}
|
||||
|
||||
public static List getListaDatiDettaglioExtraRecipientInRange(RecipientQuadraturaBean aRecipientQuadraturaBean,long start, long range) throws Exception{
|
||||
log.info("Start");
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = BeanToCar(aRecipientQuadraturaBean);
|
||||
// recupero il DAO ed eseguo la query
|
||||
RecipientQuadraturaDao theRecipientQuadraturaDao = new RecipientQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theRecipientQuadraturaDao.getListaDatiDettaglioExtraInRange(aRecipientQuadraturaCar, start, range);
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return listaDatiAnalisi;
|
||||
}
|
||||
|
||||
public static Map getInfoListaDatiAnalisiRecipient(RecipientQuadraturaBean aRecipientQuadraturaBean) throws Exception{
|
||||
log.info("Start");
|
||||
Map mappa = new HashMap();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = BeanToCar(aRecipientQuadraturaBean);
|
||||
// recupero il DAO ed eseguo la query
|
||||
RecipientQuadraturaDao theRecipientQuadraturaDao = new RecipientQuadraturaDaoImpl();
|
||||
mappa = theRecipientQuadraturaDao.getInfoListaDatiAnalisi(aRecipientQuadraturaCar);
|
||||
} catch(ServiceLocatorException e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return mappa;
|
||||
}
|
||||
|
||||
public static byte[] getTXTReportSintesi(RecipientQuadraturaBean aRecipientQuadraturaBean) throws Exception {
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
List listaDatiSintesi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = BeanToCar(aRecipientQuadraturaBean);
|
||||
|
||||
// recupero il DAO ed eseguo la query
|
||||
RecipientQuadraturaDao theRecipientQuadraturaDao = new RecipientQuadraturaDaoImpl();
|
||||
listaDatiSintesi = theRecipientQuadraturaDao.getListaDatiSintesi(aRecipientQuadraturaCar);
|
||||
|
||||
// inizio la costruzione del file
|
||||
byteTxtReport = writeTXTReportSintesi(aRecipientQuadraturaBean, listaDatiSintesi);
|
||||
|
||||
} catch(Exception e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
public static byte[] getTXTReportAnalisi(RecipientQuadraturaBean aRecipientQuadraturaBean) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = BeanToCar(aRecipientQuadraturaBean);
|
||||
|
||||
RecipientQuadraturaDao theRecipientQuadraturaDao = new RecipientQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theRecipientQuadraturaDao.getListaDatiAnalisi(aRecipientQuadraturaCar);
|
||||
|
||||
// inizio la costruzione del file
|
||||
byteTxtReport = writeTXTReportAnalisi(aRecipientQuadraturaBean, listaDatiAnalisi);
|
||||
|
||||
} catch(Exception e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
public static byte[] getTXTReportDettaglioExtra(RecipientQuadraturaBean aRecipientQuadraturaBean) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
List listaDatiAnalisi = new ArrayList();
|
||||
try {
|
||||
// copio i dati dal BEAN al CAR
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = BeanToCar(aRecipientQuadraturaBean);
|
||||
|
||||
RecipientQuadraturaDao theRecipientQuadraturaDao = new RecipientQuadraturaDaoImpl();
|
||||
listaDatiAnalisi = theRecipientQuadraturaDao.getListaDatiDettaglioExtra(aRecipientQuadraturaCar);
|
||||
|
||||
// inizio la costruzione del file
|
||||
byteTxtReport = writeTXTReportDettaglioExtra(aRecipientQuadraturaBean, listaDatiAnalisi);
|
||||
|
||||
} catch(Exception e) {
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
log.info("End");
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
// metodo accessorio per la costruzione del file di sintesi
|
||||
private static byte[] writeTXTReportSintesi(RecipientQuadraturaBean aRecipientQuadraturaBean, List listaDatiSintesi) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
try{
|
||||
String dataDal = aRecipientQuadraturaBean.getDataDal();
|
||||
String meseRiferimento = dataDal.substring(6)+""+dataDal.substring(3,5);
|
||||
AnagOperatoriDao anagOperatoriDao = new AnagOperatoriDao();
|
||||
InfoOperatore infoOperatore = anagOperatoriDao.getInfoOperatore(aRecipientQuadraturaBean.getIdOperatore());
|
||||
// creazione record di testa
|
||||
|
||||
StringBuffer stringBufferHeader = new StringBuffer(90);
|
||||
StringBuffer stringBufferHeader_ = new StringBuffer();
|
||||
stringBufferHeader_.append(Generic.fillWith(1,' ')); // filler(1)
|
||||
stringBufferHeader_.append("RS"); // tipo record(2)
|
||||
stringBufferHeader_.append("TIMG"); // codice operatore recipient(4)
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferHeader_.append(infoOperatore.getGestore_aom());
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
} // codice operatore donating(4)
|
||||
if("TIM".equalsIgnoreCase(aRecipientQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFillwhite(4,aRecipientQuadraturaBean.getIdOperatoreVirtuale())); // codice operatore virtuale recipient(4)
|
||||
}
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferHeader_.append(infoOperatore.getId_operatore()); // codice operatore virtuale donating(4)
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferHeader_.append(meseRiferimento); // mese di riferimento(6)
|
||||
stringBufferHeader_.append("SIN_"+meseRiferimento); // nome file(10)
|
||||
stringBufferHeader.append(Generic.plainRow(stringBufferHeader_.toString()));
|
||||
|
||||
stringBufferHeader.append("\r\n");
|
||||
|
||||
// creazione dei record centrali
|
||||
int numeroDisposizioni = 0;
|
||||
double totaleImporti = 0;
|
||||
int contatore = 0;
|
||||
StringBuffer stringBufferBody = new StringBuffer();
|
||||
|
||||
Iterator iterator = listaDatiSintesi.iterator();
|
||||
while(iterator.hasNext()){
|
||||
StringBuffer stringBufferBody_ = new StringBuffer();
|
||||
contatore++;
|
||||
RecipientQuadraturaSintesiDto aRecipientQuadraturaSintesiDto = (RecipientQuadraturaSintesiDto)iterator.next();
|
||||
numeroDisposizioni = numeroDisposizioni + aRecipientQuadraturaSintesiDto.getNumeroPosizioniTrasferite();
|
||||
totaleImporti = totaleImporti + aRecipientQuadraturaSintesiDto.getTotaleImportiTrasferiti();
|
||||
|
||||
stringBufferBody_.append(Generic.fillWith(1,' '));
|
||||
stringBufferBody_.append("20");
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000",""+contatore));
|
||||
String dataNC = Generic.DateToString(aRecipientQuadraturaSintesiDto.getDataNotificaCredito(), "dd-MM-yyyy");
|
||||
//porto in formato yyyyMMdd
|
||||
dataNC = dataNC.substring(6)+""+dataNC.substring(3,5)+""+dataNC.substring(0,2);
|
||||
stringBufferBody_.append(dataNC);
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(aRecipientQuadraturaSintesiDto.getTotaleImportiTrasferiti())));
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000", ""+aRecipientQuadraturaSintesiDto.getNumeroPosizioniTrasferite()));
|
||||
//stringBufferBody_.append(aRecipientQuadraturaSintesiDto.getOperatoreDonating());
|
||||
stringBufferBody.append(Generic.plainRow(stringBufferBody_.toString()));
|
||||
stringBufferBody.append("\r\n");
|
||||
}
|
||||
|
||||
// creazione record di coda
|
||||
StringBuffer stringBufferFooter = new StringBuffer(90);
|
||||
StringBuffer stringBufferFooter_ = new StringBuffer();
|
||||
stringBufferFooter_.append(Generic.fillWith(1,' ')); // filler(1)
|
||||
stringBufferFooter_.append("RF"); // tipo record(2)
|
||||
stringBufferFooter_.append("TIMG"); // codice operatore recipient(4)
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferFooter_.append(infoOperatore.getGestore_aom()); // codice operatore donating(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
if("TIM".equalsIgnoreCase(aRecipientQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFillwhite(4,aRecipientQuadraturaBean.getIdOperatoreVirtuale())); // codice operatore virtuale recipient(10)
|
||||
}
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferFooter_.append(infoOperatore.getId_operatore()); // codice operatore virtuale donating(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
} // codice operatore virtuale donating(10)
|
||||
stringBufferFooter_.append(meseRiferimento); // mese di riferimento(6)
|
||||
stringBufferFooter_.append("SIN_"+meseRiferimento); // nome file(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+numeroDisposizioni)); // numero disposizioni(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(totaleImporti))); // totale importi trasferiti(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+(listaDatiSintesi.size()+2))); // numero record(10)
|
||||
stringBufferFooter.append(Generic.plainRow(stringBufferFooter_.toString()));
|
||||
stringBufferFooter.append("\r\n");
|
||||
|
||||
String txtReport = stringBufferHeader.toString()+stringBufferBody.toString()+stringBufferFooter.toString();
|
||||
byteTxtReport = txtReport.getBytes();
|
||||
log.info("End");
|
||||
} catch (Exception e){
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
// metodo accessorio per la costruzione del file di analisi
|
||||
private static byte[] writeTXTReportDettaglioExtra(RecipientQuadraturaBean aRecipientQuadraturaBean, List listaDatiAnalisi) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
try{
|
||||
String dataDal = aRecipientQuadraturaBean.getDataDal();
|
||||
String dataRiferimento = dataDal.substring(6)+""+dataDal.substring(3,5)+""+dataDal.substring(0,2);
|
||||
AnagOperatoriDao anagOperatoriDao = new AnagOperatoriDao();
|
||||
InfoOperatore infoOperatore = anagOperatoriDao.getInfoOperatore(aRecipientQuadraturaBean.getIdOperatore());
|
||||
// creazione record di testa
|
||||
StringBuffer stringBufferHeader = new StringBuffer(90);
|
||||
StringBuffer stringBufferHeader_ = new StringBuffer();
|
||||
stringBufferHeader_.append(Generic.fillWith(1,' ')); // filler(1)
|
||||
stringBufferHeader_.append("TE"); // tipo record(2)
|
||||
stringBufferHeader_.append("TIMG"); // codice operatore recipient(4)
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferHeader_.append(infoOperatore.getGestore_aom());
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
} // codice operatore donating(4)
|
||||
if("TIM".equalsIgnoreCase(aRecipientQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFillwhite(4,aRecipientQuadraturaBean.getIdOperatoreVirtuale())); // codice operatore virtuale recipient(4)
|
||||
}
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferHeader_.append(infoOperatore.getId_operatore()); // codice operatore virtuale donating(4)
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferHeader_.append(dataRiferimento); // data notifica credito(8)
|
||||
stringBufferHeader_.append("D_"+dataRiferimento); // nome file(10)
|
||||
stringBufferHeader.append(Generic.plainRow(stringBufferHeader_.toString()));
|
||||
stringBufferHeader.append("\r\n");
|
||||
|
||||
// creazione dei record centrali
|
||||
double totaleImporti = 0;
|
||||
int contatore = 0;
|
||||
StringBuffer stringBufferBody = new StringBuffer();
|
||||
|
||||
Iterator iterator = listaDatiAnalisi.iterator();
|
||||
while(iterator.hasNext()){
|
||||
StringBuffer stringBufferBody_ = new StringBuffer();
|
||||
contatore++;
|
||||
RecipientQuadraturaAnalisiDto aRecipientQuadraturaAnalisiDto = (RecipientQuadraturaAnalisiDto)iterator.next();
|
||||
totaleImporti = totaleImporti + aRecipientQuadraturaAnalisiDto.getImportoTrasferito();
|
||||
|
||||
stringBufferBody_.append(Generic.fillWith(1,' '));
|
||||
stringBufferBody_.append("30");
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000",""+contatore));
|
||||
String contenitore18Blank = " ";
|
||||
stringBufferBody_.append(Generic.strRightFill(contenitore18Blank, aRecipientQuadraturaAnalisiDto.getCodiceRichiestaRecipient()));
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(aRecipientQuadraturaAnalisiDto.getImportoTrasferito())));
|
||||
stringBufferBody_.append(aRecipientQuadraturaAnalisiDto.getOperatoreDonating());
|
||||
stringBufferBody_.append(Generic.strLeftFill("000000000000000", aRecipientQuadraturaAnalisiDto.getMsisdn()));
|
||||
if(aRecipientQuadraturaAnalisiDto.getUtenza().equals("PRP")){
|
||||
stringBufferBody_.append("PP ");
|
||||
} else {
|
||||
stringBufferBody_.append(aRecipientQuadraturaAnalisiDto.getUtenza());
|
||||
}
|
||||
stringBufferBody_.append(aRecipientQuadraturaAnalisiDto.getAmbito());
|
||||
stringBufferBody.append(Generic.plainRow(stringBufferBody_.toString()));
|
||||
stringBufferBody.append("\r\n");
|
||||
}
|
||||
|
||||
// creazione record di coda
|
||||
StringBuffer stringBufferFooter = new StringBuffer(90);
|
||||
StringBuffer stringBufferFooter_ = new StringBuffer();
|
||||
stringBufferFooter_.append(Generic.fillWith(1,' ')); // filler(1)
|
||||
stringBufferFooter_.append("CO"); // tipo record(2)
|
||||
stringBufferFooter_.append("TIMG"); // codice operatore recipient(4)
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferFooter_.append(infoOperatore.getGestore_aom());
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
} // codice operatore donating(4)
|
||||
if("TIM".equalsIgnoreCase(aRecipientQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFillwhite(4,aRecipientQuadraturaBean.getIdOperatoreVirtuale())); // codice operatore virtuale recipient(4)
|
||||
}
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferFooter_.append(infoOperatore.getId_operatore()); // codice operatore virtuale donating(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferFooter_.append(dataRiferimento); // data notifica credito(8)
|
||||
stringBufferFooter_.append("D_"+dataRiferimento); // nome file(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+listaDatiAnalisi.size())); // numero disposizioni(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(totaleImporti))); // totale importi trasferiti(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+(listaDatiAnalisi.size()+2))); // numero record(10)
|
||||
stringBufferFooter.append(Generic.plainRow(stringBufferFooter_.toString()));
|
||||
stringBufferFooter.append("\r\n");
|
||||
|
||||
String txtReport = stringBufferHeader.toString()+stringBufferBody.toString()+stringBufferFooter.toString();
|
||||
byteTxtReport = txtReport.getBytes();
|
||||
|
||||
log.info("End");
|
||||
} catch (Exception e){
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
// metodo accessorio per la costruzione del file di analisi
|
||||
private static byte[] writeTXTReportAnalisi(RecipientQuadraturaBean aRecipientQuadraturaBean, List listaDatiAnalisi) throws Exception{
|
||||
|
||||
log.info("Start");
|
||||
byte[] byteTxtReport = null;
|
||||
try{
|
||||
String dataDal = aRecipientQuadraturaBean.getDataDal();
|
||||
String dataRiferimento = dataDal.substring(6)+""+dataDal.substring(3,5)+""+dataDal.substring(0,2);
|
||||
AnagOperatoriDao anagOperatoriDao = new AnagOperatoriDao();
|
||||
InfoOperatore infoOperatore = anagOperatoriDao.getInfoOperatore(aRecipientQuadraturaBean.getIdOperatore());
|
||||
// creazione record di testa
|
||||
StringBuffer stringBufferHeader = new StringBuffer(90);
|
||||
StringBuffer stringBufferHeader_ = new StringBuffer(90);
|
||||
stringBufferHeader_.append(Generic.fillWith(1,' ')); // filler(1)
|
||||
stringBufferHeader_.append("PC"); // tipo record(2)
|
||||
stringBufferHeader_.append("TIMG"); // codice operatore recipient(4)
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferHeader_.append(infoOperatore.getGestore_aom());
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
} // codice operatore donating(4)
|
||||
if("TIM".equalsIgnoreCase(aRecipientQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFillwhite(4,aRecipientQuadraturaBean.getIdOperatoreVirtuale())); // codice operatore virtuale recipient(4)
|
||||
}
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferHeader_.append(infoOperatore.getId_operatore()); // codice operatore virtuale donating(4)
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferHeader_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferHeader_.append(dataRiferimento); // data notifica credito(8)
|
||||
stringBufferHeader_.append("D_"+dataRiferimento); // nome file(10)
|
||||
stringBufferHeader.append(Generic.plainRow(stringBufferHeader_.toString()));
|
||||
|
||||
stringBufferHeader.append("\r\n");
|
||||
|
||||
// creazione dei record centrali
|
||||
double totaleImporti = 0;
|
||||
int contatore = 0;
|
||||
StringBuffer stringBufferBody = new StringBuffer();
|
||||
|
||||
Iterator iterator = listaDatiAnalisi.iterator();
|
||||
while(iterator.hasNext()){
|
||||
StringBuffer stringBufferBody_ = new StringBuffer();
|
||||
contatore++;
|
||||
RecipientQuadraturaAnalisiDto aRecipientQuadraturaAnalisiDto = (RecipientQuadraturaAnalisiDto)iterator.next();
|
||||
totaleImporti = totaleImporti + aRecipientQuadraturaAnalisiDto.getImportoTrasferito();
|
||||
|
||||
stringBufferBody_.append(Generic.fillWith(1,' '));
|
||||
stringBufferBody_.append("10");
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000",""+contatore));
|
||||
String contenitore18Blank = " ";
|
||||
stringBufferBody_.append(Generic.strRightFill(contenitore18Blank, aRecipientQuadraturaAnalisiDto.getCodiceRichiestaRecipient()));
|
||||
stringBufferBody_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(aRecipientQuadraturaAnalisiDto.getImportoTrasferito())));
|
||||
//stringBufferBody_.append(aRecipientQuadraturaAnalisiDto.getOperatoreDonating());
|
||||
stringBufferBody.append(Generic.plainRow(stringBufferBody_.toString()));
|
||||
stringBufferBody.append("\r\n");
|
||||
}
|
||||
|
||||
// creazione record di coda
|
||||
StringBuffer stringBufferFooter = new StringBuffer(90);
|
||||
StringBuffer stringBufferFooter_ = new StringBuffer(90);
|
||||
stringBufferFooter_.append(Generic.fillWith(1,' ')); // filler(1)
|
||||
stringBufferFooter_.append("EF"); // tipo record(2)
|
||||
stringBufferFooter_.append("TIMG"); // codice operatore recipient(4)
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
stringBufferFooter_.append(infoOperatore.getGestore_aom());
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
} // codice operatore donating(4)
|
||||
if("TIM".equalsIgnoreCase(aRecipientQuadraturaBean.getIdOperatoreVirtuale())){
|
||||
// non esiste virtuale
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFillwhite(4,aRecipientQuadraturaBean.getIdOperatoreVirtuale())); // codice operatore virtuale recipient(4)
|
||||
}
|
||||
if(!aRecipientQuadraturaBean.getIdOperatore().equals("%%")){
|
||||
if (isVirt(infoOperatore)) {
|
||||
stringBufferFooter_.append(infoOperatore.getId_operatore()); // codice operatore virtuale donating(4)
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.fillWith(4,' '));
|
||||
}
|
||||
} else {
|
||||
stringBufferFooter_.append(Generic.strRightFill(" ", "ALL"));
|
||||
}
|
||||
stringBufferFooter_.append(dataRiferimento); // data notifica credito(8)
|
||||
stringBufferFooter_.append("D_"+dataRiferimento); // nome file(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+listaDatiAnalisi.size())); // numero disposizioni(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+Generic.doubleToCentesimi(totaleImporti))); // totale importi trasferiti(10)
|
||||
stringBufferFooter_.append(Generic.strLeftFill("0000000000", ""+(listaDatiAnalisi.size()+2))); // numero record(10)
|
||||
stringBufferFooter.append(Generic.plainRow(stringBufferFooter_.toString()));
|
||||
stringBufferFooter.append("\r\n");
|
||||
|
||||
String txtReport = stringBufferHeader.toString()+stringBufferBody.toString()+stringBufferFooter.toString();
|
||||
byteTxtReport = txtReport.getBytes();
|
||||
|
||||
log.info("End");
|
||||
} catch (Exception e){
|
||||
log.error(e.getCause());
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
return byteTxtReport;
|
||||
}
|
||||
|
||||
// metodo accessorio per il trasferimento dei dati
|
||||
private static RecipientQuadraturaCar BeanToCar(RecipientQuadraturaBean aRecipientQuadraturaBean){
|
||||
|
||||
RecipientQuadraturaCar aRecipientQuadraturaCar = new RecipientQuadraturaCar();
|
||||
aRecipientQuadraturaCar.setIdOperatore(aRecipientQuadraturaBean.getIdOperatore());
|
||||
|
||||
// eseguo controlli su idOperatoreVirtuale
|
||||
String idOperatoreVirtuale = aRecipientQuadraturaBean.getIdOperatoreVirtuale();
|
||||
if("TIM".equalsIgnoreCase(idOperatoreVirtuale)){
|
||||
idOperatoreVirtuale = idOperatoreVirtuale+"%";
|
||||
} else if("ALL".equalsIgnoreCase(idOperatoreVirtuale)){
|
||||
idOperatoreVirtuale = "%%";
|
||||
}
|
||||
aRecipientQuadraturaCar.setIdOperatoreVirtuale(idOperatoreVirtuale);
|
||||
|
||||
aRecipientQuadraturaCar.setDataDal(aRecipientQuadraturaBean.getDataDal());
|
||||
aRecipientQuadraturaCar.setDataAl(aRecipientQuadraturaBean.getDataAl());
|
||||
|
||||
// eseguo controlli su idTipoCliente
|
||||
String idTipoCliente = aRecipientQuadraturaBean.getIdTipoCliente();
|
||||
if("ALL".equalsIgnoreCase(idTipoCliente)){
|
||||
idTipoCliente = "%%";
|
||||
}
|
||||
aRecipientQuadraturaCar.setIdTipoCliente(idTipoCliente);
|
||||
|
||||
// eseguo controlli sul idTipoContratto
|
||||
String idTipoContratto = aRecipientQuadraturaBean.getIdTipoContratto();
|
||||
if("ALL".equalsIgnoreCase(idTipoContratto)){
|
||||
idTipoContratto = "%%";
|
||||
}
|
||||
aRecipientQuadraturaCar.setIdTipoContratto(idTipoContratto);
|
||||
|
||||
aRecipientQuadraturaCar.setIdStato(STATO_TRASFERITO);
|
||||
|
||||
return aRecipientQuadraturaCar;
|
||||
}
|
||||
|
||||
private static boolean isVirt(InfoOperatore info){
|
||||
if ("VIRT".equals(info.getTipo_operatore().trim()))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoGestRicRecVirtViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoVoPrevalidazioneDbcDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoGestRicRecVirtView;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoVoPrevalidazioneDbc;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.RestrictionBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
public class RecipientVirtMvnoBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(RecipientVirtMvnoBusiness.class.getName());
|
||||
public List criterion;
|
||||
public DbcgoGestRicRecVirtViewDAO dbcgoGestRicRecVirtViewDAO;
|
||||
|
||||
public RecipientVirtMvnoBusiness () {
|
||||
dbcgoGestRicRecVirtViewDAO = new DbcgoGestRicRecVirtViewDAO();
|
||||
}
|
||||
|
||||
public void instanceCriteria(Map _map){
|
||||
DynaWorkForm dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
}
|
||||
|
||||
public List eseguiRicerca (int start, int range) {
|
||||
List opcol_lista_dati = new ArrayList();
|
||||
List opcol_lista_dati_uscita = new ArrayList();
|
||||
opcol_lista_dati = (List)dbcgoGestRicRecVirtViewDAO.findByCriteriaRange(getCriterion(),start,range);
|
||||
Iterator it = opcol_lista_dati.iterator();
|
||||
while (it.hasNext()) {
|
||||
DbcgoVoPrevalidazioneDbcDAO dbcgoVoPrevalidazioneDbcDAO = new DbcgoVoPrevalidazioneDbcDAO();
|
||||
DbcgoGestRicRecVirtView dbcgoGestRicRecVirtView = (DbcgoGestRicRecVirtView)it.next();
|
||||
String rifiutoValidazione = dbcgoGestRicRecVirtView.getCodicerifiutovalidazione();
|
||||
if(rifiutoValidazione!=null && !("").equals(rifiutoValidazione.trim())){
|
||||
String[] codiciA = rifiutoValidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ", <br>";;
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicRecVirtView.setCodicerifiutovalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String prevalidazione = dbcgoGestRicRecVirtView.getPrevalidazione();
|
||||
if(prevalidazione!=null && !("").equals(prevalidazione.trim())){
|
||||
String[] codiciA = prevalidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel() +", <br>";
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicRecVirtView.setPrevalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
opcol_lista_dati_uscita.add(dbcgoGestRicRecVirtView);
|
||||
}
|
||||
|
||||
log.info("Record trovati" + opcol_lista_dati.size());
|
||||
log.info("Record trovati dopo decode" + opcol_lista_dati_uscita.size());
|
||||
return opcol_lista_dati;
|
||||
}
|
||||
|
||||
public List eseguiRicerca () {
|
||||
List opcol_lista_dati = new ArrayList();
|
||||
List opcol_lista_dati_uscita = new ArrayList();
|
||||
opcol_lista_dati = (List)dbcgoGestRicRecVirtViewDAO.findByCriteria(getCriterion());
|
||||
Iterator it = opcol_lista_dati.iterator();
|
||||
while (it.hasNext()) {
|
||||
DbcgoVoPrevalidazioneDbcDAO dbcgoVoPrevalidazioneDbcDAO = new DbcgoVoPrevalidazioneDbcDAO();
|
||||
DbcgoGestRicRecVirtView dbcgoGestRicRecVirtView = (DbcgoGestRicRecVirtView)it.next();
|
||||
String rifiutoValidazione = dbcgoGestRicRecVirtView.getCodicerifiutovalidazione();
|
||||
if(rifiutoValidazione!=null && !("").equals(rifiutoValidazione.trim())){
|
||||
String[] codiciA = rifiutoValidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ", <br>";;
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicRecVirtView.setCodicerifiutovalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String prevalidazione = dbcgoGestRicRecVirtView.getPrevalidazione();
|
||||
if(prevalidazione!=null && !("").equals(prevalidazione.trim())){
|
||||
String[] codiciA = prevalidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel() +", <br>";
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestRicRecVirtView.setPrevalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
opcol_lista_dati_uscita.add(dbcgoGestRicRecVirtView);
|
||||
}
|
||||
|
||||
log.info("Record trovati" + opcol_lista_dati.size());
|
||||
log.info("Record trovati dopo decode" + opcol_lista_dati_uscita.size());
|
||||
return opcol_lista_dati;
|
||||
}
|
||||
|
||||
public int count () {
|
||||
return dbcgoGestRicRecVirtViewDAO.findByCriteriaCount(getCriterion());
|
||||
}
|
||||
|
||||
public List getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
public void setCriterion(List criterion) {
|
||||
this.criterion = criterion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.MnpReportAgcomViewDAO;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.RestrictionBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class ReportAgcomBusiness {
|
||||
static Logger log = Logger.getLogger(ReportAgcomBusiness.class.getName());
|
||||
|
||||
public List criterion;
|
||||
public MnpReportAgcomViewDAO mnpReportAgcomViewDAO;
|
||||
|
||||
public ReportAgcomBusiness () {
|
||||
mnpReportAgcomViewDAO = new MnpReportAgcomViewDAO();
|
||||
}
|
||||
|
||||
public void instanceCriteria(Map _map){
|
||||
DynaWorkForm dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
}
|
||||
public List eseguiRicerca () {
|
||||
return (List)mnpReportAgcomViewDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
public List getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
public void setCriterion(List criterion) {
|
||||
this.criterion = criterion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,827 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dto.MnpReportAgcomView;
|
||||
import jxl.Cell;
|
||||
import jxl.write.Label;
|
||||
import jxl.write.WritableCell;
|
||||
import jxl.write.WritableSheet;
|
||||
import jxl.write.WritableWorkbook;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
//import org.apache.poi.ss.usermodel.CellType;
|
||||
|
||||
/**
|
||||
* @version 4.0 201709 Report AGCOM migrato a formato XLSX per superamento 256 colonne com ILIAD
|
||||
* @version 5.0 MNP_SM_2350 201712 Anomalia su report AGCOM
|
||||
* Add field CSV4 to cover further 4k segment of CLOB field MNP.MNP_REPORT_AGCOM.CSV
|
||||
* @version 5.1 MNP_SM_2352 20180105 "Numero di giorni di manutenzione programmata nel mese di riferimento"
|
||||
* valorizzato non correttamente in Dati Generali
|
||||
* @version 5.2 MNP_SM_2358 20180806 "DBCGO Report AGCOM - dati ILIAD Donating mancanti"
|
||||
* MAX_ROWS era rimasto a 264 (WELCOME) e quindi escludeva tutte le righe ILIAD
|
||||
* INOLTRE richiesto di posizionare il cursore in A1 all'apertura del foglio
|
||||
*
|
||||
* ATTENZIONE: ogni volta che si aggiungono righe/colonne al template del foglio Excel
|
||||
* bisogna aggiornare le costanti MAX_COLUMNS e MAX_ROWS di conseguenza
|
||||
*/
|
||||
public class ReportAgcomXLSBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(ReportAgcomXLSBusiness.class.getName());
|
||||
|
||||
// Costanti per il popolamento delle schede 1R_2R_5T_5S_5A_6_7
|
||||
// ATTENZIONE: aggiornare a ogni aggiunta di righe/colonne al template excel
|
||||
// impostare all'ordinale ZERO-BASED dell'ultima colonna e riga effettive del riquadro dati
|
||||
// sottraendo 1 al valore dell'ordinale 1-based rilevato dal foglio:
|
||||
// - 1-based per le colonne si ricava dalla formula =COLUMN() su una cella della colonna,
|
||||
// (per esempio COLUMN(DY) = 129, quindi MAX_COLUMS=128)
|
||||
// - 1-based per le righe e' l'etichetta di riga visibile nel foglio (quindi per la 139 MAX_ROWS=138);
|
||||
// MNP_SM_2358 MAX_ROWS era rimasto a 264 (WELCOME) e quindi escludeva tutte le righe ILIAD
|
||||
//SOMMARE SEMPRE PIU 21
|
||||
private int MAX_COLUMNS = 359; // Attualmente la colonna JP (COLUMN(JP)=276) del foglio Excel
|
||||
private int MAX_ROWS = 369; // Attualmente la riga con etichetta 286 del foglio Excel
|
||||
|
||||
private HashMap mappaTipoReport;
|
||||
//private HashMap xMappaTipoReport;
|
||||
|
||||
public ReportAgcomXLSBusiness () {
|
||||
inizializzaMappa();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2017 C09 Report AGCOM migrato a formato XLSX per superamento 256 colonne con ILIAD
|
||||
* @see xGenerateSheet
|
||||
*/
|
||||
public void generateSheet(WritableWorkbook copy, String tipoReport, List l) {
|
||||
log.debug("Start method - generate sheet on xls - parameter: " + tipoReport);
|
||||
try{
|
||||
int reportSelezionato = getTipoReport(tipoReport);
|
||||
|
||||
WritableSheet sheet = copy.getSheet(reportSelezionato);
|
||||
|
||||
MnpReportAgcomView mnpReportAgcomView = (MnpReportAgcomView) (l.get(0));
|
||||
|
||||
String tmp1 = (mnpReportAgcomView.getCsv1() != null) ? mnpReportAgcomView.getCsv1() : "";
|
||||
String tmp2 = (mnpReportAgcomView.getCsv2() != null) ? mnpReportAgcomView.getCsv2() : "";
|
||||
String tmp3 = (mnpReportAgcomView.getCsv3() != null) ? mnpReportAgcomView.getCsv3() : "";
|
||||
|
||||
String[] risultato = (tmp1 + tmp2 + tmp3).split("\n");
|
||||
|
||||
if(reportSelezionato == 2 || reportSelezionato == 3 || reportSelezionato == 8 || reportSelezionato == 9 ||
|
||||
reportSelezionato == 10 || reportSelezionato == 11 || reportSelezionato == 12){
|
||||
popola_1R_2R_5T_5S_5A_6_7(sheet, risultato);
|
||||
}
|
||||
else if(reportSelezionato == 0){
|
||||
popolaDatiGenerali(sheet, risultato);
|
||||
}
|
||||
else if(reportSelezionato == 13){
|
||||
popola_8(sheet, risultato, tipoReport);
|
||||
}
|
||||
else if(reportSelezionato == 14 || reportSelezionato == 15){
|
||||
popola_9(sheet, risultato);
|
||||
}
|
||||
else{
|
||||
popola_3R_3D_4R_4D(sheet, risultato);
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
}
|
||||
log.debug("End method - generate sheet on xls - parameter: " + tipoReport);
|
||||
}
|
||||
|
||||
/**
|
||||
* @version 4.0 201709 Report AGCOM migrato a formato XLSX per superamento 256 colonne com ILIAD
|
||||
* @version 5.0 MNP_SM_2350 201712 Anomalia su report AGCOM
|
||||
* Add field CSV4 to cover further 4k segment of CLOB field MNP.MNP_REPORT_AGCOM.CSV
|
||||
*/
|
||||
public void xGenerateSheet(XSSFWorkbook copy, String tipoReport, List l) {
|
||||
log.debug("Start method xGenerateSheet - generate sheet on xls - parameter: " + tipoReport);
|
||||
|
||||
try{
|
||||
|
||||
int reportSelezionato = getTipoReport(tipoReport);
|
||||
XSSFSheet sheet = copy.getSheetAt(reportSelezionato);
|
||||
MnpReportAgcomView mnpReportAgcomView = (MnpReportAgcomView) (l.get(0));
|
||||
|
||||
String tmp1 = (mnpReportAgcomView.getCsv1() != null) ? mnpReportAgcomView.getCsv1() : "";
|
||||
String tmp2 = (mnpReportAgcomView.getCsv2() != null) ? mnpReportAgcomView.getCsv2() : "";
|
||||
String tmp3 = (mnpReportAgcomView.getCsv3() != null) ? mnpReportAgcomView.getCsv3() : "";
|
||||
// MNP_SM_2350 BEGIN
|
||||
String tmp4 = (mnpReportAgcomView.getCsv4() != null) ? mnpReportAgcomView.getCsv4() : "";
|
||||
// MNP_SM_2350 END
|
||||
|
||||
// MNP_SM_2391 BEGIN
|
||||
String tmp5 = (mnpReportAgcomView.getCsv5() != null) ? mnpReportAgcomView.getCsv5() : "";
|
||||
String tmp6 = (mnpReportAgcomView.getCsv6() != null) ? mnpReportAgcomView.getCsv6() : "";
|
||||
String tmp7 = (mnpReportAgcomView.getCsv7() != null) ? mnpReportAgcomView.getCsv7() : "";
|
||||
String tmp8 = (mnpReportAgcomView.getCsv8() != null) ? mnpReportAgcomView.getCsv8() : "";
|
||||
String tmp9 = (mnpReportAgcomView.getCsv9() != null) ? mnpReportAgcomView.getCsv9() : "";
|
||||
String tmp10 = (mnpReportAgcomView.getCsv10() != null) ? mnpReportAgcomView.getCsv10() : "";
|
||||
// MNP_SM_2391 END
|
||||
|
||||
String[] risultato = (tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6 + tmp7 + tmp8 + tmp9 + tmp10).split("\n");
|
||||
|
||||
if(reportSelezionato == 2 || reportSelezionato == 3 || reportSelezionato == 8 || reportSelezionato == 9 ||
|
||||
reportSelezionato == 10 || reportSelezionato == 11 || reportSelezionato == 12){
|
||||
xPopola_1R_2R_5T_5S_5A_6_7(sheet, risultato);
|
||||
}
|
||||
else if(reportSelezionato == 0){
|
||||
xPopolaDatiGenerali(sheet, risultato);
|
||||
}
|
||||
else if(reportSelezionato == 13){
|
||||
xPopola_8(sheet, risultato, tipoReport);
|
||||
}
|
||||
else if(reportSelezionato == 14 || reportSelezionato == 15){
|
||||
xPopola_9(sheet, risultato);
|
||||
}
|
||||
else{
|
||||
xPopola_3R_3D_4R_4D(sheet, risultato);
|
||||
}
|
||||
|
||||
FormulaEvaluator evaluator = copy.getCreationHelper().createFormulaEvaluator();
|
||||
evaluator.evaluateAll();
|
||||
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
////e.printStackTrace();
|
||||
}
|
||||
log.debug("End method xGenerateSheet - generate sheet on xls - parameter: " + tipoReport);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2017 C09 Report AGCOM migrato a formato XLSX per superamento 256 colonne con ILIAD
|
||||
* @see xPopola_1R_2R_5T_5S_5A_6_7
|
||||
*/
|
||||
private void popola_1R_2R_5T_5S_5A_6_7(WritableSheet sheet, String[] risultato) {
|
||||
try{
|
||||
String colonna, riga, valore = "";
|
||||
Cell cellRow, cellColumn = null;
|
||||
WritableCell cella = null;
|
||||
jxl.write.Number num = null;
|
||||
|
||||
if(risultato != null && risultato.length > 0){
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
if(!risultato[i].trim().equals("")){
|
||||
colonna = (risultato[i].split(";")[0] == null) ? "" : risultato[i].split(";")[0].trim();
|
||||
riga = (risultato[i].split(";")[1] == null) ? "" : risultato[i].split(";")[1].trim();
|
||||
valore = (risultato[i].split(";")[2] == null) ? "" : risultato[i].split(";")[2].trim();
|
||||
|
||||
cellRow = sheet.findCell(riga, 1, 13, 1, MAX_ROWS, false); // cerco da B14 (1,13) a B{MAX_ROWS+1} (1, {MAX_ROWS})
|
||||
cellColumn = sheet.findCell(colonna, 3, 11, MAX_COLUMNS, 11, false); // cerco da D12 (3,11) a {MAX_COLUMNS}12
|
||||
|
||||
if(cellRow != null && cellColumn != null){
|
||||
cella = sheet.getWritableCell(cellColumn.getColumn(), cellRow.getRow());
|
||||
num = new jxl.write.Number(cellColumn.getColumn(), cellRow.getRow(), Double.parseDouble(valore.replaceAll(",",".")));
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2017 C09 Report AGCOM migrato a formato XLSX per superamento 256 colonne con ILIAD
|
||||
* @see xPopola_9
|
||||
*/
|
||||
private void popola_9(WritableSheet sheet, String[] risultato) {
|
||||
try{
|
||||
String colonna, riga, valore = "";
|
||||
Cell cellRow, cellColumn = null;
|
||||
WritableCell cella = null;
|
||||
jxl.write.Number num = null;
|
||||
|
||||
if(risultato != null && risultato.length > 0){
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
if(!risultato[i].trim().equals("")){
|
||||
colonna = (risultato[i].split(";")[0] == null) ? "" : risultato[i].split(";")[0].trim();
|
||||
colonna += (risultato[i].split(";")[1] == null) ? "" : " " + risultato[i].split(";")[1].trim();
|
||||
riga = (risultato[i].split(";")[2] == null) ? "" : risultato[i].split(";")[2].trim();
|
||||
valore = (risultato[i].split(";")[3] == null) ? "" : risultato[i].split(";")[3].trim();
|
||||
|
||||
cellColumn = sheet.findCell(colonna, MAX_COLUMNS+1, 12, MAX_COLUMNS+1, 60, false);
|
||||
cellRow = sheet.findCell(riga, 3, 11, MAX_COLUMNS, 11, false); // cerco da D12 (3,11) a {MAX_COLUMNS}12 ( {MAX_COLUMNS}, 11)
|
||||
|
||||
if(cellRow != null && cellColumn != null){
|
||||
cella = sheet.getWritableCell(cellRow.getColumn(), cellColumn.getRow());
|
||||
num = new jxl.write.Number(cellRow.getColumn(), cellColumn.getRow(), Double.parseDouble(valore.replaceAll(",",".")));
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}
|
||||
|
||||
removeLabel("9",sheet); //rimuove le label nella colonna DZ presenti nel template
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2017 C09 Report AGCOM migrato a formato XLSX per superamento 256 colonne con ILIAD
|
||||
* @see xPopola_3R_3D_4R_4D
|
||||
*/
|
||||
private void popola_3R_3D_4R_4D(WritableSheet sheet, String[] risultato) {
|
||||
try{
|
||||
String colonna, riga, valore = "";
|
||||
Cell cellRow, cellColumn = null;
|
||||
WritableCell cella = null;
|
||||
jxl.write.Number num = null;
|
||||
|
||||
if(risultato != null && risultato.length > 0){
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
if(!risultato[i].trim().equals("")){
|
||||
colonna = (risultato[i].split(";")[0] == null) ? "" : risultato[i].split(";")[0].trim();
|
||||
riga = (risultato[i].split(";")[1] == null) ? "" : risultato[i].split(";")[1].trim();
|
||||
valore = (risultato[i].split(";")[2] == null) ? "" : risultato[i].split(";")[2].trim();
|
||||
|
||||
cellColumn = sheet.findCell(colonna, MAX_COLUMNS+1, 12, MAX_COLUMNS+1, 45, false);
|
||||
cellRow = sheet.findCell(riga, 3, 11, MAX_COLUMNS, 11, false);
|
||||
|
||||
if(cellRow != null && cellColumn != null){
|
||||
cella = sheet.getWritableCell(cellRow.getColumn(), cellColumn.getRow());
|
||||
num = new jxl.write.Number(cellRow.getColumn(), cellColumn.getRow(), Double.parseDouble(valore.replaceAll(",",".")));
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}
|
||||
|
||||
removeLabel("3_4",sheet); //rimuove le label nella colonna DZ presenti nel template
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2017 C09 Report AGCOM migrato a formato XLSX per superamento 256 colonne con ILIAD
|
||||
* @see xPopola_8
|
||||
*/
|
||||
private void popola_8(WritableSheet sheet, String[] risultato, String tipoReport) {
|
||||
try{
|
||||
String colonna, valore = "";
|
||||
Cell cellColumn = null;
|
||||
int cellRow = 0;
|
||||
WritableCell cella = null;
|
||||
jxl.write.Number num = null;
|
||||
|
||||
if(risultato != null && risultato.length > 0){
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
if(!risultato[i].trim().equals("")){
|
||||
colonna = (risultato[i].split(";")[0] == null) ? "" : risultato[i].split(";")[0].trim();
|
||||
valore = (risultato[i].split(";")[1] == null) ? "" : risultato[i].split(";")[1].trim();
|
||||
|
||||
cellColumn = sheet.findCell(colonna, 3, 18, MAX_COLUMNS, 18, false);
|
||||
if(tipoReport.equalsIgnoreCase("8R_1"))
|
||||
cellRow = 12;
|
||||
else if(tipoReport.equalsIgnoreCase("8R_2"))
|
||||
cellRow = 13;
|
||||
else
|
||||
cellRow = 14;
|
||||
|
||||
if(cellColumn != null){
|
||||
cella = sheet.getWritableCell(cellColumn.getColumn(), cellRow);
|
||||
num = new jxl.write.Number(cellColumn.getColumn(), cellRow, Double.parseDouble(valore.replaceAll(",",".")));
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}
|
||||
|
||||
//se sono nel report 8r_3rimuove le label nella riga 19 presenti nel template
|
||||
if(tipoReport.equals("8R_3")){
|
||||
removeLabel("8",sheet);
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metodo per eliminare le label presenti nel template
|
||||
* (colonna DZ x schede 3r,3d,4r,4d,9r,9d - riga 19 x scheda 8r)
|
||||
* @param scheda
|
||||
* @param sheet
|
||||
* @deprecated 2017 C09 Report AGCOM migrato a formato XLSX per superamento 256 colonne con ILIAD
|
||||
* @see xRemoveLabel
|
||||
*/
|
||||
private void removeLabel(String scheda, WritableSheet sheet) {
|
||||
try {
|
||||
Label label = null;
|
||||
|
||||
if(scheda.equals("9")){
|
||||
for(int i=12; i<54;i++){
|
||||
label = new Label(MAX_COLUMNS+1,i, ""); // rimuove l'ultima colonna dal template
|
||||
sheet.addCell(label);
|
||||
}
|
||||
}
|
||||
else if(scheda.equals("3_4")){
|
||||
for(int i=12; i<39;i++){
|
||||
label = new Label(MAX_COLUMNS+1,i, ""); // rimuove l'ultima colonna dal template
|
||||
sheet.addCell(label);
|
||||
}
|
||||
}
|
||||
else if(scheda.equals("8")){
|
||||
for(int i=3; i<MAX_COLUMNS+1;i++){
|
||||
label = new Label(i,18, ""); // Rimuove l'ultima riga (quella con gli acronimi degli operatori)
|
||||
sheet.addCell(label);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Errore nella rimozione delle label scheda: "+ scheda);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2017 C09 Report AGCOM migrato a formato XLSX per superamento 256 colonne con ILIAD
|
||||
* @see xPopolaDatiGenerali
|
||||
*/
|
||||
private void popolaDatiGenerali(WritableSheet sheet, String[] risultato){
|
||||
try{
|
||||
String[] valore = new String[risultato.length];
|
||||
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
valore[i] = (risultato[i].split(";")[1] == null) ? "" : risultato[i].split(";")[1];
|
||||
}
|
||||
|
||||
WritableCell cella = sheet.getWritableCell(1, 1);
|
||||
|
||||
/* Commentato il 09/01/2015. Nella cella B2, lascio il valore preimpostato nel template
|
||||
Label label = new Label(1, 1, valore[0].replaceAll(",","."));
|
||||
label.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(label);*/
|
||||
|
||||
Label label = new Label(1, 2, valore[1].replaceAll(",","."));
|
||||
cella = sheet.getWritableCell(1, 2);
|
||||
label.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(label);
|
||||
|
||||
jxl.write.Number num = new jxl.write.Number(1, 3, Double.parseDouble(valore[2].replaceAll(",",".")));
|
||||
cella = sheet.getWritableCell(1, 3);
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
|
||||
num = new jxl.write.Number(1, 4, Double.parseDouble(valore[3].replaceAll(",",".")));
|
||||
cella = sheet.getWritableCell(1, 4);
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
|
||||
num = new jxl.write.Number(1, 5, Double.parseDouble(valore[4].replaceAll(",",".")));
|
||||
cella = sheet.getWritableCell(1, 5);
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
|
||||
num = new jxl.write.Number(1, 6, Double.parseDouble(valore[5].replaceAll(",",".")));
|
||||
cella = sheet.getWritableCell(1, 6);
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
|
||||
num = new jxl.write.Number(1, 7, Double.parseDouble(valore[6].replaceAll(",",".")));
|
||||
cella = sheet.getWritableCell(1, 7);
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
|
||||
num = new jxl.write.Number(1, 8, Double.parseDouble(valore[7].replaceAll(",",".")));
|
||||
cella = sheet.getWritableCell(1, 8);
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
|
||||
num = new jxl.write.Number(1, 11, Double.parseDouble(valore[8].replaceAll(",",".")));
|
||||
cella = sheet.getWritableCell(1, 11);
|
||||
num.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(num);
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void xPopola_1R_2R_5T_5S_5A_6_7(XSSFSheet sheet, String[] risultato) {
|
||||
String methSig = "[xPopola_1R_2R_5T_5S_5A_6_7] ";
|
||||
try{
|
||||
log.debug(methSig + "BEGIN");
|
||||
|
||||
String colonna, riga, valore = "";
|
||||
XSSFCell cellRow, cellColumn = null;
|
||||
XSSFCell cella = null;
|
||||
|
||||
if(risultato != null && risultato.length > 0){
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
if(null == risultato[i] || "".equals(risultato[i].trim())) {
|
||||
log.debug(methSig + "elemento ["+i+"] non valorizzato");
|
||||
} else {
|
||||
log.debug(methSig + "elemento ["+i+"] = ["+risultato[i]+"]");
|
||||
colonna = (risultato[i].split(";")[0] == null) ? "" : risultato[i].split(";")[0].trim();
|
||||
riga = (risultato[i].split(";")[1] == null) ? "" : risultato[i].split(";")[1].trim();
|
||||
valore = (risultato[i].split(";")[2] == null) ? "" : risultato[i].split(";")[2].trim();
|
||||
|
||||
cellRow = findCell(sheet, riga, 1, 13, 1, MAX_ROWS, false); // cerco da B14 (1,13) a B{MAX_ROWS+1} (1, {MAX_ROWS})
|
||||
cellColumn = findCell(sheet, colonna, 3, 11, MAX_COLUMNS, 11, false); // cerco da D12 (3,11) a {MAX_COLUMNS}12
|
||||
|
||||
if(cellRow != null && cellColumn != null){
|
||||
int cellColIndex = cellColumn.getColumnIndex();
|
||||
int cellRowIndex = cellRow.getRowIndex();
|
||||
cella = sheet.getRow(cellRowIndex).getCell(cellColIndex);
|
||||
//XSSFCellStyle style = cella.getCellStyle();
|
||||
cella.setCellValue(Double.parseDouble(valore.replaceAll(",",".")));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// MNP_SM_2358 richiesto di posizionare il cursore in A1 all'apertura del foglio
|
||||
cella = sheet.getRow(0).getCell(0);
|
||||
}
|
||||
else{
|
||||
log.debug(methSig + "Nessun elemento trovato per il foglio");
|
||||
}
|
||||
log.debug(methSig + "END");
|
||||
}catch(Exception e){
|
||||
log.error(methSig + "FAIL: " + e);
|
||||
////e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void xPopola_9(XSSFSheet sheet, String[] risultato) {
|
||||
try{
|
||||
log.debug("xPopola_9");
|
||||
|
||||
String testataRiga, testataColonna, valore = "";
|
||||
XSSFCell cellaTestataColonna, cellaTestataRiga = null;
|
||||
XSSFCell cella = null;
|
||||
|
||||
if(risultato != null && risultato.length > 0){
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
if(!risultato[i].trim().equals("")){
|
||||
testataRiga = (risultato[i].split(";")[0] == null) ? "" : risultato[i].split(";")[0].trim();
|
||||
testataRiga += (risultato[i].split(";")[1] == null) ? "" : " " + risultato[i].split(";")[1].trim();
|
||||
testataColonna = (risultato[i].split(";")[2] == null) ? "" : risultato[i].split(";")[2].trim();
|
||||
valore = (risultato[i].split(";")[3] == null) ? "" : risultato[i].split(";")[3].trim();
|
||||
|
||||
// cerca nella post-ultima colonna l'etichetta di interesse e legge l'indice della RIGA
|
||||
cellaTestataRiga = findCell(sheet, testataRiga, MAX_COLUMNS+1, 12, MAX_COLUMNS+1, 60, false);
|
||||
// cerca nella 12a riga l'etichetta di interesse e legge l'indice della COLONNA
|
||||
cellaTestataColonna = findCell(sheet, testataColonna, 3, 11, MAX_COLUMNS, 11, false); // cerco da D12 (3,11) a {MAX_COLUMNS}12 ( {MAX_COLUMNS}, 11)
|
||||
//log.debug("cellaTestataColonna ["+(null==cellaTestataColonna?"NULL":"NOT null")+"]; cellaTestataRiga ["+(null==cellaTestataRiga?"NULL":"NOT null")+"]");
|
||||
|
||||
// scrive il valore nella cella all'incrocio di riga e colonna trovate
|
||||
if(cellaTestataColonna != null && cellaTestataRiga != null){
|
||||
int cellColIndex = cellaTestataColonna.getColumnIndex();
|
||||
int cellRowIndex = cellaTestataRiga.getRowIndex();
|
||||
cella = sheet.getRow(cellRowIndex).getCell(cellColIndex);
|
||||
cella.setCellValue(Double.parseDouble(valore.replaceAll(",",".")));
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}
|
||||
|
||||
xRemoveLabel("9", sheet); //rimuove le label nella colonna DZ presenti nel template
|
||||
// MNP_SM_2358 richiesto di posizionare il cursore in A1 all'apertura del foglio
|
||||
cella = sheet.getRow(0).getCell(0);
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void xPopola_3R_3D_4R_4D(XSSFSheet sheet, String[] risultato) {
|
||||
try{
|
||||
log.debug("xPopola_3R_3D_4R_4D");
|
||||
|
||||
String colonna, riga, valore = "";
|
||||
XSSFCell cellRow, cellColumn = null;
|
||||
XSSFCell cella = null;
|
||||
|
||||
if(risultato != null && risultato.length > 0){
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
if(!risultato[i].trim().equals("")){
|
||||
colonna = (risultato[i].split(";")[0] == null) ? "" : risultato[i].split(";")[0].trim();
|
||||
riga = (risultato[i].split(";")[1] == null) ? "" : risultato[i].split(";")[1].trim();
|
||||
valore = (risultato[i].split(";")[2] == null) ? "" : risultato[i].split(";")[2].trim();
|
||||
|
||||
cellColumn = findCell(sheet, colonna, MAX_COLUMNS + 1, 12, MAX_COLUMNS + 1, 45, false);
|
||||
cellRow = findCell(sheet, riga, 3, 11, MAX_COLUMNS, 11, false);
|
||||
|
||||
if(cellRow != null && cellColumn != null){
|
||||
int cellColIndex = cellRow.getColumnIndex();
|
||||
int cellRowIndex = cellColumn.getRowIndex();
|
||||
//String value = valore.replaceAll(",", ".");
|
||||
Double value = Double.parseDouble(valore.replaceAll(",","."));
|
||||
XSSFRow row = sheet.getRow(cellRowIndex);
|
||||
cella = row.getCell(cellColIndex);
|
||||
//XSSFCellStyle style = cella.getCellStyle();
|
||||
cella.setCellValue(value);
|
||||
//cella.setCellStyle(style);
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato in risultato["+i+"]");
|
||||
}
|
||||
}
|
||||
xRemoveLabel("3_4", sheet); //rimuove le label nella colonna DZ presenti nel template
|
||||
// MNP_SM_2358 richiesto di posizionare il cursore in A1 all'apertura del foglio
|
||||
cella = sheet.getRow(0).getCell(0);
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato");
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void xPopola_8(XSSFSheet sheet, String[] risultato, String tipoReport) {
|
||||
try{
|
||||
log.debug("xPopola_8");
|
||||
|
||||
String colonna, valore = "";
|
||||
int cellRowIndex = 0;
|
||||
XSSFCell cellColumn = null;
|
||||
XSSFCell cella = null;
|
||||
|
||||
if(risultato != null && risultato.length > 0){
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
if(!risultato[i].trim().equals("")){
|
||||
colonna = (risultato[i].split(";")[0] == null) ? "" : risultato[i].split(";")[0].trim();
|
||||
valore = (risultato[i].split(";")[1] == null) ? "" : risultato[i].split(";")[1].trim();
|
||||
|
||||
cellColumn = findCell(sheet, colonna, 3, 18, MAX_COLUMNS, 18, false);
|
||||
if(tipoReport.equalsIgnoreCase("8R_1"))
|
||||
cellRowIndex = 12;
|
||||
else if(tipoReport.equalsIgnoreCase("8R_2"))
|
||||
cellRowIndex = 13;
|
||||
else
|
||||
cellRowIndex = 14;
|
||||
|
||||
if(cellColumn != null){
|
||||
int cellColIndex = cellColumn.getColumnIndex();
|
||||
cella = sheet.getRow(cellRowIndex).getCell(cellColIndex);
|
||||
cella.setCellValue(Double.parseDouble(valore.replaceAll(",",".")));
|
||||
}
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato in risultato["+i+"]");
|
||||
}
|
||||
}
|
||||
|
||||
//se sono nel report 8r_3rimuove le label nella riga 19 presenti nel template
|
||||
if(tipoReport.equals("8R_3")){
|
||||
xRemoveLabel("8", sheet);
|
||||
}
|
||||
// MNP_SM_2358 richiesto di posizionare il cursore in A1 all'apertura del foglio
|
||||
cella = sheet.getRow(0).getCell(0);
|
||||
}
|
||||
else{
|
||||
log.debug("Nessun elemento trovato.");
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metodo per eliminare le label presenti nel template
|
||||
* (colonna DZ x schede 3r,3d,4r,4d,9r,9d - riga 19 x scheda 8r)
|
||||
* @param scheda
|
||||
* @param sheet
|
||||
*/
|
||||
private void xRemoveLabel(String scheda, XSSFSheet sheet) {
|
||||
try {
|
||||
log.debug("xRemoveLabel");
|
||||
|
||||
if(scheda.equals("9")){
|
||||
//le schede 9 hanno righe nascoste per cui alcune celle sono null
|
||||
for(int i=12; i<54;i++){
|
||||
try {
|
||||
XSSFCell cell = sheet.getRow(i).getCell(MAX_COLUMNS + 1); // rimuove l'ultima colonna dal template
|
||||
cell.setCellValue("");
|
||||
}
|
||||
catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(scheda.equals("3_4")){
|
||||
for(int i=12; i<39;i++){
|
||||
XSSFCell cell = sheet.getRow(i).getCell(MAX_COLUMNS+1); // rimuove l'ultima colonna dal template
|
||||
cell.setCellValue("");
|
||||
}
|
||||
}
|
||||
|
||||
else if(scheda.equals("8")){
|
||||
for(int i=3; i<MAX_COLUMNS+1;i++){
|
||||
XSSFCell cell = sheet.getRow(18).getCell(i); // Rimuove l'ultima riga (quella con gli acronimi degli operatori)
|
||||
cell.setCellValue("");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Errore nella rimozione delle label scheda: "+ scheda);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void xPopolaDatiGenerali(XSSFSheet sheet, String[] risultato){
|
||||
try{
|
||||
log.debug("xPopolaDatiGenerali");
|
||||
String[] valore = new String[risultato.length];
|
||||
|
||||
for(int i=0; i<risultato.length;i++){
|
||||
valore[i] = (risultato[i].split(";")[1] == null) ? "" : risultato[i].split(";")[1];
|
||||
log.debug("i: " + i + " - valore["+valore[i]+"]");
|
||||
}
|
||||
|
||||
log.debug("risultato.lenght: " + risultato.length);
|
||||
|
||||
log.debug("sheet is"+ ( null == sheet ? "" : " not" ) +" null");
|
||||
|
||||
/* Commentato il 09/01/2015. Nella cella B2, lascio il valore preimpostato nel template
|
||||
Label label = new Label(1, 1, valore[0].replaceAll(",","."));
|
||||
label.setCellFormat(cella.getCellFormat());
|
||||
sheet.addCell(label);*/
|
||||
|
||||
log.debug("cell declaration");
|
||||
XSSFCell cell;
|
||||
|
||||
cell = sheet.getRow(2).getCell(1);
|
||||
String value = valore[1].replaceAll(",", ".");
|
||||
log.debug("value: " + value);
|
||||
cell.setCellValue(value);
|
||||
|
||||
cell = sheet.getRow(3).getCell(1);
|
||||
value = valore[2].replaceAll(",",".");
|
||||
log.debug("value: " + value);
|
||||
cell.setCellValue(Double.parseDouble(value));
|
||||
|
||||
cell = sheet.getRow(4).getCell(1);
|
||||
value = valore[3].replaceAll(",",".");
|
||||
log.debug("value: " + value);
|
||||
cell.setCellValue(Double.parseDouble(value));
|
||||
|
||||
cell = sheet.getRow(5).getCell(1);
|
||||
value = valore[4].replaceAll(",", ".");
|
||||
log.debug("value: " + value);
|
||||
cell.setCellValue(Double.parseDouble(value));
|
||||
|
||||
cell = sheet.getRow(6).getCell(1);
|
||||
value = valore[5].replaceAll(",", ".");
|
||||
log.debug("value: " + value);
|
||||
cell.setCellValue(Double.parseDouble(value));
|
||||
|
||||
cell = sheet.getRow(7).getCell(1);
|
||||
value = valore[6].replaceAll(",", ".");
|
||||
log.debug("value: " + value);
|
||||
cell.setCellValue(Double.parseDouble(value));
|
||||
|
||||
// MNP_SM_2352 20180105 "Numero di giorni di manutenzione programmata nel mese di riferimento"
|
||||
// valorizzato non correttamente in Dati Generali (riportava il Numero Giorni Lavorativi)
|
||||
cell = sheet.getRow(8).getCell(1);
|
||||
value = valore[7].replaceAll(",", ".");
|
||||
//value = valore[6].replaceAll(",", ".");
|
||||
log.debug("value: " + value);
|
||||
cell.setCellValue(Double.parseDouble(value));
|
||||
|
||||
cell = sheet.getRow(11).getCell(1);
|
||||
value = valore[8].replaceAll(",", ".");
|
||||
log.debug("value: " + value);
|
||||
cell.setCellValue(Double.parseDouble(value));
|
||||
|
||||
}catch(Exception e){
|
||||
log.error(e);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private int getTipoReport(String tipo) {
|
||||
return Integer.parseInt(mappaTipoReport.get(tipo).toString());
|
||||
}
|
||||
|
||||
private void inizializzaMappa() {
|
||||
mappaTipoReport = new HashMap();
|
||||
|
||||
mappaTipoReport.put("DatiG", "0");
|
||||
mappaTipoReport.put("1R", "2");
|
||||
mappaTipoReport.put("2R", "3");
|
||||
mappaTipoReport.put("3R", "4");
|
||||
mappaTipoReport.put("3D", "5");
|
||||
mappaTipoReport.put("4R", "6");
|
||||
mappaTipoReport.put("4D", "7");
|
||||
mappaTipoReport.put("5T", "8");
|
||||
mappaTipoReport.put("5S", "9");
|
||||
mappaTipoReport.put("5A", "10");
|
||||
mappaTipoReport.put("6", "11");
|
||||
mappaTipoReport.put("7", "12");
|
||||
mappaTipoReport.put("8R_1", "13");
|
||||
mappaTipoReport.put("8R_2", "13");
|
||||
mappaTipoReport.put("8R_3", "13");
|
||||
mappaTipoReport.put("9R", "14");
|
||||
mappaTipoReport.put("9D", "15");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ricerca per righe
|
||||
* @param sheet lo sheet su cui cercare
|
||||
* @param contents la stringa da cercare
|
||||
* @param upperLeftColIdx indice colonna dell'angolo in alto a sinistra, partendo da 0
|
||||
* @param lowerRightColIdx indice della colonna dell'angolo in basso a destra, partendo da 0
|
||||
* @param upperLeftRowIdx indice della riga dell'angolo in alto a sinistra, partendo da 0
|
||||
* @param lowerRightRowIdx indice della riga dell'angolo in basso a destra, partendo da 0
|
||||
* @param debug se true scrive sul log i parametri con cui e' stato invocato il metodo
|
||||
* @return la cella il cui valore e' uguale a @contents
|
||||
*/
|
||||
private XSSFCell findCell(XSSFSheet sheet, String contents, int upperLeftColIdx, int upperLeftRowIdx, int lowerRightColIdx, int lowerRightRowIdx, boolean debug) {
|
||||
if (debug) {
|
||||
log.debug("findCell - contents= [" + contents + "] - upperLeftColIdx = [" + upperLeftColIdx + "] - upperLeftRowIdx = [" + upperLeftRowIdx + "] - lowerRightColIdx = [" + lowerRightColIdx + "] - lowerRightRowIdx = [" + lowerRightRowIdx + "]");
|
||||
}
|
||||
|
||||
try {
|
||||
for (int rowInd = upperLeftRowIdx; rowInd <= lowerRightRowIdx; rowInd++) {
|
||||
XSSFRow row = sheet.getRow(rowInd);
|
||||
for (int colInd = upperLeftColIdx; colInd <= lowerRightColIdx; colInd++) {
|
||||
XSSFCell cell = row.getCell(colInd);
|
||||
|
||||
if (cell == null) {
|
||||
//le schede 9 hanno righe nascoste per cui alcune celle sono null, in tal caso ignora
|
||||
continue;
|
||||
}
|
||||
org.apache.poi.ss.usermodel.CellType type = cell.getCellTypeEnum();
|
||||
|
||||
//log.debug("cell rerefence: " + cell.getReference());
|
||||
|
||||
if (debug) {
|
||||
log.debug("cell.getStringCellValue() "+cell.getStringCellValue());
|
||||
}else {
|
||||
System.out.println("colInd "+ colInd +" cell.getStringCellValue() "+cell.getStringCellValue());
|
||||
}
|
||||
|
||||
//NUMERIC, STRING, FORMULA, ERROR, BOOLEAN
|
||||
switch (type) {
|
||||
case STRING:
|
||||
if (contents.equals(cell.getStringCellValue())) {
|
||||
//log.debug("string cell found");
|
||||
return cell;
|
||||
}
|
||||
else break; //esce dallo switch non dal for
|
||||
default:
|
||||
//log.debug("nothing found - type: " + type.toString());
|
||||
break; //esce dallo switch non dal for
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.dao.report.CapacitaEvasione;
|
||||
import it.valueteam.dbcgo.dao.report.CapacitaEvasioneDAO;
|
||||
import it.valueteam.dbcgo.utility.agcom.CapacitaEvasioneExcelUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class ReportCapacitaEvasioneBusiness {
|
||||
static Logger log = Logger.getLogger(ReportCapacitaEvasioneBusiness.class.getName());
|
||||
|
||||
private CapacitaEvasione ceBean;
|
||||
private CapacitaEvasioneExcelUtils ceUtils;
|
||||
|
||||
public ReportCapacitaEvasioneBusiness() {}
|
||||
|
||||
public byte[] getRequestedFile() {
|
||||
byte[] excel = null;
|
||||
CapacitaEvasioneDAO dao = null;
|
||||
try {
|
||||
ceBean = new CapacitaEvasione();
|
||||
ceUtils = new CapacitaEvasioneExcelUtils();
|
||||
|
||||
dao = new CapacitaEvasioneDAO();
|
||||
List list = dao.loadReportItems();
|
||||
|
||||
if(list == null || list.size() < 2){
|
||||
return null;
|
||||
}
|
||||
|
||||
ceBean.setBean1((CapacitaEvasione) list.get(0));
|
||||
ceBean.setBean2((CapacitaEvasione) list.get(1));
|
||||
|
||||
excel = ceUtils.generaExcel(ceBean);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
return excel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.MnpDwSlaFranchigiaOutViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.MnpDwSlaTcOutViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.MnpDwSla3ggOutViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.MnpDwSla3ggOutView;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.RestrictionBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class ReportFranchigiaBusiness {
|
||||
static Logger log = Logger.getLogger(ReportFranchigiaBusiness.class.getName());
|
||||
public List criterion;
|
||||
public MnpDwSlaFranchigiaOutViewDAO viewDAO;
|
||||
|
||||
public ReportFranchigiaBusiness () {
|
||||
viewDAO = new MnpDwSlaFranchigiaOutViewDAO();
|
||||
}
|
||||
|
||||
public void instanceCriteria(Map _map){
|
||||
DynaWorkForm dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
}
|
||||
public List eseguiRicerca () {
|
||||
return (List)viewDAO.findByCriteria(criterion);
|
||||
}
|
||||
|
||||
public List eseguiRicerca (int start, int range) {
|
||||
log.info("ReportFranchigiaBusiness.eseguiRicerca("+start+","+range+") criterion.size()="+criterion.size());
|
||||
return (List)viewDAO.findByCriteriaRange(criterion,start,range);
|
||||
}
|
||||
|
||||
|
||||
public int count () {
|
||||
int retC=viewDAO.findByCriteriaCount(criterion);
|
||||
return retC;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.MnpDwSlaTcOutViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.MnpDwSla3ggOutViewDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.MnpDwSla3ggOutView;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.RestrictionBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class ReportPenaliBusiness {
|
||||
static Logger log = Logger.getLogger(ReportPenaliBusiness.class.getName());
|
||||
public List criterion;
|
||||
public MnpDwSlaTcOutViewDAO mnpDwSlaTcOutViewDAO;
|
||||
public MnpDwSla3ggOutViewDAO mnpDwSla3ggOutViewDAO;
|
||||
public ReportPenaliBusiness () {
|
||||
mnpDwSlaTcOutViewDAO = new MnpDwSlaTcOutViewDAO();
|
||||
mnpDwSla3ggOutViewDAO = new MnpDwSla3ggOutViewDAO();
|
||||
}
|
||||
|
||||
public void instanceCriteria(Map _map){
|
||||
DynaWorkForm dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
}
|
||||
public List eseguiRicerca () {
|
||||
return (List)mnpDwSlaTcOutViewDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
public List eseguiRicerca (int start, int range) {
|
||||
log.info("ReportPenaliBusiness.eseguiRicerca("+start+","+range+")");
|
||||
return (List)mnpDwSlaTcOutViewDAO.findByCriteriaRange(getCriterion(),start,range);
|
||||
//return (List)mnpDwSlaTcOutViewDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
//1603
|
||||
public List eseguiRicercaAll (int start, int range) {
|
||||
log.info("ReportPenaliBusiness.eseguiRicercaAll("+start+","+range+")");
|
||||
List sla3gg = mnpDwSla3ggOutViewDAO.findByCriteria(getCriterion());
|
||||
List slaTC = mnpDwSlaTcOutViewDAO.findByCriteria(getCriterion());
|
||||
|
||||
sla3gg.addAll(slaTC);
|
||||
|
||||
int fromIndex = start;
|
||||
int sizeMax = sla3gg.size();
|
||||
int toIndex = start + range;
|
||||
|
||||
if (toIndex>sizeMax){
|
||||
toIndex = sizeMax;
|
||||
}
|
||||
|
||||
List subList = sla3gg.subList(fromIndex, toIndex);
|
||||
return subList;
|
||||
}//end
|
||||
|
||||
public List eseguiRicercaAll () {
|
||||
log.info("ReportPenaliBusiness.eseguiRicercaAll()");
|
||||
List sla3gg = mnpDwSla3ggOutViewDAO.findByCriteria(getCriterion());
|
||||
List slaTC = mnpDwSlaTcOutViewDAO.findByCriteria(getCriterion());
|
||||
|
||||
sla3gg.addAll(slaTC);
|
||||
return sla3gg;
|
||||
}//end
|
||||
|
||||
public List eseguiRicercaSLA3GG(int start, int range) {
|
||||
log.info("ReportPenaliBusiness.eseguiRicercaSLA3GG("+start+","+range+")");
|
||||
List sla3gg = mnpDwSla3ggOutViewDAO.findByCriteriaRange(getCriterion(),start,range);
|
||||
for(int i=0;i<sla3gg.size();i++){
|
||||
MnpDwSla3ggOutView elemento=(MnpDwSla3ggOutView) sla3gg.get(i);
|
||||
log.info("elemento "+(i+1)+" di "+sla3gg.size());
|
||||
log.info("codice rich recipient"+elemento.getCodiceRichiestaRecipient());
|
||||
log.info("nome file"+elemento.getNomeFile());
|
||||
log.info("giorni rit"+elemento.getNumeroGiorniRitardo());
|
||||
}
|
||||
//List sla3gg = mnpDwSla3ggOutViewDAO.findByCriteria(getCriterion());
|
||||
|
||||
return sla3gg;
|
||||
}//end
|
||||
|
||||
public List eseguiRicercaSLA3GG() {
|
||||
log.info("ReportPenaliBusiness.eseguiRicercaSLA3GG()");
|
||||
List sla3gg = mnpDwSla3ggOutViewDAO.findByCriteria(getCriterion());
|
||||
//List sla3gg = mnpDwSla3ggOutViewDAO.findByCriteria(getCriterion());
|
||||
|
||||
return sla3gg;
|
||||
}//end
|
||||
|
||||
public int countSLA3GG () {
|
||||
log.info("ReportPenaliBusiness.countSLA3GG()");
|
||||
int retC=mnpDwSla3ggOutViewDAO.findByCriteriaCount(getCriterion());
|
||||
log.info("ReportPenaliBusiness.countSLA3GG() return "+retC);
|
||||
return retC;
|
||||
}
|
||||
|
||||
public int countAll () {
|
||||
log.info("ReportPenaliBusiness.countAll()");
|
||||
int count = mnpDwSla3ggOutViewDAO.findByCriteriaCount(getCriterion());
|
||||
count = count + mnpDwSlaTcOutViewDAO.findByCriteriaCount(getCriterion());
|
||||
log.info("ReportPenaliBusiness.countAll() return "+count);
|
||||
return count;
|
||||
}
|
||||
//1603
|
||||
public int count () {
|
||||
log.info("ReportPenaliBusiness.count()");
|
||||
int retC=mnpDwSlaTcOutViewDAO.findByCriteriaCount(getCriterion());
|
||||
log.info("ReportPenaliBusiness.count() return "+retC);
|
||||
return retC;
|
||||
}
|
||||
|
||||
public List getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
public void setCriterion(List criterion) {
|
||||
this.criterion = criterion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.MnpDwReportTcrDAO;
|
||||
import it.valueteam.dbcgo.hb.dao.MnpDwReportTcrDonorDAO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ReportTcrBusiness {
|
||||
static Logger log = Logger.getLogger(ReportTcrBusiness.class.getName());
|
||||
|
||||
private MnpDwReportTcrDAO mnpDwReportTcrDAO;
|
||||
private MnpDwReportTcrDonorDAO mnpDwReportTcrDonorDAO;
|
||||
|
||||
private ArrayList criterion;
|
||||
private static final String C_DONOR_EFFETTIVO = "id.codiceOperatoreDonEff";
|
||||
private static final String C_RECIPIENT_EFFETTIVO = "id.codiceOperatoreRecEff";
|
||||
private static final String C_DATA_RIFERIMENTO = "dataDiRiferimento";
|
||||
private static final String C_BLOCCO = "blocco";
|
||||
private static final String C_CAR_LINEA = "codicePrePostPagato";
|
||||
private static final String C_MSISDN = "msisdn";
|
||||
|
||||
public ReportTcrBusiness() {
|
||||
mnpDwReportTcrDAO = new MnpDwReportTcrDAO();
|
||||
mnpDwReportTcrDonorDAO = new MnpDwReportTcrDonorDAO();
|
||||
criterion = new ArrayList();
|
||||
}
|
||||
|
||||
public void createCriteriaRecipient(String operatoreDonor, Date dataInizio, Date dataFine, int tipologiaTcr, int carLinea, String msisdn, String[] aoms) {
|
||||
// chiave obbligatoria, nessun controllo
|
||||
if (operatoreDonor != null && !operatoreDonor.trim().equals("")) {
|
||||
criterion.add(Restrictions.eq(C_DONOR_EFFETTIVO, operatoreDonor));
|
||||
} /*else {
|
||||
criterion.add(Restrictions.in(C_DONOR_EFFETTIVO, aoms));
|
||||
}*/
|
||||
criterion.add(Restrictions.eq(C_RECIPIENT_EFFETTIVO, "TIMG"));
|
||||
// chiave obbligatoria, nessun controllo
|
||||
criterion.add(Restrictions.between(C_DATA_RIFERIMENTO, dataInizio, dataFine));
|
||||
|
||||
switch (tipologiaTcr) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
criterion.add(Restrictions.ne(C_BLOCCO, new Long(0)));
|
||||
break;
|
||||
case 2:
|
||||
criterion.add(Restrictions.eq(C_BLOCCO, new Long(0)));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (carLinea) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
criterion.add(Restrictions.eq(C_CAR_LINEA, "POP"));
|
||||
break;
|
||||
case 2:
|
||||
criterion.add(Restrictions.eq(C_CAR_LINEA, "PRP"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (msisdn != null && !msisdn.trim().equals("")) {
|
||||
criterion.add(Restrictions.eq(C_MSISDN, msisdn));
|
||||
}
|
||||
}
|
||||
|
||||
public void createCriteriaDonor(String operatoreRecipient, Date dataInizio, Date dataFine, int tipologiaTcr, String msisdn, String[] aoms) {
|
||||
if (operatoreRecipient != null && !operatoreRecipient.trim().equals("")) {
|
||||
criterion.add(Restrictions.eq(C_RECIPIENT_EFFETTIVO, operatoreRecipient));
|
||||
} /*else {
|
||||
criterion.add(Restrictions.in(C_RECIPIENT_EFFETTIVO, aoms));
|
||||
}*/
|
||||
criterion.add(Restrictions.eq(C_DONOR_EFFETTIVO, "TIMG"));
|
||||
// chiave obbligatoria, nessun controllo
|
||||
criterion.add(Restrictions.between(C_DATA_RIFERIMENTO, dataInizio, dataFine));
|
||||
|
||||
switch (tipologiaTcr) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
criterion.add(Restrictions.ne(C_BLOCCO, new Long(0)));
|
||||
break;
|
||||
case 2:
|
||||
criterion.add(Restrictions.eq(C_BLOCCO, new Long(0)));
|
||||
break;
|
||||
}
|
||||
|
||||
if (msisdn != null && !msisdn.trim().equals("")) {
|
||||
criterion.add(Restrictions.eq(C_MSISDN, msisdn));
|
||||
}
|
||||
}
|
||||
|
||||
private List getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
|
||||
public List eseguiRicercaRecipientAll() {
|
||||
return mnpDwReportTcrDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
public List eseguiRicercaRecipient(int start, int range) {
|
||||
return mnpDwReportTcrDAO.findByCriteria(getCriterion(), start, range);
|
||||
}
|
||||
|
||||
public List eseguiRicercaDonorAll() {
|
||||
return mnpDwReportTcrDonorDAO.findByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
public List eseguiRicercaDonor(int start, int range) {
|
||||
return mnpDwReportTcrDonorDAO.findByCriteria(getCriterion(), start, range);
|
||||
}
|
||||
|
||||
public int countRicercaRecipient() {
|
||||
return mnpDwReportTcrDAO.countByCriteria(getCriterion());
|
||||
}
|
||||
|
||||
public int countRicercaDonor() {
|
||||
return mnpDwReportTcrDonorDAO.countByCriteria(getCriterion());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: SeiditaNi
|
||||
* Date: 28/05/12
|
||||
* Time: 16.37
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class StoricoCreazioneFile {
|
||||
|
||||
static Logger log = Logger.getLogger(StoricoCreazioneFile.class.getName());
|
||||
/**
|
||||
* Questa classe fornisce metodi collegati
|
||||
* alla storicizzazione delle azioni di business.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Storico file delle penali
|
||||
* @param nomeFile
|
||||
* @param user
|
||||
* @param timestamp
|
||||
*/
|
||||
public void storicizzaCreazioneFilePenali(String nomeFile,String user, Date timestamp) {
|
||||
log.info("storicizzaCreazioneFilePenali for nomeFile:"+nomeFile+ " user:"+user+" timestamp:"+timestamp);
|
||||
//TODO
|
||||
log.info("exit storicizzaCreazioneFilePenali");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package it.valueteam.dbcgo.business;
|
||||
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoGestioneRicV00DAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoGestioneRicV00;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoVoPrevalidazioneDbcDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoVoPrevalidazioneDbc;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm;
|
||||
import it.valueteam.dbcgo.utility.RestrictionBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
public class UpdateDonorDCOBusiness {
|
||||
static Logger log = Logger.getLogger(UpdateDonorDCOBusiness.class.getName());
|
||||
private List criterion;
|
||||
private DbcgoGestioneRicV00DAO dbcgoGestioneRicV00DAO;
|
||||
private DynaWorkForm dwm;
|
||||
|
||||
public UpdateDonorDCOBusiness () {
|
||||
dbcgoGestioneRicV00DAO = new DbcgoGestioneRicV00DAO();
|
||||
}
|
||||
|
||||
public void instanceCriteria(Map _map){
|
||||
dwm = new DynaWorkForm(_map);
|
||||
dwm.printVect(dwm.workthismap());
|
||||
criterion = new RestrictionBuilder(dwm.getVlist()).getCriteria();
|
||||
}
|
||||
public List eseguiRicerca (int start, int range) {
|
||||
List opcol_lista_dati = new ArrayList();
|
||||
List opcol_lista_dati_uscita = new ArrayList();
|
||||
opcol_lista_dati = (List)dbcgoGestioneRicV00DAO.findByCriteriaRange(getCriterion(),start,range);
|
||||
log.info("opcol_lista_dati.size():" + opcol_lista_dati.size());
|
||||
Iterator it = opcol_lista_dati.iterator();
|
||||
while (it.hasNext()) {
|
||||
DbcgoVoPrevalidazioneDbcDAO dbcgoVoPrevalidazioneDbcDAO = new DbcgoVoPrevalidazioneDbcDAO();
|
||||
DbcgoGestioneRicV00 dbcgoGestioneRicV00 = (DbcgoGestioneRicV00)it.next();
|
||||
String rifiutoValidazione = dbcgoGestioneRicV00.getCodicerifiutovalidazione();
|
||||
if(rifiutoValidazione!=null && !("").equals(rifiutoValidazione.trim())){
|
||||
String[] codiciA = rifiutoValidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ", <br>";;
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestioneRicV00.setCodicerifiutovalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String prevalidazione = dbcgoGestioneRicV00.getPrevalidazione();
|
||||
if(prevalidazione!=null && !("").equals(prevalidazione.trim())){
|
||||
String[] codiciA = prevalidazione.split(";");
|
||||
String decode = "";
|
||||
try {
|
||||
for (int i=0;i<codiciA.length;i++){
|
||||
ArrayList criterion = new ArrayList();
|
||||
criterion.add(Restrictions.eq("value", codiciA[i]));
|
||||
List mylist = dbcgoVoPrevalidazioneDbcDAO.findByCriteria(criterion);
|
||||
if(mylist.size()>0 && i!=(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel() +", <br>";
|
||||
} else if(mylist.size()>0 && i==(codiciA.length-1)){
|
||||
decode = decode + ((DbcgoVoPrevalidazioneDbc) (mylist).get(0)).getLabel()+ ".";;
|
||||
} else if(mylist.size()==0) {
|
||||
decode = decode + " " + codiciA[i] + " ";
|
||||
}
|
||||
}
|
||||
dbcgoGestioneRicV00.setPrevalidazione(decode);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
opcol_lista_dati_uscita.add(dbcgoGestioneRicV00);
|
||||
}
|
||||
|
||||
log.info("Record trovati" + opcol_lista_dati.size());
|
||||
log.info("Record trovati dopo decode" + opcol_lista_dati_uscita.size());
|
||||
return opcol_lista_dati;
|
||||
}
|
||||
|
||||
public List searchGroup(){
|
||||
List _results = dbcgoGestioneRicV00DAO.findByCriteriaByGroup(getCriterion());
|
||||
List result = new ArrayList();
|
||||
Iterator it = _results.iterator();
|
||||
if (!it.hasNext()) {
|
||||
log.info("Nessun Dato");
|
||||
} else {
|
||||
while (it.hasNext()) {
|
||||
Object[] row = (Object[]) it.next();
|
||||
if (row!=null){
|
||||
String dato = ((Integer)row[1]).toString();
|
||||
//log.info(row[1].getClass());
|
||||
result.add(new InfoDTO((String)row[0],dato));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int count () {
|
||||
return dbcgoGestioneRicV00DAO.findByCriteriaCount(getCriterion());
|
||||
}
|
||||
|
||||
public List getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
public void setCriterion(List criterion) {
|
||||
this.criterion = criterion;
|
||||
}
|
||||
|
||||
public DynaWorkForm getDwm() {
|
||||
return dwm;
|
||||
}
|
||||
|
||||
public void setDwm(DynaWorkForm dwm) {
|
||||
this.dwm = dwm;
|
||||
}
|
||||
|
||||
public class InfoDTO {
|
||||
private String codiceGruppo;
|
||||
private String numeroRichieste;
|
||||
|
||||
public InfoDTO(String _codiceGruppo,String _numeroRichieste){
|
||||
codiceGruppo = _codiceGruppo;
|
||||
numeroRichieste = _numeroRichieste;
|
||||
}
|
||||
|
||||
public String getCodiceGruppo() {
|
||||
return codiceGruppo;
|
||||
}
|
||||
|
||||
public void setCodiceGruppo(String codiceGruppo) {
|
||||
this.codiceGruppo = codiceGruppo;
|
||||
}
|
||||
|
||||
public String getNumeroRichieste() {
|
||||
return numeroRichieste;
|
||||
}
|
||||
|
||||
public void setNumeroRichieste(String numeroRichieste) {
|
||||
this.numeroRichieste = numeroRichieste;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package it.valueteam.dbcgo.business.reportritardi;
|
||||
|
||||
import it.valueteam.dbcgo.business.GenericComboBusiness;
|
||||
import it.valueteam.dbcgo.dto.GenericComboDto;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoRichiesteProcessateDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoReportIndennizziCliente;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoReportIndennizziClienteDownload;
|
||||
import it.valueteam.dbcgo.sync.dto.StatoRichiestaRec;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class ReportIndennizziClienteBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(ReportIndennizziClienteBusiness.class.getName());
|
||||
public DbcgoRichiesteProcessateDAO viewDAO;
|
||||
|
||||
public static final String QUERY_REPORT_INDENNIZZI_CLIENTE =
|
||||
"select * from " +
|
||||
"(select ID_CORRELAZIONE, MSISDN, TIPO_CLIENTE, GG_LAV-2 GIORNI_RITARDO, case when :costoGiornaliero*(GG_LAV-2) < 50 THEN :costoGiornaliero*(GG_LAV-2) ELSE 50 end TOTALE, MSISDN_PARLI_SUBITO, rownum rnum from " +
|
||||
" (SELECT ID_CORRELAZIONE, DRP.MSISDN, DRP.TIPO_CLIENTE, " +
|
||||
" dwh.FUN_GIORNI_LAVORATIVI@dwh(max(drp.DATA_ATTIVITA_RETE),min(GRR.DATA_CUT_OVER_CALC))-1 gg_lav, " +
|
||||
" (select MSISDN_PARLI_SUBITO FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE = DRP.ID_CORRELAZIONE AND STATO_FINALE = 12) MSISDN_PARLI_SUBITO " +
|
||||
" FROM DBCGO_RICHIESTE_PROCESSATE drp, DBCGO_GESTIONE_RICHIESTA_REC grr " +
|
||||
" WHERE ID_CORRELAZIONE IN ( SELECT D.ID_CORRELAZIONE " +
|
||||
" FROM DBCGO.DBCGO_RICHIESTE_PROCESSATE d " +
|
||||
" WHERE D.DATA_CHIUSURA_PROCESSO between to_date(:dataInizio,'dd/MM/yyyy') and to_date(:dataFine,'dd/MM/yyyy') " +
|
||||
" AND D.ID_CORRELAZIONE is not null " +
|
||||
" AND D.STATO_FINALE = " + StatoRichiestaRec.EVASA +
|
||||
" AND D.PROCESSO = 'R'" +
|
||||
" AND D.OPERATORE_REC_EFF = 'TIMG' " +
|
||||
" ) " +
|
||||
" CLAUSOLA_MARCAGGIO " +
|
||||
" CLAUSOLA_MSISDN " +
|
||||
" CLAUSOLA_COD_FISCALE " +
|
||||
" AND GRR.ID_RICHIESTA = DRP.ID_RICHIESTA " +
|
||||
" AND DRP.DATA_CHIUSURA_PROCESSO >= to_date(:dataInizio,'dd/MM/yyyy')-30 " +
|
||||
"group by ID_CORRELAZIONE, DRP.MSISDN, DRP.TIPO_CLIENTE, DRP.MSISDN_PARLI_SUBITO) " +
|
||||
"where gg_lav > 2 " +
|
||||
" and rownum <= (:start + :range)) " +
|
||||
"where rnum > :start ";
|
||||
|
||||
public static final String QUERY_COUNT_REPORT_INDENNIZZI_CLIENTE =
|
||||
"select count(*) from " +
|
||||
" (SELECT ID_CORRELAZIONE, DRP.MSISDN, DRP.TIPO_CLIENTE, " +
|
||||
" dwh.FUN_GIORNI_LAVORATIVI@dwh(max(drp.DATA_ATTIVITA_RETE),min(GRR.DATA_CUT_OVER_CALC))-1 gg_lav, " +
|
||||
" (select MSISDN_PARLI_SUBITO FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE = DRP.ID_CORRELAZIONE AND STATO_FINALE = 12) MSISDN_PARLI_SUBITO " +
|
||||
" FROM DBCGO_RICHIESTE_PROCESSATE drp, DBCGO_GESTIONE_RICHIESTA_REC grr " +
|
||||
" WHERE ID_CORRELAZIONE IN ( SELECT D.ID_CORRELAZIONE " +
|
||||
" FROM DBCGO.DBCGO_RICHIESTE_PROCESSATE d " +
|
||||
" WHERE D.DATA_CHIUSURA_PROCESSO between to_date(:dataInizio,'dd/MM/yyyy') and to_date(:dataFine,'dd/MM/yyyy') " +
|
||||
" AND D.ID_CORRELAZIONE is not null " +
|
||||
" AND D.STATO_FINALE = " + StatoRichiestaRec.EVASA +
|
||||
" AND D.PROCESSO = 'R' " +
|
||||
" AND D.OPERATORE_REC_EFF = 'TIMG' " +
|
||||
" ) " +
|
||||
" CLAUSOLA_MARCAGGIO " +
|
||||
" CLAUSOLA_MSISDN " +
|
||||
" CLAUSOLA_COD_FISCALE " +
|
||||
" AND GRR.ID_RICHIESTA = DRP.ID_RICHIESTA " +
|
||||
" AND DRP.DATA_CHIUSURA_PROCESSO >= to_date(:dataInizio,'dd/MM/yyyy')-30 " +
|
||||
"group by ID_CORRELAZIONE, DRP.MSISDN, DRP.TIPO_CLIENTE) " +
|
||||
"where gg_lav > 2 ";
|
||||
|
||||
public static final String QUERY_REPORT_DOWNLOAD_INDENNIZZI_CLIENTE =
|
||||
"SELECT ID_CORRELAZIONE, MSISDN, TIPO_CLIENTE," +
|
||||
" (select CODICE_FISCALE FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE= MIDLE.ID_CORRELAZIONE AND STATO_FINALE=12) CODICE_FISCALE, "+
|
||||
" (select ID_RICHIESTA FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE= MIDLE.ID_CORRELAZIONE AND DATARICEZIONERICHIESTA = "+
|
||||
" (SELECT min(DATARICEZIONERICHIESTA) FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE= MIDLE.ID_CORRELAZIONE AND DATA_CHIUSURA_PROCESSO >= to_date(:dataInizio,'dd/MM/yyyy')-30) AND ROWNUM<2) ID_RICH_FIRST, "+
|
||||
" (SELECT min(DATARICEZIONERICHIESTA) FROM DBCGO_RICHIESTE_PROCESSATE DRP WHERE ID_CORRELAZIONE= MIDLE.ID_CORRELAZIONE AND DATA_CHIUSURA_PROCESSO >= to_date(:dataInizio,'dd/MM/yyyy')-30) DATA_INS_FIRST, "+
|
||||
" (SELECT min(DCO) FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE= MIDLE.ID_CORRELAZIONE AND DATA_CHIUSURA_PROCESSO >= to_date(:dataInizio,'dd/MM/yyyy')-30) DATA_DCO_FIRST, "+
|
||||
" (select ID_RICHIESTA FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE= MIDLE.ID_CORRELAZIONE AND STATO_FINALE="+StatoRichiestaRec.EVASA +") ID_RICH_EVASA, "+
|
||||
" (select DATA_ATTIVITA_RETE FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE= MIDLE.ID_CORRELAZIONE AND STATO_FINALE="+StatoRichiestaRec.EVASA +") DATA_RICH_EVASA, "+
|
||||
" MIDLE.GG_LAV GIORNI_PORTING, "+
|
||||
" MIDLE.GG_LAV-2 GIORNI_RITARDO, case when :costoGiornaliero*(GG_LAV-2) < 50 THEN :costoGiornaliero*(GG_LAV-2) ELSE 50 end TOTALE, " +
|
||||
" (select MSISDN_PARLI_SUBITO FROM DBCGO_RICHIESTE_PROCESSATE WHERE ID_CORRELAZIONE = MIDLE.ID_CORRELAZIONE AND STATO_FINALE = 12) MSISDN_PARLI_SUBITO " +
|
||||
"FROM (SELECT ID_CORRELAZIONE, DRP.MSISDN, DRP.TIPO_CLIENTE, "+
|
||||
" dwh.FUN_GIORNI_LAVORATIVI@dwh(max(drp.DATA_ATTIVITA_RETE),min(GRR.DATA_CUT_OVER_CALC))-1 gg_lav "+
|
||||
" FROM DBCGO_RICHIESTE_PROCESSATE drp, DBCGO_GESTIONE_RICHIESTA_REC grr "+
|
||||
" WHERE ID_CORRELAZIONE IN ( SELECT D.ID_CORRELAZIONE "+
|
||||
" FROM DBCGO.DBCGO_RICHIESTE_PROCESSATE d "+
|
||||
" WHERE D.DATA_CHIUSURA_PROCESSO between to_date(:dataInizio,'dd/MM/yyyy') and to_date(:dataFine,'dd/MM/yyyy') "+
|
||||
" AND D.STATO_FINALE = " + StatoRichiestaRec.EVASA +
|
||||
" AND D.PROCESSO = 'R' " +
|
||||
" AND D.OPERATORE_REC_EFF = 'TIMG' " +
|
||||
" ) " +
|
||||
" CLAUSOLA_MARCAGGIO " +
|
||||
" CLAUSOLA_MSISDN " +
|
||||
" CLAUSOLA_COD_FISCALE " +
|
||||
" AND GRR.ID_RICHIESTA = DRP.ID_RICHIESTA " +
|
||||
" AND DRP.DATA_CHIUSURA_PROCESSO >= to_date(:dataInizio,'dd/MM/yyyy')-30 " +
|
||||
"GROUP BY ID_CORRELAZIONE, DRP.MSISDN, DRP.TIPO_CLIENTE) MIDLE "+
|
||||
"WHERE gg_lav > 2 ";
|
||||
|
||||
public ReportIndennizziClienteBusiness() {
|
||||
viewDAO = new DbcgoRichiesteProcessateDAO();
|
||||
}
|
||||
|
||||
public List eseguiRicerca(String dataInizio, String dataFine, String marcaggio, String numeroTelefonico, String codiceFiscale, int start, int range) {
|
||||
String query = QUERY_REPORT_INDENNIZZI_CLIENTE;
|
||||
if (numeroTelefonico != null && numeroTelefonico.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_MSISDN", " AND DRP.MSISDN = :numeroTelefonico ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_MSISDN", "");
|
||||
}
|
||||
|
||||
if (marcaggio != null && marcaggio.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_MARCAGGIO", " AND DRP.TIPO_CLIENTE = :tipoCliente ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_MARCAGGIO", "");
|
||||
}
|
||||
|
||||
if (codiceFiscale != null && codiceFiscale.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_COD_FISCALE", " AND DRP.CODICE_FISCALE = :codiceFiscale ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_COD_FISCALE", "");
|
||||
}
|
||||
|
||||
try {
|
||||
Query stmt = viewDAO.getSession().createSQLQuery(query).addEntity(DbcgoReportIndennizziCliente.class);
|
||||
stmt.setParameter("dataInizio", dataInizio);
|
||||
stmt.setParameter("dataFine", dataFine);
|
||||
stmt.setParameter("costoGiornaliero","2.5");
|
||||
stmt.setParameter("start", new Integer(start));
|
||||
stmt.setParameter("range", new Integer(range));
|
||||
if (numeroTelefonico != null && numeroTelefonico.trim().length() != 0) {
|
||||
stmt.setParameter("numeroTelefonico", numeroTelefonico);
|
||||
}
|
||||
if (marcaggio != null && marcaggio.trim().length() != 0) {
|
||||
stmt.setParameter("tipoCliente", marcaggio);
|
||||
}
|
||||
if (codiceFiscale != null && codiceFiscale.trim().length() != 0) {
|
||||
stmt.setParameter("codiceFiscale", codiceFiscale);
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) log.debug("Eseguo la query ["+query+"]");
|
||||
return stmt.list();
|
||||
} catch (RuntimeException re) {
|
||||
log.error(re);
|
||||
throw re;
|
||||
} finally {
|
||||
viewDAO.closeSession();
|
||||
}
|
||||
}
|
||||
|
||||
public int countRicerca(String dataInizio, String dataFine, String marcaggio, String numeroTelefonico, String codiceFiscale) {
|
||||
String query = QUERY_COUNT_REPORT_INDENNIZZI_CLIENTE;
|
||||
if (numeroTelefonico != null && numeroTelefonico.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_MSISDN", " AND DRP.MSISDN = :numeroTelefonico ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_MSISDN", "");
|
||||
}
|
||||
|
||||
if (marcaggio != null && marcaggio.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_MARCAGGIO", " AND DRP.TIPO_CLIENTE = :tipoCliente ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_MARCAGGIO", "");
|
||||
}
|
||||
|
||||
if (codiceFiscale != null && codiceFiscale.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_COD_FISCALE", " AND DRP.CODICE_FISCALE = :codiceFiscale ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_COD_FISCALE", "");
|
||||
}
|
||||
|
||||
try {
|
||||
Query stmt = viewDAO.getSession().createSQLQuery(query);
|
||||
stmt.setParameter("dataInizio", dataInizio);
|
||||
stmt.setParameter("dataFine", dataFine);
|
||||
if (numeroTelefonico != null && numeroTelefonico.trim().length() != 0) {
|
||||
stmt.setParameter("numeroTelefonico", numeroTelefonico);
|
||||
}
|
||||
if (marcaggio != null && marcaggio.trim().length() != 0) {
|
||||
stmt.setParameter("tipoCliente", marcaggio);
|
||||
}
|
||||
if (codiceFiscale != null && codiceFiscale.trim().length() != 0) {
|
||||
stmt.setParameter("codiceFiscale", codiceFiscale);
|
||||
}
|
||||
|
||||
BigDecimal count = (BigDecimal)stmt.uniqueResult();
|
||||
return count.intValue();
|
||||
} catch (RuntimeException re) {
|
||||
log.error(re);
|
||||
throw re;
|
||||
} finally {
|
||||
viewDAO.closeSession();
|
||||
}
|
||||
}
|
||||
|
||||
public List cercaDettaglio(String idCorrelazione, String dataInizio) {
|
||||
List criteri = new ArrayList();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
Calendar dateInizioCal = GregorianCalendar.getInstance();
|
||||
try {
|
||||
dateInizioCal.setTime(dateFormat.parse(dataInizio));
|
||||
dateInizioCal.add(Calendar.DAY_OF_MONTH, -30);
|
||||
dateInizioCal.set(Calendar.HOUR, 0);
|
||||
dateInizioCal.set(Calendar.MINUTE, 0);
|
||||
dateInizioCal.set(Calendar.SECOND, 0);
|
||||
dateInizioCal.set(Calendar.MILLISECOND, 0);
|
||||
log.debug("[Dettaglio] Limit to date : "+dateInizioCal);
|
||||
} catch (ParseException pe) {};
|
||||
criteri.add(Restrictions.eq("idCorrelazione", new Long(idCorrelazione)));
|
||||
criteri.add(Restrictions.ge("dataChiusuraProcesso", dateInizioCal.getTime()));
|
||||
List risultati = viewDAO.findByCriteria(criteri);
|
||||
return risultati;
|
||||
}
|
||||
|
||||
|
||||
public List eseguiDownload(String dataInizio, String dataFine, String marcaggio, String numeroTelefonico, String codiceFiscale) {
|
||||
String query = QUERY_REPORT_DOWNLOAD_INDENNIZZI_CLIENTE;
|
||||
if (numeroTelefonico != null && numeroTelefonico.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_MSISDN", " AND DRP.MSISDN = :numeroTelefonico ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_MSISDN", "");
|
||||
}
|
||||
|
||||
if (marcaggio != null && marcaggio.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_MARCAGGIO", " AND DRP.TIPO_CLIENTE = :tipoCliente ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_MARCAGGIO", "");
|
||||
}
|
||||
|
||||
if (codiceFiscale != null && codiceFiscale.trim().length() != 0) {
|
||||
query = query.replaceAll("CLAUSOLA_COD_FISCALE", " AND DRP.CODICE_FISCALE = :codiceFiscale ");
|
||||
} else {
|
||||
query = query.replaceAll("CLAUSOLA_COD_FISCALE", "");
|
||||
}
|
||||
|
||||
try {
|
||||
Query stmt = viewDAO.getSession().createSQLQuery(query).addEntity(DbcgoReportIndennizziClienteDownload.class);
|
||||
stmt.setParameter("dataInizio", dataInizio);
|
||||
stmt.setParameter("dataFine", dataFine);
|
||||
stmt.setParameter("costoGiornaliero","2.5");
|
||||
if (numeroTelefonico != null && numeroTelefonico.trim().length() != 0) {
|
||||
stmt.setParameter("numeroTelefonico", numeroTelefonico);
|
||||
}
|
||||
if (marcaggio != null && marcaggio.trim().length() != 0) {
|
||||
stmt.setParameter("tipoCliente", marcaggio);
|
||||
}
|
||||
if (codiceFiscale != null && codiceFiscale.trim().length() != 0) {
|
||||
stmt.setParameter("codiceFiscale", codiceFiscale);
|
||||
}
|
||||
|
||||
return stmt.list();
|
||||
} catch (RuntimeException re) {
|
||||
log.error(re);
|
||||
throw re;
|
||||
} finally {
|
||||
viewDAO.closeSession();
|
||||
}
|
||||
}
|
||||
|
||||
private String getClausolaOperatoriRete() {
|
||||
StringBuffer output = new StringBuffer();
|
||||
List list = GenericComboBusiness.getComboAnagOperatoriRete();
|
||||
for (Iterator iter = list.iterator(); iter.hasNext();) {
|
||||
GenericComboDto operatore = (GenericComboDto) iter.next();
|
||||
output.append("'").append(operatore.getValue()).append("'").append(",");
|
||||
}
|
||||
if (log.isDebugEnabled()) log.debug("[operatoriRete] "+ (output.substring(0, output.length()-1)) );
|
||||
return output.substring(0, output.length()-1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package it.valueteam.dbcgo.business.reportritardi;
|
||||
|
||||
import it.valueteam.dbcgo.bean.reportritardi.MonitoraggioRifiutiCsvRow;
|
||||
import it.valueteam.dbcgo.dao.impl.MonitoraggioRifiutiDao;
|
||||
import it.valueteam.dbcgo.dto.DbcgoMonitoraggioRifiutiDto;
|
||||
import it.valueteam.dbcgo.service.ServiceLocatorException;
|
||||
import it.valueteam.dbcgo.sync.dto.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ReportMonitoraggioRifiutiBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(ReportMonitoraggioRifiutiBusiness.class.getName());
|
||||
public MonitoraggioRifiutiDao viewDAO;
|
||||
private Map mappaConteggiCausaliRifiuti;
|
||||
private HashSet processiDonor = new HashSet() {{ add("D"); add("W"); add("H"); }};
|
||||
private HashSet processiRecipient = new HashSet() {{ add("R"); add("V"); add("O"); }};
|
||||
|
||||
public ReportMonitoraggioRifiutiBusiness() {
|
||||
try {
|
||||
viewDAO = new MonitoraggioRifiutiDao();
|
||||
} catch (ServiceLocatorException sle) {
|
||||
log.error(sle);
|
||||
}
|
||||
}
|
||||
|
||||
public List eseguiRicercaBU(String dataInizio, String dataFine, String numeroRifiuti, String processo, Hashtable codiciCausaliRifiuti) {
|
||||
// contiene una lista di oggetti DbcgoMonitoraggioRifiutiDto.class
|
||||
List risultatiGrezzi = eseguiRicerca(dataInizio, dataFine, "BU", processo);
|
||||
|
||||
// contiene una lista di oggetti MonitoraggioRifiutiCsvRow.class
|
||||
List risultatiAggregati = aggregaRisultati(risultatiGrezzi, codiciCausaliRifiuti, processo, numeroRifiuti);
|
||||
return risultatiAggregati;
|
||||
}
|
||||
|
||||
public List eseguiRicercaCO(String dataInizio, String dataFine, String numeroRifiuti, String processo, Hashtable codiciCausaliRifiuti) {
|
||||
// contiene una lista di oggetti DbcgoMonitoraggioRifiutiDto.class
|
||||
List risultatiGrezzi = eseguiRicerca(dataInizio, dataFine, "CO", processo);
|
||||
|
||||
// contiene una lista di oggetti MonitoraggioRifiutiCsvRow.class
|
||||
List risultatiAggregati = aggregaRisultati(risultatiGrezzi, codiciCausaliRifiuti, processo, numeroRifiuti);
|
||||
return risultatiAggregati;
|
||||
}
|
||||
|
||||
private List eseguiRicerca(String dataInizio, String dataFine, String marcaggio, String processo) {
|
||||
List results = viewDAO.getRifiuti(dataInizio, dataFine, marcaggio, processo);
|
||||
return results;
|
||||
}
|
||||
|
||||
private List aggregaRisultati(List risultatiGrezzi, Hashtable codiciCausaliRifiuti, String tipoProcessoSelezionato, String numeroRifiuti) {
|
||||
if (log.isDebugEnabled()) log.debug("Aggregazione risultati. Risultati grezzi ["+risultatiGrezzi.size()+"]");
|
||||
List output = new ArrayList();
|
||||
String tipoProcessoTemp = null;
|
||||
String msisdnTemp = null;
|
||||
String operEffTemp = null;
|
||||
MonitoraggioRifiutiCsvRow rowCsv = null;
|
||||
for (int i = 0; i < risultatiGrezzi.size(); i++) {
|
||||
DbcgoMonitoraggioRifiutiDto singleRow = (DbcgoMonitoraggioRifiutiDto)risultatiGrezzi.get(i);
|
||||
if (i == 0 || !tipoProcessoTemp.equalsIgnoreCase(singleRow.getProcesso()) ||
|
||||
!msisdnTemp.equalsIgnoreCase(singleRow.getMsisdn()) ||
|
||||
(tipoProcessoSelezionato.equalsIgnoreCase("R") && !operEffTemp.equalsIgnoreCase(singleRow.getDonorEffettivo())) ||
|
||||
(tipoProcessoSelezionato.equalsIgnoreCase("D") && !operEffTemp.equalsIgnoreCase(singleRow.getRecipientEffettivo()))) {
|
||||
// C'e' un cambio di numero oppure di processo oppure di operatore. Chiudo la precedente riga
|
||||
// e ne apro una nuova. Inserisco la riga nei risultati solamente se il processo e'
|
||||
// uguale a quello selezionato da form oppure se rispetta il numeroRifiuti selezionato da filtro
|
||||
if (i != 0) {
|
||||
if (tipoProcessoSelezionato.equalsIgnoreCase("R") && processiRecipient.contains(tipoProcessoTemp)) {
|
||||
calcoloRifiutiPerCausale(codiciCausaliRifiuti, rowCsv);
|
||||
|
||||
// controllo sul numero rifiuti
|
||||
boolean scriviRiga = false;
|
||||
if (numeroRifiuti.equalsIgnoreCase("1") && rowCsv.getNumeroRifiutiTotali()>=1) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("2") && rowCsv.getNumeroRifiutiTotali()==1) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("3") && rowCsv.getNumeroRifiutiTotali()>=2 && rowCsv.getNumeroRifiutiTotali()<=10) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("4") && rowCsv.getNumeroRifiutiTotali()>10) {
|
||||
scriviRiga = true;
|
||||
}
|
||||
if (scriviRiga) {
|
||||
output.add(rowCsv);
|
||||
}
|
||||
} else if (tipoProcessoSelezionato.equalsIgnoreCase("D") && processiDonor.contains(tipoProcessoTemp)) {
|
||||
calcoloRifiutiPerCausale(codiciCausaliRifiuti, rowCsv);
|
||||
// controllo sul numero rifiuti
|
||||
boolean scriviRiga = false;
|
||||
if (numeroRifiuti.equalsIgnoreCase("1") && rowCsv.getNumeroRifiutiTotali()>=1) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("2") && rowCsv.getNumeroRifiutiTotali()==1) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("3") && rowCsv.getNumeroRifiutiTotali()>=2 && rowCsv.getNumeroRifiutiTotali()<=10) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("4") && rowCsv.getNumeroRifiutiTotali()>10) {
|
||||
scriviRiga = true;
|
||||
}
|
||||
if (scriviRiga) {
|
||||
output.add(rowCsv);
|
||||
}
|
||||
}
|
||||
}
|
||||
// inizializzo i nuovi valori
|
||||
rowCsv = new MonitoraggioRifiutiCsvRow();
|
||||
rowCsv.setMsisdn( singleRow.getMsisdn() );
|
||||
rowCsv.setDataPic( singleRow.getDataPic() );
|
||||
rowCsv.setCausaliRifiuto("");
|
||||
|
||||
tipoProcessoTemp = singleRow.getProcesso();
|
||||
msisdnTemp = singleRow.getMsisdn();
|
||||
if (tipoProcessoSelezionato.equalsIgnoreCase("R")) {
|
||||
operEffTemp = singleRow.getDonorEffettivo();
|
||||
} else {
|
||||
operEffTemp = singleRow.getRecipientEffettivo();
|
||||
}
|
||||
}
|
||||
// se la richiesta e' rifiutata sommo i valori, se è evasa imposto la data espletamento
|
||||
if (tipoProcessoSelezionato.equalsIgnoreCase("R")) {
|
||||
if (singleRow.getStatoFinale().intValue() == StatoRichiestaRec.RIFIUTATA) {
|
||||
rowCsv.setNumeroRifiutiTotali(rowCsv.getNumeroRifiutiTotali() + 1);
|
||||
if (rowCsv.getCausaliRifiuto().trim().length() == 0) {
|
||||
rowCsv.setCausaliRifiuto( convertToCSVFormat(singleRow.getCodiciRifiutoValidazione()) );
|
||||
} else {
|
||||
rowCsv.setCausaliRifiuto( rowCsv.getCausaliRifiuto() + ";" + convertToCSVFormat(singleRow.getCodiciRifiutoValidazione()) );
|
||||
}
|
||||
} else if (singleRow.getStatoFinale().intValue() == StatoRichiestaRec.EVASA) {
|
||||
rowCsv.setDataEspletamento( singleRow.getDataChiusuraProcesso() );
|
||||
rowCsv.setOperatoreEffettivo(singleRow.getDonorEffettivo());
|
||||
}
|
||||
} else if (tipoProcessoSelezionato.equalsIgnoreCase("D")) {
|
||||
// Nel caso donor lo stato rifiutata e' diverso a seconda del processo puntuale
|
||||
if (singleRow.getProcesso().equalsIgnoreCase("D") || singleRow.getProcesso().equalsIgnoreCase("H")) {
|
||||
if (singleRow.getStatoFinale().intValue() == StatoRichiestaDon.RIFIUTATA) {
|
||||
rowCsv.setNumeroRifiutiTotali( rowCsv.getNumeroRifiutiTotali()+1);
|
||||
if (rowCsv.getCausaliRifiuto().trim().length() == 0) {
|
||||
rowCsv.setCausaliRifiuto( convertToCSVFormat(singleRow.getCodiciRifiutoValidazione()) );
|
||||
} else {
|
||||
rowCsv.setCausaliRifiuto( rowCsv.getCausaliRifiuto() + ";" + convertToCSVFormat(singleRow.getCodiciRifiutoValidazione()) );
|
||||
}
|
||||
} else if (singleRow.getStatoFinale().intValue() == StatoRichiestaDon.ESPLETATA) {
|
||||
rowCsv.setDataEspletamento( singleRow.getDataChiusuraProcesso() );
|
||||
rowCsv.setOperatoreEffettivo(singleRow.getRecipientEffettivo());
|
||||
}
|
||||
} else if (singleRow.getProcesso().equalsIgnoreCase("W")) {
|
||||
if (singleRow.getStatoFinale().intValue() == StatoRichiestaDonVirt.RIFIUTATA) {
|
||||
rowCsv.setNumeroRifiutiTotali( rowCsv.getNumeroRifiutiTotali()+1);
|
||||
if (rowCsv.getCausaliRifiuto().trim().length() == 0) {
|
||||
rowCsv.setCausaliRifiuto( convertToCSVFormat(singleRow.getCodiciRifiutoValidazione()) );
|
||||
} else {
|
||||
rowCsv.setCausaliRifiuto( rowCsv.getCausaliRifiuto() + ";" + convertToCSVFormat(singleRow.getCodiciRifiutoValidazione()) );
|
||||
}
|
||||
} else if (singleRow.getStatoFinale().intValue() == StatoRichiestaDonVirt.EVASA) {
|
||||
rowCsv.setDataEspletamento( singleRow.getDataChiusuraProcesso() );
|
||||
rowCsv.setOperatoreEffettivo(singleRow.getRecipientEffettivo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Aggiunge l'ultimo record ai risultati
|
||||
if (tipoProcessoSelezionato.equalsIgnoreCase("R") && processiRecipient.contains(tipoProcessoTemp)) {
|
||||
calcoloRifiutiPerCausale(codiciCausaliRifiuti, rowCsv);
|
||||
// controllo sul numero rifiuti
|
||||
boolean scriviRiga = false;
|
||||
if (numeroRifiuti.equalsIgnoreCase("1") && rowCsv.getNumeroRifiutiTotali()>=1) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("2") && rowCsv.getNumeroRifiutiTotali()==1) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("3") && rowCsv.getNumeroRifiutiTotali()>=2 && rowCsv.getNumeroRifiutiTotali()<=10) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("4") && rowCsv.getNumeroRifiutiTotali()>10) {
|
||||
scriviRiga = true;
|
||||
}
|
||||
if (scriviRiga) {
|
||||
output.add(rowCsv);
|
||||
}
|
||||
} else if (tipoProcessoSelezionato.equalsIgnoreCase("D") && processiDonor.contains(tipoProcessoTemp)) {
|
||||
calcoloRifiutiPerCausale(codiciCausaliRifiuti, rowCsv);
|
||||
// controllo sul numero rifiuti
|
||||
boolean scriviRiga = false;
|
||||
if (numeroRifiuti.equalsIgnoreCase("1") && rowCsv.getNumeroRifiutiTotali()>=1) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("2") && rowCsv.getNumeroRifiutiTotali()==1) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("3") && rowCsv.getNumeroRifiutiTotali()>=2 && rowCsv.getNumeroRifiutiTotali()<=10) {
|
||||
scriviRiga = true;
|
||||
} else if (numeroRifiuti.equalsIgnoreCase("4") && rowCsv.getNumeroRifiutiTotali()>10) {
|
||||
scriviRiga = true;
|
||||
}
|
||||
if (scriviRiga) {
|
||||
output.add(rowCsv);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// Sostituisce i ";" con "-" e toglie l'ultimo carattere
|
||||
private String convertToCSVFormat(String input) {
|
||||
return input.replaceAll(";","-").substring(0,input.length()-1);
|
||||
}
|
||||
|
||||
private void calcoloRifiutiPerCausale(Hashtable codiciCausaliRifiuti, MonitoraggioRifiutiCsvRow rowCsv) {
|
||||
// inizializzo la mappa dei conteggi
|
||||
LinkedHashMap mappaConteggiCausaliRifiuti = new LinkedHashMap(codiciCausaliRifiuti.size());
|
||||
Iterator it = codiciCausaliRifiuti.keySet().iterator();
|
||||
log.debug("numero codici rifiuto:"+codiciCausaliRifiuti.size());
|
||||
while (it.hasNext()) {
|
||||
String key = (String)it.next();
|
||||
mappaConteggiCausaliRifiuti.put(key, new Integer(0));
|
||||
}
|
||||
log.debug(mappaConteggiCausaliRifiuti);
|
||||
|
||||
// tokenizer sulle causali rifiuti per aggiornare i conteggi. tolgo il ";" utilizzato
|
||||
// per separare le causali di diverse richieste e lo rimpiazzo con il "-"
|
||||
String rifiutiTotali = rowCsv.getCausaliRifiuto().replaceAll(";","-");
|
||||
String[] causali = rifiutiTotali.split("-");
|
||||
log.debug(rifiutiTotali);
|
||||
for(int i=0; i<causali.length; i++) {
|
||||
Integer valore = (Integer)mappaConteggiCausaliRifiuti.get(causali[i]);
|
||||
if (valore != null) {
|
||||
mappaConteggiCausaliRifiuti.put(causali[i], new Integer( valore.intValue() + 1));
|
||||
}
|
||||
}
|
||||
rowCsv.setNumeroRifiutiCausali(mappaConteggiCausaliRifiuti);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package it.valueteam.dbcgo.business.reportritardi;
|
||||
|
||||
import it.valueteam.dbcgo.dto.RicorrenzaLineeMnpCsvRow;
|
||||
import it.valueteam.dbcgo.dao.impl.RicorrenzaLineeMNPDao;
|
||||
import it.valueteam.dbcgo.dto.*;
|
||||
import it.valueteam.dbcgo.service.ServiceLocatorException;
|
||||
import it.valueteam.dbcgo.sync.dto.*;
|
||||
import it.valueteam.dbcgo.utility.JavaUtilsClass;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ReportRicorrenzaLineeMnpBusiness {
|
||||
|
||||
static Logger log = Logger.getLogger(ReportRicorrenzaLineeMnpBusiness.class.getName());
|
||||
public RicorrenzaLineeMNPDao viewDAO;
|
||||
private HashSet processiDonor = new HashSet() {{ add("D"); add("W"); }};
|
||||
private HashSet processiRecipient = new HashSet() {{ add("R"); add("V"); }};
|
||||
|
||||
public ReportRicorrenzaLineeMnpBusiness() {
|
||||
try {
|
||||
viewDAO = new RicorrenzaLineeMNPDao();
|
||||
} catch (ServiceLocatorException sle) {
|
||||
log.error(sle);
|
||||
}
|
||||
}
|
||||
|
||||
public List eseguiRicercaLinee(String dataInizio, String dataFine, int giorniRitardoDa, int giorniRitardoA, String processo, String tipoCliente) {
|
||||
// contiene una lista di oggetti RicorrenzaLineeMnpCsvRow.class
|
||||
List risultati = eseguiRicerca(dataInizio, dataFine, processo, giorniRitardoDa, giorniRitardoA, tipoCliente);
|
||||
if (log.isDebugEnabled()) log.debug("Trovati "+risultati.size() + ".");
|
||||
|
||||
// contiene una lista di oggetti RicorrenzaLineeMnpCsvRow.class
|
||||
//List risultatiAggregati = aggregaRisultati(risultatiGrezzi, processo, giorniRitardoDa, giorniRitardoA);
|
||||
return risultati;
|
||||
}
|
||||
|
||||
private List eseguiRicerca(String dataInizio, String dataFine, String processo, int giorniRitardoDa, int giorniRitardoA, String tipoCliente) {
|
||||
List results = viewDAO.getRicorrenzaLinee(dataInizio, dataFine, processo, giorniRitardoDa, giorniRitardoA, tipoCliente);
|
||||
return results;
|
||||
}
|
||||
|
||||
private List aggregaRisultati(List risultatiGrezzi, String tipoProcessoSelezionato, int giorniRitardoDa, int giorniRitardoA) {
|
||||
if (log.isDebugEnabled()) log.debug("Aggregazione ricorrenzaLineeMNP");
|
||||
List output = new ArrayList();
|
||||
String tipoProcessoTemp = null;
|
||||
String msisdnTemp = null;
|
||||
RicorrenzaLineeMnpCsvRow rowCsv = null;
|
||||
DbcgoRicorrenzaLineeDto singleRowTemp = null;
|
||||
boolean trovataRichiestaCorrispondente = false;
|
||||
for (int i = 0; i < risultatiGrezzi.size(); i++) {
|
||||
DbcgoRicorrenzaLineeDto singleRow = (DbcgoRicorrenzaLineeDto)risultatiGrezzi.get(i);
|
||||
|
||||
if (i == 0 || msisdnTemp == null || !msisdnTemp.equalsIgnoreCase(singleRow.getMsisdn()) || trovataRichiestaCorrispondente) {
|
||||
// C'e' un cambio di numero oppure di processo. Chiudo la precedente riga
|
||||
// e ne apro una nuova. Inserisco la riga nei risultati solamente se il processo e'
|
||||
// uguale a quello selezionato da form oppure se rispetta il numeroGiorniRitardo selezionato da filtro
|
||||
if (i != 0 && rowCsv != null) {
|
||||
if (giorniRitardoDa <= rowCsv.getNumeroGiorniRitardo() && rowCsv.getNumeroGiorniRitardo() <= giorniRitardoA) {
|
||||
if (trovataRichiestaCorrispondente) {
|
||||
output.add(rowCsv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trovataRichiestaCorrispondente = false;
|
||||
// se non ci sono PP salto l'MSISDN
|
||||
if (singleRow.getPpNum() == 0) {
|
||||
//if (log.isDebugEnabled()) log.debug("Record scartato per PP_NUM = 0. MSISDN ["+singleRow.getMsisdn()+"] idRichiesta ["+singleRow.getIdRichiesta()+"] processo ["+singleRow.getProcesso()+"]");
|
||||
continue;
|
||||
}
|
||||
// inizializzo i nuovi valori
|
||||
if (log.isDebugEnabled()) log.debug("Nuovo record per MSISDN ["+singleRow.getMsisdn()+"] idRichiesta ["+singleRow.getIdRichiesta()+"] processo ["+singleRow.getProcesso()+"]" );
|
||||
rowCsv = new RicorrenzaLineeMnpCsvRow();
|
||||
rowCsv.setMsisdn( singleRow.getMsisdn() );
|
||||
if (tipoProcessoSelezionato.equalsIgnoreCase("R")) {
|
||||
rowCsv.setOperatoreEffettivo(singleRow.getDonorEffettivo());
|
||||
} else {
|
||||
rowCsv.setOperatoreEffettivo(singleRow.getRecipientEffettivo());
|
||||
}
|
||||
rowCsv.setDataEspletamento( singleRow.getDataChiusuraProcesso() );
|
||||
rowCsv.setPpNum( singleRow.getPpNum() );
|
||||
|
||||
singleRowTemp = null;
|
||||
|
||||
tipoProcessoTemp = singleRow.getProcesso();
|
||||
msisdnTemp = singleRow.getMsisdn();
|
||||
}
|
||||
|
||||
// Nel caso recipient devo partire da una richiesta RECIPIENT EVASA
|
||||
if (singleRowTemp == null) {
|
||||
if (tipoProcessoSelezionato.equalsIgnoreCase("R")) {
|
||||
if (singleRow.getStatoFinale().intValue() != StatoRichiestaRec.EVASA ) {
|
||||
continue;
|
||||
}
|
||||
if (processiRecipient.contains(singleRow.getProcesso())) {
|
||||
singleRowTemp = singleRow;
|
||||
if (log.isDebugEnabled()) log.debug("Nuovo record di riferimento MSISDN ["+singleRow.getMsisdn()+"] idRichiesta ["+singleRow.getIdRichiesta()+"] processo ["+singleRow.getProcesso()+"]" );
|
||||
}
|
||||
} else if (tipoProcessoSelezionato.equalsIgnoreCase("D")) { // Nel caso donor devo partire da una richiesta DONOR EVASA
|
||||
// DONOR e DONOR_VIRT hanno stato finale diverso
|
||||
if (singleRow.getProcesso().equalsIgnoreCase("D")) {
|
||||
if (singleRow.getStatoFinale().intValue() != StatoRichiestaDon.ESPLETATA) {
|
||||
continue;
|
||||
}
|
||||
singleRowTemp = singleRow;
|
||||
if (log.isDebugEnabled()) log.debug("Nuovo record di riferimento MSISDN ["+singleRow.getMsisdn()+"] idRichiesta ["+singleRow.getIdRichiesta()+"] processo ["+singleRow.getProcesso()+"]" );
|
||||
} else if (singleRow.getProcesso().equalsIgnoreCase("W")) {
|
||||
if (singleRow.getStatoFinale().intValue() != StatoRichiestaDonVirt.EVASA) {
|
||||
continue;
|
||||
}
|
||||
singleRowTemp = singleRow;
|
||||
if (log.isDebugEnabled()) log.debug("Nuovo record di riferimento MSISDN ["+singleRow.getMsisdn()+"] idRichiesta ["+singleRow.getIdRichiesta()+"] processo ["+singleRow.getProcesso()+"]" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (singleRowTemp != singleRow && singleRowTemp != null) {
|
||||
if (tipoProcessoSelezionato.equalsIgnoreCase("R")) {
|
||||
// Cerco la prossima richiesta Donor in evaso
|
||||
if ( ((singleRow.getProcesso().equalsIgnoreCase("D") && singleRow.getStatoFinale().intValue() == StatoRichiestaDon.ESPLETATA)) ||
|
||||
((singleRow.getProcesso().equalsIgnoreCase("W") && singleRow.getStatoFinale().intValue() == StatoRichiestaDonVirt.EVASA))) {
|
||||
trovataRichiestaCorrispondente = true;
|
||||
// calcolo giorni di differenza
|
||||
long giorniDifferenza = Math.abs(JavaUtilsClass.differenzaGiorni(singleRowTemp.getDataChiusuraProcesso(), singleRow.getDataChiusuraProcesso()));
|
||||
rowCsv.setNumeroGiorniRitardo((int)giorniDifferenza);
|
||||
if (log.isDebugEnabled()) log.debug("TROVATA RICHIESTA CORRISPONDENTE con giorni ritardo = "+giorniDifferenza);
|
||||
}
|
||||
} else if (tipoProcessoSelezionato.equalsIgnoreCase("D")) {
|
||||
// Cerco la prossima richiesta Recipient in evaso
|
||||
if (processiRecipient.contains(singleRow.getProcesso())) {
|
||||
if (singleRow.getStatoFinale().intValue() == StatoRichiestaRec.EVASA) {
|
||||
trovataRichiestaCorrispondente = true;
|
||||
// calcolo giorni di differenza
|
||||
long giorniDifferenza = Math.abs(JavaUtilsClass.differenzaGiorni(singleRow.getDataChiusuraProcesso(), singleRowTemp.getDataChiusuraProcesso()));
|
||||
if (log.isDebugEnabled()) log.debug("TROVATA RICHIESTA CORRISPONDENTE con giorni ritardo = "+giorniDifferenza);
|
||||
rowCsv.setNumeroGiorniRitardo((int)giorniDifferenza);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Gestione dell'ultimo record
|
||||
if (rowCsv != null) {
|
||||
if (giorniRitardoDa <= rowCsv.getNumeroGiorniRitardo() && rowCsv.getNumeroGiorniRitardo() <= giorniRitardoA) {
|
||||
if (trovataRichiestaCorrispondente) {
|
||||
output.add(rowCsv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("Report RicorrenzaLineeMNP. Trovati ["+output.size()+"] risultati.");
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.valueteam.dbcgo.exception;
|
||||
|
||||
public class CalcoloPenaliException extends Exception {
|
||||
|
||||
public static final String UNKNOWN = "unknown";
|
||||
public static final String RICERCA_VUOTA = "RICERCA_VUOTA";
|
||||
|
||||
String errorCode;
|
||||
|
||||
public CalcoloPenaliException() {
|
||||
super();
|
||||
errorCode = UNKNOWN;
|
||||
}
|
||||
|
||||
public CalcoloPenaliException(String err, String errorCode) {
|
||||
super(err);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public CalcoloPenaliException(String errorCode) {
|
||||
super();
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package it.valueteam.dbcgo.exception;
|
||||
|
||||
public class CsvFormatException extends Exception {
|
||||
public static final String UNKNOWN = "unknown";
|
||||
public static final String SLA_NON_PERMESSO = "SLA_NON_PERMESSO";
|
||||
|
||||
String errorCode;
|
||||
|
||||
public CsvFormatException() {
|
||||
super();
|
||||
errorCode = UNKNOWN;
|
||||
}
|
||||
|
||||
public CsvFormatException(String err, String errorCode) {
|
||||
super(err);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public CsvFormatException(String errorCode) {
|
||||
super();
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}}
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* Tramite questa classe <20> possibile ottenere un vettore di oggetti non nulli
|
||||
* contenente la mappatura chiave valore dei dati provenienti dal form;
|
||||
*/
|
||||
package it.valueteam.dbcgo.utility;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class DynaWorkForm {
|
||||
private Map map;
|
||||
private Vector vlist = new Vector();
|
||||
static Logger log = Logger.getLogger(DynaWorkForm.class.getName());
|
||||
|
||||
public DynaWorkForm(Map _map){
|
||||
map = _map;
|
||||
}
|
||||
|
||||
public Map getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public Vector workthismap(){
|
||||
Vector _vlist = new Vector();
|
||||
Set setmapkey = map.keySet();
|
||||
Iterator it = setmapkey.iterator();
|
||||
while (it.hasNext()) {
|
||||
String chiave = (String)it.next();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("operazione");
|
||||
StringBuffer sb2 = new StringBuffer();
|
||||
sb2.append("start");
|
||||
StringBuffer sb3 = new StringBuffer();
|
||||
sb3.append("range");
|
||||
StringBuffer sb4 = new StringBuffer();
|
||||
sb4.append("numeroTotaleRichieste");
|
||||
StringBuffer sb5 = new StringBuffer();
|
||||
sb5.append("maxRowNum");
|
||||
if (chiave.indexOf("opsel_")==-1 && chiave.indexOf("opcol_")==-1 && !chiave.contentEquals(sb5) && !chiave.contentEquals(sb4) && !chiave.contentEquals(sb) && !chiave.contentEquals(sb2) && !chiave.contentEquals(sb3)) {
|
||||
if ((map.get(chiave)).getClass().equals(java.lang.String.class)) {
|
||||
String valore = (String)map.get(chiave);
|
||||
if (valore!=null){
|
||||
if (!valore.trim().equals("")){
|
||||
_vlist.add(new OggettoDyna(chiave,valore));
|
||||
}
|
||||
}
|
||||
} else if ((map.get(chiave)).getClass().equals(java.lang.Long.class)){
|
||||
Long valore = (Long)map.get(chiave);
|
||||
if (!valore.equals(new Long(-1))){
|
||||
_vlist.add(new OggettoDyna(chiave,valore));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vlist = _vlist;
|
||||
return _vlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna una lista di OggettiDyna:
|
||||
* chiave:valore
|
||||
* @return
|
||||
*/
|
||||
public Vector getVlist() {
|
||||
return vlist;
|
||||
}
|
||||
|
||||
public void setVlist(Vector vlist) {
|
||||
this.vlist = vlist;
|
||||
}
|
||||
public void printVect (Vector _vlist){
|
||||
for (int i=0;i<_vlist.size();i++) {
|
||||
OggettoDyna oDyna = (OggettoDyna)_vlist.get(i);
|
||||
if (oDyna.getValore()!=null) {
|
||||
log.debug("chiave:"+oDyna.getChiave()+" valore:" +oDyna.getValore());
|
||||
} else {
|
||||
log.debug("chiave:"+oDyna.getChiave()+" valore:" +oDyna.getValoreLong().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class OggettoDyna {
|
||||
private String valore;
|
||||
private String chiave;
|
||||
private Long valoreLong;
|
||||
|
||||
public OggettoDyna(String _chiave, String _valore){
|
||||
valore = _valore;
|
||||
chiave = _chiave;
|
||||
}
|
||||
|
||||
public OggettoDyna(String _chiave, Long _valore){
|
||||
valoreLong = _valore;
|
||||
chiave = _chiave;
|
||||
}
|
||||
|
||||
public String getValore() {
|
||||
return valore;
|
||||
}
|
||||
public void setValore(String valore) {
|
||||
this.valore = valore;
|
||||
}
|
||||
public String getChiave() {
|
||||
return chiave;
|
||||
}
|
||||
public void setChiave(String chiave) {
|
||||
this.chiave = chiave;
|
||||
}
|
||||
|
||||
public Long getValoreLong() {
|
||||
return valoreLong;
|
||||
}
|
||||
|
||||
public void setValoreLong(Long valoreLong) {
|
||||
this.valoreLong = valoreLong;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
package it.valueteam.dbcgo.utility;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
public class Generic {
|
||||
private static int lunghezzariga = 90;
|
||||
static Logger log = Logger.getLogger(Generic.class.getName());
|
||||
|
||||
/**
|
||||
* Restituisce una stringa della lunghezza del campo contenitore
|
||||
* che contiene alla destra il campo valore e filla sulla sinistra con
|
||||
* contenitore
|
||||
* esempio:
|
||||
* contenitore AAAA
|
||||
* valore B
|
||||
* restituisce AAAB
|
||||
* @param contenitore
|
||||
* @param valore
|
||||
* @return
|
||||
*/
|
||||
public static String strLeftFill(String contenitore, String valore){
|
||||
int startNumber = (contenitore.length())-(valore.length());
|
||||
String primaParte = contenitore.substring(0, startNumber);
|
||||
String nuovaParte = primaParte + valore;
|
||||
return nuovaParte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce una stringa della lunghezza del campo contenitore
|
||||
* che contiene alla destra il campo valore e filla sulla destra con
|
||||
* contenitore
|
||||
* esempio:
|
||||
* contenitore AAAA
|
||||
* valore B
|
||||
* restituisce BAAA
|
||||
* @param contenitore
|
||||
* @param valore
|
||||
* @return
|
||||
*/
|
||||
public static String strRightFill(String contenitore, String valore){
|
||||
int startIndex = valore.length();
|
||||
String secondaParte = contenitore.substring(startIndex,contenitore.length());
|
||||
String nuovaParte = valore+secondaParte;
|
||||
return nuovaParte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce una stringa di lunghezza nwhite
|
||||
* che contiene alla destra il campo valore e filla sulla destra con
|
||||
* contenitore di spazi vuoti
|
||||
* esempio:
|
||||
* nWhite 4
|
||||
* valore X
|
||||
* restituisce |X |
|
||||
* @param nWhite
|
||||
* @param valore
|
||||
* @return
|
||||
*/
|
||||
public static String strRightFillwhite(int nWhite,String valore){
|
||||
|
||||
StringBuffer stringContenitore = new StringBuffer();
|
||||
for (int i = 0;i<nWhite;i++){
|
||||
stringContenitore.append(" ");
|
||||
}
|
||||
String contenitore = stringContenitore.toString();
|
||||
int startIndex = valore.length();
|
||||
String secondaParte = contenitore.substring(startIndex,contenitore.length());
|
||||
String nuovaParte = valore+secondaParte;
|
||||
return nuovaParte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce una stringa di lunghezza fissata da proprietà statica
|
||||
* che contiene alla destra il campo valore e filla sulla destra con
|
||||
* contenitore di spazi vuoti
|
||||
* esempio:
|
||||
* valore X
|
||||
* restituisce |X |
|
||||
* @param nWhite
|
||||
* @param valore
|
||||
* @return
|
||||
*/
|
||||
public static String plainRow(String valore){
|
||||
|
||||
StringBuffer stringContenitore = new StringBuffer();
|
||||
for (int i = 0;i<lunghezzariga;i++){
|
||||
stringContenitore.append(" ");
|
||||
}
|
||||
String contenitore = stringContenitore.toString();
|
||||
int startIndex = valore.length();
|
||||
String secondaParte = contenitore.substring(startIndex,contenitore.length());
|
||||
String nuovaParte = valore+secondaParte;
|
||||
return nuovaParte;
|
||||
}
|
||||
public static String fillWith(int occorrenze,char carattere){
|
||||
char[] arr = new char[occorrenze];
|
||||
for (int i=0;i<arr.length;i++){
|
||||
arr[i] = carattere;
|
||||
}
|
||||
String result = new String(arr);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String doubleToCentesimi(double importo){
|
||||
DecimalFormat format = new DecimalFormat("0.00");
|
||||
String appo = format.format(importo).toString();
|
||||
if (appo.indexOf(',') != -1)
|
||||
appo = replace(appo, ",", "");
|
||||
if (appo.indexOf('.') != -1)
|
||||
appo = replace(appo, ".", "");
|
||||
return appo;
|
||||
}
|
||||
|
||||
public static String replace(String source, String pattern, String replace) {
|
||||
if (source!=null) {
|
||||
final int len = pattern.length();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int found = -1;
|
||||
int start = 0;
|
||||
|
||||
while( (found = source.indexOf(pattern, start) ) != -1) {
|
||||
sb.append(source.substring(start, found));
|
||||
sb.append(replace);
|
||||
start = found + len;
|
||||
}
|
||||
sb.append(source.substring(start));
|
||||
return sb.toString();
|
||||
}
|
||||
else return "";
|
||||
}
|
||||
|
||||
public static Integer stringToInteger(String str){
|
||||
|
||||
// valore di default
|
||||
Integer valore = new Integer(0);
|
||||
|
||||
// verifico che la stringa non sia nulla o vuota
|
||||
String strAppo = str.trim();
|
||||
if("".equals(strAppo) || strAppo == null){
|
||||
return valore;
|
||||
} else {
|
||||
valore = new Integer(str);
|
||||
return valore;
|
||||
}
|
||||
}
|
||||
|
||||
public static String IntegerToString(Integer intero){
|
||||
|
||||
// valore di default
|
||||
String valore = "";
|
||||
|
||||
// verifico che la stringa non sia nulla
|
||||
if(intero!=null){
|
||||
valore = intero.toString();
|
||||
}
|
||||
return valore;
|
||||
}
|
||||
|
||||
public static String DateToString(Date data, String formato){
|
||||
|
||||
Date dataInLavorazione = null;
|
||||
Date dataCorrente = new Date();
|
||||
|
||||
if(data!=null){
|
||||
dataInLavorazione = data;
|
||||
} else {
|
||||
dataInLavorazione = dataCorrente;
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(formato);
|
||||
return sdf.format(dataInLavorazione);
|
||||
}
|
||||
|
||||
public static Date StringToDate(String dataStringa, String formato){
|
||||
Date data = null;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(formato);
|
||||
try {
|
||||
data = sdf.parse(dataStringa);
|
||||
} catch (ParseException e) {
|
||||
log.error("Errore conversione Stringa in Data :"+e.getMessage());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// metodi per il calcolo di giorno, mens e anno corrente
|
||||
public static String getGiorniDelMeseCorrente(){
|
||||
// passando a JDK 1.5 utilizzare il metodo isLeapYear per verificare l'anno bisestile
|
||||
final int[] GIORNI_IN_MESE = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
GregorianCalendar gregorianCalendar = new GregorianCalendar();
|
||||
return ""+GIORNI_IN_MESE[gregorianCalendar.get(Calendar.MONTH)];
|
||||
}
|
||||
|
||||
public static String getMeseCorrente(){
|
||||
GregorianCalendar gregorianCalendar = new GregorianCalendar();
|
||||
int meseCorrente = gregorianCalendar.get(Calendar.MONTH) + 1;
|
||||
|
||||
return strLeftFill("00", new Integer(meseCorrente).toString());
|
||||
}
|
||||
|
||||
public static String getAnnoCorrente(){
|
||||
GregorianCalendar gregorianCalendar = new GregorianCalendar();
|
||||
int annoCorrente = gregorianCalendar.get(Calendar.YEAR);
|
||||
|
||||
return new Integer(annoCorrente).toString();
|
||||
}
|
||||
|
||||
// metodi per il calcolo di una data relativa al mese corrente
|
||||
public static String getDataInizioMeseCorrente(){
|
||||
return "01" + "/" + getMeseCorrente() + "/" + getAnnoCorrente();
|
||||
}
|
||||
|
||||
public static String getDataFineMeseCorrente(){
|
||||
return getGiorniDelMeseCorrente() + "/" + getMeseCorrente() + "/" + getAnnoCorrente();
|
||||
}
|
||||
|
||||
|
||||
// metodi per il calcolo di una data relativa al mese precedente
|
||||
public static String getDataInizioMesePrecedente(){
|
||||
|
||||
final int[] GIORNI_IN_MESE = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
int anno = -1;
|
||||
int mese = -1;
|
||||
int mesePrecedente = -1;
|
||||
int giorniDelMese = -1;
|
||||
|
||||
GregorianCalendar gregorianCalendar = new GregorianCalendar();
|
||||
int annoCorrente = gregorianCalendar.get(Calendar.YEAR);
|
||||
int meseCorrente = gregorianCalendar.get(Calendar.MONTH);
|
||||
|
||||
if(meseCorrente==0){
|
||||
anno = annoCorrente-1;
|
||||
mese = 12;
|
||||
giorniDelMese = GIORNI_IN_MESE[11];
|
||||
} else {
|
||||
anno = annoCorrente;
|
||||
mesePrecedente = meseCorrente-1;
|
||||
if(mesePrecedente==0){
|
||||
mese = 1;
|
||||
} else{
|
||||
mese = meseCorrente;
|
||||
}
|
||||
giorniDelMese = GIORNI_IN_MESE[mesePrecedente];
|
||||
}
|
||||
return "01" + "/" + strLeftFill("00", ""+mese) + "/" + anno;
|
||||
|
||||
}
|
||||
|
||||
public static String getDataFineMesePrecedente(){
|
||||
|
||||
final int[] GIORNI_IN_MESE = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
int anno = -1;
|
||||
int mese = -1;
|
||||
int mesePrecedente = -1;
|
||||
int giorniDelMese = -1;
|
||||
|
||||
GregorianCalendar gregorianCalendar = new GregorianCalendar();
|
||||
int annoCorrente = gregorianCalendar.get(Calendar.YEAR);
|
||||
int meseCorrente = gregorianCalendar.get(Calendar.MONTH);
|
||||
|
||||
if(meseCorrente==0){
|
||||
anno = annoCorrente-1;
|
||||
mese = 12;
|
||||
giorniDelMese = GIORNI_IN_MESE[11];
|
||||
} else {
|
||||
anno = annoCorrente;
|
||||
mesePrecedente = meseCorrente-1;
|
||||
if(mesePrecedente==0){
|
||||
mese = 1;
|
||||
} else{
|
||||
mese = meseCorrente;
|
||||
}
|
||||
giorniDelMese = GIORNI_IN_MESE[mesePrecedente];
|
||||
}
|
||||
return giorniDelMese + "/" + strLeftFill("00", ""+mese) + "/" + anno;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
package it.valueteam.dbcgo.utility;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class JavaUtilsClass {
|
||||
static Logger log = Logger.getLogger(JavaUtilsClass.class.getName());
|
||||
public Integer stringToInteger(String str){
|
||||
|
||||
// valore di default
|
||||
Integer valore = new Integer(0);
|
||||
|
||||
// verifico che la stringa non sia nulla o vuota
|
||||
String strAppo = str.trim();
|
||||
if("".equals(strAppo) || strAppo == null){
|
||||
return valore;
|
||||
} else {
|
||||
valore = new Integer(str);
|
||||
return valore;
|
||||
}
|
||||
}
|
||||
|
||||
public String IntegerToString(Integer intero){
|
||||
|
||||
// valore di default
|
||||
String valore = "";
|
||||
|
||||
// verifico che la stringa non sia nulla
|
||||
if(intero!=null){
|
||||
valore = intero.toString();
|
||||
}
|
||||
return valore;
|
||||
}
|
||||
|
||||
public String DateToString(Date data, String formato){
|
||||
|
||||
Date dataInLavorazione = null;
|
||||
Date dataCorrente = new Date();
|
||||
|
||||
if(data!=null){
|
||||
dataInLavorazione = data;
|
||||
} else {
|
||||
dataInLavorazione = dataCorrente;
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(formato);
|
||||
return sdf.format(dataInLavorazione);
|
||||
}
|
||||
|
||||
public Date StringToDate(String dataStringa, String formato){
|
||||
Date data = null;
|
||||
if (dataStringa == null || dataStringa.trim().length() == 0) return null;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(formato);
|
||||
try {
|
||||
data = sdf.parse(dataStringa);
|
||||
} catch (ParseException e) {
|
||||
log.error("Errore conversione Stringa in Data :"+e.getMessage());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public int selettoreOpzioni(String opt1, String opt2){
|
||||
|
||||
final int OPZIONE_ZERO = 0;
|
||||
final int OPZIONE_UNO = 1;
|
||||
final int OPZIONE_DUE = 2;
|
||||
final int OPZIONE_DOPPIA = 9;
|
||||
|
||||
int valore = 0;
|
||||
if("".equalsIgnoreCase(opt1) && "".equalsIgnoreCase(opt2)){
|
||||
valore = OPZIONE_ZERO;
|
||||
} else if(!"".equalsIgnoreCase(opt1) && "".equalsIgnoreCase(opt2)){
|
||||
valore = OPZIONE_UNO;
|
||||
} else if("".equalsIgnoreCase(opt1) && !"".equalsIgnoreCase(opt2)){
|
||||
valore = OPZIONE_DUE;
|
||||
} else if(!"".equalsIgnoreCase(opt1) && !"".equalsIgnoreCase(opt2)) {
|
||||
valore = OPZIONE_DOPPIA;
|
||||
}
|
||||
return valore;
|
||||
}
|
||||
|
||||
|
||||
// converte un orario (HH:MM) negli equivalenti secondi
|
||||
public Integer generaSecondi(String ora, String minuti){
|
||||
|
||||
int intOra = Integer.parseInt(ora);
|
||||
int intMinuti = Integer.parseInt(minuti);
|
||||
|
||||
int oraInSecondi = intOra * 3600;
|
||||
int oraInMinuti = intMinuti * 60;
|
||||
|
||||
int orarioInSecondi = oraInSecondi + oraInMinuti;
|
||||
return new Integer(orarioInSecondi);
|
||||
}
|
||||
|
||||
// converte orario espresso in secondi -> ore
|
||||
public String generaOra(Integer orarioInSecondi){
|
||||
|
||||
int intOra = orarioInSecondi.intValue()/3600;
|
||||
return new Integer(intOra).toString();
|
||||
}
|
||||
|
||||
// converte orario espresso in secondi -> restanti minuti
|
||||
public String generaMinuti(Integer orarioInSecondi){
|
||||
|
||||
BigInteger unOraInSecondi = new BigInteger("3600");
|
||||
String oraInSecondi = orarioInSecondi.toString();
|
||||
|
||||
BigInteger orario = new BigInteger(oraInSecondi);
|
||||
BigInteger minutiInSecondi = orario.mod(unOraInSecondi);
|
||||
|
||||
int intMinuti = minutiInSecondi.intValue()/60;
|
||||
return new Integer(intMinuti).toString();
|
||||
}
|
||||
|
||||
|
||||
public String getOra(String orario){
|
||||
StringTokenizer st = new StringTokenizer(orario, ":");
|
||||
String ora = st.nextToken();
|
||||
return ora;
|
||||
}
|
||||
|
||||
public String getMinuti(String orario){
|
||||
StringTokenizer st = new StringTokenizer(orario, ":");
|
||||
String ora = st.nextToken();
|
||||
String minuti = st.nextToken();
|
||||
return minuti;
|
||||
}
|
||||
|
||||
//semplice somma di array unisce due array.
|
||||
public String[] sommaDiArray(String[] a, String[] b){
|
||||
String[] c = new String[a.length+b.length];
|
||||
int i = 0;
|
||||
for(;i<a.length;i++ ){
|
||||
c[i] = a[i];
|
||||
}
|
||||
int d = 0;
|
||||
for(;d<b.length;d++){
|
||||
c[i] = b[d];
|
||||
i++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public boolean isPresent(String[] array,String id){
|
||||
for (int i=0;i<array.length;i++){
|
||||
if (array[i].equalsIgnoreCase(id)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String intArrayToString(Integer[] array){
|
||||
String stringa= "";
|
||||
for (int i=0;i<array.length;i++){
|
||||
stringa+=String.valueOf(array[i]);
|
||||
}
|
||||
return stringa;
|
||||
}
|
||||
|
||||
//accetta in ingresso una data in formato stringa gg/mm/aaaa
|
||||
//restituisce una stringa es: Lunedi, 3 Marzo 2008
|
||||
public String getGiornoSettimana(String data){
|
||||
GregorianCalendar cal = new GregorianCalendar(
|
||||
Integer.parseInt(data.substring(6)),
|
||||
Integer.parseInt(data.substring(3, 5))-1,
|
||||
Integer.parseInt(data.substring(0, 2)));
|
||||
String giorno = "";
|
||||
String mese = "";
|
||||
|
||||
switch (cal.get(Calendar.DAY_OF_WEEK)){
|
||||
case Calendar.SUNDAY: giorno = "Domenica";
|
||||
break;
|
||||
case Calendar.MONDAY: giorno = "Luned<EFBFBD>";
|
||||
break;
|
||||
case Calendar.TUESDAY: giorno = "Marted<EFBFBD>";
|
||||
break;
|
||||
case Calendar.WEDNESDAY: giorno = "Mercoled<EFBFBD>";
|
||||
break;
|
||||
case Calendar.THURSDAY: giorno = "Gioved<EFBFBD>";
|
||||
break;
|
||||
case Calendar.FRIDAY: giorno = "Venerd<EFBFBD>";
|
||||
break;
|
||||
case Calendar.SATURDAY: giorno = "Sabato";
|
||||
break;
|
||||
}
|
||||
//mesi
|
||||
switch (cal.get(Calendar.MONTH)){
|
||||
case Calendar.JANUARY: mese = "Gennaio";
|
||||
break;
|
||||
case Calendar.FEBRUARY: mese = "Febbraio";
|
||||
break;
|
||||
case Calendar.MARCH: mese = "Marzo";
|
||||
break;
|
||||
case Calendar.APRIL: mese = "Aprile";
|
||||
break;
|
||||
case Calendar.MAY: mese = "Maggio";
|
||||
break;
|
||||
case Calendar.JUNE: mese = "Giugno";
|
||||
break;
|
||||
case Calendar.JULY: mese = "Luglio";
|
||||
break;
|
||||
case Calendar.AUGUST: mese = "Agosto";
|
||||
break;
|
||||
case Calendar.SEPTEMBER: mese = "Settembre";
|
||||
break;
|
||||
case Calendar.OCTOBER: mese = "Ottobre";
|
||||
break;
|
||||
case Calendar.NOVEMBER: mese = "Novembre";
|
||||
break;
|
||||
case Calendar.DECEMBER: mese = "Dicembre";
|
||||
break;
|
||||
}
|
||||
return giorno+", "+data.substring(0, 2)+" "+mese+" "+data.substring(6);
|
||||
}
|
||||
|
||||
//Passando un indice,restituisce un'array di 3 campi contenente la fascia oraria equivalente
|
||||
//il terzo campo contiene un orario interno a quella fascia oraria
|
||||
public String[] getFasciaOraria(String indice){
|
||||
String[] fascia = new String[3];
|
||||
int ind = Integer.parseInt(indice);
|
||||
|
||||
switch (ind) {
|
||||
case 0 : fascia[0]="06:00"; fascia[1]="06:30"; fascia[2]="06:15"; break;
|
||||
case 1 : fascia[0]="06:30"; fascia[1]="07:00"; fascia[2]="06:45"; break;
|
||||
case 2 : fascia[0]="07:00"; fascia[1]="07:30"; fascia[2]="07:10"; break;
|
||||
case 3 : fascia[0]="07:30"; fascia[1]="08:00"; fascia[2]="07:45"; break;
|
||||
case 4 : fascia[0]="08:00"; fascia[1]="08:30"; fascia[2]="08:15"; break;
|
||||
case 5 : fascia[0]="08:30"; fascia[1]="09:00"; fascia[2]="08:45"; break;
|
||||
case 6 : fascia[0]="09:00"; fascia[1]="09:30"; fascia[2]="09:15"; break;
|
||||
case 7 : fascia[0]="09:30"; fascia[1]="10:00"; fascia[2]="09:45"; break;
|
||||
case 8 : fascia[0]="10:00"; fascia[1]="10:30"; fascia[2]="10:15"; break;
|
||||
case 9 : fascia[0]="10:30"; fascia[1]="11:00"; fascia[2]="10:45"; break;
|
||||
case 10 : fascia[0]="11:00"; fascia[1]="11:30"; fascia[2]="11:15"; break;
|
||||
case 11 : fascia[0]="11:30"; fascia[1]="12:00"; fascia[2]="11:45"; break;
|
||||
case 12 : fascia[0]="12:00"; fascia[1]="12:30"; fascia[2]="12:15"; break;
|
||||
case 13 : fascia[0]="12:30"; fascia[1]="13:00"; fascia[2]="12:45"; break;
|
||||
case 14 : fascia[0]="13:00"; fascia[1]="13:30"; fascia[2]="13:15"; break;
|
||||
case 15 : fascia[0]="13:30"; fascia[1]="14:00"; fascia[2]="13:45"; break;
|
||||
case 16 : fascia[0]="14:00"; fascia[1]="14:30"; fascia[2]="14:15"; break;
|
||||
case 17 : fascia[0]="14:30"; fascia[1]="15:00"; fascia[2]="14:45"; break;
|
||||
case 18 : fascia[0]="15:00"; fascia[1]="15:30"; fascia[2]="15:15"; break;
|
||||
case 19 : fascia[0]="15:30"; fascia[1]="16:00"; fascia[2]="15:45"; break;
|
||||
case 20 : fascia[0]="16:00"; fascia[1]="16:30"; fascia[2]="16:15"; break;
|
||||
case 21 : fascia[0]="16:30"; fascia[1]="17:00"; fascia[2]="16:45"; break;
|
||||
case 22 : fascia[0]="17:00"; fascia[1]="17:30"; fascia[2]="17:15"; break;
|
||||
case 23 : fascia[0]="17:30"; fascia[1]="18:00"; fascia[2]="17:45"; break;
|
||||
case 24 : fascia[0]="18:00"; fascia[1]="18:30"; fascia[2]="18:15"; break;
|
||||
case 25 : fascia[0]="18:30"; fascia[1]="19:00"; fascia[2]="18:45"; break;
|
||||
case 26 : fascia[0]="19:00"; fascia[1]="19:30"; fascia[2]="19:15"; break;
|
||||
case 27 : fascia[0]="19:30"; fascia[1]="20:00"; fascia[2]="19:45"; break;
|
||||
case 28 : fascia[0]="20:00"; fascia[1]="20:30"; fascia[2]="20:15"; break;
|
||||
case 29 : fascia[0]="20:30"; fascia[1]="21:00"; fascia[2]="20:45"; break;
|
||||
case 30 : fascia[0]="21:00"; fascia[1]="21:30"; fascia[2]="21:15"; break;
|
||||
case 31 : fascia[0]="21:30"; fascia[1]="22:00"; fascia[2]="21:45"; break;
|
||||
case 32 : fascia[0]="22:00"; fascia[1]="22:30"; fascia[2]="22:15"; break;
|
||||
case 33 : fascia[0]="22:30"; fascia[1]="23:00"; fascia[2]="22:45"; break;
|
||||
case 34 : fascia[0]="23:00"; fascia[1]="23:30"; fascia[2]="23:15"; break;
|
||||
case 35 : fascia[0]="23:30"; fascia[1]="24:00"; fascia[2]="23:45"; break;
|
||||
|
||||
default : fascia[0]="06:00"; fascia[1]="24:00"; fascia[2]="06:30"; break;
|
||||
}
|
||||
return fascia;
|
||||
}
|
||||
|
||||
//ritorna l'indice corrispondete all'ora in input, se l'ora <20> quella di fine (destro=true)
|
||||
public int getIndiceByFasciaOraria(String inizio, boolean destro){
|
||||
int indice = 0;
|
||||
|
||||
if ("06:00".equals(inizio) && !destro) indice = 0;
|
||||
else if ("06:00".equals(inizio) && destro) indice = 0;
|
||||
if ("06:30".equals(inizio) && !destro) indice = 1;
|
||||
else if ("06:30".equals(inizio) && destro) indice = 0;
|
||||
if ("07:00".equals(inizio) && !destro) indice = 2;
|
||||
else if ("07:00".equals(inizio) && destro) indice = 1;
|
||||
if ("07:30".equals(inizio) && !destro) indice = 3;
|
||||
else if ("07:30".equals(inizio) && destro) indice = 2;
|
||||
if ("08:00".equals(inizio) && !destro) indice = 4;
|
||||
else if ("08:00".equals(inizio) && destro) indice = 3;
|
||||
if ("08:30".equals(inizio) && !destro) indice = 5;
|
||||
else if ("08:30".equals(inizio) && destro) indice = 4;
|
||||
if ("09:00".equals(inizio) && !destro) indice = 6;
|
||||
else if ("09:00".equals(inizio) && destro) indice = 5;
|
||||
if ("09:30".equals(inizio) && !destro) indice = 7;
|
||||
else if ("09:30".equals(inizio) && destro) indice = 6;
|
||||
if ("10:00".equals(inizio) && !destro) indice = 8;
|
||||
else if ("10:00".equals(inizio) && destro) indice = 7;
|
||||
if ("10:30".equals(inizio) && !destro) indice = 9;
|
||||
else if ("10:30".equals(inizio) && destro) indice = 8;
|
||||
if ("11:00".equals(inizio) && !destro) indice = 10;
|
||||
else if ("11:00".equals(inizio) && destro) indice = 9;
|
||||
if ("11:30".equals(inizio) && !destro) indice = 11;
|
||||
else if ("11:30".equals(inizio) && destro) indice = 10;
|
||||
if ("12:00".equals(inizio) && !destro) indice = 12;
|
||||
else if ("12:00".equals(inizio) && destro) indice = 11;
|
||||
if ("12:30".equals(inizio) && !destro) indice = 13;
|
||||
else if ("12:30".equals(inizio) && destro) indice = 12;
|
||||
if ("13:00".equals(inizio) && !destro) indice = 14;
|
||||
else if ("13:00".equals(inizio) && destro) indice = 13;
|
||||
if ("13:30".equals(inizio) && !destro) indice = 15;
|
||||
else if ("13:30".equals(inizio) && destro) indice = 14;
|
||||
if ("14:00".equals(inizio) && !destro) indice = 16;
|
||||
else if ("14:00".equals(inizio) && destro) indice = 15;
|
||||
if ("14:30".equals(inizio) && !destro) indice = 17;
|
||||
else if ("14:30".equals(inizio) && destro) indice = 16;
|
||||
if ("15:00".equals(inizio) && !destro) indice = 18;
|
||||
else if ("15:00".equals(inizio) && destro) indice = 17;
|
||||
if ("15:30".equals(inizio) && !destro) indice = 19;
|
||||
else if ("15:30".equals(inizio) && destro) indice = 18;
|
||||
if ("16:00".equals(inizio) && !destro) indice = 20;
|
||||
else if ("16:00".equals(inizio) && destro) indice = 19;
|
||||
if ("16:30".equals(inizio) && !destro) indice = 21;
|
||||
else if ("16:30".equals(inizio) && destro) indice = 20;
|
||||
if ("17:00".equals(inizio) && !destro) indice = 22;
|
||||
else if ("17:00".equals(inizio) && destro) indice = 21;
|
||||
if ("17:30".equals(inizio) && !destro) indice = 23;
|
||||
else if ("17:30".equals(inizio) && destro) indice = 22;
|
||||
if ("18:00".equals(inizio) && !destro) indice = 24;
|
||||
else if ("18:00".equals(inizio) && destro) indice = 23;
|
||||
if ("18:30".equals(inizio) && !destro) indice = 25;
|
||||
else if ("18:30".equals(inizio) && destro) indice = 24;
|
||||
if ("19:00".equals(inizio) && !destro) indice = 26;
|
||||
else if ("19:00".equals(inizio) && destro) indice = 25;
|
||||
if ("19:30".equals(inizio) && !destro) indice = 27;
|
||||
else if ("19:30".equals(inizio) && destro) indice = 26;
|
||||
if ("20:00".equals(inizio) && !destro) indice = 28;
|
||||
else if ("20:00".equals(inizio) && destro) indice = 27;
|
||||
if ("20:30".equals(inizio) && !destro) indice = 29;
|
||||
else if ("20:30".equals(inizio) && destro) indice = 28;
|
||||
if ("21:00".equals(inizio) && !destro) indice = 30;
|
||||
else if ("21:00".equals(inizio) && destro) indice = 29;
|
||||
if ("21:30".equals(inizio) && !destro) indice = 31;
|
||||
else if ("21:30".equals(inizio) && destro) indice = 30;
|
||||
if ("22:00".equals(inizio) && !destro) indice = 32;
|
||||
else if ("22:00".equals(inizio) && destro) indice = 31;
|
||||
if ("22:30".equals(inizio) && !destro) indice = 33;
|
||||
else if ("22:30".equals(inizio) && destro) indice = 32;
|
||||
if ("23:00".equals(inizio) && !destro) indice = 34;
|
||||
else if ("23:00".equals(inizio) && destro) indice = 33;
|
||||
if ("23:30".equals(inizio) && !destro) indice = 35;
|
||||
else if ("23:30".equals(inizio) && destro) indice = 34;
|
||||
if ("24:00".equals(inizio) && !destro) indice = 0;
|
||||
else if ("24:00".equals(inizio) && destro) indice = 35;
|
||||
return indice;
|
||||
}
|
||||
/**
|
||||
* Metodo per aggiungere giorni solari alla data passata in input (formato yyyy-MM-dd)
|
||||
* @param inputDate
|
||||
* @param numGiorni
|
||||
* @return
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
public String aggiungiGiorniSolari(String inputDate, int numGiorni) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
java.util.Date data = StringToDate(inputDate,"dd/MM/yyyy");
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
//Calendario impostato alla data in input
|
||||
calendar.setTime(data);
|
||||
//Giorni aggiunti
|
||||
calendar.add(calendar.DAY_OF_MONTH, numGiorni);
|
||||
// System.out.println("DATA: " + calendar.getTime());
|
||||
return DateToString(calendar.getTime(),"dd/MM/yyyy");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public static long differenzaGiorni(Date dataInizio, Date dataFine) {
|
||||
Calendar inizio = Calendar.getInstance();
|
||||
inizio.setTime(dataInizio);
|
||||
Calendar fine = Calendar.getInstance();
|
||||
fine.setTime(dataFine);
|
||||
long inizioMillisecondi = inizio.getTimeInMillis();
|
||||
long fineMillisecondi = fine.getTimeInMillis();
|
||||
long differenzaMillisecondi = fineMillisecondi - inizioMillisecondi;
|
||||
|
||||
// 1 giorno = 1000*60*60*24 ms = 86400000 ms
|
||||
long giorniFraDueDate = Math.round(differenzaMillisecondi / 86400000.0);
|
||||
|
||||
return giorniFraDueDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package it.valueteam.dbcgo.utility;
|
||||
|
||||
import it.valueteam.dbcgo.business.RecipientVirtMvnoBusiness;
|
||||
import it.valueteam.dbcgo.utility.DynaWorkForm.OggettoDyna;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.hibernate.criterion.LogicalExpression;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
public class RestrictionBuilder {
|
||||
private Vector vlist = new Vector();
|
||||
private JavaUtilsClass juc = new JavaUtilsClass();
|
||||
//static Logger log = Logger.getLogger(RestrictionBuilder.class.getName());
|
||||
public RestrictionBuilder(Vector _vlist){
|
||||
vlist = _vlist;
|
||||
//getCriteria();
|
||||
}
|
||||
/**
|
||||
* Il metodo costruisce a partire dai dati provenienti dal form,
|
||||
* l'associazione tra operatore logico valore e proprietà.
|
||||
* In tal modo è possibile centralizzare la produzione dei criteria
|
||||
* per la query Hibernate
|
||||
* @return
|
||||
*/
|
||||
public ArrayList getCriteria(){
|
||||
ArrayList criterion = new ArrayList();
|
||||
String valorePCNCodProfTariff = "U";
|
||||
String descProfTariffProp = "codProfiloTariffarioDesc";
|
||||
String descProfTariffValue = "RICARICABILE BUSINESS";
|
||||
String valorePCNabbPrep = "D";
|
||||
String valoreCodRifiutoValidazione = "99";
|
||||
for (int i=0;i<vlist.size();i++) {
|
||||
OggettoDyna oDyna = (OggettoDyna)vlist.get(i);
|
||||
String prop = oDyna.getChiave();
|
||||
|
||||
if (prop.indexOf("_operatore_logico")==-1 && prop.indexOf("_dataa")==-1 && prop.indexOf("_datada")==-1 && prop.indexOf("_datail")==-1
|
||||
&& !prop.equals("codProfiloTariffario") && !prop.equals("abbonatoPrepagato") && !prop.equals("codicerifiutovalidazione")&& !prop.equals("donorEffettivo")&& !prop.equals("tipoProcessoSla") && !prop.equals("donEffettivoBis") && !prop.equals("percentualeFuoriSla") && !prop.equals("trasferimentoConSblocco")
|
||||
&& !prop.equals("processoFr")){
|
||||
//non sono presenti valori per criteri complessi.
|
||||
Object valore = "";
|
||||
if (oDyna.getValore()!=null) {
|
||||
valore = (String)oDyna.getValore();
|
||||
} else {
|
||||
valore = oDyna.getValoreLong();
|
||||
}
|
||||
//controllo se vi sia un criterio di uguale o disuguale
|
||||
String operatore_logico = (String)getValue(prop+"_operatore_logico");
|
||||
int op_logic = new Integer(operatore_logico).intValue();
|
||||
|
||||
switch (op_logic){
|
||||
case 1:
|
||||
// =
|
||||
if (valore.getClass().equals(java.lang.String.class)) {
|
||||
String _valore = (String)valore;
|
||||
criterion.add(Restrictions.eq(prop, _valore));
|
||||
} else {
|
||||
criterion.add(Restrictions. eq(prop, valore));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// !=
|
||||
criterion.add(Restrictions.ne(prop, valore));
|
||||
break;
|
||||
case 3:
|
||||
//%
|
||||
criterion.add(Restrictions.like(prop, "%"+valore+";%"));
|
||||
break;
|
||||
case 4:
|
||||
criterion.add(Restrictions.eq(prop, valore));
|
||||
break;
|
||||
case 5:
|
||||
//not like
|
||||
/**
|
||||
* serve per includere anche i valori nulli nella query del not like
|
||||
*/
|
||||
Criterion _firstCrit = Restrictions.not(Restrictions.like(prop, "%"+valore+";%"));
|
||||
Criterion _nullClause = Restrictions.isNull(prop);
|
||||
LogicalExpression orExp = Restrictions.or(_firstCrit,_nullClause);
|
||||
criterion.add(orExp);
|
||||
break;
|
||||
case 0:
|
||||
criterion.add(Restrictions.eq(prop, valore));
|
||||
break;
|
||||
}
|
||||
} else if(prop.indexOf("_dataa")==-1 && prop.indexOf("_datada")!=-1){
|
||||
|
||||
String dataa = null;
|
||||
String valore = oDyna.getValore();
|
||||
String _prop = prop.replaceAll("_datada", "");
|
||||
String operatore_logico =(String) getValue(_prop+"_operatore_logico");
|
||||
Date dDate = juc.StringToDate(valore,"dd/MM/yyyy");
|
||||
int op_logic = new Integer(operatore_logico).intValue();
|
||||
|
||||
switch (op_logic){
|
||||
case 1:
|
||||
// =
|
||||
criterion.add(Restrictions.ge(_prop, dDate));
|
||||
//log.info("*** "+_prop+" >= "+dDate.toString());
|
||||
dataa = (String)getValue(_prop+"_dataa");
|
||||
if (!dataa.equals("4")){
|
||||
String dataPiuUno=dataa;
|
||||
try{
|
||||
dataPiuUno= juc.aggiungiGiorniSolari(dataa,1) ;
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
dDate=juc.StringToDate(dataPiuUno,"dd/MM/yyyy");
|
||||
criterion.add(Restrictions.lt(_prop, dDate));
|
||||
//log.info("*** "+_prop+" <= "+dDate.toString());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// !=
|
||||
criterion.add(Restrictions.le(_prop, dDate)); //TODO alescar secondo me è sbajato?
|
||||
dataa = (String)getValue(_prop+"_dataa");
|
||||
if (!dataa.equals("4")){
|
||||
String dataPiuUno=dataa;
|
||||
try{
|
||||
dataPiuUno= juc.aggiungiGiorniSolari(dataa, 1) ;
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
dDate=juc.StringToDate(dataPiuUno,"dd/MM/yyyy");
|
||||
criterion.add(Restrictions.lt(_prop, dDate));
|
||||
//log.info("*** "+_prop+" < "+dDate.toString());
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
//nulla
|
||||
break;
|
||||
|
||||
}
|
||||
} /*else if(prop.indexOf("_dataa")!=-1 && prop.indexOf("_datada")==-1){
|
||||
String datada = null;
|
||||
String valore = oDyna.getValore();
|
||||
String _prop = prop.replaceAll("_dataa", "");
|
||||
datada = (String)getValue(_prop+"_datada");
|
||||
log.info("CASO 2 datada="+datada);
|
||||
if (datada.equals("4")){
|
||||
String operatore_logico = (String)getValue(_prop+"_operatore_logico");
|
||||
Date dDate;
|
||||
|
||||
int op_logic = new Integer(operatore_logico).intValue();
|
||||
switch (op_logic){
|
||||
case 1:
|
||||
// = y");
|
||||
Date dataPiuUno=juc.StringToDate(valore,"dd/MM/yyyy");
|
||||
try{
|
||||
dataPiuUno= juc.aggiungiGiorniSolari(juc.StringToDate(valore,"dd/MM/yyyy"), 1) ;
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
criterion.add(Restrictions.le(_prop, dataPiuUno));
|
||||
log.info("*** "+_prop+" <= "+dataPiuUno.toString());
|
||||
break;
|
||||
case 2:
|
||||
// !=
|
||||
dDate= juc.StringToDate(valore,"dd/MM/yyyy");
|
||||
criterion.add(Restrictions.ge(_prop, dDate));
|
||||
log.info("*** "+_prop+" >= "+dDate.toString());
|
||||
break;
|
||||
case 4:
|
||||
//nulla
|
||||
break;
|
||||
}
|
||||
}
|
||||
} */else if (prop.indexOf("_datail")!=-1) {
|
||||
String datada = null;
|
||||
String valore = oDyna.getValore();
|
||||
String _prop = prop.replaceAll("_datail", "");
|
||||
datada = (String)getValue(_prop+"_datada");
|
||||
if (datada.equals("4")){
|
||||
String operatore_logico = (String)getValue(_prop+"_operatore_logico");
|
||||
Date dDate = juc.StringToDate(valore,"dd/MM/yyyy");
|
||||
int op_logic = new Integer(operatore_logico).intValue();
|
||||
switch (op_logic){
|
||||
case 1:
|
||||
// =
|
||||
criterion.add(Restrictions.eq(_prop, dDate));
|
||||
break;
|
||||
case 2:
|
||||
// !=
|
||||
criterion.add(Restrictions.ne(_prop, dDate));
|
||||
break;
|
||||
case 4:
|
||||
//nulla
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else if (prop.equals("codProfiloTariffario")) {
|
||||
String valore = oDyna.getValore();
|
||||
if (valore.equals(valorePCNCodProfTariff)) {
|
||||
criterion.add(Restrictions.and(Restrictions.eq(prop, oDyna.getValore()),
|
||||
Restrictions.eq(descProfTariffProp, descProfTariffValue)));
|
||||
} else {
|
||||
Criterion _firstCrit = Restrictions.ne(prop, valorePCNCodProfTariff);
|
||||
Criterion _nullClause = Restrictions.isNull(prop);
|
||||
LogicalExpression orExp = Restrictions.or(_firstCrit,_nullClause);
|
||||
criterion.add(orExp);
|
||||
}
|
||||
} else if (prop.equals("abbonatoPrepagato")) {
|
||||
String valore = oDyna.getValore();
|
||||
|
||||
|
||||
if (valore.equals(valorePCNabbPrep)) {
|
||||
criterion.add(Restrictions.eq(prop, oDyna.getValore()));
|
||||
} else {
|
||||
Criterion _firstCrit = Restrictions.ne(prop, valorePCNabbPrep);
|
||||
Criterion _nullClause = Restrictions.isNull(prop);
|
||||
LogicalExpression orExp = Restrictions.or(_firstCrit,_nullClause);
|
||||
criterion.add(orExp);
|
||||
}
|
||||
} else if (prop.equals("codicerifiutovalidazione")) {
|
||||
String valore = oDyna.getValore();
|
||||
|
||||
if (!valore.equals(valoreCodRifiutoValidazione)) {
|
||||
criterion.add(Restrictions.eq(prop, oDyna.getValore()));
|
||||
}
|
||||
}
|
||||
else if(prop.equals("donorEffettivo")){
|
||||
String valore = oDyna.getValore();
|
||||
if(valore.equalsIgnoreCase("TIMG")){
|
||||
Criterion _firstCrit = Restrictions.eq(prop, valore);
|
||||
Criterion _secCrit = Restrictions.eq("terzaParte", valore);
|
||||
LogicalExpression orExp = Restrictions.or(_firstCrit,_secCrit);
|
||||
criterion.add(orExp);
|
||||
}
|
||||
else {
|
||||
criterion.add(Restrictions.eq(prop,valore));
|
||||
}
|
||||
}else if(prop.equals("donEffettivoBis")){
|
||||
String valore = oDyna.getValore();
|
||||
criterion.add(Restrictions.eq("donorEffettivo",valore));
|
||||
}else if(prop.equals("tipoProcessoSla")){
|
||||
String valore = oDyna.getValore();
|
||||
Criterion _firstCrit = Restrictions.eq("tipoProcesso", valore);
|
||||
Criterion _secCrit = Restrictions.eq("tipoProcesso", "V");
|
||||
LogicalExpression orExp = Restrictions.or(_firstCrit,_secCrit);
|
||||
criterion.add(orExp);
|
||||
}else if(prop.equals("processoFr")){
|
||||
String valore = oDyna.getValore();
|
||||
Criterion _firstCrit = Restrictions.eq("processo", valore);
|
||||
Criterion _secCrit = Restrictions.eq("processo", "V");
|
||||
LogicalExpression orExp = Restrictions.or(_firstCrit,_secCrit);
|
||||
criterion.add(orExp);
|
||||
}
|
||||
else if(prop.equals("trasferimentoConSblocco")){
|
||||
String valore = oDyna.getValore();
|
||||
if(valore.equalsIgnoreCase("NULL")){
|
||||
criterion.add(Restrictions.isNull(prop));
|
||||
}else {
|
||||
criterion.add(Restrictions.eq(prop,valore));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return criterion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Questo metodo restituisce il tipo di operatore logico
|
||||
* equivalente. Se nessun operatore è stato selezionato oppure non è previsto
|
||||
* torna il valore 4 che viene gestito dal getCriteria() come do nothing
|
||||
* @param _prop
|
||||
* @return
|
||||
*/
|
||||
public Object getValue (String _prop){
|
||||
Object _value = "4";
|
||||
for (int i = 0; i<vlist.size();i++){
|
||||
OggettoDyna oDyna = (OggettoDyna)vlist.get(i);
|
||||
if (oDyna.getChiave().equals(_prop)) {
|
||||
if (oDyna.getValore()!=null) {
|
||||
return _value = oDyna.getValore();
|
||||
} else {
|
||||
return _value = oDyna.getValoreLong();
|
||||
}
|
||||
}
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package it.valueteam.dbcgo.utility.agcom;
|
||||
|
||||
import it.valueteam.dbcgo.dao.report.CapacitaEvasione;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import jxl.CellView;
|
||||
import jxl.Workbook;
|
||||
import jxl.format.Alignment;
|
||||
import jxl.format.Colour;
|
||||
import jxl.format.UnderlineStyle;
|
||||
import jxl.format.VerticalAlignment;
|
||||
import jxl.format.Border;
|
||||
import jxl.format.BorderLineStyle;
|
||||
import jxl.write.Label;
|
||||
import jxl.write.Number;
|
||||
import jxl.write.NumberFormats;
|
||||
import jxl.write.WritableCellFormat;
|
||||
import jxl.write.WritableFont;
|
||||
import jxl.write.WritableSheet;
|
||||
import jxl.write.WritableWorkbook;
|
||||
import jxl.write.WriteException;
|
||||
import jxl.write.biff.RowsExceededException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class CapacitaEvasioneExcelUtils {
|
||||
|
||||
Logger logger = Logger.getLogger(CapacitaEvasioneExcelUtils.class);
|
||||
|
||||
private static String NOME_FOGLIO = "Report mensile capacità";
|
||||
|
||||
private WritableCellFormat headerFormat;
|
||||
private WritableFont headerFont;
|
||||
private WritableCellFormat tableHeaderFormat;
|
||||
private WritableFont tableHeaderFont;
|
||||
private WritableCellFormat tableBodyFormat;
|
||||
private WritableFont tableBodyFont;
|
||||
|
||||
private CapacitaEvasione risultato;
|
||||
|
||||
public CapacitaEvasioneExcelUtils() {
|
||||
super();
|
||||
try {
|
||||
headerFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.WHITE);
|
||||
headerFormat = new WritableCellFormat(headerFont);
|
||||
headerFormat.setBackground(Colour.DARK_BLUE);
|
||||
headerFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
|
||||
|
||||
tableHeaderFont = new WritableFont(WritableFont.ARIAL, 9, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
|
||||
tableHeaderFormat = new WritableCellFormat(tableHeaderFont);
|
||||
tableHeaderFormat.setBackground(Colour.LIGHT_GREEN);
|
||||
tableHeaderFormat.setAlignment(Alignment.CENTRE);
|
||||
tableHeaderFormat.setWrap(true);
|
||||
tableHeaderFormat.setVerticalAlignment(VerticalAlignment.TOP);
|
||||
tableHeaderFormat.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
|
||||
|
||||
tableBodyFont = new WritableFont(WritableFont.ARIAL, 9, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
|
||||
tableBodyFormat = new WritableCellFormat(tableBodyFont, NumberFormats.THOUSANDS_INTEGER);
|
||||
tableBodyFormat.setBackground(Colour.LIGHT_GREEN);
|
||||
tableBodyFormat.setAlignment(Alignment.CENTRE);
|
||||
tableBodyFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
|
||||
tableBodyFormat.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
|
||||
|
||||
} catch (WriteException e) {
|
||||
logger.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] generaExcel(CapacitaEvasione risultato) {
|
||||
ByteArrayOutputStream baos = null;
|
||||
try {
|
||||
baos = new ByteArrayOutputStream();
|
||||
WritableWorkbook w = Workbook.createWorkbook(baos);
|
||||
WritableSheet sheet = w.createSheet(NOME_FOGLIO, 0);
|
||||
|
||||
this.risultato = risultato;
|
||||
|
||||
writeHeader(sheet);
|
||||
writeTableHeader(sheet);
|
||||
writeTableBody(sheet);
|
||||
|
||||
setCellsAutoSize(sheet);
|
||||
|
||||
w.write();
|
||||
w.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
} finally {
|
||||
if (baos != null) {
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta la larghezza delle celle.
|
||||
*
|
||||
* @param sheet
|
||||
*/
|
||||
protected void setCellsAutoSize(WritableSheet sheet) {
|
||||
try {
|
||||
int colNumber = sheet.getColumns();
|
||||
CellView cellView = new CellView();
|
||||
cellView.setSize(4290);
|
||||
|
||||
for (int j = 0; j < colNumber; j++) {
|
||||
sheet.setColumnView(j, cellView); //column
|
||||
}
|
||||
|
||||
cellView.setSize(600);
|
||||
sheet.setRowView(1, cellView); //header
|
||||
|
||||
cellView.setSize(1365);
|
||||
sheet.setRowView(3, cellView); //table header
|
||||
|
||||
cellView.setSize(390);
|
||||
sheet.setRowView(4, cellView); //table body
|
||||
|
||||
} catch (RowsExceededException e) {
|
||||
logger.debug(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void writeHeader(WritableSheet sheet) throws WriteException {
|
||||
logger.debug("Generazione header xls");
|
||||
sheet.addCell(new Label(0, 1, "Donating: Telecom Italia", headerFormat));
|
||||
sheet.mergeCells(0, 1, 1, 1);
|
||||
sheet.addCell(new Label(2, 1, "Periodo: " + risultato.getMesiAndAnno(), headerFormat));
|
||||
sheet.mergeCells(2, 1, 7, 1);
|
||||
}
|
||||
|
||||
private void writeTableHeader(WritableSheet sheet) throws WriteException {
|
||||
logger.debug("Generazione header della tabella xls");
|
||||
sheet.addCell(new Label(0, 3, "Richieste standard ricevute e prese in carico (A)", tableHeaderFormat));
|
||||
sheet.addCell(new Label(1, 3, "Richieste standard ricevute e scartate per wlist (B)", tableHeaderFormat));
|
||||
sheet.addCell(new Label(2, 3, "Richieste standard ricevute e scartate per sospensione per manutenzione programmata (C)", tableHeaderFormat));
|
||||
sheet.addCell(new Label(3, 3, "Totale bimestrale (A+B+C)", tableHeaderFormat));
|
||||
sheet.addCell(new Label(4, 3, "Media bimestrale (A+B+C)/(numero di giorni lavorativi del bimestre)", tableHeaderFormat));
|
||||
sheet.addCell(new Label(5, 3, "Capacità nel periodo", tableHeaderFormat));
|
||||
sheet.addCell(new Label(6, 3, "Valore di guardia nel periodo Capacità max * 0,8 (rounding al centinaio sup.)", tableHeaderFormat));
|
||||
sheet.addCell(new Label(7, 3, "Capacità prossimo mese", tableHeaderFormat));
|
||||
}
|
||||
|
||||
private void writeTableBody(WritableSheet sheet) throws WriteException {
|
||||
logger.debug("Generazione body della tabella xls");
|
||||
sheet.addCell(new Number(0, 4, risultato.getSommaRichiestePreseInCarico() ,tableBodyFormat));
|
||||
sheet.addCell(new Number(1, 4, risultato.getSommaRichiesteScartateWaitList() ,tableBodyFormat));
|
||||
sheet.addCell(new Number(2, 4, risultato.getSommaRichiesteScartateManProgr() ,tableBodyFormat));
|
||||
sheet.addCell(new Number(3, 4, risultato.getTotaleBimestrale() ,tableBodyFormat));
|
||||
sheet.addCell(new Number(4, 4, risultato.getMediaBimestrale() ,tableBodyFormat));
|
||||
sheet.addCell(new Number(5, 4, risultato.getCapacitaPeriodo() ,tableBodyFormat));
|
||||
sheet.addCell(new Number(6, 4, risultato.getValoreDiGuardia() ,tableBodyFormat));
|
||||
sheet.addCell(new Number(7, 4, risultato.getCapacitaProxMese() ,tableBodyFormat));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,871 @@
|
||||
package it.valueteam.dbcgo.utility.penali;
|
||||
|
||||
import it.valueteam.dbcgo.bean.excel.RigaExcelReportSintesi;
|
||||
import it.valueteam.dbcgo.business.CalcoloPenaliBusiness;
|
||||
import it.valueteam.dbcgo.business.GestioneXlsBusiness;
|
||||
import it.valueteam.dbcgo.dao.impl.AnagOperatoriDao;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoProcessoPenali;
|
||||
import jxl.*;
|
||||
import jxl.format.Colour;
|
||||
import jxl.format.Border;
|
||||
import jxl.format.BorderLineStyle;
|
||||
import jxl.write.*;
|
||||
import jxl.write.Number;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class CalcoloPenaliReportSintesiExcelUtils extends ExcelUtils {
|
||||
|
||||
private static final String KEY_EXCELS_INFATTURAZIONE = "KEY_EXCELS_INFATTURAZIONE";
|
||||
private static final String KEY_EXCELS_INCONTESTAZIONE = "KEY_EXCELS_INCONTESTAZIONE";
|
||||
|
||||
public CalcoloPenaliReportSintesiExcelUtils() {
|
||||
super();
|
||||
}
|
||||
|
||||
public byte[] generaReportSintesi(String trimestre, String anno) {
|
||||
ByteArrayOutputStream baos = null;
|
||||
try {
|
||||
AnagOperatoriDao operDao = new AnagOperatoriDao();
|
||||
List operatori = operDao.getListaOperatori();
|
||||
|
||||
baos = new ByteArrayOutputStream();
|
||||
WritableWorkbook w = Workbook.createWorkbook(baos);
|
||||
|
||||
// Scrive il primo foglio SINTESI
|
||||
WritableSheet sheet = w.createSheet(NOME_PRIMO_FOGLIO_REPORT_SINTESI, 0);
|
||||
writeHeaderXlsSintesi(sheet);
|
||||
|
||||
writeBodyXlsSintesi(sheet, operatori, trimestre, anno);
|
||||
//setCellsAutoSize(sheet);
|
||||
/* CellView cv = null;
|
||||
for(int x=0; x < sheet.getColumns(); x++) {
|
||||
cv = sheet.getColumnView(x);
|
||||
cv.setSize(15*256);
|
||||
sheet.setColumnView(x, cv);
|
||||
} */
|
||||
|
||||
// Salva il workbook
|
||||
w.write();
|
||||
w.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (baos != null) {
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
private void writeHeaderXlsSintesi(WritableSheet sheet) throws WriteException {
|
||||
Label cellaAttivo = new Label(3, 0, "ATTIVO", headerFormatSintesi);
|
||||
WritableCellFormat newFormat = new WritableCellFormat(cellaAttivo.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
cellaAttivo.setCellFormat(newFormat);
|
||||
sheet.addCell( cellaAttivo );
|
||||
sheet.mergeCells(3, 0, 14, 0);
|
||||
|
||||
Label cellaPassivo = new Label(15, 0, "PASSIVO", headerFormatSintesi);
|
||||
newFormat = new WritableCellFormat(cellaPassivo.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
cellaPassivo.setCellFormat(newFormat);
|
||||
sheet.addCell( cellaPassivo );
|
||||
sheet.mergeCells(15, 0, 27, 0);
|
||||
|
||||
Label cellaSaldo = new Label(28, 0, "SALDO", headerFormatSintesi);
|
||||
newFormat = new WritableCellFormat(cellaSaldo.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
cellaSaldo.setCellFormat(newFormat);
|
||||
sheet.addCell( cellaSaldo );
|
||||
sheet.mergeCells(28, 0, 39, 0);
|
||||
|
||||
Label cellaPenali = new Label(0, 0, "PENALI MNP/TCR", headerFormatSintesi);
|
||||
newFormat = new WritableCellFormat(cellaPenali.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
cellaPenali.setCellFormat(newFormat);
|
||||
sheet.addCell( cellaPenali );
|
||||
sheet.mergeCells(0, 0, 2, 1);
|
||||
|
||||
// ************ SEZIONE ATTIVO ************ //
|
||||
sheet.addCell(new Label(3,1, "Caricato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(4,1, "Non fatturabile per disservizi", headerFormatSintesi));
|
||||
sheet.addCell(new Label(5,1, "Non fatturabile per franchigia", headerFormatSintesi));
|
||||
sheet.addCell(new Label(6,1, "Non fatturabile per altre causali", headerFormatSintesi));
|
||||
sheet.addCell(new Label(7,1, "Fatturato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(8,1, "Contestato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(9,1, "Contestazione accettata", headerFormatSintesi));
|
||||
sheet.addCell(new Label(10,1, "Contestazione respinta", headerFormatSintesi));
|
||||
sheet.addCell(new Label(11,1, "In verifica", headerFormatSintesi));
|
||||
sheet.addCell(new Label(12,1, "Accettato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(13,1, "Chiuso", headerFormatSintesi));
|
||||
sheet.addCell(new Label(14,1, "Stato", headerFormatSintesi));
|
||||
|
||||
// ************ SEZIONE PASSIVO ************ //
|
||||
sheet.addCell(new Label(15,1, "Caricato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(16,1, "Non fatturabile per disservizi", headerFormatSintesi));
|
||||
sheet.addCell(new Label(17,1, "Non fatturabile per franchigia", headerFormatSintesi));
|
||||
sheet.addCell(new Label(18,1, "Non fatturabile per altre causali", headerFormatSintesi));
|
||||
sheet.addCell(new Label(19,1, "Fatturato stimato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(20,1, "Fatturato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(21,1, "Contestato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(22,1, "Contestazione accettata", headerFormatSintesi));
|
||||
sheet.addCell(new Label(23,1, "Contestazione respinta", headerFormatSintesi));
|
||||
sheet.addCell(new Label(24,1, "In verifica", headerFormatSintesi));
|
||||
sheet.addCell(new Label(25,1, "Accettato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(26,1, "Chiuso", headerFormatSintesi));
|
||||
sheet.addCell(new Label(27,1, "Stato", headerFormatSintesi));
|
||||
|
||||
// ************ SEZIONE SALDO ************ //
|
||||
sheet.addCell(new Label(28,1, "Caricato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(29,1, "Non fatturabile per disservizi", headerFormatSintesi));
|
||||
sheet.addCell(new Label(30,1, "Non fatturabile per franchigia", headerFormatSintesi));
|
||||
sheet.addCell(new Label(31,1, "Non fatturabile per altre causali", headerFormatSintesi));
|
||||
sheet.addCell(new Label(32,1, "Fatturato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(33,1, "Contestato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(34,1, "Contestazione accettata", headerFormatSintesi));
|
||||
sheet.addCell(new Label(35,1, "Contestazione respinta", headerFormatSintesi));
|
||||
sheet.addCell(new Label(36,1, "In verifica", headerFormatSintesi));
|
||||
sheet.addCell(new Label(37,1, "Accettato", headerFormatSintesi));
|
||||
sheet.addCell(new Label(38,1, "Chiuso", headerFormatSintesi));
|
||||
sheet.addCell(new Label(39,1, "Stato", headerFormatSintesi));
|
||||
|
||||
CellView cv = null;
|
||||
for(int x=0; x < sheet.getColumns(); x++) {
|
||||
cv = sheet.getColumnView(x);
|
||||
cv.setSize(20*256); // dimensione colonne dati pari a 140 pixel
|
||||
sheet.setColumnView(x, cv);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeBodyXlsSintesi(WritableSheet sheet, List operatori, String trimestre, String anno) throws WriteException {
|
||||
// per ogni operatore
|
||||
Map sintesiTotale = new HashMap(operatori.size());
|
||||
for (int i=0; i < operatori.size(); i++) {
|
||||
AnagOperatoriDao.InfoOperatore oper = (AnagOperatoriDao.InfoOperatore)operatori.get(i);
|
||||
// Cerca i dati per il singolo operatore
|
||||
Map sintesiSingoloOperatore;
|
||||
if (sintesiTotale.get(oper.getDescrizione()) == null) {
|
||||
sintesiSingoloOperatore = new HashMap(4);
|
||||
// la chiave e' composta da TIPO_SLA (MNP/TCR) + "true" se RECIPIENT, "false" se DONOR
|
||||
RigaExcelReportSintesi mnpRecipient = new RigaExcelReportSintesi();
|
||||
mnpRecipient.setRecipient(true);
|
||||
mnpRecipient.setTipoSla(GestioneXlsBusiness.TIPO_SLA_MNP);
|
||||
sintesiSingoloOperatore.put(GestioneXlsBusiness.TIPO_SLA_MNP + "_true", mnpRecipient);
|
||||
|
||||
RigaExcelReportSintesi tcrRecipient = new RigaExcelReportSintesi();
|
||||
tcrRecipient.setRecipient(true);
|
||||
tcrRecipient.setTipoSla(GestioneXlsBusiness.TIPO_SLA_TCR);
|
||||
sintesiSingoloOperatore.put(GestioneXlsBusiness.TIPO_SLA_TCR + "_true", tcrRecipient);
|
||||
|
||||
RigaExcelReportSintesi mnpDonor = new RigaExcelReportSintesi();
|
||||
mnpDonor.setRecipient(false);
|
||||
mnpDonor.setTipoSla(GestioneXlsBusiness.TIPO_SLA_MNP);
|
||||
sintesiSingoloOperatore.put(GestioneXlsBusiness.TIPO_SLA_MNP + "_false", mnpDonor);
|
||||
|
||||
RigaExcelReportSintesi tcrDonor = new RigaExcelReportSintesi();
|
||||
tcrDonor.setRecipient(false);
|
||||
tcrDonor.setTipoSla(GestioneXlsBusiness.TIPO_SLA_TCR);
|
||||
sintesiSingoloOperatore.put(GestioneXlsBusiness.TIPO_SLA_TCR + "_false", tcrDonor);
|
||||
} else {
|
||||
sintesiSingoloOperatore = (HashMap) sintesiTotale.get(oper.getDescrizione());
|
||||
}
|
||||
|
||||
// prendere gli excel del secondo e quarto step MNP del trimestre in corso
|
||||
try {
|
||||
Map excelsMnpRecipient = cercaExcel("R", oper.getId_operatore(), trimestre, anno, GestioneXlsBusiness.TIPO_SLA_MNP);
|
||||
Map excelsMnpDonor = cercaExcel("D", oper.getId_operatore(), trimestre, anno, GestioneXlsBusiness.TIPO_SLA_MNP);
|
||||
Map excelsTcrRecipient = cercaExcel("R", oper.getId_operatore(), trimestre, anno, GestioneXlsBusiness.TIPO_SLA_TCR);
|
||||
Map excelsTcrDonor = cercaExcel("D", oper.getId_operatore(), trimestre, anno, GestioneXlsBusiness.TIPO_SLA_TCR);
|
||||
|
||||
sommaElementiSintesi(excelsMnpRecipient, (RigaExcelReportSintesi) sintesiSingoloOperatore.get(GestioneXlsBusiness.TIPO_SLA_MNP + "_true"), true, oper.getId_operatore(), trimestre, anno);
|
||||
sommaElementiSintesi(excelsMnpDonor, (RigaExcelReportSintesi) sintesiSingoloOperatore.get(GestioneXlsBusiness.TIPO_SLA_MNP + "_false"), false, oper.getId_operatore(), trimestre, anno);
|
||||
sommaElementiSintesi(excelsTcrRecipient, (RigaExcelReportSintesi) sintesiSingoloOperatore.get(GestioneXlsBusiness.TIPO_SLA_TCR + "_true"), true, oper.getId_operatore(), trimestre, anno);
|
||||
sommaElementiSintesi(excelsTcrDonor, (RigaExcelReportSintesi) sintesiSingoloOperatore.get(GestioneXlsBusiness.TIPO_SLA_TCR + "_false"), false, oper.getId_operatore(), trimestre, anno);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
sintesiTotale.put(oper.getDescrizione(), sintesiSingoloOperatore);
|
||||
}
|
||||
|
||||
// ******************* SCRIVE I DATI DELLA MAPPA NELL'EXCEL ***************************
|
||||
|
||||
// Unisce le celle per scrivere il trimestre. Deve essere alta 3*(numero operatori)
|
||||
sheet.addCell(new Label(0, 2, trimestre + " - " + anno, headerFormatSintesi));
|
||||
sheet.mergeCells(0, 2, 0, 2+( (3*operatori.size())-1) );
|
||||
for (int j=0; j < operatori.size(); j++) {
|
||||
// Scrive il nome dell'operatore
|
||||
AnagOperatoriDao.InfoOperatore oper = (AnagOperatoriDao.InfoOperatore)operatori.get(j);
|
||||
Label cellaOperatore = new Label(1, ((j+1)*3)-1, oper.getDescrizione(), headerFormatSintesi );
|
||||
WritableCellFormat newFormat = new WritableCellFormat(cellaOperatore.getCellFormat());
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
cellaOperatore.setCellFormat(newFormat);
|
||||
sheet.addCell(cellaOperatore);
|
||||
sheet.mergeCells(1, ((j+1)*3)-1, 1, ((j+1)*3)+1);
|
||||
|
||||
// Scrive le intestazioni MNP, TCR, TOTALE
|
||||
Label cellaMNP = new Label(2, ((j+1)*3)-1, GestioneXlsBusiness.TIPO_SLA_MNP, headerFormatSintesi );
|
||||
newFormat = new WritableCellFormat(cellaMNP.getCellFormat());
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
cellaMNP.setCellFormat(newFormat);
|
||||
sheet.addCell(cellaMNP);
|
||||
|
||||
Label cellaTCR = new Label(2, (j+1)*3, GestioneXlsBusiness.TIPO_SLA_TCR, headerFormatSintesi );
|
||||
newFormat = new WritableCellFormat(cellaTCR.getCellFormat());
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
cellaTCR.setCellFormat(newFormat);
|
||||
sheet.addCell(cellaTCR);
|
||||
|
||||
Label cellaTotale = new Label(2, ((j + 1) * 3) + 1, "TOT", headerFormatSintesi);
|
||||
newFormat = new WritableCellFormat(cellaTotale.getCellFormat());
|
||||
newFormat.setBackground(Colour.IVORY);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
cellaTotale.setCellFormat(newFormat);
|
||||
sheet.addCell(cellaTotale);
|
||||
|
||||
// recupera la sintesi dei dati
|
||||
Map sintesisingoloOperatore = (Map) sintesiTotale.get(oper.getDescrizione());
|
||||
RigaExcelReportSintesi rigaMNP_Recipient = (RigaExcelReportSintesi) sintesisingoloOperatore.get(GestioneXlsBusiness.TIPO_SLA_MNP + "_true");
|
||||
RigaExcelReportSintesi rigaTCR_Recipient = (RigaExcelReportSintesi) sintesisingoloOperatore.get(GestioneXlsBusiness.TIPO_SLA_TCR + "_true");
|
||||
RigaExcelReportSintesi rigaMNP_Donor = (RigaExcelReportSintesi) sintesisingoloOperatore.get(GestioneXlsBusiness.TIPO_SLA_MNP + "_false");
|
||||
RigaExcelReportSintesi rigaTCR_Donor = (RigaExcelReportSintesi) sintesisingoloOperatore.get(GestioneXlsBusiness.TIPO_SLA_TCR + "_false");
|
||||
|
||||
// ********************* RIGA MNP *********************
|
||||
writeSingleRowRecipient(sheet, ((j + 1) * 3) - 1, rigaMNP_Recipient);
|
||||
writeSingleRowDonor(sheet, ((j+1)*3)-1, rigaMNP_Donor );
|
||||
writeSingleRowSaldo(sheet, ((j+1)*3)-1 );
|
||||
|
||||
// ********************* RIGA TCR *********************
|
||||
writeSingleRowRecipient(sheet, ((j+1)*3), rigaTCR_Recipient );
|
||||
writeSingleRowDonor(sheet, ((j+1)*3), rigaTCR_Donor );
|
||||
writeSingleRowSaldo(sheet, ((j+1)*3) );
|
||||
|
||||
// ********************* RIGA TOTALE *********************
|
||||
for (int k=3; k <= 39; k++) {
|
||||
boolean isFormula = true;
|
||||
if (k==14 || k==27 || k==39) {
|
||||
// escludo le colonne STATO (non devono essere sommate)
|
||||
isFormula = false;
|
||||
}
|
||||
String primaCella = CellReferenceHelper.getCellReference(k, (((j+1)*3)-1));
|
||||
String secondaCella = CellReferenceHelper.getCellReference(k, (((j+1)*3)));
|
||||
String formula = "SUM("+ primaCella +"+"+ secondaCella+")";
|
||||
WritableCell totale = null;
|
||||
if (isFormula) {
|
||||
totale = new Formula(k, ((j+1)*3)+1, formula, recordNumberFormatStep3);
|
||||
} else {
|
||||
totale = new Label(k, ((j+1)*3)+1, "", recordNumberFormatStep3);
|
||||
}
|
||||
newFormat = new WritableCellFormat(totale.getCellFormat());
|
||||
newFormat.setBackground(Colour.IVORY);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
totale.setCellFormat(newFormat);
|
||||
sheet.addCell( totale );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeSingleRowRecipient(WritableSheet sheet, int row, RigaExcelReportSintesi rigaDati) throws WriteException {
|
||||
// ***************** CARICATO *****************
|
||||
Number caricato = new Number(3, row, rigaDati.getCaricato().doubleValue(), recordNumberFormatStep3 );
|
||||
WritableCellFormat newFormat = new WritableCellFormat(caricato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
caricato.setCellFormat(newFormat);
|
||||
sheet.addCell(caricato); // CARICATO
|
||||
|
||||
// ***************** NON FATTURABILE PER DISSERVIZI *****************
|
||||
Number nonFattDisservizi = new Number(4, row, rigaDati.getNonFattDisservizi().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(nonFattDisservizi.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattDisservizi.setCellFormat(newFormat);
|
||||
sheet.addCell(nonFattDisservizi); // NON FATTURABILE PER DISSERVIZI
|
||||
|
||||
// ***************** NON FATTURABILE PER FRANCHIGIA *****************
|
||||
Number nonFattFranchigia = new Number(5, row, rigaDati.getNonFattFranchigia().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(nonFattFranchigia.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattFranchigia.setCellFormat(newFormat);
|
||||
sheet.addCell(nonFattFranchigia); // NON FATTURABILE PER FRANCHIGIA
|
||||
|
||||
// ***************** NON FATTURABILE PER ALTRE CAUSALI *****************
|
||||
Number nonFattAltreCausali = new Number(6, row, rigaDati.getNonFattAltreCausali().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(nonFattAltreCausali.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattAltreCausali.setCellFormat(newFormat);
|
||||
sheet.addCell(nonFattAltreCausali); // NON FATTURABILE PER ALTRE CAUSALI
|
||||
|
||||
// Formula per FATTURATO SUM(D-E-F-G)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formula = "SUM(D"+(row+1)+"-E"+(row+1)+"-F"+(row+1)+"-G"+(row+1)+")";
|
||||
Formula fatturato = new Formula(7, row, formula, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(fatturato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
fatturato.setCellFormat(newFormat);
|
||||
sheet.addCell( fatturato );
|
||||
|
||||
// ***************** CONTESTATO *****************
|
||||
Number contestato = new Number(8, row, rigaDati.getContestato().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(contestato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestato.setCellFormat(newFormat);
|
||||
sheet.addCell(contestato); // CONTESTATO
|
||||
|
||||
// ***************** CONTESTATO ACCETTATO *****************
|
||||
Number contestatoAccettato = new Number(9, row, rigaDati.getContestatoAccettata().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(contestatoAccettato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestatoAccettato.setCellFormat(newFormat);
|
||||
sheet.addCell(contestatoAccettato); // CONTESTATO ACCETTATO
|
||||
|
||||
// ***************** CONTESTATO Respinto *****************
|
||||
Number contestatoRespinto = new Number(10, row, rigaDati.getContestatoRespinta().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(contestatoRespinto.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestatoRespinto.setCellFormat(newFormat);
|
||||
sheet.addCell(contestatoRespinto); // CONTESTATO RESPINTA
|
||||
|
||||
// Formula per IN VERIFICA SUM(I-J-K)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaInVerifica = "SUM(I"+(row+1)+"-J"+(row+1)+"-K"+(row+1)+")";
|
||||
Formula inVerifica = new Formula(11, row, formulaInVerifica, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(inVerifica.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
inVerifica.setCellFormat(newFormat);
|
||||
sheet.addCell( inVerifica );
|
||||
|
||||
// Formula per ACCETTATO SUM(H-I)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaAccettato = "SUM(H"+(row+1)+"-I"+(row+1)+")";
|
||||
Formula accettato = new Formula(12, row, formulaAccettato, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(accettato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
accettato.setCellFormat(newFormat);
|
||||
sheet.addCell( accettato );
|
||||
|
||||
// Formula per CHIUSO SUM(H-J)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaChiuso = "SUM(H"+(row+1)+"-J"+(row+1)+")";
|
||||
Formula chiuso = new Formula(13, row, formulaChiuso, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(chiuso.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
chiuso.setCellFormat(newFormat);
|
||||
sheet.addCell( chiuso );
|
||||
|
||||
// STATO
|
||||
Label stato = new Label(14, row, rigaDati.getStato(), headerFormatStep3 );
|
||||
newFormat = new WritableCellFormat(stato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
stato.setCellFormat(newFormat);
|
||||
sheet.addCell(stato); // STATO
|
||||
}
|
||||
|
||||
private void writeSingleRowDonor(WritableSheet sheet, int row, RigaExcelReportSintesi rigaDati) throws WriteException {
|
||||
// CARICATO
|
||||
Number caricato = new Number(15, row, rigaDati.getCaricato().doubleValue(), recordNumberFormatStep3 );
|
||||
WritableCellFormat newFormat = new WritableCellFormat(caricato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
caricato.setCellFormat(newFormat);
|
||||
sheet.addCell(caricato); // CARICATO
|
||||
|
||||
// NON FATTURABILE PER DISSERVIZI
|
||||
Number nonFattDisservizi = new Number(16, row, rigaDati.getNonFattDisservizi().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(nonFattDisservizi.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattDisservizi.setCellFormat(newFormat);
|
||||
sheet.addCell(nonFattDisservizi); // NON FATTURABILE PER DISSERVIZI
|
||||
|
||||
// NON FATTURABILE PER FRANCHIGIA
|
||||
Number nonFattFranchigia = new Number(17, row, rigaDati.getNonFattFranchigia().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(nonFattFranchigia.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattFranchigia.setCellFormat(newFormat);
|
||||
sheet.addCell(nonFattFranchigia); // NON FATTURABILE PER FRANCHIGIA
|
||||
|
||||
|
||||
// NON FATTURABILE PER ALTRE CAUSALI
|
||||
Number nonFattAltreCausali = new Number(18, row, rigaDati.getNonFattAltreCausali().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(nonFattAltreCausali.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattAltreCausali.setCellFormat(newFormat);
|
||||
sheet.addCell(nonFattAltreCausali); // NON FATTURABILE PER ALTRE CAUSALI
|
||||
|
||||
// Formula per FATTURATO STIMATO SUM(P-Q-R-S)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formula = "SUM(P"+(row+1)+"-Q"+(row+1)+"-R"+(row+1)+"-S"+(row+1)+")";
|
||||
Formula fatturatoStimato = new Formula(19, row, formula, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(fatturatoStimato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
fatturatoStimato.setCellFormat(newFormat);
|
||||
sheet.addCell( fatturatoStimato );
|
||||
|
||||
// FATTURATO (preso da file CSV AOM)
|
||||
Number fatturato = new Number(20, row, rigaDati.getFatturato().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(fatturato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
fatturato.setCellFormat(newFormat);
|
||||
sheet.addCell(fatturato);
|
||||
|
||||
// CONTESTATO
|
||||
Number contestato = new Number(21, row, rigaDati.getContestato().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(contestato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestato.setCellFormat(newFormat);
|
||||
sheet.addCell(contestato);
|
||||
|
||||
// CONTESTATO ACCETTATO
|
||||
Number contestatoAccettato = new Number(22, row, rigaDati.getContestatoAccettata().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(contestatoAccettato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestatoAccettato.setCellFormat(newFormat);
|
||||
sheet.addCell(contestatoAccettato);
|
||||
|
||||
// CONTESTATO RESPINTA
|
||||
Number contestatoRespinto = new Number(23, row, rigaDati.getContestatoRespinta().doubleValue(), recordNumberFormatStep3 );
|
||||
newFormat = new WritableCellFormat(contestatoRespinto.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestatoRespinto.setCellFormat(newFormat);
|
||||
sheet.addCell(contestatoRespinto);
|
||||
|
||||
// Formula per IN VERIFICA SUM(V-W-X)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaInVerifica = "SUM(V"+(row+1)+"-W"+(row+1)+"-X"+(row+1)+")";
|
||||
Formula inVerifica = new Formula(24, row, formulaInVerifica, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(inVerifica.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
inVerifica.setCellFormat(newFormat);
|
||||
sheet.addCell( inVerifica );
|
||||
|
||||
// Formula per ACCETTATO SUM(U-V)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaAccettato = "SUM(U"+(row+1)+"-V"+(row+1)+")";
|
||||
Formula accettato = new Formula(25, row, formulaAccettato, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(accettato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
accettato.setCellFormat(newFormat);
|
||||
sheet.addCell( accettato );
|
||||
|
||||
// Formula per CHIUSO SUM(U-W)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaChiuso = "SUM(U"+(row+1)+"-W"+(row+1)+")";
|
||||
Formula chiuso = new Formula(26, row, formulaChiuso, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(chiuso.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
chiuso.setCellFormat(newFormat);
|
||||
sheet.addCell( chiuso );
|
||||
|
||||
// STATO
|
||||
Label stato = new Label(27, row, rigaDati.getStato(), headerFormatStep3 );
|
||||
newFormat = new WritableCellFormat(stato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
stato.setCellFormat(newFormat);
|
||||
sheet.addCell(stato); // STATO
|
||||
}
|
||||
|
||||
private void writeSingleRowSaldo(WritableSheet sheet, int row) throws WriteException {
|
||||
// Formula per CARICATO SUM(D-P)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaCaricato = "SUM(D"+(row+1)+"-P"+(row+1)+")";
|
||||
Formula caricato = new Formula(28, row, formulaCaricato, recordNumberFormatStep3);
|
||||
WritableCellFormat newFormat = new WritableCellFormat(caricato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
caricato.setCellFormat(newFormat);
|
||||
sheet.addCell( caricato );
|
||||
|
||||
// Formula per NON FATTURABILE DISSERVIZI SUM(E-Q)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaNonFattDisservizi = "SUM(E"+(row+1)+"-Q"+(row+1)+")";
|
||||
Formula nonFattDisservizi = new Formula(29, row, formulaNonFattDisservizi, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(nonFattDisservizi.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattDisservizi.setCellFormat(newFormat);
|
||||
sheet.addCell( nonFattDisservizi );
|
||||
|
||||
// Formula per NON FATTURABILE FRANCHIGIA SUM(F-R)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaNonFattFranchigia = "SUM(F"+(row+1)+"-R"+(row+1)+")";
|
||||
Formula nonFattFranchigia = new Formula(30, row, formulaNonFattFranchigia, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(nonFattFranchigia.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattFranchigia.setCellFormat(newFormat);
|
||||
sheet.addCell( nonFattFranchigia );
|
||||
|
||||
// Formula per NON FATTURABILE ALTRE CAUSALI SUM(G-S)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaNonFattAltreCausali = "SUM(G"+(row+1)+"-S"+(row+1)+")";
|
||||
Formula nonFattAltreCausali = new Formula(31, row, formulaNonFattAltreCausali, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(nonFattAltreCausali.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
nonFattAltreCausali.setCellFormat(newFormat);
|
||||
sheet.addCell( nonFattAltreCausali );
|
||||
|
||||
// Formula per FATTURATO SUM(H-U)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaFatturato = "SUM(H"+(row+1)+"-U"+(row+1)+")";
|
||||
Formula fatturato = new Formula(32, row, formulaFatturato, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(fatturato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
fatturato.setCellFormat(newFormat);
|
||||
sheet.addCell( fatturato );
|
||||
|
||||
// Formula per CONTESTATO SUM(I-V)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaContestato = "SUM(I"+(row+1)+"-V"+(row+1)+")";
|
||||
Formula contestato = new Formula(33, row, formulaContestato, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(contestato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestato.setCellFormat(newFormat);
|
||||
sheet.addCell( contestato );
|
||||
|
||||
// Formula per CONTESTATO ACCETTATA SUM(J-W)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaContestatoAcc = "SUM(J"+(row+1)+"-W"+(row+1)+")";
|
||||
Formula contestatoAcc = new Formula(34, row, formulaContestatoAcc, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(contestatoAcc.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestatoAcc.setCellFormat(newFormat);
|
||||
sheet.addCell( contestatoAcc );
|
||||
|
||||
// Formula per CONTESTATO RESPINTA SUM(K-X)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaContestatoRespinta = "SUM(K"+(row+1)+"-X"+(row+1)+")";
|
||||
Formula contestatoRespinta = new Formula(35, row, formulaContestatoRespinta, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(contestatoRespinta.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
contestatoRespinta.setCellFormat(newFormat);
|
||||
sheet.addCell( contestatoRespinta );
|
||||
|
||||
// Formula per IN VERIFICA SUM(L-Y)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaInVerifica = "SUM(L"+(row+1)+"-Y"+(row+1)+")";
|
||||
Formula inVerifica = new Formula(36, row, formulaInVerifica, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(inVerifica.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
inVerifica.setCellFormat(newFormat);
|
||||
sheet.addCell( inVerifica );
|
||||
|
||||
// Formula per ACCETTATO SUM(M-Z)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaAccettato = "SUM(M"+(row+1)+"-Z"+(row+1)+")";
|
||||
Formula accettato = new Formula(37, row, formulaAccettato, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(accettato.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
accettato.setCellFormat(newFormat);
|
||||
sheet.addCell( accettato );
|
||||
|
||||
// Formula per CHIUSO SUM(N-AA)
|
||||
// Nelle formule l'indice e' 1 based
|
||||
String formulaChiuso = "SUM(N"+(row+1)+"-AA"+(row+1)+")";
|
||||
Formula chiuso = new Formula(38, row, formulaChiuso, recordNumberFormatStep3);
|
||||
newFormat = new WritableCellFormat(chiuso.getCellFormat());
|
||||
newFormat.setBackground(Colour.WHITE);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.THIN);
|
||||
chiuso.setCellFormat(newFormat);
|
||||
sheet.addCell( chiuso );
|
||||
}
|
||||
|
||||
private Map cercaExcel(String tipoProcesso, String operatore, String trimestre, String anno, String tipoSla) throws Exception {
|
||||
List excelsInFatturazione = new ArrayList();
|
||||
List excelsInContestazione = new ArrayList();
|
||||
|
||||
CalcoloPenaliBusiness businessService = new CalcoloPenaliBusiness();
|
||||
String meseanno = null;
|
||||
if (trimestre.equalsIgnoreCase("1Q")) {
|
||||
meseanno = 13+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("2Q")) {
|
||||
meseanno = 14+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("3Q")) {
|
||||
meseanno = 15+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("4Q")) {
|
||||
meseanno = 16+"/"+anno;
|
||||
}
|
||||
List dbcgoProcessi = businessService.getRecordPerMese(tipoProcesso, operatore, meseanno, tipoSla);
|
||||
|
||||
for (Iterator iter = dbcgoProcessi.iterator(); iter.hasNext();) {
|
||||
DbcgoProcessoPenali singleProcess = (DbcgoProcessoPenali) iter.next();
|
||||
if (singleProcess.getId().getStep().equals(new Long(2))) {
|
||||
// Prendo sempre l'ultima versione dell'excel
|
||||
excelsInFatturazione.add( businessService.getRequestedFile("xls", new Long(0), singleProcess.getIdProcesso()));
|
||||
}
|
||||
|
||||
if (tipoProcesso.equalsIgnoreCase("R")) {
|
||||
// nei processi recipient l'ultimo step e' il numero 4
|
||||
if (singleProcess.getId().getStep().equals(new Long(4))) {
|
||||
// Prendo sempre l'ultima versione dell'excel
|
||||
excelsInContestazione.add( businessService.getRequestedFile("xls", new Long(0), singleProcess.getIdProcesso()));
|
||||
}
|
||||
} else {
|
||||
// nei processi donor l'ultimo step e' il numero 5
|
||||
if (singleProcess.getId().getStep().equals(new Long(5))) {
|
||||
// Prendo sempre l'ultima versione dell'excel
|
||||
excelsInContestazione.add( businessService.getRequestedFile("xls", new Long(0), singleProcess.getIdProcesso()));
|
||||
}
|
||||
}
|
||||
//rest of the code block removed
|
||||
}
|
||||
Map output = new HashMap(2);
|
||||
output.put(KEY_EXCELS_INFATTURAZIONE, excelsInFatturazione);
|
||||
output.put(KEY_EXCELS_INCONTESTAZIONE, excelsInContestazione);
|
||||
return output;
|
||||
}
|
||||
|
||||
private void sommaElementiSintesi(Map excels, RigaExcelReportSintesi sintesi, boolean isRecipient, String operatore, String trimestre, String anno) {
|
||||
// la mappa di excel e' formata da due liste, una per step 2 (infatturazione)
|
||||
// e una per step4 (incontestazione)
|
||||
List excelsInFatturazione = (ArrayList)excels.get(KEY_EXCELS_INFATTURAZIONE);
|
||||
for (Iterator iter = excelsInFatturazione.iterator(); iter.hasNext();) {
|
||||
// Singolo excel step 2
|
||||
byte[] singleExcel = (byte[]) iter.next();
|
||||
sommaValoriDaStep2(singleExcel, sintesi);
|
||||
sintesi.setStato("Calcolo importi non fatturabili");
|
||||
}
|
||||
|
||||
List excelsInContestazione = (ArrayList)excels.get(KEY_EXCELS_INCONTESTAZIONE);
|
||||
for (Iterator iter = excelsInContestazione.iterator(); iter.hasNext();) {
|
||||
// Singolo excel step 4
|
||||
byte[] singleExcel = (byte[]) iter.next();
|
||||
sommaValoriDaStep4(singleExcel, sintesi, isRecipient);
|
||||
sintesi.setStato("In contestazione");
|
||||
}
|
||||
|
||||
// Verificare se il processo è terminato ed impostare lo stato su EVASO
|
||||
String tipoProcesso = (isRecipient) ? "R" : "D";
|
||||
CalcoloPenaliBusiness businessService = new CalcoloPenaliBusiness();
|
||||
String meseanno = null;
|
||||
if (trimestre.equalsIgnoreCase("1Q")) {
|
||||
meseanno = 13+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("2Q")) {
|
||||
meseanno = 14+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("3Q")) {
|
||||
meseanno = 15+"/"+anno;
|
||||
} else if (trimestre.equalsIgnoreCase("4Q")) {
|
||||
meseanno = 16+"/"+anno;
|
||||
}
|
||||
try {
|
||||
List dbcgoProcessi = businessService.getRecordPerMese(tipoProcesso, operatore, meseanno, sintesi.getTipoSla());
|
||||
for (Iterator iter = dbcgoProcessi.iterator(); iter.hasNext();) {
|
||||
DbcgoProcessoPenali singleProcess = (DbcgoProcessoPenali) iter.next();
|
||||
if (tipoProcesso.equalsIgnoreCase("R")) {
|
||||
// nei processi recipient l'ultimo step e' il numero 4
|
||||
// Prendo solo il processo dello step 4 relativo al mese in input
|
||||
if (singleProcess.getId().getStep().equals(new Long(4)) ) {
|
||||
if (singleProcess.getStato().doubleValue() == 2) {
|
||||
sintesi.setStato("EVASA");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// nei processi donor l'ultimo step e' il numero 5
|
||||
// Prendo solo il processo dello step 5 relativo al mese in input
|
||||
if (singleProcess.getId().getStep().equals(new Long(5))) {
|
||||
if (singleProcess.getStato().doubleValue() == 2) {
|
||||
sintesi.setStato("EVASA");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void sommaValoriDaStep2(byte[] singleExcel, RigaExcelReportSintesi rigaSintesi) {
|
||||
// Aprire l'excel e prendere i valori da sommare nell'oggetto sintesi
|
||||
try {
|
||||
Workbook tempWb = Workbook.getWorkbook(new ByteArrayInputStream(singleExcel));
|
||||
Sheet sheet = tempWb.getSheet(0);
|
||||
|
||||
// ciclo sulle righe escludendo l'header (parto quindi da 1)
|
||||
for (int i = 1; i < sheet.getRows(); i++) {
|
||||
Cell[] row = sheet.getRow(i);
|
||||
|
||||
// "Caricato" nel processo MNP e' la colonna T (indice 19), nel TCR e' la colonna S (indice 18)
|
||||
double caricato;
|
||||
if (rigaSintesi.getTipoSla().equalsIgnoreCase(GestioneXlsBusiness.TIPO_SLA_MNP)) {
|
||||
caricato = rigaSintesi.getCaricato().doubleValue() + Double.valueOf(row[19].getContents()).doubleValue();
|
||||
} else {
|
||||
caricato = rigaSintesi.getCaricato().doubleValue() + Double.valueOf(row[18].getContents()).doubleValue();
|
||||
}
|
||||
rigaSintesi.setCaricato( new Double(caricato) );
|
||||
|
||||
// verifico se l'evento e' fatturabile o no
|
||||
if (row[0].getContents().equalsIgnoreCase("NO")) {
|
||||
double nonFatturabileDisservizi;
|
||||
double nonFatturabileFranchigia;
|
||||
double nonFatturabileAltreCausali;
|
||||
// in base alla causale sommo gli importi dove serve
|
||||
if (row[1].getContents().equalsIgnoreCase(CAUSALE_DISSERVIZI)) {
|
||||
nonFatturabileDisservizi = rigaSintesi.getNonFattDisservizi().doubleValue() + Double.valueOf(row[19].getContents()).doubleValue();
|
||||
rigaSintesi.setNonFattDisservizi( new Double(nonFatturabileDisservizi));
|
||||
} else if (row[1].getContents().equalsIgnoreCase(CAUSALE_FRANCHIGIA)) {
|
||||
nonFatturabileFranchigia = rigaSintesi.getNonFattFranchigia().doubleValue() + Double.valueOf(row[19].getContents()).doubleValue();
|
||||
rigaSintesi.setNonFattFranchigia( new Double(nonFatturabileFranchigia));
|
||||
} else {
|
||||
nonFatturabileAltreCausali = rigaSintesi.getNonFattAltreCausali().doubleValue() + Double.valueOf(row[19].getContents()).doubleValue();
|
||||
rigaSintesi.setNonFattAltreCausali( new Double(nonFatturabileAltreCausali));
|
||||
}
|
||||
}
|
||||
}
|
||||
tempWb.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void sommaValoriDaStep4(byte[] singleExcel, RigaExcelReportSintesi rigaSintesi, boolean isRecipient) {
|
||||
// Aprire l'excel e prendere i valori da sommare nell'oggetto sintesi
|
||||
try {
|
||||
Workbook tempWb = Workbook.getWorkbook(new ByteArrayInputStream(singleExcel));
|
||||
Sheet sheet = tempWb.getSheet(0);
|
||||
|
||||
// ciclo sulle righe escludendo l'header (parto quindi da 1)
|
||||
for (int i = 1; i < sheet.getRows(); i++) {
|
||||
Cell[] row = sheet.getRow(i);
|
||||
double importoGiornaliero = 0;
|
||||
if (!isRecipient) {
|
||||
if (Double.valueOf(row[44].getContents()).doubleValue() != 0) {
|
||||
importoGiornaliero = Double.valueOf(row[44].getContents()).doubleValue() / Double.valueOf(row[42].getContents()).doubleValue();
|
||||
}
|
||||
} else {
|
||||
if (rigaSintesi.getTipoSla().equalsIgnoreCase(GestioneXlsBusiness.TIPO_SLA_MNP)) {
|
||||
if (Double.valueOf(row[27].getContents()).doubleValue() != 0) {
|
||||
importoGiornaliero = Double.valueOf(row[27].getContents()).doubleValue() / Double.valueOf(row[26].getContents()).doubleValue();
|
||||
}
|
||||
} else {
|
||||
if (Double.valueOf(row[26].getContents()).doubleValue() != 0) {
|
||||
importoGiornaliero = Double.valueOf(row[26].getContents()).doubleValue() / Double.valueOf(row[25].getContents()).doubleValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "Contestato"
|
||||
double contestato = rigaSintesi.getContestato().doubleValue() + ( Double.valueOf(row[1].getContents()).doubleValue() * importoGiornaliero); // Giorni contestati per importoGiornaliero
|
||||
rigaSintesi.setContestato( new Double(contestato) );
|
||||
|
||||
// "Contestazione accettata"
|
||||
if (row[4].getContents().equalsIgnoreCase(ESITO_CONTESTAZIONE_ACCETTATA)) {
|
||||
double contestazioneAccettata = rigaSintesi.getContestatoAccettata().doubleValue() + ( Double.valueOf(row[1].getContents()).doubleValue() * importoGiornaliero); // Giorni contestati per importoGiornaliero
|
||||
rigaSintesi.setContestatoAccettata( new Double(contestazioneAccettata) );
|
||||
}
|
||||
|
||||
// "Contestazione respinta"
|
||||
if (row[4].getContents().equalsIgnoreCase(ESITO_CONTESTAZIONE_RESPINTA)) {
|
||||
double contestazioneRespinta = rigaSintesi.getContestatoRespinta().doubleValue() + ( Double.valueOf(row[1].getContents()).doubleValue() * importoGiornaliero); // Giorni contestati per importoGiornaliero
|
||||
rigaSintesi.setContestatoRespinta( new Double(contestazioneRespinta) );
|
||||
}
|
||||
|
||||
if (!isRecipient) {
|
||||
// Fatturato (preso dal 5 step colonna importoDaCorrispondereAOM) [vale solo per DONOR]
|
||||
double fatturato = rigaSintesi.getFatturato().doubleValue() + ( Double.valueOf(row[12].getContents()).doubleValue() * importoGiornaliero);
|
||||
rigaSintesi.setFatturato( new Double(fatturato) );
|
||||
}
|
||||
}
|
||||
tempWb.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,166 @@
|
||||
package it.valueteam.dbcgo.utility.penali;
|
||||
|
||||
import it.valueteam.dbcgo.business.GestioneXlsBusiness;
|
||||
import it.valueteam.dbcgo.hb.dto.MnpDwSla3ggOutView;
|
||||
import it.valueteam.dbcgo.hb.dto.MnpDwSlaTcOutView;
|
||||
import jxl.Workbook;
|
||||
import jxl.write.*;
|
||||
import jxl.write.Number;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class CalcoloPenaliStep1ExcelUtils extends ExcelUtils {
|
||||
|
||||
public CalcoloPenaliStep1ExcelUtils() {
|
||||
super();
|
||||
}
|
||||
|
||||
public byte[] generaExcelStep1(List risultati, boolean isDonating, String tipoSla) {
|
||||
ByteArrayOutputStream baos = null;
|
||||
try {
|
||||
baos = new ByteArrayOutputStream();
|
||||
WritableWorkbook w = Workbook.createWorkbook(baos);
|
||||
WritableSheet sheet = null;
|
||||
if (isDonating) {
|
||||
sheet = w.createSheet(NOME_FOGLIO_STEP_1 + TIPO_PROCESSO_DONOR, 0);
|
||||
} else {
|
||||
sheet = w.createSheet(NOME_FOGLIO_STEP_1 + TIPO_PROCESSO_RECIPIENT, 0);
|
||||
}
|
||||
|
||||
writeHeaderStep1(sheet);
|
||||
|
||||
if (tipoSla.equalsIgnoreCase(GestioneXlsBusiness.TIPO_SLA_MNP)) {
|
||||
for (int i = 0; i < risultati.size(); i++) {
|
||||
MnpDwSla3ggOutView o = (MnpDwSla3ggOutView) risultati.get(i);
|
||||
writeRecordStep1MNP(sheet, o, i + 1);
|
||||
}
|
||||
} else if (tipoSla.equalsIgnoreCase(GestioneXlsBusiness.TIPO_SLA_TCR)) {
|
||||
for (int i = 0; i < risultati.size(); i++) {
|
||||
MnpDwSlaTcOutView o = (MnpDwSlaTcOutView) risultati.get(i);
|
||||
writeRecordStep1TCR(sheet, o, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
setCellsAutoSize(sheet);
|
||||
|
||||
w.write();
|
||||
w.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
} finally {
|
||||
if (baos != null) {
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
private void writeHeaderStep1(WritableSheet sheet) throws WriteException {
|
||||
sheet.addCell(new Label(0, 0, "Donating Ospitato", headerFormat));
|
||||
sheet.addCell(new Label(1, 0, "Recipient Ospitato", headerFormat));
|
||||
sheet.addCell(new Label(2, 0, "Donating di rete", headerFormat));
|
||||
sheet.addCell(new Label(3, 0, "Recipient di rete", headerFormat));
|
||||
|
||||
sheet.addCell(new Label(4, 0, "MSISDN", headerFormat));
|
||||
sheet.addCell(new Label(5, 0, "Codice Richiesta Recipient", headerFormat));
|
||||
sheet.addCell(new Label(6, 0, "Data Invio/Ricezione File Evento Iniziale", headerFormat));
|
||||
sheet.addCell(new Label(7, 0, "Nome file evento iniziale", headerFormat));
|
||||
|
||||
sheet.addCell(new Label(8, 0, "ACK Evento Iniziale", headerFormat));
|
||||
sheet.addCell(new Label(9, 0, "Data Invio/Ricezione File Evento Finale", headerFormat));
|
||||
sheet.addCell(new Label(10, 0, "Nome file evento finale", headerFormat));
|
||||
sheet.addCell(new Label(11, 0, "ACK Evento Finale", headerFormat));
|
||||
|
||||
sheet.addCell(new Label(12, 0, "Data Attesa Evento Finale", headerFormat));
|
||||
sheet.addCell(new Label(13, 0, "Giorni di ritardo (solari)", headerFormat));
|
||||
sheet.addCell(new Label(14, 0, "Importo", headerFormat));
|
||||
sheet.addCell(new Label(15, 0, "Mese di competenza Evento Finale", headerFormat));
|
||||
|
||||
sheet.addCell(new Label(16, 0, "Tipo SLA", headerFormat));
|
||||
sheet.addCell(new Label(17, 0, "FLAG penale altro operatore", headerFormat));
|
||||
|
||||
// KS12
|
||||
sheet.addCell(new Label(18, 0, "Data Evento Iniziale", headerFormat));
|
||||
sheet.addCell(new Label(19, 0, "Data Evento Finale", headerFormat));
|
||||
}
|
||||
|
||||
private void writeRecordStep1MNP(WritableSheet sheet, MnpDwSla3ggOutView record, int riga) throws WriteException {
|
||||
sheet.addCell(new Label(0, riga, record.getDonorEffettivo(), recordFormat));
|
||||
sheet.addCell(new Label(1, riga, record.getRecipientEffettivo(), recordFormat));
|
||||
sheet.addCell(new Label(2, riga, record.getDonorRete(), recordFormat));
|
||||
sheet.addCell(new Label(3, riga, record.getRecipientRete(), recordFormat));
|
||||
|
||||
sheet.addCell(new Number(4, riga, Double.parseDouble(record.getMsisdn()), recordNumberFormat));
|
||||
sheet.addCell(new Label(5, riga, record.getCodiceRichiestaRecipient(), recordFormat));
|
||||
sheet.addCell(new DateTime(6, riga, record.getDataIniziale(), recordDateFormat));
|
||||
sheet.addCell(new Label(7, riga, record.getNomeFileIniziale(), recordFormat));
|
||||
|
||||
sheet.addCell(new Label(8, riga, record.getAckIniziale(), recordFormat));
|
||||
sheet.addCell(new DateTime(9, riga, record.getDataFinale(), recordDateFormat));
|
||||
sheet.addCell(new Label(10, riga, record.getNomeFileFinale(), recordFormat));
|
||||
sheet.addCell(new Label(11, riga, record.getAckFinale(), recordFormat));
|
||||
|
||||
sheet.addCell(new DateTime(12, riga, record.getDataAttesaEventoFin(), recordDateFormat));
|
||||
sheet.addCell(new Number(13, riga, Double.parseDouble(record.getNumeroGiorniRitardo().toString()), recordNumberFormat));
|
||||
sheet.addCell(new Number(14, riga, Double.parseDouble(record.getPenale().toString()), recordNumberFormat));
|
||||
sheet.addCell(new Label(15, riga, record.getMeseCompFinale(), recordFormat));
|
||||
|
||||
sheet.addCell(new Label(16, riga, record.getTipoMessaggio(), recordFormat));
|
||||
sheet.addCell(new Label(17, riga, record.getIsPenaleAltroAom(), recordFormat));
|
||||
|
||||
if (record.getDataFrontieraSeIn() != null) {
|
||||
sheet.addCell(new DateTime(18, riga, record.getDataFrontieraSeIn(), recordDateFormat));
|
||||
} else {
|
||||
sheet.addCell(new Label(18, riga, "", recordDateFormat));
|
||||
}
|
||||
|
||||
if (record.getDataFrontieraSeOut() != null) {
|
||||
sheet.addCell(new DateTime(19, riga, record.getDataFrontieraSeOut(), recordDateFormat));
|
||||
} else {
|
||||
sheet.addCell(new Label(19, riga, "", recordDateFormat));
|
||||
}
|
||||
}
|
||||
|
||||
private void writeRecordStep1TCR(WritableSheet sheet, MnpDwSlaTcOutView record, int riga) throws WriteException {
|
||||
sheet.addCell(new Label(0, riga, record.getDonorEffettivo(), recordFormat));
|
||||
sheet.addCell(new Label(1, riga, record.getRecipientEffettivo(), recordFormat));
|
||||
sheet.addCell(new Label(2, riga, record.getDonorRete(), recordFormat));
|
||||
sheet.addCell(new Label(3, riga, record.getRecipientRete(), recordFormat));
|
||||
|
||||
sheet.addCell(new Number(4, riga, Double.parseDouble(record.getMsisdn()), recordNumberFormat));
|
||||
sheet.addCell(new Label(5, riga, record.getCodiceRichiestaRecipient(), recordFormat));
|
||||
sheet.addCell(new DateTime(6, riga, record.getDataIniziale(), recordDateFormat));
|
||||
sheet.addCell(new Label(7, riga, record.getNomeFileIniziale(), recordFormat));
|
||||
|
||||
sheet.addCell(new Label(8, riga, record.getAckIniziale(), recordFormat));
|
||||
sheet.addCell(new DateTime(9, riga, record.getDataFinale(), recordDateFormat));
|
||||
sheet.addCell(new Label(10, riga, record.getNomeFileFinale(), recordFormat));
|
||||
sheet.addCell(new Label(11, riga, record.getAckFinale(), recordFormat));
|
||||
|
||||
sheet.addCell(new DateTime(12, riga, record.getDataAttesaEventoFin(), recordDateFormat));
|
||||
sheet.addCell(new Number(13, riga, Double.parseDouble(record.getNumeroGiorniRitardo().toString()), recordNumberFormat));
|
||||
sheet.addCell(new Number(14, riga, Double.parseDouble(record.getPenale().toString()), recordNumberFormat));
|
||||
sheet.addCell(new Label(15, riga, record.getMeseCompFinale(), recordFormat));
|
||||
|
||||
sheet.addCell(new Label(16, riga, record.getTipoMessaggio(), recordFormat));
|
||||
sheet.addCell(new Label(17, riga, record.getIsPenaleAltroAom(), recordFormat));
|
||||
|
||||
if (record.getDataFrontieraSeIn() != null) {
|
||||
sheet.addCell(new DateTime(18, riga, record.getDataFrontieraSeIn(), recordDateFormat));
|
||||
} else {
|
||||
sheet.addCell(new Label(18, riga, "", recordDateFormat));
|
||||
}
|
||||
|
||||
if (record.getDataFrontieraSeOut() != null) {
|
||||
sheet.addCell(new DateTime(19, riga, record.getDataFrontieraSeOut(), recordDateFormat));
|
||||
} else {
|
||||
sheet.addCell(new Label(19, riga, "", recordDateFormat));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,531 @@
|
||||
package it.valueteam.dbcgo.utility.penali;
|
||||
|
||||
import it.valueteam.dbcgo.business.CalcoloDisserviziAomBusiness;
|
||||
import it.valueteam.dbcgo.business.CalcoloPenaliBusiness;
|
||||
import it.valueteam.dbcgo.common.Utils;
|
||||
import it.valueteam.dbcgo.dao.CostantsMap;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoAnagFranchigieDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.*;
|
||||
import it.valueteam.dbcgo.utility.JavaUtilsClass;
|
||||
import jxl.*;
|
||||
import jxl.write.*;
|
||||
import jxl.write.Number;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
* Versione 2.0 R1C-18-2151 2018-BU-00070594 Aggiunto operatore PLINTRON
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CalcoloPenaliStep2ExcelUtils extends ExcelUtils {
|
||||
|
||||
public CalcoloPenaliStep2ExcelUtils() {
|
||||
super();
|
||||
}
|
||||
|
||||
public byte[] generaExcelStep2(byte[] excelStep1, boolean isDonating, boolean isMNP, Long idProcesso) {
|
||||
File fileStep1 = null;
|
||||
FileOutputStream fosStep1 = null;
|
||||
|
||||
File fileStep2 = null;
|
||||
|
||||
byte[] output = null;
|
||||
try {
|
||||
// Causa problema con JexcelApi per copiare da un excel ad un altro bisogna passare per un oggetto java.io.File
|
||||
// Per scrivere il file dello step1
|
||||
fileStep1 = File.createTempFile("step1" + System.currentTimeMillis(), ".xls");
|
||||
fosStep1 = new FileOutputStream(fileStep1);
|
||||
fosStep1.write(excelStep1);
|
||||
fosStep1.flush();
|
||||
|
||||
// Per scrivere il file dello step 2
|
||||
fileStep2 = File.createTempFile("step2" + System.currentTimeMillis(), ".xls");
|
||||
|
||||
Workbook workbookStep1 = Workbook.getWorkbook(fileStep1);
|
||||
WritableWorkbook workbookStep2 = Workbook.createWorkbook(fileStep2, workbookStep1);
|
||||
WritableSheet sheet = null;
|
||||
if (isDonating) {
|
||||
sheet = workbookStep2.getSheet(NOME_FOGLIO_STEP_1 + TIPO_PROCESSO_DONOR);
|
||||
} else {
|
||||
sheet = workbookStep2.getSheet(NOME_FOGLIO_STEP_1 + TIPO_PROCESSO_RECIPIENT);
|
||||
}
|
||||
|
||||
sheet.setName(NOME_FOGLIO_STEP_2);
|
||||
|
||||
addColumnsForStep2(sheet, isMNP, idProcesso);
|
||||
|
||||
setCellsAutoSize(sheet);
|
||||
workbookStep2.write();
|
||||
workbookStep2.close();
|
||||
|
||||
workbookStep1.close();
|
||||
|
||||
output = Utils.readFileToByteArray(fileStep2);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (fosStep1 != null) {
|
||||
try {
|
||||
fosStep1.close();
|
||||
fileStep1.delete();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
if (fileStep2 != null) {
|
||||
fileStep2.delete();
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private void addColumnsForStep2(WritableSheet sheet, boolean isMNP, Long idProcesso) throws WriteException {
|
||||
// Inserimento colonne in ordine invertito
|
||||
// la librerie sposta automaticamente le colonne sulla destra
|
||||
if (isMNP) {
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Soggetto a franchigia", headerFormat));
|
||||
}
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Importo da corrispondere", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Giorni da corrispondere", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Causale Storno", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Check Fatturazione", headerFormat));
|
||||
|
||||
// KS12 2012
|
||||
// Aggiunta colonne in coda
|
||||
if (isMNP) {
|
||||
sheet.insertColumn(25);
|
||||
sheet.addCell(new Label(25, 0, "Flag variazione evento iniziale", headerFormat));
|
||||
|
||||
sheet.insertColumn(26);
|
||||
sheet.addCell(new Label(26, 0, "Flag variazione evento finale", headerFormat));
|
||||
} else {
|
||||
sheet.insertColumn(24);
|
||||
sheet.addCell(new Label(24, 0, "Flag variazione evento iniziale", headerFormat));
|
||||
|
||||
sheet.insertColumn(25);
|
||||
sheet.addCell(new Label(25, 0, "Flag variazione evento finale", headerFormat));
|
||||
}
|
||||
// KS12 2012
|
||||
|
||||
// INIZIO Gestione combo per Check Fatturazione
|
||||
// ArrayList checkFatturazioneValues = new ArrayList();
|
||||
// checkFatturazioneValues.add("SI");
|
||||
// checkFatturazioneValues.add("NO");
|
||||
// WritableCellFeatures checkFatturazioneFeatures = new WritableCellFeatures();
|
||||
// checkFatturazioneFeatures.setDataValidationList(checkFatturazioneValues);
|
||||
// Fine Gestione combo per Check Fatturazione
|
||||
|
||||
boolean isDonating = sheet.getName().toUpperCase().indexOf("DONOR") != -1;
|
||||
// Calcola il valore di default per le nuove colonne
|
||||
CalcoloPenaliBusiness calcPenBusiness = new CalcoloPenaliBusiness();
|
||||
DbcgoProcessoPenali processo = calcPenBusiness.getProcesso(""+idProcesso);
|
||||
HashMap franchigie = recuperaMappaFranchigie(String.valueOf(processo.getId().getMeseRiferimento()),
|
||||
String.valueOf(processo.getId().getAnno()),
|
||||
processo.getId().getOperatore(),
|
||||
isDonating);
|
||||
|
||||
List disservizi = recuperaListaDisservizi(String.valueOf(processo.getId().getMeseRiferimento()),
|
||||
String.valueOf(processo.getId().getAnno()),
|
||||
processo.getId().getOperatore(),
|
||||
isMNP,
|
||||
isDonating);
|
||||
logger.info("Trovati ["+disservizi.size()+"] disservizi.");
|
||||
for (int i = 1; i < sheet.getRows(); i++) {
|
||||
Label checkFatturazione = new Label(0, i, "SI", recordFormat);
|
||||
// Blank checkFatturazione = new Blank(0, i, recordFormat );
|
||||
// checkFatturazione.setCellFeatures(checkFatturazioneFeatures);
|
||||
sheet.addCell(checkFatturazione); // Check Fatturazione DEFAULT = SI
|
||||
sheet.addCell(new Label(1, i, "", recordFormat)); // Causale Storno DEFAULT = BLANK
|
||||
|
||||
String giorniRitardo = null;
|
||||
if (isMNP) {
|
||||
giorniRitardo = sheet.getCell(18,i).getContents();
|
||||
} else {
|
||||
giorniRitardo = sheet.getCell(17,i).getContents();
|
||||
}
|
||||
sheet.addCell(new Number(2, i, Double.parseDouble(giorniRitardo), recordNumberFormat)); // Giorni da corrispondere DEFAULT = Giorni di ritardo (Solari)
|
||||
|
||||
// Importo da corrispondere = FORMULA
|
||||
String importo = null;
|
||||
if (isMNP) {
|
||||
importo = sheet.getCell(19,i).getContents();
|
||||
} else {
|
||||
importo = sheet.getCell(18,i).getContents();
|
||||
}
|
||||
|
||||
double importoGiornoSolare = 0;
|
||||
if (Double.valueOf(importo).doubleValue() != 0) {
|
||||
importoGiornoSolare = Double.valueOf(importo).doubleValue() / Double.valueOf(giorniRitardo).doubleValue();
|
||||
}
|
||||
|
||||
String riferimentoGiorniRitardo = CellReferenceHelper.getCellReference(2, i);
|
||||
String formulaImpostoDaCorrispondere = riferimentoGiorniRitardo+"*"+importoGiornoSolare;
|
||||
Formula importoDaCorrispondereFor = new Formula(3, i, formulaImpostoDaCorrispondere, recordNumberFormat);
|
||||
sheet.addCell(importoDaCorrispondereFor); // Importo da corrispondere DEFAULT = Importo
|
||||
//sheet.addCell(new Number(3, i, Double.parseDouble(importo), recordNumberFormat)); // Importo da corrispondere DEFAULT = Importo
|
||||
|
||||
if (isMNP) {
|
||||
sheet.addCell(new Label(4, i, "NO", recordFormat)); // Soggetto a franchigia DEFAULT = NO
|
||||
}
|
||||
|
||||
Date dataAttesaEventoFinaleExcel = null;
|
||||
Date dataIRFileEventoInizialeExcel = null;
|
||||
Date dataIRFileEventoFinaleExcel = null;
|
||||
Date dataFrontieraSeIn = null;
|
||||
Date dataFrontieraSeOut = null;
|
||||
String tipoSlaExcel = null;
|
||||
try {
|
||||
if (isMNP) {
|
||||
dataAttesaEventoFinaleExcel = ((DateTime) sheet.getCell(17, i)).getDate();
|
||||
dataIRFileEventoInizialeExcel = ((DateTime) sheet.getCell(11, i)).getDate();
|
||||
dataIRFileEventoFinaleExcel = ((DateTime) sheet.getCell(14, i)).getDate();
|
||||
if (sheet.getCell(23, i) instanceof DateTime) {
|
||||
dataFrontieraSeIn = ((DateTime) sheet.getCell(23, i)).getDate();
|
||||
}
|
||||
if (sheet.getCell(24, i) instanceof DateTime) {
|
||||
dataFrontieraSeOut = ((DateTime) sheet.getCell(24, i)).getDate();
|
||||
}
|
||||
|
||||
tipoSlaExcel = sheet.getCell(21, i).getContents();
|
||||
// Default Flag variazione data evento iniziale e finale
|
||||
sheet.addCell(new Label(25, i, "NO", recordFormat));
|
||||
sheet.addCell(new Label(26, i, "NO", recordFormat));
|
||||
} else {
|
||||
dataAttesaEventoFinaleExcel = ((DateTime) sheet.getCell(16, i)).getDate();
|
||||
dataIRFileEventoInizialeExcel = ((DateTime) sheet.getCell(10, i)).getDate();
|
||||
dataIRFileEventoFinaleExcel = ((DateTime) sheet.getCell(13, i)).getDate();
|
||||
if (sheet.getCell(22, i) instanceof DateTime) {
|
||||
dataFrontieraSeIn = ((DateTime) sheet.getCell(22, i)).getDate();
|
||||
}
|
||||
if (sheet.getCell(23, i) instanceof DateTime) {
|
||||
dataFrontieraSeOut = ((DateTime) sheet.getCell(23, i)).getDate();
|
||||
}
|
||||
tipoSlaExcel = sheet.getCell(20, i).getContents();
|
||||
// Default Flag variazione data evento iniziale e finale
|
||||
sheet.addCell(new Label(24, i, "NO", recordFormat));
|
||||
sheet.addCell(new Label(25, i, "NO", recordFormat));
|
||||
}
|
||||
|
||||
logger.debug("***** Gestione FLAG");
|
||||
String dataAttesaEventoFinaleFormattataExcel = new SimpleDateFormat(DATE_FORMAT_PATTERN).format(dataAttesaEventoFinaleExcel);
|
||||
|
||||
// KS12 2012
|
||||
// Gestione dei flag variazione date
|
||||
String dataIRFileEventoInizialeExcelFormattata = new SimpleDateFormat(DATE_FORMAT_PATTERN).format(dataIRFileEventoInizialeExcel);
|
||||
String dataIRFileEventoFinaleExcelFormattata = new SimpleDateFormat(DATE_FORMAT_PATTERN).format(dataIRFileEventoFinaleExcel);
|
||||
logger.debug("***** Date ["+dataIRFileEventoInizialeExcelFormattata+"] ["+dataIRFileEventoFinaleExcelFormattata+"]");
|
||||
String dataFrontieraSeInFormattata = "";
|
||||
try {
|
||||
dataFrontieraSeInFormattata = new SimpleDateFormat(DATE_FORMAT_PATTERN).format(dataFrontieraSeIn);
|
||||
} catch (Exception e) {}
|
||||
|
||||
String dataFrontieraSeOutFormattata = "";
|
||||
try {
|
||||
dataFrontieraSeOutFormattata = new SimpleDateFormat(DATE_FORMAT_PATTERN).format(dataFrontieraSeOut);
|
||||
} catch (Exception e) {}
|
||||
|
||||
if (isMNP) {
|
||||
if (!dataFrontieraSeInFormattata.equalsIgnoreCase("") && !dataIRFileEventoInizialeExcelFormattata.equalsIgnoreCase(dataFrontieraSeInFormattata)) {
|
||||
Label label = (Label)sheet.getCell(25, i);
|
||||
label.setString("SI");
|
||||
}
|
||||
if (!dataFrontieraSeOutFormattata.equalsIgnoreCase("") && !dataIRFileEventoFinaleExcelFormattata.equalsIgnoreCase(dataFrontieraSeOutFormattata)) {
|
||||
Label label = (Label)sheet.getCell(26, i);
|
||||
label.setString("SI");
|
||||
}
|
||||
} else {
|
||||
if (!dataFrontieraSeInFormattata.equalsIgnoreCase("") && !dataIRFileEventoInizialeExcelFormattata.equalsIgnoreCase(dataFrontieraSeInFormattata)) {
|
||||
Label label = (Label)sheet.getCell(24, i);
|
||||
label.setString("SI");
|
||||
}
|
||||
if (!dataFrontieraSeOutFormattata.equalsIgnoreCase("") && !dataIRFileEventoFinaleExcelFormattata.equalsIgnoreCase(dataFrontieraSeOutFormattata)) {
|
||||
Label label = (Label)sheet.getCell(25, i);
|
||||
label.setString("SI");
|
||||
}
|
||||
}
|
||||
// KS12 2012
|
||||
|
||||
// ************ GESTIONE FRANCHIGIE SOLO PER PROCESSI MNP ****************
|
||||
if (isMNP) {
|
||||
if (franchigie.get(dataAttesaEventoFinaleFormattataExcel + "_" + tipoSlaExcel) != null) {
|
||||
// Modifico le prime cinque colonne
|
||||
Label causaleStorno = (Label) sheet.getWritableCell(1, i);
|
||||
causaleStorno.setString(CAUSALE_FRANCHIGIA);
|
||||
Number giorniDaCorrispondere = (Number) sheet.getWritableCell(2, i);
|
||||
//Number importoDaCorrispondere = (Number) sheet.getWritableCell(3, i);
|
||||
//double importoSingoloGiorno = 0;
|
||||
//if (importoDaCorrispondere.getValue() != 0) {
|
||||
// importoSingoloGiorno = importoDaCorrispondere.getValue() / giorniDaCorrispondere.getValue();
|
||||
//}
|
||||
giorniDaCorrispondere.setValue(giorniDaCorrispondere.getValue() - 1);
|
||||
//importoDaCorrispondere.setValue(giorniDaCorrispondere.getValue() * importoSingoloGiorno);
|
||||
Label soggettoAFranchigia = (Label) sheet.getWritableCell(4, i);
|
||||
|
||||
String donatingEffettivo = sheet.getCell(5, i).getContents();
|
||||
String recipientEffettivo = sheet.getCell(6, i).getContents();
|
||||
String donatingRete = sheet.getCell(7, i).getContents();
|
||||
String recipientRete = sheet.getCell(8, i).getContents();
|
||||
|
||||
// R1C-18-2151 2018-BU-00070594 Aggiunto operatore PLINTRON e ILIT alle condzioni
|
||||
// Aggiunto operatore COPF per COOP HYBRID
|
||||
if (!isDonating) { // per MNP Recipient
|
||||
if (tipoSlaExcel.equalsIgnoreCase(TIPO_SLA0) &&
|
||||
(donatingRete.equalsIgnoreCase(CostantsMap.CODICE_OPIV) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_WIND) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_NOVA) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_H3GI) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_LMIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_PMOB) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_BTIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_ILIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_COOP_HYBRID) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_MASS_RESPONSE) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_PLTN) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_WIN3)) ) {
|
||||
soggettoAFranchigia.setString("SI");
|
||||
} else if (tipoSlaExcel.equalsIgnoreCase(TIPO_SLA1) &&
|
||||
(donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_OPIV) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_WIND) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_NOVA) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_H3GI) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_LMIT) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_PMOB) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_BTIT) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_ILIT) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_COOP_HYBRID) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_MASS_RESPONSE) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_PLTN) ||
|
||||
donatingEffettivo.equalsIgnoreCase(CostantsMap.CODICE_WIN3)) ) {
|
||||
soggettoAFranchigia.setString("SI");
|
||||
} else if (tipoSlaExcel.equalsIgnoreCase(TIPO_SLA2) &&
|
||||
(donatingRete.equalsIgnoreCase(CostantsMap.CODICE_OPIV) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_WIND) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_NOVA) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_H3GI) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_LMIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_PMOB) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_BTIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_ILIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_COOP_HYBRID) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_MASS_RESPONSE) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_PLTN) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_WIN3)) ) {
|
||||
soggettoAFranchigia.setString("SI");
|
||||
} else if (tipoSlaExcel.equalsIgnoreCase(TIPO_SLA3) &&
|
||||
(donatingRete.equalsIgnoreCase(CostantsMap.CODICE_OPIV) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_WIND) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_NOVA) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_H3GI) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_LMIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_PMOB) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_BTIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_ILIT) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_MASS_RESPONSE) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_COOP_HYBRID) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_PLTN) ||
|
||||
donatingRete.equalsIgnoreCase(CostantsMap.CODICE_WIN3)) ){
|
||||
soggettoAFranchigia.setString("SI");
|
||||
}
|
||||
} else { // MNP DONOR, per qualsiasi SLA viene verificato recipientEffettivo
|
||||
if (recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_OPIV) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_WIND) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_NOVA) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_H3GI) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_LMIT) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_PMOB) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_BTIT) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_ILIT) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_COOP_HYBRID) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_MASS_RESPONSE) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_PLTN) ||
|
||||
recipientEffettivo.equalsIgnoreCase(CostantsMap.CODICE_WIN3)
|
||||
) {
|
||||
soggettoAFranchigia.setString("SI");
|
||||
}
|
||||
}
|
||||
Label flagFatturazione = (Label) sheet.getWritableCell(0, i);
|
||||
if (giorniDaCorrispondere.getValue() == 0) {
|
||||
flagFatturazione.setString("NO");
|
||||
} else {
|
||||
flagFatturazione.setString("PARZ");
|
||||
}
|
||||
} else {
|
||||
logger.info("Nessuna franchigia trovata per la data ["+dataAttesaEventoFinaleFormattataExcel+"] e SLA ["+tipoSlaExcel+"]");
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Prima della gestione dei disservizi...");
|
||||
// ************ GESTIONE DISSERVIZI PER ENTRAMBI I PROCESSI ****************
|
||||
// Cerco eventuali disservizi per la data dell'evento
|
||||
for (Iterator iter = disservizi.iterator(); iter.hasNext();) {
|
||||
logger.info("Dentro ciclo disservizi .................");
|
||||
DbcgoAnagDisservizi disservizio = (DbcgoAnagDisservizi)iter.next();
|
||||
SimpleDateFormat compareFormat = new SimpleDateFormat(DATE_FORMAT_PATTERN_COMPARE);
|
||||
String sLimiteInferioreDisservizio = compareFormat.format(disservizio.getId().getDataInizio());
|
||||
String sLimiteSuperioreDisservizio = compareFormat.format(disservizio.getId().getDataFine());
|
||||
String sDataEventoCompare = compareFormat.format(dataAttesaEventoFinaleExcel);
|
||||
logger.info("DISSERVIZIO: dataInizio ["+sLimiteInferioreDisservizio+"]");
|
||||
logger.info("DISSERVIZIO: dataFine ["+sLimiteSuperioreDisservizio+"]");
|
||||
logger.info("DISSERVIZIO: sla ["+disservizio.getId().getSla()+"]");
|
||||
|
||||
logger.info("EXCEL: dataInizio ["+sDataEventoCompare+"]");
|
||||
logger.info("SLAEXCEL: dataFine ["+tipoSlaExcel+"]");
|
||||
|
||||
logger.info("CLAUSOLA DATE ["+(sLimiteInferioreDisservizio.compareToIgnoreCase(sDataEventoCompare)<= 0 &&
|
||||
sDataEventoCompare.compareToIgnoreCase(sLimiteSuperioreDisservizio)<= 0)+"]");
|
||||
// Se l'evento e' compreso nel disservizio
|
||||
if (sLimiteInferioreDisservizio.compareToIgnoreCase(sDataEventoCompare)<= 0 &&
|
||||
sDataEventoCompare.compareToIgnoreCase(sLimiteSuperioreDisservizio)<= 0 ) {
|
||||
// verifico se lo SLA e' oggetto del disservizio
|
||||
if (tipoSlaExcel.equalsIgnoreCase(disservizio.getId().getSla())) {
|
||||
double giorniDaTogliere = JavaUtilsClass.differenzaGiorni(dataAttesaEventoFinaleExcel, disservizio.getId().getDataFine() ) + 1;
|
||||
// modifico le colonne dell'excel relative al record in esame
|
||||
Label causaleStorno = (Label) sheet.getWritableCell(1, i);
|
||||
causaleStorno.setString(CAUSALE_DISSERVIZI);
|
||||
Number giorniDaCorrispondere = (Number) sheet.getWritableCell(2, i);
|
||||
//Number importoDaCorrispondere = (Number) sheet.getWritableCell(3, i);
|
||||
//double importoSingoloGiorno = 0;
|
||||
//if (importoDaCorrispondere.getValue() != 0) {
|
||||
// importoSingoloGiorno = importoDaCorrispondere.getValue() / giorniDaCorrispondere.getValue();
|
||||
//}
|
||||
|
||||
if ((giorniDaCorrispondere.getValue() - giorniDaTogliere) < 0) {
|
||||
giorniDaCorrispondere.setValue( 0 );
|
||||
} else {
|
||||
giorniDaCorrispondere.setValue(giorniDaCorrispondere.getValue() - giorniDaTogliere);
|
||||
}
|
||||
|
||||
//importoDaCorrispondere.setValue(giorniDaCorrispondere.getValue() * importoSingoloGiorno);
|
||||
Label flagFatturazione = (Label) sheet.getWritableCell(0, i);
|
||||
if (giorniDaCorrispondere.getValue() == 0) {
|
||||
flagFatturazione.setString("NO");
|
||||
} else {
|
||||
flagFatturazione.setString("PARZ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Costruisce una mappa delle franchigie avente chiave dataEvento_tipoEvento
|
||||
// p.e. 01/07/2012_SLA0
|
||||
private HashMap recuperaMappaFranchigie(String mese, String anno, String operatore, boolean isDonating) {
|
||||
HashMap output = new HashMap();
|
||||
DbcgoAnagFranchigieDAO dao = new DbcgoAnagFranchigieDAO();
|
||||
List criteri = new ArrayList();
|
||||
Date[] rangeDate = calcolaRangeDateMese(mese, anno);
|
||||
logger.info(" ************ RECUPERA FRANCHIGIE STEP 2 mese ["+mese+"] anno ["+anno+"] operatore ["+operatore+"]");
|
||||
logger.info(" ************ range date da ["+rangeDate[0]+"] a ["+rangeDate[1]+"]");
|
||||
criteri.add(Restrictions.between("dataEvento", rangeDate[0], rangeDate[1]));
|
||||
if (!isDonating) {
|
||||
criteri.add(Restrictions.eq("recipientOspitato", operatore));
|
||||
criteri.add(Restrictions.eq("donatingOspitato", "TIMG"));
|
||||
} else {
|
||||
criteri.add(Restrictions.eq("donatingOspitato", operatore));
|
||||
criteri.add(Restrictions.eq("recipientOspitato", "TIMG"));
|
||||
}
|
||||
criteri.add(Restrictions.eq("superamentoSoglia", "Y"));
|
||||
|
||||
// ritorna una lista di DbcgoAnagFranchigie
|
||||
List risultati = dao.findByCriteria(criteri);
|
||||
|
||||
for (Iterator iter = risultati.iterator(); iter.hasNext();) {
|
||||
DbcgoAnagFranchigie franchigia = (DbcgoAnagFranchigie)iter.next();
|
||||
String dataEvento = new SimpleDateFormat(DATE_FORMAT_PATTERN).format(franchigia.getDataEvento());
|
||||
String key = dataEvento + "_" + franchigia.getTipoEvento();
|
||||
// Aggiungo solamente se non ho superato la soglia (quindi non devono essere fatturati)
|
||||
/* if (franchigia.getSuperamentoSoglia().equalsIgnoreCase("N")) {
|
||||
output.put(key, franchigia);
|
||||
}*/
|
||||
output.put(key, franchigia);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private List recuperaListaDisservizi(String mese, String anno, String operatore, boolean isMNP, boolean isDonating) {
|
||||
// Recupera le informazioni per le date
|
||||
logger.info(" ************ RECUPERA DISSERVIZI STEP 2 mese ["+mese+"] anno ["+anno+"] operatore ["+operatore+"]");
|
||||
Date[] limitiDate = ExcelUtils.calcolaRangeDateMese(mese, anno);
|
||||
|
||||
// Recupera le informazioni sui disservizi
|
||||
CalcoloDisserviziAomBusiness disserviziBusiness = new CalcoloDisserviziAomBusiness();
|
||||
List criteri = new ArrayList();
|
||||
if (isMNP) {
|
||||
criteri.add(Restrictions.in("id.sla", new String[]{"SLA0","SLA1","SLA2", "SLA3"}));
|
||||
} else {
|
||||
criteri.add(Restrictions.in("id.sla", new String[]{"SLA X","SLA Y","SLA Z"}));
|
||||
}
|
||||
criteri.add(Restrictions.eq("id.operatore",operatore));
|
||||
criteri.add(Restrictions.le("id.dataInizio", limitiDate[1]));
|
||||
criteri.add(Restrictions.ge("id.dataFine", limitiDate[0]));
|
||||
criteri.add(Restrictions.eq("disabilitaDisservizio", "N"));
|
||||
if (isDonating) {
|
||||
criteri.add(Restrictions.eq("tipoProcesso", "R"));
|
||||
} else {
|
||||
criteri.add(Restrictions.eq("tipoProcesso", "D"));
|
||||
}
|
||||
|
||||
// List of DbcgoAnagDisservizi
|
||||
return disserviziBusiness.eseguiRicerca(criteri);
|
||||
}
|
||||
|
||||
private void test() {
|
||||
String filename = "C:\\inputREAD.xls";
|
||||
try {
|
||||
/*WorkbookSettings ws = new WorkbookSettings();
|
||||
//ws.setLocale(new Locale("en", "EN"));
|
||||
WritableWorkbook tempWb = Workbook.createWorkbook(new File(filename), ws);
|
||||
WritableSheet s1 = tempWb.createSheet("Output", 0);
|
||||
s1.addCell(new Number(3, 0, 5));
|
||||
s1.addCell(new Number(3, 1, 6));
|
||||
s1.addCell(new Number(3, 2, 1));
|
||||
s1.addCell(new Number(3, 3, 6));
|
||||
s1.addCell(new Number(3, 4, 1));
|
||||
Formula formula = new Formula(3,5,"SUM(D1:D5)");
|
||||
s1.addCell(formula);*/
|
||||
Workbook tempWb = Workbook.getWorkbook(new File(filename));
|
||||
Sheet s1 = tempWb.getSheet(0);
|
||||
|
||||
NumberCell unaformula = (NumberCell) s1.getCell(3,5);
|
||||
|
||||
/*Formula myCell = (Formula) s1.getCell(3,5);
|
||||
System.out.println("TIPO:"+myCell.getType());
|
||||
System.out.println("CONTENTS:"+myCell.getContents());
|
||||
System.out.println("VALUE:"+myCell.getValue());*/
|
||||
|
||||
|
||||
//tempWb.write();
|
||||
tempWb.close();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
CalcoloPenaliStep2ExcelUtils utils = new CalcoloPenaliStep2ExcelUtils();
|
||||
utils.test();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,484 @@
|
||||
package it.valueteam.dbcgo.utility.penali;
|
||||
|
||||
import it.valueteam.dbcgo.bean.excel.*;
|
||||
import it.valueteam.dbcgo.common.Utils;
|
||||
import jxl.format.Colour;
|
||||
import jxl.format.Border;
|
||||
import jxl.format.BorderLineStyle;
|
||||
import jxl.*;
|
||||
import jxl.write.*;
|
||||
import jxl.write.Number;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class CalcoloPenaliStep4ExcelUtils extends ExcelUtils {
|
||||
|
||||
public CalcoloPenaliStep4ExcelUtils() {
|
||||
super();
|
||||
}
|
||||
|
||||
public byte[] generaExcelStep4(byte[] excelFirstMonth, byte[] excelSecondMonth, byte[] excelThirdMonth, boolean isDonating, boolean isMnp) {
|
||||
byte[] output = null;
|
||||
|
||||
try {
|
||||
if (isDonating) {
|
||||
List righeExcel = new ArrayList(excelFirstMonth.length);
|
||||
estraiRighe(excelFirstMonth, righeExcel, true);
|
||||
output = creaExcelFromList(righeExcel, isDonating);
|
||||
} else {
|
||||
List righeExcel = new ArrayList(excelFirstMonth.length + excelSecondMonth.length + excelThirdMonth.length - 2);
|
||||
estraiRighe(excelFirstMonth, righeExcel, true);
|
||||
estraiRighe(excelSecondMonth, righeExcel, false);
|
||||
estraiRighe(excelThirdMonth, righeExcel, false);
|
||||
output = creaExcelFromList(righeExcel, isDonating);
|
||||
}
|
||||
|
||||
output = aggiungiColonneExcelStep4(output, isDonating, isMnp);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private byte[] aggiungiColonneExcelStep4(byte[] excelStepIniziale, boolean isDonating, boolean isMnp) {
|
||||
File fileStep1 = null;
|
||||
FileOutputStream fosStep1 = null;
|
||||
|
||||
File fileStep2 = null;
|
||||
|
||||
byte[] output = null;
|
||||
try {
|
||||
// Causa problema con JexcelApi per copiare da un excel ad un altro bisogna passare per un oggetto java.io.File
|
||||
// Per scrivere il file dello step1
|
||||
fileStep1 = File.createTempFile("step4" + System.currentTimeMillis() + Thread.currentThread(), ".xls");
|
||||
fosStep1 = new FileOutputStream(fileStep1);
|
||||
fosStep1.write(excelStepIniziale);
|
||||
fosStep1.flush();
|
||||
|
||||
// Per scrivere il file dello step 2
|
||||
fileStep2 = File.createTempFile("step4new" + System.currentTimeMillis() + Thread.currentThread(), ".xls");
|
||||
|
||||
Workbook workbookStep1 = Workbook.getWorkbook(fileStep1);
|
||||
WritableWorkbook workbookStep2 = Workbook.createWorkbook(fileStep2, workbookStep1);
|
||||
WritableSheet sheet = null;
|
||||
//if (isDonating) {
|
||||
sheet = workbookStep2.getSheet(0);
|
||||
//} else {
|
||||
// sheet = workbookStep2.getSheet(NOME_FOGLIO_STEP_1 + TIPO_PROCESSO_RECIPIENT);
|
||||
//}
|
||||
|
||||
sheet.setName(NOME_FOGLIO_STEP_4);
|
||||
|
||||
addColumnsForStep4(sheet, isDonating, isMnp);
|
||||
|
||||
setCellsAutoSize(sheet);
|
||||
workbookStep2.write();
|
||||
workbookStep2.close();
|
||||
|
||||
workbookStep1.close();
|
||||
|
||||
output = Utils.readFileToByteArray(fileStep2);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (fosStep1 != null) {
|
||||
try {
|
||||
fosStep1.close();
|
||||
fileStep1.delete();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
if (fileStep2 != null) {
|
||||
fileStep2.delete();
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private void addColumnsForStep4(WritableSheet sheet, boolean isDonating, boolean isMnp) throws WriteException {
|
||||
// Inserimento colonne in ordine invertito
|
||||
// la librerie sposta automaticamente le colonne sulla destra
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Importo Riconosciuto", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Giorni Riconosciuti", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Causale Esito", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Esito Contestazione", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Causale Contestazione", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Importo Contestato", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Giorni Contestati", headerFormat));
|
||||
|
||||
sheet.insertColumn(0);
|
||||
sheet.addCell(new Label(0, 0, "Contestazione", headerFormat));
|
||||
|
||||
int indiceColonnaImporto = 0; // occorre solamente per ricavare l'importo giornaliero della penale
|
||||
int indiceColonnaGiorni = 0;
|
||||
int indiceColonnaGiorniDaCorrispondere = 0;
|
||||
if (isDonating) {
|
||||
indiceColonnaImporto = 44; // prendo l'importo dall'AOM
|
||||
indiceColonnaGiorni = 42; // prendo i giorni dall'AOM
|
||||
indiceColonnaGiorniDaCorrispondere = 12; // prendo i giorni dall'AOM
|
||||
} else {
|
||||
if (isMnp) {
|
||||
indiceColonnaImporto = 27;
|
||||
indiceColonnaGiorni = 26;
|
||||
indiceColonnaGiorniDaCorrispondere = 10;
|
||||
} else {
|
||||
indiceColonnaImporto = 26;
|
||||
indiceColonnaGiorni = 25;
|
||||
indiceColonnaGiorniDaCorrispondere = 10;
|
||||
}
|
||||
}
|
||||
|
||||
// Calcola il valore di default per le nuove colonne
|
||||
for (int i = 1; i < sheet.getRows(); i++) {
|
||||
Number importo = (Number) sheet.getWritableCell(indiceColonnaImporto, i);
|
||||
Number giorniRitardo = (Number) sheet.getWritableCell(indiceColonnaGiorni, i);
|
||||
double importoSingoloGiorno = 0;
|
||||
if (importo.getValue() != 0) {
|
||||
importoSingoloGiorno = importo.getValue() / giorniRitardo.getValue();
|
||||
}
|
||||
|
||||
sheet.addCell(new Label(0, i, "NO", recordFormat)); // Contestazione DEFAULT = NO
|
||||
sheet.addCell(new Number(1, i, 0, recordNumberFormat)); // Giorni Contestati DEFAULT = 0
|
||||
String formulaImportoContestato = CellReferenceHelper.getCellReference(1, i)+"*"+importoSingoloGiorno;
|
||||
Formula importoContestato = new Formula(2, i, formulaImportoContestato, recordNumberFormat); // Importo contestato DEFAULT = GiorniContestati * importoSingoloGiorno
|
||||
sheet.addCell(importoContestato);
|
||||
|
||||
sheet.addCell(new Label(3, i, "", recordFormat)); // Causale Contestazione DEFAULT = blank
|
||||
sheet.addCell(new Label(4, i, "", recordFormat)); // Esito contestazione DEFAULT = blank
|
||||
sheet.addCell(new Label(5, i, "", recordFormat)); // Causato Esito DEFAULT = blank
|
||||
String giorniDaCorrispondere = sheet.getCell(indiceColonnaGiorniDaCorrispondere, i).getContents();
|
||||
if (giorniDaCorrispondere != null && giorniDaCorrispondere.length() != 0) {
|
||||
sheet.addCell(new Number(6, i, Double.parseDouble(giorniDaCorrispondere), recordNumberFormat)); // Giorni riconosciuti DEFAULT = Giorni da corrispondere
|
||||
} else {
|
||||
sheet.addCell(new Number(6, i, 0, recordNumberFormat)); // Giorni riconosciuti DEFAULT = Giorni da corrispondere
|
||||
}
|
||||
|
||||
//String importoDaCorrispondere = sheet.getCell(11, i).getContents();
|
||||
String formulaImportoRiconosciuto = CellReferenceHelper.getCellReference(6, i)+"*"+importoSingoloGiorno;
|
||||
Formula importoRiconosciuto = new Formula(7, i, formulaImportoRiconosciuto, recordNumberFormat); // Importo riconosciuto DEFAULT = GiorniRiconosciuti * importoSingoloGiorno
|
||||
sheet.addCell(importoRiconosciuto);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] creaExcelFromList(List righe, boolean isDonating) {
|
||||
byte[] output = null;
|
||||
ByteArrayOutputStream baos = null;
|
||||
try {
|
||||
baos = new ByteArrayOutputStream();
|
||||
WritableWorkbook w = Workbook.createWorkbook(baos);
|
||||
WritableSheet sheet = null;
|
||||
if (isDonating) {
|
||||
sheet = w.createSheet(NOME_FOGLIO_STEP_4, 0);
|
||||
} else {
|
||||
sheet = w.createSheet(NOME_FOGLIO_STEP_4, 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < righe.size(); i++) {
|
||||
RigaExcel riga = (RigaExcel) righe.get(i);
|
||||
List colonne = riga.getColonne();
|
||||
for (int j = 0; j < colonne.size(); j++) {
|
||||
CellaExcel cella = (CellaExcel) colonne.get(j);
|
||||
if (cella.isIntestazione()) {
|
||||
sheet.addCell(new Label(j, i, cella.getContents(), headerFormat));
|
||||
} else if (cella.getTipo().equals(CellType.DATE)) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT_PATTERN);
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
Date contents = sdf.parse(cella.getContents().replace('.',':'));
|
||||
sheet.addCell(new DateTime(j, i, contents, recordDateFormat));
|
||||
} else if (cella.getTipo().equals(CellType.LABEL)) {
|
||||
sheet.addCell(new Label(j, i, cella.getContents(), recordFormat));
|
||||
} else if (cella.getTipo().equals(CellType.NUMBER)) {
|
||||
sheet.addCell(new Number(j, i, Double.parseDouble(cella.getContents()), recordNumberFormat));
|
||||
} else if (cella.getTipo().equals(CellType.NUMBER_FORMULA)) {
|
||||
logger.debug(" Trovata formula a colonna ["+j+"] e riga ["+i+"] valore ["+cella.getContents()+"]");
|
||||
sheet.addCell(new Formula(j, i, recalculateFormula( cella.getContents(), i+1), recordNumberFormat));
|
||||
} else {
|
||||
sheet.addCell(new Label(j, i, cella.getContents(), recordFormat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setCellsAutoSize(sheet);
|
||||
|
||||
// Aggiunge foglio per info fatture e note di credito
|
||||
WritableSheet sheet3 = w.createSheet(NOME_FOGLIO_INFO_STEP_4, 1);
|
||||
writeHeaderSheetFatture(sheet3);
|
||||
setCellsAutoSize(sheet3);
|
||||
|
||||
w.write();
|
||||
w.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
} finally {
|
||||
if (baos != null) {
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
public byte[] generaExcelStep4_Donor(List righeExcel, HashMap eventiPenaleInterni) {
|
||||
ByteArrayOutputStream baos = null;
|
||||
try {
|
||||
baos = new ByteArrayOutputStream();
|
||||
WritableWorkbook w = Workbook.createWorkbook(baos);
|
||||
WritableSheet sheet = w.createSheet(NOME_FOGLIO_STEP_4, 0);
|
||||
|
||||
writeHeaderStep4Donor(sheet, (RigaExcelStep4Donor)righeExcel.get(0));
|
||||
|
||||
for (int i = 1; i < righeExcel.size(); i++) {
|
||||
RigaExcelStep4Donor riga = (RigaExcelStep4Donor) righeExcel.get(i);
|
||||
writeBodyStep4Donor(sheet, riga, i, eventiPenaleInterni);
|
||||
}
|
||||
|
||||
setCellsAutoSize(sheet);
|
||||
|
||||
w.write();
|
||||
w.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
} finally {
|
||||
if (baos != null) {
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
private void writeHeaderStep4Donor(WritableSheet sheet, RigaExcelStep4Donor header) throws WriteException {
|
||||
sheet.addCell(new Label(0, 0, header.getCheckFatturazione()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(1, 0, header.getCheckFatturazione()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(2, 0, header.getCausaleStorno()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(3, 0, header.getCausaleStorno()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(4, 0, header.getGiorniDaCorrispondere()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(5, 0, header.getGiorniDaCorrispondere()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(6, 0, "Importo da corrispondere AOM", headerFormat));
|
||||
sheet.addCell(new Label(7, 0, "Importo da corrispondere TIM", headerFormat));
|
||||
sheet.addCell(new Label(8, 0, header.getSoggettoAFranchigia()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(9, 0, header.getSoggettoAFranchigia()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(10, 0, header.getDonatingOspitato()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(11, 0, header.getDonatingOspitato()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(12, 0, header.getRecipientOspitato()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(13, 0, header.getRecipientOspitato()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(14, 0, header.getDonatingRete()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(15, 0, header.getDonatingRete()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(16, 0, header.getRecipientRete()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(17, 0, header.getRecipientRete()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(18, 0, header.getMSISDN(), headerFormat));
|
||||
sheet.addCell(new Label(19, 0, header.getCodiceRichiestaRecipient(), headerFormat));
|
||||
sheet.addCell(new Label(20, 0, header.getDataInvioRicezioneFileEventoIniziale()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(21, 0, header.getDataInvioRicezioneFileEventoIniziale()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(22, 0, header.getNomeFileEventoIniziale()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(23, 0, header.getNomeFileEventoIniziale()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(24, 0, header.getAckEventoIniziale()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(25, 0, header.getAckEventoIniziale()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(26, 0, header.getDataInvioRicezioneFileEventoFinale()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(27, 0, header.getDataInvioRicezioneFileEventoFinale()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(28, 0, header.getNomeFileEventoFinale()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(29, 0, header.getNomeFileEventoFinale()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(30, 0, header.getAckEventoFinale()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(31, 0, header.getAckEventoFinale()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(32, 0, header.getDataAttesaEventoFinale()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(33, 0, header.getDataAttesaEventoFinale()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(34, 0, header.getGiorniRitardoSolari()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(35, 0, header.getGiorniRitardoSolari()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(36, 0, header.getImporto()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(37, 0, header.getImporto()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(38, 0, header.getMeseCompetenzaEventoFinale()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(39, 0, header.getMeseCompetenzaEventoFinale()+" TIM", headerFormat));
|
||||
sheet.addCell(new Label(40, 0, header.getTipoSla(), headerFormat));
|
||||
sheet.addCell(new Label(41, 0, header.getFlagPenaleAltroOperatore()+" AOM", headerFormat));
|
||||
sheet.addCell(new Label(42, 0, header.getFlagPenaleAltroOperatore()+" TIM", headerFormat));
|
||||
}
|
||||
|
||||
private void writeBodyStep4Donor(WritableSheet sheet, RigaExcelStep4Donor riga, int row, HashMap eventiPenaleInterni) throws WriteException {
|
||||
String codiceRichiesta = riga.getCodiceRichiestaRecipient();
|
||||
String sla = riga.getTipoSla();
|
||||
RigaExcelStep4Donor eventoInterno = null;
|
||||
if (eventiPenaleInterni.get( (codiceRichiesta+"-"+sla) ) != null) {
|
||||
eventoInterno = (RigaExcelStep4Donor)eventiPenaleInterni.get( (codiceRichiesta+"-"+sla) );
|
||||
}
|
||||
try {
|
||||
sheet.addCell(new Label(0, row, riga.getCheckFatturazione(), recordFormat));
|
||||
sheet.addCell(new Label(1, row, (eventoInterno!=null) ? eventoInterno.getCheckFatturazione() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Label(2, row, riga.getCausaleStorno(), recordFormat));
|
||||
sheet.addCell(new Label(3, row, (eventoInterno!=null) ? eventoInterno.getCausaleStorno() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Number(4, row, Double.parseDouble(riga.getGiorniDaCorrispondere()), recordNumberFormat));
|
||||
sheet.addCell(new Number(5, row, (eventoInterno!=null) ? Double.parseDouble(eventoInterno.getGiorniDaCorrispondere()) : 0, recordNumberFormat));
|
||||
|
||||
double importoSingoloGiornoAOM = 0;
|
||||
if (Double.valueOf(riga.getImporto()).doubleValue() != 0) {
|
||||
importoSingoloGiornoAOM = Double.valueOf(riga.getImporto()).doubleValue() / Double.valueOf(riga.getGiorniRitardoSolari()).doubleValue();
|
||||
}
|
||||
double importoSingoloGiornoTIM = 0;
|
||||
if (eventoInterno!=null && Double.valueOf(eventoInterno.getImporto()).doubleValue() != 0) {
|
||||
importoSingoloGiornoTIM = Double.valueOf(eventoInterno.getImporto()).doubleValue() / Double.valueOf(eventoInterno.getGiorniRitardoSolari()).doubleValue();
|
||||
}
|
||||
|
||||
sheet.addCell(new Formula(6, row, (CellReferenceHelper.getCellReference(4, row)+"*"+importoSingoloGiornoAOM), recordNumberFormat));
|
||||
sheet.addCell(new Formula(7, row, (eventoInterno!=null) ? (CellReferenceHelper.getCellReference(5, row)+"*"+importoSingoloGiornoTIM) : "0", recordNumberFormat));
|
||||
|
||||
sheet.addCell(new Label(8, row, riga.getSoggettoAFranchigia(), recordFormat));
|
||||
sheet.addCell(new Label(9, row, (eventoInterno!=null) ? eventoInterno.getSoggettoAFranchigia() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Label(10, row, riga.getDonatingOspitato(), recordFormat));
|
||||
sheet.addCell(new Label(11, row, (eventoInterno!=null) ? eventoInterno.getDonatingOspitato() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Label(12, row, riga.getRecipientOspitato(), recordFormat));
|
||||
sheet.addCell(new Label(13, row, (eventoInterno!=null) ? eventoInterno.getRecipientOspitato() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Label(14, row, riga.getDonatingRete(), recordFormat));
|
||||
sheet.addCell(new Label(15, row, (eventoInterno!=null) ? eventoInterno.getDonatingRete() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Label(16, row, riga.getRecipientRete(), recordFormat));
|
||||
sheet.addCell(new Label(17, row, (eventoInterno!=null) ? eventoInterno.getRecipientRete() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Number(18, row, Double.parseDouble(riga.getMSISDN()), recordNumberFormat));
|
||||
sheet.addCell(new Label(19, row, riga.getCodiceRichiestaRecipient(), recordFormat));
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT_PATTERN);
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
Date contents = sdf.parse(riga.getDataInvioRicezioneFileEventoIniziale().replace('.',':'));
|
||||
sheet.addCell(new DateTime(20, row, contents, recordDateFormat));
|
||||
sheet.addCell(new DateTime(21, row, (eventoInterno!=null) ? sdf.parse(eventoInterno.getDataInvioRicezioneFileEventoIniziale().replace('.',':')) : getFakeDate(), recordDateFormat));
|
||||
|
||||
sheet.addCell(new Label(22, row, riga.getNomeFileEventoIniziale(), recordFormat));
|
||||
sheet.addCell(new Label(23, row, (eventoInterno!=null) ? eventoInterno.getNomeFileEventoIniziale() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Label(24, row, riga.getAckEventoIniziale(), recordFormat));
|
||||
sheet.addCell(new Label(25, row, (eventoInterno!=null) ? eventoInterno.getAckEventoIniziale() : "", recordFormat));
|
||||
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
contents = sdf.parse(riga.getDataInvioRicezioneFileEventoFinale().replace('.',':'));
|
||||
sheet.addCell(new DateTime(26, row, contents, recordDateFormat));
|
||||
sheet.addCell(new DateTime(27, row, (eventoInterno!=null) ? sdf.parse(eventoInterno.getDataInvioRicezioneFileEventoFinale().replace('.',':')) : getFakeDate(), recordDateFormat));
|
||||
|
||||
sheet.addCell(new Label(28, row, riga.getNomeFileEventoFinale(), recordFormat));
|
||||
sheet.addCell(new Label(29, row, (eventoInterno!=null) ? eventoInterno.getNomeFileEventoFinale() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Label(30, row, riga.getAckEventoFinale(), recordFormat));
|
||||
sheet.addCell(new Label(31, row, (eventoInterno!=null) ? eventoInterno.getAckEventoFinale() : "", recordFormat));
|
||||
|
||||
// Aggiunto replace del punto per problemi di date pattern con Excel & Win XP
|
||||
contents = sdf.parse(riga.getDataAttesaEventoFinale().replace('.',':'));
|
||||
sheet.addCell(new DateTime(32, row, contents, recordDateFormat));
|
||||
sheet.addCell(new DateTime(33, row, (eventoInterno!=null) ? sdf.parse(eventoInterno.getDataAttesaEventoFinale().replace('.',':')) : getFakeDate(), recordDateFormat));
|
||||
|
||||
sheet.addCell(new Number(34, row, Double.parseDouble(riga.getGiorniRitardoSolari()), recordFormat));
|
||||
sheet.addCell(new Number(35, row, (eventoInterno!=null) ? Double.parseDouble(eventoInterno.getGiorniRitardoSolari()) : 0, recordFormat));
|
||||
|
||||
sheet.addCell(new Number(36, row, Double.parseDouble(riga.getImporto()), recordFormat));
|
||||
sheet.addCell(new Number(37, row, (eventoInterno!=null) ? Double.parseDouble(eventoInterno.getImporto()) : 0, recordFormat));
|
||||
|
||||
sheet.addCell(new Label(38, row, riga.getMeseCompetenzaEventoFinale(), recordFormat));
|
||||
sheet.addCell(new Label(39, row, (eventoInterno!=null) ? eventoInterno.getMeseCompetenzaEventoFinale() : "", recordFormat));
|
||||
|
||||
sheet.addCell(new Label(40, row, riga.getTipoSla(), recordFormat));
|
||||
|
||||
sheet.addCell(new Label(41, row, riga.getFlagPenaleAltroOperatore(), recordFormat));
|
||||
sheet.addCell(new Label(42, row, (eventoInterno!=null) ? eventoInterno.getFlagPenaleAltroOperatore() : "", recordFormat));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeHeaderSheetFatture(WritableSheet sheet) throws WriteException {
|
||||
Label numeroFattura = new Label(1, 1, "Numero Fattura", headerFormatStep3);
|
||||
WritableCellFormat newFormat = new WritableCellFormat(numeroFattura.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.NONE);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
numeroFattura.setCellFormat(newFormat);
|
||||
sheet.addCell( numeroFattura );
|
||||
|
||||
Label dataFattura = new Label(2, 1, "Data Fattura", headerFormatStep3);
|
||||
newFormat = new WritableCellFormat(dataFattura.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.NONE);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
dataFattura.setCellFormat(newFormat);
|
||||
sheet.addCell( dataFattura );
|
||||
|
||||
Label importoFattura = new Label(3, 1, "Importo Fattura", headerFormatStep3);
|
||||
newFormat = new WritableCellFormat(importoFattura.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.NONE);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
importoFattura.setCellFormat(newFormat);
|
||||
sheet.addCell( importoFattura );
|
||||
|
||||
Label numeroNotaDiCredito = new Label(6, 1, "Numero Nota di Credito", headerFormatStep3);
|
||||
newFormat = new WritableCellFormat(numeroNotaDiCredito.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.NONE);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
numeroNotaDiCredito.setCellFormat(newFormat);
|
||||
sheet.addCell( numeroNotaDiCredito );
|
||||
|
||||
Label dataNotaCredito = new Label(7, 1, "Data Nota di Credito", headerFormatStep3);
|
||||
newFormat = new WritableCellFormat(dataNotaCredito.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.NONE);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
dataNotaCredito.setCellFormat(newFormat);
|
||||
sheet.addCell( dataNotaCredito );
|
||||
|
||||
Label importoNotaCredito = new Label(8, 1, "Importo Nota di Credito", headerFormatStep3);
|
||||
newFormat = new WritableCellFormat(importoNotaCredito.getCellFormat());
|
||||
newFormat.setBackground(Colour.GRAY_25);
|
||||
newFormat.setBorder(Border.TOP, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.BOTTOM, BorderLineStyle.NONE);
|
||||
newFormat.setBorder(Border.LEFT, BorderLineStyle.MEDIUM);
|
||||
newFormat.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM);
|
||||
importoNotaCredito.setCellFormat(newFormat);
|
||||
sheet.addCell( importoNotaCredito );
|
||||
}
|
||||
|
||||
/*
|
||||
* Il metodo ricalcola la formula sostituendo l'indice di riga con il nuovo
|
||||
* indice dovuto alla somma degli excel di step 2
|
||||
* Es. oldformula = C24*50.0 , nuovo indice = 9 ==> newFormula C9*50.0
|
||||
*
|
||||
*/
|
||||
private String recalculateFormula(String oldFormula, int newIndex) {
|
||||
StringBuffer output = new StringBuffer();
|
||||
String rifCella = oldFormula.substring(0, oldFormula.indexOf("*")).replaceAll("[0-9]","");
|
||||
output.append(rifCella).append(newIndex).append( oldFormula.substring(oldFormula.indexOf("*")) );
|
||||
return output.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
package it.valueteam.dbcgo.utility.penali;
|
||||
|
||||
import it.valueteam.dbcgo.bean.excel.CellaExcel;
|
||||
import it.valueteam.dbcgo.bean.excel.RigaExcel;
|
||||
import it.valueteam.dbcgo.business.CalcoloDisserviziAomBusiness;
|
||||
import it.valueteam.dbcgo.hb.dao.DbcgoVoMesiRiferimentoDAO;
|
||||
import it.valueteam.dbcgo.hb.dto.DbcgoVoMesiRiferimento;
|
||||
import jxl.*;
|
||||
import jxl.format.Colour;
|
||||
import jxl.format.*;
|
||||
import jxl.format.VerticalAlignment;
|
||||
import jxl.format.Alignment;
|
||||
import jxl.format.Border;
|
||||
import jxl.format.BorderLineStyle;
|
||||
import jxl.write.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class ExcelUtils {
|
||||
|
||||
Logger logger = Logger.getLogger(ExcelUtils.class);
|
||||
public static String TIPO_PROCESSO_RECIPIENT = "RECIPIENT";
|
||||
public static String TIPO_PROCESSO_DONOR = "DONOR";
|
||||
public static Map mesiTrimestri = null;
|
||||
|
||||
public static String NOME_FOGLIO_STEP_1 = "PENALI GREZZE ";
|
||||
public static String NOME_FOGLIO_STEP_2 = "CALCOLO IMPORTI NON FATTURABILI ";
|
||||
public static String NOME_PRIMO_FOGLIO_STEP_3 = "SINTESI";
|
||||
public static String NOME_SECONDO_FOGLIO_STEP_3 = "ev FLAG PENALI";
|
||||
public static String NOME_TERZO_FOGLIO_STEP_3 = "INFO FATTURE";
|
||||
public static String NOME_FOGLIO_STEP_4 = "IN CONTESTAZIONE ";
|
||||
public static String NOME_FOGLIO_INFO_STEP_4 = "FATTURE - NOTE DI CREDITO ";
|
||||
|
||||
public static String NOME_PRIMO_FOGLIO_REPORT_SINTESI = "VISTA TRIMESTRALE";
|
||||
public static String NOME_SECONDO_FOGLIO_REPORT_SINTESI = "VISTA ANNUALE";
|
||||
|
||||
public static String NOME_PRIMO_FOGLIO_REPORT_SINTESI_MENSILE = "VISTA MENSILE";
|
||||
|
||||
public static String DATE_TIME_FORMAT_PATTERN = "dd/MM/yyyy HH:mm";
|
||||
|
||||
public static String DATE_FORMAT_PATTERN = "dd/MM/yyyy";
|
||||
public static String DATE_FORMAT_PATTERN_COMPARE = "yyyyMMdd";
|
||||
|
||||
// Tipologie SLA MNP
|
||||
public static String TIPO_SLA0 = "SLA0";
|
||||
public static String TIPO_SLA1 = "SLA1";
|
||||
public static String TIPO_SLA2 = "SLA2";
|
||||
public static String TIPO_SLA3 = "SLA3";
|
||||
|
||||
// Tipologie SLA TCR
|
||||
public static String TIPO_SLAX = "SLA X";
|
||||
public static String TIPO_SLAY = "SLA Y";
|
||||
public static String TIPO_SLAZ = "SLA Z";
|
||||
|
||||
// CAUSALI STORNO DEFAULT
|
||||
public static String CAUSALE_DISSERVIZI = "DISSERVIZI";
|
||||
public static String CAUSALE_FRANCHIGIA = "FRANCHIGIA";
|
||||
|
||||
// ESITI CONTESTAZIONI
|
||||
public static String ESITO_CONTESTAZIONE_ACCETTATA = "ACCETTATA";
|
||||
public static String ESITO_CONTESTAZIONE_RESPINTA = "RESPINTA";
|
||||
|
||||
static {
|
||||
Map aMap = new HashMap();
|
||||
aMap.put("1Q", new String[]{"GENNAIO", "FEBBRAIO", "MARZO"});
|
||||
aMap.put("2Q", new String[]{"APRILE", "MAGGIO", "GIUGNO"});
|
||||
aMap.put("3Q", new String[]{"LUGLIO", "AGOSTO", "SETTEMBRE"});
|
||||
aMap.put("4Q", new String[]{"OTTOBRE", "NOVEMBRE", "DICEMBRE"});
|
||||
|
||||
mesiTrimestri = Collections.unmodifiableMap(aMap);
|
||||
}
|
||||
|
||||
protected WritableCellFormat headerFormat;
|
||||
protected WritableCellFormat headerFormatStep3;
|
||||
protected WritableCellFormat headerFormatSintesi;
|
||||
protected WritableCellFormat recordFormat;
|
||||
protected WritableCellFormat recordNumberFormat;
|
||||
protected WritableCellFormat recordNumberFormatStep3;
|
||||
protected WritableCellFormat recordDateFormat;
|
||||
protected WritableFont headerFont;
|
||||
protected WritableFont headerFontStep3;
|
||||
protected WritableFont headerFontSintesi;
|
||||
protected WritableFont recordFont;
|
||||
protected WritableFont recordFontStep3;
|
||||
|
||||
protected NumberFormat f = NumberFormat.getPercentInstance(Locale.ITALY);
|
||||
|
||||
public ExcelUtils() {
|
||||
headerFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
|
||||
headerFontStep3 = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
|
||||
headerFontSintesi = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
|
||||
recordFont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
|
||||
recordFontStep3 = new WritableFont(WritableFont.ARIAL, 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
|
||||
headerFormat = new WritableCellFormat(headerFont);
|
||||
headerFormatStep3 = new WritableCellFormat(headerFontStep3);
|
||||
headerFormatSintesi = headerFormatStep3;
|
||||
try {
|
||||
headerFormat.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
headerFormatStep3.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
|
||||
headerFormat.setAlignment(Alignment.CENTRE);
|
||||
headerFormatStep3.setAlignment(Alignment.CENTRE);
|
||||
headerFormatSintesi.setWrap(true);
|
||||
headerFormatSintesi.setBackground(Colour.GRAY_25);
|
||||
headerFormatSintesi.setVerticalAlignment(VerticalAlignment.CENTRE);
|
||||
|
||||
recordFormat = new WritableCellFormat(recordFont);
|
||||
recordNumberFormat = new WritableCellFormat(recordFont, NumberFormats.INTEGER);
|
||||
recordNumberFormatStep3 = new WritableCellFormat(recordFontStep3, NumberFormats.INTEGER);
|
||||
recordDateFormat = new WritableCellFormat(recordFont, new DateFormat(DATE_TIME_FORMAT_PATTERN));
|
||||
} catch (WriteException we) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta la larghezza automatica delle celle.
|
||||
*
|
||||
* @param sheet
|
||||
*/
|
||||
protected void setCellsAutoSize(WritableSheet sheet) {
|
||||
int colNumber = sheet.getColumns();
|
||||
CellView cellView = new CellView();
|
||||
cellView.setAutosize(true);
|
||||
for (int j = 0; j < colNumber; j++) {
|
||||
sheet.setColumnView(j, cellView);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna <code>true</code> se l'excel in input possiede almeno due righe
|
||||
* (una riga oltre l'intestazione). <code>false</code> quando non ci sono eventi in penale
|
||||
*
|
||||
* @param excel l'excel in input
|
||||
* @return true se ho almeno un record
|
||||
*/
|
||||
public boolean isEmptyExcel(byte[] excel) {
|
||||
boolean output = false;
|
||||
ByteArrayInputStream bais = null;
|
||||
try {
|
||||
bais = new ByteArrayInputStream(excel);
|
||||
Workbook workbookStep1 = Workbook.getWorkbook(bais);
|
||||
Sheet sheet = workbookStep1.getSheet(0);
|
||||
output = (sheet.getRows()) > 1 ? false : true;
|
||||
workbookStep1.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (bais != null) {
|
||||
bais.close();
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public void writeToFile(String file, byte[] bytes) {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(bytes);
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
System.out.println("FileNotFoundException : " + ex);
|
||||
} catch (IOException ioe) {
|
||||
System.out.println("IOException : " + ioe);
|
||||
}
|
||||
}
|
||||
|
||||
protected void estraiRighe(byte[] excel, List output, boolean header) {
|
||||
try {
|
||||
Workbook tempWb = Workbook.getWorkbook(new ByteArrayInputStream(excel));
|
||||
Sheet sheetToAdd = tempWb.getSheet(0);
|
||||
int start = (header) ? 0 : 1;
|
||||
|
||||
for (int i = start; i < sheetToAdd.getRows(); i++) {
|
||||
Cell[] row = sheetToAdd.getRow(i);
|
||||
RigaExcel nuovaRiga = new RigaExcel();
|
||||
if (i == 0) {
|
||||
nuovaRiga.setIntestazione(true);
|
||||
}
|
||||
for (int j = 0; j < row.length; j++) {
|
||||
CellaExcel cella = new CellaExcel();
|
||||
if (row[j].getType().equals(CellType.NUMBER_FORMULA)) {
|
||||
NumberFormulaCell formula = (NumberFormulaCell)row[j];
|
||||
cella.setContents(formula.getFormula());
|
||||
} else {
|
||||
cella.setContents(row[j].getContents());
|
||||
}
|
||||
cella.setTipo(row[j].getType());
|
||||
if (i == 0) {
|
||||
cella.setIntestazione(true);
|
||||
}
|
||||
nuovaRiga.addCella(cella);
|
||||
}
|
||||
output.add(nuovaRiga);
|
||||
}
|
||||
tempWb.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Date[] calcolaRangeDateTrimestre(String trimestre, String anno) {
|
||||
Date[] output = new Date[2];
|
||||
DbcgoVoMesiRiferimentoDAO mesiRiferimentoDAO = new DbcgoVoMesiRiferimentoDAO();
|
||||
List criteri = new ArrayList();
|
||||
criteri.add(Restrictions.eq("trimestreRif", trimestre));
|
||||
criteri.add(Restrictions.lt("id", new Long(13)));
|
||||
List mesi = mesiRiferimentoDAO.findByCriteria(criteri);
|
||||
|
||||
DbcgoVoMesiRiferimento primoMese = (DbcgoVoMesiRiferimento)mesi.get(0);
|
||||
Calendar dataInizio = Calendar.getInstance();
|
||||
dataInizio.set(Calendar.DATE, 1);
|
||||
dataInizio.set(Calendar.MONTH, primoMese.getId().intValue()-1);
|
||||
dataInizio.set(Calendar.YEAR, Integer.parseInt(anno));
|
||||
output[0] = dataInizio.getTime();
|
||||
|
||||
DbcgoVoMesiRiferimento ultimoMese = (DbcgoVoMesiRiferimento)mesi.get(2);
|
||||
Calendar dataFine = Calendar.getInstance();
|
||||
dataFine.set(Calendar.DATE, 1);
|
||||
dataFine.set(Calendar.MONTH, ultimoMese.getId().intValue()-1);
|
||||
dataFine.set(Calendar.YEAR, Integer.parseInt(anno));
|
||||
// Imposto l'ultimo giorno del mese
|
||||
dataFine.set(Calendar.DATE, dataFine.getActualMaximum(Calendar.DATE));
|
||||
output[1] = dataFine.getTime();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
protected List recuperaDisservizi(String trimestre, String anno, String operatore, boolean isMNP, boolean isDonating) {
|
||||
// Recupera le informazioni per le date
|
||||
Date[] limitiDate = ExcelUtils.calcolaRangeDateTrimestre(trimestre, anno);
|
||||
|
||||
// Recupera le informazioni sui disservizi
|
||||
CalcoloDisserviziAomBusiness disserviziBusiness = new CalcoloDisserviziAomBusiness();
|
||||
List criteri = new ArrayList();
|
||||
if (isMNP) {
|
||||
criteri.add(Restrictions.in("id.sla", new String[]{"SLA0","SLA1","SLA2", "SLA3"}));
|
||||
} else {
|
||||
criteri.add(Restrictions.in("id.sla", new String[]{"SLA X","SLA Y","SLA Z"}));
|
||||
}
|
||||
criteri.add(Restrictions.eq("id.operatore",operatore));
|
||||
criteri.add(Restrictions.le("id.dataInizio", limitiDate[1]));
|
||||
criteri.add(Restrictions.ge("id.dataFine", limitiDate[0]));
|
||||
criteri.add(Restrictions.eq("disabilitaDisservizio", "N"));
|
||||
if (isDonating) {
|
||||
criteri.add(Restrictions.eq("tipoProcesso", "D"));
|
||||
} else {
|
||||
criteri.add(Restrictions.eq("tipoProcesso", "R"));
|
||||
}
|
||||
|
||||
// List of DbcgoAnagDisservizi
|
||||
return disserviziBusiness.eseguiRicerca(criteri);
|
||||
}
|
||||
|
||||
// Viene utilizzato per generare un range da utilizzare per la ricerca dei disservizi e franchigie.
|
||||
// Per default si cercano le entità a partire da 4 mesi prima (quindi si presuppongono eventi con
|
||||
// penali di massimo 120 giorni)
|
||||
public static Date[] calcolaRangeDateMese(String mese, String anno) {
|
||||
Date[] output = new Date[2];
|
||||
|
||||
Calendar dataInizio = Calendar.getInstance();
|
||||
dataInizio.set(Calendar.DATE, 1);
|
||||
dataInizio.set(Calendar.MONTH, Integer.parseInt(mese)-1);
|
||||
dataInizio.set(Calendar.YEAR, Integer.parseInt(anno));
|
||||
// 4 mesi indietro
|
||||
dataInizio.add(Calendar.MONTH, -4);
|
||||
|
||||
output[0] = dataInizio.getTime();
|
||||
|
||||
Calendar dataFine = Calendar.getInstance();
|
||||
dataFine.set(Calendar.DATE, 1);
|
||||
dataFine.set(Calendar.MONTH, Integer.parseInt(mese)-1);
|
||||
dataFine.set(Calendar.YEAR, Integer.parseInt(anno));
|
||||
// Imposto l'ultimo giorno del mese
|
||||
dataFine.set(Calendar.DATE, dataFine.getActualMaximum(Calendar.DATE));
|
||||
output[1] = dataFine.getTime();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna una data finta 01/01/0001 00:00 per la gestione delle date nulle dei fogli excel
|
||||
* @return
|
||||
*/
|
||||
public Date getFakeDate() {
|
||||
/*Calendar zeroTime = Calendar.getInstance();
|
||||
zeroTime.set(Calendar.YEAR, 1970);
|
||||
zeroTime.set(Calendar.MONTH, 0);
|
||||
zeroTime.set(Calendar.DAY_OF_MONTH, 1);
|
||||
zeroTime.set(Calendar.HOUR_OF_DAY, 0);
|
||||
zeroTime.set(Calendar.MINUTE, 0);
|
||||
zeroTime.set(Calendar.SECOND, 0);
|
||||
return zeroTime.getTime();*/
|
||||
return new Date(0);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user