Skip to content

Commit

Permalink
#133 Risolto bug raggruppamento risultati quadrature. #135 Aggiunta p…
Browse files Browse the repository at this point in the history
…ossibilita' di filtrare e raggruppare per tassonomia versamento.
  • Loading branch information
pintorig committed Nov 25, 2019
1 parent 6cf9d81 commit f108641
Show file tree
Hide file tree
Showing 25 changed files with 314 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public ListaRiscossioniDTOResponse listaRiscossioni(ListaRiscossioniDTO listaRis

StatisticaRiscossioniBD statisticaRiscossioniBD = new StatisticaRiscossioniBD(bd);
StatisticaRiscossioniFilter filter = statisticaRiscossioniBD.newFilter();

filter.setOffset(listaRiscossioniDTO.getOffset());
filter.setLimit(listaRiscossioniDTO.getLimit());
filter.setFiltro(listaRiscossioniDTO.getFiltro());

List<IField> gruppiDaFare = new ArrayList<IField>();

for (GROUP_BY gruppo : listaRiscossioniDTO.getGroupBy()) {
switch (gruppo) {
case DIR:
Expand All @@ -47,6 +47,9 @@ public ListaRiscossioniDTOResponse listaRiscossioni(ListaRiscossioniDTO listaRis
case DIV:
gruppiDaFare.add(it.govpay.orm.Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.DIVISIONE);
break;
case TASSONOMIA:
gruppiDaFare.add(it.govpay.orm.Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.TASSONOMIA);
break;
case DOMINIO:
gruppiDaFare.add(it.govpay.orm.Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.ID_UO.ID_DOMINIO.COD_DOMINIO);
break;
Expand All @@ -61,17 +64,23 @@ public ListaRiscossioniDTOResponse listaRiscossioni(ListaRiscossioniDTO listaRis
break;
}
}

List<StatisticaRiscossione> findAll = statisticaRiscossioniBD.statisticaNumeroPagamenti(filter, gruppiDaFare);

for (StatisticaRiscossione riscossione: findAll) {
riscossione.getApplicazione(bd);
riscossione.getDominio(bd);
riscossione.getUo(bd);
riscossione.getTipoVersamento(bd);
}

return new ListaRiscossioniDTOResponse(findAll.size(), findAll);
long count = statisticaRiscossioniBD.count(filter, gruppiDaFare);

List<StatisticaRiscossione> findAll = new ArrayList<StatisticaRiscossione>();

if(count > 0) {
findAll = statisticaRiscossioniBD.statisticaNumeroPagamenti(filter, gruppiDaFare);

for (StatisticaRiscossione riscossione: findAll) {
riscossione.getApplicazione(bd);
riscossione.getDominio(bd);
riscossione.getUo(bd);
riscossione.getTipoVersamento(bd);
}

}
return new ListaRiscossioniDTOResponse(count, findAll);
}finally {
if(bd != null)
bd.closeConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class ListaRiscossioniDTO extends BasicFindRequestDTO{

public enum GROUP_BY { DIV, DIR, DOMINIO, TIPO_PENDENZA, UO, APPLICAZIONE}
public enum GROUP_BY { DIV, DIR, DOMINIO, TIPO_PENDENZA, UO, APPLICAZIONE, TASSONOMIA}

public ListaRiscossioniDTO(Authentication user) {
super(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class FiltroRiscossioni implements Serializable{
private String codTipoVersamento;
private String direzione;
private String divisione;
private String tassonomia;
private Long idApplicazione;
private String codApplicazione;

Expand Down Expand Up @@ -95,4 +96,10 @@ public String getCodApplicazione() {
public void setCodApplicazione(String codApplicazione) {
this.codApplicazione = codApplicazione;
}
public String getTassonomia() {
return tassonomia;
}
public void setTassonomia(String tassonomia) {
this.tassonomia = tassonomia;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ public StatisticaRiscossioniBD(BasicBD basicBD) {
public StatisticaRiscossioniFilter newFilter() throws ServiceException {
return new StatisticaRiscossioniFilter(this.getPagamentoService());
}

public long count(StatisticaRiscossioniFilter filter, List<IField> gruppiDaFare) throws ServiceException {
try {
IExpression expression = filter.toExpression();

for (IField iField : gruppiDaFare) {
expression.addGroupBy(iField);
}

return this.getPagamentoService().count(expression).longValue();
} catch (ExpressionException | ExpressionNotImplementedException | NotImplementedException e) {
throw new ServiceException(e);
}
}

public List<StatisticaRiscossione> statisticaNumeroPagamenti(StatisticaRiscossioniFilter filter, List<IField> gruppiDaFare)throws ServiceException {
List<StatisticaRiscossione> lista = new ArrayList<>();
Expand Down Expand Up @@ -65,8 +79,6 @@ public List<StatisticaRiscossione> statisticaNumeroPagamenti(StatisticaRiscossio
else
entry.setImporto(BigDecimal.ZERO);



if(map.containsKey(JDBCUtilities.getAlias(it.govpay.orm.Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.ID_APPLICAZIONE.COD_APPLICAZIONE))) {
Object applicazioneObj = map.get(JDBCUtilities.getAlias(it.govpay.orm.Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.ID_APPLICAZIONE.COD_APPLICAZIONE));
if(applicazioneObj instanceof String) {
Expand Down Expand Up @@ -109,6 +121,13 @@ public List<StatisticaRiscossione> statisticaNumeroPagamenti(StatisticaRiscossio
}
}

if(map.containsKey(JDBCUtilities.getAlias(it.govpay.orm.Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.TASSONOMIA))) {
Object tassonomiaObj = map.get(JDBCUtilities.getAlias(it.govpay.orm.Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.TASSONOMIA));
if(tassonomiaObj instanceof String) {
entry.setTassonomia((String) tassonomiaObj);
}
}

lista.add(entry);
}
}catch (NotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ public IExpression _toExpression() throws ServiceException {
newExpression.equals(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.DIVISIONE, this.filtro.getDivisione());
addAnd = true;
}

if(this.filtro.getTassonomia() != null){
if(addAnd)
newExpression.and();

newExpression.equals(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.TASSONOMIA, this.filtro.getTassonomia());
addAnd = true;
}

return newExpression;
} catch (NotImplementedException e) {
Expand Down
16 changes: 15 additions & 1 deletion jars/orm/src/main/java/it/govpay/orm/IdVersamento.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* &lt;element name="idTipoVersamento" type="{http://www.govpay.it/orm}id-tipo-versamento" minOccurs="1" maxOccurs="1"/>
* &lt;element name="divisione" type="{http://www.govpay.it/orm}string" minOccurs="0" maxOccurs="1"/>
* &lt;element name="direzione" type="{http://www.govpay.it/orm}string" minOccurs="0" maxOccurs="1"/>
* &lt;element name="tassonomia" type="{http://www.govpay.it/orm}string" minOccurs="0" maxOccurs="1"/>
* &lt;/sequence>
* &lt;/complexType>
* </pre>
Expand All @@ -74,7 +75,8 @@
"idUo",
"idTipoVersamento",
"divisione",
"direzione"
"direzione",
"tassonomia"
}
)

Expand Down Expand Up @@ -202,6 +204,14 @@ public void setDirezione(java.lang.String direzione) {
this.direzione = direzione;
}

public java.lang.String getTassonomia() {
return this.tassonomia;
}

public void setTassonomia(java.lang.String tassonomia) {
this.tassonomia = tassonomia;
}

private static final long serialVersionUID = 1L;

@XmlTransient
Expand Down Expand Up @@ -258,4 +268,8 @@ public void setDirezione(java.lang.String direzione) {
@XmlElement(name="direzione",required=false,nillable=false)
protected java.lang.String direzione;

@javax.xml.bind.annotation.XmlSchemaType(name="string")
@XmlElement(name="tassonomia",required=false,nillable=false)
protected java.lang.String tassonomia;

}
2 changes: 2 additions & 0 deletions jars/orm/src/main/java/it/govpay/orm/binding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
<structure name="idTipoVersamento" field="idTipoVersamento" usage="required" map-as="_IdTipoVersamento_Type"/>
<value name="divisione" field="divisione" usage="optional"/>
<value name="direzione" field="direzione" usage="optional"/>
<value name="tassonomia" field="tassonomia" usage="optional"/>
</mapping>

<mapping type-name="_IdVersamento_Type" class="it.govpay.orm.IdVersamento" abstract="true">
Expand All @@ -218,6 +219,7 @@
<structure name="idTipoVersamento" field="idTipoVersamento" usage="required" map-as="_IdTipoVersamento_Type"/>
<value name="divisione" field="divisione" usage="optional"/>
<value name="direzione" field="direzione" usage="optional"/>
<value name="tassonomia" field="tassonomia" usage="optional"/>
</mapping>
<mapping name="idSingoloVersamento" class="it.govpay.orm.IdSingoloVersamento" abstract="false">
<namespace uri="http://www.govpay.it/orm" default="elements"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,24 +676,40 @@ private void _join(IExpression expression, ISQLQueryObject sqlQueryObject) throw
String tableTipoVersamento = this.getPagamentoFieldConverter().toAliasTable(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.ID_TIPO_VERSAMENTO);
String tableTributi = this.getPagamentoFieldConverter().toAliasTable(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_TRIBUTO);

boolean joinSV = false;
boolean joinV = false;
boolean joinUO = false;


if(expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO,false)){
if(!sqlQueryObject.getTablesName().contains(tableSingoliVersamenti)) {
sqlQueryObject.addFromTable(tableSingoliVersamenti);
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
}

if(!joinSV) {
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
joinSV = true;
}
}

if(expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO,false)){
if(!sqlQueryObject.getTablesName().contains(tableVersamenti)) {
sqlQueryObject.addFromTable(tableVersamenti);
sqlQueryObject.addWhereCondition(tableSingoliVersamenti+".id_versamento="+tableVersamenti+".id");
}

if(!joinV) {
sqlQueryObject.addWhereCondition(tableSingoliVersamenti+".id_versamento="+tableVersamenti+".id");
joinV = true;
}

if(!expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO,false)){
if(!sqlQueryObject.getTablesName().contains(tableSingoliVersamenti)) {
sqlQueryObject.addFromTable(tableSingoliVersamenti);
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
}

if(!joinSV) {
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
joinSV = true;
}
}
}
Expand All @@ -707,7 +723,10 @@ private void _join(IExpression expression, ISQLQueryObject sqlQueryObject) throw
}

if(expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.ID_UO,false)){
sqlQueryObject.addWhereCondition(tableVersamenti+".id_uo="+tableUo+".id");
if(!joinUO) {
sqlQueryObject.addWhereCondition(tableVersamenti+".id_uo="+tableUo+".id");
joinUO = true;
}
}

if(expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.ID_TIPO_VERSAMENTO,false)){
Expand All @@ -717,13 +736,19 @@ private void _join(IExpression expression, ISQLQueryObject sqlQueryObject) throw
if(!expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO,false)){
if(!sqlQueryObject.getTablesName().contains(tableVersamenti)) {
sqlQueryObject.addFromTable(tableVersamenti);
sqlQueryObject.addWhereCondition(tableSingoliVersamenti+".id_versamento="+tableVersamenti+".id");
}
if(!joinV) {
sqlQueryObject.addWhereCondition(tableSingoliVersamenti+".id_versamento="+tableVersamenti+".id");
joinV = true;
}

if(!expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO,false)){
if(!sqlQueryObject.getTablesName().contains(tableSingoliVersamenti)) {
sqlQueryObject.addFromTable(tableSingoliVersamenti);
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
}
if(!joinSV) {
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
joinSV = true;
}
}
}
Expand Down Expand Up @@ -767,18 +792,28 @@ private void _join(IExpression expression, ISQLQueryObject sqlQueryObject) throw
if(!expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.ID_UO,false)){
if(!sqlQueryObject.getTablesName().contains(tableUo)) {
sqlQueryObject.addFromTable(tableUo);
sqlQueryObject.addWhereCondition(tableVersamenti+".id_uo="+tableUo+".id");
}
if(!joinUO) {
sqlQueryObject.addWhereCondition(tableVersamenti+".id_uo="+tableUo+".id");
joinUO = true;
}

if(!expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO,false)){
if(!sqlQueryObject.getTablesName().contains(tableVersamenti)) {
sqlQueryObject.addFromTable(tableVersamenti);
sqlQueryObject.addWhereCondition(tableSingoliVersamenti+".id_versamento="+tableVersamenti+".id");
}
if(!joinV) {
sqlQueryObject.addWhereCondition(tableSingoliVersamenti+".id_versamento="+tableVersamenti+".id");
joinV = true;
}

if(!expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO,false)){
if(!sqlQueryObject.getTablesName().contains(tableSingoliVersamenti)) {
sqlQueryObject.addFromTable(tableSingoliVersamenti);
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
}
if(!joinSV) {
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
joinSV = true;
}
}
}
Expand Down Expand Up @@ -807,7 +842,10 @@ private void _join(IExpression expression, ISQLQueryObject sqlQueryObject) throw
if(!expression.inUseModel(Pagamento.model().ID_SINGOLO_VERSAMENTO,false)){
if(!sqlQueryObject.getTablesName().contains(tableSingoliVersamenti)) {
sqlQueryObject.addFromTable(tableSingoliVersamenti);
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
}
if(!joinSV) {
sqlQueryObject.addWhereCondition(tablePagamenti+".id_singolo_versamento="+tableSingoliVersamenti+".id");
joinSV = true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ public String toColumn(IField field,boolean returnAlias,boolean appendTablePrefi
return "direzione";
}
}
if(field.equals(FR.model().ID_PAGAMENTO.ID_VERSAMENTO.TASSONOMIA)){
if(appendTablePrefix){
return this.toAliasTable(field)+".tassonomia";
}else{
return "tassonomia";
}
}
if(field.equals(FR.model().ID_PAGAMENTO.INDICE_DATI)){
if(appendTablePrefix){
return this.toAliasTable(field)+".indice_dati";
Expand Down Expand Up @@ -398,6 +405,9 @@ public String toTable(IField field,boolean returnAlias) throws ExpressionExcepti
if(field.equals(FR.model().ID_PAGAMENTO.ID_VERSAMENTO.DIREZIONE)){
return this.toTable(FR.model().ID_PAGAMENTO.ID_VERSAMENTO, returnAlias);
}
if(field.equals(FR.model().ID_PAGAMENTO.ID_VERSAMENTO.TASSONOMIA)){
return this.toTable(FR.model().ID_PAGAMENTO.ID_VERSAMENTO, returnAlias);
}
if(field.equals(FR.model().ID_PAGAMENTO.INDICE_DATI)){
return this.toTable(FR.model().ID_PAGAMENTO, returnAlias);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ public String toColumn(IField field,boolean returnAlias,boolean appendTablePrefi
return "direzione";
}
}
if(field.equals(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.TASSONOMIA)){
if(appendTablePrefix){
return this.toAliasTable(field)+".tassonomia";
}else{
return "tassonomia";
}
}
if(field.equals(Pagamento.model().ID_SINGOLO_VERSAMENTO.COD_SINGOLO_VERSAMENTO_ENTE)){
if(appendTablePrefix){
return this.toAliasTable(field)+".cod_singolo_versamento_ente";
Expand Down Expand Up @@ -456,6 +463,9 @@ public String toTable(IField field,boolean returnAlias) throws ExpressionExcepti
if(field.equals(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.DIREZIONE)){
return this.toTable(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO, returnAlias);
}
if(field.equals(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO.TASSONOMIA)){
return this.toTable(Pagamento.model().ID_SINGOLO_VERSAMENTO.ID_VERSAMENTO, returnAlias);
}
if(field.equals(Pagamento.model().ID_SINGOLO_VERSAMENTO.COD_SINGOLO_VERSAMENTO_ENTE)){
return this.toTable(Pagamento.model().ID_SINGOLO_VERSAMENTO, returnAlias);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ public String toColumn(IField field,boolean returnAlias,boolean appendTablePrefi
return "direzione";
}
}
if(field.equals(PagamentoPortaleVersamento.model().ID_VERSAMENTO.TASSONOMIA)){
if(appendTablePrefix){
return this.toAliasTable(field)+".tassonomia";
}else{
return "tassonomia";
}
}


return super.toColumn(field,returnAlias,appendTablePrefix);
Expand Down Expand Up @@ -260,6 +267,9 @@ public String toTable(IField field,boolean returnAlias) throws ExpressionExcepti
if(field.equals(PagamentoPortaleVersamento.model().ID_VERSAMENTO.DIREZIONE)){
return this.toTable(PagamentoPortaleVersamento.model().ID_VERSAMENTO, returnAlias);
}
if(field.equals(PagamentoPortaleVersamento.model().ID_VERSAMENTO.TASSONOMIA)){
return this.toTable(PagamentoPortaleVersamento.model().ID_VERSAMENTO, returnAlias);
}


return super.toTable(field,returnAlias);
Expand Down

0 comments on commit f108641

Please sign in to comment.