package com.yihu.wlyy.task;

import com.yihu.wlyy.service.third.jw.JwArchivesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

/**
 * 健康指标推送
 * Created by hzp on 2016/11/15.
 */
public class HealthIndexUploadTask implements Runnable {

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

    @Autowired
    private JwArchivesService jwArchivesService;
    String id = "";

    public HealthIndexUploadTask(String id) {
        this.id = id;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(3000);
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            jwArchivesService.uploadHealthIndex(id);
            logger.info("healthIndex:"+id+" upload success.");

        } catch (Exception e) {
            e.printStackTrace();
            logger.info("healthIndex:"+id+" upload fail."+e.getMessage());
        }
    }
}
