Search in sources :

Example 16 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project goci by EBISPOT.

the class DailyEnsemblPing method pingEnsembl.

@Scheduled(cron = "0 0 7 * * *")
public void pingEnsembl() {
    RestTemplate restTemplate = new RestTemplate();
    String url = "http://rest.ensembl.org/info/ping?content-type=application/json";
    Ping ping = new Ping();
    try {
        ping = restTemplate.getForObject(url, Ping.class);
        Integer num = ping.getPing();
        getLog().info("Pinging Ensembl: " + url);
        if (num != 1) {
            mailService.sendEnsemblPingFailureMail();
            getLog().error("Pinging Ensembl returned " + num);
        } else {
            getLog().info("Pinging Ensembl returned " + num);
        }
    } catch (Exception e) {
        getLog().error("Pinging Ensembl failed", e);
        mailService.sendEnsemblPingFailureMail();
    }
}
Also used : Ping(uk.ac.ebi.spot.goci.curation.model.Ping) RestTemplate(org.springframework.web.client.RestTemplate) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 17 with Scheduled

use of org.springframework.scheduling.annotation.Scheduled in project sic by belluccifranco.

the class CajaServiceImpl method cerrarCajas.

// Todos los dias a las 00:00:30
@Scheduled(cron = "30 0 0 * * *")
public void cerrarCajas() {
    LOGGER.warn("Cierre automático de Cajas." + LocalDateTime.now());
    List<Empresa> empresas = this.empresaService.getEmpresas();
    for (Empresa empresa : empresas) {
        Caja ultimaCajaDeEmpresa = this.getUltimaCaja(empresa.getId_Empresa());
        if ((ultimaCajaDeEmpresa != null) && (ultimaCajaDeEmpresa.getEstado() == EstadoCaja.ABIERTA)) {
            LocalDate fechaActual = LocalDate.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), LocalDate.now().getDayOfMonth());
            Calendar fechaHoraCaja = new GregorianCalendar();
            fechaHoraCaja.setTime(ultimaCajaDeEmpresa.getFechaApertura());
            LocalDate fechaCaja = LocalDate.of(fechaHoraCaja.get(Calendar.YEAR), fechaHoraCaja.get(Calendar.MONTH) + 1, fechaHoraCaja.get(Calendar.DAY_OF_MONTH));
            if (fechaCaja.compareTo(fechaActual) < 0) {
                this.cerrarCaja(ultimaCajaDeEmpresa.getId_Caja(), this.getTotalCaja(ultimaCajaDeEmpresa, true), ultimaCajaDeEmpresa.getUsuarioAbreCaja().getId_Usuario(), true);
            }
        }
    }
}
Also used : Empresa(sic.modelo.Empresa) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Caja(sic.modelo.Caja) QCaja(sic.modelo.QCaja) EstadoCaja(sic.modelo.EstadoCaja) LocalDate(java.time.LocalDate) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Aggregations

Scheduled (org.springframework.scheduling.annotation.Scheduled)17 Nabaztag (com.nabalive.data.core.model.Nabaztag)4 Date (java.util.Date)4 Application (com.nabalive.application.core.Application)3 Status (com.nabalive.server.jabber.Status)3 ArrayList (java.util.ArrayList)3 SimpleDateFormat (java.text.SimpleDateFormat)2 LocalDate (java.time.LocalDate)2 SpeciesListDTO (au.org.ala.spatial.dto.SpeciesListDTO)1 LogicalDevice (com.alliander.osgp.simulator.protocol.iec61850.server.logicaldevices.LogicalDevice)1 SprintDTO (com.bbva.arq.devops.ae.mirrorgate.core.dto.SprintDTO)1 SleepPacket (com.nabalive.server.jabber.packet.SleepPacket)1 InstanceInfo (com.netflix.appinfo.InstanceInfo)1 File (java.io.File)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1