@Override @SuppressWarnings("unchecked") public List<PopulationDto> getListePopulations(Long uidPersonneMorale) { final StringBuffer requete = new StringBuffer("select population, count(distinct uidAssure) from Contrat ") .append("where uidSouscripteur = :uidPersonneMorale ") .append("and uidAssure is not null ") .append("and statut.id = :idStatutEnCours ") .append("and nature.id = :idNatureSante ") .append("and isVisible = true ") .append("group by population"); final Query query = createQuery(requete.toString()); query.setLong("uidPersonneMorale", uidPersonneMorale); query.setLong("idStatutEnCours", adherentMappingService.getIdStatutContratEnCours()); query.setLong("idNatureSante", adherentMappingService.getIdNatureContratSante()); final List<Object[]> listResult = query.list(); final List<PopulationDto> listePopulations = new ArrayList<PopulationDto>(); if (listResult != null && listResult.size() > 0) { for (Object[] result : listResult) { final String libellePopulation = (String) result[0]; final Integer effectif = Integer.valueOf((String) result[1].toString()); final PopulationDto population = new PopulationDto(); population.setLibelle(libellePopulation); population.setEffectif(effectif); listePopulations.add(population); } } return listePopulations; }
private Criteria createCriteriaByCriteres(CritereRechercheContratDto criteres) { final Criteria crit = createCriteria(Contrat.class); crit.createAlias("statut", "statut"); if (criteres != null && criteres.getIdAssure() != null) { crit.add(Restrictions.eq("uidAssure", criteres.getIdAssure())); } if (criteres != null && criteres.getIdSouscripteur() != null) { crit.add(Restrictions.eq("uidSouscripteur", criteres.getIdSouscripteur())); } if (criteres != null && criteres.isIdAssureNull()) { crit.add(Restrictions.isNull("uidAssure")); } if (criteres != null && StringUtils.isNotBlank(criteres.getNumeroContrat())) { crit.add(Restrictions.ilike("numeroContrat", criteres.getNumeroContrat() + "%")); } if (criteres != null && criteres.getHasContratEnCours() != null && criteres.getHasContratEnCours()) { crit.add(Restrictions.eq("statut.id", adherentMappingService.getIdStatutContratEnCours())); } if (criteres != null && criteres.getContratEid() != null && StringUtils.isNotBlank(criteres.getContratEid())) { crit.add(Restrictions.like("identifiantExterieur", "%" + criteres.getContratEid() + "%")); } crit.add(Restrictions.eq("isVisible", true)); return crit; }
@Override public Integer getNombreAdherentsContrat(String eidContrat) { final StringBuffer requete = new StringBuffer("select count(distinct uidAssure) from Garantie ") .append("where contrat.identifiantExterieur like :idContrat ") .append("and contrat.uidAssure is not null ") .append("and contrat.statut.id = :idStatutContratEnCours ") .append("and statut.id = :idStatutGarantieEnCours ") .append("and isVisible = true"); final Query query = createQuery(requete.toString()); query.setString("idContrat", eidContrat.substring(0, NB_CARACTERE_ID_CONTRAT) + POURCENT); query.setLong("idStatutContratEnCours", adherentMappingService.getIdStatutContratEnCours()); query.setLong("idStatutGarantieEnCours", adherentMappingService.getIdStatutGarantieEnCours()); final Integer nbAdherents = Integer.valueOf(query.uniqueResult().toString()); return nbAdherents; }
@Override @SuppressWarnings("unchecked") public Contrat getContratSantePersonneInactifXMois( Long idPersonne, Calendar dateInactiviteGarantieSante) { final StringBuffer requete = new StringBuffer("select contrat_numero from data_contrat "); requete.append("where data_contrat.contrat_assure_uid = :idPersonne "); requete.append( "and data_contrat.contrat_statut_uid <> :idStatutEnCours and data_contrat.contrat_nature_uid = :idNatureSante "); // requete.append("and data_contrat.contrat_adhesion_onum <> 'groupe' "); requete.append( "and data_contrat.contrat_date_resiliation < now() and data_contrat.contrat_date_resiliation >= :dateInactiviteGarantieSante "); requete.append("and data_contrat.contrat_visible = true "); requete.append("group by contrat_numero "); final Query crit = createSqlQuery(requete.toString()); crit.setLong("idPersonne", idPersonne); crit.setLong("idStatutEnCours", adherentMappingService.getIdStatutContratEnCours()); crit.setLong("idNatureSante", adherentMappingService.getIdNatureContratSante()); crit.setCalendar("dateInactiviteGarantieSante", dateInactiviteGarantieSante); final List<String> resultats = (ArrayList<String>) crit.list(); return resultats.size() == 1 ? ((Contrat) getContratByNumero(resultats.get(0))) : null; }