Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.*;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;

@Entity
Expand Down Expand Up @@ -154,6 +155,9 @@ public class Stazioni {
@Column(name = "FLAG_STANDIN", nullable = false)
private Boolean flagStandin = false;

@Column(name = "DATA_CREAZIONE")
private Timestamp dataCreazione;

@Column(name = "VERSIONE_PRIMITIVE")
private Integer versionePrimitive;
@OneToMany(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.OffsetDateTime;
import java.util.List;
import java.util.Optional;

Expand All @@ -25,21 +26,37 @@ public interface StazioniRepository extends JpaRepository<Stazioni, Long>, JpaSp
"select distinct s from Stazioni s, PaStazionePa r where (:fkIntermediario is null or"
+ " s.fkIntermediarioPa = :fkIntermediario) and (r.fkPa = :fkPa and r.fkStazione = s)"
+ " and (:idStazione is null or upper(s.idStazione) like concat('%',"
+ " upper(:idStazione), '%')) ")
+ " upper(:idStazione), '%')) "
+ " AND (cast(cast(:createDateBefore as text) as timestamp) IS NULL OR s.dataCreazione < cast(cast(:createDateBefore as text) as timestamp)) "
+ " AND (cast(cast(:createDateAfter as text) as timestamp) IS NULL OR s.dataCreazione > cast(cast(:createDateAfter as text) as timestamp)) "
+ " AND ((:connectionType IS NULL OR :connectionType = 'NONE') "
+ " OR (:connectionType = 'SYNC' AND servizio LIKE '%gpd%')"
+ " OR (:connectionType = 'ASYNC' AND (servizio IS NULL or servizio NOT LIKE '%gpd%')))")
Page<Stazioni> findAllByFilters(
@Param("fkIntermediario") Long fkIntermediario,
@Param("fkPa") Long fkPa,
@Param("idStazione") String idStazione,
@Param("createDateBefore") OffsetDateTime createDateBefore,
@Param("createDateAfter") OffsetDateTime createDateAfter,
@Param("connectionType") String connectionType,
Pageable pageable);

@Query(
value =
"select distinct s from Stazioni s where (:fkIntermediario is null or s.fkIntermediarioPa"
+ " = :fkIntermediario) and (:idStazione is null or upper(s.idStazione) like"
+ " concat('%', upper(:idStazione), '%')) ")
+ " concat('%', upper(:idStazione), '%')) "
+ " AND (cast(cast(:createDateBefore as text) as timestamp) IS NULL OR s.dataCreazione < cast(cast(:createDateBefore as text) as timestamp)) "
+ " AND (cast(cast(:createDateAfter as text) as timestamp) IS NULL OR s.dataCreazione > cast(cast(:createDateAfter as text) as timestamp)) "
+ " AND ((:connectionType IS NULL OR :connectionType = 'NONE') "
+ " OR (:connectionType = 'SYNC' AND servizio LIKE '%gpd%')"
+ " OR (:connectionType = 'ASYNC' AND (servizio IS NULL or servizio NOT LIKE '%gpd%')))")
Page<Stazioni> findAllByFilters(
@Param("fkIntermediario") Long fkIntermediario,
@Param("idStazione") String idStazione,
@Param("createDateBefore") OffsetDateTime createDateBefore,
@Param("createDateAfter") OffsetDateTime createDateAfter,
@Param("connectionType") String connectionType,
Pageable pageable);

@Query(
Expand All @@ -49,12 +66,20 @@ Page<Stazioni> findAllByFilters(
+ " = :fkPa and r.fkStazione = s) and (s.intermediarioPa = i) and (:idStazione is"
+ " null or upper(s.idStazione) like concat('%', upper(:idStazione), '%')) and"
+ " (:codiceIntermediario is null or upper(i.codiceIntermediario) like concat('%',"
+ " upper(:codiceIntermediario), '%')) ")
+ " upper(:codiceIntermediario), '%')) "
+ " AND (cast(cast(:createDateBefore as text) as timestamp) IS NULL OR s.dataCreazione < cast(cast(:createDateBefore as text) as timestamp)) "
+ " AND (cast(cast(:createDateAfter as text) as timestamp) IS NULL OR s.dataCreazione > cast(cast(:createDateAfter as text) as timestamp)) "
+ " AND ((:connectionType IS NULL OR :connectionType = 'NONE') "
+ " OR (:connectionType = 'SYNC' AND servizio LIKE '%gpd%')"
+ " OR (:connectionType = 'ASYNC' AND (servizio IS NULL or servizio NOT LIKE '%gpd%')))")
Page<Stazioni> findAllByFilters(
@Param("fkIntermediario") Long fkIntermediario,
@Param("fkPa") Long fkPa,
@Param("idStazione") String idStazione,
@Param("codiceIntermediario") String codiceIntermediario,
@Param("createDateBefore") OffsetDateTime createDateBefore,
@Param("createDateAfter") OffsetDateTime createDateAfter,
@Param("connectionType") String connectionType,
Pageable pageable);

@Query(
Expand All @@ -63,11 +88,20 @@ Page<Stazioni> findAllByFilters(
+ " (:fkIntermediario is null or s.fkIntermediarioPa = :fkIntermediario) and"
+ " (:idStazione is null or upper(s.idStazione) like concat('%', upper(:idStazione),"
+ " '%')) and (:codiceIntermediario is null or upper(i.codiceIntermediario) like "
+ " concat('%', upper(:codiceIntermediario), '%')) ")
+ " concat('%', upper(:codiceIntermediario), '%')) "
+ " AND (cast(cast(:createDateBefore as text) as timestamp) IS NULL OR s.dataCreazione < cast(cast(:createDateBefore as text) as timestamp)) "
+ " AND (cast(cast(:createDateAfter as text) as timestamp) IS NULL OR s.dataCreazione > cast(cast(:createDateAfter as text) as timestamp)) "
+ " AND ((:connectionType IS NULL OR :connectionType = 'NONE') "
+ " OR (:connectionType = 'SYNC' AND servizio LIKE '%gpd%')"
+ " OR (:connectionType = 'ASYNC' AND (servizio IS NULL or servizio NOT LIKE '%gpd%')))"
)
Page<Stazioni> findAllByFilters(
@Param("fkIntermediario") Long fkIntermediario,
@Param("idStazione") String idStazione,
@Param("codiceIntermediario") String codiceIntermediario,
@Param("createDateBefore") OffsetDateTime createDateBefore,
@Param("createDateAfter") OffsetDateTime createDateAfter,
@Param("connectionType") String connectionType,
Pageable pageable);

@Query(
Expand Down
Loading