use of org.springframework.scheduling.annotation.Scheduled in project alf.io by alfio-event.
the class AdminJobManager method cleanupExpiredRequests.
@Scheduled(cron = "#{environment.acceptsProfiles('dev') ? '0 * * * * *' : '0 0 0 * * *'}")
void cleanupExpiredRequests() {
log.trace("Cleanup expired requests");
ZonedDateTime now = ZonedDateTime.now(clockProvider.getClock());
int deleted = adminJobQueueRepository.removePastSchedules(now.minusDays(1), executedStatuses);
if (deleted > 0) {
log.trace("Deleted {} executed jobs", deleted);
}
deleted = adminJobQueueRepository.removePastSchedules(now.minusWeeks(1), notExecutedStatuses);
if (deleted > 0) {
log.warn("Deleted {} NOT executed jobs", deleted);
}
}
use of org.springframework.scheduling.annotation.Scheduled in project pmph by BCSquad.
the class FlightTrainTask method consoleInfo.
// 间隔5秒执行
@Scheduled(cron = "1 0 0 1/1 * ? ")
public void consoleInfo() {
String os = System.getProperty("os.name");
if (!os.toLowerCase().startsWith("win")) {
path = "/usr/local/tomcat/logs/";
}
try {
Map<String, Object> api = new HashMap<String, Object>();
api.put("app_key", "nmkt8v9NkWbQ9WPFl3l6lFNsyThsfcep");
api.put("format", "json");
api.put("method", "com.ai.ecp.pmph.order.saleRank");
api.put("session", "MDzjI012CaqX4HG1HbOj35ps1yOYxJ7KfL1ezjKT89OLZZe0f22S6LY6eZ4DleBR");
api.put("sign_method", "md5");
api.put("timestamp", DateUtil.formatTimeStamp("yyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime()));
api.put("v", "1.0");
String sign = DigestUtil.digest(api, "hbP5YsbmiWnkOP4IPtXE126JiIaFRCWD4gpfrcULPbs5hytCw06T2SooKfcUnc2g");
String params = SyncUtils.getUrlApi(api);
params += "&sign=" + sign;
params += "&biz_content=" + CodecUtil.encodeURL("{\"num\":10}");
/* params=CodecUtil.encodeURL(params);*/
String url = "http://aip.pmph.com/route/rest";
String res = SyncUtils.StringGet(params, url);
System.out.println("图书同步销量++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
JSONObject jsonObject = JSON.parseObject(res);
Integer code = jsonObject.getInteger("code");
List<Map<String, Object>> sales = new ArrayList<Map<String, Object>>();
if (code == 0) {
String msg = jsonObject.getString("msg");
JSONArray goodsList = jsonObject.getJSONArray("goodsList");
for (Object o : goodsList) {
Map<String, Object> saleMap = new HashMap<>();
JSONObject jso = JSON.parseObject(o.toString());
String vn = jso.getString("bb_code");
String sale = jso.getString("trade_amount");
saleMap.put("vn", vn);
saleMap.put("sale", sale);
sales.add(saleMap);
}
int i = bookSyncService.updateBookSaleByVns(sales);
}
createFile("SyncSaleLog", new Date().toLocaleString() + "同步图书原始数据:" + res);
} catch (Exception e) {
e.printStackTrace();
}
}
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);
}
}
}
}
use of org.springframework.scheduling.annotation.Scheduled in project cas by apereo.
the class MultifactorAuthenticationTrustStorageCleaner method clean.
/**
* Clean up expired records.
*/
@Scheduled(initialDelayString = "${cas.authn.mfa.trusted.cleaner.schedule.startDelay:PT10S}", fixedDelayString = "${cas.authn.mfa.trusted.cleaner.schedule.repeatInterval:PT60S}")
public void clean() {
if (!trustedProperties.getCleaner().getSchedule().isEnabled()) {
LOGGER.debug("[{}] is disabled. Expired trusted authentication records will not automatically be cleaned up by CAS", getClass().getName());
return;
}
try {
LOGGER.debug("Proceeding to clean up expired trusted authentication records...");
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
final LocalDate validDate = LocalDate.now().minus(trustedProperties.getExpiration(), DateTimeUtils.toChronoUnit(trustedProperties.getTimeUnit()));
LOGGER.info("Expiring records that are on/before [{}]", validDate);
this.storage.expire(validDate);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
use of org.springframework.scheduling.annotation.Scheduled in project webapp by elimu-ai.
the class MailChimpScheduler method executeImport.
// 10 past every hour
@Scheduled(cron = "00 10 * * * *")
public synchronized void executeImport() {
logger.info("executeImport");
if (EnvironmentContextLoaderListener.env != Environment.PROD) {
return;
}
List<Contributor> contributors = contributorDao.readAll();
logger.info("contributors.size(): " + contributors.size());
for (Contributor contributor : contributors) {
try {
// Check if contributor is already subscribed to the mailing list
String memberInfo = MailChimpApiHelper.getMemberInfo(contributor.getEmail());
if (StringUtils.isBlank(memberInfo)) {
MailChimpApiHelper.subscribeMember(contributor);
}
} catch (IOException ex) {
logger.error(null, ex);
break;
}
}
logger.info("executeImport complete");
}
Aggregations