ScheduledTask.java 1.64 KB
package com.xkl.config;

import com.xkl.domain.XklAmpReportMetaItemsEntity;
import com.xkl.domain.XklAmpReportMetaScoreStandardEntity;
import com.xkl.repository.XklAmpReportMetaItemsRespository;
import com.xkl.repository.XklAmpReportMetaScoreStandardRespository;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Iterator;


/**
 * Created by win7 on 2016/11/21.
 * 定时任务读取打分标准
 */
@Component
@CommonsLog
public class ScheduledTask implements Constants{
    @Autowired
    private XklAmpReportMetaScoreStandardRespository scoreStandardRespository;
    @Autowired
    private XklAmpReportMetaItemsRespository metaItemsRespository;

    @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
    public void getTableMap(){
        log.info("Load ScoreStandard Table");
        Iterator<XklAmpReportMetaScoreStandardEntity> it=scoreStandardRespository.findAll().iterator();
        while(it.hasNext()){
            XklAmpReportMetaScoreStandardEntity scoreStandard=it.next();
            scoreMap.put(scoreStandard.getItemId(),scoreStandard);
        }
    }

    @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000)
    public void getItemMetaMap(){
        log.info("Load ItemMeta Table");
        Iterator<XklAmpReportMetaItemsEntity> it = metaItemsRespository.findAll().iterator();
        while(it.hasNext()){
            XklAmpReportMetaItemsEntity reportMetaItems = it.next();
            itemMetaMap.put(reportMetaItems.getItemId(),reportMetaItems);
        }
    }
}