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();
}
}
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);
}
}
}
}
Aggregations