package com.ejie.ad74a.async;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.ejie.ad74a.dao.AvisosDao;
import com.ejie.ad74a.model.Avisos;

/**
 * Gestión del control de plazos
 * 
 * @author IBERMATICA
 */

@Service(value = "AvisosAsyncProcessService")
public class AvisosAsyncProcessServiceImpl implements AvisosAsyncProcessService {

	private static final Logger logger = LoggerFactory.getLogger(AvisosAsyncProcessServiceImpl.class);

	@Autowired
	private AvisosDao avisosDao;

	@Async("asyncExecutor")
	@Override
	public void procesarAvisoAutomatico(Long idAviso) {
		AvisosAsyncProcessServiceImpl.logger
				.info("AvisosAsyncProcessService.procesarAvisoAutomatico - idAviso " + idAviso + " - inicio");

		Avisos aviso = this.avisosDao.find(new Avisos(idAviso));
		aviso.setUsuProcesado20(com.ejie.ad74a.constantes.Constantes.USER_PROCESADO_AUTOMATICO);
		this.avisosDao.updateProcesado(aviso);
		AvisosAsyncProcessServiceImpl.logger
				.info("AvisosAsyncProcessService.procesarAvisoAutomatico - idAviso " + idAviso + " - fin");
	}

}
