package cn.com.countrygarden.bi.main.controller.manager;

import cn.com.countrygarden.bi.main.service.manager.map.util.ManagerMapUtil;
import cn.com.countrygarden.bi.main.util.RedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * package: cn.com.countrygarden.bi.main.controller.manager.map
 * describe: 管家地图模块数据缓存定时器（半个月同步一次）
 * creat_user: lsl
 * creat_date: 2018/11/19
 * creat_time: 10:36
 **/
public class ManagerMapCacheDataTask{

    Logger logger= LoggerFactory.getLogger(ManagerMapCacheDataTask.class);

    private ManagerMapUtil managerMapUtil;




    public void setManagerMapUtil(ManagerMapUtil managerMapUtil) {
        this.managerMapUtil = managerMapUtil;
    }

    public void cacheManagerMapData() throws InterruptedException {
        logger.info("开始缓存管家地图数据...");
        managerMapUtil.cacheManagerMapData();
        logger.info("结束缓存管家地图数据...");
    }

    public static final String cacheKey="syncManagerKeeper";

    public void cacheHouseKeeperData() throws InterruptedException{
        //先查询Redis中是否有数据 有则返回
        if (RedisUtils.exits(cacheKey)) {
            return;
        }
        RedisUtils.put(cacheKey,"1",60 * 60);
        logger.info("开始缓存管家列表数据...");
        managerMapUtil.cacheHouseKeeperData();
        logger.info("结束缓存管家地图数据...");
        RedisUtils.del(cacheKey);
    }

//    public void test(){
//        System.out.println("=================测试定时器=======================");
//    }
}
